Index: darwin.jam =================================================================== --- darwin.jam (revision 57269) +++ darwin.jam (working copy) @@ -16,6 +16,10 @@ import common ; import generators ; import path : basename ; +import version ; +import property-set ; +import regex ; +import errors ; ## Use a framework. feature framework : : free ; @@ -60,7 +64,7 @@ type.set-generated-target-suffix PCH : darwin : gch ; -toolset.inherit-rules darwin : gcc ; +toolset.inherit-rules darwin : gcc : localize ; toolset.inherit-flags darwin : gcc : static arm/32 @@ -82,6 +86,17 @@ # rule init ( version ? : command * : options * : requirement * ) { + # First time around, figure what is host OSX version + if ! $(.host-osx-version) + { + .host-osx-version = [ MATCH "^([0-9.]+)" + : [ SHELL "/usr/bin/sw_vers -productVersion" ] ] ; + if $(.debug-configuration) + { + ECHO notice: OSX version on this machine is $(.host-osx-version) ; + } + } + # - The root directory of the tool install. local root = [ feature.get-values : $(options) ] ; @@ -121,6 +136,8 @@ version ?= $(real-version) ; } + .real-version.$(version) = $(real-version) ; + # - Define the condition for this toolset instance. local condition = [ common.check-init-parameters darwin $(requirement) : version $(version) ] ; @@ -265,10 +282,105 @@ generators.register-c-compiler darwin.compile.m : OBJECTIVE_C : OBJ : darwin ; generators.register-c-compiler darwin.compile.mm : OBJECTIVE_CPP : OBJ : darwin ; -rule compile.m +rule setup-address-model ( targets * : sources * : properties * ) { + local ps = [ property-set.create $(properties) ] ; + local arch = [ $(ps).get ] ; + local address-model = [ $(ps).get ] ; + local osx-version = [ $(ps).get ] ; + local gcc-version = [ $(ps).get ] ; + gcc-version = $(.real-version.$(gcc-version)) ; + local options ; + + local support-ppc64 = 1 ; + + osx-version ?= $(.host-osx-version) ; + + if $(osx-version) && ! [ version.version-less [ regex.split $(osx-version) \\. ] : 10 6 ] + { + # When targeting 10.6: + # - gcc 4.2 will give a compiler errir if ppc64 compilation is requested + # - gcc 4.0 will compile fine, somehow, but then fail at link time + support-ppc64 = ; + } + + switch $(arch) + { + case combined : + { + if $(address-model) = 32_64 { + if $(support-ppc64) { + options = -arch i386 -arch ppc -arch x86_64 -arch ppc64 ; + } else { + # Build 3-way binary + options = -arch i386 -arch ppc -arch x86_64 ; + } + } else if $(address-model) = 64 { + if $(support-ppc64) { + options = -arch x86_64 -arch ppc64 ; + } else { + errors.user-error "64-bit PPC compilation is not supported when targeting OSX 10.6 or later" ; + } + } else { + options = -arch i386 -arch ppc ; + } + } + + case x86 : + { + if $(address-model) = 32_64 { + options = -arch i386 -arch x86_64 ; + } else if $(address-model) = 64 { + options = -arch x86_64 ; + } else { + options = -arch i386 ; + } + } + + case power : + { + if ! $(support-ppc64) + && ( $(address-model) = 32_64 || $(address-model) = 64 ) + { + errors.user-error "64-bit PPC compilation is not supported when targeting OSX 10.6 or later" ; + } + + if $(address-model) = 32_64 { + options = -arch ppc -arch ppc64 ; + } else if $(address-model) = 64 { + options = -arch ppc64 ; + } else { + options = -arch ppc ; + } + } + + case arm : + { + options = -arch armv6 ; + } + } + + if $(options) + { + OPTIONS on $(targets) += $(options) ; + } +} + +rule setup-threading ( targets * : sources * : properties * ) +{ + gcc.setup-threading $(targets) : $(sources) : $(properties) ; +} + +rule setup-fpic ( targets * : sources * : properties * ) +{ + gcc.setup-fpic $(targets) : $(sources) : $(properties) ; +} + +rule compile.m ( targets * : sources * : properties * ) +{ LANG on $(<) = "-x objective-c" ; gcc.setup-fpic $(targets) : $(sources) : $(properties) ; + setup-arch-addr-flags $(targets) : $(sources) : $(properties) ; } actions compile.m @@ -280,6 +392,7 @@ { LANG on $(<) = "-x objective-c++" ; gcc.setup-fpic $(targets) : $(sources) : $(properties) ; + setup-arch-addr-flags $(targets) : $(sources) : $(properties) ; } actions compile.mm @@ -287,37 +400,6 @@ "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" } -# Add option selection for combined and specific architecture combinations. - -local rule arch-addr-flags ( toolset variable - : architecture : address-model + : values + : default ? ) -{ - if $(default) - { - flags $(toolset) $(variable) - $(architecture)/ - : $(values) ; - } - flags $(toolset) $(variable) - /$(address-model) - $(architecture)/$(address-model) - : $(values) ; -} - -arch-addr-flags darwin OPTIONS : combined : 32 : -arch i386 -arch ppc : default ; -arch-addr-flags darwin OPTIONS : combined : 64 : -arch x86_64 -arch ppc64 ; -arch-addr-flags darwin OPTIONS : combined : 32_64 : -arch i386 -arch ppc -arch x86_64 -arch ppc64 ; - -arch-addr-flags darwin OPTIONS : x86 : 32 : -arch i386 : default ; -arch-addr-flags darwin OPTIONS : x86 : 64 : -arch x86_64 ; -arch-addr-flags darwin OPTIONS : x86 : 32_64 : -arch i386 -arch x86_64 ; - -arch-addr-flags darwin OPTIONS : power : 32 : -arch ppc : default ; -arch-addr-flags darwin OPTIONS : power : 64 : -arch ppc64 ; -arch-addr-flags darwin OPTIONS : power : 32_64 : -arch ppc -arch ppc64 ; - -arch-addr-flags darwin OPTIONS : arm : 32 : -arch armv6 : default ; - # Set the max header padding to allow renaming of libs for installation. flags darwin.link.dll OPTIONS : -headerpad_max_install_names ; @@ -360,8 +442,9 @@ } } -rule link +rule link ( targets * : sources * : properties * ) { + setup-address-model $(targets) : $(sources) : $(properties) ; prepare-framework-path $(<) ; } @@ -375,8 +458,9 @@ $(NEED_STRIP)"$(.STRIP)" $(NEED_STRIP)-S $(NEED_STRIP)-x $(NEED_STRIP)"$(<)" } -rule link.dll +rule link.dll ( targets * : sources * : properties * ) { + setup-address-model $(targets) : $(sources) : $(properties) ; prepare-framework-path $(<) ; }