#  Makefile_head from ObjectProDSP 0.1
#  Copyright (C) 1994, Mountain Math Software. All rights reserved.
#  
#  This file is part of ObjectProDSP, a tool for Digital Signal
#  Processing design, development and implementation. It is free
#  software provided you use and distribute it under the terms of
#  version 2 of the GNU General Public License as published
#  by the Free Software Foundation. You may NOT distribute it or
#  works derived from it or code that it generates under ANY
#  OTHER terms.  In particular NONE of the ObjectProDSP system is
#  licensed for use under the GNU General Public LIBRARY License.
#  Mountain Math Software plans to offer a commercial version of
#  ObjectProDSP for a fee. That version will allow redistribution
#  of generated code under standard commercial terms.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of version 2 of the GNU General
#  Public License along with this program. See file COPYING. If not
#  or if you wish information on commercial versions and licensing
#  write Mountain Math Software, P. O. Box 2124, Saratoga, CA 95070,
#  USA, or send us e-mail at: support@mtnmath.com.
#  
#  You may also obtain the GNU General Public License by writing the
#  Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
#  USA.  However if you received a copy of this program without the
#  file COPYING or without a copyright notice attached to all text
#  files, libraries and executables please inform Mountain Math Software.
#  
#  ObjectProDSP is a trademark of Mountain Math Software.
#  

# The `over_front' and `ovr_app' files form one document. The index
# is common to both. Thus `ovr_app.dvi' dependes on `over_front.idx'.
# It is done this way to get separate table of contents for the main
# document and the appendix

DEFAULT : check_index_ovr_app check_index_nodeman 

OPD_PSFIG := ${PSFIG_DIR}/dsp_case_ps \
	${shell ${DOC_DIR}/scripts/xwd_to_ps.sh ECHO_PS}

OPD_OVR_NOT_CREATED= brbody.tex ovrcom.tex \
  purpose.tex example.tex example2.tex edit_net.tex brocinx.tex

OPD_APP_NOT_CREATED=therest.tex desnode.tex shrtnode.tex ovr_app.tex

ovr_front.dvi : ovr_front.tex ${OPD_DOC_COM_DEP} ${OPD_OVR_NOT_CREATED} \
	${OPD_PSFIG}
	${OPD_LATEX} $@

ovr_front.dvi : ovr_front.idx



ovr_app.dvi: ovr_front.idx ovr_app.tex over_all.txx \
  ${OPD_APP_NOT_CREATED} ${TRADEMARK_DIR}/mtnmath.tex \
  ovr_app.txx \
	${NODE_TEXS_DEP} \
	${SIGNAL_TEXS_DEP} \
	${DISPLAY_TEXS_DEP} \
	${AUX_FUNC_TEXS_DEP} \
  nodes.tex signals.tex displays.tex basenods.tex auxfuncs.tex
	${OPD_LATEX} $@
	make check_index_ovr_app


ovr_app.txx :
	touch $@

over_all.txx :
	touch $@

check_index_ovr_app: ovr_front.idx
	if [ -e ovr_app.idx ]  ;then \
		if [ -e ovr_front.idx ]  ;then \
			if [ -e over_all.idx ] ;then \
				 mv over_all.idx old_over_all.idx ;fi ; \
			cp ovr_front.idx over_all.idx ; \
			cat ovr_app.idx >> over_all.idx ; \
			${OPD_CHECK_INDEX} over_all ;fi ;fi
	make ovr_front.dvi
	make ovr_app.dvi

OPD_LIB_NOT_CREATED=nodeman.tex lngnode.tex nodmnx.tex refintro.tex \
	ovnode.tex

OPD_NOT_CREATED=${OPD_OVR_NOT_CREATED} ${OPD_APP_NOT_CREATED} \
	${OPD_LIB_NOT_CREATED}

ovnodlst.tex : ${OPD_ROOT}/doc/roff/mmake/node_list
	awk '{ if ( $$1 != "#") print "\\input{" $$1 "}"}' < $< > $@

nodeman.dvi : nodeman.txx ovnodlst.tex \
	${OPD_DOC_COM_DEP} nodeman.tex ${NODE_HELP} \
	lngnode.tex \
	${NODE_TEX_DEP} \
	${SIGNAL_TEX_DEP} \
	${DISPLAY_TEX_DEP} \
	${AUX_FUNC_TEX_DEP} \
		node.tex signal.tex display.tex auxfunc.tex basenod.tex \
	nodmnx.tex \
		nodeman.txx \
	refintro.tex ovnode.tex 
	${OPD_LATEX} $@

check_index_nodeman :
	${OPD_CHECK_INDEX} nodeman
	make nodeman.dvi

ovr_front.idx :
	touch ovr_frint.idx

nodeman.idx :
	touch nodeman.idx

