Jamfile.v2 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. # Copyright Vladimir Prus 2002-2006.
  2. # Copyright Dave Abrahams 2005-2006.
  3. # Copyright Rene Rivera 2005-2006.
  4. # Copyright Douglas Gregor 2005.
  5. #
  6. # Distributed under the Boost Software License, Version 1.0.
  7. # (See accompanying file LICENSE_1_0.txt or copy at
  8. # http://www.boost.org/LICENSE_1_0.txt)
  9. # Usage:
  10. #
  11. # bjam [options] [install|stage]
  12. #
  13. # Builds and installs Boost.
  14. #
  15. # Targets and Related Options:
  16. #
  17. # install Install headers and compiled library files to the
  18. # ======= configured locations (below).
  19. #
  20. # --prefix=PREFIX Install architecture independent files here.
  21. # Default; C:\Boost on Win32
  22. # Default; /usr/local on Unix. Linux, etc.
  23. #
  24. # --exec-prefix=EPREFIX Install architecture dependent files here.
  25. # Default; PREFIX
  26. #
  27. # --libdir=DIR Install library files here.
  28. # Default; EPREFIX/lib
  29. #
  30. # --includedir=DIR Install header files here.
  31. # Default; PREFIX/include
  32. #
  33. # stage Build and install only compiled library files
  34. # ===== to the stage directory.
  35. #
  36. # --stagedir=DIR Install library files here
  37. # Default; ./stage
  38. #
  39. # Other Options:
  40. #
  41. # --builddir=DIR Build in this location instead of building
  42. # within the distribution tree. Recommended!
  43. #
  44. # --toolset=toolset Indicates the toolset to build with.
  45. #
  46. # --show-libraries Displays the list of Boost libraries that require
  47. # build and installation steps, then exit.
  48. #
  49. # --layout=<layout> Determines what kind of build layout to use. This
  50. # allows one to control the naming of the resulting
  51. # libraries, and the locations of the installed
  52. # files. Default is 'versioned'. Possible values:
  53. #
  54. # versioned - Uses the Boost standard names
  55. # which include version number for Boost the
  56. # release and version and name of the
  57. # compiler as part of the library names. Also
  58. # installs the includes to a versioned
  59. # sub-directory.
  60. #
  61. # system - Builds an install without the
  62. # Boost standard names, and does not install
  63. # includes to a versioned sub-directory. This
  64. # is intended for system integrators to build
  65. # for packaging of distributions.
  66. #
  67. # --buildid=ID Adds the specified ID to the name of built
  68. # libraries. Default is to not add anything.
  69. #
  70. # --help This message.
  71. #
  72. # --with-<library> Build and install the specified <library>
  73. # If this option is used, only libraries
  74. # specified using this option will be built.
  75. #
  76. # --without-<library> Do not build, stage, or install the specified
  77. # <library>. By default, all libraries are built.
  78. #
  79. # --with-python-root[=PYTHON_ROOT]
  80. # Build Boost.Python libraries with the Python
  81. # devel packages located at PYTHON_ROOT.
  82. # Default PYTHON_ROOT; C:\Python24 on Win32.
  83. # Default PYTHON_ROOT; /usr on Unix, Linux,
  84. # Cygwin, etc.
  85. #
  86. # --with-python-version[=2.4]
  87. # Build Boost.Python libraries with the Python
  88. # version indicated.
  89. # Default; 2.4.
  90. #
  91. # --with-pydebug Build Boost.Python libraries for use with a
  92. # debug build of Python.
  93. #
  94. # This is Boost Jamfile for Boost.Build V2.
  95. #
  96. # Pass --v2 option to bjam to use this file. For example:
  97. #
  98. # bjam --v2 link=static
  99. #
  100. # TODO:
  101. # - handle boost version
  102. import modules ;
  103. import set ;
  104. import stage ;
  105. import package ;
  106. import path ;
  107. import common ;
  108. import os ;
  109. import regex ;
  110. constant BOOST_VERSION : 1.35.0 ;
  111. local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ] ;
  112. if $(version-tag[3]) = 0
  113. {
  114. version-tag = $(version-tag[1-2]) ;
  115. }
  116. constant BOOST_VERSION_TAG : $(version-tag:J="_") ;
  117. local default-build ;
  118. if $(__file__:D) = ""
  119. {
  120. default-build =
  121. debug release
  122. <threading>single <threading>multi
  123. <link>shared <link>static
  124. ;
  125. if [ os.name ] = NT
  126. {
  127. default-build += <runtime-link>shared <runtime-link>static ;
  128. }
  129. }
  130. else
  131. {
  132. default-build =
  133. debug
  134. ;
  135. }
  136. project boost
  137. : requirements <include>.
  138. # disable auto-linking for all targets here,
  139. # primarily because it caused troubles with V2
  140. <define>BOOST_ALL_NO_LIB=1
  141. # Used to encode variant in target name. See the
  142. # 'tag' rule below.
  143. <tag>@$(__name__).tag
  144. # This property combination is dangerous.
  145. # Ideally, we'd add constaint to default build,
  146. # so that user can build with property combination
  147. # by hand. But we don't have any 'constaint' mechanism
  148. # for default-build, so disable such builds in requirements.
  149. <link>shared,<runtime-link>static:<build>no
  150. : usage-requirements <include>.
  151. : build-dir bin.v2
  152. : default-build $(default-build)
  153. ;
  154. # Setup convenient aliases for all libraries.
  155. all-libraries =
  156. [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ] ]
  157. ;
  158. # First, the complicated libraries: where the target name in
  159. # Jamfile is different from directory name.
  160. alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ;
  161. alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ;
  162. alias unit_test_framework : libs/test/build//boost_unit_test_framework ;
  163. alias bgl-vis : libs/graps/build//bgl-vis ;
  164. alias serialization : libs/serialization/build//boost_serialization ;
  165. alias wserialization : libs/serialization/build//boost_wserialization ;
  166. explicit prg_exec_monitor test_exec_monitor unit_test_framework
  167. bgl-vis serialization wserialization ;
  168. for local l in $(all-libraries)
  169. {
  170. if ! $(l) in test graph serialization
  171. {
  172. alias $(l) : libs/$(l)/build//boost_$(l) ;
  173. explicit $(l) ;
  174. }
  175. }
  176. alias headers : : : : <include>. ;
  177. # Decides which libraries are to be installed by looking at --with-<library>
  178. # --without-<library> arguments. Returns the list of directories under "libs"
  179. # which must be built at installed.
  180. rule libraries-to-install ( existing-libraries * )
  181. {
  182. local argv = [ modules.peek : ARGV ] ;
  183. local with-parameter = [ MATCH --with-(.*) : $(argv) ] ;
  184. local without-parameter = [ MATCH --without-(.*) : $(argv) ] ;
  185. # Do some checks
  186. if $(with-parameter) && $(without-parameter)
  187. {
  188. ECHO "error: both --with-<library> and --without-<library> specified" ;
  189. EXIT ;
  190. }
  191. local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ;
  192. if $(wrong)
  193. {
  194. ECHO "error: wrong library name '$(wrong[1])' in the --with-<library> option." ;
  195. EXIT ;
  196. }
  197. local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ;
  198. if $(wrong)
  199. {
  200. ECHO "error: wrong library name '$(wrong[1])' in the --without-<library> option." ;
  201. EXIT ;
  202. }
  203. if $(with-parameter)
  204. {
  205. return [ set.intersection $(existing-libraries) : $(with-parameter) ] ;
  206. }
  207. else
  208. {
  209. return [ set.difference $(existing-libraries) : $(without-parameter) ] ;
  210. }
  211. }
  212. # what kind of layout are we doing?
  213. layout = [ MATCH "^--layout=(.*)" : [ modules.peek : ARGV ] ] ;
  214. layout ?= versioned ;
  215. layout-$(layout) = true ;
  216. # possible stage only location
  217. local stage-locate = [ MATCH "^--stagedir=(.*)" : [ modules.peek : ARGV ] ] ;
  218. stage-locate ?= stage ;
  219. path-constant BOOST_STAGE_LOCATE : $(stage-locate) ;
  220. # location of python
  221. local python-root = [ MATCH "^--with-python-root=(.*)" : [ modules.peek : ARGV ] ] ;
  222. PYTHON_ROOT ?= $(python-root) ;
  223. # Select the libraries to install.
  224. libraries = [ libraries-to-install $(all-libraries) ] ;
  225. # Custom build ID.
  226. local build-id = [ MATCH "^--buildid=(.*)" : [ modules.peek : ARGV ] ] ;
  227. if $(build-id)
  228. {
  229. constant BUILD_ID : [ regex.replace $(build-id) "[*\\/:.\"\' ]" "_" ] ;
  230. }
  231. # This rule is called by Boost.Build to determine the name of
  232. # target. We use it to encode build variant, compiler name and
  233. # boost version in the target name
  234. rule tag ( name : type ? : property-set )
  235. {
  236. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
  237. {
  238. if $(layout) = versioned
  239. {
  240. local result = [ common.format-name
  241. <base> <toolset> <threading> <runtime> -$(BOOST_VERSION_TAG)
  242. -$(BUILD_ID)
  243. : $(name) : $(type) : $(property-set) ] ;
  244. # Optionally add version suffix.
  245. # On NT, library with version suffix won't be recognized
  246. # by linkers. On CYGWIN, we get strage duplicate symbol
  247. # errors when library is generated with version suffix.
  248. # On OSX, version suffix is not needed -- the linker expets
  249. # libFoo.1.2.3.dylib format.
  250. # AIX linkers don't accept version suffixes either.
  251. if $(type) = SHARED_LIB &&
  252. ! ( [ $(property-set).get <target-os> ] in windows cygwin darwin aix )
  253. {
  254. result = $(result).$(BOOST_VERSION) ;
  255. }
  256. return $(result) ;
  257. }
  258. else
  259. {
  260. return [ common.format-name
  261. <base> <toolset> <threading> <runtime> -$(BUILD_ID)
  262. : $(name) : $(type) : $(property-set) ] ;
  263. }
  264. }
  265. }
  266. # Install to system location.
  267. local install-requirements =
  268. <install-source-root>boost
  269. ;
  270. if $(layout-versioned)
  271. {
  272. install-requirements += <install-header-subdir>boost-$(BOOST_VERSION_TAG)/boost ;
  273. }
  274. if [ modules.peek : NT ]
  275. {
  276. install-requirements += <install-default-prefix>C:/Boost ;
  277. }
  278. else if [ modules.peek : UNIX ]
  279. {
  280. install-requirements += <install-default-prefix>/usr/local ;
  281. }
  282. local headers =
  283. [ path.glob-tree boost : *.hpp *.ipp *.h *.inc : CVS ]
  284. [ path.glob-tree boost/compatibility/cpp_c_headers : c* : CVS ]
  285. ;
  286. local header-subdir ;
  287. if $(layout-versioned) { header-subdir = boost-$(BOOST_VERSION_TAG)/boost ; }
  288. else { header-subdir = boost ; }
  289. # Complete install
  290. package.install install
  291. : $(install-requirements)
  292. :
  293. : libs/$(libraries)/build
  294. : $(headers)
  295. ;
  296. # Install just library.
  297. install stage
  298. : libs/$(libraries)/build
  299. : <location>$(stage-locate)
  300. <install-dependencies>on <install-type>LIB
  301. ;
  302. # Just build the libraries, don't install them anywhere.
  303. # This is what happend with just "bjam --v2".
  304. alias build_all : libs/$(libraries)/build ;
  305. # This rule should be called from libraries' Jamfiles and will
  306. # create two targets, "install" and "stage", that will install
  307. # or stage that library. The --prefix option is respected, by
  308. # --with and --without options, naturally, are ignored.
  309. #
  310. # - libraries -- list of library targets to install.
  311. rule boost-install ( libraries * )
  312. {
  313. package.install install
  314. : <dependency>/boost//install-headers $(install-requirements)
  315. : # No binaries
  316. : $(libraries)
  317. : # No headers, it's handled by the dependency
  318. ;
  319. install stage : $(libraries) : <location>$(BOOST_STAGE_LOCATE) ;
  320. local c = [ project.current ] ;
  321. local project-module = [ $(c).project-module ] ;
  322. module $(project-module)
  323. {
  324. explicit stage ;
  325. }
  326. }
  327. # Make project ids of all libraries known.
  328. for local l in $(libraries)
  329. {
  330. use-project /boost/$(l) : libs/$(l)/build ;
  331. }
粤ICP备19079148号