#!c:sksh

# by WB
# function to echo dependencies of infile/* to man:2/auto2/*

mandir=man
inlinedir=inline
protodir=proto
fddir=fd


for file in $mandir/*.doc
do
  if head $file | fgrep -s library/
  then
    echo $file
  fi
done >t:mandeps

bases=`
  for i in $(cat t:mandeps)
  do
    Basename $i .doc
  done
`
echo -n "ALL= "
for base in $bases
do
  echo	"$inlinedir/$base.h \\"
  echo	"$protodir/$base.h  \\"
done

echo
echo
echo "$inlinedir/%.h: $protodir/%.h $fddir/%_lib.fd"
echo "\tfd2inline $fddir/\$*_lib.fd $protodir/\$*.h >$inlinedir/\$*.h"
echo
echo "$protodir/%.h: $mandir/%.doc"
echo "\t+auto2proto $mandir/\$\*.doc >$protodir/\$*.h"
echo
echo "all: $(ALL)"
echo

for base in $bases
do
  echo	  "$protodir/$base.h: $mandir/$base.doc"
  echo -c "$inlinedir/$base.h: $protodir/$base.h $fddir/$base" "_lib.fd"
done

