# Makefile for test harness for e4Graph library.
#
# Copyright (c) 2000-2003, JYL Software Inc.
# 
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE, EVEN IF
# JYL SOFTWARE INC. IS MADE AWARE OF THE POSSIBILITY OF SUCH DAMAGE.

# Include the parameters determined at configure time:

include ../../all/makefile.include

# Which libraries to link with the libe4graph (we use the assignemnt
# syntax rather than += to make this work for the HPUX and Tru64 Make
# programs).

ALLLIBS	= \
	-L${PRODUCT_DIR}/libs -le4graph \
	-L${METAKIT_LIB} -lmk4 \
	${LIBS}

# Which libraries to link into the static executable:

ALLSTATICLIBS = \
	-L${PRODUCT_DIR}/libs -le4graphs \
	-L${METAKIT_LIB} -lmk4 \
	${LIBS}

# Where is everything:

SRC 		= ./../src
INCLUDE 	= ./../include
E4GRAPHINCLUDE	= ./../../main/include

# Where to put object files:

PRODOBJDIR = ${PRODUCT_DIR}/objects/test

# Where to put libraries:

PRODLIBDIR = ${PRODUCT_DIR}/libs

# Where to put executables:

PRODBINDIR = ${PRODUCT_DIR}/bin

# Source and object files for the test program:

SOURCE = \
	$(SRC)/test.cpp \
	$(SRC)/testcallback.cpp \
	$(SRC)/testdetach.cpp \
	$(SRC)/testdstring.cpp \
	$(SRC)/teststorage.cpp \
	$(SRC)/testnode.cpp \
	$(SRC)/testrefcount.cpp \
	$(SRC)/testvvisitor.cpp \
	$(SRC)/testnvisitor.cpp \
	$(SRC)/testsvisitor.cpp \
	$(SRC)/testvertex.cpp

OBJECTS = \
	${PRODOBJDIR}/test.o		\
	${PRODOBJDIR}/testcallback.o	\
	${PRODOBJDIR}/testdetach.o	\
	${PRODOBJDIR}/testdstring.o	\
	${PRODOBJDIR}/teststorage.o	\
	${PRODOBJDIR}/testnode.o	\
	${PRODOBJDIR}/testrefcount.o	\
	${PRODOBJDIR}/testvvisitor.o	\
	${PRODOBJDIR}/testnvisitor.o	\
	${PRODOBJDIR}/testsvisitor.o	\
	${PRODOBJDIR}/testvertex.o

# Which includes to make available to the program:

INCLUDES = -I$(INCLUDE) -I$(E4GRAPHINCLUDE)

# What compile flags to pass to the compiler. Collect all the
# flags specified in the makefile.include and by users on the
# command line, e.g. 'make CPPFLAGS=...'.

ALLCPPFLAGS = $(CPPFLAGS) $(INCLUDES)

# Main target:

all: ${PRODBINDIR}/testcore

# Static linked e4graph target:

static: ${PRODBINDIR}/testcores

# Install this package:

install: all
	-mkdir -p $(bindir)
	cp -p ${PRODBINDIR}/testcore $(bindir)/testcore

# Install the statically linked version:

install_static: static
	-mkdir -p $(bindir)
	cp -p ${PRODBINDIR}/testcores $(bindir)/testcores

# Uninstall this package:

uninstall:
	/bin/rm -f $(bindir)/testcore $(bindir)/testcores

# Run the test program

runtest: ${PRODBINDIR}/testcore
	@csh ./runtest.csh \
		${PRODLIBDIR}:${prefix}/lib:${METAKIT_LIB} \
		${PRODBINDIR}/testcore

# Run the statically linked version of the test program:

runtest_static: ${PRODBINDIR}/testcores
	@csh ./runtest.csh \
		${PRODLIBDIR}:${prefix}/lib:${METAKIT_LIB} \
		${PRODBINDIR}/testcores

# Release engineering:

release:
	-@echo nothing to do for target release

# Clean up:

clean:
	-/bin/rm -f $(OBJECTS) ${PRODBINDIR}/testcore

# Make the testcore executable:

${PRODBINDIR}/testcore: $(OBJECTS)
	-@mkdir -p ${PRODBINDIR}
	$(CXX) -o ${PRODBINDIR}/testcore $(OBJECTS) $(ALLLIBS)

# Make the statically linked executable:

${PRODBINDIR}/testcores: $(OBJECTS)
	-@mkdir -p ${PRODBINDIR}
	$(CXX) -o ${PRODBINDIR}/testcores $(OBJECTS) $(ALLSTATICLIBS)

# Compile individual test files:

${PRODOBJDIR}/test.o: $(SRC)/test.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/test.cpp -o $@

${PRODOBJDIR}/testcallback.o: $(SRC)/testcallback.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/testcallback.cpp -o $@

${PRODOBJDIR}/testdetach.o: $(SRC)/testdetach.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/testdetach.cpp -o $@

${PRODOBJDIR}/testdstring.o: $(SRC)/testdstring.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/testdstring.cpp -o $@

${PRODOBJDIR}/teststorage.o: $(SRC)/teststorage.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/teststorage.cpp -o $@

${PRODOBJDIR}/testnode.o: $(SRC)/testnode.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/testnode.cpp -o $@

${PRODOBJDIR}/testrefcount.o: $(SRC)/testrefcount.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/testrefcount.cpp -o $@

${PRODOBJDIR}/testvertex.o: $(SRC)/testvertex.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/testvertex.cpp -o $@

${PRODOBJDIR}/testvvisitor.o: $(SRC)/testvvisitor.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/testvvisitor.cpp -o $@

${PRODOBJDIR}/testnvisitor.o: $(SRC)/testnvisitor.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/testnvisitor.cpp -o $@

${PRODOBJDIR}/testsvisitor.o: $(SRC)/testsvisitor.cpp
	-@mkdir -p ${PRODOBJDIR}
	$(CXX) -c $(CXXFLAGS) $(ALLCPPFLAGS) $(SRC)/testsvisitor.cpp -o $@
