#  domakemake from ObjectProDSP 0.1
#  Copyright (C) 1994, Mountain Math Software, All rights reserved.
#  Licensed for free use and distribution under version 2 of the Gnu General
#  Public License. Please see file COPYING for details and restrictions.
#  
#  ObjectProDSP is a trademark of Mountain Math Software.
#  
cp $OPD_ROOT/doc/mac/Makefile_preamble Makefile
#
function define_section() { # list dir start end
	$OPD_ROOT/bin/cp_part "$3" "$4" < $1  |
	awk '{ if ( $1 != "#") print "\t${'$2'}/" $1 ".tex \\" }' >> Makefile
	echo >> Makefile
	echo >> Makefile
}

echo -n "EXAMP_DEP=" >> Makefile
awk '{ if ( $1 != "#") print "\t${EXAMP_DIR}/" $1 ".tex \\" }' \
	< $OPD_ROOT/doc/roff/mmake/examp_list >> Makefile
echo >> Makefile
echo >> Makefile
#
echo -n "FH_USAGE=" >> Makefile
define_section $OPD_ROOT/doc/roff/mmake/help_list HELP_DIR \
	'# start to include in usage section userman' \
	'# end to include in usage section userman'
#
echo -n "FH_RELEASE=" >> Makefile
define_section $OPD_ROOT/doc/roff/mmake/help_list HELP_DIR \
	'# start to include in release notes section userman' \
	'# end to include in release notes section userman'
#
echo -n "FH_NET_EDIT=" >> Makefile
define_section $OPD_ROOT/doc/roff/mmake/help_list HELP_DIR \
	'# start to include in net edit section userman' \
	'# end to include in net edit section userman'
#
echo -n "FH_DATABASE=" >> Makefile
define_section $OPD_ROOT/doc/roff/mmake/help_list HELP_DIR \
	'# start to include in database section userman' \
	'# end to include in database section userman'
#
echo -n "FH_MEMBER=" >> Makefile
define_section $OPD_ROOT/doc/roff/mmake/help_list HELP_DIR \
	'# start to include in member section userman' \
	'# end to include in member section userman'
#
OPD_ROFF_HELP=`awk '{ if ( $1 != "#") printf "%s ",  $1}' \
     < $OPD_ROOT/doc/roff/mmake/help_list`
echo "HELP_DEP=\\" >> Makefile
for i in $OPD_ROFF_HELP ;do echo "  \${HELP_DIR}/$i.tex \\" >> Makefile ;done
OPD_ALL_FH="usage release net_edit database member"
echo -n "  " >> Makefile
for i in $OPD_ALL_FH ;do echo -n "fh_$i.tex " >> Makefile ;done
echo >> Makefile
echo >> Makefile
#
cat Makefile_head >> Makefile
for i in $OPD_ALL_FH ;do
	I=FH_`$OPD_ROOT/bin/to_low_arg -u $i`
	echo "fh_$i.tex : \${$I}" >> Makefile
	echo "	sh \${DOC_DIR}/scripts/make_tex_input_list.sh \"\${$I}\" > \$@" \
		>> Makefile
done
#
for i  in $OPD_ROFF_HELP ; do
    echo "\${HELP_DIR}/$i.tex: \${OPD_ROOT}/doc/roff/$i.roff" >> Makefile
    echo "	cd \${OPD_ROOT}/doc/roff ; make \$@" >> Makefile
done
echo >> Makefile
#
OPD_ROFF_EXAMP=`awk '{ if ( $1 != "#") printf "%s ",  $1}' \
     < $OPD_ROOT/doc/roff/mmake/examp_list`

for i  in $OPD_ROFF_EXAMP ; do
    echo "\${EXAMP_DIR}/$i.tex: \${OPD_ROOT}/doc/roff/$i.roff" >> Makefile
    echo "	cd \${OPD_ROOT}/doc/roff ; make \$@" >> Makefile
done
echo >> Makefile
 
