#!/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|*.8|*.man)
    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,@version@,man-1.6e,
s,@CC@,gcc -O,
s,@BUILD_CC@,gcc -O,
s,@INSTALL@,install,
s,@DEFS@, -DSTDC_HEADERS -DTERMIOS_HEADER -DPOSIX -DDO_COMPRESS,
s,@LIBS@,,
s,@LIBOBJS@,,
s,@troff@,/usr/bin/groff -Tps -mandoc -c,
s,@nroff@,/usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c,
s,@jnroff@,/usr/bin/groff -Tnippon -mandocj -c,
s,@eqn@,/usr/bin/eqn -Tps,
s,@neqn@,/usr/bin/eqn -Tascii,
s,@jneqn@,/usr/bin/eqn -Tnippon,
s,@tbl@,/usr/bin/tbl,
s,@nocol@,# ,
s,@pcol@,,
s,@col@,/usr/bin/col,
s,@vgrind@,/usr/bin/vgrind,
s,@refer@,/usr/bin/refer,
s,@grap@,,
s,@pic@,/usr/bin/pic,
s,@fcat@,,
s,@pcat@,,
s,@zcat@,/usr/bin/zcat,
s,@gunzip@,/usr/bin/gunzip -c,
s,@bzip2@,/usr/bin/bzip2 -c -d,
s,@unyabba@,,
s,@compress@,/usr/bin/bzip2,
s,@compress_ext@,.bz2,
s,@decompress@,/usr/bin/bzip2 -c -d,
s,@pager@,/usr/bin/less -is,
s,@browser@,/opt/local/bin/lynx,
s,@htmlpager@,/opt/local/bin/lynx -dump,
s,@cmp@,/usr/bin/cmp -s,
s,@cat@,/bin/cat,
s,@awk@,/usr/bin/awk,
s,@bindir@,/opt/local/bin,
s,@sbindir@,/opt/local/sbin,
s,@mandir@,/opt/local/share/man,
s,@locale@,/opt/local/share/locale,
s,@fhs@,,
s,@fsstnd@,# ,
s,@man1ext@,1,g
s,@man5ext@,5,g
s,@man8ext@,8,g
s,@man_install_flags@,,
s,@man_user@,,
s,@languages@,??,
s,@man@,/opt/local/bin/man,
s,@apropos@,/opt/local/bin/apropos,
s,@whatis@,/opt/local/bin/whatis,
s,@man2dvi@,/opt/local/bin/man2dvi,
s,@makewhatis@,/opt/local/sbin/makewhatis,
s,@man_config_dir@,/opt/local/etc,
s,@man_config_file@,/opt/local/etc/man.conf,
s,@manpathoption@,--path,
s/@sections@/1:1p:8:2:3:3p:4:5:6:7:9:0p:tcl:n:l:p:o/
' $infile.in >> $infile
done
