bootstrap.sh 10 KB

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