# saved from url
# http://www-cs.canisius.edu/PL_TUTORIALS/C++/EXAMPLES/MRD/SRC/makefile -->

# C++ definitions
CC = g++
CFLAGS = -g

# install location
#INSTALL = /where

# application sources for distribution
SRCS = Makefile readme index mdb.doc demo.doc batch1.sh batch2.sh \
candy.txt cities.txt cityfun.txt colleges.txt \
cost.txt currentyear.txt family.txt natldebt.txt nums.txt \
parts.txt people.txt planets.txt sp.txt \
states.txt states2.txt states3.txt states4.txt \
sup.txt towns.txt \
command.cpp expressions.cpp get_line.cpp parseline.cpp \
shell.cpp read.cpp relation.cpp speclist.cpp \
test.cpp write.cpp \
expressions.h parseline.h relation.h speclist.h

# intermediate objects
OBJS = relation.o speclist.o expressions.o parseline.o command.o shell.o

# targets : dependencies
#	command
#	...

all :	mrd ${OBJS} parseline.t

mrd :	${OBJS}
	${CC} ${CFLAGS} ${OBJS} -o mrd

shell.o :	shell.cpp relation.h
	${CC} ${CFLAGS} -c shell.cpp

command.o :	command.cpp expressions.h relation.h
	${CC} ${CFLAGS} -c command.cpp

parseline.o :	parseline.cpp parseline.h
	${CC} ${CFLAGS} -c parseline.cpp

expressions.o :	expressions.cpp expressions.h
	${CC} ${CFLAGS} -c expressions.cpp

speclist.o :	speclist.cpp speclist.h
	${CC} ${CFLAGS} -c speclist.cpp

relation.o :	relation.cpp relation.h
	${CC} ${CFLAGS} -c relation.cpp

parseline.t :	test.cpp parseline.h parseline.o
	${CC} ${CFLAGS} parseline.o test.cpp -o parseline.t

.PHONEY : clean realclean install dist help all test

clean :
	rm -f *.o

realclean :
	rm -f mrd mrd.exe *~ *.o *.t mdb.tgz mdb.zip

install :
	mv mrd ${INSTALL}/.

dist :
	tar -zcvf mdb.tgz ${SRCS}
	zip mdb.zip ${SRCS}

test :
	parseline.t

help :
	@echo "make help screen"
	@echo "targets     ... purpose"
	@echo ""
	@echo "all         ... compile everything"
	@echo "<name>.o    ... compile this intermediate file"
	@echo "mrd         ... compile the mrd executable"
	@echo "parseline.t ... compile the test executable"
	@echo ""
	@echo "clean       ... delete all intermediate compiled files"
	@echo "dist        ... create a tarred, gzipped and zip files"
	@echo "install     ... install mrd to the INSTALL=<dir> directory"
	@echo "realclean   ... deleted all intermediate files"
	@echo ""
