-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (46 loc) · 1.42 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
65
66
67
68
PROJECT_NAME=cpplisp
CC=clang++
LD=clang++
BIN_DIR=bin
INC_DIR=include
SRC_DIR=src
OBJ_DIR=obj
SUBDIRS=. Lisp Lisp/Util Lisp/Funcs Lisp/Primitives Lisp/Exceptions
EXEC_NAME=$(PROJECT_NAME)
EXEC_PATH=$(BIN_DIR)/$(EXEC_NAME)
INCLUDES_DIRS=
LIBS_DIRS=/usr/local/lib
LIBS=
DEFINES=
CFLAGS=-g -Wall -gdwarf-4 -std=c++20 -fstandalone-debug
LDFLAGS=
DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJ_DIR)/$*.d
FULL_EXEC=$(EXEC_PATH)
FULL_CFLAGS=$(CFLAGS) -I$(INC_DIR) $(addprefix -I, $(INCLUDES_DIRS)) $(addprefix -D, $(DEFINES)) $(DEPFLAGS)
FULL_LDFLAGS=$(LDFLAGS) $(addprefix -L, $(LIBS_DIRS)) $(addprefix -l, $(LIBS))
SRC_SUBDIRS=$(addprefix $(SRC_DIR)/, $(SUBDIRS))
INC_SUBDIRS=$(addprefix $(INC_DIR)/, $(SUBDIRS))
INCS=$(wildcard *.hpp $(foreach fd, $(INC_SUBDIRS), $(fd)/*.hpp))
SRCS=$(wildcard *.cpp $(foreach fd, $(SRC_SUBDIRS), $(fd)/*.cpp))
OBJS=$(subst $(SRC_DIR), $(OBJ_DIR), $(SRCS:.cpp=.o))
DEPFILES := $(OBJS:.o=.d)
all: $(FULL_EXEC)
obj_subdirs:
mkdir -p $(addprefix $(OBJ_DIR)/, $(SUBDIRS))
$(FULL_EXEC): $(OBJS)
$(CC) $(OBJS) $(FULL_LDFLAGS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CC) $(FULL_CFLAGS) -c $< -o $@
clean:
rm -rf $(EXEC_PATH) $(OBJ_DIR)/*
mkdir -p $(addprefix $(OBJ_DIR)/, $(SUBDIRS))
run: $(FULL_EXEC)
@$(EXEC_PATH)
debug: $(FULL_EXEC)
@lldb $(EXEC_PATH)
valgrind: $(FULL_EXEC)
@valgrind $(EXEC_PATH)
valgrind_massif: $(FULL_EXEC)
@valgrind --tool=massif $(EXEC_PATH)
$(DEPFILES):
include $(wildcard $(DEPFILES))