-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
234 lines (196 loc) · 5.43 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#
# Created by gmakemake (Ubuntu Jun 8 2024) on Sun Jun 16 19:49:12 2024
#
#
# Definitions
#
.SUFFIXES:
.SUFFIXES: .a .o .c .C .cpp .s .S
.c.o:
$(COMPILE.c) -o $@ $<
.C.o:
$(COMPILE.cc) -o $@ $<
.cpp.o:
$(COMPILE.cc) -o $@ $<
.S.s:
$(CPP) -o $*.s $<
.s.o:
$(COMPILE.cc) -o $@ $<
.c.a:
$(COMPILE.c) -o $% $<
$(AR) $(ARFLAGS) $@ $%
$(RM) $%
.C.a:
$(COMPILE.cc) -o $% $<
$(AR) $(ARFLAGS) $@ $%
$(RM) $%
.cpp.a:
$(COMPILE.cc) -o $% $<
$(AR) $(ARFLAGS) $@ $%
$(RM) $%
CC = gcc
CXX = g++
RM = rm -f
AR = ar
LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
LINK.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
CPP = $(CPP) $(CPPFLAGS)
########## Flags from header.mak
CPPFLAGS = -Wall -Wextra -Werror -pedantic -Wno-unused-parameter -Wno-unknown-pragmas -Iinclude -Iimgui/ -Iimgui/backends/ -Infd/src/include/
CXXFLAGS = --std=c++11
ifeq ($(OS),Windows_NT)
CCLIBFLAGS = -Llib -lglfw3 -lopengl32 -lgdi32 -lshell32 -lole32 -luuid
else
CCLIBFLAGS = -Llib -lglfw -lGL
endif
ifeq ($(MAKECMDGOALS),build)
CPPFLAGS += -s -Ofast -DNDEBUG -DNO_DEMO_WINDOW
ifeq ($(CXX),cccl)
CCLIBFLAGS += /O2 /link /subsystem:windows /ENTRY:mainCRTStartup /nologo
unexport CXXFLAGS
else
ifeq ($(OS),Windows_NT)
CCLIBFLAGS += -static-libgcc -static-libstdc++ -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive
CXXFLAGS += -mwindows
endif
endif
endif
ifeq ($(MAKECMDGOALS),shared)
CPPFLAGS += -s -Ofast -DNDEBUG -DNO_DEMO_WINDOW -DGLFW_DLL -DDLL_IMPORT
CCLIBFLAGS := $(filter-out -lglfw3,$(CCLIBFLAGS))
ifeq ($(CXX),cccl)
CCLIBFLAGS += -luser32 -lglfw3dll /O2 /link /subsystem:windows /ENTRY:mainCRTStartup /nologo
unexport CXXFLAGS
else
ifeq ($(OS),Windows_NT)
CCLIBFLAGS += -lglfw3dll lib/*.dll
CXXFLAGS += -mwindows
endif
CCLIBFLAGS := -Wl,-Bdynamic $(CCLIBFLAGS)
endif
endif
ifeq ($(MAKECMDGOALS),emscripten)
CPPFLAGS += -s -Ofast -DNDEBUG -DNO_DEMO_WINDOW
CPPFLAGS += -Wno-dollar-in-identifier-extension -x c++ -lglfw3
endif
########## End of flags from header.mak
CPP_FILES = 3to4++.cpp camera.cpp control.cpp font.cpp gui.cpp pieces.cpp puzzle.cpp render.cpp shaders.cpp window.cpp
C_FILES = gl.c
PS_FILES =
S_FILES =
H_FILES = camera.h constants.h control.h font.h gui.h pieces.h puzzle.h render.h shaders.h window.h
SOURCEFILES = $(H_FILES) $(CPP_FILES) $(C_FILES) $(S_FILES)
.PRECIOUS: $(SOURCEFILES)
OBJFILES = camera.o control.o font.o gui.o pieces.o puzzle.o render.o shaders.o window.o gl.o
#
# Main targets
#
all: 3to4++
3to4++: 3to4++.o $(OBJFILES)
$(CXX) $(CXXFLAGS) -o 3to4++ 3to4++.o $(OBJFILES) $(CCLIBFLAGS)
#
# Dependencies
#
3to4++.o: camera.h control.h gui.h pieces.h puzzle.h render.h window.h
camera.o: camera.h constants.h
control.o: constants.h control.h pieces.h puzzle.h render.h
font.o:
gui.o: control.h font.h gui.h pieces.h puzzle.h render.h
pieces.o: pieces.h
puzzle.o: puzzle.h
render.o: constants.h control.h pieces.h puzzle.h render.h
shaders.o: shaders.h
window.o: camera.h constants.h control.h gui.h pieces.h puzzle.h render.h shaders.h window.h
gl.o:
########## Targets from targets.mak
.PHONY: all run addicon build shared clean realclean
IMGUI_SOURCEFILES = imgui/imgui.cpp \
imgui/imgui_draw.cpp \
imgui/imgui_demo.cpp \
imgui/imgui_tables.cpp \
imgui/imgui_widgets.cpp \
imgui/backends/imgui_impl_glfw.cpp \
imgui/backends/imgui_impl_opengl3.cpp
IMGUI_OBJFILES = $(IMGUI_SOURCEFILES:.cpp=.o)
NFD_SOURCEFILES = nfd/src/nfd_common.c
NFD_OBJFILES = nfd/src/nfd_common.o
ifeq ($(OS),Windows_NT)
NFD_SOURCEFILES += nfd/src/nfd_win.cpp
NFD_OBJFILES += nfd/src/nfd_win.o
else
NFD_SOURCEFILES += nfd/src/nfd_zenity.c
NFD_OBJFILES += nfd/src/nfd_zenity.o
endif
ifneq ($(CXX),cccl)
ifeq ($(MAKECMDGOALS),shared)
ifeq ($(OS),Windows_NT)
LIBIMGUI = lib/imgui.dll
LIBNFD = lib/nfd.dll
else
LIBIMGUI = lib/libimgui.so
LIBNFD = lib/libnfd.so
endif
$(IMGUI_OBJFILES): CXXFLAGS += -fPIC
$(LIBIMGUI): $(IMGUI_OBJFILES)
rm -f $@
ifeq ($(OS),Windows_NT)
$(LINK.cc) -shared -o $@ $^ lib/glfw3.dll
else
$(LINK.cc) -shared -o $@ $^ -lglfw
endif
$(NFD_OBJFILES): CXXFLAGS += -fPIC
$(LIBNFD): $(NFD_OBJFILES)
rm -f $@
$(LINK.cc) -shared -o $@ $^
clean: OBJFILES += $(IMGUI_OBJFILES) $(NFD_OBJFILES)
CCLIBFLAGS += -Wl,-rpath=\$$ORIGIN -limgui -lnfd
else
OBJFILES += $(IMGUI_OBJFILES) $(NFD_OBJFILES)
endif
else
OBJFILES += $(IMGUI_OBJFILES) $(NFD_OBJFILES)
endif
ifeq ($(OS),Windows_NT)
resources.o: resources.rc icons/icons.ico
windres resources.rc -o resources.o
OBJFILES += resources.o
endif
3to4++: 3to4++.o $(LIBIMGUI) $(LIBNFD) $(OBJFILES)
run: 3to4++
./3to4++
build: clean all
rm -rf 3to4pp
mkdir 3to4pp
cp 3to4++ 3to4pp
cp LICENSE 3to4pp
shared: build
ifeq ($(OS),Windows_NT)
ldd 3to4++ | grep -v "WINDOWS" | sed -e 's/\t.*\.dll => \| \(.*\)\|not found//g' | xargs -I {} cp {} 3to4pp
cp lib/*.dll 3to4pp
else
cp lib/*.so 3to4pp
endif
release:
rm -rf dist
make build
7z a dist/3to4++.zip 3to4pp/
make shared
7z a dist/3to4++dll.zip 3to4pp/
emscripten:
rm -rf web/3to4++*
em++ $(CPPFLAGS) $(CPP_FILES) $(C_FILES) $(IMGUI_SOURCEFILES) \
-o web/3to4++.js -sMAX_WEBGL_VERSION=3 -sFILESYSTEM=0 \
-flto --closure 1 -sENVIRONMENT=web
########## End of targets from targets.mak
#
# Housekeeping
#
Archive: archive.tgz
archive.tgz: $(SOURCEFILES) Makefile
tar cf - $(SOURCEFILES) Makefile | gzip > archive.tgz
clean:
-/bin/rm -f $(OBJFILES) 3to4++.o core
realclean: clean
-/bin/rm -f 3to4++