-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
175 lines (134 loc) · 5.14 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
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
175
SHELL := /bin/bash
TARGET_ORB = bin/OrbitPropagator
TARGET_SGP4 = bin/SGP4Propagator
TARGET_ATT = bin/AttitudePropagator
TARGET_EVE = bin/EventsComputation
C_SRC := $(wildcard *.c)
CPP_SRC_ORB := orbprop.cpp
CPP_SRC_SGP4 := sgp4prop.cpp
CPP_SRC_ATT := attprop.cpp
CPP_SRC_EVE := eventscomp.cpp
H_SRC := $(wildcard *.h)
LIBRARY :=
INCLUDE_PATH := -I.
LIBRARY_PATH := -L.
#-L/opt/MATLAB/R2017b/extern/lib/
CC = gcc
CC_FLAGS = -Wall -O3 -pg
CCXX = g++ -std=c++17 -fopenmp
CCXX_FLAGS = -Wall -O3 -falign-functions=16 -falign-loops=16 -falign-jumps -pg -DUSE_QUATERNION -DUSE_SPICE -DXSD_CXX11 -fno-signaling-nans -fno-trapping-math
LIBRARY := -lboost_system -lpthread ./extlib/cspice/lib/cspice.a -lm -lxerces-c extlib/Atmosphere/JB2008/JB2008.o extlib/Atmosphere/JB2008/Readfiles.o extlib/Atmosphere/NRLMSISE-00/FORTRAN/nrlmsise00_sub.o extlib/MagneticField/IGRF/FORTRAN/igrf13.o extlib/MagneticField/WMM/FORTRAN/geomag.o -lgfortran
LD_FLAGS =
#include makefile fragments in subdirectories if they exist
-include ./*/make.mk
#OBJECTS_ORB = $(patsubst %.c, %.o, $(C_SRC))
OBJECTS_ORB += $(patsubst %.cpp, %.o, $(CPP_SRC_ORB))
OBJECTS_SGP4 += $(patsubst %.cpp, %.o, $(CPP_SRC_SGP4))
OBJECTS_ATT = $(patsubst %.c, %.o, $(C_SRC))
OBJECTS_ATT += $(patsubst %.cpp, %.o, $(CPP_SRC_ATT))
OBJECTS_EVE = $(patsubst %.c, %.o, $(C_SRC))
OBJECTS_EVE += $(patsubst %.cpp, %.o, $(CPP_SRC_EVE))
RAMDISK_DIR = /mnt/ramdisk
# make ramdisj target creates and mounts a tempfs drive
#OBJ_DIR = $(RAMDISK_DIR)/objs
OBJ_DIR = objs
OBJS_ORB = $(addprefix $(OBJ_DIR)/, $(OBJECTS_ORB))
DEPS_ORB = $(patsubst %.o, %.o.d, $(OBJECTS_ORB))
OBJS_SGP4 = $(addprefix $(OBJ_DIR)/, $(OBJECTS_SGP4))
DEPS_SGP4 = $(patsubst %.o, %.o.d, $(OBJECTS_SGP4))
OBJS_ATT = $(addprefix $(OBJ_DIR)/, $(OBJECTS_ATT))
DEPS_ATT = $(patsubst %.o, %.o.d, $(OBJECTS_ATT))
OBJS_EVE = $(addprefix $(OBJ_DIR)/, $(OBJECTS_EVE))
DEPS_EVE = $(patsubst %.o, %.o.d, $(OBJECTS_EVE))
#DEPS = $(patsubst %.o, %.o.d, $(OBJS))
orbit: $(TARGET_ORB) silent
-include $(DEPS_ORB)
sgp4: $(TARGET_SGP4) silent
-include $(DEPS_SGP4)
attitude: $(TARGET_ATT) silent
-include $(DEPS_ATT)
events: $(TARGET_EVE) silent
-include $(DEPS_EVE)
#all: $(TARGET) silent
#
##include all rules generated by gcc into the makefile
#-include $(DEPS)
#dummy target to that we don't get unnecessary messages ( target is up to date & co)
silent:
@:
$(TARGET_ORB): $(OBJS_ORB)
@echo Linking
@$(CCXX) $(LD_FLAGS) $(LIBRARY_PATH) -o $(TARGET_ORB) $^ $(LIBRARY)
$(TARGET_SGP4): $(OBJS_SGP4)
@echo Linking
@$(CCXX) $(LD_FLAGS) $(LIBRARY_PATH) -o $(TARGET_SGP4) $^ $(LIBRARY)
$(TARGET_ATT): $(OBJS_ATT)
@echo Linking
@$(CCXX) $(LD_FLAGS) $(LIBRARY_PATH) -o $(TARGET_ATT) $^ $(LIBRARY)
$(TARGET_EVE): $(OBJS_EVE)
@echo Linking
@$(CCXX) $(LD_FLAGS) $(LIBRARY_PATH) -o $(TARGET_EVE) $^ $(LIBRARY)
#create output directory if it doesn't exist
#generate dependency file for current file
# .o and .d are targets of the rule
# create blank targets for each source/header file. Used to update .d files when you delete a file
$(OBJ_DIR)/%.o: %.c
@mkdir -p $(@D)
@echo Building $<
@$(CC) $(CC_FLAGS) $(INCLUDE_PATH) $(ARGS) -c $< -o $@
@echo -n "[email protected] $(@D)/" > [email protected]
@$(CC) $(CC_FLAGS) $(INCLUDE_PATH) $(ARGS) -MM $< >> [email protected]
@cp [email protected] $<.tp
@sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' -e '/^$$/ d' -e 's/$$/ :/' < $<.tp >> [email protected]
@rm -f $<.tp
$(OBJ_DIR)/%.o: %.cpp
@mkdir -p $(@D)
@echo Building $<
@$(CCXX) $(CCXX_FLAGS) $(INCLUDE_PATH) $(ARGS) -c $< -o $@
@echo -n "[email protected] $(@D)/" > [email protected]
@$(CCXX) $(CCXX_FLAGS) $(INCLUDE_PATH) $(ARGS) -MM $< >> [email protected]
@cp [email protected] $<.tp
@sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' -e '/^$$/ d' -e 's/$$/ :/' < $<.tp >> [email protected]
@rm -f $<.tp
clean:
@echo Removing objects directory
@rm -rf $(OBJ_DIR)
@echo Removing target
@rm -f $(TARGET_ORB)
@rm -f $(TARGET_SGP4)
@rm -f $(TARGET_ATT)
@rm -f $(TARGET_EVE)
#http://blog.jgc.org/2015/04/the-one-line-you-should-add-to-every.html
print-%: ; @echo $*=$($*)
test:
@echo $(@D)
@echo $(DEPS)
@echo $(OBJECTS2)
@echo Test
@echo $(C_SRC)
@echo Test
@echo $(H_SRC)
@echo Test
@echo $(LIBRARY)
run: all
@./$(TARGET_ORB)
@./$(TARGET_SGP4)
@./$(TARGET_ATT)
@./$(TARGET_EVE)
ramdisk:
sudo mkdir $(RAMDISK_DIR)
sudo mount -t tmpfs -o size=512m tmpfs $(RAMDISK_DIR)
install_libs:
sudo apt-get install libboost-all-dev libxerces-c-dev xsdcxx gfortran freeglut3 freeglut3-dev libxi-dev libxmu-dev mesa-utils libsdl2* libsoil* doxygen graphviz
install_atmo:
rm -f extlib/Atmosphere/NRLMSISE-00/FORTRAN/*.o
rm -f extlib/Atmosphere/JB2008/*.o
gfortran -c -std=legacy extlib/Atmosphere/NRLMSISE-00/FORTRAN/nrlmsise00_sub.for -o extlib/Atmosphere/NRLMSISE-00/FORTRAN/nrlmsise00_sub.o
gfortran -c extlib/Atmosphere/JB2008/JB2008.f -o extlib/Atmosphere/JB2008/JB2008.o
gfortran -c extlib/Atmosphere/JB2008/Readfiles.f -o extlib/Atmosphere/JB2008/Readfiles.o
install_mag:
rm -f extlib/MagneticField/IGRF/FORTRAN/*.o
rm -f extlib/MagneticField/WMM/FORTRAN/*.o
gfortran -c extlib/MagneticField/IGRF/FORTRAN/igrf13.f -o extlib/MagneticField/IGRF/FORTRAN/igrf13.o
gfortran -c extlib/MagneticField/WMM/FORTRAN/geomag.for -o extlib/MagneticField/WMM/FORTRAN/geomag.o
.PHONY: test deploy all ramdisk