#!/bin/sh
infiles=$@
trap 'rm -f $infiles; exit 1' 1 3 15

echo ""
for infile in $infiles
do
  case $infile in
  *.h)
    cb="/*"; cs=" *"; ce=" */";;
  *.1|*.5)
    cb=.\\\"; cs=.\\\"; ce=.\\\";;
  *)
    cb="#"; cs="#"; ce="#";;
  esac
  echo "$cb"                                                    > $infile
  echo "$cs Generated automatically from $infile.in by the"     >> $infile
  echo "$cs configure script."                                  >> $infile
  echo "$ce"                                                    >> $infile
  echo "Creating $infile from $infile.in"
  sed -e '
s,@CC@,cc,
s,@INSTALL@,install,
s,@DEFS@, -DSTDC_HEADERS -DPOSIX -DUSG -DALLOCA_MISSING -DNONLS -DNOGETOPT -DDO_COMPRESS,
s,@LIBS@,,
s,@LIBOBJS@,,
s,@troff@,/usr/local/bin/groff -Tps -mandoc,
s,@nroff@,/usr/local/bin/groff -Tlatin1 -mandoc,
s,@eqn@,/usr/local/bin/geqn -Tps,
s,@neqn@,/usr/local/bin/geqn -Tlatin1,
s,@tbl@,/usr/local/bin/gtbl,
s,@nocol@,# ,
s,@pcol@,,
s,@col@,/usr/local/bin/col,
s,@vgrind@,/usr/local/bin/vgrind,
s,@refer@,/usr/local/bin/grefer,
s,@grap@,,
s,@pic@,/usr/local/bin/gpic,
s,@fcat@,/usr/bin/fcat,
s,@zcat@,,
s,@gunzip@,,
s,@unyabba@,,
s,@compress@,/usr/local/bin/gzip,
s,@compress_ext@,.gz,
s,@pager@,/bin/less -is,
s,@cmp@,/bin/cmp -s,
s,@bindir@,/usr/bin,
s,@libdir@,/usr/lib,
s,@locale@,,
s,@fsstnd@,# ,
s,@mandir@,/usr/man,
s,@man1ext@,1,g
s,@man5ext@,5,g
s,@man_install_flags@,,
s,@man_user@,,
s,@languages@,en,
s,@man@,/usr/bin/man,
s,@apropos@,/usr/bin/apropos,
s,@whatis@,/usr/bin/whatis,
s,@makewhatis@,/usr/lib/makewhatis,
s,@man_config_file@,/usr/lib/man.config,
s,@manpathoption@,-w,
s/@sections@/1:2:3:4:5:6:7:8:9:tcl:n:l:p:o/
' $infile.in >> $infile
done
