# $Id: makefile.am 3769 2015-12-29 16:13:16Z bradbell $
# -----------------------------------------------------------------------------
# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell
#
# CppAD is distributed under multiple licenses. This distribution is under
# the terms of the
#                     GNU General Public License Version 3.
#
# A copy of this license is included in the COPYING file of this distribution.
# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
# -----------------------------------------------------------------------------
#
BUILT_SOURCES = $(top_srcdir)/cppad/configure.hpp
$(top_srcdir)/cppad/configure.hpp: cppad/configure.hpp
	cp cppad/configure.hpp $(top_srcdir)/cppad/configure.hpp
#
if CppAD_POSTFIX
postfix_dir  = $(POSTFIX_DIR)
else
postfix_dir  = .
endif
#
# Did user specify a value for ADOLC_DIR in configure command line
if CppAD_ADOLC
SPEED_ADOLC_TESTS   = speed/adolc
else
SPEED_ADOLC_TESTS   =
endif
#
# Did user specify a value for FADBAD_DIR in configure command line
if CppAD_FADBAD
SPEED_FADBAD_TESTS  = speed/fadbad
else
SPEED_FADBAD_TESTS  =
endif
#
# Did user specify a value for SACADO_DIR in configure command line
if CppAD_SACADO
SPEED_SACADO_TESTS  = speed/sacado
else
SPEED_SACADO_TESTS  =
endif
#
# Did user specify a value for IPOPT_DIR in configure command line
if CppAD_IPOPT
IPOPT_TESTS = \
	example/ipopt_solve \
	cppad_ipopt/example \
	cppad_ipopt/speed \
	cppad_ipopt/test
#
IPOPT_DIRS = \
	cppad_ipopt/src \
	$(IPOPT_TESTS)
#
IPOPT_HEADER = \
	cppad_ipopt/src/cppad_ipopt_nlp.hpp
else
IPOPT_TESTS  =
IPOPT_DIRS   =
IPOPT_HEADER =
endif
#
# Is the library archiving program present
if CppAD_HAVE_AR
SPEED_TESTS = \
	$(SPEED_ADOLC_TESTS)  \
	speed/cppad \
	speed/double \
	speed/example \
	$(SPEED_FADBAD_TESTS) \
	speed/profile \
	$(SPEED_SACADO_TESTS)
#
SPEED_DIRS = \
	speed/src \
	$(SPEED_TESTS)
else
	SPEED_TESTS =
	SPEED_DIRS =
endif
# ---------------------------------------------------------------------------
myincludedir = $(includedir)/$(postfix_dir)
#
myinclude_HEADERS = \
	$(IPOPT_HEADER)
