-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
85 lines (68 loc) · 1.98 KB
/
Makefile
File metadata and controls
85 lines (68 loc) · 1.98 KB
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
######################################
# target
######################################
TARGET = projectA
######################################
# building variables
######################################
# debug build?
DEBUG = 1
#######################################
# paths
#######################################
# Build path
BUILD_DIR = build
######################################
# source
######################################
# C++ sources
CPP_SOURCES = \
main.cpp \
src/parser.cpp \
src/dataStructs.cpp \
src/threadpool.cpp
######################################
# compiler
######################################
CXX = g++
#######################################
# CXXFLAGS
#######################################
# C++ includes
PYTHON_LIB = -I /usr/include/python3.11 -lpython3.11
SOCI_LIB = -lsoci_core -lsoci_postgresql
CXX_INCLUDES = -Iinc $(PYTHON_LIB) $(SOCI_LIB)
LDFLAGS = $(PYTHON_LIB) $(SOCI_LIB) -lpq -lssl -lcrypto -pthread -lcurl
# compile CXX flags
CXXFLAGS = $(CXX_INCLUDES) -Wall -Werror -pedantic -std=c++20
ifeq ($(DEBUG), 1)
CXXFLAGS += -g -gdwarf-2
endif
# Generate dependency information
CXXFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
#######################################
# build the application
#######################################
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
$(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR)
$(CXX) -c $(CXXFLAGS) $< -o $@
$(BUILD_DIR)/$(TARGET): $(OBJECTS) Makefile
$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
# create build directory
$(BUILD_DIR):
mkdir $@
#######################################
# clean up
#######################################
clean:
-rm -fR $(BUILD_DIR)
#######################################
# run the application
#######################################
run: $(BUILD_DIR)/$(TARGET)
./$(BUILD_DIR)/$(TARGET) $(ARGS)
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)