bootstrap.sh 10 KB

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