-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (52 loc) · 1.67 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
CXX := -c++
CXXFLAGS := -std=c++11 -pedantic-errors -Wall -Wextra -Werror
LDFLAGS := -L/usr/lib -lstdc++ -lm
BUILD := ./build
OBJ_DIR := $(BUILD)/objects
APP_DIR := $(BUILD)/apps
TARGET := slinky
INCLUDE := -Iinclude/
SRC := $(shell find src -name '*.cpp')
HEADERS := $(shell find include -name '*.h') $(shell find include -name '*.hpp')
OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o)
DEPENDENCIES \
:= $(OBJECTS:.o=.d)
space := $(empty) $(empty)
all: build $(APP_DIR)/$(TARGET)
$(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 format 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)/*
format:
@clang-format -i $(SRC) $(HEADERS)
info:
@echo " _ _ _ "
@echo " __| (_)_ _ | |___ _ "
@echo " (_-< | | ' \| / / || |"
@echo " /__/_|_|_||_|_\_\\_, |"
@echo " |__/ "
@echo ""
@echo "[*] Application dir: ${APP_DIR} "
@echo "[*] Object dir: ${OBJ_DIR} "
@echo "[*] Sources: "
@echo " - $(subst $(space),\n - ,$(SRC))"
@echo "[*] Headers: "
@echo " - $(subst $(space),\n - ,$(HEADERS))"
@echo "[*] Objects: "
@echo " - $(subst $(space),\n - ,$(OBJECTS))"
@echo "[*] Dependencies: "
@echo " - $(subst $(space),\n - ,$(DEPENDENCIES))"