-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (70 loc) · 2.51 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
76
77
78
79
80
81
82
83
84
85
86
87
#
# **************************************************************
# * Simple C++ Makefile Template *
# * *
# * Author: Arash Partow (2003) *
# * URL: http://www.partow.net/programming/makefile/index.html *
# * *
# * Copyright notice: *
# * Free use of this C++ Makefile template is permitted under *
# * the guidelines and in accordance with the the MIT License *
# * http://www.opensource.org/licenses/MIT *
# * *
# **************************************************************
#
UNAME_R := $(uname -r | grep microsoft)
CXX := g++
WARNINGS := -Wall -Wextra -Wswitch-enum -Wstack-protector -Wdate-time -Walloc-zero -Walloca
WARNINGS_NO := -Wno-shadow -Wno-unused-parameter
IF_WINDOWS := -fno-stack-protector
CXXFLAGS := -std=c++17 -pedantic-errors -fPIC $(WARNINGS) $(WARNINGS_NO)
LDFLAGS := -lstdc++ -lm -lboost_program_options -lboost_system
BUILD := ./build
OBJ_DIR := $(BUILD)/objects
APP_DIR := $(BUILD)/apps
TARGET := main
INCLUDE := -Iinclude/ -I/usr/local/include
SRC := \
$(wildcard src/*.cpp) \
$(wildcard src/utils/*.cpp) \
$(wildcard src/file/*.cpp) \
$(wildcard src/file/formats/*.cpp) \
$(wildcard src/config/*.cpp) \
OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o)
DEPENDENCIES \
:= $(OBJECTS:.o=.d)
#for some reason wsl doesn't work without stacksmashing removed?
#ifeq ($(UNAME_R),)
# CXXFLAGS := $(CXXFLAGS) $(IF_WINDOWS)
#endif
all: build $(APP_DIR)/$(TARGET)
@echo all
$(OBJ_DIR)/%.o: %.cpp
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -MMD -o $@
$(APP_DIR)/$(TARGET): $(OBJECTS)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -o $(APP_DIR)/$(TARGET) $^ $(LDFLAGS)
-include $(DEPENDENCIES)
.PHONY: all build clean debug release info
build:
@mkdir -p $(APP_DIR)
@mkdir -p $(OBJ_DIR)
debug: CXXFLAGS += -DDEBUG -g
debug: all
release: CXXFLAGS += -O2
release: all
clean:
-@rm -rvf $(OBJ_DIR)/*
-@rm -rvf $(APP_DIR)/*
info:
@echo "[*] Application dir: ${APP_DIR} "
@echo "[*] Object dir: ${OBJ_DIR} "
@echo "[*] Sources: ${SRC} "
@echo "[*] Objects: ${OBJECTS} "
@echo "[*] Dependencies: ${DEPENDENCIES}"
run:
@echo "running program"
@exec build/apps/${TARGET}
gdb:
gdb build/apps/${TARGET}