
SUBDIRS = \
    cashflows \
    currencies \
    experimental \
    indexes \
    instruments \
    legacy \
    math \
    methods \
    models \
    patterns \
    pricingengines \
    processes \
    quotes \
    termstructures \
    time \
    utilities

AM_CPPFLAGS = -I${top_builddir} -I${top_srcdir}

this_includedir=${includedir}/${subdir}
this_include_HEADERS = \
	any.hpp \
	auto_link.hpp \
	cashflow.hpp \
	compounding.hpp \
	config.hpp \
	currency.hpp \
	default.hpp \
	discretizedasset.hpp \
	errors.hpp \
	exchangerate.hpp \
	exercise.hpp \
	event.hpp \
	functional.hpp \
	grid.hpp \
	handle.hpp \
	index.hpp \
	instrument.hpp \
	interestrate.hpp \
	mathconstants.hpp \
	money.hpp \
	numericalmethod.hpp \
	option.hpp \
	optional.hpp \
	payoff.hpp \
	position.hpp \
	prices.hpp \
	pricingengine.hpp \
	qldefines.hpp \
	quantlib.hpp \
	quote.hpp \
	rebatedexercise.hpp \
	settings.hpp \
	shared_ptr.hpp \
	stochasticprocess.hpp \
	termstructure.hpp \
	timegrid.hpp \
	timeseries.hpp \
	tuple.hpp \
	types.hpp \
	version.hpp \
	volatilitymodel.hpp

cpp_files = \
    cashflow.cpp \
    currency.cpp \
	discretizedasset.cpp \
	errors.cpp \
	event.cpp \
	exchangerate.cpp \
	exercise.cpp \
    index.cpp \
    instrument.cpp \
    interestrate.cpp \
    money.cpp \
    position.cpp \
    prices.cpp \
	rebatedexercise.cpp \
    settings.cpp \
	stochasticprocess.cpp \
	termstructure.cpp \
	timegrid.cpp \
	version.cpp

if UNITY_BUILD

nodist_libQuantLib_la_SOURCES = unity.cpp

unity.cpp: Makefile.am
	echo "/* This file is automatically generated; do not edit.     */" > $@
	echo "/* Add the files to be included into Makefile.am instead. */" >> $@
	echo >> $@
	for i in $(cpp_files); do \
		echo "#include \"${subdir}/$$i\"" >> $@; \
	done

EXTRA_DIST = $(cpp_files)

else

libQuantLib_la_SOURCES = $(cpp_files)

EXTRA_DIST =

endif

lib_LTLIBRARIES = libQuantLib.la
libQuantLib_la_LDFLAGS = -version-info 0:0:0

libQuantLib_la_LIBADD = \
    cashflows/libCashFlows.la \
    currencies/libCurrencies.la \
    experimental/libExperimental.la \
    indexes/libIndexes.la \
    instruments/libInstruments.la \
    legacy/libLegacy.la \
    math/libMath.la \
    methods/libMethods.la \
    models/libModels.la \
    patterns/libPatterns.la \
    pricingengines/libPricingEngines.la \
    processes/libProcesses.la \
    quotes/libQuotes.la \
    termstructures/libTermStructures.la \
    time/libTime.la \
    utilities/libUtilities.la

EXTRA_DIST += \
	CMakeLists.txt \
	config.hpp.cfg \
	config.ansi.hpp \
	config.msvc.hpp \
	config.mingw.hpp \
	config.sun.hpp \
	qldefines.hpp.cfg \
	userconfig.hpp

quantlib.hpp: Makefile.am
	echo "/* This file is automatically generated; do not edit.     */" > ${srcdir}/$@
	echo "/* Add the files to be included into Makefile.am instead. */" >> ${srcdir}/$@
	echo >> ${srcdir}/$@
	echo "#include <ql/qldefines.hpp>" >> ${srcdir}/$@
	echo "#include <ql/version.hpp>" >> ${srcdir}/$@
	echo "#ifdef BOOST_MSVC" >> ${srcdir}/$@
	echo "#  include <ql/auto_link.hpp>" >> ${srcdir}/$@
	echo "#endif" >> ${srcdir}/$@
	echo >> ${srcdir}/$@
	for i in $(this_include_HEADERS); do \
		case $$i in \
			auto_link.hpp)     continue;; \
			config.hpp)        continue;; \
			mathconstants.hpp) continue;; \
			qldefines.hpp)     continue;; \
			quantlib.hpp)      continue;; \
			version.hpp)       continue;; \
			*.hpp)             ;; \
		esac; \
		echo "#include <${subdir}/$$i>" >> ${srcdir}/$@; \
	done
	echo >> ${srcdir}/$@
	subdirs='$(SUBDIRS)'; for i in $$subdirs; do \
		echo "#include <${subdir}/$$i/all.hpp>" >> ${srcdir}/$@; \
	done

install-data-hook:
	$(SED) -e "s,HAVE_CONFIG_H,QL_HAVE_CONFIG_H," \
           -e "s,/\* install-hook \*/,#define QL_HAVE_CONFIG_H," \
           $(DESTDIR)$(this_includedir)/qldefines.hpp > .qldefines.hpp
	$(INSTALL_DATA) .qldefines.hpp $(DESTDIR)$(this_includedir)/qldefines.hpp
	rm .qldefines.hpp
	$(SED) -e "s,PACKAGE,QL_PACKAGE," \
           -e "s,STDC,QL_STDC," \
           -e "s, HAVE, QL_HAVE," \
           -e "s, VERSION, QL_AC_VERSION," \
           $(DESTDIR)$(this_includedir)/config.hpp > .config.hpp
	$(INSTALL_DATA) .config.hpp $(DESTDIR)$(this_includedir)/config.hpp
	rm .config.hpp
depend:
	makedepend $(INCLUDES) -- $(CFLAGS) -- $(SOURCES)
