# Makefile for t4XML, an extension to input XML with the TGraph package.
#
# 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. We use the assignment syntax (rather
# than +=) to make this work with HPUX and Tru64 make.

ALLLIBS	= \
	-L${PRODUCT_DIR}/libs -le4graph -ltgraph -le4xml \
	-L${METAKIT_LIB} -lmk4 \
	-L${EXPAT_LIB} -lexpat \
	${TCL_STB} \
	${LIBS}

# Where to find source and include files:

OBJ		= ./objects
SRC		= ./../src
INCLUDE		= ./../include
E4GRAPHINCLUDE	= ./../../main/include
T4GRAPHINCLUDE	= ./../../tcl/include
XMLINCLUDE	= ./../../xml/include

# Where to store object files:

PRODOBJDIR	= ${PRODUCT_DIR}/objects/t4xml

# Where to store libraries:

PRODLIBDIR	= ${PRODUCT_DIR}/libs

# The source, include and object files for the e4XML package:

# Where to put include files:

PRODINCDIR	= ${PRODUCT_DIR}/include

# Source, object and include files:

SOURCE = \
	$(SRC)/t4cinit.c \
	$(SRC)/t4xml.cpp

OBJECTS = \
	${PRODOBJDIR}/t4cinit.o \
	${PRODOBJDIR}/t4xml.o

INCLUDES = \
	-I$(INCLUDE) \
	-I$(E4GRAPHINCLUDE) \
	-I$(T4GRAPHINCLUDE) \
	-I$(XMLINCLUDE) \
	-I$(EXPAT_INC) \
	$(TCL_INC)

# Compile flags. Collect all the flags specified in the makefile.include
# and by users on the command line, e.g. 'make CPPFLAGS=...'.

ALLCPPFLAGS = $(CPPFLAGS) ${INCLUDES} -DUSE_TCL_STUBS

# Main target:

all: ${PRODLIBDIR}/libtxml${SHLIB_SUFFIX} includes

# Install this package:

install: all
	-mkdir -p $(includedir)
	cp -p ../include/t4xml_c.h $(includedir)/t4xml_c.h
	-mkdir -p $(libdir)
	cp -p ${PRODLIBDIR}/libtxml${SHLIB_SUFFIX} \
	      $(libdir)/libtxml${SHLIB_SUFFIX}.0.0.0
	-/bin/rm -f $(libdir)/libtxml${SHLIB_SUFFIX} \
		    $(libdir)/libtxml${SHLIB_SUFFIX}.0
	-ln -s libtxml${SHLIB_SUFFIX}.0.0.0 \
	       $(libdir)/libtxml${SHLIB_SUFFIX}
	-ln -s libtxml${SHLIB_SUFFIX}.0.0.0 \
	       $(libdir)/libtxml${SHLIB_SUFFIX}.0

# Uninstall this package:

uninstall:
	/bin/rm -f $(includedir)/t4xml_c.h
	/bin/rm -f $(libdir)/libtxml${SHLIB_SUFFIX}.0.0.0
	/bin/rm -f $(libdir)/libtxml${SHLIB_SUFFIX}
	/bin/rm -f $(libdir)/libtxml${SHLIB_SUFFIX}.0

# Release engineering:

release: all
	mkdir -p $(release_tmp_dir)/include
	cp -p ../include/t4xml_c.h $(release_tmp_dir)/include/t4xml_c.h
	mkdir -p $(release_tmp_dir)/lib
	cp -p ${PRODLIBDIR}/libtxml${SHLIB_SUFFIX} \
	      $(release_tmp_dir)/lib/libtxml${SHLIB_SUFFIX}.0.0.0
	cp -p ${PRODLIBDIR}/libtxml${SHLIB_SUFFIX} \
	      $(release_tmp_dir)/lib/libtxml${SHLIB_SUFFIX}
	cp -p ${PRODLIBDIR}/libtxml${SHLIB_SUFFIX} \
	      $(release_tmp_dir)/lib/libtxml${SHLIB_SUFFIX}.0

# Build the library:

${PRODLIBDIR}/libtxml${SHLIB_SUFFIX}: ${OBJECTS}
	-@mkdir -p ${PRODLIBDIR}
	${SHLIB_LD} -o ${PRODLIBDIR}/libtxml${SHLIB_SUFFIX} \
		    ${OBJECTS} ${ALLLIBS}

# Produce the include files:

includes:
	-@mkdir -p ${PRODINCDIR}
	-@cp ${INCLUDE}/*.h ${PRODINCDIR}

# Individual file targets:

${PRODOBJDIR}/t4cinit.o: ${SRC}/t4cinit.c
	-@mkdir -p ${PRODOBJDIR}
	${CC} -c ${CXXFLAGS} $(ALLCPPFLAGS) ${SRC}/t4cinit.c -o $@

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

# Clean:

clean:
	-@/bin/rm -f ${PRODLIBDIR}/libtxml${SHLIB_SUFFIX}
	-@/bin/rm -f ${OBJECTS}
	-@/bin/rm -f *~ #*
