-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (58 loc) · 1.92 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
ifeq ($(BUILD),release)
BUILDFLAGS := -O3
else
BUILDFLAGS := -g -O0
endif
ifeq ($(OS),Windows_NT)
DEPS := gtk4 gtkmm-4.0
OUTPUT := game.exe
else
DEPS := gtk4 gtkmm-4.0 x11
OUTPUT := game
endif
STANDARD ?= -std=c++2a
CPP := g++
CPPFLAGS := -Wall -Wextra $(BUILDFLAGS) $(STANDARD) -Iinclude -Ijson/single_include/nlohmann
INCLUDES := $(shell pkg-config --cflags $(DEPS))
LIBS := $(shell pkg-config --libs $(DEPS))
LDFLAGS := -pthread
SOURCES := $(shell find src -name \*.cpp) src/resources.cpp
OBJECTS := $(SOURCES:.cpp=.o)
GLIB_COMPILE_RESOURCES = $(shell pkg-config --variable=glib_compile_resources gio-2.0)
.PHONY: all clean test run
all: $(OUTPUT)
src/resources.cpp: game2.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=resources --generate-dependencies game2.gresource.xml)
$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=resources --generate-source $<
%.o: %.cpp
@ printf "\e[2m[\e[22;32mCC\e[39;2m]\e[22m $< \e[2m$(BUILDFLAGS)\e[22m\n"
@ $(CPP) $(CPPFLAGS) $(INCLUDES) -c $< -o $@
$(OUTPUT): $(OBJECTS)
@ printf "\e[2m[\e[22;36mLD\e[39;2m]\e[22m $@\n"
@ $(CPP) $^ -o $@ $(LIBS) $(LDFLAGS)
ifeq ($(BUILD),release)
strip $@
endif
test: $(OUTPUT)
./$(OUTPUT)
run: $(OUTPUT)
./$(OUTPUT)
clean:
@ echo rm -f $$\(OBJECTS\) $(OUTPUT) src/resources.cpp
@ rm -f $(OBJECTS) $(OUTPUT) src/resources.cpp
install: $(OUTPUT)
mkdir -p ~/.cache/gnome-builder/install/game2/host/
cp $(OUTPUT) ~/.cache/gnome-builder/install/game2/host/
count:
cloc . --exclude-dir=.vscode
countbf:
cloc --by-file . --exclude-dir=.vscode
install-desktop-file:
@ mkdir -p ~/.local/share/applications
sed -e "s#@bindir@#$$PWD#" desktop.in > ~/.local/share/applications/game2.desktop
DEPFILE := .dep
DEPTOKEN := "\# MAKEDEPENDS"
depend:
@ echo $(DEPTOKEN) > $(DEPFILE)
makedepend -f $(DEPFILE) -s $(DEPTOKEN) -- $(CPP) $(CPPFLAGS) -- $(SOURCES) 2>/dev/null
@ rm $(DEPFILE).bak
sinclude $(DEPFILE)