-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
298 lines (274 loc) · 6.05 KB
/
Copy pathMakefile
File metadata and controls
298 lines (274 loc) · 6.05 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
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
PROGRAM:= strangepg
VERSION:= 0.9.6
DIRS:=
ifeq ($(wildcard .git),.git)
VERSION:= $(shell git describe --tags)
GITCMD:= git describe --abbrev=8 --always
ifneq ($(shell git diff-index --name-only HEAD --),"")
GITCMD+= --dirty
endif
GIT_HEAD:= $(shell $(GITCMD))
ifneq ($(GIT_HEAD),)
VERSION+= git_$(GIT_HEAD)
endif
endif
ARCH?= $(shell uname -m)
ifeq ($(OS),Windows_NT)
OS:= $(shell uname 2>/dev/null || echo Win64)
OS:= $(patsubst CYGWIN%,Cygwin,$(OS))
else
OS:= $(shell uname 2>/dev/null || echo NEIN)
endif
ifndef MAKE
ifeq ($(OS),OpenBSD)
MAKE:= gmake
else
MAKE:= make
endif
endif
ifndef TARGET
ifeq ($(OS),Darwin)
TARGET:= MacOS
else ifeq ($(OS),Cygwin)
TARGET:= Win64
else
TARGET:= Unix
endif
endif
CC?= clang
CPPFLAGS+= -MMD -MP
CPPFLAGS+= -fextended-identifiers -finput-charset=UTF-8
CPPFLAGS+= -DVERSION="\"$(VERSION)\""
CPPFLAGS+=\
-I.\
-Icmd\
-Idraw\
-Ifs\
-Igraph\
-Ilayout\
-Iposix\
-Irend\
-Iui\
-Iutil\
CFLAGS?= -O3 -pipe -march=native
# with minor plan9esque violations
# such as omitting parameter names in function definitions
# gnu designator: plan9 extension: struct dicks = {[enum1] {..}, [enum2] {..}}
CFLAGS+= -std=c11
CFLAGS+= -Wall -Wformat=2 -Wunused -Wno-parentheses -Wno-unknown-pragmas
ifdef DEBUG
ifdef ASAN
CFLAGS+= -O1 -fsanitize=address -fsanitize=leak -fsanitize=undefined
CFLAGS+= -fsanitize-address-use-after-scope
LDFLAGS+= -fsanitize=address -fsanitize=leak -fsanitize=undefined
LDFLAGS+= -fsanitize-address-use-after-scope
CPPFLAGS+= -D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS -fexceptions
else
CFLAGS+= -O0
endif
CFLAGS+= -DSOKOL_DEBUG
CFLAGS+= -fasynchronous-unwind-tables
CFLAGS+= -fstack-clash-protection -fstack-protector-strong
ifeq ($(CC), clang)
export LLVM_PROFILE_FILE:= ./llvm_%p.prof
CFLAGS+= -glldb -fprofile-instr-generate -fcoverage-mapping \
-Wno-c2x-extensions -Wno-cast-align
else
CFLAGS+= -ggdb -Wno-suggest-attribute=format -Wno-inline
endif
CFLAGS+= -Wdisabled-optimization -Winit-self \
-Winvalid-pch -Wmissing-format-attribute -Wpacked \
-Wredundant-decls -Wshadow -Wstack-protector \
-Wvariadic-macros
else
CPPFLAGS+= -DNDEBUG
CFLAGS+= -flto
LDFLAGS+= -flto
ifeq ($(CC), clang)
CFLAGS+= -glldb -Wno-c2x-extensions
else
CFLAGS+= -ggdb -Wno-discarded-qualifiers
endif
CFLAGS+= -Wno-incompatible-pointer-types -Wno-ignored-qualifiers \
-Wno-unused-result -Wno-unused-function -Wno-unused-value \
-Wno-format-nonliteral
endif
ifdef PROF
CFLAGS+= -pg
LDFLAGS+= -pg
endif
LDFLAGS?=
LDLIBS?=
GLOBJ:=\
sokol/draw.o\
sokol/impl_glsl.o\
sokol/shaders.o\
sokol/ui.o\
OBJ:=\
sokol/impl_nuklear.o\
sokol/impl_sokol_gfx.o\
sokol/impl_sokol_nuklear.o\
lib/chan.o\
lib/queue.o\
lib/plan9/getfields.o\
lib/plan9/seprint.o\
lib/plan9/strecpy.o\
posix/fs.o\
posix/sys.o\
posix/threads.o\
cmd/awk.o\
cmd/awkext.o\
cmd/awkprog.o\
cmd/cmd.o\
cmd/var.o\
draw/bih.o\
draw/color.o\
draw/draw.o\
draw/ray.o\
draw/view.o\
fs/ctab.o\
fs/em.o\
fs/fs.o\
fs/gfa.o\
fs/layout.o\
fs/load.o\
fs/metacsv.o\
fs/odgi.o\
fs/svg.o\
graph/coarse.o\
graph/graph.o\
layout/layout.o\
layout/pfr.o\
ui/ui.o\
util/print.o\
util/rand.o\
strpg.o\
strawk/alloc.o\
strawk/awkgram.tab.o\
strawk/b.o\
strawk/parse.o\
strawk/proctab.o\
strawk/tran.o\
strawk/lib.o\
strawk/run.o\
strawk/lex.o\
strawk/mt19937-64.o\
strawk/unix.o\
$(GLOBJ) \
GLSL:= $(patsubst %.glsl,%.h,$(wildcard glsl/*.glsl))
ifeq ($(TARGET),Unix)
PREFIX?= $(HOME)/.local
# _XOPEN_SOURCE: M_PI et al
# _POSIX_C_SOURCE >= 200809L: getline (in _DEFAULT_SOURCE)
CPPFLAGS+= -pthread -D_XOPEN_SOURCE=500
CPPFLAGS+= -Iunix
LDLIBS+= -lm
LDLIBS+= -lX11 -lXcursor -lXi
ifdef GLES
CPPFLAGS+= -DSOKOL_GLES3
LDLIBS+= -lGLESv2
EGL:=1
else
CPPFLAGS+= -DSOKOL_GLCORE
LDLIBS+= -lGL
endif
ifdef EGL
CPPFLAGS+= -DSOKOL_FORCE_EGL
LDLIBS+= -lEGL
endif
ifeq ($(OS),OpenBSD)
CPPFLAGS+= -I/usr/X11R6/include
LDFLAGS+= -L/usr/X11R6/lib
LDLIBS+= -pthread
endif
else ifeq ($(TARGET),Win64)
PROGRAM:= $(PROGRAM).exe
CPPFLAGS+= -pthread -D_XOPEN_SOURCE=500
CPPFLAGS+= -Iwin64
CFLAGS+= -mwin32 -mwindows
ifeq ($(OS),Cygwin)
PREFIX?= /usr
CPPFLAGS+= -DSOKOL_GLCORE
LDLIBS+= -lkernel32 -luser32 -lshell32 -lgdi32 -lopengl32
else
PREFIX?= ""
# FIXME
CC?= x86_64-w64-mingw32-gcc-posix
CFLAGS+= -mthreads
CPPFLAGS+= -DSOKOL_D3D11
OBJ+=\
win64/sys.o\
endif
LDFLAGS+= -static
LDLIBS+= -lkernel32 -luser32 -lshell32 -ldxgi -ld3d11 -lole32 -lgdi32 -Wl,-Bstatic -lpthread
else ifeq ($(TARGET),MacOS)
PREFIX?= /usr/local
# FIXME: -target arm64-apple-macos15.1
CPPFLAGS+= -pthread -D_DARWIN_C_SOURCE
CPPFLAGS+= -Imacos -DSOKOL_METAL
CFLAGS+= -ObjC
LDFLAGS+=\
-ObjC\
-framework Cocoa\
-framework QuartzCore\
-framework Metal\
-framework MetalKit\
-dead_strip\
-lpthread\
else
$(error unknown target)
endif
ifneq ($(PREFIX),"")
BINDIR:= $(PREFIX)/bin
else
BINDIR:= .
endif
BINTARGET:= $(PROGRAM)
ALLTARGETS:=\
$(BINTARGET)\
DEPS:=$(patsubst %.o,%.d,$(OBJ))
CLEANFILES:= $(OBJ) $(DEPS) $(BINTARGET)
all: $(ALLTARGETS) dirall
# sucks, but we want to force creating or updating these headers before
# the source using them is built and avoid any compilation failure or
# accidental usage of old headers, without having to rebuild anything
# else on update
$(GLOBJ): $(GLSL)
glsl/%.h: glsl/%.glsl
sokol-shdc -f sokol_impl -i $^ -l glsl430:hlsl5:metal_macos:glsl300es -o $@
$(BINTARGET): $(OBJ)
$(CC) $^ -o $@ $(LDFLAGS) $(LDLIBS)
install: $(ALLTARGETS) dirinstall
test -d $(BINDIR) || install -d -m755 $(BINDIR)
for i in $(ALLTARGETS); do \
test -z $(PREFIX) || install -m755 $$i $(BINDIR); \
done
uninstall: $(ALLTARGETS)
for i in $(ALLTARGETS); do \
$(RM) $(BINDIR)/$$i; \
done
for i in $(DIRS); do \
cd $$i; \
$(MAKE) uninstall; \
cd ..; \
done
dirall:
for i in $(DIRS); do \
cd $$i; \
$(MAKE) $(MAKEFLAGS) all; \
cd ..; \
done
dirinstall:
for i in $(DIRS); do \
cd $$i; \
$(MAKE) $(MAKEFLAGS) PREFIX=$(PREFIX) install; \
cd ..; \
done
clean:
$(RM) $(CLEANFILES)
for i in $(DIRS); do \
cd $$i; \
$(MAKE) clean; \
cd ..; \
done
-include $(DEPS)