-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
53 lines (42 loc) · 1.68 KB
/
makefile
File metadata and controls
53 lines (42 loc) · 1.68 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
TARGET = maeve
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
SRC_C := $(call rwildcard,third-party/,*.c)
SRC_CPP := $(call rwildcard,src/,*.cpp)
OBJDIR = build
OBJ_C = $(addprefix $(OBJDIR)/, $(SRC_C:.c=.o))
OBJ_CPP = $(addprefix $(OBJDIR)/, $(SRC_CPP:.cpp=.o))
default: debug
check-os:
ifeq ($(OS),Windows_NT)
$(info Building on Windows)
DEBUG_FLAGS = -g -DDEBUG -IC:/include -IC:/include/GLFW/include -IC:/include/freetype2/include -std=c++20
RELEASE_FLAGS = -O2 -IC:/include -IC:/include/GLFW/include -IC:/include/freetype2/include -std=c++20
LDFLAGS = -IC:/include -IC:/include/GLFW/include -IC:/include/freetype2/include -LC:/include/GLFW/lib-mingw-w64 -LC:/include/freetype2/build -lglfw3 -lopengl32 -lgdi32 -lfreetype -std=c++20
else
# Packages: libglm-dev, libglfw3-dev, libfreetype6-dev
# -Wall -Wextra
$(info Building on Linux OS)
DEBUG_FLAGS = -Og -DDEBUG -Ithird-party/ $(shell pkg-config --cflags freetype2) -std=c++20
RELEASE_FLAGS = -O2 -Ithird-party/ $(shell pkg-config --cflags freetype2) -std=c++20
LDFLAGS = -I/usr/include/glm/ -Ithird-party/ -lglfw $(shell pkg-config --libs freetype2) -std=c++20
endif
debug: check-os
debug: CXXFLAGS = $(DEBUG_FLAGS)
debug: $(TARGET)
release: check-os
release: CXXFLAGS = $(RELEASE_FLAGS)
release: $(TARGET)
# Link
$(TARGET): $(OBJ_C) $(OBJ_CPP)
g++ $^ -o $@ $(LDFLAGS)
# Compile c
$(OBJDIR)/%.o: %.c | create-dirs
@echo ""
gcc $(CXXFLAGS) -c $< -o $@
# Compile cpp
$(OBJDIR)/%.o: %.cpp | create-dirs
@echo ""
g++ $(CXXFLAGS) -c $< -o $@
create-dirs:
@echo "Creating directories: $(dir $(OBJ_C)) $(dir $(OBJ_CPP))"
@mkdir -p $(sort $(dir $(OBJ_C) $(OBJ_CPP))) 2>/dev/null