bootstrap.sh 10 KB

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