3 #~ Copyright 2002-2019 Rene Rivera.
4 #~ Distributed under the Boost Software License, Version 1.0.
5 #~ (See accompanying file LICENSE_1_0.txt or copy at
6 #~ http://www.boost.org/LICENSE_1_0.txt)
12 # Run a command, and echo before doing so. Also checks the exit status and quits
13 # if there was an error.
19 if test $r -ne 0 ; then
24 # Print an error message, and exit with a status of 1.
30 You can specify the toolset as the argument, i.e.:
33 Toolsets supported by this script are:
34 acc, clang, como, gcc, intel-darwin, intel-linux, kcc, kylix, mipspro,
35 pathscale, pgi, qcc, sun, sunpro, tru64cxx, vacpp
37 For any toolset you can override the path to the compiler with the CXX
38 environment variable. You can also use additional flags for the compiler
39 with the CXXFLAGS environment variable.
41 A special toolset; cxx, is available which is used as a fallback when a more
42 specific toolset is not found and the cxx command is detected. The 'cxx'
43 toolset will use the CXX, CXXFLAGS, and LIBS environment variables, if present.
45 Similarly, the cross-cxx toolset is available for cross-compiling by using the
46 BUILD_CXX, BUILD_CXXFLAGS, and BUILD_LDFLAGS environment variables to compile
47 binaries that will be executed on the build system. This allows CXX etc. to be
48 set for cross-compilers to be propagated to subprocesses.
53 # Check that a command is in the PATH.
56 if `command -v command 1>/dev/null 2>/dev/null`; then
57 command -v $1 1>/dev
/null
2>/dev
/null
59 hash $1 1>/dev
/null
2>/dev
/null
63 # Check that the OS name, as returned by "uname", is as given.
66 if test_path uname
; then
71 # Try and guess the toolset to bootstrap the build with...
74 if test_uname Darwin
; then B2_TOOLSET
=clang
75 elif test_uname IRIX
; then B2_TOOLSET
=mipspro
76 elif test_uname IRIX64
; then B2_TOOLSET
=mipspro
77 elif test_uname OSF1
; then B2_TOOLSET
=tru64cxx
78 elif test_uname QNX
&& test_path QCC
; then B2_TOOLSET
=qcc
79 elif test_uname Linux
&& test_path xlC_r
; then
80 if /usr
/bin
/lscpu |
grep Byte |
grep Little
> /dev
/null
2>&1 ; then
87 elif test_uname AIX
&& test_path xlC_r
; then B2_TOOLSET
=vacpp
88 elif test_uname FreeBSD
&& test_path freebsd-version
&& test_path clang
++; then B2_TOOLSET
=clang
89 elif test_path g
++ ; then B2_TOOLSET
=gcc
90 elif test_path clang
++ ; then B2_TOOLSET
=clang
91 elif test_path icc
; then B2_TOOLSET
=intel-linux
92 elif test -r /opt
/intel
/cc
/9.0/bin
/iccvars.sh
; then
93 B2_TOOLSET
=intel-linux
94 B2_TOOLSET_ROOT
=/opt
/intel
/cc
/9.0
95 elif test -r /opt
/intel_cc_80
/bin
/iccvars.sh
; then
96 B2_TOOLSET
=intel-linux
97 B2_TOOLSET_ROOT
=/opt
/intel_cc_80
98 elif test -r /opt
/intel
/compiler70
/ia32
/bin
/iccvars.sh
; then
99 B2_TOOLSET
=intel-linux
100 B2_TOOLSET_ROOT
=/opt
/intel
/compiler70
/ia32
/
101 elif test -r /opt
/intel
/compiler60
/ia32
/bin
/iccvars.sh
; then
102 B2_TOOLSET
=intel-linux
103 B2_TOOLSET_ROOT
=/opt
/intel
/compiler60
/ia32
/
104 elif test -r /opt
/intel
/compiler50
/ia32
/bin
/iccvars.sh
; then
105 B2_TOOLSET
=intel-linux
106 B2_TOOLSET_ROOT
=/opt
/intel
/compiler50
/ia32
/
107 elif test_path pgc
++ ; then B2_TOOLSET
=pgi
108 elif test_path pathCC
; then B2_TOOLSET
=pathscale
109 elif test_path como
; then B2_TOOLSET
=como
110 elif test_path KCC
; then B2_TOOLSET
=kcc
111 elif test_path
bc++ ; then B2_TOOLSET
=kylix
112 elif test_path aCC
; then B2_TOOLSET
=acc
113 elif test_uname HP-UX
; then B2_TOOLSET
=acc
114 elif test -r /opt
/SUNWspro
/bin
/cc
; then
116 B2_TOOLSET_ROOT
=/opt
/SUNWspro
/
117 # Test for some common compile command as the default fallback.
118 elif test_path
$CXX ; then B2_TOOLSET
=cxx
119 elif test_path cxx
; then
122 elif test_path cpp
; then
125 elif test_path CC
; then
129 if test "$B2_TOOLSET" = "" ; then
130 error_exit
"Could not find a suitable toolset."
146 # The one option we support in the invocation
147 # is the name of the toolset to force building
150 --guess-toolset) guess_toolset
; echo "$B2_TOOLSET" ; exit 1 ;;
152 ?
*) B2_TOOLSET
=$1 ; shift ;;
159 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
160 # Check whether it's MinGW GCC, which has Windows headers and none of POSIX ones.
161 machine
=$
(${CXX} -dumpmachine 2>/dev
/null
)
162 if [ $?
-ne 0 ]; then
163 echo "B2_TOOLSET is gcc, but the 'gcc' command cannot be executed."
164 echo "Make sure 'gcc' is in PATH, or use a different toolset."
169 # MinGW insists that its bin directory be in PATH.
170 if test -r ${B2_TOOLSET_ROOT}bin
/gcc
; then
171 export PATH
=${B2_TOOLSET_ROOT}bin
:$PATH
173 B2_CXX
="${CXX} -x c++ -std=c++11"
174 B2_CXXFLAGS_RELEASE
="-O2 -s"
175 B2_CXXFLAGS_DEBUG
="-O0 -g"
180 B2_CXX
="${CXX} -x c++ -std=gnu11"
181 B2_CXXFLAGS_RELEASE
="-O2 -s"
182 B2_CXXFLAGS_DEBUG
="-O0 -g"
186 B2_CXX
="${CXX} -x c++ -std=c++11"
187 B2_CXXFLAGS_RELEASE
="-O2 -s"
188 B2_CXXFLAGS_DEBUG
="-O0 -g"
194 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
195 B2_CXX
="${CXX} -xc++"
196 B2_CXXFLAGS_RELEASE
="-O3 -s"
197 B2_CXXFLAGS_DEBUG
="-O0 -g -p"
202 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
203 test_path
${CXX} >/dev
/null
2>&1
205 echo "Found ${CXX} in environment"
206 B2_TOOLSET_ROOT
=`echo ${CXX}| sed -e 's/bin.*\/icc//'`
207 # probably the most widespread
210 echo "No intel compiler in current path"
211 echo "Look in a few old place for legacy reason"
212 if test -r /opt
/intel
/cc
/9.0/bin
/iccvars.sh
; then
213 B2_TOOLSET_ROOT
=/opt
/intel
/cc
/9.0/
214 elif test -r /opt
/intel_cc_80
/bin
/iccvars.sh
; then
215 B2_TOOLSET_ROOT
=/opt
/intel_cc_80
/
216 elif test -r /opt
/intel
/compiler70
/ia32
/bin
/iccvars.sh
; then
217 B2_TOOLSET_ROOT
=/opt
/intel
/compiler70
/ia32
/
218 elif test -r /opt
/intel
/compiler60
/ia32
/bin
/iccvars.sh
; then
219 B2_TOOLSET_ROOT
=/opt
/intel
/compiler60
/ia32
/
220 elif test -r /opt
/intel
/compiler50
/ia32
/bin
/iccvars.sh
; then
221 B2_TOOLSET_ROOT
=/opt
/intel
/compiler50
/ia32
/
224 if test -r ${B2_TOOLSET_ROOT}bin
/iccvars.sh
; then
225 # iccvars does not change LD_RUN_PATH. We adjust LD_RUN_PATH here in
226 # order not to have to rely on ld.so.conf knowing the icc library
227 # directory. We do this before running iccvars.sh in order to allow a
228 # user to add modifications to LD_RUN_PATH in iccvars.sh.
229 if test -z "${LD_RUN_PATH}"; then
230 LD_RUN_PATH
="${B2_TOOLSET_ROOT}lib"
232 LD_RUN_PATH
="${B2_TOOLSET_ROOT}lib:${LD_RUN_PATH}"
235 .
${B2_TOOLSET_ROOT}bin
/iccvars.sh
$ARCH
237 B2_CXX
="${CXX} -xc++"
238 B2_CXXFLAGS_RELEASE
="-O3 -s"
239 B2_CXXFLAGS_DEBUG
="-O0 -g -p"
244 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
246 B2_CXXFLAGS_RELEASE
="-O3 -s -qstrict -qinline"
247 B2_CXXFLAGS_DEBUG
="-g -qNOOPTimize -qnoinline -pg"
252 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
254 B2_CXXFLAGS_RELEASE
="-s -O3 -qstrict -qinline"
255 B2_CXXFLAGS_DEBUG
="-g -qNOOPTimize -qnoinline -pg"
260 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
262 B2_CXXFLAGS_RELEASE
="-O3 --inlining"
263 B2_CXXFLAGS_DEBUG
="-O0 -g --no_inlining --long_long"
268 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
270 B2_CXXFLAGS_RELEASE
="+K2 -s"
271 B2_CXXFLAGS_DEBUG
="+K0 -g"
276 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
278 B2_CXXFLAGS_RELEASE
="-O2 -vi -w-inl -s"
279 B2_CXXFLAGS_DEBUG
="-Od -v -vi-"
284 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
285 B2_CXX
="${CXX} -FE:template_in_elf_section -ptused"
286 B2_CXXFLAGS_RELEASE
="-Ofast -g0 \"-INLINE:none\" -s"
287 B2_CXXFLAGS_DEBUG
="-O0 -INLINE -g"
292 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
294 B2_CXXFLAGS_RELEASE
="-O3 -inline -s"
295 B2_CXXFLAGS_DEBUG
="-O0 -noinline -ggdb"
300 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
301 B2_CXX
="${CXX} -std=c++11"
302 B2_CXXFLAGS_RELEASE
="-fast -s"
303 B2_CXXFLAGS_DEBUG
="-O0 -gopt"
308 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
309 if test -z "${B2_TOOLSET_ROOT}" -a -r /opt
/SUNWspro
/bin
/CC
; then
310 B2_TOOLSET_ROOT
=/opt
/SUNWspro
/
312 if test -r "${B2_TOOLSET_ROOT}/bin/CC" ; then
313 PATH
=${B2_TOOLSET_ROOT}bin
:${PATH}
317 B2_CXXFLAGS_RELEASE
="-xO4 -s"
318 B2_CXXFLAGS_DEBUG
="-g"
323 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
324 B2_CXX
="${CXX} -x c++ -O3 -std=c++11"
326 B2_CXXFLAGS_RELEASE
="-O3 -s"
327 B2_CXXFLAGS_DEBUG
="-O0 -fno-inline -g"
331 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
333 B2_CXXFLAGS_RELEASE
="-O5 -inline speed -s"
334 B2_CXXFLAGS_DEBUG
="-O0 -pg -g"
339 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
341 B2_CXXFLAGS_RELEASE
="-O3 -s"
342 B2_CXXFLAGS_DEBUG
="+d -g"
347 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
349 B2_CXXFLAGS_RELEASE
="-O3 -Wc,-finline-functions"
350 B2_CXXFLAGS_DEBUG
="O0 -Wc,-fno-inline -gstabs+"
355 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
360 CXX
=${BUILD_CXX:=cxx}
361 CXXFLAGS
=${BUILD_CXXFLAGS}
362 CXX_VERSION_OPT
=${CXX_VERSION_OPT:=--version}
367 error_exit
"Unknown toolset: $B2_TOOLSET"
373 echo "### Using '$B2_TOOLSET' toolset."
376 echo_run
${CXX} ${CXX_VERSION_OPT}
424 modules/property-set.cpp \
426 modules/sequence.cpp \
431 B2_SOURCES
="${B2_SOURCES} execnt.cpp filent.cpp pathnt.cpp"
435 B2_SOURCES
="${B2_SOURCES} execunix.cpp fileunix.cpp pathunix.cpp"
439 if check_debug_build
"$@" ; then B2_CXXFLAGS
="${B2_CXXFLAGS_DEBUG}"
440 else B2_CXXFLAGS
="${B2_CXXFLAGS_RELEASE} -DNDEBUG"
442 echo_run
${B2_CXX} ${CXXFLAGS} ${B2_CXXFLAGS} ${B2_SOURCES} -o b2