-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (52 loc) · 1.87 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
#ifndef
UNAME := $(shell uname)
ifdef ENV_DEBUG
CONDITIONAL_CXX = -g
else
CONDITIONAL_CXX = -g -O3 -DNDEBUG #-fprofile-use=./prof/out_single.pgo #-lgcov
ifneq ($(UNAME), Darwin)
CONDITIONAL_CXX += #-fsanitize=address -fno-omit-frame-pointer
endif
endif
COMMITDESC:= "\"$(shell git log -1 --pretty=format:'%h %ad' --date=iso --abbrev=12)\""
CXX = g++-11
CXXFLAGSCOMMON = -std=c++20 -Wall -Iinclude -Ithird_party -ffast-math $(ENV_CXXFLAGS) $(CONDITIONAL_CXX) -MP -MD -DCOMMITDESC=$(COMMITDESC)#-O0
CXXFLAGS = $(CXXFLAGSCOMMON)
CXXFLAGSTEST = $(CXXFLAGSCOMMON)
LIBS := -ltbb #-lprofiler $(ENV_LIBFLAGS) #-lgcov -fprofile-use=./prof/out_single2.pgo
ifeq ($(UNAME), Darwin)
LIBS := #-lprofiler -L/opt/homebrew/Cellar/gperftools/2.9.1_1/lib -L/opt/homebrew/Cellar/tbb/2021.5.0/lib
endif
SRC_DIR := src
TEST_DIR := test
OBJ_DIR := obj
BIN_DIR := bin
SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp)
SRC_FILES += $(wildcard $(TEST_DIR)/*.cpp)
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES))
OBJ_FILES_NO_TEST := $(filter-out $(wildcard $(TEST_DIR)/*), $(OBJ_FILES))
OBJ_FILES := $(patsubst $(TEST_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(OBJ_FILES))
OBJ_FILES_NO_MAIN := $(filter-out $(OBJ_DIR)/main.o, $(OBJ_FILES))
INCLUDES = $(wildcard include/*.h)
LDFLAGS := $(LIBS)
DEPS := $(OBJ_FILES_NO_TEST:.o=.d)
TEST_DEPS := $(OBJ_FILES_NO_MAIN:.o=.d)
$(BIN_DIR)/solve: $(OBJ_FILES_NO_TEST)
@mkdir -p $(BIN_DIR)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
$(BIN_DIR)/test: $(OBJ_FILES_NO_MAIN)
@mkdir -p $(BIN_DIR)
$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
-include $(DEPS)
-include $(TEST_DEPS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(OBJ_DIR)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< $(LIBS)
$(OBJ_DIR)/%.o: $(TEST_DIR)/%.cpp
@mkdir -p $(OBJ_DIR)
$(CXX) $(CXXFLAGSTEST) -c -o $@ $< $(LIBS)
clean:
- rm -r $(OBJ_DIR)/* $(BIN_DIR)/*
all: $(BIN_DIR)/solve
# debug:
# @echo $(OBJ_FILES_NO_TEST)