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)
11 # Run a command, and echo before doing so. Also checks the exit status and quits
12 # if there was an error.
18 if test $r -ne 0 ; then
23 # Print an error message, and exit with a status of 1.
29 echo "### You can specify the toolset as the argument, i.e.:"
30 echo "### ./build.sh gcc"
32 echo "### Toolsets supported by this script are:"
33 echo "### acc, como, darwin, gcc, intel-darwin, intel-linux, kcc, kylix,"
34 echo "### mipspro, mingw(msys), pathscale, pgi, qcc, sun, sunpro, tru64cxx, vacpp"
36 echo "### A special toolset; cc, is available which is used as a fallback"
37 echo "### when a more specific toolset is not found and the cc command is"
38 echo "### detected. The 'cc' toolset will use the CC, CFLAGS, and LIBS"
39 echo "### environment variables, if present."
44 # Check that a command is in the PATH.
47 if `command -v command 1>/dev/null 2>/dev/null`; then
48 command -v $1 1>/dev/null 2>/dev/null
50 hash $1 1>/dev/null 2>/dev/null
54 # Check that the OS name, as returned by "uname", is as given.
57 if test_path uname; then
62 # Try and guess the toolset to bootstrap the build with...
65 if test -r /mingw/bin/gcc ; then
66 BOOST_JAM_TOOLSET=mingw
67 BOOST_JAM_TOOLSET_ROOT=/mingw/
68 elif test_uname Darwin ; then BOOST_JAM_TOOLSET=darwin
69 elif test_uname IRIX ; then BOOST_JAM_TOOLSET=mipspro
70 elif test_uname IRIX64 ; then BOOST_JAM_TOOLSET=mipspro
71 elif test_uname OSF1 ; then BOOST_JAM_TOOLSET=tru64cxx
72 elif test_uname QNX && test_path qcc ; then BOOST_JAM_TOOLSET=qcc
73 elif test_path gcc ; then BOOST_JAM_TOOLSET=gcc
74 elif test_path icc ; then BOOST_JAM_TOOLSET=intel-linux
75 elif test -r /opt/intel/cc/9.0/bin/iccvars.sh ; then
76 BOOST_JAM_TOOLSET=intel-linux
77 BOOST_JAM_TOOLSET_ROOT=/opt/intel/cc/9.0
78 elif test -r /opt/intel_cc_80/bin/iccvars.sh ; then
79 BOOST_JAM_TOOLSET=intel-linux
80 BOOST_JAM_TOOLSET_ROOT=/opt/intel_cc_80
81 elif test -r /opt/intel/compiler70/ia32/bin/iccvars.sh ; then
82 BOOST_JAM_TOOLSET=intel-linux
83 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler70/ia32/
84 elif test -r /opt/intel/compiler60/ia32/bin/iccvars.sh ; then
85 BOOST_JAM_TOOLSET=intel-linux
86 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler60/ia32/
87 elif test -r /opt/intel/compiler50/ia32/bin/iccvars.sh ; then
88 BOOST_JAM_TOOLSET=intel-linux
89 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler50/ia32/
90 elif test_path pgcc ; then BOOST_JAM_TOOLSET=pgi
91 elif test_path pathcc ; then BOOST_JAM_TOOLSET=pathscale
92 elif test_path xlc ; then BOOST_JAM_TOOLSET=vacpp
93 elif test_path como ; then BOOST_JAM_TOOLSET=como
94 elif test_path KCC ; then BOOST_JAM_TOOLSET=kcc
95 elif test_path bc++ ; then BOOST_JAM_TOOLSET=kylix
96 elif test_path aCC ; then BOOST_JAM_TOOLSET=acc
97 elif test_uname HP-UX ; then BOOST_JAM_TOOLSET=acc
98 elif test -r /opt/SUNWspro/bin/cc ; then
99 BOOST_JAM_TOOLSET=sunpro
100 BOOST_JAM_TOOLSET_ROOT=/opt/SUNWspro/
101 # Test for "cc" as the default fallback.
102 elif test_path $CC ; then BOOST_JAM_TOOLSET=cc
103 elif test_path cc ; then
107 if test "$BOOST_JAM_TOOLSET" = "" ; then
108 error_exit "Could not find a suitable toolset."
112 # The one option we support in the invocation
113 # is the name of the toolset to force building
116 --guess-toolset) Guess_Toolset ; echo "$BOOST_JAM_TOOLSET" ; exit 1 ;;
118 ?*) BOOST_JAM_TOOLSET=$1 ; shift ;;
121 BOOST_JAM_OPT_JAM="-o bootstrap/jam0"
122 BOOST_JAM_OPT_MKJAMBASE="-o bootstrap/mkjambase0"
123 BOOST_JAM_OPT_YYACC="-o bootstrap/yyacc0"
124 case $BOOST_JAM_TOOLSET in
126 if test -r ${BOOST_JAM_TOOLSET_ROOT}bin/gcc ; then
127 export PATH=${BOOST_JAM_TOOLSET_ROOT}bin:$PATH
129 BOOST_JAM_CC="gcc -DNT"
145 if test -r /opt/intel/cc/9.0/bin/iccvars.sh ; then
146 BOOST_JAM_TOOLSET_ROOT=/opt/intel/cc/9.0/
147 elif test -r /opt/intel_cc_80/bin/iccvars.sh ; then
148 BOOST_JAM_TOOLSET_ROOT=/opt/intel_cc_80/
149 elif test -r /opt/intel/compiler70/ia32/bin/iccvars.sh ; then
150 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler70/ia32/
151 elif test -r /opt/intel/compiler60/ia32/bin/iccvars.sh ; then
152 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler60/ia32/
153 elif test -r /opt/intel/compiler50/ia32/bin/iccvars.sh ; then
154 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler50/ia32/
156 if test -r ${BOOST_JAM_TOOLSET_ROOT}bin/iccvars.sh ; then
157 # iccvars does not change LD_RUN_PATH. We adjust LD_RUN_PATH here in
158 # order not to have to rely on ld.so.conf knowing the icc library
159 # directory. We do this before running iccvars.sh in order to allow a
160 # user to add modifications to LD_RUN_PATH in iccvars.sh.
161 if test -z "${LD_RUN_PATH}"; then
162 LD_RUN_PATH="${BOOST_JAM_TOOLSET_ROOT}lib"
164 LD_RUN_PATH="${BOOST_JAM_TOOLSET_ROOT}lib:${LD_RUN_PATH}"
167 . ${BOOST_JAM_TOOLSET_ROOT}bin/iccvars.sh
177 BOOST_JAM_CC="como --c"
201 if test -z "${BOOST_JAM_TOOLSET_ROOT}" -a -r /opt/SUNWspro/bin/cc ; then
202 BOOST_JAM_TOOLSET_ROOT=/opt/SUNWspro/
204 if test -r "${BOOST_JAM_TOOLSET_ROOT}bin/cc" ; then
205 PATH=${BOOST_JAM_TOOLSET_ROOT}bin:${PATH}
212 BOOST_JAM_CC="clang -Wno-unused -Wno-format"
213 BOOST_JAM_TOOLSET=clang
221 BOOST_JAM_CC="cc -Ae"
225 if test -z "$CC" ; then CC=cc ; fi
227 BOOST_JAM_OPT_JAM="$BOOST_JAM_OPT_JAM $CFLAGS $LIBS"
228 BOOST_JAM_OPT_MKJAMBASE="$BOOST_JAM_OPT_MKJAMBASE $CFLAGS $LIBS"
229 BOOST_JAM_OPT_YYACC="$BOOST_JAM_OPT_YYACC $CFLAGS $LIBS"
237 error_exit "Unknown toolset: $BOOST_JAM_TOOLSET"
242 echo "### Using '$BOOST_JAM_TOOLSET' toolset."
245 YYACC_SOURCES="yyacc.c"
246 MKJAMBASE_SOURCES="mkjambase.c"
248 command.c compile.c constants.c debug.c execcmd.c frames.c function.c glob.c\
249 hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c\
250 object.c option.c output.c parse.c pathsys.c regexp.c rules.c\
251 scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c\
252 builtins.c class.c cwd.c native.c md5.c w32_getreg.c modules/set.c\
253 modules/path.c modules/regex.c modules/property-set.c modules/sequence.c\
255 case $BOOST_JAM_TOOLSET in
257 BJAM_SOURCES="${BJAM_SOURCES} execnt.c filent.c pathnt.c"
261 BJAM_SOURCES="${BJAM_SOURCES} execunix.c fileunix.c pathunix.c"
266 if test "$1" = "--update" -o "$2" = "--update" -o "$3" = "--update" -o "$4" = "--update" ; then
269 if test "${BJAM_UPDATE}" = "update" -a ! -x "./bootstrap/jam0" ; then
273 if test "${BJAM_UPDATE}" != "update" ; then
274 echo_run rm -rf bootstrap
275 echo_run mkdir bootstrap
276 if test ! -r jamgram.y -o ! -r jamgramtab.h ; then
277 echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_YYACC} ${YYACC_SOURCES}
278 if test -x "./bootstrap/yyacc0" ; then
279 echo_run ./bootstrap/yyacc0 jamgram.y jamgramtab.h jamgram.yy
282 if test ! -r jamgram.c -o ! -r jamgram.h ; then
283 if test_path yacc ; then YACC="yacc -d"
284 elif test_path bison ; then YACC="bison -y -d --yacc"
286 echo_run $YACC jamgram.y
287 mv -f y.tab.c jamgram.c
288 mv -f y.tab.h jamgram.h
290 if test ! -r jambase.c ; then
291 echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_MKJAMBASE} ${MKJAMBASE_SOURCES}
292 if test -x "./bootstrap/mkjambase0" ; then
293 echo_run ./bootstrap/mkjambase0 jambase.c Jambase
296 echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_JAM} ${BJAM_SOURCES}
298 if test -x "./bootstrap/jam0" ; then
299 if test "${BJAM_UPDATE}" != "update" ; then
300 echo_run ./bootstrap/jam0 -f build.jam --toolset=$BOOST_JAM_TOOLSET "--toolset-root=$BOOST_JAM_TOOLSET_ROOT" "$@" clean
302 echo_run ./bootstrap/jam0 -f build.jam --toolset=$BOOST_JAM_TOOLSET "--toolset-root=$BOOST_JAM_TOOLSET_ROOT" "$@"