
SUBDIRS = calendars daycounters

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

this_includedir=${includedir}/${subdir}
this_include_HEADERS = \
    all.hpp \
    asx.hpp \
    businessdayconvention.hpp \
    calendar.hpp \
    date.hpp \
    dategenerationrule.hpp \
	daycounter.hpp \
	ecb.hpp \
    frequency.hpp \
    imm.hpp \
    period.hpp \
    schedule.hpp \
    timeunit.hpp \
    weekday.hpp

cpp_files = \
    asx.cpp \
    businessdayconvention.cpp \
    calendar.cpp \
    date.cpp \
    dategenerationrule.cpp \
    ecb.cpp \
    frequency.cpp \
    imm.cpp \
    period.cpp \
    schedule.cpp \
    timeunit.cpp \
    weekday.cpp

if UNITY_BUILD

nodist_libTime_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

libTime_la_SOURCES = $(cpp_files)

endif

libTime_la_LIBADD = \
    calendars/libCalendars.la \
    daycounters/libDayCounters.la

noinst_LTLIBRARIES = libTime.la

all.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}/$@
	for i in $(filter-out all.hpp, $(this_include_HEADERS)); do \
		echo "#include <${subdir}/$$i>" >> ${srcdir}/$@; \
	done
	echo >> ${srcdir}/$@
	subdirs='$(SUBDIRS)'; for i in $$subdirs; do \
		echo "#include <${subdir}/$$i/all.hpp>" >> ${srcdir}/$@; \
	done

