-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
70 lines (51 loc) · 1.92 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
#
# This is the main Makefile
#
# This should appear before including makefile common
SRC_DIR = ./src
BUILD_DIR = ./build
BIN_DIR = ./bin
# This will let make shutup
MAKEFLAGS += -s
# We print the mode fir the first invocation, but
# not the following
MODE_PRINT = 1
# This include the common make file
-include ./src/common/Makefile-common
$(info = Invoking the main compilation dispatcher...)
$(info = CXXFLAGS: $(CXXFLAGS))
$(info = LDFLAGS: $(LDFLAGS))
.PHONY: all test-all test common clean prepare
all: test-all
test-all: common test
# Note that calling make with -C will also pass the environmental variable set inside and by
# the shell to the subprocess of make
COMMON_OBJ = $(patsubst ./src/common/%.cpp, $(BUILD_DIR)/%.o, $(wildcard ./src/common/*.cpp))
common:
@$(MAKE) -C ./src/common
TEST_OBJ = $(patsubst ./src/test/%.cpp, $(BUILD_DIR)/%.o, $(wildcard ./src/test/*.cpp))
test:
@$(MAKE) -C ./src/test
BWTREE_OBJ = $(patsubst ./src/bwtree/%.cpp, $(BUILD_DIR)/%.o, $(wildcard ./src/bwtree/*.cpp))
bwtree: ./src/bwtree/bwtree.h ./src/bwtree/bwtree.cpp
@$(MAKE) -C ./src/bwtree
common-test: common test ./test/common-test.cpp
$(info >>> Building binary for $@)
$(CXX) -o $(BIN_DIR)/$@ $(COMMON_OBJ) $(TEST_OBJ) ./test/common-test.cpp $(CXXFLAGS) $(LDFLAGS)
@$(LN) -sf $(BIN_DIR)/$@ ./$@-bin
binary-util-test: common test ./test/binary-util-test.cpp
$(info >>> Building binary for $@)
$(CXX) -o $(BIN_DIR)/$@ $(COMMON_OBJ) $(TEST_OBJ) ./test/binary-util-test.cpp $(CXXFLAGS) $(LDFLAGS)
@$(LN) -sf $(BIN_DIR)/$@ ./$@-bin
bwtree-test: common test ./test/bwtree-test.cpp ./src/bwtree/bwtree.h bwtree
$(info >>> Building binary for $@)
$(CXX) -o $(BIN_DIR)/$@ $(COMMON_OBJ) $(TEST_OBJ) $(BWTREE_OBJ) ./test/bwtree-test.cpp $(CXXFLAGS) $(LDFLAGS)
@$(LN) -sf $(BIN_DIR)/$@ ./$@-bin
clean:
$(info >>> Cleaning files)
$(RM) -f ./build/*
$(RM) -f ./bin/*
$(RM) -f *-bin
prepare:
$(MKDIR) -p build
$(MKDIR) -p bin