bootstrap.sh 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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/jam/src/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.Jam with toolset $TOOLSET... "
  177. pwd=`pwd`
  178. cd "$my_dir/tools/jam/src" && ./build.sh "$TOOLSET" > config.log 2>&1
  179. cd "$pwd"
  180. arch=`cd $my_dir/tools/jam/src && ./bootstrap/jam0 -d0 -f build.jam --toolset=$TOOLSET --toolset-root= --show-locate-target && cd ..`
  181. BJAM="$my_dir/tools/jam/src/$arch/bjam"
  182. echo "tools/jam/src/$arch/bjam"
  183. cp "$BJAM" .
  184. fi
  185. # TBD: Turn BJAM into an absolute path
  186. # If there is a list of libraries
  187. if test "x$flag_show_libraries" = xyes; then
  188. libraries=`$BJAM -d0 --show-libraries`
  189. cat <<EOF
  190. The following Boost libraries have portions that require a separate build
  191. and installation step. Any library not listed here can be used by including
  192. the headers only.
  193. The Boost libraries requiring separate building and installation are:
  194. EOF
  195. for lib in $libraries
  196. do
  197. echo " $lib"
  198. done
  199. exit 0
  200. fi
  201. # Setup paths
  202. if test "x$EPREFIX" = x; then
  203. EPREFIX="$PREFIX"
  204. fi
  205. if test "x$LIBDIR" = x; then
  206. LIBDIR="$EPREFIX/lib"
  207. fi
  208. if test "x$INCLUDEDIR" = x; then
  209. INCLUDEDIR="$PREFIX/include"
  210. fi
  211. # Find Python
  212. if test "x$flag_no_python" = x; then
  213. result=`$PYTHON -c "exit" > /dev/null 2>&1`
  214. if [ "$?" -ne "0" ]; then
  215. flag_no_python=yes
  216. fi
  217. fi
  218. if test "x$flag_no_python" = x; then
  219. if test "x$PYTHON_VERSION" = x; then
  220. echo -n "Detecting Python version... "
  221. PYTHON_VERSION=`$PYTHON -c "import sys; print (\"%d.%d\" % (sys.version_info[0], sys.version_info[1]))"`
  222. echo $PYTHON_VERSION
  223. fi
  224. if test "x$PYTHON_ROOT" = x; then
  225. echo -n "Detecting Python root... "
  226. PYTHON_ROOT=`$PYTHON -c "import sys; print sys.prefix"`
  227. echo $PYTHON_ROOT
  228. fi
  229. fi
  230. # Configure ICU
  231. echo -n "Unicode/ICU support for Boost.Regex?... "
  232. if test "x$flag_icu" != xno; then
  233. if test "x$ICU_ROOT" = x; then
  234. COMMON_ICU_PATHS="/usr /usr/local /sw"
  235. for p in $COMMON_ICU_PATHS; do
  236. if test -r $p/include/unicode/utypes.h; then
  237. ICU_ROOT=$p
  238. fi
  239. done
  240. if test "x$ICU_ROOT" = x; then
  241. echo "not found."
  242. else
  243. BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT"
  244. echo "$ICU_ROOT"
  245. fi
  246. else
  247. BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT"
  248. echo "$ICU_ROOT"
  249. fi
  250. else
  251. echo "disabled."
  252. fi
  253. # Backup the user's existing project-config.jam
  254. JAM_CONFIG_OUT="project-config.jam"
  255. if test -r "project-config.jam"; then
  256. counter=1
  257. while test -r "project-config.jam.$counter"; do
  258. counter=`expr $counter + 1`
  259. done
  260. echo "Backing up existing Boost.Build configuration in project-config.jam.$counter"
  261. mv "project-config.jam" "project-config.jam.$counter"
  262. fi
  263. # Generate user-config.jam
  264. echo "Generating Boost.Build configuration in project-config.jam..."
  265. cat > project-config.jam <<EOF
  266. # Boost.Build Configuration
  267. # Automatically generated by bootstrap.sh
  268. import option ;
  269. import feature ;
  270. # Compiler configuration. This definition will be used unless
  271. # you already have defined some toolsets in your user-config.jam
  272. # file.
  273. if ! $TOOLSET in [ feature.values <toolset> ]
  274. {
  275. using $TOOLSET ;
  276. }
  277. project : default-build <toolset>$TOOLSET ;
  278. EOF
  279. # - Python configuration
  280. if test "x$flag_no_python" = x; then
  281. cat >> project-config.jam <<EOF
  282. # Python configuration
  283. using python : $PYTHON_VERSION : $PYTHON_ROOT ;
  284. EOF
  285. fi
  286. if test "x$ICU_ROOT" != x; then
  287. cat >> project-config.jam << EOF
  288. path-constant ICU_PATH : $ICU_ROOT ;
  289. EOF
  290. fi
  291. cat >> project-config.jam << EOF
  292. # List of --with-<library> and --without-<library>
  293. # options. If left empty, all libraries will be built.
  294. # Options specified on the command line completely
  295. # override this variable.
  296. libraries = $LIBS ;
  297. # These settings are equivivalent to corresponding command-line
  298. # options.
  299. option.set prefix : $PREFIX ;
  300. option.set exec-prefix : $EPREFIX ;
  301. option.set libdir : $LIBDIR ;
  302. option.set includedir : $INCLUDEDIR ;
  303. EOF
  304. cat << EOF
  305. Bootstrapping is done. To build, run:
  306. ./bjam
  307. To adjust configuration, edit 'project-config.jam'.
  308. Further information:
  309. - Command line help:
  310. ./bjam --help
  311. - Getting started guide:
  312. http://www.boost.org/more/getting_started/unix-variants.html
  313. - Boost.Build documentation:
  314. http://www.boost.org/boost-build2/doc/html/index.html
  315. EOF
粤ICP备19079148号