# @HEADER
#
########################################################################
#
#  Zoltan Toolkit for Load-balancing, Partitioning, Ordering and Coloring
#                  Copyright 2012 Sandia Corporation
#
# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
# the U.S. Government retains certain rights in this software.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Corporation nor the names of the
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Questions? Contact Karen Devine	kddevin@sandia.gov
#                    Erik Boman	        egboman@sandia.gov
#
########################################################################
#
# @HEADER


## #######################################################################
## Options to automake (rarely used - don't worry about it)
## #######################################################################
AUTOMAKE_OPTIONS = foreign

## #######################################################################
## Aclocal command (rarely used - don't worry about it)
## #######################################################################
ACLOCAL_AMFLAGS = -I config

## #######################################################################
## Additional files to be included in distribution for 'make dist'
## #######################################################################
ZOLTAN_TESTS = \
    test/test_zoltan \
    test/runtests \
    test/ctest_zoltan.pl \
    test/ch_simple \
    test/hg_simple 

ZOLTAN_DOCS = \
    doc/Zoltan_html/Zoltan.html \
    doc/Zoltan_html/Zoltan_FAQ.html \
    doc/Zoltan_html/Zoltan_bugreport.html \
    doc/Zoltan_html/Zoltan_cite.html \
    doc/Zoltan_html/Zoltan_construction.html \
    doc/Zoltan_html/Zoltan_phil.html \
    doc/Zoltan_html/Zoltan_pubs.html \
    doc/Zoltan_html/dev_html/brack3d.png \
    doc/Zoltan_html/dev_html/dev.html \
    doc/Zoltan_html/dev_html/dev_add.html \
    doc/Zoltan_html/dev_html/dev_add_interface.html \
    doc/Zoltan_html/dev_html/dev_add_lb.html \
    doc/Zoltan_html/dev_html/dev_add_memory.html \
    doc/Zoltan_html/dev_html/dev_add_params.html \
    doc/Zoltan_html/dev_html/dev_add_remap.html \
    doc/Zoltan_html/dev_html/dev_add_struct.html \
    doc/Zoltan_html/dev_html/dev_cpp.html \
    doc/Zoltan_html/dev_html/dev_degenerate.html \
    doc/Zoltan_html/dev_html/dev_dist.html \
    doc/Zoltan_html/dev_html/dev_dist_compile.html \
    doc/Zoltan_html/dev_html/dev_dist_cvs.html \
    doc/Zoltan_html/dev_html/dev_dist_dir.html \
    doc/Zoltan_html/dev_html/dev_driver.html \
    doc/Zoltan_html/dev_html/dev_fortran.html \
    doc/Zoltan_html/dev_html/dev_hier.html \
    doc/Zoltan_html/dev_html/dev_hsfc.html \
    doc/Zoltan_html/dev_html/dev_intro.html \
    doc/Zoltan_html/dev_html/dev_intro_coding.html \
    doc/Zoltan_html/dev_html/dev_intro_philosophy.html \
    doc/Zoltan_html/dev_html/dev_intro_sqe.html \
    doc/Zoltan_html/dev_html/dev_lb.html \
    doc/Zoltan_html/dev_html/dev_lb_interface.html \
    doc/Zoltan_html/dev_html/dev_lb_structs.html \
    doc/Zoltan_html/dev_html/dev_lb_types.html \
    doc/Zoltan_html/dev_html/dev_mig.html \
    doc/Zoltan_html/dev_html/dev_parmetis.html \
    doc/Zoltan_html/dev_html/dev_phg.html \
    doc/Zoltan_html/dev_html/dev_rcb.html \
    doc/Zoltan_html/dev_html/dev_refs.html \
    doc/Zoltan_html/dev_html/dev_reftree.html \
    doc/Zoltan_html/dev_html/dev_rib.html \
    doc/Zoltan_html/dev_html/dev_services.html \
    doc/Zoltan_html/dev_html/dev_services_debug.html \
    doc/Zoltan_html/dev_html/dev_services_hash.html \
    doc/Zoltan_html/dev_html/dev_services_objlist.html \
    doc/Zoltan_html/dev_html/dev_services_parallel.html \
    doc/Zoltan_html/dev_html/dev_services_params.html \
    doc/Zoltan_html/dev_html/dev_services_time.html \
    doc/Zoltan_html/dev_html/dev_services_zoltantimer.html \
    doc/Zoltan_html/dev_html/dev_test_script.html \
    doc/Zoltan_html/dev_html/dev_view.html \
    doc/Zoltan_html/dev_html/film2d.png \
    doc/Zoltan_html/dev_html/hammondMesh.png \
    doc/Zoltan_html/dev_html/hammondPoints.png \
    doc/Zoltan_html/dev_html/zdrive.inp \
    doc/Zoltan_html/ug_html/figures/arrow.gif \
    doc/Zoltan_html/ug_html/figures/HGFigure.gif \
    doc/Zoltan_html/ug_html/figures/hierexample.fig \
    doc/Zoltan_html/ug_html/figures/hierexample.gif \
    doc/Zoltan_html/ug_html/figures/Z.gif \
    doc/Zoltan_html/ug_html/ug.html \
    doc/Zoltan_html/ug_html/ug_alg.html \
    doc/Zoltan_html/ug_html/ug_alg_block.html \
    doc/Zoltan_html/ug_html/ug_alg_geom.html \
    doc/Zoltan_html/ug_html/ug_alg_graph.html \
    doc/Zoltan_html/ug_html/ug_alg_hier.html \
    doc/Zoltan_html/ug_html/ug_alg_hsfc.html \
    doc/Zoltan_html/ug_html/ug_alg_hypergraph.html \
    doc/Zoltan_html/ug_html/ug_alg_jostle.html \
    doc/Zoltan_html/ug_html/ug_alg_oct.html \
    doc/Zoltan_html/ug_html/ug_alg_parkway.html \
    doc/Zoltan_html/ug_html/ug_alg_parmetis.html \
    doc/Zoltan_html/ug_html/ug_alg_patoh.html \
    doc/Zoltan_html/ug_html/ug_alg_phg.html \
    doc/Zoltan_html/ug_html/ug_alg_ptscotch.html \
    doc/Zoltan_html/ug_html/ug_alg_random.html \
    doc/Zoltan_html/ug_html/ug_alg_rcb.html \
    doc/Zoltan_html/ug_html/ug_alg_reftree.html \
    doc/Zoltan_html/ug_html/ug_alg_rib.html \
    doc/Zoltan_html/ug_html/ug_alg_simple.html \
    doc/Zoltan_html/ug_html/ug_backward.html \
    doc/Zoltan_html/ug_html/ug_color.html \
    doc/Zoltan_html/ug_html/ug_color_parallel.html \
    doc/Zoltan_html/ug_html/ug_cpp.html \
    doc/Zoltan_html/ug_html/ug_examples.html \
    doc/Zoltan_html/ug_html/ug_examples_init.html \
    doc/Zoltan_html/ug_html/ug_examples_lb.html \
    doc/Zoltan_html/ug_html/ug_examples_mig.html \
    doc/Zoltan_html/ug_html/ug_examples_query.html \
    doc/Zoltan_html/ug_html/ug_fortran.html \
    doc/Zoltan_html/ug_html/ug_graph_vs_hg.html \
    doc/Zoltan_html/ug_html/ug_index.html \
    doc/Zoltan_html/ug_html/ug_interface.html \
    doc/Zoltan_html/ug_html/ug_interface_augment.html \
    doc/Zoltan_html/ug_html/ug_interface_color.html \
    doc/Zoltan_html/ug_html/ug_interface_init.html \
    doc/Zoltan_html/ug_html/ug_interface_lb.html \
    doc/Zoltan_html/ug_html/ug_interface_mig.html \
    doc/Zoltan_html/ug_html/ug_interface_order.html \
    doc/Zoltan_html/ug_html/ug_intro.html \
    doc/Zoltan_html/ug_html/ug_order.html \
    doc/Zoltan_html/ug_html/ug_order_parmetis.html \
    doc/Zoltan_html/ug_html/ug_order_ptscotch.html \
    doc/Zoltan_html/ug_html/ug_param.html \
    doc/Zoltan_html/ug_html/ug_query.html \
    doc/Zoltan_html/ug_html/ug_query_lb.html \
    doc/Zoltan_html/ug_html/ug_query_mig.html \
    doc/Zoltan_html/ug_html/ug_refs.html \
    doc/Zoltan_html/ug_html/ug_release.html \
    doc/Zoltan_html/ug_html/ug_usage.html \
    doc/Zoltan_html/ug_html/ug_util.html \
    doc/Zoltan_html/ug_html/ug_util_comm.html \
    doc/Zoltan_html/ug_html/ug_util_dd.html \
    doc/Zoltan_html/ug_html/ug_util_mem.html 