# Do this if you move any .usr files to a different directory
# Then make an executable before you generate the documentation again.
CHANGE_USR_LOCATIONS:
	-rm node.tex signal.tex display.tex auxfunc.tex basenod.tex
	-rm nodes.tex signals.tex displays.tex auxfuncs.tex basenods.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/proc/tex/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/proc/texs/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/proc/target/*.C
	-rm ${OPD_ROOT}/src/dsp/nodes/proc32/tex/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/proc32/texs/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/proc32/target/*.C
	-rm ${OPD_ROOT}/src/dsp/nodes/signal/tex/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/signal/texs/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/signal/target/*.C
	-rm ${OPD_ROOT}/src/dsp/nodes/sigdsk/tex/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/sigdsk/texs/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/sigdsk/target/*.C
	-rm ${OPD_ROOT}/src/dsp/nodes/ionode/tex/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/ionode/texs/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/ionode/target/*.C
	-rm ${OPD_ROOT}/src/dsp/nodes/display/tex/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/display/texs/*.tex
	-rm ${OPD_ROOT}/src/dsp/nodes/display/target/*.C
	-rm ${OPD_ROOT}/src/dsp/lib/network/tex/*.tex
	-rm ${OPD_ROOT}/src/dsp/lib/network/texs/*.tex
	-rm ${OPD_ROOT}/src/dsp/lib/network/target/*.C
	cd ${OPD_ROOT}/build ; make TOUCH_USR TOUCH_DOMAKEMAKE

######### start of tex

NODE_TEX_DEP=$(wildcard ${OPD_ROOT}/src/dsp/nodes/proc/tex/*.tex) \
  $(wildcard ${OPD_ROOT}/src/dsp/nodes/proc32/tex/*.tex)
node.tex: ${NODE_TEX_DEP}
	@${OPD_ROOT}/bin/nod_sort -s tex $@ \
		-d ${OPD_ROOT}/src/dsp/nodes/proc \
		-d ${OPD_ROOT}/src/dsp/nodes/proc32  \
		-e ${OPD_ROOT}/src/dsp/nodes/proc/tex/procstr.tex

SIGNAL_TEX_DEP = $(wildcard ${OPD_ROOT}/src/dsp/nodes/signal/tex/*.tex) \
  $(wildcard ${OPD_ROOT}/src/dsp/nodes/sigdsk/tex/*.tex) \
  ${OPD_ROOT}/src/dsp/nodes/ionode/tex/innode.tex

signal.tex : ${SIGNAL_TEX_DEP}
	@${OPD_ROOT}/bin/nod_sort -s tex $@ \
		-d ${OPD_ROOT}/src/dsp/nodes/signal \
		-e ${OPD_ROOT}/src/dsp/nodes/signal/tex/signode.tex \
		-d ${OPD_ROOT}/src/dsp/nodes/sigdsk \
		-f ${OPD_ROOT}/src/dsp/nodes/ionode/tex/innode.tex 

DISPLAY_TEX_DEP = $(wildcard ${OPD_ROOT}/src/nodes/dsp/display/tex/*.tex) \
  ${OPD_ROOT}/src/dsp/nodes/ionode/tex/outnode.tex

display.tex : ${DISPLAY_TEX_DEP}
	@${OPD_ROOT}/bin/nod_sort -s tex $@ \
		-d ${OPD_ROOT}/src/dsp/nodes/display \
		-e ${OPD_ROOT}/src/dsp/nodes/display/tex/dsplstr.tex \
		-f ${OPD_ROOT}/src/dsp/nodes/ionode/tex/outnode.tex

AUX_FUNC_TEX_DEP = $(wildcard ${OPD_ROOT}/src/nodes/lib/control/tex) \
    $(wildcard ${OPD_ROOT}/src/nodes/lib/network/tex)

auxfunc.tex : ${AUX_FUNC_TEX_DEP}
	@${OPD_ROOT}/bin/nod_sort -s tex $@ \
	 -d ${OPD_ROOT}/src/dsp/lib/control \
	 -d ${OPD_ROOT}/src/dsp/lib/network 

basenod.tex : ${OPD_ROOT}/src/dsp/nodes/proc/tex/procstr.tex \
  ${OPD_ROOT}/src/dsp/nodes/signal/tex/signode.tex
	@${OPD_ROOT}/bin/nod_sort -s tex $@ \
	-f ${OPD_ROOT}/src/dsp/nodes/proc/tex/procstr.tex \
	-f ${OPD_ROOT}/src/dsp/nodes/signal/tex/signode.tex \
	-f ${OPD_ROOT}/src/dsp/nodes/display/tex/dsplstr.tex


######## Start of texs

NODE_TEXS_DEP=$(wildcard ${OPD_ROOT}/src/dsp/nodes/proc/texs/*.tex) \
  $(wildcard ${OPD_ROOT}/src/dsp/nodes/proc32/texs/*.tex)

nodes.tex: ${NODE_TEXS_DEP}
	@${OPD_ROOT}/bin/nod_sort -s texs $@ \
		-d ${OPD_ROOT}/src/dsp/nodes/proc \
		-d ${OPD_ROOT}/src/dsp/nodes/proc32  \
		-e ${OPD_ROOT}/src/dsp/nodes/proc/texs/procstr.tex

SIGNAL_TEXS_DEP = $(wildcard ${OPD_ROOT}/src/dsp/nodes/signal/texs/*.tex) \
  $(wildcard ${OPD_ROOT}/src/dsp/nodes/sigdsk/texs/*.tex) \
  ${OPD_ROOT}/src/dsp/nodes/ionode/texs/innode.tex

signals.tex : ${SIGNAL_TEXS_DEP}
	@${OPD_ROOT}/bin/nod_sort -s texs $@ \
		-d ${OPD_ROOT}/src/dsp/nodes/signal \
		-e ${OPD_ROOT}/src/dsp/nodes/signal/texs/signode.tex \
		-d ${OPD_ROOT}/src/dsp/nodes/sigdsk \
		-f ${OPD_ROOT}/src/dsp/nodes/ionode/texs/innode.tex 

DISPLAY_TEXS_DEP = $(wildcard ${OPD_ROOT}/src/nodes/dsp/display/texs/*.tex) \
  ${OPD_ROOT}/src/dsp/nodes/ionode/texs/outnode.tex

displays.tex : ${DISPLAY_TEXS_DEP}
	@${OPD_ROOT}/bin/nod_sort -s texs $@ \
		-d ${OPD_ROOT}/src/dsp/nodes/display \
		-e ${OPD_ROOT}/src/dsp/nodes/display/texs/dsplstr.tex \
		-f ${OPD_ROOT}/src/dsp/nodes/ionode/texs/outnode.tex

AUX_FUNC_TEXS_DEP = $(wildcard ${OPD_ROOT}/src/nodes/lib/control/texs) \
    $(wildcard ${OPD_ROOT}/src/nodes/lib/network/texs)

auxfuncs.tex : ${AUX_FUNC_TEXS_DEP}
	@${OPD_ROOT}/bin/nod_sort -s texs $@ \
	 -d ${OPD_ROOT}/src/dsp/lib/control \
	 -d ${OPD_ROOT}/src/dsp/lib/network 

basenods.tex : ${OPD_ROOT}/src/dsp/nodes/proc/texs/procstr.tex \
  ${OPD_ROOT}/src/dsp/nodes/signal/texs/signode.tex
	@${OPD_ROOT}/bin/nod_sort -s texs $@ \
	-f ${OPD_ROOT}/src/dsp/nodes/proc/texs/procstr.tex \
	-f ${OPD_ROOT}/src/dsp/nodes/signal/texs/signode.tex \
	-f ${OPD_ROOT}/src/dsp/nodes/display/texs/dsplstr.tex

over_all.dvi :
	make ovr_app.dvi

nodeman.ps : nodeman.dvi
	dvips -f $< > $@

ovr_front.ps : ovr_front.dvi
	dvips -f $< > $@

ovr_app.ps : ovr_app.dvi
	dvips -f $< > $@

PS : ovr_front.ps ovr_app.ps nodeman.ps

OVER_ODD_EVEN_PS : over_even.ps over_odd.ps app_even.ps app_odd.ps

over_even.ps : ovr_front.dvi
	dvips -f -c 4 -B -r $<  > $@

over_odd.ps : ovr_front.dvi
	dvips -f -c 4 -A -r $< > $@

app_even.ps : ovr_app.dvi
	dvips -f -c 4 -B -r $< > $@

app_odd.ps : ovr_app.dvi
	dvips -f -c 4 -A -r $< > $@

DIST_LIST: 
	@echo "Makefile_head domakemake ${OPD_OVR_NOT_CREATED} \
		${OPD_APP_NOT_CREATED} ${OPD_LIB_NOT_CREATED} \
		ovr_front.tex ovr_app.tex" > DIST_LIST

ADD_NODES:
	-rm -f nodes.tex signals.tex displays.tex basenods.tex auxfuncs.tex \
	node.tex signal.tex display.tex auxfunc.tex basenod.tex 
	
Makefile : ${OPD_COM_MAKEFILE_DEP} \
  ${DOC_DIR}/scripts/xwd_to_ps.sh ${DOC_DIR}/mac/Makefile_xwd
	sh domakemake

.PHONY: clean check_index_nodeman check_index_ovr_app \
	over_all.dvi DEFAULT ADD_NODES DIST_LIST OVER_ODD_EVEN_PS \
	PS SPELL

clean: ADD_NODES
	-rm -f *.dvi *.ps \
		*.aux *.idx *.toc *.txx *.lof *.lot *.log *.slog 

include ${OPD_ROOT}/doc/mac/makefile_suf_base
