#  Makefile 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.
#  
TO_BUILD=${OPD_ROOT}/bin/mknode ${OPD_ROOT}/bin/domenus

LIB_FLT=${OPD_ROOT}/lib/LibTarLnxFlt 

LIB_FLT_AUX= ${OPD_ROOT}/lib/LibTarNobench2Flt \
	${OPD_ROOT}/lib/LibTarnobenchmFlt
# build automaticaly when LIBFLT is built

ifdef INCLUDE_INT16
LIB_INT16=${OPD_ROOT}/lib/LibTarLnxInt16 

LIB_INT16_AUX= ${OPD_ROOT}/lib/LibTarNobench2Int16 \
	${OPD_ROOT}/lib/LibTarnobenchmInt16
# build automaticaly when LIB_INT16 is built

EXE_INT16=${OPD_ROOT}/bin/opd_dsp16_exe
else
LIB_INT16=
EXE_INT16=
endif

# These are built automatically by the initial build of `makemake'
LIB_GENERIC = ${OPD_ROOT}/lib/Libopdgen ${OPD_ROOT}/lib/Libopdcom \
	${OPD_ROOT}/lib/Libopdnogui

LIB_TARGET = ${LIB_FLT} ${LIB_INT16} 


BUILD_ALL_EXE= ${OPD_ROOT}/bin/makemake ${OPD_ROOT}/bin/cp_update_legal \
	${TO_BUILD} ${OPD_ROOT}/bin/indextex ${OPD_ROOT}/bin/maketex  \
	${OPD_ROOT}/bin/cp_part ${OPD_ROOT}/bin/nod_sort ${OPD_ROOT}/bin/toc_depth ${OPD_ROOT}/bin/to_low_arg  \
	${OPD_ROOT}/bin/opd  ${OPD_ROOT}/bin/opd_dsp_exe ${OPD_ROOT}/bin/opd_gui_exe ${EXE_INT16} \
	${OPD_ROOT}/bin/rofftotex

DOC_DVI=${OPD_ROOT}/doc/overview/ovr_front.dvi ${OPD_ROOT}/doc/overview/ovr_app.dvi \
	${OPD_ROOT}/doc/overview/nodeman.dvi ${OPD_ROOT}/doc/userman/userman.dvi


BUILD_ALL=${BUILD_ALL_EXE} ${LIB_TARGET} 

DEFAULT:
ifndef OPD_ROOT
	@clear
	@sh ../scripts/is_root_set.sh 
else
	@clear
	@echo "Must say what to build."
	@echo "\`make ALL_INIT' initial build of everything."
	@echo "\`make ALL' update everything."
	@echo "\`make EXE' for update all executables and librarys only."
	@echo "\`make EXE_INIT' initial build of executables and librarys only."
	@echo "\`make DOC' update all documentation (EXE must have been made)."
	@echo "\`make ( VALIDATE | VAL_DATA ) validate or make validation data."
	@echo "\`make ( SOURCE | BINARY | DOCUMENTATION | TEST_DATA | FULL ) distribution."
	@echo "\`make FIG' create automated figures from executable."
	@echo
	@echo "OPD_ROOT is now set to \`$$OPD_ROOT'." 
	@echo "This must be the root directory in which ObjectProDSP is installed." 
	@echo
	@echo "Set and \`export' environmental variable \`INCLUDE_INT16=yes'."
	@echo "to generate both the 16 bit and floating point versions."
	@echo "(See files \`make_all' and \`make_all_init' for examples.)"
	@echo "The default is only to build the floating point version."
	@echo "See \`\$$OPD_ROOT/validate/README' for information on validation."
	@echo "The \`.xwd' files created by \`make FIG' only need to be updated"
	@echo "if you change the appearance of the windows. If so you"
	@echo "may want to manually recreate the other figures that" 
	@echo "come form X-windows images in the tutorial." 
	@echo "(See \$$OPD_ROOT/doc/scripts/xwd_to_ps.sh.)" 
endif

ALL_INIT:: TOUCH_REBUILD ${BUILD_ALL} DOC

EXE_INIT:: TOUCH_REBUILD ${BUILD_ALL}

ALL:: ${BUILD_ALL} DOC

EXE:: ${BUILD_ALL}

DOC::
	cd ${OPD_ROOT}/doc/build ; make

