-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.in
executable file
·113 lines (96 loc) · 3.26 KB
/
Makefile.in
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
# Target variables
MODE ?= Debug
# The Directories, Source, Includes, Objects, Binary
ROOT := .
3RD_PARTY_DIR := $(ROOT)/3rd-party
GTEST_DIR := googletest-release-1.12.1
GTEST_CODE := $(GTEST_DIR).tar.gz
OBJ_DIR := $(ROOT)/obj
BUILD_DIR := $(OBJ_DIR)/release
AST_DIR := $(ROOT)/ast
BIN_DIR := $(ROOT)/bin
ifeq ($(MODE),Debug)
BUILD_DIR := $(OBJ_DIR)/debug
endif
prefix ?= /usr/local
exec_prefix ?= $(prefix)
includedir ?= $(prefix)/include
libdir ?= $(exec_prefix)/lib
boost_libdir ?= $(prefix)
# Flags, Libraries and Includes
INCLUDES := -I. -I$(boost_libdir)/include
CXXFLAGS := -std=c++17 -Wall -Werror -Wno-reorder -O2 -D BOOST_PHOENIX_STL_TUPLE_H_ -D BOOST_MPL_LIMIT_LIST_SIZE=30 -D BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
ifeq ($(MODE),Debug)
CXXFLAGS += -ggdb
endif
LIB_SBGRAPH = lib/libsbgraph.a
all: $(LIB_SBGRAPH)
include sbg/Makefile.include
include parser/Makefile.include
include util/Makefile.include
include eval/Makefile.include
include test/Makefile.include
$(BUILD_DIR)/%.o : %.cpp
$(CC) $(INCLUDES) $(CXXFLAGS) -MM -MT $@ -MF $(patsubst %.o,%.d,$@) $<
$(CC) $(INCLUDES) -c $< -o $@ $(CXXFLAGS)
$(LIB_SBGRAPH): create-folders $(SBG_OBJ) $(UTIL_OBJ) $(PARSER_OBJ) $(EVAL_OBJ)
$(AR) rcs $(LIB_SBGRAPH) $(SBG_OBJ) $(UTIL_OBJ) $(PARSER_OBJ) $(EVAL_OBJ)
lib-gtest: | create-folders
ifeq ("$(wildcard $(3RD_PARTY_DIR)/gtest/usr/lib)","")
cd $(3RD_PARTY_DIR)/gtest; tar xvzf $(GTEST_CODE)
mkdir -p $(3RD_PARTY_DIR)/gtest/build
cd $(3RD_PARTY_DIR)/gtest/build; cmake ../$(GTEST_DIR) -DCMAKE_INSTALL_PREFIX=../usr
cd $(3RD_PARTY_DIR)/gtest/build; make install
rm -rf $(3RD_PARTY_DIR)/gtest/$(GTEST_DIR)
rm -rf $(3RD_PARTY_DIR)/gtest/build
endif
install: | install-folders
@echo "Installing SBG library headers."
@echo ${prefix}
@install $(ROOT)/ast/*.hpp $(includedir)/ast
@install $(ROOT)/sbg/*.hpp $(includedir)/sbg
@install $(ROOT)/util/*.hpp $(includedir)/util
@install $(ROOT)/parser/*.hpp $(includedir)/parser
@install $(ROOT)/eval/*.hpp $(includedir)/eval
@install $(ROOT)/lib/libsbgraph.a $(libdir)/
@echo "Done."
install-folders:
@mkdir -p $(libdir)
@mkdir -p $(includedir)
@mkdir -p $(includedir)/ast
@mkdir -p $(includedir)/sbg
@mkdir -p $(includedir)/util
@mkdir -p $(includedir)/parser
@mkdir -p $(includedir)/eval
create-folders::
@mkdir -p $(ROOT)/lib
@mkdir -p $(OBJ_DIR)
@mkdir -p $(BUILD_DIR)
@mkdir -p $(BUILD_DIR)/$(AST_DIR)
@mkdir -p $(BIN_DIR)
.PHONY: doc
doc:
@mkdir -p $(ROOT)/doc
@mkdir -p $(ROOT)/doc/html
@mkdir -p $(ROOT)/doc/latex
doxygen sbg/SBG.doxyfile
doxygen util/UTIL.doxyfile
test: lib-gtest $(SBG_TEST)
TEST_DIRS := test/parser test/performance test/performance/boost test/eval
clean:
$(RM) -rf $(BIN_DIR) $(OBJ_DIR) $(LIB_SBGRAPH) $(ROOT)/lib $(ROOT)/include $(3RD_PARTY_DIR)/gtest/usr
for dir in $(TEST_DIRS); do \
$(RM) -rf $$dir/bin; \
$(RM) -rf $$dir/obj; \
$(RM) -rf $$dir/test_data; \
done
help:
@echo "make MODE=<Debug|Release> prefix=<PATH> exec_prefix=<PATH> includedir=<PATH> libdir=<PATH> boost_libdir=<PATH>"
@echo "Default values:"
@echo ""
@echo "MODE=Debug"
@echo "prefix=/usr/local"
@echo "exec_prefix=/usr/local"
@echo "includedir=/usr/local/include"
@echo "libdir=/usr/local/lib"
@echo "boost_libdir=/usr/local/include"