Makefile 3.57 KB
Newer Older
1
2
3
4
5
6
7
8
9
# Makefile to build SPINS, generalized for multiple systemd

# The "system.mk" file in the current directory will contain
# system-specific make variables, most notably the
# C/C++ compiler/linker, 
include system.mk


# Compile with debugging flags
10
DEBUG?=false
11
# Compile with optimizations
12
OPTIM?=true
13
14
# Compile with extra optimizations that may require significantly
# longer for compilation
15
SLOW_OPTIM?=false
16

17
18
19
# Compile with instrumentation support for timing
TIMINGS?=false

20
21
22
23
24
25
# If MPICXX isn't separately defined, then set it to be the same
# as CXX
ifeq ($(strip $(MPICXX)),)
   MPICXX:=$(CXX)
endif

26
# Assemble the CFLAGS
27
CFLAGS:=$(SYSTEM_CFLAGS) $(MPI_CFLAGS) $(SYSTEM_CXXFLAGS)
28
29
30
31
32
33
34
35
36
37
38
39
40
41
LDFLAGS:=$(SYSTEM_LDFLAGS)
ifeq ($(DEBUG),true)
   CFLAGS:=$(CFLAGS) $(DEBUG_CFLAGS)
   LDFLAGS:=$(LDFLAGS) $(DEBUG_LDFLAGS)
endif
ifeq ($(OPTIM),true)
   CFLAGS:=$(CFLAGS) $(OPTIM_CFLAGS)
   LDFLAGS:=$(LDFLAGS) $(OPTIM_LDFLAGS)
   ifeq ($(SLOW_OPTIM),true)
      CFLAGS:=$(CFLAGS) $(EXTRA_OPTIM_CFLAGS)
      LDFLAGS:=$(LDFLAGS) $(EXTRA_OPTIM_LDFLAGS)
   endif
endif

42
43
44
45
46
ifeq ($(TIMINGS),true)
   CFLAGS:=$(CFLAGS) -DTIMING_ENABLE
endif


47
INCLUDE_DIRS := -I../include $(MPI_INCDIR) $(LAPACK_INCDIR) $(BLITZ_INCDIR) $(FFTW_INCDIR) $(UMF_INCDIR)
48
49
CFLAGS := $(CFLAGS) $(INCLUDE_DIRS)

50
LIB_DIRS := -L../lib $(MPI_LIBDIR) $(LAPACK_LIBDIR) $(BLITZ_LIBDIR) $(FFTW_LIBDIR) $(UMF_LIBDIR)
Christopher Subich's avatar
Christopher Subich committed
51
LDLIBS := -lfftw3 $(MPI_LIB) -lumfpack -lamd -lboost_program_options $(LAPACK_LIB) -lblitz -lm -lstdc++ 
52
LDFLAGS := $(LDFLAGS) $(LIB_DIRS) 
Christopher Subich's avatar
Christopher Subich committed
53
54
55
56
57
58

.PHONY: all 
all: tests/test_deriv_x tests/test_write_x tests/test_esolve_x tests/test_heat_x tests/test_ode_x tests/test_ns_x

.PHONY: clean
clean:
59
	rm -f *.o tests/*.o cases/*.o cases/*.src.? tests/*.src.?
Christopher Subich's avatar
Christopher Subich committed
60
61
62
63
64

objfiles: $(shell ls *.cpp | sed -e 's/cpp/o/g')

NSIntegrator.o: NSIntegrator.cpp NSIntegrator_impl.cc

65
tests/test%.o: tests/test%.cpp
66
	$(MPICXX) $(CFLAGS) -o $@ -c $<
Christopher Subich's avatar
Christopher Subich committed
67

68
tests/test%_x: tests/test%.o tests/test%.src.o TArray.o Parformer.o T_util.o  ESolver.o Timestep.o NSIntegrator.o BaseCase.o Science.o Splits.o Par_util.o Split_reader.o gmres.o gmres_1d_solver.o gmres_2d_solver.o grad.o multigrid.o Options.o 
69
70
	$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) 

Christopher Subich's avatar
Christopher Subich committed
71
cases/%.o: cases/%.cpp NSIntegrator_impl.cc NSIntegrator.hpp
72
	$(MPICXX) $(CFLAGS) -o $@ -c  $<
Christopher Subich's avatar
Christopher Subich committed
73
74
75
76
77
78
79

nonhydro_x: nonhydro_sw.o TArray.o T_util.o Parformer.o Splits.o Par_util.o Split_reader.o 
	$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)

derek_x: derek.o TArray.o T_util.o Parformer.o ESolver.o Timestep.o Splits.o Par_util.o Split_reader.o gmres.o gmres_1d_solver.o gmres_2d_solver.o grad.o multigrid.o 
	$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)

80
cases/%.x: cases/%.o cases/%.src.o TArray.o T_util.o Parformer.o ESolver.o Timestep.o NSIntegrator.o BaseCase.o \
Christopher Subich's avatar
Christopher Subich committed
81
           Science.o Splits.o Par_util.o Split_reader.o gmres.o gmres_1d_solver.o gmres_2d_solver.o grad.o multigrid.o Options.o timing.o
Christopher Subich's avatar
Christopher Subich committed
82
83
	$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)

84
cases/%_x: cases/%.o cases/%.src.o TArray.o T_util.o Parformer.o ESolver.o Timestep.o NSIntegrator.o BaseCase.o \
Christopher Subich's avatar
Christopher Subich committed
85
           Science.o Splits.o Par_util.o Split_reader.o gmres.o gmres_1d_solver.o gmres_2d_solver.o grad.o multigrid.o Options.o timing.o
Christopher Subich's avatar
Christopher Subich committed
86
87
	$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)

88
89
90
91
92
tests/test%.src.c: tests/test%.cpp CaseFileSource.c
	echo "const char casefilesource[] = {`xxd -i < $<`, 0x00};" > $@
	echo "const char casefilename[] = \"$<\";" >> $@
	cat CaseFileSource.c >> $@

93
94
95
96
97
cases/%.src.c: cases/%.cpp CaseFileSource.c
	echo "const char casefilesource[] = {`xxd -i < $<`, 0x00};" > $@
	echo "const char casefilename[] = \"$<\";" >> $@
	cat CaseFileSource.c >> $@

98
%.o: %.cpp	*.hpp
99
	$(MPICXX) $(CFLAGS) -o $@ -c $< 
Christopher Subich's avatar
Christopher Subich committed
100

101
102
print-%  : ; @echo $* = $($*)

103
.SECONDARY: