-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
44 lines (32 loc) · 846 Bytes
/
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
.SILENT:
.PHONY: all dir clean build
# compiler settings
CXX = g++
CXXFLAGS = -std=c++20 -Isrc -Wno-psabi
# directories
OUT_DIR = bin
OBJ_DIR = obj
SRC_DIR = src
EXMPL_DIR = src/examples
INC_DIR = src
# files
HDRS = $(wildcard ${SRC_DIR}/*.hpp)
SRC = $(wildcard ${SRC_DIR}/*.cpp)
OBJ = $(addprefix obj/, $(notdir $(patsubst %.cpp, %.o, $(SRC))))
EXMPL = $(wildcard ${EXMPL_DIR}/*.cpp)
EXOBJ = $(addprefix obj/, $(notdir $(patsubst %.cpp, %.o, $(EXMPL_DIR))))
BIN = $(addprefix bin/, $(notdir $(patsubst %.cpp, %, $(EXMPL))))
# phony targets
all: clean dir build
clean:
rm -rf ${OBJ_DIR}
rm -rf ${OUT_DIR}
dir:
mkdir -p ${OBJ_DIR}
mkdir -p ${OUT_DIR}
build: dir ${OBJ} ${BIN}
# rules
${OBJ_DIR}/%.o: ${SRC_DIR}/%.cpp
${CXX} ${CXXFLAGS} -c $< -o $@
${OUT_DIR}/%: ${EXMPL_DIR}/%.cpp ${OBJ}
${CXX} ${CXXFLAGS} $< ${OBJ} -o $@