1 # Copyright (c) 2003 Michael Stevens
2 # Copyright (c) 2010-2011 Bryce Lelbach (blelbach@cct.lsu.edu, maintainer)
4 # Use, modification and distribution is subject to the Boost Software
5 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
6 # http://www.boost.org/LICENSE_1_0.txt)
10 import toolset : flags ;
20 feature.extend-subfeature toolset clang : platform : linux ;
22 toolset.inherit-generators clang-linux
23 <toolset>clang <toolset-clang:platform>linux : gcc
24 : gcc.mingw.link gcc.mingw.link.dll gcc.cygwin.link gcc.cygwin.link.dll ;
25 generators.override clang-linux.prebuilt : builtin.lib-generator ;
26 generators.override clang-linux.prebuilt : builtin.prebuilt ;
27 generators.override clang-linux.searched-lib-generator : searched-lib-generator ;
29 # Override default do-nothing generators.
30 generators.override clang-linux.compile.c.pch : pch.default-c-pch-generator ;
31 generators.override clang-linux.compile.c++.pch : pch.default-cpp-pch-generator ;
33 type.set-generated-target-suffix PCH
34 : <toolset>clang <toolset-clang:platform>linux : pth ;
36 toolset.inherit-rules clang-linux : gcc ;
37 toolset.inherit-flags clang-linux : gcc
38 : <inlining>off <inlining>on <inlining>full
39 <optimization>space <optimization>speed
40 <warnings>off <warnings>all <warnings>on ;
42 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] {
43 .debug-configuration = true ;
46 rule init ( version ? : command * : options * ) {
47 command = [ common.get-invocation-command clang-linux : clang++
50 # Determine the version
51 local command-string = $(command:J=" ") ;
54 version ?= [ MATCH "version ([0-9.]+)"
55 : [ SHELL "$(command-string) --version" ] ] ;
58 local condition = [ common.check-init-parameters clang-linux
59 : version $(version) ] ;
61 common.handle-options clang-linux : $(condition) : $(command) : $(options) ;
63 gcc.init-link-flags clang-linux gnu $(condition) ;
66 ###############################################################################
69 toolset.flags clang-linux.compile OPTIONS <cflags> ;
70 toolset.flags clang-linux.compile.c++ OPTIONS <cxxflags> ;
72 toolset.flags clang-linux.compile OPTIONS <optimization>off : ;
73 toolset.flags clang-linux.compile OPTIONS <optimization>speed : -O3 ;
74 toolset.flags clang-linux.compile OPTIONS <optimization>space : -Os ;
76 # note: clang silently ignores some of these inlining options
77 toolset.flags clang-linux.compile OPTIONS <inlining>off : -fno-inline ;
78 # For clang, 'on' and 'full' are identical.
79 toolset.flags clang-linux.compile OPTIONS <inlining>on : -Wno-inline ;
80 toolset.flags clang-linux.compile OPTIONS <inlining>full : -Wno-inline ;
82 toolset.flags clang-linux.compile OPTIONS <warnings>off : -w ;
83 toolset.flags clang-linux.compile OPTIONS <warnings>on : -Wall ;
84 toolset.flags clang-linux.compile OPTIONS <warnings>all : -Wall -pedantic ;
85 toolset.flags clang-linux.compile OPTIONS <warnings-as-errors>on : -Werror ;
87 toolset.flags clang-linux.compile OPTIONS <debug-symbols>on : -g ;
88 toolset.flags clang-linux.compile OPTIONS <profiling>on : -pg ;
89 toolset.flags clang-linux.compile OPTIONS <rtti>off : -fno-rtti ;
91 ###############################################################################
92 # C and C++ compilation
94 rule compile.c++ ( targets * : sources * : properties * ) {
95 setup-threading $(targets) : $(sources) : $(properties) ;
96 gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
97 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
99 local pth-file = [ on $(<) return $(PCH_FILE) ] ;
102 DEPENDS $(<) : $(pth-file) ;
103 clang-linux.compile.c++.with-pch $(targets) : $(sources) ;
106 clang-linux.compile.c++.without-pth $(targets) : $(sources) ;
110 actions compile.c++.without-pth {
111 "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
114 actions compile.c++.with-pch bind PCH_FILE
116 "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pth -Xclang "$(PCH_FILE)" -o "$(<)" "$(>)"
119 rule compile.c ( targets * : sources * : properties * )
121 setup-threading $(targets) : $(sources) : $(properties) ;
122 gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
123 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
125 local pth-file = [ on $(<) return $(PCH_FILE) ] ;
128 DEPENDS $(<) : $(pth-file) ;
129 clang-linux.compile.c.with-pch $(targets) : $(sources) ;
132 clang-linux.compile.c.without-pth $(targets) : $(sources) ;
136 actions compile.c.without-pth
138 "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
141 actions compile.c.with-pch bind PCH_FILE
143 "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pth -Xclang "$(PCH_FILE)" -c -o "$(<)" "$(>)"
146 ###############################################################################
149 rule compile.c++.pch ( targets * : sources * : properties * ) {
150 setup-threading $(targets) : $(sources) : $(properties) ;
151 gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
152 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
155 actions compile.c++.pch {
156 rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pth -o "$(<)" "$(>)"
159 rule compile.c.pch ( targets * : sources * : properties * ) {
160 setup-threading $(targets) : $(sources) : $(properties) ;
161 gcc.setup-fpic $(targets) : $(sources) : $(properties) ;
162 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
165 actions compile.c.pch
167 rm -f "$(<)" && "$(CONFIG_COMMAND)" -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pth -o "$(<)" "$(>)"
170 ###############################################################################
175 rule link ( targets * : sources * : properties * ) {
176 setup-threading $(targets) : $(sources) : $(properties) ;
177 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
178 SPACE on $(targets) = " " ;
179 JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ;
182 actions link bind LIBRARIES {
183 "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
186 rule link.dll ( targets * : sources * : properties * ) {
187 setup-threading $(targets) : $(sources) : $(properties) ;
188 gcc.setup-address-model $(targets) : $(sources) : $(properties) ;
189 SPACE on $(targets) = " " ;
190 JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ;
193 rule setup-threading ( targets * : sources * : properties * )
196 local target = [ feature.get-values target-os : $(properties) ] ;
201 local threading = [ feature.get-values threading : $(properties) ] ;
202 if $(threading) = multi
204 OPTIONS on $(targets) += -pthread ;
206 case * : gcc.setup-threading $(targets) : $(sources) : $(properties) ;
210 # Differ from 'link' above only by -shared.
211 actions link.dll bind LIBRARIES {
212 "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" -Wl,-soname$(SPACE)-Wl,$(<[1]:D=) -shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)