3 #~ Copyright 2002-2005 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 echo "### You can specify the toolset as the argument, i.e.:"
31 echo "### ./build.sh gcc"
33 echo "### Toolsets supported by this script are:"
34 echo "### acc, como, darwin, gcc, intel-darwin, intel-linux, kcc, kylix,"
35 echo "### mipspro, pathscale, pgi, qcc, sun, sunpro, tru64cxx, vacpp"
37 echo "### A special toolset; cc, is available which is used as a fallback"
38 echo "### when a more specific toolset is not found and the cc command is"
39 echo "### detected. The 'cc' toolset will use the CC, CFLAGS, and LIBS"
40 echo "### environment variables, if present."
45 # Check that a command is in the PATH.
48 if `command -v command 1>/dev/null 2>/dev/null`; then
49 command -v $1 1>/dev
/null
2>/dev
/null
51 hash $1 1>/dev
/null
2>/dev
/null
55 # Check that the OS name, as returned by "uname", is as given.
58 if test_path uname
; then
63 # Try and guess the toolset to bootstrap the build with...
66 if test_uname Darwin
; then BOOST_JAM_TOOLSET
=darwin
67 elif test_uname IRIX
; then BOOST_JAM_TOOLSET
=mipspro
68 elif test_uname IRIX64
; then BOOST_JAM_TOOLSET
=mipspro
69 elif test_uname OSF1
; then BOOST_JAM_TOOLSET
=tru64cxx
70 elif test_uname QNX
&& test_path qcc
; then BOOST_JAM_TOOLSET
=qcc
71 elif test_uname Linux
&& test_path xlc
; then
72 if /usr
/bin
/lscpu |
grep Byte |
grep Little
> /dev
/null
2>&1 ; then
74 BOOST_JAM_TOOLSET
=xlcpp
77 BOOST_JAM_TOOLSET
=vacpp
79 elif test_uname AIX
&& test_path xlc
; then BOOST_JAM_TOOLSET
=vacpp
80 elif test_uname FreeBSD
&& test_path freebsd-version
&& test_path clang
; then BOOST_JAM_TOOLSET
=clang
81 elif test_path gcc
; then BOOST_JAM_TOOLSET
=gcc
82 elif test_path icc
; then BOOST_JAM_TOOLSET
=intel-linux
83 elif test -r /opt
/intel
/cc
/9.0/bin
/iccvars.sh
; then
84 BOOST_JAM_TOOLSET
=intel-linux
85 BOOST_JAM_TOOLSET_ROOT
=/opt
/intel
/cc
/9.0
86 elif test -r /opt
/intel_cc_80
/bin
/iccvars.sh
; then
87 BOOST_JAM_TOOLSET
=intel-linux
88 BOOST_JAM_TOOLSET_ROOT
=/opt
/intel_cc_80
89 elif test -r /opt
/intel
/compiler70
/ia32
/bin
/iccvars.sh
; then
90 BOOST_JAM_TOOLSET
=intel-linux
91 BOOST_JAM_TOOLSET_ROOT
=/opt
/intel
/compiler70
/ia32
/
92 elif test -r /opt
/intel
/compiler60
/ia32
/bin
/iccvars.sh
; then
93 BOOST_JAM_TOOLSET
=intel-linux
94 BOOST_JAM_TOOLSET_ROOT
=/opt
/intel
/compiler60
/ia32
/
95 elif test -r /opt
/intel
/compiler50
/ia32
/bin
/iccvars.sh
; then
96 BOOST_JAM_TOOLSET
=intel-linux
97 BOOST_JAM_TOOLSET_ROOT
=/opt
/intel
/compiler50
/ia32
/
98 elif test_path pgcc
; then BOOST_JAM_TOOLSET
=pgi
99 elif test_path pathcc
; then BOOST_JAM_TOOLSET
=pathscale
100 elif test_path como
; then BOOST_JAM_TOOLSET
=como
101 elif test_path KCC
; then BOOST_JAM_TOOLSET
=kcc
102 elif test_path
bc++ ; then BOOST_JAM_TOOLSET
=kylix
103 elif test_path aCC
; then BOOST_JAM_TOOLSET
=acc
104 elif test_uname HP-UX
; then BOOST_JAM_TOOLSET
=acc
105 elif test -r /opt
/SUNWspro
/bin
/cc
; then
106 BOOST_JAM_TOOLSET
=sunpro
107 BOOST_JAM_TOOLSET_ROOT
=/opt
/SUNWspro
/
108 # Test for "cc" as the default fallback.
109 elif test_path
$CC ; then BOOST_JAM_TOOLSET
=cc
110 elif test_path cc
; then
114 if test "$BOOST_JAM_TOOLSET" = "" ; then
115 error_exit
"Could not find a suitable toolset."
119 # The one option we support in the invocation
120 # is the name of the toolset to force building
123 --guess-toolset) Guess_Toolset
; echo "$BOOST_JAM_TOOLSET" ; exit 1 ;;
125 ?
*) BOOST_JAM_TOOLSET
=$1 ; shift ;;
128 BOOST_JAM_OPT_JAM
="-o bootstrap/jam0"
129 BOOST_JAM_OPT_MKJAMBASE
="-o bootstrap/mkjambase0"
130 BOOST_JAM_OPT_YYACC
="-o bootstrap/yyacc0"
131 case $BOOST_JAM_TOOLSET in
134 # Check whether it's MinGW GCC, which has Windows headers and none of POSIX ones.
135 machine
=$
(gcc
-dumpmachine 2>/dev
/null
)
136 if [ $?
-ne 0 ]; then
137 echo "BOOST_JAM_TOOLSET is gcc, but the 'gcc' command cannot be executed."
138 echo "Make sure 'gcc' is in PATH, or use a different toolset."
143 # MinGW insists that its bin directory be in PATH.
144 if test -r ${BOOST_JAM_TOOLSET_ROOT}bin
/gcc
; then
145 export PATH
=${BOOST_JAM_TOOLSET_ROOT}bin
:$PATH
147 BOOST_JAM_CC
="gcc -DNT"
165 test_path icc
>/dev
/null
2>&1
167 BOOST_JAM_CC
=`test_path icc`
168 echo "Found $BOOST_JAM_CC in environment"
169 BOOST_JAM_TOOLSET_ROOT
=`echo $BOOST_JAM_CC | sed -e 's/bin.*\/icc//'`
170 # probably the most widespread
173 echo "No intel compiler in current path"
174 echo "Look in a few old place for legacy reason"
175 if test -r /opt
/intel
/cc
/9.0/bin
/iccvars.sh
; then
176 BOOST_JAM_TOOLSET_ROOT
=/opt
/intel
/cc
/9.0/
177 elif test -r /opt
/intel_cc_80
/bin
/iccvars.sh
; then
178 BOOST_JAM_TOOLSET_ROOT
=/opt
/intel_cc_80
/
179 elif test -r /opt
/intel
/compiler70
/ia32
/bin
/iccvars.sh
; then
180 BOOST_JAM_TOOLSET_ROOT
=/opt
/intel
/compiler70
/ia32
/
181 elif test -r /opt
/intel
/compiler60
/ia32
/bin
/iccvars.sh
; then
182 BOOST_JAM_TOOLSET_ROOT
=/opt
/intel
/compiler60
/ia32
/
183 elif test -r /opt
/intel
/compiler50
/ia32
/bin
/iccvars.sh
; then
184 BOOST_JAM_TOOLSET_ROOT
=/opt
/intel
/compiler50
/ia32
/
187 if test -r ${BOOST_JAM_TOOLSET_ROOT}bin
/iccvars.sh
; then
188 # iccvars does not change LD_RUN_PATH. We adjust LD_RUN_PATH here in
189 # order not to have to rely on ld.so.conf knowing the icc library
190 # directory. We do this before running iccvars.sh in order to allow a
191 # user to add modifications to LD_RUN_PATH in iccvars.sh.
192 if test -z "${LD_RUN_PATH}"; then
193 LD_RUN_PATH
="${BOOST_JAM_TOOLSET_ROOT}lib"
195 LD_RUN_PATH
="${BOOST_JAM_TOOLSET_ROOT}lib:${LD_RUN_PATH}"
198 .
${BOOST_JAM_TOOLSET_ROOT}bin
/iccvars.sh
$ARCH
200 if test -z "$BOOST_JAM_CC" ; then
214 BOOST_JAM_CC
="como --c"
238 if test -z "${BOOST_JAM_TOOLSET_ROOT}" -a -r /opt
/SUNWspro
/bin
/cc
; then
239 BOOST_JAM_TOOLSET_ROOT
=/opt
/SUNWspro
/
241 if test -r "${BOOST_JAM_TOOLSET_ROOT}bin/cc" ; then
242 PATH
=${BOOST_JAM_TOOLSET_ROOT}bin
:${PATH}
249 BOOST_JAM_CC
="clang -Wno-unused -Wno-format"
250 BOOST_JAM_TOOLSET
=clang
258 BOOST_JAM_CC
="cc -Ae"
262 if test -z "$CC" ; then CC
=cc
; fi
264 BOOST_JAM_OPT_JAM
="$BOOST_JAM_OPT_JAM $CFLAGS $LIBS"
265 BOOST_JAM_OPT_MKJAMBASE
="$BOOST_JAM_OPT_MKJAMBASE $CFLAGS $LIBS"
266 BOOST_JAM_OPT_YYACC
="$BOOST_JAM_OPT_YYACC $CFLAGS $LIBS"
274 error_exit
"Unknown toolset: $BOOST_JAM_TOOLSET"
279 echo "### Using '$BOOST_JAM_TOOLSET' toolset."
282 YYACC_SOURCES
="yyacc.c"
283 MKJAMBASE_SOURCES
="mkjambase.c"
285 command.c compile.c constants.c debug.c execcmd.c frames.c function.c glob.c\
286 hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c\
287 object.c option.c output.c parse.c pathsys.c regexp.c rules.c\
288 scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c\
289 builtins.c class.c cwd.c native.c md5.c w32_getreg.c modules/set.c\
290 modules/path.c modules/regex.c modules/property-set.c modules/sequence.c\
292 case $BOOST_JAM_OS in
294 BJAM_SOURCES
="${BJAM_SOURCES} execnt.c filent.c pathnt.c"
298 BJAM_SOURCES
="${BJAM_SOURCES} execunix.c fileunix.c pathunix.c"
303 if test "$1" = "--update" -o "$2" = "--update" -o "$3" = "--update" -o "$4" = "--update" ; then
306 if test "${BJAM_UPDATE}" = "update" -a ! -x "./bootstrap/jam0" ; then
310 if test "${BJAM_UPDATE}" != "update" ; then
311 echo_run
rm -rf bootstrap
312 echo_run mkdir bootstrap
313 if test ! -r jamgram.y
-o ! -r jamgramtab.h
; then
314 echo_run
${BOOST_JAM_CC} ${BOOST_JAM_OPT_YYACC} ${YYACC_SOURCES}
315 if test -x "./bootstrap/yyacc0" ; then
316 echo_run .
/bootstrap
/yyacc0 jamgram.y jamgramtab.h jamgram.yy
319 if test ! -r jamgram.c
-o ! -r jamgram.h
; then
320 if test_path
yacc ; then YACC
="yacc -d"
321 elif test_path bison
; then YACC
="bison -y -d --yacc"
323 echo_run
$YACC jamgram.y
324 mv -f y.tab.c jamgram.c
325 mv -f y.tab.h jamgram.h
327 if test ! -r jambase.c
; then
328 echo_run
${BOOST_JAM_CC} ${BOOST_JAM_OPT_MKJAMBASE} ${MKJAMBASE_SOURCES}
329 if test -x "./bootstrap/mkjambase0" ; then
330 echo_run .
/bootstrap
/mkjambase0 jambase.c Jambase
333 echo_run
${BOOST_JAM_CC} ${BOOST_JAM_OPT_JAM} ${BJAM_SOURCES}
335 if test -x "./bootstrap/jam0" ; then
336 if test "${BJAM_UPDATE}" != "update" ; then
337 echo_run .
/bootstrap
/jam0
-f build.jam
--toolset=$BOOST_JAM_TOOLSET "--toolset-root=$BOOST_JAM_TOOLSET_ROOT" "$@" clean
339 echo_run .
/bootstrap
/jam0
-f build.jam
--toolset=$BOOST_JAM_TOOLSET "--toolset-root=$BOOST_JAM_TOOLSET_ROOT" "$@"