# vim: set ft=make: DESTDIR ?= . LOW_PRECISION ?= double HIGH_PRECISION ?= double TARGETS = MP-Gadget MP-GenIC CFLAGS = -I. -I$(DESTDIR) $(OPTIONS) $(GSL_INCL) -I$(CURDIR)/depends/include CFLAGS += "-DLOW_PRECISION=$(LOW_PRECISION)" CFLAGS += "-DHIGH_PRECISION=$(HIGH_PRECISION)" BUNDLEDLIBS = -lmpsort-mpi -lradixsort -lbigfile-mpi -lbigfile -lpfft_omp -lfftw3_mpi -lfftw3_omp -lfftw3 LIBS = -lm $(GSL_LIBS) -Ldepends/lib $(BUNDLEDLIBS) -lstdc++ OPTIONS = $(OPTIMIZE) $(OPT) OBJECTS = \ gdbtools.o \ fof.o fofpetaio.o petaio.o \ param.o paramset.o utils-string.o \ domain.o allvars.o main.o \ blackhole.o \ run.o predict.o begrun.o endrun.o global.o \ timestep.o init.o io.o sfr_eff.o \ accel.o \ cooling.o openmpsort.o \ system.o allocate.o density.o \ treewalk.o cosmology.o \ gravshort-tree.o gravshort-tree-old.o gravshort-pair.o hydra.o driftfac.o \ gravpm.o powerspectrum.o \ forcetree.o peano.o \ petapm.o longrange.o mymalloc.o \ densitykernel.o interp.o lightcone.o walltime.o\ runtests.o \ cppexample.o ICOBJECTS = genic-main.o genic-power.o genic-allvars.o genic-params.o \ petapm.o \ paramset.o \ utils-string.o \ openmpsort.o \ genic-zeldovich.o \ genic-save.o \ walltime.o \ mymalloc.o \ endrun.o \ INCL = allvars.h proto.h forcetree.h cooling.h domain.h treewalk.h \ fof.h cosmology.h powerspectrum.h \ petaio.h TESTED = interp powerspectrum EXEC = $(TARGETS:%=$(DESTDIR)/%) OBJS = $(OBJECTS:%=$(DESTDIR)/%) TESTBIN = $(TESTED:%=$(DESTDIR)/%_test) ICOBJS = $(ICOBJECTS:%=$(DESTDIR)/%) FILES = $(shell git ls-files) all: depends builddir $(EXEC) .PHONY: depends builddir test all depends: cd depends; make builddir: mkdir -p $(DESTDIR) $(DESTDIR)/MP-Gadget: $(OBJS) $(MPICC) $(OPTIMIZE) $(OBJS) $(LIBS) -o $@ $(DESTDIR)/MP-GenIC: $(ICOBJS) $(MPICC) $(OPTIMIZE) $(ICOBJS) $(LIBS) -o $@ $(DESTDIR)/config.h: Makefile $(CONFIG) $(FILES) mkdir -p `dirname $@` MPICC="$(MPICC)" CFLAGS="$(CFLAGS)" OPT="$(OPT)" OPTIMIZE="$(OPTIMIZE)" bash makeconfig.sh > $@ $(DESTDIR)/%.o: %.c $(INCL) @echo Compiling $<; $(MPICC) -c -o $@ $(CFLAGS) $< $(DESTDIR)/main.o: main.c $(INCL) $(DESTDIR)/config.h @echo Compiling $<; $(MPICC) -c -o $@ $(CFLAGS) $< $(DESTDIR)/%.o: %.cpp $(INCL) @echo Compiling $<; $(MPICXX) -c -o $@ $(CFLAGS) $< clean: rm -f $(OBJS) $(EXEC) $(ICOBJS) test: $(TESTBIN) for tt in $^ ; do ./$$tt ; done $(DESTDIR)/run_%_test: $(DESTDIR)/%_test $(DESTDIR)/%_test: test/%_test.c $(DESTDIR)/%.o $(MPICC) $(CFLAGS) $(LIBS) $^ -o $@ -lcmocka