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,49 +18,73 @@ 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)
33- CXXFLAGS += -ggdb -Wall -Werror
34+ CXXFLAGS += -ggdb -Wall -Werror
3435endif
36+
37+ # Target
3538LIB_SBGRAPH = lib/libsbgraph.a
3639
37- all : $(LIB_SBGRAPH )
40+ # ///////////////////////////////////////////////////////////////////////////////
41+ # PHONY ------------------------------------------------------------------------
42+ # ///////////////////////////////////////////////////////////////////////////////
43+
44+ .PHONY : doc clean create-folders install install-folders lib-gtest test
45+
46+ # ///////////////////////////////////////////////////////////////////////////////
47+ # Compilation ------------------------------------------------------------------
48+ # ///////////////////////////////////////////////////////////////////////////////
3849
3950include util/Makefile.include
4051include sbg/Makefile.include
4152include ast/Makefile.include
4253include parser/Makefile.include
43- include eval/Makefile.include
54+ include algorithms/cc/Makefile.include
55+ include algorithms/matching/Makefile.include
56+ include algorithms/scc/Makefile.include
57+ include algorithms/cutvertex/Makefile.include
58+ include algorithms/toposort/Makefile.include
4459include algorithms/partitioner/Makefile.include
60+ include algorithms/misc/Makefile.include
61+ include eval/Makefile.include
62+ include test/performance/Makefile.include
63+
64+ LIB_SRC = $(UTIL_SRC ) $(SBG_SRC ) $(AST_SRC ) $(PARSER_SRC ) $(EVAL_SRC ) $(ALG_SRC )
65+
66+ LIB_OBJ = $(UTIL_OBJ ) $(SBG_OBJ ) $(AST_OBJ ) $(PARSER_OBJ ) $(EVAL_OBJ ) $(ALG_OBJ )
67+
68+ # Objects compilation
69+ $(LIB_SRC:%.cpp =$(BUILD_DIR ) /%.o): $(BUILD_DIR ) /%.o: %.cpp | create-folders
70+ $(CXX) -c $< $(INCLUDES) -MMD -MP $(CXXFLAGS) -o $@
71+
72+ compile : $(LIB_SBGRAPH ) $(PARSER_BIN ) $(EVAL_BIN ) $(PARTITIONER_BIN )
4573
4674create-folders ::
4775 @mkdir -p $(ROOT ) /lib
4876 @mkdir -p $(OBJ_DIR )
4977 @mkdir -p $(BUILD_DIR )
5078 @mkdir -p $(BIN_DIR )
5179
52- LIB_OBJ = $(UTIL_OBJ ) $(SBG_OBJ ) $(AST_OBJ ) $(PARSER_OBJ ) $(EVAL_OBJ ) $(ALG_OBJ )
53-
54- $(LIB_SBGRAPH ) : create-folders $(LIB_OBJ )
80+ $(LIB_SBGRAPH ) : $(LIB_OBJ ) | create-folders
5581 $(AR ) rcs $(LIB_SBGRAPH ) $(LIB_OBJ )
5682
57- DEPS = $(addprefix $(BUILD_DIR ) /, $(LIB_SRC:.cpp=.d ) )
83+ # ///////////////////////////////////////////////////////////////////////////////
84+ # Dependencies -----------------------------------------------------------------
85+ # ///////////////////////////////////////////////////////////////////////////////
5886
59- -include $(DEPS )
87+ -include $(LIB_OBJ :.o=.d )
6088
6189# ///////////////////////////////////////////////////////////////////////////////
6290# Library Installation ---------------------------------------------------------
@@ -96,7 +124,8 @@ ifeq ("$(wildcard $(3RD_PARTY_DIR)/gtest/usr/lib)","")
96124 rm -rf $(3RD_PARTY_DIR)/gtest/build
97125endif
98126
99- test : lib-gtest
127+ test : compile lib-gtest perf-compile
128+ @./bin/sbg-performance
100129 @cd $(TEST_DIR ) && ./compile_run_tests.sh
101130
102131# ///////////////////////////////////////////////////////////////////////////////
118147TEST_DIRS := test/parser test/performance test/performance/boost test/eval
119148
120149clean :
121- $(RM ) -rf $(BIN_DIR ) $(OBJ_DIR ) $(LIB_SBGRAPH ) $(ROOT ) /lib $(ROOT ) /include $(3RD_PARTY_DIR ) /gtest/usr
150+ $(RM ) -rf $(BIN_DIR ) $(OBJ_DIR ) $(LIB_SBGRAPH ) $(ROOT ) /lib $(ROOT ) /include \
151+ $(3RD_PARTY_DIR ) /gtest/usr
122152 for dir in $( TEST_DIRS) ; do \
123153 $(RM) -rf $$dir/bin; \
124154 $(RM) -rf $$dir/obj; \
0 commit comments