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)
11 import toolset : flags ;
21 feature.extend-subfeature toolset clang : platform : linux ;
23 toolset.inherit-generators clang-linux
24 <toolset>clang <toolset-clang:platform>linux : gcc
25 : gcc.mingw.link gcc.mingw.link.dll gcc.cygwin.link gcc.cygwin.link.dll ;
26 generators.override clang-linux.prebuilt : builtin.lib-generator ;
27 generators.override clang-linux.prebuilt : builtin.prebuilt ;
28 generators.override clang-linux.searched-lib-generator : searched-lib-generator ;
30 # Override default do-nothing generators.
31 generators.override clang-linux.compile.c.pch : pch.default-c-pch-generator ;
32 generators.override clang-linux.compile.c++.pch : pch.default-cpp-pch-generator ;
34 type.set-generated-target-suffix PCH
35 : <toolset>clang <toolset-clang:platform>linux : pth ;
37 toolset.inherit-rules clang-linux : gcc ;
38 toolset.inherit-flags clang-linux : gcc
40 <threading>multi/<target-os>windows
43 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] {
44 .debug-configuration = true ;
47 rule init ( version ? : command * : options * ) {
48 command = [ common.get-invocation-command clang-linux : clang++
51 # Determine the version
53 local command-string = \"$(command)\" ;
54 command-string = $(command-string:J=" ") ;
55 version ?= [ MATCH "version ([0-9.]+)"
56 : [ SHELL "$(command-string) --version" ] ] ;
59 local condition = [ common.check-init-parameters clang-linux
60 : version $(version) ] ;
62 common.handle-options clang-linux : $(condition) : $(command) : $(options) ;
63 clang.init-cxxstd-flags clang-linux : $(condition) : $(version) ;
66 local ranlib = [ feature.get-values <ranlib> : $(options) ] ;
67 toolset.flags clang-linux.archive .RANLIB $(condition) : $(ranlib[1]) ;
70 local archiver = [ feature.get-values <archiver> : $(options) ] ;
71 toolset.flags clang-linux.archive .AR $(condition) : $(archiver[1]) ;
74 ###############################################################################
77 # note: clang silently ignores some of these inlining options
78 # For clang, 'on' and 'full' are identical.
79 toolset.flags clang-linux.compile OPTIONS <inlining>full : -Wno-inline ;
81 toolset.flags clang-linux.compile OPTIONS <threading>multi/<target-os>windows : -pthread ;
82 toolset.flags clang-linux.link OPTIONS <threading>multi/<target-os>windows : -pthread ;
84 ###############################################################################
85 # C and C++ compilation
87 rule compile.c++ ( targets * : sources * : properties * ) {
88 local pch-file = [ on $(<) return $(PCH_FILE) ] ;
91 DEPENDS $(<) : $(pch-file) ;
92 clang-linux.compile.c++.with-pch $(targets) : $(sources) ;
95 clang-linux.compile.c++.without-pch $(targets) : $(sources) ;
99 actions compile.c++.without-pch {
100 "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
103 actions compile.c++.with-pch bind PCH_FILE
105 "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pch -Xclang "$(PCH_FILE)" -o "$(<)" "$(>)"
108 rule compile.c ( targets * : sources * : properties * )
110 local pch-file = [ on $(<) return $(PCH_FILE) ] ;
113 DEPENDS $(<) : $(pch-file) ;
114 clang-linux.compile.c.with-pch $(targets) : $(sources) ;
117 clang-linux.compile.c.without-pch $(targets) : $(sources) ;
121 actions compile.c.without-pch
123 "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
126 actions compile.c.with-pch bind PCH_FILE
128 "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pch -Xclang "$(PCH_FILE)" -c -o "$(<)" "$(>)"
131 ###############################################################################
134 RM = [ common.rm-command ] ;
136 rule compile.c++.pch ( targets * : sources * : properties * ) {
139 actions compile.c++.pch {
140 $(RM) -f "$(<)" && "$(CONFIG_COMMAND)" -c -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pch -o "$(<)" "$(>)"
143 rule compile.c.pch ( targets * : sources * : properties * ) {
146 actions compile.c.pch
148 $(RM) -f "$(<)" && "$(CONFIG_COMMAND)" -c -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pch -o "$(<)" "$(>)"
151 ###############################################################################
156 rule link ( targets * : sources * : properties * ) {
157 SPACE on $(targets) = " " ;
158 JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ;
161 actions link bind LIBRARIES {
162 "$(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)
165 rule link.dll ( targets * : sources * : properties * ) {
166 SPACE on $(targets) = " " ;
167 JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ;
170 # Differ from 'link' above only by -shared.
171 actions link.dll bind LIBRARIES {
172 "$(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)