forked from msikma/allegro-4.2.2-xc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile.osx
450 lines (329 loc) · 14.2 KB
/
makefile.osx
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
#
# Rules for building the Allegro library with MacOS X. This file is included
# by the primary makefile, and should not be used directly.
#
# The "depend" and "install" targets use sed.
#
# See makefile.all for a list of the available targets.
# -------- define some variables that the primary makefile will use --------
PLATFORM = MacOS X
ifdef UB
CC = misc/gcc-uni.sh
else
CC = gcc
endif
OBJ_DIR = obj/macosx/$(VERSION)
EXE =
OBJ = .o
HTML = html
PLATFORM_DIR = obj/macosx
UNIX_TOOLS = 1
RM_OPTS = -f
# -------- local variables --------
FRAMEWORK_DIR = /Library/Frameworks
FRAMEWORK_NAME = Allegro
FRAMEWORK = $(FRAMEWORK_DIR)/$(FRAMEWORK_NAME).framework
HELPBUNDLE:=/Library/Documentation/Help/Allegro.bundle
TEMPLATE_DIR = /Developer/ProjectBuilder\ Extras/Project\ Templates/Application
ifeq ($(wildcard $(TEMPLATE_DIR)),)
TEMPLATE_DIR = /Library/Application\ Support/Apple/Developer\ Tools/Project\ Templates/Application
endif
TEMPLATE_NAME = Allegro\ Application
TEMPLATE = $(TEMPLATE_DIR)/$(TEMPLATE_NAME)
MAN_DIR = /usr/local/man
ifdef STATICLINK
# -------- link as a static library --------
LIB_NAME = lib/macosx/lib$(VERSION)_s.a
else
# -------- link as a shared library --------
LIB_NAME = lib/macosx/lib$(VERSION)-$(shared_version).dylib
LIB_MAIN_NAME = lib/macosx/lib$(VERSION)-main.a
DYLINK_FLAGS = -compatibility_version $(compatibility_version) -current_version $(shared_version)
INSTALL_NAME = -install_name lib$(VERSION)-$(shared_major_minor).dylib
INSTALL_NAME_EMBED = -install_name "`echo "@executable_path/../Frameworks/$(FRAMEWORK_NAME).framework/Versions/$(shared_version)/$(FRAMEWORK_NAME)" | sed 's!//*!/!g'`"
ifdef EMBED
FRAMEWORK_DESCRIPTION = "embeddable"
else
FRAMEWORK_DESCRIPTION = "system wide"
endif
endif # STATICLINK
# -------- give a sensible default target for make without any args --------
.PHONY: _default
_default: default
# -------- decide what compiler options to use --------
ifdef WARNMODE
WFLAGS = -Wall -W -Werror -Wno-unused -Wno-long-double
else
WFLAGS = -Wall -Wno-unused -Wno-long-double
endif
ifdef TARGET_ARCH_COMPAT
TARGET_ARCH = $(GCC_MTUNE)=$(TARGET_ARCH_COMPAT)
else
ifdef TARGET_ARCH_EXCL
TARGET_ARCH = -march=$(TARGET_ARCH_EXCL)
endif
endif
ifndef TARGET_OPTS
TARGET_OPTS = -O2 -funroll-loops -ffast-math
endif
OFLAGS = $(TARGET_ARCH) $(TARGET_OPTS)
CFLAGS = -DALLEGRO_LIB_BUILD
ifdef DEBUGMODE
# -------- debugging build --------
CFLAGS += -DDEBUGMODE=$(DEBUGMODE) $(WFLAGS) -g
SFLAGS = -DDEBUGMODE=$(DEBUGMODE) $(WFLAGS)
LFLAGS = -g
else
ifdef PROFILEMODE
# -------- profiling build --------
CFLAGS += $(WFLAGS) $(OFLAGS) -pg
SFLAGS = $(WFLAGS)
LFLAGS = -pg
else
# -------- optimised build --------
CFLAGS += $(WFLAGS) $(OFLAGS) -fomit-frame-pointer
SFLAGS = $(WFLAGS)
ifndef SYMBOLMODE
LFLAGS = -s
else
LFLAGS =
endif
endif
endif
CFLAGS += -fno-common -pipe
ifndef STATICLINK
CFLAGS += -dynamic
endif
# -------- list platform specific objects and programs --------
VPATH = src/macosx src/unix src/misc src/c tools/macosx
CFLAGS += -DALLEGRO_NO_ASM
ifdef STATICLINK
ALLEGRO_SRC_MACOSX_FILES += src/macosx/main.m
endif
OBJECT_LIST = $(COMMON_OBJECTS) $(C_OBJECTS) $(basename $(notdir $(ALLEGRO_SRC_MACOSX_FILES)))
STATIC_LIBRARIES = -framework Cocoa -framework Carbon -framework IOKit -framework System -framework CoreAudio -framework AudioUnit -framework AudioToolbox -framework QuickTime
ifdef STATICLINK
LIBRARIES = $(STATIC_LIBRARIES)
else
LIBRARIES = -framework Cocoa
endif
PROGRAMS = fixbundle
fixbundle: tools/macosx/fixbundle
DISTCLEAN_FILES += tools/macosx/fixbundle
# -------- rules for installing and removing the library files --------
DESTDIR =
INSTALLDIR = $(DESTDIR)/usr/local
BINDIR = bin
LIBDIR = lib
INCDIR = include
ifdef STATICLINK
$(INSTALLDIR)/lib/lib$(VERSION)_s.a: $(LIB_NAME)
install -d $(INSTALLDIR)/lib
install $(LIB_NAME) $(INSTALLDIR)/lib
ranlib $(INSTALLDIR)/lib/lib$(VERSION)_s.a
else
$(INSTALLDIR)/lib/lib$(VERSION)-main.a: $(LIB_MAIN_NAME)
install -d $(INSTALLDIR)/lib
install $(LIB_MAIN_NAME) $(INSTALLDIR)/lib
ranlib $(INSTALLDIR)/lib/lib$(VERSION)-main.a
$(INSTALLDIR)/lib/lib$(VERSION)-$(shared_version).dylib: $(LIB_NAME)
install $(LIB_NAME) $(INSTALLDIR)/lib
(cd $(INSTALLDIR)/lib; ln -s -f lib$(VERSION)-$(shared_version).dylib lib$(VERSION)-$(shared_major_minor).dylib)
(cd $(INSTALLDIR)/lib; ln -s -f lib$(VERSION)-$(shared_version).dylib lib$(VERSION)-4.dylib)
(cd $(INSTALLDIR)/lib; ln -s -f lib$(VERSION)-$(shared_version).dylib lib$(VERSION).dylib)
endif
$(INSTALLDIR)/bin/allegro-config: $(LIB_NAME)
install -d $(INSTALLDIR)/bin
ifdef STATICLINK
@sed -e "s/@LINK_WITH_STATIC_LIBS@/yes/" misc/allegro-config.in >temp
else
@sed -e "s/@LINK_WITH_STATIC_LIBS@/no/" misc/allegro-config.in >temp
endif
@sed -e "s#@prefix@#$(INSTALLDIR)#" temp > temp2
@sed -e "s#@INCLUDE_PREFIX@#$(INSTALLDIR)#" temp2 > temp
@sed -e "s#@includedir@#$(INSTALLDIR)/include#" temp > temp2
@sed -e "s#@libdir@#$(INSTALLDIR)/lib#" temp2 > temp
@sed -e "s#@bindir@#$(INSTALLDIR)/bin#" temp > temp2
@sed -e "s/@LIB_TO_LINK@/$(VERSION)/" temp2 > temp
@sed -e "s/@LDFLAGS@//" temp > temp2
@sed -e "s/@LIBS@/$(STATIC_LIBRARIES)/" temp2 > temp
@cat temp > temp2
@sed -e "s/@FRAMEWORKS@/-framework Cocoa -framework $(FRAMEWORK_NAME) -l$(VERSION)-main/" temp2 > temp
@sed -e "s/accepts_frameworks=no/accepts_frameworks=yes/" temp > temp2
@sed -e "s/{lib_type} \$$allegro_libs/{lib_type}_s \$$allegro_libs/" temp2 > temp
@sed -e "s/-l\$${lib_type}_unsharable/-l\$${lib_type}-main $(LIBRARIES)/" temp >$(INSTALLDIR)/bin/allegro-config
@rm -f temp temp2
@chmod a+x $(INSTALLDIR)/bin/allegro-config
@echo allegro-config script created in $(INSTALLDIR)/bin
$(INSTALLDIR)/bin/fixbundle: tools/macosx/fixbundle
@install $< $(INSTALLDIR)/bin/
BUILD_HEADERS = $(INCDIR)/osxalleg.h \
$(INCDIR)/allegro/platform/aintosx.h \
$(INCDIR)/allegro/platform/aintunix.h \
$(INCDIR)/allegro/platform/alosxcfg.h \
$(INCDIR)/allegro/platform/alplatf.h \
$(INCDIR)/allegro/platform/astdint.h \
$(INCDIR)/allegro/platform/alosx.h
HEADERS = $(addprefix $(INSTALLDIR)/,$(BUILD_HEADERS))
ifdef STATICLINK
INSTALL_FILES = $(INSTALLDIR)/$(LIBDIR)/lib$(VERSION)_s.a
else
INSTALL_FILES = $(INSTALLDIR)/$(LIBDIR)/lib$(VERSION)-$(shared_version).dylib
INSTALL_FILES += $(INSTALLDIR)/$(LIBDIR)/lib$(VERSION)-main.a
endif
INSTALL_FILES += $(HEADERS) $(INSTALLDIR)/bin/allegro-config $(INSTALLDIR)/bin/fixbundle
install: generic-install
@echo The $(DESCRIPTION) $(PLATFORM) library has been installed.
@if (printenv PATH |grep -q -v "$(INSTALLDIR)/bin"); then echo "Please check that $(INSTALLDIR)/bin is in your path (see docs/build/macosx.txt)"; fi
@echo Run make install-man if you wish to install the man pages.
@echo Run make install-applehelp if you wish to install the Apple Help Center documentation
@echo Run make install-framework if you wish to install the library as a framework.
@echo Run make install-template if you wish to install the application template.
UNINSTALL_FILES = $(INSTALLDIR)/$(LIBDIR)/liballeg_s.a \
$(INSTALLDIR)/$(LIBDIR)/liballd_s.a \
$(INSTALLDIR)/$(LIBDIR)/liballp_s.a \
$(INSTALLDIR)/$(LIBDIR)/liballeg-$(shared_version).dylib \
$(INSTALLDIR)/$(LIBDIR)/liballd-$(shared_version).dylib \
$(INSTALLDIR)/$(LIBDIR)/liballp-$(shared_version).dylib \
$(INSTALLDIR)/$(LIBDIR)/liballeg-main.a \
$(INSTALLDIR)/$(LIBDIR)/liballd-main.a \
$(INSTALLDIR)/$(LIBDIR)/liballp-main.a \
$(HEADERS) \
$(INSTALLDIR)/bin/allegro-config \
$(INSTALLDIR)/bin/fixbundle
uninstall: generic-uninstall
rm -f $(INSTALLDIR)/$(LIBDIR)/lib$(VERSION)-$(shared_major_minor).dylib
rm -f $(INSTALLDIR)/$(LIBDIR)/lib$(VERSION)-4.dylib
rm -f $(INSTALLDIR)/$(LIBDIR)/lib$(VERSION).dylib
-rm -fr $(FRAMEWORK)
-rm -fr $(TEMPLATE)
-sed -n -e "s,^@[@\\].*@\([a-zA-Z0-9_]*\)[^a-zA-Z0-9_*].*,$(MAN_DIR)/man3/\1.3,p" docs/src/allegro._tx \
| xargs -n 1 rm -f
-sed -n -e "s,^@@Example.*@\(ex.*\),$(MAN_DIR)/man3/\1.3,p" docs/src/allegro._tx \
| xargs -n 1 rm -f
-sed -n -e "s,^@@\(struct\|typedef\).*@\([a-zA-Z0-9_]*\),$(MAN_DIR)/man3/\2.3,p" docs/src/allegro._tx \
| xargs -n 1 rm -f
@test -d $(HELPBUNDLE) && rm -fR $(HELPBUNDLE) || true
@echo All gone!
install-framework: $(FRAMEWORK)
install-applehelp:
install -d $(HELPBUNDLE)
install docs/html/*.html $(HELPBUNDLE)
sed -n -e '1,6p' docs/html/index.html > $(HELPBUNDLE)/index.html
echo "<META NAME=\"AppleTitle\" CONTENT=\"Allegro Help\">" >> $(HELPBUNDLE)/index.html
echo "<META NAME=\"AppleIcon\" CONTENT=\"alex.png\">" >> $(HELPBUNDLE)/index.html
sed -n -e '7,$$p' docs/html/index.html >> $(HELPBUNDLE)/index.html
install misc/alex.png $(HELPBUNDLE)
$(FRAMEWORK): $(LIB_NAME)
ifdef STATICLINK
@echo You need to compile Allegro as a dynamic library to install the framework.
else
@rm -fr $(FRAMEWORK)
@install -d $(FRAMEWORK)
@install -d $(FRAMEWORK)/Versions/$(shared_version)/Headers
@install -d $(FRAMEWORK)/Versions/$(shared_version)/Resources
ifdef EMBED
$(CC) -dynamiclib $(DYLINK_FLAGS) $(INSTALL_NAME_EMBED) $(PFLAGS) -o $(FRAMEWORK)/Versions/$(shared_version)/$(FRAMEWORK_NAME) $(OBJECTS) $(STATIC_LIBRARIES)
else
@install $(LIB_NAME) $(FRAMEWORK)/Versions/$(shared_version)/$(FRAMEWORK_NAME)
endif
@install include/allegro.h $(FRAMEWORK)/Versions/$(shared_version)/Headers
@install include/osxalleg.h $(FRAMEWORK)/Versions/$(shared_version)/Headers
@install $(BUILD_HEADERS) $(FRAMEWORK)/Versions/$(shared_version)/Headers
@(cd $(FRAMEWORK)/Versions; ln -s $(shared_version) Current)
@(cd $(FRAMEWORK); ln -s Versions/Current/Headers $(FRAMEWORK)/Headers)
@(cd $(FRAMEWORK); ln -s Versions/Current/Resources $(FRAMEWORK)/Resources)
@(cd $(FRAMEWORK); ln -s Versions/Current/$(FRAMEWORK_NAME) $(FRAMEWORK)/$(FRAMEWORK_NAME))
@sed -e "s/@NAME@/$(FRAMEWORK_NAME)/" misc/Info.plist >temp
@sed -e "s/@VERSION@/$(shared_version) ($(DESCRIPTION))/" temp >$(FRAMEWORK)/Resources/Info.plist
@rm -f temp
ifdef EMBED
@echo "This is the embeddable version of the Allegro framework" > $(FRAMEWORK)/Resources/Embeddable
endif
@echo The $(FRAMEWORK_DESCRIPTION) Allegro framework has been successfully installed in:
@echo $(FRAMEWORK)
endif
install-template: $(TEMPLATE)
$(TEMPLATE): $(FRAMEWORK)
@rm -fr $(TEMPLATE)
@install -d $(TEMPLATE)/AllegroApp.pbproj
@install misc/template.c $(TEMPLATE)/main.c
@install misc/TemplateInfo.plist $(TEMPLATE)/AllegroApp.pbproj
@install misc/project.pbxproj $(TEMPLATE)/AllegroApp.pbproj
@install misc/project.pbxuser $(TEMPLATE)/AllegroApp.pbproj
@echo Allegro application template for Project Builder \(XCode\) installed in:
@echo $(TEMPLATE)
docs/man/install_allegro.3: docs/src/allegro._tx $(MAKEDOC)
$(MAKEDOC) -man docs/man/dummyname.3 $<
install-man: docs docs/man/install_allegro.3
@install -d $(MAN_DIR)/man3
@echo Installing man files to $(MAN_DIR)/man3
@install docs/man/*.3 $(MAN_DIR)/man3/
# -------- test capabilities --------
TEST_CPP = $(CC) -fno-exceptions -c src/misc/test.cpp -o $(PLATFORM_DIR)/test.o
include makefile.tst
# -------- finally, we get to the fun part... --------
ifdef STATICLINK
# -------- link as a static library --------
define MAKE_LIB
libtool -static -s -o $(LIB_NAME) $(OBJECTS)
endef
else
# -------- link as a shared library --------
define MAKE_LIB
$(CC) -dynamiclib $(DYLINK_FLAGS) $(INSTALL_NAME) $(PFLAGS) -o $(LIB_NAME) $(OBJECTS) $(STATIC_LIBRARIES)
endef
endif # STATICLINK
$(LIB_MAIN_NAME): obj/macosx/$(VERSION)/main.o
ifndef STATICLINK
libtool -static -s -o $(LIB_MAIN_NAME) obj/macosx/$(VERSION)/main.o
endif
COMPILE_FLAGS = $(subst src/,-DALLEGRO_SRC ,$(findstring src/, $<))$(CFLAGS)
$(OBJ_DIR)/%.o: %.c
$(CC) $(COMPILE_FLAGS) -I. -I./include -o $@ -c $<
$(OBJ_DIR)/%.o: %.cpp
$(CC) -fno-exceptions $(COMPILE_FLAGS) -I. -I./include -o $@ -c $<
$(OBJ_DIR)/%.o: %.m
$(CC) $(COMPILE_FLAGS) -I. -I./include -o $@ -c $<
demo/demo: $(OBJECTS_DEMO) $(LIB_NAME) $(LIB_MAIN_NAME)
$(CC) $(LFLAGS) -o $@ $(OBJECTS_DEMO) $(LIB_NAME) $(LIB_MAIN_NAME) $(LIBRARIES)
*/%: $(OBJ_DIR)/%.o $(LIB_NAME) $(LIB_MAIN_NAME)
$(CC) $(LFLAGS) -o $@ $< $(LIB_NAME) $(LIB_MAIN_NAME) $(LIBRARIES)
define LINK_WITHOUT_LIB
$(CC) $(LFLAGS) -o $@ $^
endef
PLUGIN_LIB = lib/macosx/lib$(VERY_SHORT_VERSION)dat.a
PLUGINS_H = obj/macosx/plugins.h
PLUGIN_DEPS = $(LIB_NAME) $(PLUGIN_LIB)
PLUGIN_SCR = scr
define GENERATE_PLUGINS_H
cat tools/plugins/*.inc > obj/macosx/plugins.h
endef
define MAKE_PLUGIN_LIB
libtool -static -s -o $(PLUGIN_LIB) $(PLUGIN_OBJS)
endef
define LINK_WITH_PLUGINS
$(CC) $(LFLAGS) -o $@ $< $(strip $(PLUGIN_LIB) $(addprefix `cat < ,$(addsuffix `,$(PLUGIN_SCRIPTS))) $(LIB_NAME) $(LIB_MAIN_NAME) $(LIBRARIES))
endef
tools/macosx/%: $(OBJ_DIR)/%.o $(LIB_NAME) $(LIB_MAIN_NAME)
ifdef STATICLINK
$(CC) $(LFLAGS) -o $@ $< $(LIB_NAME) $(LIBRARIES)
else
$(CC) $(LFLAGS) -o $@ $< $(LIB_NAME) $(LIB_MAIN_NAME) $(LIBRARIES) -framework Carbon
endif
# -------- demo program iconification --------
.PHONY: fixdemo
fixdemo: demo/demo demo/demo.dat tools/macosx/fixbundle
tools/macosx/fixbundle demo/demo -d demo/demo.dat GAME_PAL SHIP3
# -------- generate automatic dependencies --------
DEPEND_PARAMS = -MM -MG -I. -I./include -DSCAN_DEPEND -DALLEGRO_MACOSX
depend:
$(CC) $(DEPEND_PARAMS) src/*.c src/unix/*.c src/misc/*.c src/c/*.c demo/*.c > _depend.tmp
$(CC) $(DEPEND_PARAMS) docs/src/makedoc/*.c examples/*.c setup/*.c tests/*.c >> _depend.tmp
$(CC) $(DEPEND_PARAMS) tools/*.c tools/plugins/*.c tools/macosx/*.c >> _depend.tmp
$(CC) $(DEPEND_PARAMS) -x c src/macosx/*.m tests/*.cpp >> _depend.tmp
sed -e "s/^[a-zA-Z0-9_\/]*\///" _depend.tmp > _depend2.tmp
sed -e "s/^\([a-zA-Z0-9_]*\.o *:\)/obj\/macosx\/alleg\/\1/" _depend2.tmp > obj/macosx/alleg/makefile.dep
sed -e "s/^\([a-zA-Z0-9_]*\.o *:\)/obj\/macosx\/alld\/\1/" _depend2.tmp > obj/macosx/alld/makefile.dep
sed -e "s/^\([a-zA-Z0-9_]*\.o *:\)/obj\/macosx\/allp\/\1/" _depend2.tmp > obj/macosx/allp/makefile.dep
rm _depend.tmp _depend2.tmp