-
Notifications
You must be signed in to change notification settings - Fork 44
/
Makefile
131 lines (101 loc) · 4.77 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
CXX ?= g++
CC ?= gcc
CXXFLAGS=-g -Wall -Werror -Wformat=2 -Wextra -Wwrite-strings \
-Wno-unused-parameter -Wmissing-format-attribute -Wno-non-template-friend \
-Woverloaded-virtual -Wcast-qual -Wcast-align -fomit-frame-pointer \
-std=c++11 -fPIC -O3 $(EXTRA_CXXFLAGS)
CFLAGS=-g -Wall -Werror -Wformat=2 -Wextra -Wwrite-strings \
-Wno-unused-parameter -Wmissing-format-attribute \
-Wcast-align -Wconversion -fomit-frame-pointer \
-std=gnu99 -fPIC -O3
# Output directories
OBJECT_DIR = obj
SRC_DIR = src
WRAPPER_DIR = cwrapper
INCLUDE_DIR = include/Arachne
LIB_DIR = lib
BIN_DIR = bin
# Depenencies
PERFUTILS=../PerfUtils
COREARBITER=../CoreArbiter
INCLUDE=-I$(PERFUTILS)/include -I$(COREARBITER)/include -I$(SRC_DIR)
LIBS=$(COREARBITER)/lib/libCoreArbiter.a $(PERFUTILS)/lib/libPerfUtils.a -lpcrecpp -pthread
CLIBS=$(LIBS) -lstdc++
# Stuff needed for make check
TOP := $(shell echo $${PWD-`pwd`})
ifndef CHECK_TARGET
CHECK_TARGET=$$(find $(SRC_DIR) $(WRAPPER_DIR) '(' -name '*.h' -or -name '*.cc' ')' -not -path '$(TOP)/googletest/*' )
endif
# Conversion to fully qualified names
OBJECT_NAMES := Arachne.o Logger.o PerfStats.o DefaultCorePolicy.o CoreLoadEstimator.o arachne_wrapper.o
OBJECTS = $(patsubst %,$(OBJECT_DIR)/%,$(OBJECT_NAMES))
HEADERS= $(shell find $(SRC_DIR) $(WRAPPER_DIR) -name '*.h')
ifeq ($(MAKECMDGOALS),clean)
DEP=
else
DEP=$(OBJECTS:.o=.d)
endif # ($(MAKECMDGOALS),clean)
install: $(OBJECT_DIR)/libArachne.a
mkdir -p $(LIB_DIR) $(INCLUDE_DIR)
cp $(HEADERS) $(INCLUDE_DIR)
cp $< $(LIB_DIR)
$(OBJECT_DIR)/libArachne.a: $(OBJECTS)
ar rcs $@ $^
-include $(DEP)
$(OBJECT_DIR)/%.d: $(WRAPPER_DIR)/%.c | $(OBJECT_DIR)
$(CC) $(INCLUDE) $(CFLAGS) $< -MM -MT $(@:.d=.o) > $@
$(OBJECT_DIR)/%.o: $(WRAPPER_DIR)/%.c $(HEADERS) | $(OBJECT_DIR)
$(CC) $(INCLUDE) $(CFLAGS) -c $< -o $@
$(OBJECT_DIR)/%.d: $(WRAPPER_DIR)/%.cc | $(OBJECT_DIR)
$(CXX) $(INCLUDE) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) > $@
$(OBJECT_DIR)/%.o: $(WRAPPER_DIR)/%.cc $(HEADERS) | $(OBJECT_DIR)
$(CXX) $(INCLUDE) $(CXXFLAGS) -c $< -o $@
$(OBJECT_DIR)/%.d: $(SRC_DIR)/%.cc | $(OBJECT_DIR)
$(CXX) $(INCLUDE) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) > $@
$(OBJECT_DIR)/%.o: $(SRC_DIR)/%.cc $(HEADERS) | $(OBJECT_DIR)
$(CXX) $(INCLUDE) $(CXXFLAGS) -c $< -o $@
$(OBJECT_DIR):
mkdir -p $(OBJECT_DIR)
check:
scripts/cpplint.py --filter=-runtime/threadsafe_fn,-readability/streams,-whitespace/blank_line,-whitespace/braces,-whitespace/comments,-runtime/arrays,-build/include_what_you_use,-whitespace/semicolon $(CHECK_TARGET)
! grep '.\{81\}' $(SRC_DIR)/*.h $(SRC_DIR)/*.cc $(WRAPPER_DIR)/*.h $(WRAPPER_DIR)/*.cc
################################################################################
# Test Targets
GTEST_DIR=../googletest/googletest
GMOCK_DIR=../googletest/googlemock
TEST_LIBS=-Lobj/ -lArachne $(OBJECT_DIR)/libgtest.a
CTEST_LIBS=-Lobj/ -lArachne
INCLUDE+=-I${GTEST_DIR}/include -I${GMOCK_DIR}/include
COREARBITER_BIN=$(COREARBITER)/bin/coreArbiterServer
test: $(OBJECT_DIR)/ArachneTest $(OBJECT_DIR)/CorePolicyTest $(OBJECT_DIR)/DefaultCorePolicyTest $(OBJECT_DIR)/arachne_wrapper_test
$(OBJECT_DIR)/ArachneTest
$(OBJECT_DIR)/DefaultCorePolicyTest
$(OBJECT_DIR)/arachne_wrapper_test
$(OBJECT_DIR)/CorePolicyTest
ctest: $(OBJECT_DIR)/arachne_wrapper_ctest
$(OBJECT_DIR)/arachne_wrapper_ctest
$(OBJECT_DIR)/arachne_wrapper_ctest: $(OBJECT_DIR)/arachne_wrapper_ctest.o $(OBJECT_DIR)/libArachne.a
$(CC) $(INCLUDE) $(CFLAGS) $< $(CTEST_LIBS) $(CLIBS) -o $@
$(OBJECT_DIR)/arachne_wrapper_test: $(OBJECT_DIR)/arachne_wrapper_test.o $(OBJECT_DIR)/libgtest.a $(OBJECT_DIR)/libArachne.a
$(CXX) $(INCLUDE) $(CXXFLAGS) $< $(GTEST_DIR)/src/gtest_main.cc $(TEST_LIBS) $(LIBS) -o $@
$(OBJECT_DIR)/ArachneTest: $(OBJECT_DIR)/ArachneTest.o $(OBJECT_DIR)/libgtest.a $(OBJECT_DIR)/libArachne.a
$(CXX) $(INCLUDE) $(CXXFLAGS) $< $(GTEST_DIR)/src/gtest_main.cc $(TEST_LIBS) $(LIBS) -o $@
$(OBJECT_DIR)/DefaultCorePolicyTest: $(OBJECT_DIR)/DefaultCorePolicyTest.o $(OBJECT_DIR)/libgtest.a $(OBJECT_DIR)/libArachne.a
$(CXX) $(INCLUDE) $(CXXFLAGS) $< $(GTEST_DIR)/src/gtest_main.cc $(TEST_LIBS) $(LIBS) -o $@
$(OBJECT_DIR)/CorePolicyTest: $(OBJECT_DIR)/CorePolicyTest.o $(OBJECT_DIR)/libgtest.a $(OBJECT_DIR)/libArachne.a
$(CXX) $(INCLUDE) $(CXXFLAGS) $< $(GTEST_DIR)/src/gtest_main.cc $(TEST_LIBS) $(LIBS) -o $@
$(OBJECT_DIR)/libgtest.a:
g++ -I${GTEST_DIR}/include -I${GTEST_DIR} \
-pthread -c ${GTEST_DIR}/src/gtest-all.cc \
-o $(OBJECT_DIR)/gtest-all.o
ar -rv $(OBJECT_DIR)/libgtest.a $(OBJECT_DIR)/gtest-all.o
################################################################################
# Doc targets
docs:
doxygen Doxyfile
site: docs
git fetch origin gh-pages:gh-pages
scripts/git-replace-branch html gh-pages "Updating website on $(shell date) from commit $(shell git rev-parse HEAD)."
git push origin gh-pages
clean:
rm -rf $(OBJECT_DIR) $(LIB_DIR) $(INCLUDE_DIR)