1#!/bin/sh 2# Copyright (C) 2005, 2006 Douglas Gregor. 3# Copyright (C) 2006 The Trustees of Indiana University 4# 5# Distributed under the Boost Software License, Version 1.0. 6# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 7 8# boostinspect:notab - Tabs are required for the Makefile. 9 10BJAM="" 11TOOLSET="" 12BJAM_CONFIG="" 13BUILD="" 14PREFIX=/usr/local 15EPREFIX= 16LIBDIR= 17INCLUDEDIR= 18LIBS="" 19PYTHON=python 20PYTHON_VERSION= 21PYTHON_ROOT= 22ICU_ROOT= 23 24# Handle case where builtin shell version of echo command doesn't 25# support -n. Use the installed echo executable if there is one 26# rather than builtin version to ensure -n is supported. 27ECHO=`which echo` 28if test "x$ECHO" = x; then 29 ECHO=echo 30fi 31 32# Internal flags 33flag_no_python= 34flag_icu= 35flag_show_libraries= 36 37for option 38do 39 case $option in 40 41 -help | --help | -h) 42 want_help=yes ;; 43 44 -prefix=* | --prefix=*) 45 PREFIX=`expr "x$option" : "x-*prefix=\(.*\)"` 46 ;; 47 48 -exec-prefix=* | --exec-prefix=*) 49 EPREFIX=`expr "x$option" : "x-*exec-prefix=\(.*\)"` 50 ;; 51 52 -libdir=* | --libdir=*) 53 LIBDIR=`expr "x$option" : "x-*libdir=\(.*\)"` 54 ;; 55 56 -includedir=* | --includedir=*) 57 INCLUDEDIR=`expr "x$option" : "x-*includedir=\(.*\)"` 58 ;; 59 60 -show-libraries | --show-libraries ) 61 flag_show_libraries=yes 62 ;; 63 64 -with-bjam=* | --with-bjam=* ) 65 BJAM=`expr "x$option" : "x-*with-bjam=\(.*\)"` 66 ;; 67 68 -with-icu | --with-icu ) 69 flag_icu=yes 70 ;; 71 72 -with-icu=* | --with-icu=* ) 73 flag_icu=yes 74 ICU_ROOT=`expr "x$option" : "x-*with-icu=\(.*\)"` 75 ;; 76 77 -without-icu | --without-icu ) 78 flag_icu=no 79 ;; 80 81 -with-libraries=* | --with-libraries=* ) 82 library_list=`expr "x$option" : "x-*with-libraries=\(.*\)"` 83 if test "$library_list" != "all"; then 84 old_IFS=$IFS 85 IFS=, 86 for library in $library_list 87 do 88 LIBS="$LIBS --with-$library" 89 90 if test $library = python; then 91 requested_python=yes 92 fi 93 done 94 IFS=$old_IFS 95 96 if test "x$requested_python" != xyes; then 97 flag_no_python=yes 98 fi 99 fi 100 ;; 101 102 -without-libraries=* | --without-libraries=* ) 103 library_list=`expr "x$option" : "x-*without-libraries=\(.*\)"` 104 old_IFS=$IFS 105 IFS=, 106 for library in $library_list 107 do 108 LIBS="$LIBS --without-$library" 109 110 if test $library = python; then 111 flag_no_python=yes 112 fi 113 done 114 IFS=$old_IFS 115 ;; 116 117 -with-python=* | --with-python=* ) 118 PYTHON=`expr "x$option" : "x-*with-python=\(.*\)"` 119 ;; 120 121 -with-python-root=* | --with-python-root=* ) 122 PYTHON_ROOT=`expr "x$option" : "x-*with-python-root=\(.*\)"` 123 ;; 124 125 -with-python-version=* | --with-python-version=* ) 126 PYTHON_VERSION=`expr "x$option" : "x-*with-python-version=\(.*\)"` 127 ;; 128 129 -with-toolset=* | --with-toolset=* ) 130 TOOLSET=`expr "x$option" : "x-*with-toolset=\(.*\)"` 131 ;; 132 133 -*) 134 { echo "error: unrecognized option: $option 135Try \`$0 --help' for more information." >&2 136 { (exit 1); exit 1; }; } 137 ;; 138 139 esac 140done 141 142if test "x$want_help" = xyes; then 143 cat <<EOF 144\`./bootstrap.sh' prepares Boost for building on a few kinds of systems. 145 146Usage: $0 [OPTION]... 147 148Defaults for the options are specified in brackets. 149 150Configuration: 151 -h, --help display this help and exit 152 --with-bjam=BJAM use existing Boost.Jam executable (bjam) 153 [automatically built] 154 --with-toolset=TOOLSET use specific Boost.Build toolset 155 [automatically detected] 156 --show-libraries show the set of libraries that require build 157 and installation steps (i.e., those libraries 158 that can be used with --with-libraries or 159 --without-libraries), then exit 160 --with-libraries=list build only a particular set of libraries, 161 describing using either a comma-separated list of 162 library names or "all" 163 [all] 164 --without-libraries=list build all libraries except the ones listed [] 165 --with-icu enable Unicode/ICU support in Regex 166 [automatically detected] 167 --without-icu disable Unicode/ICU support in Regex 168 --with-icu=DIR specify the root of the ICU library installation 169 and enable Unicode/ICU support in Regex 170 [automatically detected] 171 --with-python=PYTHON specify the Python executable [python] 172 --with-python-root=DIR specify the root of the Python installation 173 [automatically detected] 174 --with-python-version=X.Y specify the Python version as X.Y 175 [automatically detected] 176 177Installation directories: 178 --prefix=PREFIX install Boost into the given PREFIX 179 [/usr/local] 180 --exec-prefix=EPREFIX install Boost binaries into the given EPREFIX 181 [PREFIX] 182 183More precise control over installation directories: 184 --libdir=DIR install libraries here [EPREFIX/lib] 185 --includedir=DIR install headers here [PREFIX/include] 186 187EOF 188fi 189test -n "$want_help" && exit 0 190 191# TBD: Determine where the script is located 192my_dir="." 193 194# Determine the toolset, if not already decided 195if test "x$TOOLSET" = x; then 196 guessed_toolset=`$my_dir/tools/build/src/engine/build.sh --guess-toolset` 197 case $guessed_toolset in 198 acc | darwin | gcc | como | mipspro | pathscale | pgi | qcc | vacpp ) 199 TOOLSET=$guessed_toolset 200 ;; 201 202 intel-* ) 203 TOOLSET=intel 204 ;; 205 206 mingw ) 207 TOOLSET=gcc 208 ;; 209 210 sun* ) 211 TOOLSET=sun 212 ;; 213 214 * ) 215 # Not supported by Boost.Build 216 ;; 217 esac 218fi 219 220rm -f config.log 221 222# Build bjam 223if test "x$BJAM" = x; then 224 $ECHO -n "Building Boost.Build engine with toolset $TOOLSET... " 225 pwd=`pwd` 226 (cd "$my_dir/tools/build/src/engine" && ./build.sh "$TOOLSET") > bootstrap.log 2>&1 227 if [ $? -ne 0 ]; then 228 echo 229 echo "Failed to build Boost.Build build engine" 230 echo "Consult 'bootstrap.log' for more details" 231 exit 1 232 fi 233 cd "$pwd" 234 arch=`cd $my_dir/tools/build/src/engine && ./bootstrap/jam0 -d0 -f build.jam --toolset=$TOOLSET --toolset-root= --show-locate-target && cd ..` 235 BJAM="$my_dir/tools/build/src/engine/$arch/b2" 236 echo "tools/build/src/engine/$arch/b2" 237 cp "$BJAM" . 238 cp "$my_dir/tools/build/src/engine/$arch/bjam" . 239 240fi 241 242# TBD: Turn BJAM into an absolute path 243 244# If there is a list of libraries 245if test "x$flag_show_libraries" = xyes; then 246 cat <<EOF 247 248The following Boost libraries have portions that require a separate build 249and installation step. Any library not listed here can be used by including 250the headers only. 251 252The Boost libraries requiring separate building and installation are: 253EOF 254 $BJAM -d0 --show-libraries | grep '^[[:space:]]*-' 255 exit 0 256fi 257 258# Setup paths 259if test "x$EPREFIX" = x; then 260 EPREFIX="$PREFIX" 261fi 262 263if test "x$LIBDIR" = x; then 264 LIBDIR="$EPREFIX/lib" 265fi 266 267if test "x$INCLUDEDIR" = x; then 268 INCLUDEDIR="$PREFIX/include" 269fi 270 271# Find Python 272if test "x$flag_no_python" = x; then 273 result=`$PYTHON -c "exit" > /dev/null 2>&1` 274 if [ "$?" -ne "0" ]; then 275 flag_no_python=yes 276 fi 277fi 278 279if test "x$flag_no_python" = x; then 280 if test "x$PYTHON_VERSION" = x; then 281 $ECHO -n "Detecting Python version... " 282 PYTHON_VERSION=`$PYTHON -c "import sys; print (\"%d.%d\" % (sys.version_info[0], sys.version_info[1]))"` 283 echo $PYTHON_VERSION 284 fi 285 286 if test "x$PYTHON_ROOT" = x; then 287 $ECHO -n "Detecting Python root... " 288 PYTHON_ROOT=`$PYTHON -c "import sys; print(sys.prefix)"` 289 echo $PYTHON_ROOT 290 fi 291fi 292 293# Configure ICU 294$ECHO -n "Unicode/ICU support for Boost.Regex?... " 295if test "x$flag_icu" != xno; then 296 if test "x$ICU_ROOT" = x; then 297 COMMON_ICU_PATHS="/usr /usr/local /sw" 298 for p in $COMMON_ICU_PATHS; do 299 if test -r $p/include/unicode/utypes.h; then 300 ICU_ROOT=$p 301 fi 302 done 303 304 if test "x$ICU_ROOT" = x; then 305 echo "not found." 306 else 307 BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT" 308 echo "$ICU_ROOT" 309 fi 310 else 311 BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT" 312 echo "$ICU_ROOT" 313 fi 314else 315 echo "disabled." 316fi 317 318# Backup the user's existing project-config.jam 319JAM_CONFIG_OUT="project-config.jam" 320if test -r "project-config.jam"; then 321 counter=1 322 323 while test -r "project-config.jam.$counter"; do 324 counter=`expr $counter + 1` 325 done 326 327 echo "Backing up existing Boost.Build configuration in project-config.jam.$counter" 328 mv "project-config.jam" "project-config.jam.$counter" 329fi 330 331# Generate user-config.jam 332echo "Generating Boost.Build configuration in project-config.jam..." 333cat > project-config.jam <<EOF 334# Boost.Build Configuration 335# Automatically generated by bootstrap.sh 336 337import option ; 338import feature ; 339 340# Compiler configuration. This definition will be used unless 341# you already have defined some toolsets in your user-config.jam 342# file. 343if ! $TOOLSET in [ feature.values <toolset> ] 344{ 345 using $TOOLSET ; 346} 347 348project : default-build <toolset>$TOOLSET ; 349EOF 350 351# - Python configuration 352if test "x$flag_no_python" = x; then 353 cat >> project-config.jam <<EOF 354 355# Python configuration 356import python ; 357if ! [ python.configured ] 358{ 359 using python : $PYTHON_VERSION : $PYTHON_ROOT ; 360} 361EOF 362fi 363 364if test "x$ICU_ROOT" != x; then 365 cat >> project-config.jam << EOF 366 367path-constant ICU_PATH : $ICU_ROOT ; 368 369EOF 370fi 371 372cat >> project-config.jam << EOF 373 374# List of --with-<library> and --without-<library> 375# options. If left empty, all libraries will be built. 376# Options specified on the command line completely 377# override this variable. 378libraries = $LIBS ; 379 380# These settings are equivivalent to corresponding command-line 381# options. 382option.set prefix : $PREFIX ; 383option.set exec-prefix : $EPREFIX ; 384option.set libdir : $LIBDIR ; 385option.set includedir : $INCLUDEDIR ; 386 387# Stop on first error 388option.set keep-going : false ; 389EOF 390 391cat << EOF 392 393Bootstrapping is done. To build, run: 394 395 ./b2 396 397To adjust configuration, edit 'project-config.jam'. 398Further information: 399 400 - Command line help: 401 ./b2 --help 402 403 - Getting started guide: 404 http://www.boost.org/more/getting_started/unix-variants.html 405 406 - Boost.Build documentation: 407 http://www.boost.org/build/doc/html/index.html 408 409EOF 410