
.PHONY: tests quicktests cc_tests psirb_tests clean quicktestsclean

cc_subdirs = cc1 cc2 cc3 cc4 cc8 cc8a cc9 cc9a cc10 cc11 cc12 cc13 cc13a \
cc14 cc15 cc16 cc17 cc18 cc19 cc21 cc22 cc23 cc24 cc25 cc26 cc27 cc28 cc29 \
cc30 cc31 cc32 cc33 cc34 cc35 cc36 cc37 cc38 cc39 cc40 cc41 cc42 cc43 cc44 \
cc45 cc46 cc47 cc48 cc49 cc50 \

rb_subdirs = rb-scf-opt-numer rb-ccsd_t-sp rb-fci-h2o rb-ccsd-opt-grad

ci_subdirs = cisd-sp cisd-sp-2 cisd-opt-numer fci-h2o fci-h2o-2 fci-h2o-clpse fci-h2o-fzcv \
cisd-h2o+-0 cisd-h2o+-1 cisd-h2o+-2 \
fci-dipole fci-trans zaptn-nh2 

mcscf_subdirs = casscf-sp casscf-sa-sp casscf-fzc-sp rasscf-sp \
casscf-opt-numer casscf-opt casscf-sp-reorder

psimrcc_subdirs = psimrcc-sp1

scf_subdirs   = mcscf-rhf1 mcscf-rohf1 mcscf-twocon1

subdirs = \
scf-opt scf-opt-fragments mp2-opt-fragments scf-opt2 scf-opt3 scf-opt4 scf-opt5 scf-opt6 scf-opt7 \
scf-opt9 scf-opt10 scf-opt11 scf-opt12 \
scf-opt-numer scf-opt2-numer mp2-opt-numer \
scf-freq-first-3 scf-freq-first-3a scf-freq-first-5 scf-freq-first-5a \
scf-freq-none-3 scf-freq-none-5 \
scf-symm-fc-numer scf-fc-numer \
scf-freq scf-polar rhf-stab uhf-stab rohf-stab mp2-sp mp2-direct-sp mp2-scs \
$(ci_subdirs) \
$(mcscf_subdirs) \
scf-mvd-opt scf-mvd-opt-numer scf-mvd-opt-puream \
scf-mvd-opt-numer-puream \
$(cc_subdirs) \
$(psimrcc_subdirs) \
$(scf_subdirs) \
dboc-rhf1 dboc-rohf1 dboc-uhf1 dboc-rcisd1 dboc-rocisd1 \
rhf-oeprop mp2-oeprop mp2-opt \
extrema-deloc extrema-zmat mp2r12-sp1 \
rhf-lindep1 rohf-lindep1 uhf-lindep1 \
scf+d-opt1 \
scf+d-freq \
psi_start \

# Only test if psirb was compiled
HAVE_RUBY = no
ifeq ($(HAVE_RUBY),yes)
subdirs += $(rb_subdirs)
endif

# the bare minimum
quicktestdirs = scf-opt scf-freq scf-polar rhf-stab \
rhf-oeprop cc1 mp2-opt mp2-direct-sp mp2-scs \
dboc-rhf1 mp2r12-sp1 rhf-lindep1 cisd-sp casscf-sp \
psi_start

tests:
	for dir in $(subdirs); \
	do \
	 (cd $${dir} && echo ...Testing $${dir}... && $(MAKE)) || exit 1; \
	done

quicktests:
	for dir in $(quicktestdirs); \
	do \
	 (cd $${dir} && echo ...Testing $${dir}... && $(MAKE)) || exit 1; \
	done

cc_tests:
	for dir in $(cc_subdirs); \
	do \
	 (cd $${dir} && echo ...Testing $${dir}... && $(MAKE)) || exit 1; \
	done

ci_tests:
	for dir in $(ci_subdirs); \
	do \
	 (cd $${dir} && echo ...Testing $${dir}... && $(MAKE)) || exit 1; \
	done

mcscf_tests:
	for dir in $(mcscf_subdirs); \
	do \
	 (cd $${dir} && echo ...Testing $${dir}... && $(MAKE)) || exit 1; \
	done

scf_tests:
	for dir in $(scf_subdirs); \
	do \
	 (cd $${dir} && echo ...Testing $${dir}... && $(MAKE)) || exit 1; \
	done

psirb_tests:
	for dir in $(rb_subdirs); \
	do \
	 (cd $${dir} && echo ...Testing $${dir}... && $(MAKE)) || exit 1; \
	done

clean:
	for dir in $(subdirs); \
	do \
	 (cd $${dir} && echo ...Cleaning $${dir}... && $(MAKE) clean) || exit 1; \
	done
	rm -f ../test-case-results

quicktestsclean:
	for dir in $(quicktestdirs); \
	do \
	 (cd $${dir} && echo ...Cleaning $${dir}... && $(MAKE) clean) || exit 1; \
	done
	rm -f ../test-case-results

top_srcdir = /work/a/ports/science/psi3/work/psi3
srcdir = /work/a/ports/science/psi3/work/psi3/tests
top_objdir = ..

$(top_srcdir)/configure: $(top_srcdir)/configure.ac $(top_srcdir)/aclocal.m4
	cd $(top_srcdir) && autoconf

$(top_objdir)/config.status: $(top_srcdir)/configure
	cd $(top_objdir) && ./config.status --recheck

Makefile: $(srcdir)/Makefile.in $(top_objdir)/config.status
	cd $(top_objdir) && CONFIG_FILES=tests/Makefile ./config.status

