# ======================================================================
# Makefile - for UKernel
#
# 081304: Benjamin Han <benhdj@cs.cmu.edu> Version 1.92: minor changes.
# 061604: Benjamin Han <benhdj@cs.cmu.edu> Version 1.91: compiled and run with
#         gcc 3.3.
# 011403: Benjamin Han <benhdj@cs.cmu.edu> Conditional compile: either
#         for analysis (UK_ANALYSIS) or for generation (UK_GEN).
# 110602: Benjamin Han <benhdj@cs.cmu.edu> equTst now depends on grammar.o.
# 102102: Benjamin Han <benhdj@cs.cmu.edu> Version 1.89.
# 101202: Benjamin Han <benhdj@cs.cmu.edu> Version 1.88: added 
#         fsBoxTst.cpp for testing RHS penetrating path with undefined
#         branches (boxes).
# 092902: Benjamin Han <benhdj@cs.cmu.edu> Version 1.87: added new file 
#         fStrucFunc.cpp.
# 092802: Benjamin Han <benhdj@cs.cmu.edu> Version 1.86.
# 092102: Benjamin Han <benhdj@cs.cmu.edu> Version 1.85.
# 072102: Benjamin Han <benhdj@cs.cmu.edu> Changed compiler to g++ (which should
#         be version 3.0 or later).
# 120601: Benjamin Han <benhdj@cs.cmu.edu> Version 1.83.
# 092801: Benjamin Han <benhdj@cs.cmu.edu> Now dependencies are automatically
#         generated by DEPS deps target; version 1.82.
# 090301: Benjamin Han <benhdj@cs.cmu.edu> Compiled under g++ version 3 with 
#         -Wall -pedantic.
# 081601: Benjamin Han <benhdj@cs.cmu.edu> Compiling using optimization;
#         split into three targets: one for .o, one for ush, and one for testing 
#         executables.
# 081001: Benjamin Han <benhdj@cs.cmu.edu> Version 1.80: updated to work with
#	  Toolbox v1.3; several bug fixes about using operator-- on various
#         data types.
# 080501: Benjamin Han <benhdj@cs.cmu.edu> Changed file extensions .hh to .hpp
#	  and .cc to .cpp together with the necessary changes in the other 
#         files.
# 071701: Benjamin Han <benhdj@cs.cmu.edu> Version 1.79.
# 071301: Benjamin Han <benhdj@cs.cmu.edu> Added eFunc.* and fsRegs.* (the
#         latter are moved from equation.*); version 1.78: extension function
#         mechanism, revised lexicon facilities, revised behaviors of
#         interactions between atomic/complex values/FSs to conform with the
#         behavior of the 1988 GenKit, bug fixes, etc.
# 071101: Benjamin Han <benhdj@cs.cmu.edu> Added eFArgs.* and eFATst.cpp.
# 070501: Benjamin Han <benhdj@cs.cmu.edu> Version 1.76: Correctly model
#         the execution of *OR* blocks - a combined *OR* FS will be produced
#         if the execution is successful, and the resulting FS will have no
#         duplicate daughters.
# 063001: Benjamin Han <benhdj@cs.cmu.edu> Changed the macro UKERNEL_VER to
#         VERSION.
# 062901: Benjamin Han <benhdj@cs.cmu.edu> Moved FSRegisters from grammar.*
#         to equation.*.
# 062401: Benjamin Han <benhdj@cs.cmu.edu> Version 1.7: *MULTIPLE* FS is now
#         possible, plus bug fixes in FS printing and basic tree code (in 
#         Toolbox).
# 062101: Benjamin Han <benhdj@cs.cmu.edu> Version 1.6.
# 061201: Benjamin Han <benhdj@cs.cmu.edu> Moved grammar.* from Generator;
#         added graTst.cpp and graTstSub.cpp for testing; added lex*; increased
#         TEMPLATE_DEPTH from 17 to 20.
# 052901: Benjamin Han <benhdj@cs.cmu.edu> Version 1.3: indented printing
#         is now supported.
# 052001: Benjamin Han <benhdj@cs.cmu.edu> Version 1.2: now we have *OR*,
#         *EOR* and *CASE* equation blocks (eBlock.*).
# 051501: Benjamin Han <benhdj@cs.cmu.edu> Added equation.*, equTst.cpp,
#         and ushHelp.cpp.
# 050801: Benjamin Han <benhdj@cs.cmu.edu> Added symbol.*.
# 042101: Benjamin Han <benhdj@cs.cmu.edu> Created.
# ======================================================================

