# Makefile for all targets.
#
# 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.

# First of all include the Makefile.include file which defines parameters
# determined at configure time.

include makefile.include

# Main target:

all: ${E4GRAPH_TARGETS} main_static testprog_static
	-@echo done

# Test:

test: testprog
	(cd ../test/unix; $(MAKE) runtest)

# Test the statically linked version of the test program:

test_static: testprog_static
	(cd ../test/unix; $(MAKE) runtest_static)

# Install target:

install: ${E4GRAPH_INSTALL} install_main_static install_testprog_static

# Install static versions of some libraries and executables:

install_static: main_static testprog_static
	(cd ../main/unix;   $(MAKE) $(MAKEFLAGS) install_static)
	(cd ../test/unix;   $(MAKE) $(MAKEFLAGS) install_static)

# Uninstall target:

uninstall:
	(cd ../main/unix;   $(MAKE) $(MAKEFLAGS) uninstall)
	(cd ../test/unix;   $(MAKE) $(MAKEFLAGS) uninstall)
	(cd ../tcl/unix;    $(MAKE) $(MAKEFLAGS) uninstall)
	(cd ../python/unix; $(MAKE) $(MAKEFLAGS) uninstall)
	(cd ../xml/unix;    $(MAKE) $(MAKEFLAGS) uninstall)
	(cd ../t4xml/unix;  $(MAKE) $(MAKEFLAGS) uninstall)
	(cd ../java/unix;   $(MAKE) $(MAKEFLAGS) uninstall)

# Release engineering:

release: main tcl python xml t4xml java
	-@mkdir -p $(release_tmp_dir)
	-@/bin/rm -rf $(release_tmp_dir)/*
	-@mkdir -p \
		$(release_tmp_dir)/lib \
		$(release_tmp_dir)/exp \
		$(release_tmp_dir)/include \
		$(release_tmp_dir)/docs
	-@cp ../README ../INSTALL ../readme.html ../changes $(release_tmp_dir)
	-@cp pkgIndex.tcl ${release_tmp_dir}/lib
	-@cp ../docs/* $(release_tmp_dir)/docs
	-@(cd ../main/unix;   $(MAKE) $(MAKEFLAGS) release)
	-@(cd ../tcl/unix;    $(MAKE) $(MAKEFLAGS) release)
	-@(cd ../python/unix; $(MAKE) $(MAKEFLAGS) release)
	-@(cd ../xml/unix;    $(MAKE) $(MAKEFLAGS) release)
	-@(cd ../t4xml/unix;  $(MAKE) $(MAKEFLAGS) release)
	-@(cd ../java/unix;   $(MAKE) $(MAKEFLAGS) release)
	-@/bin/rm -f \
		$(release_file).tar \
		$(release_file).tar.gz
	-@(cd $(release_tmp_dir_parent); \
	   tar cf $(release_file).tar ./$(release_file))
	-@cp $(release_tmp_dir_parent)/$(release_file).tar .
	-@/bin/rm -f $(release_tmp_dir_parent)/$(release_file).tar
	-@gzip $(release_file).tar
	-@/bin/rm -rf $(release_tmp_dir)

# Individual targets:

main:
	(cd ../main/unix; $(MAKE) $(MAKEFLAGS) all)
install_main: main
	(cd ../main/unix; $(MAKE) $(MAKEFLAGS) install)

main_static:
	(cd ../main/unix; $(MAKE) $(MAKEFLAGS) static)
install_main_static: main_static
	(cd ../main/unix; $(MAKE) $(MAKEFLAGS) install_static)

tcl: main
	(cd ../tcl/unix; $(MAKE) $(MAKEFLAGS) all)
install_tcl: install_main
	(cd ../tcl/unix; $(MAKE) $(MAKEFLAGS) install)

python: main
	(cd ../python/unix; $(MAKE) $(MAKEFLAGS) all)
install_python: install_main
	(cd ../python/unix; $(MAKE) $(MAKEFLAGS) install)

testprog: main
	(cd ../test/unix; $(MAKE) $(MAKEFLAGS) all)
install_testprog: testprog install_main
	(cd ../test/unix; $(MAKE) $(MAKEFLAGS) install)

testprog_static: main main_static
	(cd ../test/unix; $(MAKE) $(MAKEFLAGS) static)
install_testprog_static: testprog_static install_main_static
	(cd ../test/unix; $(MAKE) $(MAKEFLAGS) install_static)

xml: main
	(cd ../xml/unix; $(MAKE) $(MAKEFLAGS) all)
install_xml: install_main
	(cd ../xml/unix; $(MAKE) $(MAKEFLAGS) install)

t4xml: tcl xml
	(cd ../t4xml/unix; $(MAKE) $(MAKEFLAGS) all)
install_t4xml: install_tcl install_xml
	(cd ../t4xml/unix; $(MAKE) $(MAKEFLAGS) install)

java: main
	(cd ../java/unix; $(MAKE) $(MAKEFLAGS) all)
install_java: install_main
	(cd ../java/unix; $(MAKE) $(MAKEFLAGS) install)

clean:
	(cd ../main/unix;    $(MAKE) $(MAKEFLAGS) clean)
	(cd ../tcl/unix;     $(MAKE) $(MAKEFLAGS) clean)
	(cd ../python/unix;  $(MAKE) $(MAKEFLAGS) clean)
	(cd ../test/unix;    $(MAKE) $(MAKEFLAGS) clean)
	(cd ../xml/unix;     $(MAKE) $(MAKEFLAGS) clean)
	(cd ../t4xml/unix;   $(MAKE) $(MAKEFLAGS) clean)
	(cd ../java/unix;    $(MAKE) $(MAKEFLAGS) clean)
	/bin/rm -f *~ #*

configureclean: clean
	/bin/rm -f makefile.include config.status config.h config.cache \
		   config.log libtool
	@echo remember to rerun configure if you want to build e4graph again

clobber: configureclean
	/bin/rm -f configure
	/bin/rm -rf ${PRODUCT_DIR}
	@echo remember to rerun autoconf if you want to recreate configure