ZOLTAN_SAMPLE = \
       SampleConfigurationScripts/mac_osX_no_fortran \
       SampleConfigurationScripts/linux_with_purify_zoltan_only \
       SampleConfigurationScripts/mac_osX_zoltan_only \
       SampleConfigurationScripts/linux_zoltan_only \
       SampleConfigurationScripts/linux_trilinos_runtests        \
       SampleConfigurationScripts/linux_zoltan_dist  \
       SampleConfigurationScripts/mac_osX_zoltan_dist


ZOLTAN_CMAKE = \
       CMakeLists.txt \
       src/CMakeLists.txt \
       src/driver/CMakeLists.txt \
       src/fdriver/CMakeLists.txt \
       test/CMakeLists.txt \
       test/ch_simple/CMakeLists.txt \
       test/hg_simple/CMakeLists.txt \
       cmake/Dependencies.cmake  \
       cmake/Zoltan_config.h.in

EXTRA_DIST = config/generate-makeoptions.pl \
       README.html README.txt \
       config/strip_dup_incl_paths.pl config/strip_dup_libs.pl \
       config/replace-install-prefix.pl config/string-replace.pl \
       config/token-replace.pl \
       Disclaimer GNU_Lesser_GPL.txt Known_Problems VERSION \
       $(ZOLTAN_DOCS) $(ZOLTAN_SAMPLE) $(ZOLTAN_TESTS)


