]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/bootstrap.sh
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / bootstrap.sh
1 #!/bin/sh
2 # Copyright 2019-2020 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
11 BJAM=""
12 TOOLSET=""
13 BJAM_CONFIG=""
14 BUILD=""
15 PREFIX=/usr/local
16 EPREFIX=
17 LIBDIR=
18 INCLUDEDIR=
19 LIBS=""
20 PYTHON=python
21 PYTHON_VERSION=
22 PYTHON_ROOT=
23 ICU_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.
28 ECHO=`which echo`
29 if test "x$ECHO" = x; then
30 ECHO=echo
31 fi
32
33 # Internal flags
34 flag_no_python=
35 flag_icu=
36 flag_show_libraries=
37
38 for option
39 do
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
136 Try \`$0 --help' for more information." >&2
137 { (exit 1); exit 1; }; }
138 ;;
139
140 esac
141 done
142
143 if test "x$want_help" = xyes; then
144 cat <<EOF
145 \`./bootstrap.sh' prepares Boost for building on a few kinds of systems.
146
147 Usage: $0 [OPTION]...
148
149 Defaults for the options are specified in brackets.
150
151 Configuration:
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 B2 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
178 Installation 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
184 More precise control over installation directories:
185 --libdir=DIR install libraries here [EPREFIX/lib]
186 --includedir=DIR install headers here [PREFIX/include]
187
188 EOF
189 fi
190 test -n "$want_help" && exit 0
191
192 my_dir=$(dirname "$0")
193
194 # Determine the toolset, if not already decided
195 if 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 B2
216 ;;
217 esac
218 fi
219
220 rm -f config.log
221
222 # Build bjam
223 if test "x$BJAM" = x; then
224 $ECHO "Building B2 engine.."
225 pwd=`pwd`
226 (cd "$my_dir/tools/build/src/engine" && ./build.sh)
227 if [ $? -ne 0 ]; then
228 echo
229 echo "Failed to build B2 build engine"
230 exit 1
231 fi
232 cd "$pwd"
233 BJAM="$my_dir/tools/build/src/engine/b2"
234 echo "tools/build/src/engine/b2"
235 cp "$BJAM" .
236
237 fi
238
239 # TBD: Turn BJAM into an absolute path
240
241 # If there is a list of libraries
242 if test "x$flag_show_libraries" = xyes; then
243 cat <<EOF
244
245 The following Boost libraries have portions that require a separate build
246 and installation step. Any library not listed here can be used by including
247 the headers only.
248
249 The Boost libraries requiring separate building and installation are:
250 EOF
251 $BJAM -d0 --show-libraries | grep '^[[:space:]]*-'
252 exit 0
253 fi
254
255 # Setup paths
256 if test "x$EPREFIX" = x; then
257 EPREFIX="$PREFIX"
258 fi
259
260 if test "x$LIBDIR" = x; then
261 LIBDIR="$EPREFIX/lib"
262 fi
263
264 if test "x$INCLUDEDIR" = x; then
265 INCLUDEDIR="$PREFIX/include"
266 fi
267
268 # Find Python
269 if test "x$flag_no_python" = x; then
270 result=`$PYTHON -c "exit" > /dev/null 2>&1`
271 if [ "$?" -ne "0" ]; then
272 flag_no_python=yes
273 fi
274 fi
275
276 if test "x$flag_no_python" = x; then
277 if test "x$PYTHON_VERSION" = x; then
278 $ECHO -n "Detecting Python version... "
279 PYTHON_VERSION=`$PYTHON -c "import sys; print (\"%d.%d\" % (sys.version_info[0], sys.version_info[1]))"`
280 echo $PYTHON_VERSION
281 fi
282
283 if test "x$PYTHON_ROOT" = x; then
284 $ECHO -n "Detecting Python root... "
285 PYTHON_ROOT=`$PYTHON -c "import sys; print(sys.prefix)"`
286 echo $PYTHON_ROOT
287 fi
288 fi
289
290 # Configure ICU
291 $ECHO -n "Unicode/ICU support for Boost.Regex?... "
292 if test "x$flag_icu" != xno; then
293 if test "x$ICU_ROOT" = x; then
294 if command -v pkg-config > /dev/null && pkg-config icu-uc ; then
295 ICU_ROOT=`pkg-config --variable=prefix icu-uc`
296 fi
297 fi
298 if test "x$ICU_ROOT" = x; then
299 COMMON_ICU_PATHS="/usr /usr/local /sw"
300 for p in $COMMON_ICU_PATHS; do
301 if test -r $p/include/unicode/utypes.h; then
302 ICU_ROOT=$p
303 fi
304 done
305
306 if test "x$ICU_ROOT" = x; then
307 echo "not found."
308 else
309 BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT"
310 echo "$ICU_ROOT"
311 fi
312 else
313 BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT"
314 echo "$ICU_ROOT"
315 fi
316 else
317 echo "disabled."
318 fi
319
320 # Backup the user's existing project-config.jam
321 JAM_CONFIG_OUT="project-config.jam"
322 if test -r "project-config.jam"; then
323 counter=1
324
325 while test -r "project-config.jam.$counter"; do
326 counter=`expr $counter + 1`
327 done
328
329 echo "Backing up existing B2 configuration in project-config.jam.$counter"
330 mv "project-config.jam" "project-config.jam.$counter"
331 fi
332
333 # Generate user-config.jam
334 echo "Generating B2 configuration in project-config.jam for $TOOLSET..."
335 cat > project-config.jam <<EOF
336 # B2 Configuration
337 # Automatically generated by bootstrap.sh
338
339 import option ;
340 import feature ;
341
342 # Compiler configuration. This definition will be used unless
343 # you already have defined some toolsets in your user-config.jam
344 # file.
345 if ! $TOOLSET in [ feature.values <toolset> ]
346 {
347 using $TOOLSET ;
348 }
349
350 project : default-build <toolset>$TOOLSET ;
351 EOF
352
353 # - Python configuration
354 if test "x$flag_no_python" = x; then
355 cat >> project-config.jam <<EOF
356
357 # Python configuration
358 import python ;
359 if ! [ python.configured ]
360 {
361 using python : $PYTHON_VERSION : "$PYTHON_ROOT" ;
362 }
363 EOF
364 fi
365
366 if test "x$ICU_ROOT" != x; then
367 cat >> project-config.jam << EOF
368
369 path-constant ICU_PATH : $ICU_ROOT ;
370
371 EOF
372 fi
373
374 cat >> project-config.jam << EOF
375
376 # List of --with-<library> and --without-<library>
377 # options. If left empty, all libraries will be built.
378 # Options specified on the command line completely
379 # override this variable.
380 libraries = $LIBS ;
381
382 # These settings are equivalent to corresponding command-line
383 # options.
384 option.set prefix : $PREFIX ;
385 option.set exec-prefix : $EPREFIX ;
386 option.set libdir : $LIBDIR ;
387 option.set includedir : $INCLUDEDIR ;
388
389 # Stop on first error
390 option.set keep-going : false ;
391 EOF
392
393 cat << EOF
394
395 Bootstrapping is done. To build, run:
396
397 ./b2
398
399 To generate header files, run:
400
401 ./b2 headers
402
403 To adjust configuration, edit 'project-config.jam'.
404 Further information:
405
406 - Command line help:
407 ./b2 --help
408
409 - Getting started guide:
410 http://www.boost.org/more/getting_started/unix-variants.html
411
412 - B2 documentation:
413 http://www.boost.org/build/
414
415 EOF