#
nobase_myinclude_HEADERS =  \
	cppad/utility.hpp \
	cppad/base_require.hpp \
	cppad/utility/check_numeric_type.hpp \
	cppad/utility/check_simple_vector.hpp \
	cppad/configure.hpp \
	cppad/cppad.hpp \
	cppad/utility/elapsed_seconds.hpp \
	cppad/example/base_adolc.hpp \
	cppad/example/cppad_eigen.hpp \
	cppad/example/eigen_plugin.hpp \
	cppad/example/matrix_mul.hpp \
	cppad/utility/error_handler.hpp \
	cppad/utility/index_sort.hpp \
	cppad/ipopt/solve.hpp \
	cppad/ipopt/solve_callback.hpp \
	cppad/ipopt/solve_result.hpp \
	cppad/local/abort_recording.hpp \
	cppad/local/abs.hpp \
	cppad/local/abs_op.hpp \
	cppad/local/acos_op.hpp \
	cppad/local/acosh.hpp \
	cppad/local/acosh_op.hpp \
	cppad/local/ad_assign.hpp \
	cppad/local/ad_binary.hpp \
	cppad/local/ad_ctor.hpp \
	cppad/local/add_eq.hpp \
	cppad/local/add.hpp \
	cppad/local/add_op.hpp \
	cppad/local/ad_io.hpp \
	cppad/local/ad_fun.hpp \
	cppad/local/ad.hpp \
	cppad/local/ad_tape.hpp \
	cppad/local/ad_to_string.hpp \
	cppad/local/ad_valued.hpp \
	cppad/local/arithmetic.hpp \
	cppad/local/asin_op.hpp \
	cppad/local/asinh.hpp \
	cppad/local/asinh_op.hpp \
	cppad/local/atan2.hpp \
	cppad/local/atan_op.hpp \
	cppad/local/atanh.hpp \
	cppad/local/atanh_op.hpp \
	cppad/local/atomic_base.hpp \
	cppad/local/azmul.hpp \
	cppad/local/base_complex.hpp \
	cppad/local/base_cond_exp.hpp \
	cppad/local/base_double.hpp \
	cppad/local/base_float.hpp \
	cppad/local/base_limits.hpp \
	cppad/local/base_std_math.hpp \
	cppad/local/base_to_string.hpp \
	cppad/local/bender_quad.hpp \
	cppad/local/bool_fun.hpp \
	cppad/local/bool_valued.hpp \
	cppad/local/capacity_order.hpp \
	cppad/local/checkpoint.hpp \
	cppad/local/check_for_nan.hpp \
	cppad/local/color_general.hpp \
	cppad/local/color_symmetric.hpp \
	cppad/local/compare.hpp \
	cppad/local/comp_op.hpp \
	cppad/local/compute_assign.hpp \
	cppad/local/cond_exp.hpp \
	cppad/local/cond_op.hpp \
	cppad/local/convert.hpp \
	cppad/local/cosh_op.hpp \
	cppad/local/cos_op.hpp \
	cppad/local/cppad_assert.hpp \
	cppad/local/cppad_colpack.hpp \
	cppad/local/cskip_op.hpp \
	cppad/local/csum_op.hpp \
	cppad/local/declare_ad.hpp \
	cppad/local/define.hpp \
	cppad/local/dependent.hpp \
	cppad/local/discrete.hpp \
	cppad/local/discrete_op.hpp \
	cppad/local/div_eq.hpp \
	cppad/local/div.hpp \
	cppad/local/div_op.hpp \
	cppad/local/drivers.hpp \
	cppad/local/epsilon.hpp \
	cppad/local/equal_op_seq.hpp \
	cppad/local/erf.hpp \
	cppad/local/erf_op.hpp \
	cppad/local/exp_op.hpp \
	cppad/local/expm1.hpp \
	cppad/local/expm1_op.hpp \
	cppad/local/for_jac_sweep.hpp \
	cppad/local/for_one.hpp \
	cppad/local/for_sparse_jac.hpp \
	cppad/local/for_two.hpp \
	cppad/local/forward0sweep.hpp \
	cppad/local/forward1sweep.hpp \
	cppad/local/forward2sweep.hpp \
	cppad/local/forward.hpp \
	cppad/local/fun_check.hpp \
	cppad/local/fun_construct.hpp \
	cppad/local/fun_eval.hpp \
	cppad/local/hash_code.hpp \
	cppad/local/hessian.hpp \
	cppad/local/identical.hpp \
	cppad/local/independent.hpp \
	cppad/local/integer.hpp \
	cppad/local/jacobian.hpp \
	cppad/local/load_op.hpp \
	cppad/local/log_op.hpp \
	cppad/local/log1p.hpp \
	cppad/local/log1p_op.hpp \
	cppad/local/lu_ratio.hpp \
	cppad/local/mul_eq.hpp \
	cppad/local/mul.hpp \
	cppad/local/mul_op.hpp \
	cppad/local/near_equal_ext.hpp \
	cppad/local/numeric_limits.hpp \
	cppad/local/num_skip.hpp \
	cppad/local/old_atomic.hpp \
	cppad/local/omp_max_thread.hpp \
	cppad/local/op_code.hpp \
	cppad/local/op.hpp \
	cppad/local/optimize.hpp \
	cppad/local/opt_val_hes.hpp \
	cppad/local/ordered.hpp \
	cppad/local/parallel_ad.hpp \
	cppad/local/parameter_op.hpp \
	cppad/local/par_var.hpp \
	cppad/local/player.hpp \
	cppad/local/pod_vector.hpp \
	cppad/local/pow.hpp \
	cppad/local/pow_op.hpp \
	cppad/local/print_for.hpp \
	cppad/local/print_op.hpp \
	cppad/local/prototype_op.hpp \
	cppad/local/recorder.hpp \
	cppad/local/reverse.hpp \
	cppad/local/reverse_sweep.hpp \
	cppad/local/rev_hes_sweep.hpp \
	cppad/local/rev_jac_sweep.hpp \
	cppad/local/rev_one.hpp \
	cppad/local/rev_sparse_hes.hpp \
	cppad/local/rev_sparse_jac.hpp \
	cppad/local/rev_two.hpp \
	cppad/local/set_get_in_parallel.hpp \
	cppad/local/sign.hpp \
	cppad/local/sign_op.hpp \
	cppad/local/sin_op.hpp \
	cppad/local/sinh_op.hpp \
	cppad/local/sparse_binary_op.hpp \
	cppad/local/sparse_hessian.hpp \
	cppad/local/sparse.hpp \
	cppad/local/sparse_jacobian.hpp \
	cppad/local/sparse_list.hpp \
	cppad/local/sparse_pack.hpp \
	cppad/local/sparse_pattern.hpp \
	cppad/local/sparse_set.hpp \
	cppad/local/sparse_unary_op.hpp \
	cppad/local/sqrt_op.hpp \
	cppad/local/standard_math.hpp \
	cppad/local/std_math_98.hpp \
	cppad/local/std_set.hpp \
	cppad/local/store_op.hpp \
	cppad/local/sub_eq.hpp \
	cppad/local/sub.hpp \
	cppad/local/sub_op.hpp \
	cppad/local/tanh_op.hpp \
	cppad/local/tan_op.hpp \
	cppad/local/tape_link.hpp \
	cppad/local/test_vector.hpp \
	cppad/local/testvector.hpp \
	cppad/local/unary_minus.hpp \
	cppad/local/unary_plus.hpp \
	cppad/local/undef.hpp \
	cppad/local/user_ad.hpp \
	cppad/local/value.hpp \
	cppad/local/var2par.hpp \
	cppad/local/vec_ad.hpp \
	cppad/local/zdouble.hpp \
	cppad/local/zmul_op.hpp \
	cppad/utility/lu_factor.hpp \
	cppad/utility/lu_invert.hpp \
	cppad/utility/lu_solve.hpp \
	cppad/utility/memory_leak.hpp \
	cppad/utility/nan.hpp \
	cppad/utility/near_equal.hpp \
	cppad/utility/ode_err_control.hpp \
	cppad/utility/ode_gear_control.hpp \
	cppad/utility/ode_gear.hpp \
	cppad/utility/omp_alloc.hpp \
	cppad/utility/poly.hpp \
	cppad/utility/pow_int.hpp \
	cppad/utility/romberg_mul.hpp \
	cppad/utility/romberg_one.hpp \
	cppad/utility/rosen_34.hpp \
	cppad/utility/runge_45.hpp \
	cppad/utility/to_string.hpp \
	cppad/speed/det_33.hpp \
	cppad/speed/det_by_lu.hpp \
	cppad/speed/det_by_minor.hpp \
	cppad/speed/det_grad_33.hpp \
	cppad/speed/det_of_minor.hpp \
	cppad/speed/mat_sum_sq.hpp \
	cppad/speed/ode_evaluate.hpp \
	cppad/speed/sparse_hes_fun.hpp \
	cppad/speed/sparse_jac_fun.hpp \
	cppad/utility/speed_test.hpp \
	cppad/speed/uniform_01.hpp \
	cppad/utility/thread_alloc.hpp \
	cppad/utility/time_test.hpp \
	cppad/utility/track_new_del.hpp \
	cppad/utility/vector.hpp
