Jamroot 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. # Copyright Vladimir Prus 2002-2006.
  2. # Copyright Dave Abrahams 2005-2006.
  3. # Copyright Rene Rivera 2005-2007.
  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=<HDRDIR> 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=<STAGEDIR> Install library files here
  37. # Default; ./stage
  38. #
  39. # Other Options:
  40. #
  41. # --build-type=<type> Build the specified pre-defined set of variations
  42. # of the libraries. Note, that which variants get
  43. # built depends on what each library supports.
  44. #
  45. # minimal (default) - Builds the single
  46. # "release" version of the libraries. This
  47. # release corresponds to specifying:
  48. # "release <threading>multi <link>shared
  49. # <link>static <runtime-link>shared" as the
  50. # Boost.Build variant to build.
  51. #
  52. # complete - Attempts to build all possible
  53. # variations.
  54. #
  55. # --build-dir=DIR Build in this location instead of building
  56. # within the distribution tree. Recommended!
  57. #
  58. # --toolset=toolset Indicates the toolset to build with.
  59. #
  60. # --show-libraries Displays the list of Boost libraries that require
  61. # build and installation steps, then exit.
  62. #
  63. # --layout=<layout> Determines whether to choose library names
  64. # and header locations such that multiple
  65. # versions of Boost or multiple compilers can
  66. # be used on the same system.
  67. #
  68. # versioned (default) - Names of boost
  69. # binaries include the Boost version
  70. # number and the name and version of the
  71. # compiler. Boost headers are installed
  72. # in a subdirectory of <HDRDIR> whose
  73. # name contains the Boost version
  74. # number.
  75. #
  76. # system - Binaries names do not include
  77. # the Boost version number or the name
  78. # and version number of the compiler.
  79. # Boost headers are installed directly
  80. # into <HDRDIR>. This option is
  81. # intended for system integrators who
  82. # are building distribution packages.
  83. #
  84. # --buildid=ID Adds the specified ID to the name of built
  85. # libraries. The default is to not add anything.
  86. #
  87. # --help This message.
  88. #
  89. # --with-<library> Build and install the specified <library>
  90. # If this option is used, only libraries
  91. # specified using this option will be built.
  92. #
  93. # --without-<library> Do not build, stage, or install the specified
  94. # <library>. By default, all libraries are built.
  95. # TODO:
  96. # - handle boost version
  97. # - handle python options such as pydebug
  98. import generate ;
  99. import modules ;
  100. import set ;
  101. import stage ;
  102. import package ;
  103. import path ;
  104. import common ;
  105. import os ;
  106. import regex ;
  107. import errors ;
  108. import "class" : new ;
  109. import common ;
  110. import sequence ;
  111. import symlink ;
  112. path-constant BOOST_ROOT : . ;
  113. constant BOOST_VERSION : 1.37.0 ;
  114. constant BOOST_JAMROOT_MODULE : $(__name__) ;
  115. local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ] ;
  116. if $(version-tag[3]) = 0
  117. {
  118. version-tag = $(version-tag[1-2]) ;
  119. }
  120. constant BOOST_VERSION_TAG : $(version-tag:J="_") ;
  121. # Option to choose how many variants to build. The default is "minimal",
  122. # which builds only the "release <threading>multi <link>shared" variant.
  123. local build-type = [ MATCH "^--build-type=(.*)" : [ modules.peek : ARGV ] ] ;
  124. build-type ?= minimal ;
  125. if ! ( $(build-type) in minimal complete )
  126. {
  127. build-type = minimal ;
  128. }
  129. # Specify the build variants keyed on the build-type.
  130. local default-build,minimal =
  131. release
  132. <threading>multi
  133. <link>shared <link>static
  134. <runtime-link>shared
  135. ;
  136. local default-build,complete =
  137. debug release
  138. <threading>single <threading>multi
  139. <link>shared <link>static
  140. <runtime-link>shared <runtime-link>static
  141. ;
  142. # Set the default build.
  143. local default-build = $(default-build,$(build-type)) ;
  144. # We only use the default build when building at the root to
  145. # avoid having it impact the default regression testing of "debug".
  146. # TODO: Consider having a "testing" build type instead of this check.
  147. if $(__file__:D) != ""
  148. {
  149. default-build = debug ;
  150. }
  151. rule handle-static-runtime ( properties * )
  152. {
  153. # This property combination is dangerous.
  154. # Ideally, we'd add constraint to default build,
  155. # so that user can build with property combination
  156. # by hand. But we don't have any 'constraint' mechanism
  157. # for default-build, so disable such builds in requirements.
  158. # For CW, static runtime is needed so that
  159. # std::locale works.
  160. if <link>shared in $(properties)
  161. && <runtime-link>static in $(properties)
  162. && ! ( <toolset>cw in $(properties) )
  163. {
  164. return <build>no ;
  165. }
  166. }
  167. project boost
  168. : requirements <include>.
  169. # disable auto-linking for all targets here,
  170. # primarily because it caused troubles with V2
  171. <define>BOOST_ALL_NO_LIB=1
  172. # Used to encode variant in target name. See the
  173. # 'tag' rule below.
  174. <tag>@$(__name__).tag
  175. <conditional>@handle-static-runtime
  176. : usage-requirements <include>.
  177. : build-dir bin.v2
  178. : default-build $(default-build)
  179. ;
  180. # Setup convenient aliases for all libraries.
  181. all-libraries =
  182. [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ] [ glob libs/*/build/Jamfile ] ]
  183. ;
  184. all-libraries = [ sequence.unique $(all-libraries) ] ;
  185. # First, the complicated libraries: where the target name in
  186. # Jamfile is different from directory name.
  187. alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ;
  188. alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ;
  189. alias unit_test_framework : libs/test/build//boost_unit_test_framework ;
  190. alias bgl-vis : libs/graps/build//bgl-vis ;
  191. alias serialization : libs/serialization/build//boost_serialization ;
  192. alias wserialization : libs/serialization/build//boost_wserialization ;
  193. explicit prg_exec_monitor test_exec_monitor unit_test_framework
  194. bgl-vis serialization wserialization ;
  195. for local l in $(all-libraries)
  196. {
  197. if ! $(l) in test graph serialization
  198. {
  199. alias $(l) : libs/$(l)/build//boost_$(l) ;
  200. explicit $(l) ;
  201. }
  202. }
  203. alias headers : : : : <include>. ;
  204. # Decides which libraries are to be installed by looking at --with-<library>
  205. # --without-<library> arguments. Returns the list of directories under "libs"
  206. # which must be built at installed.
  207. rule libraries-to-install ( existing-libraries * )
  208. {
  209. local argv = [ modules.peek : ARGV ] ;
  210. local with-parameter = [ MATCH --with-(.*) : $(argv) ] ;
  211. local without-parameter = [ MATCH --without-(.*) : $(argv) ] ;
  212. # Do some checks
  213. if $(with-parameter) && $(without-parameter)
  214. {
  215. ECHO "error: both --with-<library> and --without-<library> specified" ;
  216. EXIT ;
  217. }
  218. local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ;
  219. if $(wrong)
  220. {
  221. ECHO "error: wrong library name '$(wrong[1])' in the --with-<library> option." ;
  222. EXIT ;
  223. }
  224. local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ;
  225. if $(wrong)
  226. {
  227. ECHO "error: wrong library name '$(wrong[1])' in the --without-<library> option." ;
  228. EXIT ;
  229. }
  230. if $(with-parameter)
  231. {
  232. return [ set.intersection $(existing-libraries) : $(with-parameter) ] ;
  233. }
  234. else
  235. {
  236. return [ set.difference $(existing-libraries) : $(without-parameter) ] ;
  237. }
  238. }
  239. # what kind of layout are we doing?
  240. layout = [ MATCH "^--layout=(.*)" : [ modules.peek : ARGV ] ] ;
  241. layout ?= versioned ;
  242. layout-$(layout) = true ;
  243. # possible stage only location
  244. local stage-locate = [ MATCH "^--stagedir=(.*)" : [ modules.peek : ARGV ] ] ;
  245. stage-locate ?= stage ;
  246. path-constant BOOST_STAGE_LOCATE : $(stage-locate) ;
  247. # location of python
  248. local python-root = [ MATCH "^--with-python-root=(.*)" : [ modules.peek : ARGV ] ] ;
  249. PYTHON_ROOT ?= $(python-root) ;
  250. # Select the libraries to install.
  251. libraries = [ libraries-to-install $(all-libraries) ] ;
  252. if --show-libraries in [ modules.peek : ARGV ]
  253. {
  254. ECHO "The following libraries require building:" ;
  255. for local l in $(libraries)
  256. {
  257. ECHO " - $(l)" ;
  258. }
  259. EXIT ;
  260. }
  261. # Custom build ID.
  262. local build-id = [ MATCH "^--buildid=(.*)" : [ modules.peek : ARGV ] ] ;
  263. if $(build-id)
  264. {
  265. constant BUILD_ID : [ regex.replace $(build-id) "[*\\/:.\"\' ]" "_" ] ;
  266. }
  267. # This rule is called by Boost.Build to determine the name of
  268. # target. We use it to encode build variant, compiler name and
  269. # boost version in the target name
  270. rule tag ( name : type ? : property-set )
  271. {
  272. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
  273. {
  274. if $(layout) = versioned
  275. {
  276. local result = [ common.format-name
  277. <base> <toolset> <threading> <runtime> -$(BOOST_VERSION_TAG)
  278. -$(BUILD_ID)
  279. : $(name) : $(type) : $(property-set) ] ;
  280. # Optionally add version suffix.
  281. # On NT, library with version suffix won't be recognized
  282. # by linkers. On CYGWIN, we get strage duplicate symbol
  283. # errors when library is generated with version suffix.
  284. # On OSX, version suffix is not needed -- the linker expets
  285. # libFoo.1.2.3.dylib format.
  286. # AIX linkers don't accept version suffixes either.
  287. # Pgi compilers can't accept library with version suffix
  288. if $(type) = SHARED_LIB &&
  289. ( ! ( [ $(property-set).get <target-os> ] in windows cygwin darwin aix ) &&
  290. ! ( [ $(property-set).get <toolset> ] in pgi ) )
  291. {
  292. result = $(result).$(BOOST_VERSION) ;
  293. }
  294. return $(result) ;
  295. }
  296. else
  297. {
  298. return [ common.format-name
  299. <base> <threading> <runtime> -$(BUILD_ID)
  300. : $(name) : $(type) : $(property-set) ] ;
  301. }
  302. }
  303. }
  304. # Install to system location.
  305. local install-requirements =
  306. <install-source-root>boost
  307. ;
  308. if $(layout-versioned)
  309. {
  310. install-requirements += <install-header-subdir>boost-$(BOOST_VERSION_TAG)/boost ;
  311. }
  312. else
  313. {
  314. install-requirements += <install-header-subdir>boost ;
  315. }
  316. if [ modules.peek : NT ]
  317. {
  318. install-requirements += <install-default-prefix>C:/Boost ;
  319. }
  320. else if [ modules.peek : UNIX ]
  321. {
  322. install-requirements += <install-default-prefix>/usr/local ;
  323. }
  324. local headers =
  325. # The .SUNWCCh files are present in tr1 include directory and have to be installed,
  326. # see http://lists.boost.org/Archives/boost/2007/05/121430.php
  327. [ path.glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc *.SUNWCCh : CVS .svn ]
  328. [ path.glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* : CVS .svn ]
  329. [ path.glob boost/tr1/tr1 : * : bcc32 sun CVS .svn ]
  330. ;
  331. # Complete install
  332. package.install install-proper
  333. : $(install-requirements) <install-no-version-symlinks>on
  334. :
  335. : libs/$(libraries)/build
  336. : $(headers)
  337. ;
  338. explicit install-proper ;
  339. # Install just library.
  340. install stage-proper
  341. : libs/$(libraries)/build
  342. : <location>$(stage-locate)/lib
  343. <install-dependencies>on <install-type>LIB
  344. <install-no-version-symlinks>on
  345. ;
  346. explicit stage-proper ;
  347. if $(layout-versioned)
  348. && ( [ modules.peek : NT ] || [ modules.peek : UNIX ] )
  349. {
  350. rule make-unversioned-links ( project name ? : property-set : sources * )
  351. {
  352. local result ;
  353. local filtered ;
  354. local pattern ;
  355. local nt = [ modules.peek : NT ] ;
  356. # Collect the libraries that have the version number in 'filtered'.
  357. for local s in $(sources)
  358. {
  359. local m ;
  360. if $(nt)
  361. {
  362. m = [ MATCH "(.*[.]lib)" : [ $(s).name ] ] ;
  363. }
  364. else
  365. {
  366. m = [ MATCH "(.*[.]so[.0-9]+)" "(.*[.]dylib)" "(.*[.]a)" : [ $(s).name ] ] ;
  367. }
  368. if $(m)
  369. {
  370. filtered += $(s) ;
  371. }
  372. }
  373. # Create links without version.
  374. for local s in $(filtered)
  375. {
  376. local name = [ $(s).name ] ;
  377. local ea = [ $(s).action ] ;
  378. local ep = [ $(ea).properties ] ;
  379. local a = [
  380. new non-scanning-action $(s) : symlink.ln : $(ep) ] ;
  381. local noversion-file ;
  382. if $(nt)
  383. {
  384. noversion-file = [ MATCH "(.*)-[0-9_]+([.]lib)" : $(name) ] ;
  385. }
  386. else
  387. {
  388. noversion-file =
  389. [ MATCH "(.*)-[0-9_]+([.]so)[.0-9]*" : $(name) ]
  390. [ MATCH "(.*)-[0-9_]+([.]dylib)" : $(name) ]
  391. [ MATCH "(.*)-[0-9_]+([.]a)" : $(name) ]
  392. [ MATCH "(.*)-[0-9_]+([.]dll[.]a)" : $(name) ] ;
  393. }
  394. local new-name =
  395. $(noversion-file[1])$(noversion-file[2]) ;
  396. result += [ new file-target $(new-name) exact : [ $(s).type ] : $(project)
  397. : $(a) ] ;
  398. }
  399. return $(result) ;
  400. }
  401. generate stage-unversioned : stage-proper :
  402. <generating-rule>@make-unversioned-links ;
  403. explicit stage-unversioned ;
  404. generate install-unversioned : install-proper :
  405. <generating-rule>@make-unversioned-links ;
  406. explicit install-unversioned ;
  407. }
  408. else
  409. {
  410. # Create do-nothing aliases
  411. alias stage-unversioned ;
  412. explicit stage-unversioned ;
  413. alias install-unversioned ;
  414. explicit install-unversioned ;
  415. }
  416. alias install : install-proper install-unversioned ;
  417. alias stage : stage-proper stage-unversioned ;
  418. explicit install ;
  419. explicit stage ;
  420. # Just build the libraries, don't install them anywhere.
  421. # This is what happens with just "bjam --v2".
  422. alias build_all : libs/$(libraries)/build ;
  423. # This rule should be called from libraries' Jamfiles and will
  424. # create two targets, "install" and "stage", that will install
  425. # or stage that library. The --prefix option is respected, but
  426. # --with and --without options, naturally, are ignored.
  427. #
  428. # - libraries -- list of library targets to install.
  429. rule boost-install ( libraries * )
  430. {
  431. package.install install
  432. : <dependency>/boost//install-headers $(install-requirements)
  433. : # No binaries
  434. : $(libraries)
  435. : # No headers, it's handled by the dependency
  436. ;
  437. install stage : $(libraries) : <location>$(BOOST_STAGE_LOCATE) ;
  438. local c = [ project.current ] ;
  439. local project-module = [ $(c).project-module ] ;
  440. module $(project-module)
  441. {
  442. explicit stage ;
  443. explicit install ;
  444. }
  445. }
  446. # Make project ids of all libraries known.
  447. for local l in $(all-libraries)
  448. {
  449. use-project /boost/$(l) : libs/$(l)/build ;
  450. }
粤ICP备19079148号