-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
54 lines (43 loc) · 1.36 KB
/
Copy pathmakefile
File metadata and controls
54 lines (43 loc) · 1.36 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
# Build type: "release" (default, optimized) or "debug" (no optimization, debug symbols,
# AddressSanitizer + UndefinedBehaviorSanitizer). Each type has its own object directory and
# binary, so `make` and `make debug` can coexist without a `make clean` in between.
BUILD_TYPE ?= release
CXX := g++
WARNINGS := -pedantic-errors -Wall -Wextra -Werror -std=c++17
BUILD := ./build
APP_DIR := $(BUILD)/apps
INCLUDE := -Iinclude/
LDFLAGS := -lm
ifeq ($(BUILD_TYPE),debug)
CXXFLAGS := $(WARNINGS) -g -O0 -DDEBUG -fsanitize=address,undefined -fno-omit-frame-pointer
OBJ_DIR := $(BUILD)/obj/debug
TARGET := regolit_main_debug.run
else
CXXFLAGS := $(WARNINGS) -O2
OBJ_DIR := $(BUILD)/obj/release
TARGET := regolit_main.run
endif
SRC := $(wildcard src/*.cpp)
OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o)
HEADERS := $(wildcard include/*.hpp)
all: main
main: build $(APP_DIR)/$(TARGET)
$(OBJ_DIR)/%.o: %.cpp $(HEADERS)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ -c $<
$(APP_DIR)/$(TARGET): $(OBJECTS)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $(APP_DIR)/$(TARGET) $(OBJECTS) $(LDFLAGS)
.PHONY: all main build clean debug release
build:
@mkdir -p $(APP_DIR)
@mkdir -p $(OBJ_DIR)
debug:
$(MAKE) BUILD_TYPE=debug main
release:
$(MAKE) BUILD_TYPE=release main
clean:
-@rm -rvf $(BUILD)/obj
-@rm -rvf $(APP_DIR)/*
-@rm -f "log/log.txt"
-@rm -rf "output/"*