if echo ab | grep -E '(a|b)b' > /dev/null 2>&1 ; then
    EGREP='grep -E'
else
    EGREP=egrep
fi
$EGREP '<<(domain|package|category) .*>>=' *.spad.pamphlet | sort | uniq | \
awk -F: '{
  chunk=substr($2,3,length($2)-5);
  split(chunk,part," ");
  spadfile=part[2]".spad";
  print spadfile": $(srcdir)/"$1;
  print "\t$(axiom_build_document) --output=$@ --tangle=\""chunk"\" $<";
  print "";
}'
