-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
133 lines (112 loc) · 3.41 KB
/
Copy pathmakefile
File metadata and controls
133 lines (112 loc) · 3.41 KB
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
#IDIR = include
IDIR=src
LDIR=lib
SDIR=src
ODIR=obj
.SUFFIXES:
.SUFFIXES: .cpp .o
CC=g++ -std=c++14
CFLAGS=-I$(IDIR) -Wuninitialized -Weffc++
## files needed to compile stellar models
# dependencies
_STARDEPS = constants.h\
STARS/Star.h \
STARS/Polytrope.h \
STARS/ChandrasekharWD.h \
STARS/MESA.h\
STARS/PNStar.h \
STARS/PNPolytrope.h \
STARS/PNChandrasekharWD.h \
STARS/GRStar.h \
STARS/GRPolytrope.h \
STARS/SchwarzschildBH.h
STARDEPS = $(patsubst %, $(IDIR)/%, $(_STARDEPS))
# source
_STARSRC = STARS/Star.cpp \
STARS/Polytrope.cpp STARS/PNPolytrope.cpp STARS/GRPolytrope.cpp \
STARS/SchwarzschildBH.cpp \
STARS/ChandrasekharWD.cpp STARS/PNChandrasekharWD.cpp \
STARS/MESA.cpp
STARSRC = $(patsubst %, $(SDIR)/%, $(_STARSRC))
## files needed to compile mode drivers
# dependencies
_DRVDEPS = constants.h\
STARS/Star.h STARS/PNStar.h\
MODES/ModeDriver.h \
MODES/NonradialModeDriver.h \
MODES/CowlingModeDriver.h\
MODES/PNNonradialModeDriver.h\
MODES/GRCowlingModeDriver.h
DRVDEPS = $(patsubst %, $(IDIR)/%, $(_DRVDEPS))
# source
_DRVSRC = MODES/NonradialModeDriver.cpp \
MODES/PNNonradialModeDriver.cpp \
MODES/CowlingModeDriver.cpp \
MODES/GRCowlingModeDriver.cpp
DRVSRC = $(patsubst %, $(SDIR)/%, $(_DRVSRC))
## files needed to compile the mode object
# dependencies
_MODEDEPS = constants.h\
STARS/Star.h MODES/ModeDriver.h MODES/Mode.h MODES/Mode.cpp
MODEDEPS = $(patsubst %, $(IDIR)/%, $(_MODEDEPS))
# source
_MODESRC = MODES/Mode.cpp
MODESRC = $(patsubst %, $(SDIR)/%, $(_MODESRC))
## files needed to compile main program
# dependencies
_MAINDEPS = constants.h GRPulseMain.h GRPulseIO.h\
STARS/Star.h \
STARS/Polytrope.h \
STARS/ChandrasekharWD.h \
STARS/MESA.h \
STARS/PNStar.h \
STARS/PNPolytrope.h \
STARS/PNChandrasekharWD.h \
STARS/GRStar.h \
STARS/GRPolytrope.h \
STARS/SchwarzschildBH.h \
MODES/Mode.h\
MODES/Mode.cpp\
MODES/ModeDriver.h \
MODES/CowlingModeDriver.h \
MODES/NonradialModeDriver.h \
MODES/PNNonradialModeDriver.h \
MODES/GRCowlingModeDriver.h
MAINDEPS = $(patsubst %, $(IDIR)/%, $(_MAINDEPS))
# soure
_MAINSRC = GRPulseMain.cpp GRPulseIO.cpp GRPulseStellar.cpp GRPulseMode.cpp GRPulseUnits.cpp
MAINSRC = $(patsubst %, $(SDIR)/%, $(_MAINSRC))
## prepare object names
STAROBJ = $(patsubst %.cpp,$(ODIR)/%.o, $(_STARSRC))
DRVOBJ = $(patsubst %.cpp,$(ODIR)/%.o, $(_DRVSRC))
MODEOBJ = $(patsubst %.cpp,$(ODIR)/%.o, $(_MODESRC))
MAINOBJ = $(patsubst %.cpp,$(ODIR)/%.o, $(_MAINSRC))
## Main rule for GRPulse program
GRPulse: $(MAINOBJ) $(MODEOBJ) $(STAROBJ) $(DRVOBJ) |library
$(CC) -o $@ $^ $(CFLAGS) $(LDIR)/mylib.a
## Rules for each subsection -- only update if their dependencies change
$(STAROBJ): $(ODIR)/%.o: $(SDIR)/%.cpp $(STARDEPS) |obj/STARS
$(CC) -c -o $@ $< $(CFLAGS)
$(DRVOBJ): $(ODIR)/%.o: $(SDIR)/%.cpp $(DRVDEPS) |obj/MODES
$(CC) -c -o $@ $< $(CFLAGS)
$(MODEOBJ): $(ODIR)/%.o: $(SDIR)/%.cpp $(MODEDEPS) |obj/MODES
$(CC) -c -o $@ $< $(CFLAGS)
$(MAINOBJ): $(ODIR)/%.o: $(SDIR)/%.cpp $(MAINDEPS) |obj
$(CC) -c -o $@ $< $(CFLAGS)
# these will create the necessary directories
# see solution 4 here:
# https://www.cmcrossroads.com/article/making-directories-gnu-make
obj:
mkdir -p obj
obj/STARS:
mkdir -p obj/STARS
obj/MODES:
mkdir -p obj/MODES
library:
rm -f lib/*.o
rm -f lib/*.a
$(MAKE) -C lib --makefile=makelib library
rm -f lib/*.o
.PHONY: clean
clean:
rm -f $(ODIR)/*.o $(ODIR)/STARS/*.o $(ODIR)/MODES/*.o