-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
75 lines (54 loc) · 1.4 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
69
70
71
72
73
74
75
# Author: Darshan Sen (RaisinTen)
# meta
TARGET := vpp
VERSION := 1.0.0
# dirs
SRC := ./src
INCLUDE := ./include
# files
CPPFILES = $(filter-out $(wildcard $(SRC)/Vector2d.cpp $(SRC)/vppMath.cpp), $(wildcard $(SRC)/*.cpp))
OBJECTS := $(patsubst $(SRC)/%, %, $(CPPFILES:.cpp=.o))
DEPS := $(OBJECTS:.o=.d)
.PHONY := all clean
# colours
PRE := \033[
NC := $(PRE)0m
GREEN := $(PRE)1;32m
YELLOW := $(PRE)1;33m
BLUE := $(PRE)1;36m
RED := $(PRE)1;31m
# tools
CPP := g++
RM := rm
# flags util
COMPILE := -c
STD := -std=c++17
SANITIZE := -fsanitize=address -fno-omit-frame-pointer
ARCH := $(shell getconf LONG_BIT)
MODE := -m$(ARCH)
DEBUG := -g -D_GLIBCXX_DEBUG
WARNINGS := -Wall
INCLUDE_FLAG := -I $(INCLUDE)
MAKE_DEPS := -MMD -MP
DEFINES := -D TARGET=\"$(TARGET)\" -D VERSION=\"$(VERSION)\"
# flags
CPPFLAGS := $(COMPILE) $(STD) $(SANITIZE) $(MODE) $(DEBUG) $(WARNINGS) $(INCLUDE_FLAG) $(MAKE_DEPS) $(DEFINES)
RMFLAGS := -f
# recipes
all: $(TARGET)
@echo "$(GREEN)Build complete!$(NC)"
$(TARGET): $(OBJECTS)
@echo "$(BLUE)... making $(YELLOW)$@ $(BLUE)...$(NC)\n"
$(CPP) -o $(TARGET) $(SANITIZE) $^
@echo ""
%.o: $(SRC)/%.cpp
@echo "$(BLUE)... making $(YELLOW)$@ $(BLUE)...$(NC)\n"
$(CPP) $(CPPFLAGS) $<
@echo ""
clean:
@echo "$(RED)... cleaning up ...$(NC)\n"
$(RM) $(RMFLAGS) $(OBJECTS) $(DEPS) $(TARGET)
@echo ""
@echo "$(RED)Cleaning complete!$(NC)"
# from the generated dependency files
-include $(DEPS)