Jamroot 16 KB

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