-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
101 lines (73 loc) · 3.88 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
#################################################
# Variables #
#################################################
# Directories
SRC = ./src/
TEST = ./tests/
# SET DEFAULTS (which can be overriden)
ifeq ($(origin CXX), undefined)
CXX = g++
endif
ifeq ($(origin LDFLAGS), undefined)
LDFLAGS = -g -Wall -std=c++0x -O3 -lboost_program_options # -lserial -lglog -L/usr/local/lib
endif
ifeq ($(origin CXXFLAGS), undefined)
CXXFLAGS = $(LDFLAGS) -DDEBUG=1 -MD -Wno-deprecated -Wno-unused-result # -O2 PUT this back after testing
# -MD is required for auto dependency,
# -O2 and -Wno-deprecated are required for Boost Graph Library.
# -Wno-unused-result is required to stop warnings from GNUplot about ignoring
# the returned int from system().
endif
#################################################
# modules #
#################################################
# COMMON OBJECT FILES
COMMONOBJS = $(SRC)Main.o $(SRC)Signature.o $(SRC)Utils.o $(SRC)Device.o \
$(SRC)GNUplot.o $(SRC)PowerStateSequence.o $(SRC)AggregateData.o $(SRC)PowerStateGraph.o $(SRC)Histogram.o
#####################
# COMPILATION RULES #
#####################
disaggregate: $(COMMONOBJS)
$(CXX) -o $@ $(COMMONOBJS) $(INC) $(LDFLAGS) -lm
# GENERIIC COMPILATION RULE
.C.o:
$(CXX) $< -c $(CXXFLAGS) $(INC)
# AUTOMATIC DEPENDENCY DETECTION
# http://www.wlug.org.nz/MakefileHowto
# also take a look at http://lear.inrialpes.fr/people/klaeser/software_makefile_link_dependencies
DEPS := $(patsubst %.o,%.d,$(COMMONOBJS))
-include $(DEPS)
# TESTING (it's best to do a 'make clean' when switching between testing and normal compiling because object files are compiled with different options)
TESTCXXFLAGS = -g -Wall -std=c++0x -lboost_unit_test_framework -MD # -DGOOGLE_STRIP_LOG=4
testAll: ArrayTest GNUplotTest UtilsTest StatisticTest PowerStateGraphTest
ATOBJFILES = $(SRC)Utils.o $(SRC)GNUplot.o $(SRC)Histogram.o
ArrayTest: CXXFLAGS = $(TESTCXXFLAGS)
ArrayTest: $(TEST)ArrayTest.cpp $(SRC)Array.h $(ATOBJFILES)
g++ $(TESTCXXFLAGS) -o $(TEST)ArrayTest $(TEST)ArrayTest.cpp $(ATOBJFILES) && $(TEST)ArrayTest
GPTOBJFILES = $(SRC)GNUplot.o $(SRC)Utils.o
GNUplotTest: CXXFLAGS = $(TESTCXXFLAGS) -Wno-unused-result
GNUplotTest: $(TEST)GNUplotTest.cpp $(GPTOBJFILES)
g++ $(CXXFLAGS) -o $(TEST)GNUplotTest $(TEST)GNUplotTest.cpp $(GPTOBJFILES) && $(TEST)GNUplotTest
UTOBJFILES = $(SRC)Utils.o
UtilsTest: CXXFLAGS = $(TESTCXXFLAGS)
UtilsTest: $(TEST)UtilsTest.cpp $(UTOBJFILES)
g++ $(CXXFLAGS) -o $(TEST)UtilsTest $(TEST)UtilsTest.cpp $(UTOBJFILES) && $(TEST)UtilsTest
STOBJFILES = $(SRC)Utils.o $(SRC)GNUplot.o
StatisticTest: CXXFLAGS = $(TESTCXXFLAGS)
StatisticTest: $(TEST)StatisticTest.cpp $(SRC)Statistic.h $(SRC)Array.h $(STOBJFILES)
g++ $(CXXFLAGS) -o $(TEST)StatisticTest $(TEST)StatisticTest.cpp $(STOBJFILES) && $(TEST)StatisticTest
PSGTOBJFILES = $(SRC)PowerStateGraph.o $(SRC)Signature.o $(SRC)GNUplot.o $(SRC)Utils.o $(SRC)PowerStateSequence.o $(SRC)AggregateData.o
PowerStateGraphTest: CXXFLAGS = $(TESTCXXFLAGS) -Wno-deprecated -Wno-unused-result -O3
PowerStateGraphTest: $(TEST)PowerStateGraphTest.cpp $(SRC)Array.h $(PSGTOBJFILES)
g++ $(CXXFLAGS) -o $(TEST)PowerStateGraphTest $(PSGTOBJFILES) $(TEST)PowerStateGraphTest.cpp && $(TEST)PowerStateGraphTest
ADTOBJFILES = $(SRC)AggregateData.o $(SRC)GNUplot.o $(SRC)Utils.o
AggregateDataTest: CXXFLAGS = $(TESTCXXFLAGS) -Wno-deprecated -Wno-unused-result
AggregateDataTest: $(TEST)AggregateDataTest.cpp $(SRC)Array.h $(ADTOBJFILES)
g++ $(CXXFLAGS) -o $(TEST)AggregateDataTest $(ADTOBJFILES) $(TEST)AggregateDataTest.cpp && $(TEST)AggregateDataTest
#################################################
# Clean #
#################################################
clean:
rm -f $(SRC)*.o $(SRC)*.d $(TEST)*.o $(TEST)*.d
linecount:
wc -l $(SRC)*.cpp $(SRC)*.h $(TEST)*.cpp config/*.* Makefile