#    Copyright (C) 2000-2004 Benjamin Han <benhdj@cs.cmu.edu>
#
#    This library is free software; you can redistribute it and/or
#    modify it under the terms of the GNU Lesser General Public
#    License as published by the Free Software Foundation; either
#    version 2.1 of the License, or (at your option) any later version.
#
#    This library 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
#    Lesser General Public License for more details.
#
#    You should have received a copy of the GNU Lesser General Public
#    License along with this library; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

VERSION = \"1.92\"

TOOLBOX_DIR = ../Toolbox

TEMPLATE_DEPTH=24

# Modify the following to suit your needs, esp. UK_ANALYSIS (for analysis) or
# UK_GEN (for generation)
CXX          = g++
CXXFLAGS     = -O3 -ftemplate-depth-${TEMPLATE_DEPTH} -pedantic -Wall -Wno-non-virtual-dtor
#CXXFLAGS     = -g -ftemplate-depth-${TEMPLATE_DEPTH} -pedantic -Wall -Wno-non-virtual-dtor
CPPFLAGS     = -DVERSION=${VERSION} -DNDEBUG -I${TOOLBOX_DIR} -DUK_GEN
#CPPFLAGS     = -DVERSION=${VERSION} -I${TOOLBOX_DIR} -DUK_GEN

# all targets
TEST = valTst fsTst fsBoxTst eFATst equTst graTst lexTst
BIN = ush
OBJ = symbol.o value.o fStruc.o fStrucFunc.o eFArgs.o eFunc.o fsRegs.o lexicon.o equation.o eBlock.o grammar.o
DEPS = .deps
TGZ=uKernel.tar.gz

# dependencies for executables
all: ${DEPS} ${OBJ}
bin: ${DEPS} ${BIN}
test: ${DEPS} ${TEST}
deps: ${DEPS}

${DEPS}:
	echo > ${DEPS}; for i in *.cpp; do ${CXX} ${CPPFLAGS} -MM $$i >>${DEPS}; done

-include ${DEPS}

valTst: symbol.o value.o valTst.o
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -o $@ $^

fsTst: ${TOOLBOX_DIR}/indent.o symbol.o value.o fStruc.o fStrucFunc.o fsTst.o
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -o $@ $^

fsBoxTst: ${TOOLBOX_DIR}/indent.o symbol.o value.o fStruc.o fStrucFunc.o fsBoxTst.o
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -o $@ $^

lexTst: ${TOOLBOX_DIR}/indent.o symbol.o value.o fStruc.o fStrucFunc.o lexicon.o lexTst.o
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -o $@ $^

eFATst: ${TOOLBOX_DIR}/indent.o symbol.o value.o fStruc.o fStrucFunc.o eFArgs.o eFATst.o
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -o $@ $^

equTst: ${TOOLBOX_DIR}/misc.o ${TOOLBOX_DIR}/indent.o symbol.o value.o fStruc.o fStrucFunc.o lexicon.o fsRegs.o eFArgs.o eFunc.o equation.o eBlock.o grammar.o equTst.o
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -o $@ $^

graTst: ${TOOLBOX_DIR}/misc.o ${TOOLBOX_DIR}/indent.o symbol.o value.o fStruc.o fStrucFunc.o lexicon.o fsRegs.o eFArgs.o eFunc.o equation.o eBlock.o grammar.o graTstSub.o graTst.o
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -o $@ $^

ush: ${TOOLBOX_DIR}/misc.o ${TOOLBOX_DIR}/indent.o ${TOOLBOX_DIR}/tokStr.o symbol.o value.o fStruc.o fStrucFunc.o lexicon.o fsRegs.o eFArgs.o eFunc.o equation.o eBlock.o grammar.o ushHelp.o ush.o
	${CXX} ${CPPFLAGS} ${CXXFLAGS} -o $@ $^

.PHONY: clean clean_test tar

tar:
	-${RM} -rf *~ ${OBJ} ${BIN} ${TEST} *.o ${DEPS} ${TGZ} .[^.]* core
	tar -C ../ -czvf ${TGZ} --exclude ${TGZ} --exclude CVS --exclude doc/CVS --exclude-from exfile UKernel

clean:
	-${RM} -rf ${OBJ} ${BIN} ${TEST} *.o ${DEPS} ${TGZ} .[^.]* core

clean_bin:
	-${RM} -rf ${BIN} ${BIN:=.o} ${DEPS} ${TGZ} core

clean_test:
	-${RM} -rf ${TEST} ${TEST:=.o} ${DEPS} ${TGZ} core
