]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # Copyright (c) 2003 Michael Stevens |
2 | # Copyright (c) 2010-2011 Bryce Lelbach (blelbach@cct.lsu.edu, maintainer) | |
3 | # | |
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) | |
7 | ||
b32b8144 | 8 | import common ; |
7c673cae FG |
9 | import toolset ; |
10 | import feature ; | |
11 | import toolset : flags ; | |
12 | ||
13 | import clang ; | |
14 | import gcc ; | |
15 | import common ; | |
16 | import errors ; | |
17 | import generators ; | |
18 | import type ; | |
19 | import numbers ; | |
20 | ||
21 | feature.extend-subfeature toolset clang : platform : linux ; | |
22 | ||
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 ; | |
29 | ||
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 ; | |
33 | ||
34 | type.set-generated-target-suffix PCH | |
35 | : <toolset>clang <toolset-clang:platform>linux : pth ; | |
36 | ||
37 | toolset.inherit-rules clang-linux : gcc ; | |
38 | toolset.inherit-flags clang-linux : gcc | |
11fdf7f2 TL |
39 | : <inlining>full |
40 | <threading>multi/<target-os>windows | |
41 | ; | |
7c673cae FG |
42 | |
43 | if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] { | |
44 | .debug-configuration = true ; | |
45 | } | |
46 | ||
47 | rule init ( version ? : command * : options * ) { | |
48 | command = [ common.get-invocation-command clang-linux : clang++ | |
49 | : $(command) ] ; | |
50 | ||
51 | # Determine the version | |
7c673cae | 52 | if $(command) { |
b32b8144 FG |
53 | local command-string = \"$(command)\" ; |
54 | command-string = $(command-string:J=" ") ; | |
7c673cae FG |
55 | version ?= [ MATCH "version ([0-9.]+)" |
56 | : [ SHELL "$(command-string) --version" ] ] ; | |
57 | } | |
58 | ||
59 | local condition = [ common.check-init-parameters clang-linux | |
60 | : version $(version) ] ; | |
61 | ||
62 | common.handle-options clang-linux : $(condition) : $(command) : $(options) ; | |
11fdf7f2 | 63 | clang.init-cxxstd-flags clang-linux : $(condition) : $(version) ; |
b32b8144 FG |
64 | |
65 | # - Ranlib. | |
66 | local ranlib = [ feature.get-values <ranlib> : $(options) ] ; | |
67 | toolset.flags clang-linux.archive .RANLIB $(condition) : $(ranlib[1]) ; | |
68 | ||
69 | # - Archive builder. | |
70 | local archiver = [ feature.get-values <archiver> : $(options) ] ; | |
71 | toolset.flags clang-linux.archive .AR $(condition) : $(archiver[1]) ; | |
7c673cae FG |
72 | } |
73 | ||
74 | ############################################################################### | |
75 | # Flags | |
76 | ||
7c673cae | 77 | # note: clang silently ignores some of these inlining options |
7c673cae | 78 | # For clang, 'on' and 'full' are identical. |
7c673cae FG |
79 | toolset.flags clang-linux.compile OPTIONS <inlining>full : -Wno-inline ; |
80 | ||
11fdf7f2 TL |
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 ; | |
7c673cae FG |
83 | |
84 | ############################################################################### | |
85 | # C and C++ compilation | |
86 | ||
87 | rule compile.c++ ( targets * : sources * : properties * ) { | |
7c673cae FG |
88 | local pth-file = [ on $(<) return $(PCH_FILE) ] ; |
89 | ||
90 | if $(pth-file) { | |
91 | DEPENDS $(<) : $(pth-file) ; | |
92 | clang-linux.compile.c++.with-pch $(targets) : $(sources) ; | |
93 | } | |
94 | else { | |
95 | clang-linux.compile.c++.without-pth $(targets) : $(sources) ; | |
96 | } | |
97 | } | |
98 | ||
99 | actions compile.c++.without-pth { | |
100 | "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)" | |
101 | } | |
102 | ||
103 | actions compile.c++.with-pch bind PCH_FILE | |
104 | { | |
105 | "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pth -Xclang "$(PCH_FILE)" -o "$(<)" "$(>)" | |
106 | } | |
107 | ||
108 | rule compile.c ( targets * : sources * : properties * ) | |
109 | { | |
7c673cae FG |
110 | local pth-file = [ on $(<) return $(PCH_FILE) ] ; |
111 | ||
112 | if $(pth-file) { | |
113 | DEPENDS $(<) : $(pth-file) ; | |
114 | clang-linux.compile.c.with-pch $(targets) : $(sources) ; | |
115 | } | |
116 | else { | |
117 | clang-linux.compile.c.without-pth $(targets) : $(sources) ; | |
118 | } | |
119 | } | |
120 | ||
121 | actions compile.c.without-pth | |
122 | { | |
123 | "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" | |
124 | } | |
125 | ||
126 | actions compile.c.with-pch bind PCH_FILE | |
127 | { | |
128 | "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pth -Xclang "$(PCH_FILE)" -c -o "$(<)" "$(>)" | |
129 | } | |
130 | ||
131 | ############################################################################### | |
132 | # PCH emission | |
133 | ||
b32b8144 FG |
134 | RM = [ common.rm-command ] ; |
135 | ||
7c673cae | 136 | rule compile.c++.pch ( targets * : sources * : properties * ) { |
7c673cae FG |
137 | } |
138 | ||
139 | actions compile.c++.pch { | |
b32b8144 | 140 | $(RM) -f "$(<)" && "$(CONFIG_COMMAND)" -c -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pth -o "$(<)" "$(>)" |
7c673cae FG |
141 | } |
142 | ||
143 | rule compile.c.pch ( targets * : sources * : properties * ) { | |
7c673cae FG |
144 | } |
145 | ||
146 | actions compile.c.pch | |
147 | { | |
b32b8144 | 148 | $(RM) -f "$(<)" && "$(CONFIG_COMMAND)" -c -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pth -o "$(<)" "$(>)" |
7c673cae FG |
149 | } |
150 | ||
151 | ############################################################################### | |
152 | # Linking | |
153 | ||
154 | SPACE = " " ; | |
155 | ||
156 | rule link ( targets * : sources * : properties * ) { | |
7c673cae FG |
157 | SPACE on $(targets) = " " ; |
158 | JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ; | |
159 | } | |
160 | ||
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) | |
163 | } | |
164 | ||
165 | rule link.dll ( targets * : sources * : properties * ) { | |
7c673cae FG |
166 | SPACE on $(targets) = " " ; |
167 | JAM_SEMAPHORE on $(targets) = <s>clang-linux-link-semaphore ; | |
168 | } | |
169 | ||
7c673cae FG |
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) | |
173 | } | |
174 |