# End nobase_myinclude_HEADERS (check_makefile.sh uses this comment)
# ---------------------------------------------------------------
#
# No objects or executables are required to install CppAD.
# See 'make test' below for building the tests.
SUBDIRS =  \
	$(IPOPT_DIRS) \
	$(SPEED_DIRS) \
	example \
	example/atomic \
	compare_c \
	introduction/get_started \
	introduction/exp_apx \
	print_for \
	multi_thread \
	multi_thread/test_multi \
	test_more
#
# note that bin/gpl_license.sh is deleted by dist-hook
EXTRA_DIST = \
	bin \
	build.sh \
	doc.omh \
	doc \
	gpl-3.0.txt \
	epl-v10.html \
	omh \
	uw_copy_040507.html \
	\
	compare_c/CMakeLists.txt \
	cppad/CMakeLists.txt \
	pkgconfig/CMakeLists.txt \
	example/CMakeLists.txt \
	example/atomic/CMakeLists.txt \
	example/ipopt_solve/CMakeLists.txt \
	test_more/CMakeLists.txt \
	CMakeLists.txt \
	cppad_ipopt/src/CMakeLists.txt \
	cppad_ipopt/example/CMakeLists.txt \
	cppad_ipopt/test/CMakeLists.txt \
	cppad_ipopt/CMakeLists.txt \
	cppad_ipopt/speed/CMakeLists.txt \
	speed/main.cpp \
	speed/cppad/CMakeLists.txt \
	speed/adolc/CMakeLists.txt \
	speed/fadbad/CMakeLists.txt \
	speed/src/CMakeLists.txt \
	speed/example/CMakeLists.txt \
	speed/CMakeLists.txt \
	speed/double/CMakeLists.txt \
	speed/profile/CMakeLists.txt \
	speed/sacado/CMakeLists.txt \
	multi_thread/bthread/CMakeLists.txt \
	multi_thread/CMakeLists.txt \
	multi_thread/openmp/CMakeLists.txt \
	multi_thread/pthread/CMakeLists.txt \
	print_for/CMakeLists.txt