${OPD_ROOT}/bin/makemake:: 
	cd ${OPD_ROOT}/src/util/makemake/obj; make

${OPD_ROOT}/bin/mknode:: 
	cd ${OPD_ROOT}/src/util/mknode/mknodeo; make 

${OPD_ROOT}/bin/domenus::
	cd ${OPD_ROOT}/src/util/mkmenu/menuo; make

${OPD_ROOT}/bin/indextex::
	cd ${OPD_ROOT}/src/util/indextex/ix; make

${OPD_ROOT}/bin/maketex:: 
	cd ${OPD_ROOT}/src/util/maketex/mktex ; make

${OPD_ROOT}/bin/opd::
	cd ${OPD_ROOT}/src/start_up ; make

${OPD_ROOT}/bin/opd_dsp_exe::
	cd ${OPD_ROOT}/src/dsp/build/fltgui; make

${OPD_ROOT}/bin/opd_dsp16_exe::
	cd ${OPD_ROOT}/src/dsp/build/int16gui; make

${OPD_ROOT}/lib/Libopdgen::
	cd ${OPD_ROOT}/src/genlib/opdgen/obj ; make

${OPD_ROOT}/lib/Libopdcom::
	cd ${OPD_ROOT}/src/genlib/common/obj ; make

${OPD_ROOT}/bin/opd_gui_exe::
	cd ${OPD_ROOT}/src/gui/build/iv ; make

${OPD_ROOT}/bin/cp_part ${OPD_ROOT}/bin/toc_depth ${OPD_ROOT}/bin/bin/to_low_arg::
	cd ${OPD_ROOT}/src/util/misc ; make

${OPD_ROOT}/bin/rofftotex::
	cd ${OPD_ROOT}/src/util/rofftotex/o ; make

${OPD_ROOT}/bin/cp_update_legal::
	cd ${OPD_ROOT}/src/util/copyright/cp ; make

${OPD_ROOT}/bin/nod_sort::
	cd ${OPD_ROOT}/src/util/nod_sort/o ; make

${LIB_FLT}::
	cd ${OPD_ROOT}/src/dsp/lib/target/build/tarflt ; make

${LIB_INT16}::
	cd ${OPD_ROOT}/src/dsp/lib/target/build/tarint ; make

TOUCH_DOMAKEMAKE:
	cd ${OPD_ROOT}/src; \
	find . -name domakemake -exec touch {} \; 

TOUCH_USR:
	cd ${OPD_ROOT}/src; \
	find . -name '*.usr' -exec touch {} \; 

TOUCH_REBUILD: TOUCH_DOMAKEMAKE TOUCH_USR
	cd ${OPD_ROOT}/src; \
	find . -name "*.[ly]" -exec touch {} \; ; \
	find . -name '*.usr' -exec touch {} \; 

FIG:
	@. ${OPD_ROOT}/doc/scripts/xwd_to_ps.sh SET_ENV_FULL ; \
	cd ${OPD_ROOT}/doc/xwd/auto ; if [ ! -e old ] ;then mkdir old ;fi ; \
	for i in $$OPD_XWD_AUTO ;do OBJ=$$i ; \
		if [ -e $$i ] ;then mv $$i old ;fi ;done ; \
	cd ${OPD_ROOT}/doc/overview ; make $$OBJ

SOURCE:
	cd ${OPD_ROOT}/scripts ; bash distribution_create.sh $@

BINARY:
	cd ${OPD_ROOT}/scripts ; bash distribution_create.sh $@

DOCUMENTATION:
	cd ${OPD_ROOT}/scripts ; bash distribution_create.sh $@

TEST_DATA:
	cd ${OPD_ROOT}/scripts ; bash distribution_create.sh $@

FULL:
	cd ${OPD_ROOT}/scripts ; bash distribution_create.sh $@

# Used in debugging master validation script
REVALIDATE:
	${OPD_ROOT}/scripts/master_validate.sh REVALIDATE

VALIDATE:
	${OPD_ROOT}/scripts/master_validate.sh VALIDATE

VAL_DATA:
	${OPD_ROOT}/scripts/master_validate.sh VAL_DATA


.PHONY: TOUCH_REBUILD DEFAULT DOC EXE FIG ALL ALL_INIT EXE TOUCH_DOMAKEMAKE \
	SOURCE BINARY DOCUMENTATION TEST_DATA FULL VALIDATE TEST_DATA TOUCH_USR
