1#!/bin/sh 2 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) 7 8# Reset the toolset. 9BOOST_JAM_TOOLSET= 10 11# Run a command, and echo before doing so. Also checks the exit status and quits 12# if there was an error. 13echo_run () 14{ 15 echo "$@" 16 $@ 17 r=$? 18 if test $r -ne 0 ; then 19 exit $r 20 fi 21} 22 23# Print an error message, and exit with a status of 1. 24error_exit () 25{ 26 echo "###" 27 echo "###" "$@" 28 echo "###" 29 echo "### You can specify the toolset as the argument, i.e.:" 30 echo "### ./build.sh gcc" 31 echo "###" 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" 35 echo "###" 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." 40 echo "###" 41 exit 1 42} 43 44# Check that a command is in the PATH. 45test_path () 46{ 47 if `command -v command 1>/dev/null 2>/dev/null`; then 48 command -v $1 1>/dev/null 2>/dev/null 49 else 50 hash $1 1>/dev/null 2>/dev/null 51 fi 52} 53 54# Check that the OS name, as returned by "uname", is as given. 55test_uname () 56{ 57 if test_path uname; then 58 test `uname` = $* 59 fi 60} 61 62# Try and guess the toolset to bootstrap the build with... 63Guess_Toolset () 64{ 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_uname Linux && test_path xlc; then 74 if /usr/bin/lscpu | grep Byte | grep Little > /dev/null 2>&1 ; then 75 # Little endian linux 76 BOOST_JAM_TOOLSET=xlcpp 77 else 78 #Big endian linux 79 BOOST_JAM_TOOLSET=vacpp 80 fi 81 elif test_uname AIX && test_path xlc; then BOOST_JAM_TOOLSET=vacpp 82 elif test_path gcc ; then BOOST_JAM_TOOLSET=gcc 83 elif test_path icc ; then BOOST_JAM_TOOLSET=intel-linux 84 elif test -r /opt/intel/cc/9.0/bin/iccvars.sh ; then 85 BOOST_JAM_TOOLSET=intel-linux 86 BOOST_JAM_TOOLSET_ROOT=/opt/intel/cc/9.0 87 elif test -r /opt/intel_cc_80/bin/iccvars.sh ; then 88 BOOST_JAM_TOOLSET=intel-linux 89 BOOST_JAM_TOOLSET_ROOT=/opt/intel_cc_80 90 elif test -r /opt/intel/compiler70/ia32/bin/iccvars.sh ; then 91 BOOST_JAM_TOOLSET=intel-linux 92 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler70/ia32/ 93 elif test -r /opt/intel/compiler60/ia32/bin/iccvars.sh ; then 94 BOOST_JAM_TOOLSET=intel-linux 95 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler60/ia32/ 96 elif test -r /opt/intel/compiler50/ia32/bin/iccvars.sh ; then 97 BOOST_JAM_TOOLSET=intel-linux 98 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler50/ia32/ 99 elif test_path pgcc ; then BOOST_JAM_TOOLSET=pgi 100 elif test_path pathcc ; then BOOST_JAM_TOOLSET=pathscale 101 elif test_path como ; then BOOST_JAM_TOOLSET=como 102 elif test_path KCC ; then BOOST_JAM_TOOLSET=kcc 103 elif test_path bc++ ; then BOOST_JAM_TOOLSET=kylix 104 elif test_path aCC ; then BOOST_JAM_TOOLSET=acc 105 elif test_uname HP-UX ; then BOOST_JAM_TOOLSET=acc 106 elif test -r /opt/SUNWspro/bin/cc ; then 107 BOOST_JAM_TOOLSET=sunpro 108 BOOST_JAM_TOOLSET_ROOT=/opt/SUNWspro/ 109 # Test for "cc" as the default fallback. 110 elif test_path $CC ; then BOOST_JAM_TOOLSET=cc 111 elif test_path cc ; then 112 BOOST_JAM_TOOLSET=cc 113 CC=cc 114 fi 115 if test "$BOOST_JAM_TOOLSET" = "" ; then 116 error_exit "Could not find a suitable toolset." 117 fi 118} 119 120# The one option we support in the invocation 121# is the name of the toolset to force building 122# with. 123case "$1" in 124 --guess-toolset) Guess_Toolset ; echo "$BOOST_JAM_TOOLSET" ; exit 1 ;; 125 -*) Guess_Toolset ;; 126 ?*) BOOST_JAM_TOOLSET=$1 ; shift ;; 127 *) Guess_Toolset ;; 128esac 129BOOST_JAM_OPT_JAM="-o bootstrap/jam0" 130BOOST_JAM_OPT_MKJAMBASE="-o bootstrap/mkjambase0" 131BOOST_JAM_OPT_YYACC="-o bootstrap/yyacc0" 132case $BOOST_JAM_TOOLSET in 133 mingw) 134 if test -r ${BOOST_JAM_TOOLSET_ROOT}bin/gcc ; then 135 export PATH=${BOOST_JAM_TOOLSET_ROOT}bin:$PATH 136 fi 137 BOOST_JAM_CC="gcc -DNT" 138 ;; 139 140 gcc) 141 BOOST_JAM_CC=gcc 142 ;; 143 144 darwin) 145 BOOST_JAM_CC=cc 146 ;; 147 148 intel-darwin) 149 BOOST_JAM_CC=icc 150 ;; 151 152 intel-linux) 153 test_path icc >/dev/null 2>&1 154 if test $? ; then 155 BOOST_JAM_CC=`test_path icc` 156 echo "Found $BOOST_JAM_CC in environment" 157 BOOST_JAM_TOOLSET_ROOT=`echo $BOOST_JAM_CC | sed -e 's/bin.*\/icc//'` 158 # probably the most widespread 159 ARCH=intel64 160 else 161 echo "No intel compiler in current path" 162 echo "Look in a few old place for legacy reason" 163 if test -r /opt/intel/cc/9.0/bin/iccvars.sh ; then 164 BOOST_JAM_TOOLSET_ROOT=/opt/intel/cc/9.0/ 165 elif test -r /opt/intel_cc_80/bin/iccvars.sh ; then 166 BOOST_JAM_TOOLSET_ROOT=/opt/intel_cc_80/ 167 elif test -r /opt/intel/compiler70/ia32/bin/iccvars.sh ; then 168 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler70/ia32/ 169 elif test -r /opt/intel/compiler60/ia32/bin/iccvars.sh ; then 170 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler60/ia32/ 171 elif test -r /opt/intel/compiler50/ia32/bin/iccvars.sh ; then 172 BOOST_JAM_TOOLSET_ROOT=/opt/intel/compiler50/ia32/ 173 fi 174 fi 175 if test -r ${BOOST_JAM_TOOLSET_ROOT}bin/iccvars.sh ; then 176 # iccvars does not change LD_RUN_PATH. We adjust LD_RUN_PATH here in 177 # order not to have to rely on ld.so.conf knowing the icc library 178 # directory. We do this before running iccvars.sh in order to allow a 179 # user to add modifications to LD_RUN_PATH in iccvars.sh. 180 if test -z "${LD_RUN_PATH}"; then 181 LD_RUN_PATH="${BOOST_JAM_TOOLSET_ROOT}lib" 182 else 183 LD_RUN_PATH="${BOOST_JAM_TOOLSET_ROOT}lib:${LD_RUN_PATH}" 184 fi 185 export LD_RUN_PATH 186 . ${BOOST_JAM_TOOLSET_ROOT}bin/iccvars.sh $ARCH 187 fi 188 if test -z "$BOOST_JAM_CC" ; then 189 BOOST_JAM_CC=icc 190 fi 191 ;; 192 193 vacpp) 194 BOOST_JAM_CC=xlc 195 ;; 196 197 xlcpp) 198 BOOST_JAM_CC=xlc 199 ;; 200 201 como) 202 BOOST_JAM_CC="como --c" 203 ;; 204 205 kcc) 206 BOOST_JAM_CC=KCC 207 ;; 208 209 kylix) 210 BOOST_JAM_CC=bc++ 211 ;; 212 213 mipspro) 214 BOOST_JAM_CC=cc 215 ;; 216 217 pathscale) 218 BOOST_JAM_CC=pathcc 219 ;; 220 221 pgi) 222 BOOST_JAM_CC=pgcc 223 ;; 224 225 sun*) 226 if test -z "${BOOST_JAM_TOOLSET_ROOT}" -a -r /opt/SUNWspro/bin/cc ; then 227 BOOST_JAM_TOOLSET_ROOT=/opt/SUNWspro/ 228 fi 229 if test -r "${BOOST_JAM_TOOLSET_ROOT}bin/cc" ; then 230 PATH=${BOOST_JAM_TOOLSET_ROOT}bin:${PATH} 231 export PATH 232 fi 233 BOOST_JAM_CC=cc 234 ;; 235 236 clang*) 237 BOOST_JAM_CC="clang -Wno-unused -Wno-format" 238 BOOST_JAM_TOOLSET=clang 239 ;; 240 241 tru64cxx) 242 BOOST_JAM_CC=cc 243 ;; 244 245 acc) 246 BOOST_JAM_CC="cc -Ae" 247 ;; 248 249 cc) 250 if test -z "$CC" ; then CC=cc ; fi 251 BOOST_JAM_CC=$CC 252 BOOST_JAM_OPT_JAM="$BOOST_JAM_OPT_JAM $CFLAGS $LIBS" 253 BOOST_JAM_OPT_MKJAMBASE="$BOOST_JAM_OPT_MKJAMBASE $CFLAGS $LIBS" 254 BOOST_JAM_OPT_YYACC="$BOOST_JAM_OPT_YYACC $CFLAGS $LIBS" 255 ;; 256 257 qcc) 258 BOOST_JAM_CC=qcc 259 ;; 260 261 *) 262 error_exit "Unknown toolset: $BOOST_JAM_TOOLSET" 263 ;; 264esac 265 266echo "###" 267echo "### Using '$BOOST_JAM_TOOLSET' toolset." 268echo "###" 269 270YYACC_SOURCES="yyacc.c" 271MKJAMBASE_SOURCES="mkjambase.c" 272BJAM_SOURCES="\ 273 command.c compile.c constants.c debug.c execcmd.c frames.c function.c glob.c\ 274 hash.c hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c\ 275 object.c option.c output.c parse.c pathsys.c regexp.c rules.c\ 276 scan.c search.c subst.c timestamp.c variable.c modules.c strings.c filesys.c\ 277 builtins.c class.c cwd.c native.c md5.c w32_getreg.c modules/set.c\ 278 modules/path.c modules/regex.c modules/property-set.c modules/sequence.c\ 279 modules/order.c" 280case $BOOST_JAM_TOOLSET in 281 mingw) 282 BJAM_SOURCES="${BJAM_SOURCES} execnt.c filent.c pathnt.c" 283 ;; 284 285 *) 286 BJAM_SOURCES="${BJAM_SOURCES} execunix.c fileunix.c pathunix.c" 287 ;; 288esac 289 290BJAM_UPDATE= 291if test "$1" = "--update" -o "$2" = "--update" -o "$3" = "--update" -o "$4" = "--update" ; then 292 BJAM_UPDATE="update" 293fi 294if test "${BJAM_UPDATE}" = "update" -a ! -x "./bootstrap/jam0" ; then 295 BJAM_UPDATE= 296fi 297 298if test "${BJAM_UPDATE}" != "update" ; then 299 echo_run rm -rf bootstrap 300 echo_run mkdir bootstrap 301 if test ! -r jamgram.y -o ! -r jamgramtab.h ; then 302 echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_YYACC} ${YYACC_SOURCES} 303 if test -x "./bootstrap/yyacc0" ; then 304 echo_run ./bootstrap/yyacc0 jamgram.y jamgramtab.h jamgram.yy 305 fi 306 fi 307 if test ! -r jamgram.c -o ! -r jamgram.h ; then 308 if test_path yacc ; then YACC="yacc -d" 309 elif test_path bison ; then YACC="bison -y -d --yacc" 310 fi 311 echo_run $YACC jamgram.y 312 mv -f y.tab.c jamgram.c 313 mv -f y.tab.h jamgram.h 314 fi 315 if test ! -r jambase.c ; then 316 echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_MKJAMBASE} ${MKJAMBASE_SOURCES} 317 if test -x "./bootstrap/mkjambase0" ; then 318 echo_run ./bootstrap/mkjambase0 jambase.c Jambase 319 fi 320 fi 321 echo_run ${BOOST_JAM_CC} ${BOOST_JAM_OPT_JAM} ${BJAM_SOURCES} 322fi 323if test -x "./bootstrap/jam0" ; then 324 if test "${BJAM_UPDATE}" != "update" ; then 325 echo_run ./bootstrap/jam0 -f build.jam --toolset=$BOOST_JAM_TOOLSET "--toolset-root=$BOOST_JAM_TOOLSET_ROOT" "$@" clean 326 fi 327 echo_run ./bootstrap/jam0 -f build.jam --toolset=$BOOST_JAM_TOOLSET "--toolset-root=$BOOST_JAM_TOOLSET_ROOT" "$@" 328fi 329