# -*-Makefile-*-

all: McLachlan_ADM.out McLachlan_BSSN.out McLachlan_ADMConstraints.out McLachlan_ADMQuantities.out WaveToy.out WaveToyFO.out hydro.out Carlile_BSSN.out
	@echo
	@echo "The Cactus thorns are up to date."
	@echo

McLachlan_ADM.out: McLachlan_ADM.m
	rm -rf ML_ADM
	./runmath.sh $^
	for thorn in ML_ADM; do					\
		./copy-if-changed.sh $$thorn ../$$thorn;	\
	done

McLachlan_BSSN.out: McLachlan_BSSN.m
	rm -rf ML_BSSN* ML_CCZ4*
	./runmath.sh $^
	for thorn in ML_BSSN* ML_CCZ4*; do				   \
		./copy-if-changed.sh $$thorn ../$$thorn &&		   \
		./create-helper-thorn.sh ML_BSSN $$thorn &&			   \
		./copy-if-changed.sh $${thorn}_Helper ../$${thorn}_Helper; \
	done

McLachlan_ADMConstraints.out: McLachlan_ADMConstraints.m
	rm -rf ML_ADMConstraints*
	./runmath.sh $^
	for thorn in ML_ADMConstraints*; do			\
		./copy-if-changed.sh $$thorn ../$$thorn;	\
	done

McLachlan_ADMQuantities.out: McLachlan_ADMQuantities.m
	rm -rf ML_ADMQuantities*
	./runmath.sh $^
	for thorn in ML_ADMQuantities*; do			\
		./copy-if-changed.sh $$thorn ../$$thorn;	\
	done

WaveToy.out: WaveToy.m
	rm -rf ML_WaveToy ML_WaveToy_CL
	./runmath.sh $^
	for thorn in ML_WaveToy ML_WaveToy_CL; do		\
		./copy-if-changed.sh $$thorn ../$$thorn;	\
	done

WaveToyFO.out: WaveToyFO.m
	rm -rf ML_WaveToyFO
	./runmath.sh $^
	for thorn in ML_WaveToyFO; do				\
		./copy-if-changed.sh $$thorn ../$$thorn;	\
	done

hydro.out: hydro.m
	rm -rf ML_hydro
	./runmath.sh $^
	for thorn in ML_hydro; do				\
		./copy-if-changed.sh $$thorn ../$$thorn;	\
	done

Carlile_BSSN.out: Carlile_BSSN.m
	rm -rf CL_BSSN*
	./runmath.sh $^
	for thorn in CL_BSSN*; do \
		./copy-if-changed.sh $$thorn ../$$thorn; \
		./create-helper-thorn.sh CL_BSSN $$thorn; \
		./copy-if-changed.sh $${thorn}_Helper ../$${thorn}_Helper; \
	done

clean:
	rm -rf ML_ADM ML_BSSN* ML_CCZ4* ML_ADMConstraints* ML_ADMQuantities* CL_BSSN*
	rm -rf ML_WaveToy ML_WaveToy_CL ML_WaveToyFO
	rm -rf ML_hydro
	rm -f McLachlan_ADM.out McLachlan_ADM.err
	rm -f McLachlan_BSSN.out McLachlan_BSSN.err
	rm -f McLachlan_ADMConstraints.out McLachlan_ADMConstraints.err
	rm -f McLachlan_ADMQuantities.out McLachlan_ADMQuantities.err
	rm -f WaveToy.out WaveToy.err
	rm -f WaveToyFO.out WaveToyFO.err
	rm -f hydro.out hydro.err
	rm -f Carlile_BSSN.out Carlile_BSSN.err

.PHONY: all clean