test_directory_list = \
	$(IPOPT_TESTS) \
	$(SPEED_TESTS) \
	example \
	example/atomic \
	compare_c \
	introduction/get_started \
	introduction/exp_apx \
	multi_thread \
	multi_thread/test_multi \
	print_for \
	test_more

test: all
	rm -f test.log
	touch test.log
	echo "#! /bin/sh -e"                               >  test.sh
	for dir in $(test_directory_list) ; do (                        \
		echo "#"                                      >> test.sh ; \
		echo "echo \"Running make test in $$dir\""    >> test.sh ; \
		echo "cd $$dir "                              >> test.sh ; \
		echo "make test"                              >> test.sh ; \
		echo "cd $(ABS_TOP_BUILDDIR)"                 >> test.sh ; \
	) done
	echo "exit 0"                                      >> test.sh
	chmod +x test.sh
	./test.sh
#
dist-hook:
	rm -rf `find . -name .svn`
	rm $(distdir)/doc/error.wrd
	rm $(distdir)/bin/gpl_license.sh
#
doc_postfix = $(DESTDIR)$(datadir)/doc/$(postfix_dir)
doc_package = $(DESTDIR)$(datadir)/doc/$(postfix_dir)/$(PACKAGE)-$(VERSION)
inc_postfix = $(DESTDIR)/$(myincludedir)
install-data-hook:
if CppAD_DOCUMENTATION
	if [ ! -e $(doc_postfix) ] ; then mkdir -p $(doc_postfix) ; fi
	if [ -e $(doc_package) ] ; then rm -rf $(doc_package) ; fi
	cp -a $(top_srcdir)/doc $(doc_package)
	chmod -R a-w $(doc_package)
	chmod -R u+w $(doc_package)
	chmod -R a+r $(doc_package)
endif
if CppAD_DEPRECATED
	cp -a $(top_srcdir)/cppad/deprecated/* $(inc_postfix)/cppad
	chmod -R a-w $(inc_postfix)/cppad
	chmod -R u+w $(inc_postfix)/cppad
	chmod -R a+r $(inc_postfix)/cppad
endif
#
pkgconfigdir = $(datadir)/pkgconfig
pkgconfig_DATA = pkgconfig/cppad.pc
