-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
116 lines (97 loc) · 2.21 KB
/
Makefile
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
# Makefile to compile HMcode
# Compiler
FC = gfortran
# Standard flags
FFLAGS = \
-fcheck=all \
-fmax-errors=4 \
-ffpe-trap=invalid,zero,overflow \
-fimplicit-none \
-O3 \
-std=gnu \
-ffree-line-length-none \
-fdefault-real-8 \
-fdefault-double-8 \
-lgfortran \
-lm
# Extra debugging flags
DEBUG_FLAGS = \
-Wall \
-fcheck=all \
-fbounds-check \
-fbacktrace \
-Og
# Binary
BIN = HMcode
BIN_DEBUG = $(BIN)_debug
# Source-code directory
SRC_DIR = src
# Build directory
BUILD_DIR = build
# Fortran library directory
MOD_DIR = library/src
# Debug build directory
DEBUG_BUILD_DIR = debug_build
# Executable directory
BIN_DIR = bin
# Objects
_OBJ = \
precision.o \
constants.o \
physics.o \
basic_operations.o \
array_operations.o \
random_numbers.o \
file_info.o \
table_integer.o \
special_functions.o \
interpolate.o \
root_finding.o \
string_operations.o \
calculus_table.o \
camb_stuff.o \
sorting.o \
statistics.o \
calculus.o \
minimization.o \
multidark_stuff.o \
cosmology_functions.o \
hod_functions.o \
hmx.o
# Add prefixes of build directory to objects
OBJ = $(addprefix $(BUILD_DIR)/,$(_OBJ))
DEBUG_OBJ = $(addprefix $(DEBUG_BUILD_DIR)/,$(_OBJ))
# This is a rule to make directories
make_dirs = @mkdir -p $(@D)
# Standard rules
all: bin
bin: $(BIN_DIR)/$(BIN)
# Debugging rules
debug: FFLAGS += $(DEBUG_FLAGS)
debug: $(BIN_DIR)/$(BIN_DEBUG)
# Rule to make object files
$(BUILD_DIR)/%.o: $(MOD_DIR)/%.f90
$(make_dirs)
$(FC) -c -o $@ $< -J$(BUILD_DIR) $(LDFLAGS) $(FFLAGS)
# Rule to make executable
$(BIN_DIR)/$(BIN): $(OBJ) $(SRC_DIR)/$(BIN).f90
@echo "\nBuilding executable.\n"
$(make_dirs)
$(FC) -o $@ $^ -J$(BUILD_DIR) $(LDFLAGS) $(FFLAGS)
# Rule to make debugging objects
$(DEBUG_BUILD_DIR)/%.o: $(MOD_DIR)/%.f90
$(make_dirs)
$(FC) -c -o $@ $< -J$(DEBUG_BUILD_DIR) $(LDFLAGS) $(FFLAGS)
# Rule to make debugging executable
$(BIN_DIR)/$(BIN_DEBUG): $(DEBUG_OBJ) $(SRC_DIR)/$(BIN).f90
@echo "\nBuilding debugging executable.\n"
$(FC) -o $@ $^ -J$(DEBUG_BUILD_DIR) $(LDFLAGS) $(FFLAGS)
# Clean up
.PHONY: clean
clean:
rm -f $(BIN_DIR)/$(BIN)
rm -f $(BIN_DIR)/$(BIN_DEBUG)
rm -f $(BUILD_DIR)/*.o
rm -f $(BUILD_DIR)/*.mod
rm -f $(DEBUG_BUILD_DIR)/*.o
rm -f $(DEBUG_BUILD_DIR)/*.mod