## #######################################################################
## Tools in the auxillary directory 
## #######################################################################
AUX_DIST = config/install-sh config/missing config/mkinstalldirs 

## #######################################################################
## Files to be deleted by 'make maintainer-clean'
## #######################################################################
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 autom4te.cache/* \
	configure config.status config.log \
	src/common/config-h.in src/common/stamp-h.in \
	$(AUX_DIST) 

#The following line helps the test harness recover from build errors.

all-local:
	@echo ""
	@echo "Trilinos package zoltan built successfully."
	@echo ""

## #######################################################################
## Subdirectories to be make'd recursively
## #######################################################################

#We now build tests and examples through separate make targets, rather than
#during "make".  We still need to conditionally include the test and example
#in SUBDIRS, even though BUILD_TESTS and BUILD_EXAMPLES will never be
#defined, so that the tests and examples are included in the distribution
#tarball.

#Add this later
if SUB_TEST
TEST_SUBDIR=
endif

if SUB_EXAMPLE
EXAMPLE_SUBDIR=example
endif

if BUILD_TESTS
tests: examples
	@echo ""
	@echo "Now building zoltan tests."
	@echo ""
	@echo "Zoltan tests use drivers and input files; no compilation necessary."
	@echo ""
	@echo "Finished building zoltan tests."
	@echo ""
else
tests:
	@echo "zoltan tests were disabled at configure time"
endif

if BUILD_EXAMPLES
examples:
	@echo ""
	@echo "Now building zoltan examples."
	@echo ""
	cd $(top_builddir)/example && $(MAKE)
	@echo ""
	@echo "Finished building zoltan examples."
	@echo ""

install-examples:
	cd $(top_builddir)/example && $(MAKE) install
else
examples:
	@echo "zoltan examples were disabled at configure time"

install-examples:
	@echo "zoltan examples were disabled at configure time"
endif

clean-tests:
	cd $(top_builddir)/test && $(MAKE) clean

clean-examples:
	cd $(top_builddir)/example && $(MAKE) clean

everything:
	$(MAKE) && $(MAKE) examples && $(MAKE) tests

clean-everything:
	$(MAKE) clean-examples && $(MAKE) clean-tests && $(MAKE) clean

install-everything:
	$(MAKE) install && $(MAKE) install-examples

if HAVE_MPI
SIMPI_SUBDIR=
else
SIMPI_SUBDIR=siMPI
endif

SUBDIRS = $(SIMPI_SUBDIR) src $(EXAMPLE_SUBDIR) $(TEST_SUBDIR) 

## #######################################################################
## The below targets allow you to use the new
## testharness to run the test suite as make targets
## #######################################################################

TRILINOS_HOME_DIR=@abs_top_srcdir@/../..
TRILINOS_BUILD_DIR=@abs_top_builddir@/../..
TRILINOS_MPI_MAX_PROC=4
TRILINOS_TEST_CATEGORY=INSTALL

runtests-serial :
	$(PERL_EXE) $(TRILINOS_HOME_DIR)/commonTools/test/utilities/runtests \
  --trilinos-dir=$(TRILINOS_HOME_DIR) \
  --comm=serial \
  --build-dir=$(TRILINOS_BUILD_DIR) \
  --category=$(TRILINOS_TEST_CATEGORY) \
  --output-dir=@abs_top_builddir@/test/runtests-results \
  --verbosity=1 \
  --packages=zoltan

runtests-mpi :
	$(PERL_EXE) $(TRILINOS_HOME_DIR)/commonTools/test/utilities/runtests \
  --trilinos-dir=$(TRILINOS_HOME_DIR) \
  --comm=mpi \
  --mpi-go=$(TRILINOS_MPI_GO) \
  --build-dir=$(TRILINOS_BUILD_DIR) \
  --max-proc=$(TRILINOS_MPI_MAX_PROC) \
  --category=$(TRILINOS_TEST_CATEGORY) \
  --output-dir=@abs_top_builddir@/test/runtests-results \
  --verbosity=1 \
  --packages=zoltan

## #######################################################################
## Export makefile stuff
## #######################################################################

if USING_EXPORT_MAKEFILES

install-exec-hook:	
	mkdir -p $(DESTDIR)$(includedir)
	cp $(top_builddir)/Makefile.export.zoltan $(DESTDIR)$(includedir)/.
	$(PERL_EXE) $(top_srcdir)/config/replace-install-prefix.pl \
		--exec-prefix=$(exec_prefix) \
		--my-export-makefile=Makefile.export.zoltan \
		--my-abs-top-srcdir=@abs_top_srcdir@ \
		--my-abs-incl-dirs=@abs_top_builddir@/src:@abs_top_srcdir@/src \
		--my-abs-lib-dirs=@abs_top_builddir@/src
	$(PERL_EXE) $(top_srcdir)/config/generate-makeoptions.pl $(top_builddir)/src/Makefile ZOLTAN > $(DESTDIR)$(includedir)/Makefile.export.zoltan.macros

uninstall-hook:
	rm -f $(includedir)/Makefile.export.zoltan
	rm -f $(includedir)/Makefile.export.zoltan.macros

else 

install-exec-hook:

uninstall-hook:

endif

## #######################################################################

