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