-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathMakefile_main
174 lines (122 loc) · 4.48 KB
/
Makefile_main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#Files containing classes to include
#e.g. change RECOMBINATION_FILES to "recfast cosmorec" to also support cosmorec
# or to "recfast hyrec" to support HYREC-2
POWERSPECTRUM_FILES ?= InitialPower
REIONIZATION_FILES ?= reionization
RECOMBINATION_FILES ?= recfast
NONLINEAR_FILES ?= halofit SecondOrderPK
DARKENERGY_FILES ?= DarkEnergyFluid DarkEnergyPPF PowellMinimize DarkEnergyQuintessence
BISPECTRUM ?= SeparableBispectrum
#Driver program
DRIVER ?= inidriver
#DRIVER ?= sigma8
#DRIVER ?= tester
Release: OUTPUT_DIR = Release
Debug: OUTPUT_DIR = Debug
Release: DLL_DIR = Releaselib
Debug: DLL_DIR = Debuglib
OUTPUT_DIR ?= Release
PYCAMB_OUTPUT_DIR ?= ../camb
DLL_DIR ?= Releaselib
CAMBLIB = libcamb.a
SOURCEFILES = constants config classes MathUtils subroutines DarkAge21cm \
DarkEnergyInterface SourceWindows massive_neutrinos model results bessels \
$(RECOMBINATION_FILES) $(DARKENERGY_FILES) equations \
$(REIONIZATION_FILES) $(POWERSPECTRUM_FILES) $(NONLINEAR_FILES) \
lensing $(BISPECTRUM) cmbmain camb camb_python
F90WFLAGS = -Waliasing -Wampersand -Wconversion -Wc-binding-type -Wintrinsics-std \
-Wno-tabs -Wintrinsic-shadow -Wline-truncation -Wtarget-lifetime -Wreal-q-constant
# -Wsurprising -Wunused
F90FLAGS = $(FFLAGS)
#F90FLAGS += $(F90WFLAGS)
SF90FLAGS = $(SFFLAGS) $(FFLAGS)
HEALPIXLD = -L$(HEALPIXDIR)/lib -lhealpix -L$(FITSDIR) -l$(FITSLIB)
CAMBOBJ = $(patsubst %,%.o,$(SOURCEFILES))
FORUTILS_DIR ?= $(FORUTILSPATH)/$(OUTPUT_DIR)/
python: FORUTILS_DIR=$(FORUTILSPATH)/$(DLL_DIR)/
LIBLINK = -L"$(FORUTILS_DIR)" -lforutils
## CosmoRec
ifneq (,$(findstring cosmorec,$(RECOMBINATION_FILES)))
camb: libCosmoRec.a
python: libCosmoRec.a
FFLAGS += -DCOSMOREC
COSMOREC_PATH ?=../../CosmoRec/
GSL_LINK ?=-lgsl -lgslcblas
LIBLINK += -L$(COSMOREC_PATH) -lCosmoRec $(GSL_LINK) -lstdc++
endif
ifneq (,$(findstring hyrec,$(RECOMBINATION_FILES)))
FFLAGS += -DHYREC
HYREC_PATH ?= ../../HYREC-2/
LIBLINK += -L$(HYREC_PATH) -lhyrec
camb: libhyrec.a
python: libhyrec.a
endif
default: camb
all: camb python libcamb
Release: camb python
Debug: camb python
MAKEOPT ?= --no-print-directory
cur_ver := $(shell cat compiler.ver 2>&1 || echo "")
ifneq ($(cur_ver),$(compiler_ver))
$(shell rm -f compiler.ver *.d)
endif
compiler.ver:
@echo $(compiler_ver) > compiler.ver
@rm -f *.d
camb: libforutils directories
@$(MAKE) -C $(OUTPUT_DIR) $(MAKEOPT) -r -f ../Makefile_main $(CAMBLIB) ../camb
libcamb: libforutils directories
@$(MAKE) -C $(OUTPUT_DIR) $(MAKEOPT) -r -f ../Makefile_main $(CAMBLIB)
python: libforutils_so directories_so
@$(MAKE) -C $(DLL_DIR) $(MAKEOPT) -r -f ../Makefile_main camblib.so F90FLAGS="$(SF90FLAGS)" OUTPUT_DIR=$(DLL_DIR)
../camb: $(CAMBLIB) $(DRIVER).o | silent
@$(MAKE) -C .. $(MAKEOPT) -f Makefile_main camb_exe
camb_exe:
$(F90C) $(F90FLAGS) $(MODOUT) $(IFLAG)$(OUTPUT_DIR)/ $(IFLAG)"$(FORUTILS_DIR)" \
$(OUTPUT_DIR)/$(DRIVER).o $(OUTPUT_DIR)/$(CAMBLIB) $(F90CRLINK) $(LIBLINK) -o camb
camblib.so: $(CAMBOBJ)
@$(MAKE) -C .. $(MAKEOPT) -f Makefile_main $(DLL_DIR)/camblib.so
libcambobj:
LIBCAMBOBJ = $(patsubst %,$(DLL_DIR)/%.o,$(SOURCEFILES))
#cannot link the .a library, or the linker will strip out some things we might need
$(DLL_DIR)/camblib.so: libcambobj
$(F90C) $(SF90FLAGS) $(SMODOUT) $(IFLAG)$(DLL_DIR)/ $(IFLAG)"$(FORUTILS_DIR)" \
$(LIBCAMBOBJ) $(F90CRLINK) $(LIBLINK) -o $(DLL_DIR)/camblib.so
cp $(DLL_DIR)/camblib.so $(PYCAMB_OUTPUT_DIR)
$(CAMBLIB): $(CAMBOBJ)
$(AR) -r $@ $(CAMBOBJ)
camb_fits: libforutils directories writefits.f90 $(CAMBOBJ) $(DRIVER).o
$(F90C) $(F90FLAGS) -I$(HEALPIXDIR)/include $(CAMBOBJ) writefits.f90 $(DRIVER).o \
$(F90CRLINK) $(LIBLINK) $(HEALPIXLD) -DWRITE_FITS -o $@
#../Makefile ../Makefile_main
%.o: ../%.f90 compiler.ver
$(F90C) $(F90FLAGS) $(IFLAG)"$(FORUTILS_DIR)" -c $< -o $*.o
directories:
@mkdir -p $(OUTPUT_DIR)
directories_so:
@mkdir -p $(DLL_DIR)
libforutils_so:
@cd "$(FORUTILSPATH)" && \
$(MAKE) $(MAKEOPT) $(DLL_DIR)
libforutils:
@cd "$(FORUTILSPATH)" && \
$(MAKE) $(MAKEOPT) $(OUTPUT_DIR)
clean:
-rm -f *.o *.a *.d core *.mod *.optrpt
-rm -rf Release* Debug* WinDLL*
delete:
rm -f camb
rm -f ../camb/*.so
## CosmoRec make parts
cleanCR:
cd $(COSMOREC_PATH); make tidy;
libCosmoRec.a:
cd $(COSMOREC_PATH); make lib;
libhyrec.a:
cd $(HYREC_PATH); make libhyrec.a;
silent:
@:
export
-include *.d
.PHONY: clean directories libcamb Release Releaselib Debuglib Debug \
camb python camb_exe libcambobj libcamb