]> git.saurik.com Git - apple/objc4.git/blob - Makefile
objc4-267.1.tar.gz
[apple/objc4.git] / Makefile
1 # use LDFLAGS not LFLAGS
2 #
3 # Simple makefile for building objc4 on Darwin
4 #
5 # These make variables (or environment variables) are used
6 # when defined:
7 # SRCROOT path location of root of source hierarchy;
8 # defaults to ".", but must be set to a
9 # destination path for installsrc target.
10 # OBJROOT path location where .o files will be put;
11 # defaults to SRCROOT.
12 # SYMROOT path location where build products will be
13 # put; defaults to SRCROOT.
14 # DSTROOT path location where installed products will
15 # be put; defaults to / .
16 # OBJROOT and SYMROOT should not be directories shared with other
17 # built projects.
18 # PLATFORM name of platform being built on
19 # USER name of user building the project
20 # ARCHS list of archs for which to build
21 # RC_ARCHS more archs for which to build (build system)
22 # OTHER_CFLAGS other flags to be passed to compiler
23 # RC_CFLAGS more flags to be passed to compiler (build system)
24 # OTHER_LDFLAGS other flags to be passed to the link stage
25 #
26
27 # Default targets
28 default: build
29 all: build
30
31 .SUFFIXES:
32 .PHONY: default all build optimized debug profile installsrc installhdrs install clean prebuild build-optimized build-debug build-profile prebuild-optimized prebuild-debug prebuild-profile compile-optimized compile-debug compile-profile link-optimized link-debug link-profile postbuild
33
34 CURRENT_PROJECT_VERSION = 227
35
36 VERSION_NAME = A
37
38 # First figure out the platform if not specified, so we can use it in the
39 # rest of this file. Currently defined values: Darwin
40 ifeq "$(PLATFORM)" ""
41 PLATFORM := $(shell uname)
42 endif
43
44 ifndef SRCROOT
45 SRCROOT = .
46 endif
47
48 ifndef OBJROOT
49 OBJROOT = $(SRCROOT)
50 endif
51
52 ifndef SYMROOT
53 SYMROOT = $(SRCROOT)
54 endif
55
56 ifndef DSTROOT
57 DSTROOT = /
58 endif
59
60 ifeq "$(PLATFORM)" "Darwin"
61 CC = /usr/bin/cc
62 else
63 CC = /usr/bin/gcc
64 endif
65
66 ECHO = @/bin/echo
67 MKDIRS = /bin/mkdir -p
68 CD = cd
69 COPY = /bin/cp
70 COPY_RECUR = /bin/cp -r
71 REMOVE = /bin/rm
72 REMOVE_RECUR = /bin/rm -rf
73 SYMLINK = /bin/ln -s
74 CHMOD = /bin/chmod
75 CHOWN = /usr/sbin/chown
76 TAR = /usr/bin/tar
77 STRIP = /usr/bin/strip
78 NMEDIT = /usr/bin/nmedit
79 LIPO = /usr/bin/lipo
80
81 ifeq "$(PLATFORM)" "Darwin"
82 WARNING_FLAGS = -Wmost -Wno-precomp -Wno-four-char-constants
83 endif
84
85 ARCH_LIST=
86 ifeq "$(PLATFORM)" "Darwin"
87
88 ifneq "$(ARCHS)" ""
89 ARCH_LIST += $(ARCHS)
90 else
91 ifneq "$(RC_ARCHS)" ""
92 ARCH_LIST += $(RC_ARCHS)
93 else
94 ARCH_LIST += $(shell /usr/bin/arch)
95 endif
96 endif
97
98 ARCH_FLAGS = $(foreach A, $(ARCH_LIST), $(addprefix -arch , $(A)))
99
100 endif
101
102
103 ifeq "$(ORDERFILE)" ""
104 ORDERFILE = $(wildcard /usr/local/lib/OrderFiles/libobjc.order)
105 endif
106 ifneq "$(ORDERFILE)" ""
107 ORDER = -sectorder __TEXT __text $(ORDERFILE)
108 else
109 ORDER =
110 endif
111
112 ifeq "$(USER)" ""
113 USER = unknown
114 endif
115
116 CFLAGS = -g -fno-common -fobjc-exceptions -pipe $(PLATFORM_CFLAGS) $(WARNING_FLAGS) -I$(SYMROOT) -I. -I$(SYMROOT)/ProjectHeaders
117 LDFLAGS =
118
119 LIBRARY_EXT = .dylib
120
121 PUBLIC_HEADER_INSTALLDIR = usr/include/objc
122 OTHER_HEADER_INSTALLDIR = usr/local/include/objc
123 INSTALLDIR = usr/lib
124
125 ifeq "$(PLATFORM)" "Darwin"
126 LDFLAGS += -dynamiclib -dynamic -compatibility_version 1 -current_version $(CURRENT_PROJECT_VERSION)
127 endif
128
129
130 CFLAGS += $(OTHER_CFLAGS) $(RC_CFLAGS)
131 LDFLAGS += $(OTHER_LDFLAGS)
132
133 ifndef OPTIMIZATION_CFLAGS
134 OPTIMIZATION_CFLAGS = -Os
135 endif
136 ifndef DEBUG_CFLAGS
137 DEBUG_CFLAGS = -DDEBUG
138 endif
139 ifndef PROFILE_CFLAGS
140 PROFILE_CFLAGS = -DPROFILE -pg -Os
141 endif
142
143 CFLAGS_OPTIMIZED = $(OPTIMIZATION_CFLAGS) $(CFLAGS)
144 CFLAGS_DEBUG = $(DEBUG_CFLAGS) $(CFLAGS)
145 CFLAGS_PROFILE = $(PROFILE_CFLAGS) $(CFLAGS)
146
147 LDFLAGS_OPTIMIZED = $(LDFLAGS) -g
148 LDFLAGS_DEBUG = $(LDFLAGS) -g
149 LDFLAGS_PROFILE = $(LDFLAGS) -g -pg
150
151 SUBDIRS = . runtime runtime/OldClasses.subproj runtime/Messengers.subproj runtime/Auto.subproj
152
153 # files to compile
154 SOURCES=
155 # files to compile into separate linker modules
156 MODULE_SOURCES=
157 # files to not compile
158 OTHER_SOURCES=
159 # headers to install in /usr/include/objc
160 PUBLIC_HEADERS=
161 # headers that don't get installed
162 PRIVATE_HEADERS=
163 # headers to install in /usr/local/include/objc
164 OTHER_HEADERS=
165
166 # runtime
167 SOURCES += $(addprefix runtime/, \
168 Object.m Protocol.m hashtable2.m maptable.m objc-class.m objc-errors.m \
169 objc-file.m objc-load.m objc-moninit.c objc-runtime.m objc-sel.m \
170 objc-sync.m objc-exception.m objc-auto.m objc-sel-set.m objc-rtp.m \
171 )
172 PUBLIC_HEADERS += $(addprefix runtime/, \
173 objc-class.h objc-api.h objc-load.h objc-runtime.h objc.h Object.h \
174 objc-sync.h objc-exception.h objc-auto.h \
175 Protocol.h error.h hashtable2.h \
176 )
177 PRIVATE_HEADERS += runtime/objc-private.h runtime/objc-config.h runtime/objc-sel-table.h runtime/objc-sel-set.h runtime/objc-rtp.h
178 OTHER_HEADERS += runtime/maptable.h runtime/objc-auto.h
179
180 # OldClasses
181 SOURCES += runtime/OldClasses.subproj/List.m
182 PUBLIC_HEADERS += runtime/OldClasses.subproj/List.h
183
184 # Messengers
185 SOURCES += runtime/Messengers.subproj/objc-msg.s
186 OTHER_SOURCES += runtime/Messengers.subproj/objc-msg-ppc.s runtime/Messengers.subproj/objc-msg-i386.s
187
188 # Auto support
189 SOURCES += runtime/Auto.subproj/objc-auto.s
190 OTHER_SOURCES += runtime/Auto.subproj/objc-auto-ppc.s runtime/Auto.subproj/objc-auto-i386.s
191
192 # RTP symbols for gdb
193 # See also $(OBJROOT)/runtime/objc-rtp-sym.ppc.o rule below.
194 OTHER_SOURCES += runtime/objc-rtp-sym.s
195
196 # Interposing support.
197 # This code is built into a second module so dyld's function interposing
198 # can manipulate the calls.
199 MODULE_SOURCES += runtime/Messengers.subproj/objc-msg-stub.s
200 OTHER_SOURCES += runtime/Messengers.subproj/objc-msg-stub-ppc.s runtime/Messengers.subproj/objc-msg-stub-i386.s
201
202 # project root
203 OTHER_SOURCES += Makefile APPLE_LICENSE objc-exports-i386 objc-exports-ppc
204
205 OBJECTS = $(addprefix $(OBJROOT)/, $(addsuffix .o, $(basename $(SOURCES) ) ) )
206 OBJECTS_OPTIMIZED = $(OBJECTS:.o=.opt.o)
207 OBJECTS_DEBUG = $(OBJECTS:.o=.debug.o)
208 OBJECTS_PROFILE = $(OBJECTS:.o=.profile.o)
209
210 MODULE_OBJECTS = $(addprefix $(OBJROOT)/, $(addsuffix .o, $(basename $(MODULE_SOURCES) ) ) )
211 MODULE_OBJECTS_OPTIMIZED = $(MODULE_OBJECTS:.o=.opt.o)
212 MODULE_OBJECTS_DEBUG = $(MODULE_OBJECTS:.o=.debug.o)
213 MODULE_OBJECTS_PROFILE = $(MODULE_OBJECTS:.o=.profile.o)
214
215 # For simplicity, each object target depends on all objc headers. Most of
216 # them come close to requiring this anyway, and rebuild from scratch is fast.
217 DEPEND_HEADERS = $(addprefix $(SRCROOT)/, \
218 $(PUBLIC_HEADERS) $(PRIVATE_HEADERS) $(OTHER_HEADERS) )
219
220 $(OBJROOT)/%.opt.o : $(SRCROOT)/%.m $(DEPEND_HEADERS)
221 $(SILENT) $(ECHO) " ... $<"
222 $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
223
224 $(OBJROOT)/%.debug.o : $(SRCROOT)/%.m $(DEPEND_HEADERS)
225 $(SILENT) $(ECHO) " ... $<"
226 $(SILENT) $(CC) $(CFLAGS_DEBUG) "$<" -c -o "$@"
227
228 $(OBJROOT)/%.profile.o : $(SRCROOT)/%.m $(DEPEND_HEADERS)
229 $(SILENT) $(ECHO) " ... $<"
230 $(SILENT) $(CC) $(CFLAGS_PROFILE) "$<" -c -o "$@"
231
232 $(OBJROOT)/%.opt.o : $(SRCROOT)/%.c $(DEPEND_HEADERS)
233 $(SILENT) $(ECHO) " ... $<"
234 $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
235
236 $(OBJROOT)/%.debug.o : $(SRCROOT)/%.c $(DEPEND_HEADERS)
237 $(SILENT) $(ECHO) " ... $<"
238 $(SILENT) $(CC) $(CFLAGS_DEBUG) "$<" -c -o "$@"
239
240 $(OBJROOT)/%.profile.o : $(SRCROOT)/%.c $(DEPEND_HEADERS)
241 $(SILENT) $(ECHO) " ... $<"
242 $(SILENT) $(CC) $(CFLAGS_PROFILE) "$<" -c -o "$@"
243
244 $(OBJROOT)/%.opt.o : $(SRCROOT)/%.s $(DEPEND_HEADERS)
245 $(SILENT) $(ECHO) " ... $<"
246 $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) "$<" -c -o "$@"
247
248 $(OBJROOT)/%.debug.o : $(SRCROOT)/%.s $(DEPEND_HEADERS)
249 $(SILENT) $(ECHO) " ... $<"
250 $(SILENT) $(CC) $(CFLAGS_DEBUG) "$<" -c -o "$@"
251
252 $(OBJROOT)/%.profile.o : $(SRCROOT)/%.s $(DEPEND_HEADERS)
253 $(SILENT) $(ECHO) " ... $<"
254 $(SILENT) $(CC) $(CFLAGS_PROFILE) "$<" -c -o "$@"
255
256 # Additional dependency: objc-msg.s depends on objc-msg-ppc.s and
257 # objc-msg-i386.s, which it includes.
258 $(OBJROOT)/runtime/Messengers.subproj/objc-msg.opt.o \
259 $(OBJROOT)/runtime/Messengers.subproj/objc-msg.debug.o \
260 $(OBJROOT)/runtime/Messengers.subproj/objc-msg.profile.o : \
261 $(SRCROOT)/runtime/Messengers.subproj/objc-msg-ppc.s \
262 $(SRCROOT)/runtime/Messengers.subproj/objc-msg-i386.s
263
264 # Additional dependency: objc-msg-sutb.s depends on objc-msg-stub-ppc.s and
265 # objc-msg-stub-i386.s, which it includes.
266 $(OBJROOT)/runtime/Messengers.subproj/objc-msg-stub.opt.o \
267 $(OBJROOT)/runtime/Messengers.subproj/objc-msg-stub.debug.o \
268 $(OBJROOT)/runtime/Messengers.subproj/objc-msg-stub.profile.o : \
269 $(SRCROOT)/runtime/Messengers.subproj/objc-msg-stub-ppc.s \
270 $(SRCROOT)/runtime/Messengers.subproj/objc-msg-stub-i386.s
271
272 # Additional dependency: objc-auto.s depends on objc-auto-ppc.s and
273 # objc-auto-i386.s, which it includes.
274 $(OBJROOT)/runtime/Auto.subproj/objc-auto.opt.o \
275 $(OBJROOT)/runtime/Auto.subproj/objc-auto.debug.o \
276 $(OBJROOT)/runtime/Auto.subproj/objc-auto.profile.o : \
277 $(SRCROOT)/runtime/Auto.subproj/objc-auto-ppc.s \
278 $(SRCROOT)/runtime/Auto.subproj/objc-auto-i386.s
279
280 # Additional rules: objc-rtp-sym.s needs to be built with a per-arch seg1addr,
281 # and need to be stripped here because stripping the dylib does not remove
282 # debug info from the magic sections.
283 # objc-rtp-sym.s is not in SOURCES, and objc-rtp-sym.o is not in OBJECTS
284 $(OBJROOT)/runtime/objc-rtp-sym.ppc.o: $(SRCROOT)/runtime/objc-rtp-sym.s
285 $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) -arch ppc "$<" -c -o "$@.temp"
286 $(SILENT) $(STRIP) -S "$@.temp"
287 $(SILENT) $(LD) -arch ppc -seg1addr 0xfffec000 "$@.temp" -r -o "$@"
288
289 $(OBJROOT)/runtime/objc-rtp-sym.i386.o: $(SRCROOT)/runtime/objc-rtp-sym.s
290 $(SILENT) $(CC) $(CFLAGS_OPTIMIZED) -arch i386 "$<" -c -o "$@.temp"
291 $(SILENT) $(STRIP) -S "$@.temp"
292 $(SILENT) $(LD) -arch i386 -seg1addr 0xfffe8000 "$@.temp" -r -o "$@"
293
294
295 # These are the main targets:
296 # build builds the library to OBJROOT and SYMROOT
297 # installsrc copies the sources to SRCROOT
298 # installhdrs install only the headers to DSTROOT
299 # install build, then install the headers and library to DSTROOT
300 # clean removes build products in OBJROOT and SYMROOT
301 #
302 # optimized same as 'build' but builds optimized library only
303 # debug same as 'build' but builds debug library only
304 # profile same as 'build' but builds profile library only
305
306 # Default build doesn't currently build the debug library.
307 build: prebuild build-optimized build-profile postbuild
308
309 optimized: prebuild build-optimized postbuild
310 debug: prebuild build-debug postbuild
311 profile: prebuild build-profile postbuild
312
313 installsrc:
314 $(SILENT) $(ECHO) "Installing source from . to $(SRCROOT)..."
315 ifeq "$(SRCROOT)" "."
316 $(SILENT) $(ECHO) "SRCROOT must be defined to be the destination directory; it cannot be '.'"
317 exit 1
318 endif
319 $(SILENT) $(TAR) -cf $(SRCROOT)/objc4.sources.tar $(SOURCES) $(PUBLIC_HEADERS) $(PRIVATE_HEADERS) $(OTHER_HEADERS) $(OTHER_SOURCES) $(MODULE_SOURCES)
320 $(SILENT) $(CD) $(SRCROOT) && $(TAR) -xf $(SRCROOT)/objc4.sources.tar
321 $(SILENT) $(REMOVE) -f $(SRCROOT)/objc4.sources.tar
322
323 installhdrs:
324 $(SILENT) $(ECHO) "Installing headers from $(SRCROOT) to $(DSTROOT)/$(HEADER_INSTALLDIR)..."
325
326 $(SILENT) $(MKDIRS) $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)
327 -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)/*.h
328 $(SILENT) $(COPY) $(addprefix $(SRCROOT)/, $(PUBLIC_HEADERS) ) \
329 $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)
330 # duplicate hashtable2.h to hashtable.h
331 $(SILENT) $(COPY) $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)/hashtable2.h \
332 $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)/hashtable.h
333 $(SILENT) $(CHMOD) -w $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)/*.h
334 $(SILENT) $(CHMOD) a+r $(DSTROOT)/$(PUBLIC_HEADER_INSTALLDIR)/*.h
335
336 $(SILENT) $(MKDIRS) $(DSTROOT)/$(OTHER_HEADER_INSTALLDIR)
337 -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(OTHER_HEADER_INSTALLDIR)/*.h
338 $(SILENT) $(COPY) $(addprefix $(SRCROOT)/, $(OTHER_HEADERS) ) \
339 $(DSTROOT)/$(OTHER_HEADER_INSTALLDIR)
340 $(SILENT) $(CHMOD) -w $(DSTROOT)/$(OTHER_HEADER_INSTALLDIR)/*.h
341 $(SILENT) $(CHMOD) a+r $(DSTROOT)/$(OTHER_HEADER_INSTALLDIR)/*.h
342
343
344 $(SILENT) $(RM) -f $(DSTROOT)$(PUBLIC_HEADER_DIR)$(PUBLIC_HEADER_DIR_SUFFIX)/hashtable.h
345
346
347 install: build installhdrs
348 $(SILENT) $(ECHO) "Installing products from $(SYMROOT) to $(DSTROOT)..."
349
350 $(SILENT) $(MKDIRS) $(DSTROOT)/$(INSTALLDIR)
351 -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(INSTALLDIR)
352
353 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(INSTALLDIR)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT)
354 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(INSTALLDIR)/libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT)
355 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(INSTALLDIR)/libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT)
356
357 # optimized
358 $(SILENT) $(COPY) $(SYMROOT)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT) $(DSTROOT)/$(INSTALLDIR)
359 $(SILENT) $(STRIP) -S $(DSTROOT)/$(INSTALLDIR)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT)
360 -$(SILENT) $(CHOWN) root:wheel $(DSTROOT)/$(INSTALLDIR)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT)
361 $(SILENT) $(CHMOD) 755 $(DSTROOT)/$(INSTALLDIR)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT)
362 $(SILENT) $(CD) $(DSTROOT)/$(INSTALLDIR) && \
363 $(SYMLINK) libobjc.$(VERSION_NAME)$(LIBRARY_EXT) libobjc$(LIBRARY_EXT)
364
365 # debug (allowed not to exist)
366 -$(SILENT) $(COPY) $(SYMROOT)/libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT) $(DSTROOT)/$(INSTALLDIR)
367 -$(SILENT) $(CHOWN) root:wheel $(DSTROOT)/$(INSTALLDIR)/libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT)
368 -$(SILENT) $(CHMOD) 755 $(DSTROOT)/$(INSTALLDIR)/libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT)
369 -$(SILENT) $(CD) $(DSTROOT)/$(INSTALLDIR) && \
370 test -e libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT) && \
371 $(SYMLINK) libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT) libobjc_debug$(LIBRARY_EXT) && \
372 $(SYMLINK) libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT) libobjc.$(VERSION_NAME)_debug$(LIBRARY_EXT)
373
374
375 # profile (allowed not to exist)
376 -$(SILENT) $(COPY) $(SYMROOT)/libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT) $(DSTROOT)/$(INSTALLDIR)
377 -$(SILENT) $(CHOWN) root:wheel $(DSTROOT)/$(INSTALLDIR)/libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT)
378 -$(SILENT) $(CHMOD) 755 $(DSTROOT)/$(INSTALLDIR)/libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT)
379 -$(SILENT) $(CD) $(DSTROOT)/$(INSTALLDIR) && \
380 test -e libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT) && \
381 $(SYMLINK) libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT) libobjc_profile$(LIBRARY_EXT) && \
382 $(SYMLINK) libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT) libobjc.$(VERSION_NAME)_profile$(LIBRARY_EXT)
383
384
385 clean:
386 $(SILENT) $(ECHO) "Deleting build products..."
387 $(SILENT) $(REMOVE) -f \
388 $(foreach A, $(ARCH_LIST), \
389 $(OBJROOT)/libobjc_debug.$A.$(VERSION_NAME)$(LIBRARY_EXT) \
390 $(OBJROOT)/libobjc_profile.$A.$(VERSION_NAME)$(LIBRARY_EXT) \
391 $(OBJROOT)/libobjc.$A.$(VERSION_NAME)$(LIBRARY_EXT) \
392 $(OBJROOT)/runtime/objc-rtp-sym.$A.o \
393 $(OBJROOT)/runtime/objc-rtp-sym.$A.o.temp \
394 )
395
396 $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc.optimized.o
397 $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc.debug.o
398 $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc.profile.o
399
400 $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc.$(VERSION_NAME)$(LIBRARY_EXT)
401 $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc_debug.$(VERSION_NAME)$(LIBRARY_EXT)
402 $(SILENT) $(REMOVE) -f $(SYMROOT)/libobjc_profile.$(VERSION_NAME)$(LIBRARY_EXT)
403
404 $(SILENT) $(REMOVE) -f $(OBJECTS_OPTIMIZED)
405 $(SILENT) $(REMOVE) -f $(OBJECTS_DEBUG)
406 $(SILENT) $(REMOVE) -f $(OBJECTS_PROFILE)
407
408 $(SILENT) $(REMOVE) -f $(MODULE_OBJECTS_OPTIMIZED)
409 $(SILENT) $(REMOVE) -f $(MODULE_OBJECTS_DEBUG)
410 $(SILENT) $(REMOVE) -f $(MODULE_OBJECTS_PROFILE)
411
412 $(SILENT) $(REMOVE) -rf $(SYMROOT)/ProjectHeaders
413
414 prebuild:
415 $(SILENT) $(ECHO) "Prebuild-setup..."
416
417 # Install headers into $(SYMROOT)/ProjectHeaders so #includes can find them
418 # even if they're not installed in /usr.
419 $(SILENT) $(MKDIRS) $(SYMROOT)
420 $(SILENT) $(REMOVE_RECUR) $(SYMROOT)/ProjectHeaders
421 $(SILENT) $(MKDIRS) $(SYMROOT)/ProjectHeaders
422 $(SILENT) $(ECHO) "Copying headers from $(SRCROOT) to $(SYMROOT)/ProjectHeaders..."
423 $(SILENT) $(COPY) $(addprefix $(SRCROOT)/, $(PRIVATE_HEADERS) ) $(SYMROOT)/ProjectHeaders
424 $(SILENT) $(MKDIRS) $(SYMROOT)/ProjectHeaders/objc
425 $(SILENT) $(COPY) $(addprefix $(SRCROOT)/, $(PUBLIC_HEADERS) ) $(SYMROOT)/ProjectHeaders/objc
426 $(SILENT) $(COPY) $(addprefix $(SRCROOT)/, $(OTHER_HEADERS) ) $(SYMROOT)/ProjectHeaders/objc
427
428
429
430 build-optimized: prebuild-optimized compile-optimized link-optimized
431 build-debug: prebuild-debug compile-debug link-debug
432 build-profile: prebuild-profile compile-profile link-profile
433
434
435 prebuild-optimized:
436 $(SILENT) $(ECHO) "Building (optimized) ..."
437 $(SILENT) $(MKDIRS) $(foreach S, $(SUBDIRS), $(OBJROOT)/$(S) )
438
439 prebuild-debug:
440 $(SILENT) $(ECHO) "Building (debug) ..."
441 $(SILENT) $(MKDIRS) $(foreach S, $(SUBDIRS), $(OBJROOT)/$(S) )
442
443 prebuild-profile:
444 $(SILENT) $(ECHO) "Building (profile) ..."
445 $(SILENT) $(MKDIRS) $(foreach S, $(SUBDIRS), $(OBJROOT)/$(S) )
446
447
448 compile-optimized: $(OBJECTS_OPTIMIZED) $(MODULE_OBJECTS_OPTIMIZED) $(foreach A, $(ARCH_LIST), $(OBJROOT)/runtime/objc-rtp-sym.$A.o )
449 compile-debug: $(OBJECTS_DEBUG) $(MODULE_OBJECTS_DEBUG) $(foreach A, $(ARCH_LIST), $(OBJROOT)/runtime/objc-rtp-sym.$A.o )
450 compile-profile: $(OBJECTS_PROFILE) $(MODULE_OBJECTS_PROFILE) $(foreach A, $(ARCH_LIST), $(OBJROOT)/runtime/objc-rtp-sym.$A.o )
451
452
453 # link lib-suffix, LDFLAGS, OBJECTS, MODULE_OBJECTS
454 # libsuffix should be "" or _debug or _profile
455 ifeq "$(PLATFORM)" "Darwin"
456
457 define link
458 $(foreach A, $(ARCH_LIST), \
459 $(SILENT) $(LD) -r \
460 -arch $A \
461 -o $(OBJROOT)/libobjc$1.$A.o \
462 $3 ; \
463 $(SILENT) $(CC) $2 \
464 -arch $A \
465 -Wl,-exported_symbols_list,$(SRCROOT)/objc-exports-$(A) \
466 $(ORDER) \
467 -sectcreate __DATA __commpage $(OBJROOT)/runtime/objc-rtp-sym.$A.o \
468 -install_name /$(INSTALLDIR)/libobjc$1.$(VERSION_NAME)$(LIBRARY_EXT) \
469 -o $(OBJROOT)/libobjc$1.$A.$(VERSION_NAME)$(LIBRARY_EXT) \
470 $(OBJROOT)/libobjc$1.$A.o $4 ; \
471 )
472 $(SILENT) $(LIPO) \
473 -create -output $(SYMROOT)/libobjc$1.$(VERSION_NAME)$(LIBRARY_EXT) \
474 $(foreach A, $(ARCH_LIST), -arch $A $(OBJROOT)/libobjc$1.$A.$(VERSION_NAME)$(LIBRARY_EXT) )
475 endef
476
477 else
478 # PLATFORM != Darwin
479 define link
480 $(SILENT) $(ECHO) "Don't know how to link for platform '$(PLATFORM)'"
481 endef
482
483 endif
484
485
486 link-optimized:
487 $(SILENT) $(ECHO) "Linking (optimized)..."
488 $(call link,,$(LDFLAGS_OPTIMIZED),$(OBJECTS_OPTIMIZED),$(MODULE_OBJECTS_OPTIMIZED) )
489
490 link-debug:
491 $(SILENT) $(ECHO) "Linking (debug)..."
492 $(call link,_debug,$(LDFLAGS_DEBUG),$(OBJECTS_DEBUG),$(MODULE_OBJECTS_DEBUG) )
493
494 link-profile:
495 $(SILENT) $(ECHO) "Linking (profile)..."
496 $(call link,_profile,$(LDFLAGS_PROFILE),$(OBJECTS_PROFILE),$(MODULE_OBJECTS_PROFILE) )
497
498
499 postbuild:
500 $(SILENT) $(ECHO) "Done!"
501
502