1 # Simple makefile for building a framework or library on platforms other than OS X.
2 # the open source subset used in Darwin.
4 # These make variables (or environment variables) are used
6 # SRCROOT path location of root of source hierarchy;
7 # defaults to ".", but must be set to a
8 # destination path for installsrc target.
9 # OBJROOT path location where .o files will be put;
10 # defaults to "/tmp/CoreFoundation.obj".
11 # SYMROOT path location where build products will be
12 # put; defaults to "/tmp/CoreFoundation.sym".
13 # DSTROOT path location where installed products will
14 # be put; defaults to "/tmp/CoreFoundation.dst".
16 # Interesting variables to be set by the including Makefile:
17 # NAME base name of the framework or library
19 # CPP_FILES .cpp to build
20 # PUBLIC_HFILES .h files that will be installed for clients of API
21 # PRIVATE_HFILES .h files that will be installed for clients of SPI
22 # PROJECT_HFILES the rest of the .h files in the project
23 # PUBLIC_IFILES .i with API
24 # PRIVATE_IFILES .i files with SPI
25 # IFILES_DIR directory holding all the .i files
26 # MASTER_INTERFACE_DIR location of .i files we depend on
28 # We now follow the model of modern PB builds, which allow SYMROOT and OBJROOT to be shared
29 # across projects during development. This provides the benefit that one set of build flags
30 # (-F on Mach, -I and -L on Unix or Cygwin) can be used to share build products across projects.
31 # For release builds, the directories are always separate per project.
33 # PLATFORM name of platform being built on
34 # USER name of user building the project
35 # ARCHS list of archs for which to build
36 # RC_ARCHS more archs for which to build (build system)
37 # OTHER_CFLAGS other flags to be passed to compiler
38 # RC_CFLAGS more flags to be passed to compiler (build system)
39 # OTHER_LFLAGS other flags to be passed to the link stage
41 # (Note: lame "#*/" tacked onto some lines is to get PB to stop syntax coloring the entire rest of the file as a comment.)
43 # First figure out the platform if not specified, so we can use it in the
44 # rest of this file. Currently defined values: Darwin, Linux, FreeBSD, variants of CYGWIN
46 PLATFORM := $(shell uname)
49 ifeq "$(PLATFORM)" "Darwin"
50 # Darwin platforms always define __MACH__
52 ifneq "" "$(findstring CYGWIN, $(PLATFORM))"
53 # The windows platforms all define one cpp symbol or another, which CFBase.h funnels to __WIN32__.
54 # Simplify later checks, since we don't care about different versions of CYGWIN.
57 ifeq "$(PLATFORM)" "Linux"
58 PLATFORM_CFLAGS = -D__LINUX__=1
60 ifeq "$(PLATFORM)" "FreeBSD"
61 PLATFORM_CFLAGS = -D__FREEBSD__=1
63 $(error Platform could not be identified. Neither $$PLATFORM was set, nor the result of uname was recognized)
70 # Set up basic variables, commands we use
78 OBJROOT = /tmp/$(NAME).obj
82 SYMROOT = /tmp/$(NAME).sym
86 DSTROOT = /tmp/$(NAME).dst
90 ifeq "$(PLATFORM)" "CYGWIN"
106 INTERFACER = Interfacer
108 ifeq "$(PLATFORM)" "Darwin"
113 CPLUSPLUS = /usr/bin/g++
115 MKDIRS = /bin/mkdir -p
117 COPY_RECUR = /bin/cp -r
119 REMOVE_RECUR = /bin/rm -rf
120 SYMLINK = /bin/ln -sfh
122 CHOWN = /usr/sbin/chown
124 TOUCH = /usr/bin/touch
125 STRIP = /usr/bin/strip
126 INTERFACER = /AppleInternal/Developer/Tools/Interfacer
133 ifeq "$(PLATFORM)" "Darwin"
134 C_WARNING_FLAGS += -Wno-four-char-constants -Wall
135 CPP_WARNING_FLAGS += -Wno-four-char-constants -Wall
138 ifeq "$(PLATFORM)" "CYGWIN"
139 C_WARNING_FLAGS += -Wall
140 CPP_WARNING_FLAGS += -Wall
143 ifeq "$(PLATFORM)" "Darwin"
145 ARCH_FLAGS = $(foreach A, $(ARCHS), $(addprefix -arch , $(A)))
147 ifneq "$(RC_ARCHS)" ""
148 ARCH_FLAGS = $(foreach A, $(RC_ARCHS), $(addprefix -arch , $(A)))
150 ARCH_FLAGS = -arch ppc
155 ifeq "$(PLATFORM)" "FreeBSD"
156 ARCH_FLAGS = -march=i386
159 ifeq "$(PLATFORM)" "Linux"
167 CFLAGS = -fno-common -pipe $(PLATFORM_CFLAGS) $(C_WARNING_FLAGS) -I.
168 CPPFLAGS = -fno-common -pipe $(PLATFORM_CFLAGS) $(CPP_WARNING_FLAGS) -I.
170 ifeq "$(PLATFORM)" "Darwin"
171 CFLAGS += $(ARCH_FLAGS) -F$(SYMROOT) -fconstant-cfstrings
172 CPPFLAGS += $(ARCH_FLAGS) -F$(SYMROOT) -fconstant-cfstrings
175 ifeq "$(PLATFORM)" "CYGWIN"
176 # -mno-cygwin can be left out to build using the CYGWIN unix emulation libs
177 CFLAGS += -mno-cygwin
178 CPPFLAGS += -mno-cygwin
184 # Set style of building the library/framework, and the linker flags
187 ifeq "$(wildcard /System/Library/Frameworks)" ""
188 LIBRARY_STYLE = Library
190 RELEASE_LIB = lib$(NAME)$(LIBRARY_EXT)
191 DEBUG_LIB = lib$(NAME)_debug$(LIBRARY_EXT)
192 PROFILE_LIB = lib$(NAME)_profile$(LIBRARY_EXT)
193 ifeq "$(PLATFORM)" "Linux"
196 INSTALLDIR = /usr/local/lib
197 ifeq "$(PLATFORM)" "CYGWIN"
199 RELEASE_LIB = $(NAME)$(LIBRARY_EXT)
200 DEBUG_LIB = $(NAME)_debug$(LIBRARY_EXT)
201 PROFILE_LIB = $(NAME)_profile$(LIBRARY_EXT)
202 RELEASE_IMPLIB = lib$(RELEASE_LIB:.dll=.a)
203 DEBUG_IMPLIB = lib$(DEBUG_LIB:.dll=.a)
204 PROFILE_IMPLIB = lib$(PROFILE_LIB:.dll=.a)
205 INSTALLDIR = /usr/local/bin
206 LIB_INSTALLDIR = /usr/local/lib
208 HEADER_INSTALLDIR = /usr/local/include/$(NAME)
209 INSTALLDIR = /usr/local/lib
210 MASTER_INTERFACE_DIR = $(SYMROOT)/interfaces
211 # Next four dirs are used at build time, but not install time
212 PUBLIC_HEADER_DIR = $(SYMROOT)/Headers/$(NAME)
213 PRIVATE_HEADER_DIR = $(SYMROOT)/PrivateHeaders/$(NAME)
214 PROJECT_HEADER_DIR = $(OBJROOT)/$(NAME).build/ProjectHeaders/$(NAME)
215 RESOURCE_DIR = $(SYMROOT)
217 LIBRARY_STYLE = Framework
218 RELEASE_LIB = $(NAME)
219 DEBUG_LIB = $(NAME)_debug
220 PROFILE_LIB = $(NAME)_profile
221 INSTALLDIR = /System/Library/Frameworks
222 FRAMEWORK_DIR = /System/Library/Frameworks/$(NAME).framework
223 MASTER_INTERFACE_DIR = /AppleInternal/Carbon/interfaces
224 # Next three dirs are used at build time, but not install time
225 PUBLIC_HEADER_DIR = $(SYMROOT)/$(NAME).framework/Versions/A/Headers
226 PRIVATE_HEADER_DIR = $(SYMROOT)/$(NAME).framework/Versions/A/PrivateHeaders
227 PROJECT_HEADER_DIR = $(OBJROOT)/$(NAME).build/ProjectHeaders
230 ifeq "$(PLATFORM)" "Darwin"
231 LFLAGS = $(ARCH_FLAGS) -dynamiclib -dynamic
234 ifeq "$(PLATFORM)" "FreeBSD"
238 ifeq "$(PLATFORM)" "CYGWIN"
239 # -mno-cygwin can be left out to build using the CYGWIN unix emulation libs
240 LFLAGS = -mno-cygwin -L$(SYMROOT)
243 # other flags passed in from the make command line, and RC
244 CFLAGS += $(OTHER_CFLAGS) $(RC_CFLAGS)
245 CPPFLAGS += $(OTHER_CPPFLAGS) $(RC_CFLAGS)
246 LFLAGS += $(OTHER_LFLAGS)
249 # Needed to find Project Headers, which work in PB because of the fancy -header-mapfile feature.
250 CFLAGS += -I$(PROJECT_HEADER_DIR)
251 CPPFLAGS += -I$(PROJECT_HEADER_DIR)
252 # Needed for cases when a private header is included as "Foo.h" instead of <CF/Foo.h>
253 CFLAGS += -I$(PRIVATE_HEADER_DIR)
254 CPPFLAGS += -I$(PRIVATE_HEADER_DIR)
255 ifeq "$(LIBRARY_STYLE)" "Library"
256 # Needed for headers included as <CF/Foo.h>, since there is no -FframeworkDir mechanism at work
257 CFLAGS += -I$(PUBLIC_HEADER_DIR)/.. -I$(PRIVATE_HEADER_DIR)/..
258 CPPFLAGS += -I$(PUBLIC_HEADER_DIR)/.. -I$(PRIVATE_HEADER_DIR)/..
262 .PHONY: build all prebuild release debug profile debug-build release-build profile-build build-realwork test
265 build: prebuild debug-build release-build profile-build
266 release: prebuild release-build
267 debug: prebuild debug-build
268 profile: prebuild profile-build
270 # These are the main targets:
271 # build builds the library to OBJROOT and SYMROOT
272 # installsrc copies the sources to SRCROOT
273 # installhdrs install only the headers to DSTROOT
274 # install build, then install the headers and library to DSTROOT
275 # clean removes build products in OBJROOT and SYMROOT
276 # test invoke items in Tests subdirectory
278 #--------------------------------------------------------------------------------
280 #--------------------------------------------------------------------------------
283 $(SILENT) $(ECHO) "Installing source..."
284 ifeq "$(SRCROOT)" "."
285 $(SILENT) $(ECHO) "SRCROOT must be defined to be the destination directory; it cannot be '.'"
288 $(SILENT) $(MKDIRS) $(SRCROOT)
289 $(SILENT) $(MKDIRS) $(foreach S, $(SUBPROJECTS), $(SRCROOT)/$(S).subproj)
290 -$(SILENT) $(foreach S, $(SUBPROJECTS), $(COPY) $(foreach F, $($(S)_SOURCES), $(S).subproj/$(F)) $(SRCROOT)/$(S).subproj;)
291 -$(SILENT) $(foreach S, $(SUBPROJECTS), $(COPY) $(foreach F, $($(S)_PROJHEADERS), $(S).subproj/$(F)) $(SRCROOT)/$(S).subproj;)
292 -$(SILENT) $(foreach S, $(SUBPROJECTS), $(COPY) $(foreach F, $($(S)_PRIVHEADERS), $(S).subproj/$(F)) $(SRCROOT)/$(S).subproj;)
293 -$(SILENT) $(foreach S, $(SUBPROJECTS), $(COPY) $(foreach F, $($(S)_PUBHEADERS), $(S).subproj/$(F)) $(SRCROOT)/$(S).subproj;)
294 $(SILENT) $(COPY) $(OTHER_SOURCES) $(SRCROOT)
295 $(SILENT) $(COPY_RECUR) CharacterSets $(SRCROOT)
296 $(SILENT) $(REMOVE_RECUR) $(SRCROOT)/CharacterSets/CVS
299 $(SILENT) $(ECHO) "Installing headers..."
300 ifeq "$(LIBRARY_STYLE)" "Framework"
301 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(FRAMEWORK_DIR)/Headers
302 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(FRAMEWORK_DIR)/PrivateHeaders
303 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/Current
304 $(SILENT) $(MKDIRS) $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/Headers
305 $(SILENT) $(MKDIRS) $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/PrivateHeaders
306 $(SILENT) $(SYMLINK) A $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/Current
307 $(SILENT) $(SYMLINK) Versions/Current/Headers $(DSTROOT)/$(FRAMEWORK_DIR)/Headers
308 $(SILENT) $(SYMLINK) Versions/Current/PrivateHeaders $(DSTROOT)/$(FRAMEWORK_DIR)/PrivateHeaders
309 -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/Headers/*.h #*/
310 -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/PrivateHeaders/*.h #*/
311 $(SILENT) $(COPY) $(PUBLIC_HFILES) $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/Headers
312 # Install two private headers for internal Apple projects' use
313 $(SILENT) $(COPY) Base.subproj/CFPriv.h Base.subproj/CFRuntime.h PlugIn.subproj/CFBundlePriv.h $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/PrivateHeaders
314 $(SILENT) $(CHOWN) -R root:wheel $(DSTROOT)/$(FRAMEWORK_DIR)
315 -$(SILENT) $(CHMOD) -w $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/Headers/*.h #*/
316 -$(SILENT) $(CHMOD) -w $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/PrivateHeaders/*.h #*/
318 ifeq "$(LIBRARY_STYLE)" "Library"
319 $(SILENT) $(MKDIRS) $(DSTROOT)/$(HEADER_INSTALLDIR)
320 -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(HEADER_INSTALLDIR)/*.h #*/
321 $(SILENT) $(COPY) $(PUBLIC_HFILES) $(DSTROOT)/$(HEADER_INSTALLDIR)
322 $(SILENT) $(CHMOD) -w $(DSTROOT)/$(HEADER_INSTALLDIR)/*.h #*/
325 install: build install_before install_builtin install_after
330 $(SILENT) $(ECHO) "Installing..."
331 ifeq "$(LIBRARY_STYLE)" "Framework"
332 $(SILENT) $(REMOVE_RECUR) $(DSTROOT)/$(FRAMEWORK_DIR)
333 $(SILENT) $(MKDIRS) $(DSTROOT)/$(FRAMEWORK_DIR)
334 -$(SILENT) $(CHMOD) -R +w $(DSTROOT)/$(FRAMEWORK_DIR)
335 $(SILENT) (cd $(SYMROOT) && $(TAR) -cf - $(NAME).framework) | (cd $(DSTROOT)/$(INSTALLDIR) && $(TAR) -xf -)
336 $(SILENT) $(STRIP) -S $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/$(RELEASE_LIB)
337 $(SILENT) $(STRIP) -S $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/$(DEBUG_LIB)
338 $(SILENT) $(STRIP) -S $(DSTROOT)/$(FRAMEWORK_DIR)/Versions/A/$(PROFILE_LIB)
339 $(SILENT) $(CHMOD) -R ugo-w $(DSTROOT)/$(FRAMEWORK_DIR)
340 $(SILENT) $(CHMOD) -R o+rX $(DSTROOT)/$(FRAMEWORK_DIR)
341 $(SILENT) $(CHOWN) -R root:wheel $(DSTROOT)/$(FRAMEWORK_DIR)
343 ifeq "$(LIBRARY_STYLE)" "Library"
344 $(SILENT) $(MKDIRS) $(DSTROOT)/$(INSTALLDIR)
345 -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(INSTALLDIR)
346 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(INSTALLDIR)/$(RELEASE_LIB)
347 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(INSTALLDIR)/$(DEBUG_LIB)
348 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(INSTALLDIR)/$(PROFILE_LIB)
349 $(SILENT) $(COPY) $(SYMROOT)/$(RELEASE_LIB) $(DSTROOT)/$(INSTALLDIR)/$(RELEASE_LIB)
350 $(SILENT) $(COPY) $(SYMROOT)/$(DEBUG_LIB) $(DSTROOT)/$(INSTALLDIR)/$(DEBUG_LIB)
351 $(SILENT) $(COPY) $(SYMROOT)/$(PROFILE_LIB) $(DSTROOT)/$(INSTALLDIR)/$(PROFILE_LIB)
352 ifneq "$(PLATFORM)" "CYGWIN"
353 -$(SILENT) $(CHOWN) root:wheel $(DSTROOT)/$(INSTALLDIR)/$(RELEASE_LIB)
354 -$(SILENT) $(CHOWN) root:wheel $(DSTROOT)/$(INSTALLDIR)/$(DEBUG_LIB)
355 -$(SILENT) $(CHOWN) root:wheel $(DSTROOT)/$(INSTALLDIR)/$(PROFILE_LIB)
357 $(SILENT) $(CHMOD) 755 $(DSTROOT)/$(INSTALLDIR)/$(RELEASE_LIB)
358 $(SILENT) $(CHMOD) 755 $(DSTROOT)/$(INSTALLDIR)/$(DEBUG_LIB)
359 $(SILENT) $(CHMOD) 755 $(DSTROOT)/$(INSTALLDIR)/$(PROFILE_LIB)
360 ifeq "$(PLATFORM)" "CYGWIN"
361 $(SILENT) $(MKDIRS) $(DSTROOT)/$(LIB_INSTALLDIR)
362 -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(LIB_INSTALLDIR)
363 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(LIB_INSTALLDIR)/$(RELEASE_IMPLIB)
364 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(LIB_INSTALLDIR)/$(DEBUG_IMPLIB)
365 $(SILENT) $(REMOVE) -f $(DSTROOT)/$(LIB_INSTALLDIR)/$(PROFILE_IMPLIB)
366 $(SILENT) $(COPY) $(SYMROOT)/$(RELEASE_IMPLIB) $(DSTROOT)/$(LIB_INSTALLDIR)/$(RELEASE_IMPLIB)
367 $(SILENT) $(COPY) $(SYMROOT)/$(DEBUG_IMPLIB) $(DSTROOT)/$(LIB_INSTALLDIR)/$(DEBUG_IMPLIB)
368 $(SILENT) $(COPY) $(SYMROOT)/$(PROFILE_IMPLIB) $(DSTROOT)/$(LIB_INSTALLDIR)/$(PROFILE_IMPLIB)
369 $(SILENT) $(CHMOD) 755 $(DSTROOT)/$(LIB_INSTALLDIR)/$(RELEASE_IMPLIB)
370 $(SILENT) $(CHMOD) 755 $(DSTROOT)/$(LIB_INSTALLDIR)/$(DEBUG_IMPLIB)
371 $(SILENT) $(CHMOD) 755 $(DSTROOT)/$(LIB_INSTALLDIR)/$(PROFILE_IMPLIB)
373 $(SILENT) $(MKDIRS) $(DSTROOT)/$(HEADER_INSTALLDIR)
374 -$(SILENT) $(CHMOD) +w $(DSTROOT)/$(HEADER_INSTALLDIR)/*.h #*/
375 $(SILENT) $(COPY) $(PUBLIC_HFILES) $(DSTROOT)/$(HEADER_INSTALLDIR)
376 -$(SILENT) $(CHMOD) -w $(DSTROOT)/$(HEADER_INSTALLDIR)/*.h #*/
379 #--------------------------------------------------------------------------------
381 #--------------------------------------------------------------------------------
383 clean: clean_before clean_builtin clean_after
388 $(SILENT) $(ECHO) "Deleting build products..."
389 $(REMOVE_RECUR) $(OBJROOT)/$(NAME).build
390 ifeq "$(LIBRARY_STYLE)" "Framework"
391 $(REMOVE_RECUR) $(SYMROOT)/$(NAME).framework
393 ifeq "$(LIBRARY_STYLE)" "Library"
394 $(REMOVE) -f $(SYMROOT)/$(RELEASE_LIB)
395 $(REMOVE) -f $(SYMROOT)/$(DEBUG_LIB)
396 $(REMOVE) -f $(SYMROOT)/$(PROFILE_LIB)
397 $(REMOVE_RECUR) -f $(PUBLIC_HEADER_DIR) $(PRIVATE_HEADER_DIR)
398 ifeq "$(PLATFORM)" "CYGWIN"
399 $(REMOVE) -f $(SYMROOT)/$(RELEASE_IMPLIB)
400 $(REMOVE) -f $(SYMROOT)/$(DEBUG_IMPLIB)
401 $(REMOVE) -f $(SYMROOT)/$(PROFILE_IMPLIB)
402 $(REMOVE) -f $(SYMROOT)/$(RELEASE_LIB:.dll=.lib)
403 $(REMOVE) -f $(SYMROOT)/$(DEBUG_LIB:.dll=.lib)
404 $(REMOVE) -f $(SYMROOT)/$(PROFILE_LIB:.dll=.lib)
405 $(REMOVE) -f $(SYMROOT)/$(RELEASE_LIB:.dll=.defs)
406 $(REMOVE) -f $(SYMROOT)/$(DEBUG_LIB:.dll=.defs)
407 $(REMOVE) -f $(SYMROOT)/$(PROFILE_LIB:.dll=.exp)
408 $(REMOVE) -f $(SYMROOT)/$(RELEASE_LIB:.dll=.exp)
409 $(REMOVE) -f $(SYMROOT)/$(DEBUG_LIB:.dll=.exp)
410 $(REMOVE) -f $(SYMROOT)/$(PROFILE_LIB:.dll=.defs)
414 #--------------------------------------------------------------------------------
416 #--------------------------------------------------------------------------------
418 prebuild: prebuild_before prebuild_setup prebuild_headers prebuild_after
422 # build the framework, or other basic dir structure
424 $(SILENT) $(ECHO) "Prebuild-setup..."
425 $(SILENT) $(MKDIRS) $(SYMROOT)
426 ifeq "$(LIBRARY_STYLE)" "Framework"
428 $(SILENT) $(MKDIRS) $(SYMROOT)/$(NAME).framework/Versions/A/Resources
429 $(SILENT) $(SYMLINK) A $(SYMROOT)/$(NAME).framework/Versions/Current
430 $(SILENT) $(SYMLINK) Versions/Current/Headers $(SYMROOT)/$(NAME).framework/Headers
431 $(SILENT) $(SYMLINK) Versions/Current/PrivateHeaders $(SYMROOT)/$(NAME).framework/PrivateHeaders
432 $(SILENT) $(SYMLINK) Versions/Current/Resources $(SYMROOT)/$(NAME).framework/Resources
435 ifeq "$(LIBRARY_STYLE)" "Framework"
436 PLATFORM_IFLAGS = -framework $(NAME) -frameworkInterfaces $(IFILES_DIR)
437 ALL_IFILES = $(foreach F,$(PUBLIC_IFILES) $(PRIVATE_IFILES),$(IFILES_DIR)/$(F))
439 # Since they share output directories, if either the ifiles or hfiles change we must redo both
440 prebuild_headers: $(OBJROOT)/$(NAME).build/Headers.touch
441 $(OBJROOT)/$(NAME).build/Headers.touch: $(PUBLIC_HFILES) $(PRIVATE_HFILES) $(PROJECT_HFILES) $(ALL_IFILES)
442 $(SILENT) $(REMOVE_RECUR) $(PUBLIC_HEADER_DIR)
443 $(SILENT) $(REMOVE_RECUR) $(PRIVATE_HEADER_DIR)
444 $(SILENT) $(REMOVE_RECUR) $(PROJECT_HEADER_DIR)
445 $(SILENT) $(MKDIRS) $(PUBLIC_HEADER_DIR)
446 $(SILENT) $(MKDIRS) $(PRIVATE_HEADER_DIR)
447 $(SILENT) $(MKDIRS) $(PROJECT_HEADER_DIR)
448 $(SILENT) $(MAKE) prebuild_copy_headers
449 ifneq "$(ALL_IFILES)" ""
450 $(SILENT) $(MAKE) prebuild_gen_headers
452 $(SILENT) $(TOUCH) $(OBJROOT)/$(NAME).build/Headers.touch
455 ALL_IFILES = $(foreach F,$(PUBLIC_IFILES) $(PRIVATE_IFILES),$(IFILES_DIR)/$(F))
457 # Since they share output directories, if either the ifiles or hfiles change we must redo both
458 prebuild_headers: $(OBJROOT)/$(NAME).build/Headers.touch
459 $(OBJROOT)/$(NAME).build/Headers.touch: $(PUBLIC_HFILES) $(PRIVATE_HFILES) $(PROJECT_HFILES) $(ALL_IFILES)
460 $(SILENT) $(REMOVE_RECUR) $(PUBLIC_HEADER_DIR)
461 $(SILENT) $(REMOVE_RECUR) $(PRIVATE_HEADER_DIR)
462 $(SILENT) $(REMOVE_RECUR) $(PROJECT_HEADER_DIR)
463 $(SILENT) $(MKDIRS) $(PUBLIC_HEADER_DIR)
464 $(SILENT) $(MKDIRS) $(PRIVATE_HEADER_DIR)
465 $(SILENT) $(MKDIRS) $(PROJECT_HEADER_DIR)
466 $(SILENT) $(MAKE) prebuild_copy_headers
467 ifneq "$(ALL_IFILES)" ""
468 $(SILENT) $(MAKE) prebuild_gen_headers
470 $(SILENT) $(TOUCH) $(OBJROOT)/$(NAME).build/Headers.touch
472 # First try was not using -framework, so we get EXTERN_API to leverage for __declspec trickery.
473 # But that didn't help us for externed data, and the imports changed to omit the framework name.
474 # As best I can tell, when not using -framework you need to cd into the IFILES_DIR for the
475 # inter-file references to work.
476 # -update and -deepUpdate don't seem to work on WIN32, so just use a touch file
477 #ALL_IFILES = $(PUBLIC_IFILES) $(PRIVATE_IFILES)
478 #PLATFORM_IFLAGS = $(foreach F, $(ALL_IFILES), `cygpath -w $(F)`)
479 PLATFORM_IFLAGS = -framework $(NAME) -frameworkInterfaces `cygpath -w $(IFILES_DIR)/`
481 prebuild_gen_headers:
482 $(SILENT) $(ECHO) "Processing interface files..."
483 $(SILENT) $(INTERFACER) $(PLATFORM_IFLAGS) -c -rez -update \
484 -masterInterfaces `cygpath -w $(MASTER_INTERFACE_DIR)/` \
485 -cacheFolder `cygpath -w $(OBJROOT)/$(NAME).build/InterfacerCache/` \
486 -generated c=`cygpath -w $(PUBLIC_HEADER_DIR)/` \
487 -generatedPriv c=`cygpath -w $(PRIVATE_HEADER_DIR)/` \
488 -generated rez=`cygpath -w $(PUBLIC_HEADER_DIR)/` \
489 -generatedPriv rez=`cygpath -w $(PRIVATE_HEADER_DIR)/`
490 ifeq "$(PLATFORM)" "CYGWIN"
491 # Replace externs with a symbol we can use for declspec purposes, except not extern "C"
492 # Get rid of non-standard pragma
493 $(SILENT) perl -p -i \
494 -e 's/^extern ([^"].[^"])/$(NAME)_EXPORT $$1/ ;' \
495 -e 's/^(#pragma options)/\/\/$$1/' \
496 $(PUBLIC_HEADER_DIR)/*.h $(PRIVATE_HEADER_DIR)/*.h #*/
497 $(SILENT) $(REMOVE) -f $(PUBLIC_HEADER_DIR)/*.bak $(PRIVATE_HEADER_DIR)/*.bak #*/
500 # This is the line from a CFNetwork build in PB
501 # /AppleInternal/Developer/Tools/Interfacer -masterInterfaces "/AppleInternal/Carbon/interfaces/" -cacheFolder "/Volumes/Whopper/symroots/CFNetwork.build/CFNetwork.build/InterfacerCache/" -c -rez -framework "CFNetwork" -p -generated "c=/Volumes/Whopper/symroots/CFNetwork.framework/Versions/A/Headers/" -generatedPriv "c=/Volumes/Whopper/symroots/CFNetwork.framework/Versions/A/PrivateHeaders/" -generated "rez=/Volumes/Whopper/symroots/CFNetwork.framework/Versions/A/Headers/" -generatedPriv "rez=/Volumes/Whopper/symroots/CFNetwork.framework/Versions/A/PrivateHeaders/" -frameworkInterfaces /Volumes/Whale/trey/CFNetwork-Windows/Interfaces/ -installMasterInterfaces /tmp/CFNetwork.dst/AppleInternal/Carbon/interfaces/
504 prebuild_copy_headers:
505 $(SILENT) $(ECHO) "Copying headers..."
506 ifneq "$(strip $(PUBLIC_HFILES))" ""
507 $(SILENT) $(COPY) $(PUBLIC_HFILES) $(PUBLIC_HEADER_DIR)
509 ifneq "$(strip $(PRIVATE_HFILES))" ""
510 $(SILENT) $(COPY) $(PRIVATE_HFILES) $(PRIVATE_HEADER_DIR)
512 ifneq "$(strip $(PROJECT_HFILES))" ""
513 $(SILENT) $(COPY) $(PROJECT_HFILES) $(PROJECT_HEADER_DIR)
517 #--------------------------------------------------------------------------------
519 #--------------------------------------------------------------------------------
521 # ??? should use VPATH, should use generic rules
522 # ??? should use cc -MM to generate dependencies
523 # ??? should separate private from project headers, for proper installation
525 # Set some parameters of the build-realwork target, then call it with a recursive make
529 BUILD_PRODUCT=$(RELEASE_LIB) \
530 BUILD_IMPLIB=$(RELEASE_IMPLIB) \
531 OTHER_CFLAGS="-O $(OTHER_CFLAGS)" \
532 OTHER_CPPFLAGS="-O $(OTHER_CPPFLAGS)" \
533 OTHER_LFLAGS="-O $(OTHER_LFLAGS)" \
538 BUILD_PRODUCT=$(DEBUG_LIB) \
539 BUILD_IMPLIB=$(DEBUG_IMPLIB) \
540 LIBRARY_SUFFIX=_debug \
541 OTHER_CFLAGS="-DDEBUG -g $(OTHER_CFLAGS)" \
542 OTHER_CPPFLAGS="-DDEBUG -g $(OTHER_CPPFLAGS)" \
543 OTHER_LFLAGS="-g $(OTHER_LFLAGS)" \
548 BUILD_PRODUCT=$(PROFILE_LIB) \
549 BUILD_IMPLIB=$(PROFILE_IMPLIB) \
550 LIBRARY_SUFFIX=_profile \
551 OTHER_CFLAGS="-DPROFILE -pg -O $(OTHER_CFLAGS)" \
552 OTHER_CPPFLAGS="-DPROFILE -pg -O $(OTHER_CPPFLAGS)" \
553 OTHER_LFLAGS="-pg -O $(OTHER_LFLAGS)" \
556 OFILE_DIR = $(OBJROOT)/$(NAME).build/$(BUILD_TYPE)_ofiles
558 build-realwork: check-vars-defined compile-before build-compile compile-after build-link
563 $(SILENT) $(ECHO) "Building $(BUILD_TYPE)..."
564 $(SILENT) $(MKDIRS) $(OFILE_DIR)
565 $(SILENT) cumulativeError=0; \
566 for x in $(CFILES) ; do \
567 ofile=$(OFILE_DIR)/`basename $$x .c`.o ; \
568 if [ ! $$ofile -nt $$x ] ; then \
569 $(ECHO) " ..." $$x " ($(BUILD_TYPE))" ; \
570 $(CC) $(CFLAGS) -c $$x -o $$ofile ; \
572 if [ $$ccError != 0 ] ; then cumulativeError=$$ccError; fi;\
575 exit $$cumulativeError
576 $(SILENT) cumulativeError=0; \
577 for x in $(CPP_FILES) ; do \
578 ofile=$(OFILE_DIR)/`basename $$x .c`.o ; \
579 if [ ! $$ofile -nt $$x ] ; then \
580 $(ECHO) " ..." $$x " ($(BUILD_TYPE))" ; \
581 $(CPLUSPLUS) $(CPPFLAGS) -c $$x -o $$ofile ; \
583 if [ $$ccError != 0 ] ; then cumulativeError=$$ccError; fi;\
586 exit $$cumulativeError
588 ifeq "$(CPP_FILES)" ""
591 LINKER_CMD = $(CPLUSPLUS)
595 $(SILENT) $(ECHO) "Linking..."
596 ifeq "$(PLATFORM)" "Darwin"
597 $(SILENT) $(LINKER_CMD) $(LFLAGS) -O -install_name $(FRAMEWORK_DIR)/Versions/A/$(BUILD_PRODUCT) $(LIBS) -o $(SYMROOT)/$(NAME).framework/Versions/A/$(BUILD_PRODUCT) $(OFILE_DIR)/*.o #*/
598 $(SILENT) $(SYMLINK) Versions/Current/$(BUILD_PRODUCT) $(SYMROOT)/$(NAME).framework/$(BUILD_PRODUCT)
600 ifeq "$(PLATFORM)" "Linux"
601 $(SILENT) $(ECHO) "NOTE: Producing static libraries on Linux"
602 $(SILENT) ar cr $(SYMROOT)/$(BUILD_PRODUCT) $(OFILE_DIR)/*.o #*/
604 ifeq "$(PLATFORM)" "FreeBSD"
605 $(SILENT) $(LINKER_CMD) $(LFLAGS) -O -o $(SYMROOT)/$(BUILD_PRODUCT) $(OFILE_DIR)/*.o $(LIBS) #*/
607 ifeq "$(PLATFORM)" "CYGWIN"
608 $(SILENT) $(DLLTOOL) --no-export-all-symbols -z $(SYMROOT)/$(BUILD_PRODUCT:.dll=.defs) -e $(OFILE_DIR)/$(BUILD_PRODUCT:.dll=.exports.o) -l $(SYMROOT)/$(BUILD_IMPLIB) -D $(BUILD_PRODUCT) $(OFILE_DIR)/*.o #*/
609 $(SILENT) $(LINKER_CMD) $(LFLAGS) -mdll $(OFILE_DIR)/*.o $(OFILE_DIR)/$(BUILD_PRODUCT:.dll=.exports.o) $(LIBS) -o $(SYMROOT)/$(BUILD_PRODUCT) #*/
610 # generate a MS VC compatible import library
611 $(SILENT) if [ "$$MSVCDIR" != "" ] ; then \
612 defFile=`cygpath -w $(SYMROOT)/$(BUILD_PRODUCT:.dll=.defs)`; \
613 outFile=`cygpath -w $(SYMROOT)/$(BUILD_PRODUCT:.dll=.lib)`; \
614 cmd /C "$$MSVCDIR\BIN\VCVARS32" "&&" lib /MACHINE:i386 "/DEF:$$defFile" "/OUT:$$outFile"; \
616 $(ECHO) WARNING: \$$MSVCDIR is not set - no MS Visual C++ compatible import lib will be generated; \
619 $(SILENT) $(ECHO) "Done!"
621 # Make sure a couple variables are defined.
623 $(SILENT) if [ "" = "$(BUILD_TYPE)" ] || [ "" = "$(BUILD_PRODUCT)" ]; then \
624 echo ERROR: That target cannot be directly invoked. It is used only internally for recursive makes.; \