1- # Target variables
1+ # ///////////////////////////////////////////////////////////////////////////////
2+ # Variables --------------------------------------------------------------------
3+ # ///////////////////////////////////////////////////////////////////////////////
4+
5+ # Configuration
26MODE ?= Release
37
4- # The Directories, Source, Includes, Objects, Binary
8+ # Directories
59ROOT := .
6103RD_PARTY_DIR := $(ROOT ) /3rd-party
711GTEST_DIR := googletest-release-1.12.1
@@ -14,54 +18,74 @@ BIN_DIR := $(ROOT)/bin
1418ifeq ($(MODE ) , Debug)
1519BUILD_DIR := $(OBJ_DIR ) /debug
1620endif
21+ PERF_DIR := test/performance
22+
23+ # Installation paths
1724prefix ?= /usr/local
1825exec_prefix ?= $(prefix )
1926includedir ?= $(prefix ) /include
2027libdir ?= $(exec_prefix ) /lib
2128boost_libdir ?= $(prefix )
2229
23- .PHONY : doc clean create-folders install install-folders lib-gtest test
24-
25- # ///////////////////////////////////////////////////////////////////////////////
26- # Compilation ------------------------------------------------------------------
27- # ///////////////////////////////////////////////////////////////////////////////
28-
29- # Flags, Libraries and Includes
30+ # Flags and includes
3031INCLUDES := -I. -I$(boost_libdir ) /include
3132CXXFLAGS := -std=c++17 -Wno-reorder -O3
3233ifeq ($(MODE ) ,Debug)
3334CXXFLAGS += -ggdb -Wall -Werror
35+ CXXFLAGS += -D SBG_PARTITIONER_LOGGING
3436endif
37+
38+ # Target
3539LIB_SBGRAPH = lib/libsbgraph.a
3640
37- all : $(LIB_SBGRAPH )
41+ # ///////////////////////////////////////////////////////////////////////////////
42+ # PHONY ------------------------------------------------------------------------
43+ # ///////////////////////////////////////////////////////////////////////////////
44+
45+ .PHONY : doc clean create-folders install install-folders lib-gtest test
46+
47+ # ///////////////////////////////////////////////////////////////////////////////
48+ # Compilation ------------------------------------------------------------------
49+ # ///////////////////////////////////////////////////////////////////////////////
3850
3951include util/Makefile.include
4052include sbg/Makefile.include
53+ include ast/Makefile.include
4154include parser/Makefile.include
42- include eval/Makefile.include
55+ include algorithms/cc/Makefile.include
56+ include algorithms/matching/Makefile.include
57+ include algorithms/scc/Makefile.include
58+ include algorithms/cutvertex/Makefile.include
59+ include algorithms/toposort/Makefile.include
4360include algorithms/partitioner/Makefile.include
61+ include algorithms/misc/Makefile.include
62+ include eval/Makefile.include
63+ include test/performance/Makefile.include
64+
65+ LIB_SRC = $(UTIL_SRC ) $(SBG_SRC ) $(AST_SRC ) $(PARSER_SRC ) $(EVAL_SRC ) $(ALG_SRC )
66+
67+ LIB_OBJ = $(UTIL_OBJ ) $(SBG_OBJ ) $(AST_OBJ ) $(PARSER_OBJ ) $(EVAL_OBJ ) $(ALG_OBJ )
68+
69+ # Objects compilation
70+ $(LIB_SRC:%.cpp =$(BUILD_DIR ) /%.o): $(BUILD_DIR ) /%.o: %.cpp | create-folders
71+ $(CXX) -c $< $(INCLUDES) -MMD -MP $(CXXFLAGS) -o $@
72+
73+ compile : $(LIB_SBGRAPH ) $(PARSER_BIN ) $(EVAL_BIN ) $(PARTITIONER_BIN )
4474
4575create-folders ::
4676 @mkdir -p $(ROOT ) /lib
4777 @mkdir -p $(OBJ_DIR )
4878 @mkdir -p $(BUILD_DIR )
49- @mkdir -p $(BUILD_DIR ) /$(AST_DIR )
5079 @mkdir -p $(BIN_DIR )
5180
52- $(BUILD_DIR ) /% .o : % .cpp | create-folders
53- $(CC ) $(INCLUDES ) $(CXXFLAGS ) -MM -MT $@ -MF $(patsubst % .o,% .d,$@ ) $<
54- $(CC ) $(INCLUDES ) -c $< -o $@ $(CXXFLAGS )
55-
56- LIB_SRC := $(shell find ast parser sbg eval util algorithms/partitioner -type f -name "* .cpp" ! -name "main.cpp")
57- LIB_OBJ = $(addprefix $(BUILD_DIR ) /, $(LIB_SRC:.cpp=.o ) )
58-
59- $(LIB_SBGRAPH ) : create-folders $(LIB_OBJ )
81+ $(LIB_SBGRAPH ) : $(LIB_OBJ ) | create-folders
6082 $(AR ) rcs $(LIB_SBGRAPH ) $(LIB_OBJ )
6183
62- DEPS = $(addprefix $(BUILD_DIR ) /, $(LIB_SRC:.cpp=.d ) )
84+ # ///////////////////////////////////////////////////////////////////////////////
85+ # Dependencies -----------------------------------------------------------------
86+ # ///////////////////////////////////////////////////////////////////////////////
6387
64- -include $(DEPS )
88+ -include $(LIB_OBJ :.o=.d )
6589
6690# ///////////////////////////////////////////////////////////////////////////////
6791# Library Installation ---------------------------------------------------------
@@ -70,23 +94,10 @@ DEPS = $(addprefix $(BUILD_DIR)/, $(LIB_SRC:.cpp=.d))
7094install : | install-folders
7195 @echo " Installing SBG library headers."
7296 @echo ${prefix}
73- @install $(ROOT ) /ast/* .hpp $(includedir ) /ast
74- @install $(ROOT ) /sbg/* .hpp $(includedir ) /sbg
75- @install $(ROOT ) /util/* .hpp $(includedir ) /util
76- @install $(ROOT ) /parser/* .hpp $(includedir ) /parser
77- @install $(ROOT ) /eval/* .hpp $(includedir ) /eval
78- @install $(ROOT ) /lib/libsbgraph.a $(libdir ) /
97+ @find $(ROOT ) -name ' *.hpp' -printf ' %P\n' | xargs -I % install -D $(ROOT ) /% \
98+ $(includedir ) /%
7999 @echo " Done."
80100
81- install-folders :
82- @mkdir -p $(libdir )
83- @mkdir -p $(includedir )
84- @mkdir -p $(includedir ) /ast
85- @mkdir -p $(includedir ) /sbg
86- @mkdir -p $(includedir ) /util
87- @mkdir -p $(includedir ) /parser
88- @mkdir -p $(includedir ) /eval
89-
90101# ///////////////////////////////////////////////////////////////////////////////
91102# Testing ----------------------------------------------------------------------
92103# ///////////////////////////////////////////////////////////////////////////////
@@ -101,7 +112,8 @@ ifeq ("$(wildcard $(3RD_PARTY_DIR)/gtest/usr/lib)","")
101112 rm -rf $(3RD_PARTY_DIR)/gtest/build
102113endif
103114
104- test : lib-gtest
115+ test : compile lib-gtest perf-compile
116+ @./bin/sbg-performance
105117 @cd $(TEST_DIR ) && ./compile_run_tests.sh
106118
107119# ///////////////////////////////////////////////////////////////////////////////
123135TEST_DIRS := test/parser test/performance test/performance/boost test/eval
124136
125137clean :
126- $(RM ) -rf $(BIN_DIR ) $(OBJ_DIR ) $(LIB_SBGRAPH ) $(ROOT ) /lib $(ROOT ) /include $(3RD_PARTY_DIR ) /gtest/usr
138+ $(RM ) -rf $(BIN_DIR ) $(OBJ_DIR ) $(LIB_SBGRAPH ) $(ROOT ) /lib $(ROOT ) /include \
139+ $(3RD_PARTY_DIR ) /gtest/usr
127140 for dir in $( TEST_DIRS) ; do \
128141 $(RM) -rf $$dir/bin; \
129142 $(RM) -rf $$dir/obj; \
0 commit comments