-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
121 lines (86 loc) · 3.19 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#.SILENT:
flags := -Wall -Wpedantic -pedantic-errors -Wextra
compileflags := -std=c++2a -I.
linkflags := -Wl,-rpath=/opt/gcc-12.2.0/lib64
ifdef DEBUG
flags := $(flags) -ggdb -g -Og -gdwarf-4 -DDEBUG
endif
ifdef PROFILE
flags := $(flags) -pg
endif
ifdef OPENCV
OPENCV_PATH := /opt/opencv
compileflags := $(compileflags) -DHAS_OPENCV -isystem$(OPENCV_PATH)/include
linkflags := $(linkflags) -Wl,-rpath=$(OPENCV_PATH)/lib -L$(OPENCV_PATH)/lib
opencv-libs := -lopencv_core -lopencv_highgui
endif
compilecmd = g++ $(flags) $(compileflags) $(CXXFLAGS)
linkcmd = g++ $(flags) $(linkflags) $(LDFLAGS)
.PHONY: all clean packassets unpackassets checkflags
all: out/objmain out/randmain out/chunkmain out/2dmain
.flags:
if test \\\! -f .flags; then touch .flags; fi
checkflags: .flags
if echo "$(compilecmd)" "$(linkcmd)" "$(opencv-libs)"|cmp .flags; then \
:; \
else \
echo "$(compilecmd)" "$(linkcmd)" "$(opencv-libs)">.flags; \
make $(MAKECMDGOALS); \
fi
%.o: %.c++ %.h++ shared.h++ .flags|checkflags
$(compilecmd) -c $< -o $@
window.o: texture.h++ shaders.h++
obj.o: file.h++
objs.o: file.h++
assets/assets.o: file.h++ out/assets
randmain/randmain.o: randmain/randmain.c++ random.h++ chunk.h++
objmain/objmain.o: objmain/objmainfuncs.c++ window.h++ shaders.h++ matrix.h++ parseargs.h++ obj.h++ assets/assets.h++
chunkmain/chunkmain.o: chunkmain/chunkmainfuncs.c++ chunkmain/chunkmain.h++ assets/assets.h++ parseargs.h++ shaders.h++ window.h++ matrix.h++ random.h++ chunk.h++ objs.h++
2dmain/2dmain.o: 2dmain/2dmainfuncs.c++ 2dmain/2dmain.h++ assets/assets.h++ parseargs.h++ shaders.h++ window.h++ matrix.h++ random.h++ chunk.h++ objs.h++
assets/packedassets.o: assets/packedassets.S
# merge is ld -r a.o b.o -o c.o
assets/getpackedassets.o: assets/packedassets.c++|checkflags
$(compilecmd) -c assets/packedassets.c++ -o assets/getpackedassets.o
assets/packedassets.S: assets/packassets.sh assets/assets/cat.obj assets/assets/objshader.frag assets/assets/objshader.vert
bash assets/packassets.sh assets/packedassets.S assets/cat.obj assets/objshader.frag assets/objshader.vert
packassets: assets/packedassets.o assets/getpackedassets.o
ld -r assets/getpackedassets.o assets/packedassets.o -o assets/assets.o
unpackassets:
rm assets/assets.o
out/randmain: randmain/randmain.o random.o chunk.o|checkflags
$(linkcmd) $^ -o $@
out/objmain: objmain/objmain.o shaders.o window.o matrix.o texture.o parseargs.o obj.o file.o assets/assets.o|checkflags
$(linkcmd) $^ \
-lSDL2 \
-lGL -lGLEW \
$(opencv-libs) \
-o $@
out/chunkmain: chunkmain/chunkmain.o shaders.o window.o matrix.o texture.o parseargs.o objs.o file.o assets/assets.o chunk.o random.o|checkflags
$(linkcmd) $^ \
-lSDL2 \
-lGL -lGLEW \
$(opencv-libs) \
-o $@
out/2dmain: 2dmain/2dmain.o shaders.o window.o matrix.o texture.o parseargs.o objs.o file.o assets/assets.o chunk.o random.o|checkflags
$(linkcmd) $^ \
-lSDL2 -lSDL2_image \
-lGL -lGLEW \
$(opencv-libs) \
-o $@
out:
mkdir -p out
out/assets: out assets/assets/*
cp -r assets/assets out
clean:
rm -f *.o
rm -f */*.o
rm -f out/objmain
rm -f out/chunkmain
rm -f out/randmain
rm -f assets/packedassets.S
debug-%:
make $* DEBUG=1
profile-%:
make $* PROFILE=1
opencv-%:
make $* OPENCV=1