-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (63 loc) · 1.71 KB
/
Makefile
File metadata and controls
77 lines (63 loc) · 1.71 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Aqua Template project makefile
# Compiler / Linker configs
CC := g++
CC_FLAGS := -c \
-W \
-std=c++17 \
# -Wall \
# -ansi \
# -pedantic \
# Directories
SRC_DIR := src
INCLUDE_DIR := include
LIB_DIR := lib
BIN_DIR := bin
OBJ_DIR := build
TESTS_DIR := tests
TEMPLATE_DIR := templates
PREFIX := /usr/local
# Filenames
TARGET := aqua-template
TEST_TARGET := main_tests
SRC := $(wildcard $(SRC_DIR)/*.cpp)
H_SRC := $(wildcard $(INCLUDE_DIR)/*.hpp)
OBJ := $(SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
#
# Compilation and linking
#
all: binFolder objFolder $(TARGET)
$(TARGET): $(OBJ)
@echo "🚀 Building binary \"$@\" using G++ linker..."
@$(CC) $^ -o $(BIN_DIR)/$@
@echo "🎇 Build complete!"
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@echo "🪛 Compiling object file: $@..."
@$(CC) $(CC_FLAGS) $< -I $(INCLUDE_DIR)/ -o $@
objFolder:
@mkdir -p $(OBJ_DIR)
binFolder:
@mkdir -p $(BIN_DIR)
# Cleaning binaries and static libraries (object files)
clean:
@echo "🧹 Cleaning..."
@rm -r $(OBJ_DIR)
@rm -r $(BIN_DIR)
@echo "🧹 Done!"
# Running the project
run:
@./$(BIN_DIR)/$(TARGET)
# Installing the project locally
install:
@install -m 777 $(BIN_DIR)/$(TARGET) $(PREFIX)/bin
@install -d $(PREFIX)/etc/$(TARGET)/
@cp -rf $(TEMPLATE_DIR) $(PREFIX)/etc/$(TARGET)/
@chmod -R a+rwx $(PREFIX)/etc/$(TARGET)
# Building tests
test: $(TEST_TARGET)
@echo "🚙 Running tests:"
@./$(TESTS_DIR)/$(TEST_TARGET)
# Executing tests
$(TEST_TARGET):
@echo "🛠️ Building tests..."
@$(CC) $(TESTS_DIR)/*.cpp -I$(INCLUDE_DIR) --std=c++17 -o $(TESTS_DIR)/$@
.PHONY: all clean run test install