1 # Copyright Vladimir Prus 2004.
2 # Copyright Noel Belcourt 2007.
3 # Distributed under the Boost Software License, Version 1.0.
4 # (See accompanying file LICENSE_1_0.txt
5 # or copy at http://www.boost.org/LICENSE_1_0.txt)
8 import feature : feature ;
11 import toolset : flags ;
17 feature.extend-subfeature toolset clang : platform : darwin ;
19 toolset.inherit-generators clang-darwin
20 <toolset>clang <toolset-clang:platform>darwin
22 # Don't inherit PCH generators. They were not tested, and probably
23 # don't work for this compiler.
24 : gcc.mingw.link gcc.mingw.link.dll gcc.compile.c.pch gcc.compile.c++.pch
27 generators.override clang-darwin.prebuilt : builtin.lib-generator ;
28 generators.override clang-darwin.prebuilt : builtin.prebuilt ;
29 generators.override clang-darwin.searched-lib-generator : searched-lib-generator ;
31 generators.register-c-compiler clang-darwin.compile.m : OBJECTIVE_C : OBJ : <toolset>clang <toolset-clang:platform>darwin ;
32 generators.register-c-compiler clang-darwin.compile.mm : OBJECTIVE_CPP : OBJ : <toolset>clang <toolset-clang:platform>darwin ;
34 toolset.inherit-rules clang-darwin : gcc ;
35 toolset.inherit-flags clang-darwin : gcc
36 : <inlining>off <inlining>on <inlining>full <optimization>space
37 <warnings>off <warnings>all <warnings>on
38 <architecture>x86/<address-model>32
39 <architecture>x86/<address-model>64
42 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
44 .debug-configuration = true ;
47 # Initializes the clang-darwin toolset
49 # name (default clang++) is used to invoke the specified clang complier
50 # compile and link options allow you to specify addition command line options for each version
51 rule init ( version ? : command * : options * )
53 command = [ common.get-invocation-command clang-darwin : clang++
54 : $(command) : /usr/bin /usr/local/bin ] ;
56 # Determine the version
57 local command-string = $(command:J=" ") ;
60 version ?= [ MATCH "^([0-9.]+)"
61 : [ SHELL "$(command-string) -dumpversion" ] ] ;
64 local condition = [ common.check-init-parameters clang
65 : version $(version) ] ;
67 common.handle-options clang-darwin : $(condition) : $(command) : $(options) ;
69 gcc.init-link-flags clang darwin $(condition) ;
72 local ranlib = [ feature.get-values <ranlib> : $(options) ] ;
73 toolset.flags clang-darwin.archive .RANLIB $(condition) : $(ranlib[1]) ;
76 local archiver = [ feature.get-values <archiver> : $(options) ] ;
77 toolset.flags clang-darwin.archive .AR $(condition) : $(archiver[1]) ;
82 toolset.flags clang-darwin.compile OPTIONS <cflags> ;
83 toolset.flags clang-darwin.compile.c++ OPTIONS <cxxflags> ;
84 toolset.flags clang-darwin.compile.m OPTIONS <mflags> ;
85 toolset.flags clang-darwin.compile.mm OPTIONS <mflags> ;
86 toolset.flags clang-darwin.compile.mm OPTIONS <mmflags> ;
87 # toolset.flags clang-darwin.compile INCLUDES <include> ;
89 # Declare flags and action for compilation.
90 toolset.flags clang-darwin.compile OPTIONS <optimization>off : -O0 ;
91 toolset.flags clang-darwin.compile OPTIONS <optimization>speed : -O3 ;
92 toolset.flags clang-darwin.compile OPTIONS <optimization>space : -Os ;
94 # For clang, 'on' and 'full' are identical
95 toolset.flags clang-darwin.compile OPTIONS <inlining>off : -fno-inline ;
96 toolset.flags clang-darwin.compile OPTIONS <inlining>on : -Wno-inline ;
97 toolset.flags clang-darwin.compile OPTIONS <inlining>full : -Wno-inline ;
99 toolset.flags clang-darwin.compile OPTIONS <warnings>off : -w ;
100 toolset.flags clang-darwin.compile OPTIONS <warnings>on : -Wall ;
101 toolset.flags clang-darwin.compile OPTIONS <warnings>all : -Wall -pedantic ;
102 toolset.flags clang-darwin.compile OPTIONS <warnings-as-errors>on : -Werror ;
104 toolset.flags clang-darwin.compile OPTIONS <debug-symbols>on : -g ;
105 toolset.flags clang-darwin.compile OPTIONS <profiling>on : -pg ;
106 toolset.flags clang-darwin.compile OPTIONS <rtti>off : -fno-rtti ;
108 toolset.flags clang-darwin.compile OPTIONS <flags> ;
112 "$(CONFIG_COMMAND)" -x c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
117 "$(CONFIG_COMMAND)" -x c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
122 "$(CONFIG_COMMAND)" -x objective-c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
127 "$(CONFIG_COMMAND)" -x objective-c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
130 flags clang-darwin ARFLAGS <archiveflags> ;
132 # Default value. Mostly for the sake of clang-linux
133 # that inherits from gcc, but does not has the same
134 # logic to set the .AR variable. We can put the same
135 # logic in clang-linux, but that's hardly worth the trouble
136 # as on Linux, 'ar' is always available.
138 .RANLIB = ranlib -cs ;
140 rule archive ( targets * : sources * : properties * )
142 # Always remove archive and start again. Here's rationale from
145 # I had a file, say a1.c, that was included into liba.a.
146 # I moved a1.c to a2.c, updated my Jamfiles and rebuilt.
147 # My program was crashing with absurd errors.
148 # After some debugging I traced it back to the fact that a1.o was *still*
153 # Originally removing the archive was done by splicing an RM
154 # onto the archive action. That makes archives fail to build on NT
155 # when they have many files because it will no longer execute the
156 # action directly and blow the line length limit. Instead we
157 # remove the file in a different action, just before the building
160 local clean.a = $(targets[1])(clean) ;
161 TEMPORARY $(clean.a) ;
163 LOCATE on $(clean.a) = [ on $(targets[1]) return $(LOCATE) ] ;
164 DEPENDS $(clean.a) : $(sources) ;
165 DEPENDS $(targets) : $(clean.a) ;
166 common.RmTemps $(clean.a) : $(targets) ;
169 actions piecemeal archive
171 "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)"
175 flags clang-darwin.link USER_OPTIONS <linkflags> ;
177 # Declare actions for linking
178 rule link ( targets * : sources * : properties * )
180 SPACE on $(targets) = " " ;
181 # Serialize execution of the 'link' action, since
182 # running N links in parallel is just slower.
183 JAM_SEMAPHORE on $(targets) = <s>clang-darwin-link-semaphore ;
186 actions link bind LIBRARIES
188 "$(CONFIG_COMMAND)" $(USER_OPTIONS) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" $(START-GROUP) $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS)
191 actions link.dll bind LIBRARIES
193 "$(CONFIG_COMMAND)" $(USER_OPTIONS) -L"$(LINKPATH)" -o "$(<)" -single_module -dynamiclib -install_name "@rpath/$(<[1]:D=)" "$(>)" "$(LIBRARIES)" $(START-GROUP) $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS)