Blame bootstrap.sh

Packit 58578d
#!/bin/sh
Packit 58578d
# Copyright (C) 2005, 2006 Douglas Gregor.
Packit 58578d
# Copyright (C) 2006 The Trustees of Indiana University
Packit 58578d
#
Packit 58578d
# Distributed under the Boost Software License, Version 1.0.
Packit 58578d
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
Packit 58578d
Packit 58578d
# boostinspect:notab - Tabs are required for the Makefile.
Packit 58578d
Packit 58578d
BJAM=""
Packit 58578d
TOOLSET=""
Packit 58578d
BJAM_CONFIG=""
Packit 58578d
BUILD=""
Packit 58578d
PREFIX=/usr/local
Packit 58578d
EPREFIX=
Packit 58578d
LIBDIR=
Packit 58578d
INCLUDEDIR=
Packit 58578d
LIBS=""
Packit 58578d
PYTHON=python
Packit 58578d
PYTHON_VERSION=
Packit 58578d
PYTHON_ROOT=
Packit 58578d
ICU_ROOT=
Packit 58578d
Packit 58578d
# Handle case where builtin shell version of echo command doesn't 
Packit 58578d
# support -n.  Use the installed echo executable if there is one 
Packit 58578d
# rather than builtin version to ensure -n is supported.
Packit 58578d
ECHO=`which echo`
Packit 58578d
if test "x$ECHO" = x; then
Packit 58578d
  ECHO=echo
Packit 58578d
fi
Packit 58578d
Packit 58578d
# Internal flags
Packit 58578d
flag_no_python=
Packit 58578d
flag_icu=
Packit 58578d
flag_show_libraries=
Packit 58578d
Packit 58578d
for option
Packit 58578d
do
Packit 58578d
    case $option in
Packit 58578d
Packit 58578d
    -help | --help | -h)
Packit 58578d
      want_help=yes ;;
Packit 58578d
Packit 58578d
    -prefix=* | --prefix=*)
Packit 58578d
      PREFIX=`expr "x$option" : "x-*prefix=\(.*\)"`
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -exec-prefix=* | --exec-prefix=*)
Packit 58578d
      EPREFIX=`expr "x$option" : "x-*exec-prefix=\(.*\)"`
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -libdir=* | --libdir=*)
Packit 58578d
      LIBDIR=`expr "x$option" : "x-*libdir=\(.*\)"`
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -includedir=* | --includedir=*)
Packit 58578d
      INCLUDEDIR=`expr "x$option" : "x-*includedir=\(.*\)"`
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -show-libraries | --show-libraries )
Packit 58578d
      flag_show_libraries=yes
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -with-bjam=* | --with-bjam=* )
Packit 58578d
      BJAM=`expr "x$option" : "x-*with-bjam=\(.*\)"`
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -with-icu | --with-icu )
Packit 58578d
      flag_icu=yes
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -with-icu=* | --with-icu=* )
Packit 58578d
      flag_icu=yes
Packit 58578d
      ICU_ROOT=`expr "x$option" : "x-*with-icu=\(.*\)"`
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -without-icu | --without-icu )
Packit 58578d
      flag_icu=no
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -with-libraries=* | --with-libraries=* )
Packit 58578d
      library_list=`expr "x$option" : "x-*with-libraries=\(.*\)"`
Packit 58578d
      if test "$library_list" != "all"; then
Packit 58578d
          old_IFS=$IFS
Packit 58578d
          IFS=,
Packit 58578d
          for library in $library_list
Packit 58578d
          do
Packit 58578d
              LIBS="$LIBS --with-$library"
Packit 58578d
Packit 58578d
              if test $library = python; then
Packit 58578d
                  requested_python=yes
Packit 58578d
              fi
Packit 58578d
          done
Packit 58578d
          IFS=$old_IFS
Packit 58578d
Packit 58578d
          if test "x$requested_python" != xyes; then
Packit 58578d
              flag_no_python=yes
Packit 58578d
          fi
Packit 58578d
      fi
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -without-libraries=* | --without-libraries=* )
Packit 58578d
      library_list=`expr "x$option" : "x-*without-libraries=\(.*\)"`
Packit 58578d
      old_IFS=$IFS
Packit 58578d
      IFS=,
Packit 58578d
      for library in $library_list
Packit 58578d
      do
Packit 58578d
          LIBS="$LIBS --without-$library"
Packit 58578d
Packit 58578d
          if test $library = python; then
Packit 58578d
              flag_no_python=yes
Packit 58578d
          fi
Packit 58578d
      done
Packit 58578d
      IFS=$old_IFS
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -with-python=* | --with-python=* )
Packit 58578d
      PYTHON=`expr "x$option" : "x-*with-python=\(.*\)"`
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -with-python-root=* | --with-python-root=* )
Packit 58578d
      PYTHON_ROOT=`expr "x$option" : "x-*with-python-root=\(.*\)"`
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -with-python-version=* | --with-python-version=* )
Packit 58578d
      PYTHON_VERSION=`expr "x$option" : "x-*with-python-version=\(.*\)"`
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -with-toolset=* | --with-toolset=* )
Packit 58578d
      TOOLSET=`expr "x$option" : "x-*with-toolset=\(.*\)"`
Packit 58578d
      ;;
Packit 58578d
Packit 58578d
    -*)
Packit 58578d
      { echo "error: unrecognized option: $option
Packit 58578d
Try \`$0 --help' for more information." >&2
Packit 58578d
      { (exit 1); exit 1; }; }
Packit 58578d
      ;; 
Packit 58578d
Packit 58578d
    esac
Packit 58578d
done
Packit 58578d
Packit 58578d
if test "x$want_help" = xyes; then
Packit 58578d
  cat <
Packit 58578d
\`./bootstrap.sh' prepares Boost for building on a few kinds of systems.
Packit 58578d
Packit 58578d
Usage: $0 [OPTION]... 
Packit 58578d
Packit 58578d
Defaults for the options are specified in brackets.
Packit 58578d
Packit 58578d
Configuration:
Packit 58578d
  -h, --help                display this help and exit
Packit 58578d
  --with-bjam=BJAM          use existing Boost.Jam executable (bjam)
Packit 58578d
                            [automatically built]
Packit 58578d
  --with-toolset=TOOLSET    use specific Boost.Build toolset
Packit 58578d
                            [automatically detected]
Packit 58578d
  --show-libraries          show the set of libraries that require build
Packit 58578d
                            and installation steps (i.e., those libraries
Packit 58578d
                            that can be used with --with-libraries or
Packit 58578d
                            --without-libraries), then exit
Packit 58578d
  --with-libraries=list     build only a particular set of libraries,
Packit 58578d
                            describing using either a comma-separated list of
Packit 58578d
                            library names or "all"
Packit 58578d
                            [all]
Packit 58578d
  --without-libraries=list  build all libraries except the ones listed []
Packit 58578d
  --with-icu                enable Unicode/ICU support in Regex 
Packit 58578d
                            [automatically detected]
Packit 58578d
  --without-icu             disable Unicode/ICU support in Regex
Packit 58578d
  --with-icu=DIR            specify the root of the ICU library installation
Packit 58578d
                            and enable Unicode/ICU support in Regex
Packit 58578d
                            [automatically detected]
Packit 58578d
  --with-python=PYTHON      specify the Python executable [python]
Packit 58578d
  --with-python-root=DIR    specify the root of the Python installation
Packit 58578d
                            [automatically detected]
Packit 58578d
  --with-python-version=X.Y specify the Python version as X.Y
Packit 58578d
                            [automatically detected]
Packit 58578d
Packit 58578d
Installation directories:
Packit 58578d
  --prefix=PREFIX           install Boost into the given PREFIX
Packit 58578d
                            [/usr/local]
Packit 58578d
  --exec-prefix=EPREFIX     install Boost binaries into the given EPREFIX
Packit 58578d
                            [PREFIX]
Packit 58578d
Packit 58578d
More precise control over installation directories:
Packit 58578d
  --libdir=DIR              install libraries here [EPREFIX/lib]
Packit 58578d
  --includedir=DIR          install headers here [PREFIX/include]
Packit 58578d
Packit 58578d
EOF
Packit 58578d
fi
Packit 58578d
test -n "$want_help" && exit 0
Packit 58578d
Packit 58578d
my_dir=$(dirname "$0")
Packit 58578d
Packit 58578d
# Determine the toolset, if not already decided
Packit 58578d
if test "x$TOOLSET" = x; then
Packit 58578d
  guessed_toolset=`$my_dir/tools/build/src/engine/build.sh --guess-toolset`
Packit 58578d
  case $guessed_toolset in
Packit 58578d
    acc | darwin | gcc | como | mipspro | pathscale | pgi | qcc | vacpp )
Packit 58578d
    TOOLSET=$guessed_toolset
Packit 58578d
    ;;
Packit 58578d
    
Packit 58578d
    intel-* )
Packit 58578d
    TOOLSET=intel
Packit 58578d
    ;;
Packit 58578d
    
Packit 58578d
    mingw )
Packit 58578d
    TOOLSET=gcc
Packit 58578d
    ;;
Packit 58578d
    
Packit 58578d
    sun* )
Packit 58578d
    TOOLSET=sun
Packit 58578d
    ;;
Packit 58578d
    
Packit 58578d
    * )
Packit 58578d
    # Not supported by Boost.Build
Packit 58578d
    ;;
Packit 58578d
  esac
Packit 58578d
fi
Packit 58578d
Packit 58578d
rm -f config.log
Packit 58578d
Packit 58578d
# Build bjam
Packit 58578d
if test "x$BJAM" = x; then
Packit 58578d
  $ECHO -n "Building Boost.Build engine with toolset $TOOLSET... "
Packit 58578d
  pwd=`pwd`
Packit 58578d
  (cd "$my_dir/tools/build/src/engine" && ./build.sh "$TOOLSET") > bootstrap.log 2>&1
Packit 58578d
  if [ $? -ne 0 ]; then
Packit 58578d
      echo
Packit 58578d
      echo "Failed to build Boost.Build build engine" 
Packit 58578d
      echo "Consult 'bootstrap.log' for more details"
Packit 58578d
      exit 1
Packit 58578d
  fi
Packit 58578d
  cd "$pwd"
Packit 58578d
  arch=`cd $my_dir/tools/build/src/engine && ./bootstrap/jam0 -d0 -f build.jam --toolset=$TOOLSET --toolset-root= --show-locate-target && cd ..`
Packit 58578d
  BJAM="$my_dir/tools/build/src/engine/$arch/b2"
Packit 58578d
  echo "tools/build/src/engine/$arch/b2"
Packit 58578d
  cp "$BJAM" .
Packit 58578d
  cp "$my_dir/tools/build/src/engine/$arch/bjam" .
Packit 58578d
Packit 58578d
fi
Packit 58578d
Packit 58578d
# TBD: Turn BJAM into an absolute path
Packit 58578d
Packit 58578d
# If there is a list of libraries 
Packit 58578d
if test "x$flag_show_libraries" = xyes; then
Packit 58578d
  cat <
Packit 58578d
Packit 58578d
The following Boost libraries have portions that require a separate build
Packit 58578d
and installation step. Any library not listed here can be used by including
Packit 58578d
the headers only.
Packit 58578d
Packit 58578d
The Boost libraries requiring separate building and installation are:
Packit 58578d
EOF
Packit 58578d
  $BJAM -d0 --show-libraries | grep '^[[:space:]]*-'
Packit 58578d
  exit 0
Packit 58578d
fi
Packit 58578d
Packit 58578d
# Setup paths
Packit 58578d
if test "x$EPREFIX" = x; then
Packit 58578d
  EPREFIX="$PREFIX"
Packit 58578d
fi
Packit 58578d
Packit 58578d
if test "x$LIBDIR" = x; then
Packit 58578d
  LIBDIR="$EPREFIX/lib"
Packit 58578d
fi
Packit 58578d
Packit 58578d
if test "x$INCLUDEDIR" = x; then
Packit 58578d
  INCLUDEDIR="$PREFIX/include"
Packit 58578d
fi
Packit 58578d
Packit 58578d
# Find Python
Packit 58578d
if test "x$flag_no_python" = x; then
Packit 58578d
  result=`$PYTHON -c "exit" > /dev/null 2>&1`
Packit 58578d
  if [ "$?" -ne "0" ]; then
Packit 58578d
    flag_no_python=yes
Packit 58578d
  fi
Packit 58578d
fi
Packit 58578d
Packit 58578d
if test "x$flag_no_python" = x; then
Packit 58578d
    if test "x$PYTHON_VERSION" = x; then
Packit 58578d
        $ECHO -n "Detecting Python version... "
Packit 58578d
        PYTHON_VERSION=`$PYTHON -c "import sys; print (\"%d.%d\" % (sys.version_info[0], sys.version_info[1]))"`
Packit 58578d
        echo $PYTHON_VERSION
Packit 58578d
    fi
Packit 58578d
Packit 58578d
    if test "x$PYTHON_ROOT" = x; then
Packit 58578d
        $ECHO -n "Detecting Python root... "
Packit 58578d
        PYTHON_ROOT=`$PYTHON -c "import sys; print(sys.prefix)"`
Packit 58578d
        echo $PYTHON_ROOT
Packit 58578d
    fi    
Packit 58578d
fi
Packit 58578d
Packit 58578d
# Configure ICU
Packit 58578d
$ECHO -n "Unicode/ICU support for Boost.Regex?... "
Packit 58578d
if test "x$flag_icu" != xno; then
Packit 58578d
  if test "x$ICU_ROOT" = x; then
Packit 58578d
    COMMON_ICU_PATHS="/usr /usr/local /sw"
Packit 58578d
    for p in $COMMON_ICU_PATHS; do
Packit 58578d
      if test -r $p/include/unicode/utypes.h; then
Packit 58578d
        ICU_ROOT=$p
Packit 58578d
      fi
Packit 58578d
    done
Packit 58578d
  
Packit 58578d
    if test "x$ICU_ROOT" = x; then
Packit 58578d
      echo "not found."
Packit 58578d
    else      
Packit 58578d
      BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT"
Packit 58578d
      echo "$ICU_ROOT"
Packit 58578d
    fi
Packit 58578d
  else
Packit 58578d
    BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT"
Packit 58578d
    echo "$ICU_ROOT"
Packit 58578d
  fi
Packit 58578d
else
Packit 58578d
  echo "disabled."
Packit 58578d
fi
Packit 58578d
Packit 58578d
# Backup the user's existing project-config.jam
Packit 58578d
JAM_CONFIG_OUT="project-config.jam"
Packit 58578d
if test -r "project-config.jam"; then
Packit 58578d
  counter=1
Packit 58578d
 
Packit 58578d
  while test -r "project-config.jam.$counter"; do
Packit 58578d
    counter=`expr $counter + 1`
Packit 58578d
  done
Packit 58578d
Packit 58578d
  echo "Backing up existing Boost.Build configuration in project-config.jam.$counter"
Packit 58578d
  mv "project-config.jam" "project-config.jam.$counter"
Packit 58578d
fi
Packit 58578d
Packit 58578d
# Generate user-config.jam
Packit 58578d
echo "Generating Boost.Build configuration in project-config.jam..."
Packit 58578d
cat > project-config.jam <
Packit 58578d
# Boost.Build Configuration
Packit 58578d
# Automatically generated by bootstrap.sh
Packit 58578d
Packit 58578d
import option ;
Packit 58578d
import feature ;
Packit 58578d
Packit 58578d
# Compiler configuration. This definition will be used unless
Packit 58578d
# you already have defined some toolsets in your user-config.jam
Packit 58578d
# file.
Packit 58578d
if ! $TOOLSET in [ feature.values <toolset> ]
Packit 58578d
{
Packit 58578d
    using $TOOLSET ; 
Packit 58578d
}
Packit 58578d
Packit 58578d
project : default-build <toolset>$TOOLSET ;
Packit 58578d
EOF
Packit 58578d
Packit 58578d
#  - Python configuration
Packit 58578d
if test "x$flag_no_python" = x; then
Packit 58578d
  cat >> project-config.jam <
Packit 58578d
Packit 58578d
# Python configuration
Packit 58578d
import python ;
Packit 58578d
if ! [ python.configured ]
Packit 58578d
{
Packit 58578d
    using python : $PYTHON_VERSION : $PYTHON_ROOT ;
Packit 58578d
}
Packit 58578d
EOF
Packit 58578d
fi
Packit 58578d
Packit 58578d
if test "x$ICU_ROOT" != x; then
Packit 58578d
  cat >> project-config.jam << EOF
Packit 58578d
Packit 58578d
path-constant ICU_PATH : $ICU_ROOT ;
Packit 58578d
Packit 58578d
EOF
Packit 58578d
fi
Packit 58578d
Packit 58578d
cat >> project-config.jam << EOF
Packit 58578d
Packit 58578d
# List of --with-<library> and --without-<library>
Packit 58578d
# options. If left empty, all libraries will be built.
Packit 58578d
# Options specified on the command line completely
Packit 58578d
# override this variable.
Packit 58578d
libraries = $LIBS ;
Packit 58578d
Packit 58578d
# These settings are equivivalent to corresponding command-line
Packit 58578d
# options.
Packit 58578d
option.set prefix : $PREFIX ;
Packit 58578d
option.set exec-prefix : $EPREFIX ;
Packit 58578d
option.set libdir : $LIBDIR ;
Packit 58578d
option.set includedir : $INCLUDEDIR ;
Packit 58578d
Packit 58578d
# Stop on first error
Packit 58578d
option.set keep-going : false ;
Packit 58578d
EOF
Packit 58578d
Packit 58578d
cat << EOF
Packit 58578d
Packit 58578d
Bootstrapping is done. To build, run:
Packit 58578d
Packit 58578d
    ./b2
Packit 58578d
    
Packit 58578d
To adjust configuration, edit 'project-config.jam'.
Packit 58578d
Further information:
Packit 58578d
Packit 58578d
   - Command line help:
Packit 58578d
     ./b2 --help
Packit 58578d
     
Packit 58578d
   - Getting started guide: 
Packit 58578d
     http://www.boost.org/more/getting_started/unix-variants.html
Packit 58578d
     
Packit 58578d
   - Boost.Build documentation:
Packit 58578d
     http://www.boost.org/build/doc/html/index.html
Packit 58578d
Packit 58578d
EOF