forked from Mars999/regal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.regal
345 lines (272 loc) · 9.93 KB
/
Makefile.regal
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
ifndef MAKEFILE_REGAL_INCLUDED
MAKEFILE_REGAL_INCLUDED := 1
.PHONY: regal.lib regal.clean
include build/common.inc
include build/regal.inc
#
# regal
#
#
# Regenerate Regal sources
#
export:
python scripts/Export.py --api gl 4.5 --api wgl 4.5 --api glx 4.5 --api cgl 1.4 --api egl 1.0 --outdir .
# Shared library target not currently supported for NaCL or emscripten
ifneq ($(filter nacl% emscripten%,$(SYSTEM)),)
REGAL.SHARED :=
endif
ifdef REGAL.STATIC
include Makefile.apitrace
include Makefile.libpng
include Makefile.glsloptlib
include Makefile.pcrelib
all:: regal.lib
clean:: regal.clean
framework:: regal.framework
REGAL.LDFLAGS :=
ifeq ($(filter nacl%,$(SYSTEM)),)
REGAL.LDFLAGS += -lstdc++
endif
REGAL.LDFLAGS += -pthread -lm
REGAL.LIBS :=
ifeq ($(filter nacl%,$(SYSTEM)),)
REGAL.LDFLAGS += -ldl
endif
REGAL.SRCS := $(REGAL.CXX)
# Disable civetweb and Regal HTTP for NaCl build
ifeq ($(filter nacl% emscripten%,$(SYSTEM)),)
REGAL.SRCS += src/civetweb/civetweb.c
endif
ifeq ($(filter -DREGAL_NO_MD5%,$(CFLAGS)),)
REGAL.SRCS += src/md5/src/md5.c
endif
REGAL.SRCS += src/jsonsl/jsonsl.c
# Optional flags
# REGAL_SYS_ES1 for ES1 back-end support, disabled by default
# REGAL.CFLAGS += -DREGAL_SYS_ES1=1
#
# Add debug-specific flags
#
ifeq ($(MODE),debug)
#REGAL.CFLAGS += -DREGAL_ASSERT_VERBOSE=1
#REGAL.CFLAGS += -DREGAL_NO_ASSERT=1
endif
#
# In release mode we're aggressive about leaving out functionality
# in order to minimize the footprint of libRegal.so.1
#
ifeq ($(MODE),release)
REGAL.CFLAGS += -DNDEBUG
REGAL.CFLAGS += -DREGAL_DECL_EXPORT=1
REGAL.CFLAGS += -DREGAL_LOG_ALL=0
REGAL.CFLAGS += -DREGAL_LOG_ONCE=0
REGAL.CFLAGS += -DREGAL_LOG_JSON=0
REGAL.CFLAGS += -DREGAL_HTTP=0
REGAL.CFLAGS += -DREGAL_NO_ASSERT=1
REGAL.CFLAGS += -DREGAL_NO_PNG=1
REGAL.CFLAGS += -DREGAL_STATISTICS=0
REGAL.CFLAGS += -DREGAL_CODE=0
REGAL.CFLAGS += -fomit-frame-pointer
REGAL_LOG ?= 0
REGAL_ERROR ?= 0
REGAL_CACHE ?= 0
REGAL_DEBUG ?= 0
#REGAL_EMULATION ?= 1 # 0 for "loader only"
#REGAL.CFLAGS += -DREGAL_NO_TLS=0 # 1 for single threaded
endif
#
# Flags for custom mode
#
ifeq ($(MODE),custom)
endif
# NaCL options
ifneq ($(filter nacl%,$(SYSTEM)),)
REGAL.CFLAGS += -DREGAL_SYS_ES2=1
REGAL.CFLAGS += -DREGAL_HTTP=0
REGAL.CFLAGS += -DREGAL_STATISTICS=0
REGAL.CFLAGS += -Wno-constant-logical-operand
REGAL.CFLAGS += -DREGAL_PLUGIN=0
REGAL.CFLAGS += -DREGAL_TRACE=0
REGAL.CFLAGS += -DREGAL_NAMESPACE=1 -DREGAL_STATIC_ES2
REGAL_LOG = 0
REGAL_NO_TLS = 1
# Enabling this requires the library to be built with it, as well as all code
# that uses it. Defining this means that Regal will link statically to GL
# and EGL, and code will have to #include <GL/Regal.h> before any GL
# includes to pull in a bunch of #defines (e.g. #define glGetError rglGetError)
#LIB.CFLAGS += -DREGAL_SYS_EMSCRIPTEN_STATIC=1
endif
#
# Emscripten-specific
#
ifneq ($(filter emscripten%,$(SYSTEM)),)
REGAL.CFLAGS += -DREGAL_SYS_EMSCRIPTEN=1 -DREGAL_SYS_EGL=1 -DREGAL_SYS_ES2=1
REGAL.CFLAGS += -DREGAL_HTTP=0
REGAL.CFLAGS += -Wno-constant-logical-operand
REGAL.CFLAGS += -DREGAL_PLUGIN=0
REGAL.CFLAGS += -DREGAL_TRACE=0
REGAL.CFLAGS += -s LEGACY_GL_EMULATION=1
REGAL.CFLAGS += -s OUTLINING_LIMIT=50000
REGAL.CFLAGS += --js-opts 0
REGAL_LOG := 0
REGAL_ERROR := 0
REGAL_CACHE := 0
REGAL_DEBUG := 0
REGAL_NO_TLS := 1
endif
#
ifneq ($(REGAL_LOG),)
REGAL.CFLAGS += -DREGAL_LOG=$(REGAL_LOG)
endif
ifneq ($(REGAL_ERROR),)
REGAL.CFLAGS += -DREGAL_ERROR=$(REGAL_ERROR)
endif
ifneq ($(REGAL_CACHE),)
REGAL.CFLAGS += -DREGAL_CACHE=$(REGAL_CACHE)
endif
ifneq ($(REGAL_DEBUG),)
REGAL.CFLAGS += -DREGAL_DEBUG=$(REGAL_DEBUG)
endif
ifneq ($(REGAL_EMULATION),)
REGAL.CFLAGS += -DREGAL_EMULATION=$(REGAL_EMULATION)
endif
ifneq ($(REGAL_WRANGLER),)
REGAL.CFLAGS += -DREGAL_WRANGLER=$(REGAL_WRANGLER)
endif
ifneq ($(REGAL_NO_TLS),)
REGAL.CFLAGS += -DREGAL_NO_TLS=$(REGAL_NO_TLS)
endif
REGAL.CFLAGS += -fvisibility=hidden
REGAL.SRCS.NAMES := $(notdir $(REGAL.SRCS))
REGAL.HEADERS :=
REGAL.HEADERS += include/GL/Regal.h
REGAL.HEADERS += src/regal/RegalPrivate.h
REGAL.OBJS := $(addprefix tmp/$(SYSTEM)/regal/static/,$(REGAL.SRCS.NAMES))
REGAL.OBJS := $(REGAL.OBJS:.c=.o)
REGAL.OBJS := $(REGAL.OBJS:.cpp=.o)
REGAL.DEPS := $(REGAL.OBJS:.o=.d)
REGAL.SOBJS := $(addprefix tmp/$(SYSTEM)/regal/shared/,$(REGAL.SRCS.NAMES))
REGAL.SOBJS := $(REGAL.SOBJS:.c=.o)
REGAL.SOBJS := $(REGAL.SOBJS:.cpp=.o)
REGAL.SDEPS := $(LIBS.SOBJS:.o=.d)
-include $(REGAL.DEPS) $(REGAL.SDEPS)
REGAL.LIBS += $(LDFLAGS.X11)
ifneq ($(filter linux%,$(SYSTEM)),)
REGAL.SONAME := lib$(NAME).so.$(SO_MAJOR)
REGAL.DEVLNK := lib$(NAME).so
REGAL.SHARED := lib$(NAME).so.$(SO_VERSION)
REGAL.LDFLAGS.SO := $(LDFLAGS.SO) $(LDFLAGS.DYNAMIC) -Wl,-soname=$(REGAL.SONAME)
endif
ifneq ($(filter darwin%,$(SYSTEM)),)
OPENGL_NAME := OpenGL
OPENGL_FRAMEWORK := $(OPENGL_NAME).framework
OPENGL := $(OPENGL_FRAMEWORK)/Versions/A/$(OPENGL_NAME)
REGAL.SONAME := lib$(NAME).$(SO_MAJOR).dylib
REGAL.DEVLNK := lib$(NAME).dylib
REGAL.SHARED := lib$(NAME).$(SO_VERSION).dylib
REGAL.FRAMEWORK := $(NAME)
REGAL.LDFLAGS.SO := $(LDFLAGS.SO) $(LDFLAGS.DYNAMIC) -current_version $(SO_VERSION) -compatibility_version $(SO_MAJOR)
#LDFLAGS.SO += -install_name $(REGAL_DEST)/lib/$(REGAL.SHARED)
REGAL.LDFLAGS += -Wl,-reexport-lGLU -L/System/Library/Frameworks/$(OPENGL_FRAMEWORK)/Versions/A/Libraries
INFO_PLIST := build/mac/Info.plist
endif
ifdef REGAL.STATIC
regal.lib: lib/$(SYSTEM)/$(REGAL.STATIC)
endif
ifdef REGAL.SHARED
regal.lib: lib/$(SYSTEM)/$(REGAL.SHARED)
endif
regal.clean:
$(RM) -r tmp/$(SYSTEM)/regal/static
$(RM) -r tmp/$(SYSTEM)/regal/shared
ifdef REGAL.STATIC
$(RM) -r lib/$(SYSTEM)/$(REGAL.STATIC)
endif
ifdef REGAL.SHARED
$(RM) -r bin/$(SYSTEM)/$(REGAL.SHARED)
endif
ifneq ($(filter darwin%,$(SYSTEM)),)
regal.framework:
$(RM) -r $(OPENGL_FRAMEWORK)
$(MKDIR) $(OPENGL_FRAMEWORK)/Versions/A/Resources
$(MKDIR) $(OPENGL_FRAMEWORK)/Versions/A/Libraries
$(LN) A $(OPENGL_FRAMEWORK)/Versions/Current
$(LN) Versions/Current/Resources $(OPENGL_FRAMEWORK)/Resources
$(LN) Versions/Current/Headers $(OPENGL_FRAMEWORK)/Headers
$(LN) Versions/Current/Libraries $(OPENGL_FRAMEWORK)/Libraries
$(LN) Versions/Current/$(OPENGL_NAME) $(OPENGL_FRAMEWORK)/$(OPENGL_NAME)
$(CP) $(INFO_PLIST) $(OPENGL_FRAMEWORK)/Resources
ifdef REGAL.SHARED
$(CP) lib/$(SYSTEM)/$(REGAL.SHARED) $(OPENGL_FRAMEWORK)/Versions/A/Libraries/$(OPENGL_NAME)
endif
$(LN) Libraries/$(OPENGL_NAME) $(OPENGL_FRAMEWORK)/Versions/A/$(OPENGL_NAME)
endif
ifdef APITRACE.STATIC
lib/$(SYSTEM)/$(REGAL.STATIC): lib/$(SYSTEM)/$(APITRACE.STATIC) lib/$(SYSTEM)/$(SNAPPY.STATIC)
endif
ifneq ($(filter nacl%,$(SYSTEM)),)
ifeq ($(NACL_LIBC),glibc)
regal.lib: lib/$(SYSTEM)/$(REGAL.SHARED)
endif
endif
lib/$(SYSTEM)/$(REGAL.STATIC): lib/$(SYSTEM)/$(GLSLOPT.STATIC) lib/$(SYSTEM)/$(PCRE.STATIC) lib/$(SYSTEM)/$(LIBPNG.STATIC) lib/$(SYSTEM)/$(ZLIB.STATIC) $(REGAL.OBJS)
@mkdir -p $(dir $@)
$(LOG_AR)$(CCACHE) $(AR) cr $@ $(REGAL.OBJS)
ifneq ($(RANLIB),)
$(LOG_RANLIB)$(RANLIB) $@
endif
ifneq ($(STRIP),)
$(LOG_STRIP)$(STRIP) -x $@
endif
REGAL.SHARED.DEPEND :=
REGAL.SHARED.DEPEND += lib/$(SYSTEM)/$(GLSLOPT.STATIC) lib/$(SYSTEM)/$(PCRE.STATIC) lib/$(SYSTEM)/$(LIBPNG.STATIC) lib/$(SYSTEM)/$(ZLIB.STATIC)
ifdef APITRACE.STATIC
REGAL.SHARED.DEPEND += lib/$(SYSTEM)/$(APITRACE.STATIC) lib/$(SYSTEM)/$(SNAPPY.STATIC)
endif
ifdef REGAL.SHARED
lib/$(SYSTEM)/$(REGAL.SHARED): $(REGAL.SHARED.DEPEND) $(REGAL.SOBJS)
ifdef APITRACE.STATIC
$(LOG_LD)$(CCACHE) $(LD) $(LDFLAGS.EXTRA) $(REGAL.LDFLAGS.SO) -o $@ $(LDFLAGS.STARTGROUP) $(REGAL.SOBJS) lib/$(SYSTEM)/$(APITRACE.STATIC) $(LDFLAGS.ENDGROUP) $(REGAL.SHARED.DEPEND) $(REGAL.LIBS) $(REGAL.LDFLAGS)
else
$(LOG_LD)$(CCACHE) $(LD) $(LDFLAGS.EXTRA) $(REGAL.LDFLAGS.SO) -o $@ $(REGAL.SOBJS) $(REGAL.SHARED.DEPEND) $(REGAL.LIBS) $(REGAL.LDFLAGS)
endif
ifneq ($(LN),)
$(LN) $(REGAL.SHARED) lib/$(SYSTEM)/$(REGAL.SONAME)
$(LN) $(REGAL.SHARED) lib/$(SYSTEM)/$(REGAL.DEVLNK)
ifneq ($(REGAL.FRAMEWORK),)
$(LN) $(REGAL.SHARED) lib/$(SYSTEM)/$(REGAL.FRAMEWORK)
endif
endif
ifneq ($(STRIP),)
$(LOG_STRIP)$(STRIP) -x $@
endif
ifneq ($(ABIDUMP),)
$(LOG_ABIDUMP)$(ABIDUMP) $@ -o [email protected]
endif
endif
tmp/$(SYSTEM)/regal/static/%.o: src/regal/%.cpp $(REGAL.HEADERS)
@mkdir -p $(dir $@)
$(LOG_CXX)$(CCACHE) $(CXX) $(REGAL.CFLAGS) $(CFLAGS) $(CFLAGS.SO) $(GLSLOPT.INCLUDE) $(REGAL.INCLUDE) -o $@ -c $<
tmp/$(SYSTEM)/regal/shared/%.o: src/regal/%.cpp $(REGAL.HEADERS)
@mkdir -p $(dir $@)
$(LOG_CXX)$(CCACHE) $(CXX) $(REGAL.CFLAGS) $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) $(GLSLOPT.INCLUDE) $(REGAL.INCLUDE) -o $@ -c $<
tmp/$(SYSTEM)/regal/static/%.o: src/civetweb/%.c $(REGAL.HEADERS)
@mkdir -p $(dir $@)
$(LOG_CC)$(CCACHE) $(CC) $(REGAL.CFLAGS) $(CFLAGS) $(CFLAGS.SO) $(REGAL.INCLUDE) -o $@ -c $<
tmp/$(SYSTEM)/regal/shared/%.o: src/civetweb/%.c $(REGAL.HEADERS)
@mkdir -p $(dir $@)
$(LOG_CC)$(CCACHE) $(CC) $(REGAL.CFLAGS) $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) $(REGAL.INCLUDE) -o $@ -c $<
tmp/$(SYSTEM)/regal/static/%.o: src/md5/src/%.c $(REGAL.HEADERS)
@mkdir -p $(dir $@)
$(LOG_CC)$(CCACHE) $(CC) $(REGAL.CFLAGS) $(CFLAGS) $(CFLAGS.SO) $(REGAL.INCLUDE) -o $@ -c $<
tmp/$(SYSTEM)/regal/shared/%.o: src/md5/src/%.c $(REGAL.HEADERS)
@mkdir -p $(dir $@)
$(LOG_CC)$(CCACHE) $(CC) $(REGAL.CFLAGS) $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) $(REGAL.INCLUDE) -o $@ -c $<
tmp/$(SYSTEM)/regal/static/%.o: src/jsonsl/%.c $(REGAL.HEADERS)
@mkdir -p $(dir $@)
$(LOG_CC)$(CCACHE) $(CC) $(REGAL.CFLAGS) $(CFLAGS) $(CFLAGS.SO) $(REGAL.INCLUDE) -o $@ -c $<
tmp/$(SYSTEM)/regal/shared/%.o: src/jsonsl/%.c $(REGAL.HEADERS)
@mkdir -p $(dir $@)
$(LOG_CC)$(CCACHE) $(CC) $(REGAL.CFLAGS) $(CFLAGS) $(PICFLAG) $(CFLAGS.SO) $(REGAL.INCLUDE) -o $@ -c $<
endif
endif