-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile
551 lines (376 loc) · 13.9 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
#
# PGMcpp : PRIMED Grid Modelling (in C++)
#
# Anthony Truelove MASc, P.Eng.
# email: gears1763@tutanota.com
# github: gears1763-2
#
# See license terms
#
# Makefile for PGMcpp: PRIMED Grid Modelling (in C++)
#
## ======== USER INPUT ============================================================== ##
PROJECT_NAME = example
SRC_PROJECT = projects/$(PROJECT_NAME).cpp
OUT_PROJECT = bin/$(PROJECT_NAME).out
## ======== END USER INPUT ========================================================== ##
## ======== COMPILER FLAGS ========================================================== ##
CXX = g++ -O3 -std=c++17
#CXXFLAGS = -Wall -g -p -fPIC
CXXFLAGS = -Wall -fPIC
LIBS = -lpthread
## ======== END COMPILER FLAGS ====================================================== ##
## ======== BUILD =================================================================== ##
#### ==== Testing Utilities ==== ####
SRC_TESTING_UTILS = test/utils/testing_utils.cpp
OBJ_TESTING_UTILS = test/object/testing_utils.o
.PHONY: testing_utils
testing_utils: $(SRC_TESTING_UTILS)
$(CXX) $(CXXFLAGS) -c $(SRC_TESTING_UTILS) -o $(OBJ_TESTING_UTILS)
#### ==== Interpolator ==== ####
SRC_INTERPOLATOR = source/Interpolator.cpp
OBJ_INTERPOLATOR = object/Interpolator.o
.PHONY: interpolator
interpolator: $(SRC_INTERPOLATOR)
$(CXX) $(CXXFLAGS) -c $(SRC_INTERPOLATOR) -o $(OBJ_INTERPOLATOR)
#### ==== Production Hierarchy <-- Combustion ==== ####
SRC_PRODUCTION = source/Production/Production.cpp
OBJ_PRODUCTION = object/Production/Production.o
.PHONY: Production
Production: $(SRC_PRODUCTION)
$(CXX) $(CXXFLAGS) -c $(SRC_PRODUCTION) -o $(OBJ_PRODUCTION)
SRC_COMBUSTION = source/Production/Combustion/Combustion.cpp
OBJ_COMBUSTION = object/Production/Combustion/Combustion.o
.PHONY: Combustion
Combustion: $(SRC_COMBUSTION)
$(CXX) $(CXXFLAGS) -c $(SRC_COMBUSTION) -o $(OBJ_COMBUSTION)
SRC_DIESEL = source/Production/Combustion/Diesel.cpp
OBJ_DIESEL = object/Production/Combustion/Diesel.o
.PHONY: Diesel
Diesel: $(SRC_DIESEL)
$(CXX) $(CXXFLAGS) -c $(SRC_DIESEL) -o $(OBJ_DIESEL)
COMBUSTION_HIERARCHY = Production \
Combustion \
Diesel
OBJ_COMBUSTION_HIERARCHY = $(OBJ_PRODUCTION) \
$(OBJ_COMBUSTION) \
$(OBJ_DIESEL)
#### ==== Production Hierarchy <-- Noncombustion ==== ####
SRC_NONCOMBUSTION = source/Production/Noncombustion/Noncombustion.cpp
OBJ_NONCOMBUSTION = object/Production/Noncombustion/Noncombustion.o
.PHONY: Noncombustion
Noncombustion: $(SRC_NONCOMBUSTION)
$(CXX) $(CXXFLAGS) -c $(SRC_NONCOMBUSTION) -o $(OBJ_NONCOMBUSTION)
SRC_HYDRO = source/Production/Noncombustion/Hydro.cpp
OBJ_HYDRO = object/Production/Noncombustion/Hydro.o
.PHONY: Hydro
Hydro: $(SRC_HYDRO)
$(CXX) $(CXXFLAGS) -c $(SRC_HYDRO) -o $(OBJ_HYDRO)
NONCOMBUSTION_HIERARCHY = Noncombustion \
Hydro
OBJ_NONCOMBUSTION_HIERARCHY = $(OBJ_NONCOMBUSTION) \
$(OBJ_HYDRO)
#### ==== Production Hierarchy <-- Renewable ==== ####
SRC_RENEWABLE = source/Production/Renewable/Renewable.cpp
OBJ_RENEWABLE = object/Production/Renewable/Renewable.o
.PHONY: Renewable
Renewable: $(SRC_RENEWABLE)
$(CXX) $(CXXFLAGS) -c $(SRC_RENEWABLE) -o $(OBJ_RENEWABLE)
SRC_SOLAR = source/Production/Renewable/Solar.cpp
OBJ_SOLAR = object/Production/Renewable/Solar.o
.PHONY: Solar
Solar: $(SRC_SOLAR)
$(CXX) $(CXXFLAGS) -c $(SRC_SOLAR) -o $(OBJ_SOLAR)
SRC_TIDAL = source/Production/Renewable/Tidal.cpp
OBJ_TIDAL = object/Production/Renewable/Tidal.o
.PHONY: Tidal
Tidal: $(SRC_TIDAL)
$(CXX) $(CXXFLAGS) -c $(SRC_TIDAL) -o $(OBJ_TIDAL)
SRC_WAVE = source/Production/Renewable/Wave.cpp
OBJ_WAVE = object/Production/Renewable/Wave.o
.PHONY: Wave
Wave: $(SRC_WAVE)
$(CXX) $(CXXFLAGS) -c $(SRC_WAVE) -o $(OBJ_WAVE)
SRC_WIND = source/Production/Renewable/Wind.cpp
OBJ_WIND = object/Production/Renewable/Wind.o
.PHONY: Wind
Wind: $(SRC_WIND)
$(CXX) $(CXXFLAGS) -c $(SRC_WIND) -o $(OBJ_WIND)
RENEWABLE_HIERARCHY = Renewable \
Solar \
Tidal \
Wave \
Wind
OBJ_RENEWABLE_HIERARCHY = $(OBJ_RENEWABLE) \
$(OBJ_SOLAR) \
$(OBJ_TIDAL) \
$(OBJ_WAVE) \
$(OBJ_WIND)
#### ==== Storage Hierarchy ==== ####
SRC_STORAGE = source/Storage/Storage.cpp
OBJ_STORAGE = object/Storage/Storage.o
.PHONY: Storage
Storage: $(SRC_STORAGE)
$(CXX) $(CXXFLAGS) -c $(SRC_STORAGE) -o $(OBJ_STORAGE)
SRC_LIION = source/Storage/LiIon.cpp
OBJ_LIION = object/Storage/LiIon.o
.PHONY: LiIon
LiIon: $(SRC_LIION)
$(CXX) $(CXXFLAGS) -c $(SRC_LIION) -o $(OBJ_LIION)
STORAGE_HIERARCHY = Storage \
LiIon
OBJ_STORAGE_HIERARCHY = $(OBJ_STORAGE) \
$(OBJ_LIION)
#### ==== Model and Components ==== ####
SRC_CONTROLLER = source/Controller.cpp
OBJ_CONTROLLER = object/Controller.o
.PHONY: Controller
Controller: $(SRC_CONTROLLER)
$(CXX) $(CXXFLAGS) -c $(SRC_CONTROLLER) -o $(OBJ_CONTROLLER)
SRC_ELECTRICALLOAD = source/ElectricalLoad.cpp
OBJ_ELECTRICALLOAD = object/ElectricalLoad.o
.PHONY: ElectricalLoad
ElectricalLoad: $(SRC_ELECTRICALLOAD)
$(CXX) $(CXXFLAGS) -c $(SRC_ELECTRICALLOAD) -o $(OBJ_ELECTRICALLOAD)
SRC_RESOURCES = source/Resources.cpp
OBJ_RESOURCES = object/Resources.o
.PHONY: Resources
Resources: $(SRC_RESOURCES)
$(CXX) $(CXXFLAGS) -c $(SRC_RESOURCES) -o $(OBJ_RESOURCES)
SRC_MODEL = source/Model.cpp
OBJ_MODEL = object/Model.o
.PHONY: Model
Model: $(SRC_MODEL)
$(CXX) $(CXXFLAGS) -c $(SRC_MODEL) -o $(OBJ_MODEL)
MODEL = Controller \
ElectricalLoad \
Resources \
Model
OBJ_MODEL_COMPONENTS = $(OBJ_CONTROLLER) \
$(OBJ_ELECTRICALLOAD) \
$(OBJ_RESOURCES) \
$(OBJ_MODEL)
#### ==== Tests ==== ####
OBJ_ALL = $(OBJ_TESTING_UTILS) \
$(OBJ_INTERPOLATOR)\
$(OBJ_COMBUSTION_HIERARCHY) \
$(OBJ_NONCOMBUSTION_HIERARCHY) \
$(OBJ_RENEWABLE_HIERARCHY) \
$(OBJ_STORAGE_HIERARCHY) \
$(OBJ_MODEL_COMPONENTS)
## == Test: Interpolator == ##
SRC_TEST_INTERPOLATOR = test/source/test_Interpolator.cpp
OUT_TEST_INTERPOLATOR = test/bin/test_Interpolator.out
.PHONY: test_Interpolator
test_Interpolator: $(SRC_TEST_INTERPOLATOR)
$(CXX) $(CXXFLAGS) $(SRC_TEST_INTERPOLATOR) $(OBJ_ALL) \
-o $(OUT_TEST_INTERPOLATOR) $(LIBS)
## == Test: Production Hierarchy <-- Combustion == ##
SRC_TEST_PRODUCTION = test/source/Production/test_Production.cpp
OUT_TEST_PRODUCTION = test/bin/Production/test_Production.out
.PHONY: test_Production
test_Production: $(SRC_TEST_PRODUCTION)
$(CXX) $(CXXFLAGS) $(SRC_TEST_PRODUCTION) $(OBJ_ALL) \
-o $(OUT_TEST_PRODUCTION) $(LIBS)
SRC_TEST_COMBUSTION = test/source/Production/Combustion/test_Combustion.cpp
OUT_TEST_COMBUSTION = test/bin/Production/Combustion/test_Combustion.out
.PHONY: test_Combustion
test_Combustion: $(SRC_TEST_COMBUSTION)
$(CXX) $(CXXFLAGS) $(SRC_TEST_COMBUSTION) $(OBJ_ALL) \
-o $(OUT_TEST_COMBUSTION) $(LIBS)
SRC_TEST_DIESEL = test/source/Production/Combustion/test_Diesel.cpp
OUT_TEST_DIESEL = test/bin/Production/Combustion/test_Diesel.out
.PHONY: test_Diesel
test_Diesel: $(SRC_TEST_DIESEL)
$(CXX) $(CXXFLAGS) $(SRC_TEST_DIESEL) $(OBJ_ALL) \
-o $(OUT_TEST_DIESEL) $(LIBS)
## == Test: Production Hierarchy <-- Noncombustion == ##
SRC_TEST_NONCOMBUSTION = test/source/Production/Noncombustion/test_Noncombustion.cpp
OUT_TEST_NONCOMBUSTION = test/bin/Production/Noncombustion/test_Noncombustion.out
.PHONY: test_Noncombustion
test_Noncombustion: $(SRC_TEST_NONCOMBUSTION)
$(CXX) $(CXXFLAGS) $(SRC_TEST_NONCOMBUSTION) $(OBJ_ALL) \
-o $(OUT_TEST_NONCOMBUSTION) $(LIBS)
SRC_TEST_HYDRO = test/source/Production/Noncombustion/test_Hydro.cpp
OUT_TEST_HYDRO = test/bin/Production/Noncombustion/test_Hydro.out
.PHONY: test_Hydro
test_Hydro: $(SRC_TEST_HYDRO)
$(CXX) $(CXXFLAGS) $(SRC_TEST_HYDRO) $(OBJ_ALL) \
-o $(OUT_TEST_HYDRO) $(LIBS)
## == Test: Production Hierarchy <-- Renewable == ##
SRC_TEST_RENEWABLE = test/source/Production/Renewable/test_Renewable.cpp
OUT_TEST_RENEWABLE = test/bin/Production/Renewable/test_Renewable.out
.PHONY: test_Renewable
test_Renewable: $(SRC_TEST_RENEWABLE)
$(CXX) $(CXXFLAGS) $(SRC_TEST_RENEWABLE) $(OBJ_ALL) \
-o $(OUT_TEST_RENEWABLE) $(LIBS)
SRC_TEST_SOLAR = test/source/Production/Renewable/test_Solar.cpp
OUT_TEST_SOLAR = test/bin/Production/Renewable/test_Solar.out
.PHONY: test_Solar
test_Solar: $(SRC_TEST_SOLAR)
$(CXX) $(CXXFLAGS) $(SRC_TEST_SOLAR) $(OBJ_ALL) \
-o $(OUT_TEST_SOLAR) $(LIBS)
SRC_TEST_TIDAL = test/source/Production/Renewable/test_Tidal.cpp
OUT_TEST_TIDAL = test/bin/Production/Renewable/test_Tidal.out
.PHONY: test_Tidal
test_Tidal: $(SRC_TEST_TIDAL)
$(CXX) $(CXXFLAGS) $(SRC_TEST_TIDAL) $(OBJ_ALL) \
-o $(OUT_TEST_TIDAL) $(LIBS)
SRC_TEST_WAVE = test/source/Production/Renewable/test_Wave.cpp
OUT_TEST_WAVE = test/bin/Production/Renewable/test_Wave.out
.PHONY: test_Wave
test_Wave: $(SRC_TEST_WAVE)
$(CXX) $(CXXFLAGS) $(SRC_TEST_WAVE) $(OBJ_ALL) \
-o $(OUT_TEST_WAVE) $(LIBS)
SRC_TEST_WIND = test/source/Production/Renewable/test_Wind.cpp
OUT_TEST_WIND = test/bin/Production/Renewable/test_Wind.out
.PHONY: test_Wind
test_Wind: $(SRC_TEST_WIND)
$(CXX) $(CXXFLAGS) $(SRC_TEST_WIND) $(OBJ_ALL) \
-o $(OUT_TEST_WIND) $(LIBS)
## == Test: Storage Hierarchy == ##
SRC_TEST_STORAGE = test/source/Storage/test_Storage.cpp
OUT_TEST_STORAGE = test/bin/Storage/test_Storage.out
.PHONY: test_Storage
test_Storage: $(SRC_TEST_STORAGE)
$(CXX) $(CXXFLAGS) $(SRC_TEST_STORAGE) $(OBJ_ALL) \
-o $(OUT_TEST_STORAGE) $(LIBS)
SRC_TEST_LIION = test/source/Storage/test_LiIon.cpp
OUT_TEST_LIION = test/bin/Storage/test_LiIon.out
.PHONY: test_LiIon
test_LiIon: $(SRC_TEST_LIION)
$(CXX) $(CXXFLAGS) $(SRC_TEST_LIION) $(OBJ_ALL) \
-o $(OUT_TEST_LIION) $(LIBS)
## == Test: Model and Components == ##
SRC_TEST_CONTROLLER = test/source/test_Controller.cpp
OUT_TEST_CONTROLLER = test/bin/test_Controller.out
.PHONY: test_Controller
test_Controller: $(SRC_TEST_CONTROLLER)
$(CXX) $(CXXFLAGS) $(SRC_TEST_CONTROLLER) $(OBJ_ALL) \
-o $(OUT_TEST_CONTROLLER) $(LIBS)
SRC_TEST_ELECTRICALLOAD = test/source/test_ElectricalLoad.cpp
OUT_TEST_ELECTRICALLOAD = test/bin/test_ElectricalLoad.out
.PHONY: test_ElectricalLoad
test_ElectricalLoad: $(SRC_TEST_ELECTRICALLOAD)
$(CXX) $(CXXFLAGS) $(SRC_TEST_ELECTRICALLOAD) $(OBJ_ALL) \
-o $(OUT_TEST_ELECTRICALLOAD) $(LIBS)
SRC_TEST_RESOURCES = test/source/test_Resources.cpp
OUT_TEST_RESOURCES = test/bin/test_Resources.out
.PHONY: test_Resources
test_Resources: $(SRC_TEST_RESOURCES)
$(CXX) $(CXXFLAGS) $(SRC_TEST_RESOURCES) $(OBJ_ALL) \
-o $(OUT_TEST_RESOURCES) $(LIBS)
SRC_TEST_MODEL = test/source/test_Model.cpp
OUT_TEST_MODEL = test/bin/test_Model.out
.PHONY: test_Model
test_Model: $(SRC_TEST_MODEL)
$(CXX) $(CXXFLAGS) $(SRC_TEST_MODEL) $(OBJ_ALL) \
-o $(OUT_TEST_MODEL) $(LIBS)
TESTS = test_Interpolator\
test_Production \
test_Combustion \
test_Diesel \
test_Noncombustion \
test_Hydro \
test_Renewable \
test_Solar \
test_Tidal \
test_Wave \
test_Wind \
test_Storage \
test_LiIon \
test_Controller \
test_ElectricalLoad \
test_Resources \
test_Model
OUT_TESTS = $(OUT_TEST_INTERPOLATOR) &&\
$(OUT_TEST_PRODUCTION) &&\
$(OUT_TEST_COMBUSTION) &&\
$(OUT_TEST_DIESEL) &&\
$(OUT_TEST_NONCOMBUSTION) &&\
$(OUT_TEST_HYDRO) &&\
$(OUT_TEST_RENEWABLE) &&\
$(OUT_TEST_SOLAR) &&\
$(OUT_TEST_TIDAL) &&\
$(OUT_TEST_WAVE) &&\
$(OUT_TEST_WIND) &&\
$(OUT_TEST_STORAGE) &&\
$(OUT_TEST_LIION) &&\
$(OUT_TEST_CONTROLLER) &&\
$(OUT_TEST_ELECTRICALLOAD) &&\
$(OUT_TEST_RESOURCES) &&\
$(OUT_TEST_MODEL)
#### ==== Project ==== ####
.PHONY: PGMcpp_project
PGMcpp_project: $(SRC_PROJECT)
$(CXX) $(CXXFLAGS) $(SRC_PROJECT) $(OBJ_ALL) -o $(OUT_PROJECT) $(LIBS)
## ======== END BUILD =============================================================== ##
## ======== TARGETS ================================================================= ##
.PHONY: clean
clean:
rm -frv bin
rm -frv gmon.*
rm -frv object
rm -frv profiling_results
rm -frv projects/example_cpp
rm -frv projects/example_py
rm -frv projects/optimization_results
rm -frv pybindings/PGMcpp.*
rm -frv pybindings/test_results/
rm -frv test/bin
rm -frv test/object
rm -frv test/test_results
.PHONY: dirs
dirs:
mkdir -pv bin/Production/Combustion
mkdir -pv bin/Production/Noncombustion
mkdir -pv bin/Production/Renewable
mkdir -pv bin/Storage
mkdir -pv object/Production/Combustion
mkdir -pv object/Production/Noncombustion
mkdir -pv object/Production/Renewable
mkdir -pv object/Storage
mkdir -pv test/bin/Production/Combustion
mkdir -pv test/bin/Production/Noncombustion
mkdir -pv test/bin/Production/Renewable
mkdir -pv test/bin/Storage
mkdir -pv test/object
.PHONY: docs
docs:
rm -fv docs/PGMcpp_manual_html.7z
rm -fv docs/PGMcpp_manual_LaTeX.pdf
doxygen docs/config.doxygen
(cd docs/latex && \
make pdf && \
mv -fv refman.pdf ../PGMcpp_manual_LaTeX.pdf)
7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on docs/PGMcpp_manual_html.7z docs/html
rm -frv docs/html
rm -frv docs/latex
rm -frv docs/bibTmpDir
rm -frv docs/bib2xhtml.pl
rm -frv docs/doxygen.bst
rm -frv docs/citelist.doc
.PHONY: PGMcpp
PGMcpp:
make clean
make dirs
make testing_utils
make interpolator
make $(COMBUSTION_HIERARCHY)
make $(NONCOMBUSTION_HIERARCHY)
make $(RENEWABLE_HIERARCHY)
make $(STORAGE_HIERARCHY)
make $(MODEL)
make $(TESTS)
clear
@echo
$(OUT_TESTS)
@echo
.PHONY: profile
profile:
gprof test/bin/test_Model.out > profiling_results
.PHONY: project
project:
make PGMcpp_project
$(OUT_PROJECT)
## ======== END TARGETS ============================================================= ##