]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | #!/bin/sh |
1e59de90 | 2 | # Copyright 2019-2021 René Ferdinand Rivera Morell |
7c673cae FG |
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 | |
1e59de90 TL |
145 | \`./bootstrap.sh\' builds the Boost build system B2 and prepares Boost for |
146 | building. This includes setting defaults in the project-config.jam which you | |
147 | can adjust prior to invoking B2. | |
7c673cae FG |
148 | |
149 | Usage: $0 [OPTION]... | |
150 | ||
151 | Defaults for the options are specified in brackets. | |
152 | ||
153 | Configuration: | |
154 | -h, --help display this help and exit | |
155 | --with-bjam=BJAM use existing Boost.Jam executable (bjam) | |
156 | [automatically built] | |
1e59de90 TL |
157 | --with-toolset=TOOLSET use specific TOOLSET to build B2 and as default |
158 | for building Boost | |
7c673cae FG |
159 | [automatically detected] |
160 | --show-libraries show the set of libraries that require build | |
161 | and installation steps (i.e., those libraries | |
162 | that can be used with --with-libraries or | |
163 | --without-libraries), then exit | |
164 | --with-libraries=list build only a particular set of libraries, | |
165 | describing using either a comma-separated list of | |
166 | library names or "all" | |
167 | [all] | |
168 | --without-libraries=list build all libraries except the ones listed [] | |
169 | --with-icu enable Unicode/ICU support in Regex | |
170 | [automatically detected] | |
171 | --without-icu disable Unicode/ICU support in Regex | |
172 | --with-icu=DIR specify the root of the ICU library installation | |
173 | and enable Unicode/ICU support in Regex | |
174 | [automatically detected] | |
175 | --with-python=PYTHON specify the Python executable [python] | |
176 | --with-python-root=DIR specify the root of the Python installation | |
177 | [automatically detected] | |
178 | --with-python-version=X.Y specify the Python version as X.Y | |
179 | [automatically detected] | |
180 | ||
181 | Installation directories: | |
182 | --prefix=PREFIX install Boost into the given PREFIX | |
183 | [/usr/local] | |
184 | --exec-prefix=EPREFIX install Boost binaries into the given EPREFIX | |
185 | [PREFIX] | |
186 | ||
187 | More precise control over installation directories: | |
188 | --libdir=DIR install libraries here [EPREFIX/lib] | |
189 | --includedir=DIR install headers here [PREFIX/include] | |
190 | ||
191 | EOF | |
192 | fi | |
193 | test -n "$want_help" && exit 0 | |
194 | ||
b32b8144 | 195 | my_dir=$(dirname "$0") |
7c673cae FG |
196 | |
197 | # Determine the toolset, if not already decided | |
198 | if test "x$TOOLSET" = x; then | |
1e59de90 | 199 | guessed_toolset=`CXX= CXXFLAGS= $my_dir/tools/build/src/engine/build.sh --guess-toolset` |
7c673cae | 200 | case $guessed_toolset in |
92f5a8d4 | 201 | acc | clang | gcc | como | mipspro | pathscale | pgi | qcc | vacpp ) |
7c673cae FG |
202 | TOOLSET=$guessed_toolset |
203 | ;; | |
204 | ||
205 | intel-* ) | |
206 | TOOLSET=intel | |
207 | ;; | |
208 | ||
209 | mingw ) | |
210 | TOOLSET=gcc | |
211 | ;; | |
212 | ||
213 | sun* ) | |
214 | TOOLSET=sun | |
215 | ;; | |
216 | ||
217 | * ) | |
20effc67 | 218 | # Not supported by B2 |
7c673cae FG |
219 | ;; |
220 | esac | |
221 | fi | |
222 | ||
223 | rm -f config.log | |
224 | ||
225 | # Build bjam | |
226 | if test "x$BJAM" = x; then | |
20effc67 | 227 | $ECHO "Building B2 engine.." |
7c673cae | 228 | pwd=`pwd` |
1e59de90 | 229 | CXX= CXXFLAGS= "$my_dir/tools/build/src/engine/build.sh" ${TOOLSET} |
7c673cae FG |
230 | if [ $? -ne 0 ]; then |
231 | echo | |
20effc67 | 232 | echo "Failed to build B2 build engine" |
7c673cae FG |
233 | exit 1 |
234 | fi | |
235 | cd "$pwd" | |
92f5a8d4 TL |
236 | BJAM="$my_dir/tools/build/src/engine/b2" |
237 | echo "tools/build/src/engine/b2" | |
7c673cae | 238 | cp "$BJAM" . |
7c673cae FG |
239 | |
240 | fi | |
241 | ||
242 | # TBD: Turn BJAM into an absolute path | |
243 | ||
244 | # If there is a list of libraries | |
245 | if test "x$flag_show_libraries" = xyes; then | |
246 | cat <<EOF | |
247 | ||
248 | The following Boost libraries have portions that require a separate build | |
249 | and installation step. Any library not listed here can be used by including | |
250 | the headers only. | |
251 | ||
252 | The Boost libraries requiring separate building and installation are: | |
253 | EOF | |
254 | $BJAM -d0 --show-libraries | grep '^[[:space:]]*-' | |
255 | exit 0 | |
256 | fi | |
257 | ||
258 | # Setup paths | |
259 | if test "x$EPREFIX" = x; then | |
260 | EPREFIX="$PREFIX" | |
261 | fi | |
262 | ||
263 | if test "x$LIBDIR" = x; then | |
264 | LIBDIR="$EPREFIX/lib" | |
265 | fi | |
266 | ||
267 | if test "x$INCLUDEDIR" = x; then | |
268 | INCLUDEDIR="$PREFIX/include" | |
269 | fi | |
270 | ||
271 | # Find Python | |
272 | if 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 | |
277 | fi | |
278 | ||
279 | if 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 | |
291 | fi | |
292 | ||
293 | # Configure ICU | |
294 | $ECHO -n "Unicode/ICU support for Boost.Regex?... " | |
295 | if test "x$flag_icu" != xno; then | |
92f5a8d4 TL |
296 | if test "x$ICU_ROOT" = x; then |
297 | if command -v pkg-config > /dev/null && pkg-config icu-uc ; then | |
298 | ICU_ROOT=`pkg-config --variable=prefix icu-uc` | |
299 | fi | |
300 | fi | |
7c673cae FG |
301 | if test "x$ICU_ROOT" = x; then |
302 | COMMON_ICU_PATHS="/usr /usr/local /sw" | |
303 | for p in $COMMON_ICU_PATHS; do | |
304 | if test -r $p/include/unicode/utypes.h; then | |
305 | ICU_ROOT=$p | |
306 | fi | |
307 | done | |
308 | ||
309 | if test "x$ICU_ROOT" = x; then | |
310 | echo "not found." | |
311 | else | |
312 | BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT" | |
313 | echo "$ICU_ROOT" | |
314 | fi | |
315 | else | |
316 | BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT" | |
317 | echo "$ICU_ROOT" | |
318 | fi | |
319 | else | |
320 | echo "disabled." | |
321 | fi | |
322 | ||
323 | # Backup the user's existing project-config.jam | |
324 | JAM_CONFIG_OUT="project-config.jam" | |
325 | if test -r "project-config.jam"; then | |
326 | counter=1 | |
327 | ||
328 | while test -r "project-config.jam.$counter"; do | |
329 | counter=`expr $counter + 1` | |
330 | done | |
331 | ||
20effc67 | 332 | echo "Backing up existing B2 configuration in project-config.jam.$counter" |
7c673cae FG |
333 | mv "project-config.jam" "project-config.jam.$counter" |
334 | fi | |
335 | ||
336 | # Generate user-config.jam | |
20effc67 | 337 | echo "Generating B2 configuration in project-config.jam for $TOOLSET..." |
7c673cae | 338 | cat > project-config.jam <<EOF |
20effc67 | 339 | # B2 Configuration |
7c673cae FG |
340 | # Automatically generated by bootstrap.sh |
341 | ||
342 | import option ; | |
343 | import feature ; | |
344 | ||
345 | # Compiler configuration. This definition will be used unless | |
346 | # you already have defined some toolsets in your user-config.jam | |
347 | # file. | |
348 | if ! $TOOLSET in [ feature.values <toolset> ] | |
349 | { | |
350 | using $TOOLSET ; | |
351 | } | |
352 | ||
353 | project : default-build <toolset>$TOOLSET ; | |
354 | EOF | |
355 | ||
356 | # - Python configuration | |
357 | if test "x$flag_no_python" = x; then | |
358 | cat >> project-config.jam <<EOF | |
359 | ||
360 | # Python configuration | |
361 | import python ; | |
362 | if ! [ python.configured ] | |
363 | { | |
92f5a8d4 | 364 | using python : $PYTHON_VERSION : "$PYTHON_ROOT" ; |
7c673cae FG |
365 | } |
366 | EOF | |
367 | fi | |
368 | ||
369 | if test "x$ICU_ROOT" != x; then | |
370 | cat >> project-config.jam << EOF | |
371 | ||
372 | path-constant ICU_PATH : $ICU_ROOT ; | |
373 | ||
374 | EOF | |
375 | fi | |
376 | ||
377 | cat >> project-config.jam << EOF | |
378 | ||
379 | # List of --with-<library> and --without-<library> | |
380 | # options. If left empty, all libraries will be built. | |
381 | # Options specified on the command line completely | |
382 | # override this variable. | |
383 | libraries = $LIBS ; | |
384 | ||
92f5a8d4 | 385 | # These settings are equivalent to corresponding command-line |
7c673cae FG |
386 | # options. |
387 | option.set prefix : $PREFIX ; | |
388 | option.set exec-prefix : $EPREFIX ; | |
389 | option.set libdir : $LIBDIR ; | |
390 | option.set includedir : $INCLUDEDIR ; | |
391 | ||
392 | # Stop on first error | |
393 | option.set keep-going : false ; | |
394 | EOF | |
395 | ||
396 | cat << EOF | |
397 | ||
398 | Bootstrapping is done. To build, run: | |
399 | ||
400 | ./b2 | |
401 | ||
92f5a8d4 TL |
402 | To generate header files, run: |
403 | ||
404 | ./b2 headers | |
405 | ||
1e59de90 TL |
406 | The configuration generated uses ${TOOLSET} to build by default. If that is |
407 | unintended either use the --with-toolset option or adjust configuration, by | |
408 | editing 'project-config.jam'. | |
409 | ||
7c673cae FG |
410 | Further information: |
411 | ||
412 | - Command line help: | |
413 | ./b2 --help | |
414 | ||
415 | - Getting started guide: | |
416 | http://www.boost.org/more/getting_started/unix-variants.html | |
417 | ||
20effc67 | 418 | - B2 documentation: |
92f5a8d4 | 419 | http://www.boost.org/build/ |
7c673cae FG |
420 | |
421 | EOF |