Jamroot 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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.39.0 ;
  126. constant BOOST_JAMROOT_MODULE : $(__name__) ;
  127. local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ] ;
  128. if $(version-tag[3]) = 0
  129. {
  130. version-tag = $(version-tag[1-2]) ;
  131. }
  132. constant BOOST_VERSION_TAG : $(version-tag:J="_") ;
  133. # Option to choose how many variants to build. The default is "minimal",
  134. # which builds only the "release <threading>multi <link>shared" variant.
  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
  157. # avoid having it 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.
  166. # Ideally, we'd add constraint to default build,
  167. # so that user can build with property combination
  168. # by hand. But we don't have any 'constraint' mechanism
  169. # for default-build, so disable such builds in requirements.
  170. # For CW, static runtime is needed so that
  171. # std::locale works.
  172. if <link>shared in $(properties)
  173. && <runtime-link>static in $(properties)
  174. && ! ( <toolset>cw in $(properties) )
  175. {
  176. return <build>no ;
  177. }
  178. }
  179. project boost
  180. : requirements <include>.
  181. # disable auto-linking for all targets here,
  182. # primarily because it caused troubles with V2
  183. <define>BOOST_ALL_NO_LIB=1
  184. # Used to encode variant in target name. See the
  185. # 'tag' rule below.
  186. <tag>@$(__name__).tag
  187. <conditional>@handle-static-runtime
  188. : usage-requirements <include>.
  189. : build-dir bin.v2
  190. : default-build $(default-build)
  191. ;
  192. # Setup convenient aliases for all libraries.
  193. all-libraries =
  194. [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ] [ glob libs/*/build/Jamfile ] ]
  195. ;
  196. all-libraries = [ sequence.unique $(all-libraries) ] ;
  197. # First, the complicated libraries: where the target name in
  198. # Jamfile is different from directory name.
  199. alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ;
  200. alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ;
  201. alias unit_test_framework : libs/test/build//boost_unit_test_framework ;
  202. alias bgl-vis : libs/graps/build//bgl-vis ;
  203. alias serialization : libs/serialization/build//boost_serialization ;
  204. alias wserialization : libs/serialization/build//boost_wserialization ;
  205. explicit prg_exec_monitor test_exec_monitor unit_test_framework
  206. bgl-vis serialization wserialization ;
  207. for local l in $(all-libraries)
  208. {
  209. if ! $(l) in test graph serialization
  210. {
  211. alias $(l) : libs/$(l)/build//boost_$(l) ;
  212. explicit $(l) ;
  213. }
  214. }
  215. alias headers : : : : <include>. ;
  216. # Decides which libraries are to be installed by looking at --with-<library>
  217. # --without-<library> arguments. Returns the list of directories under "libs"
  218. # which must be built at installed.
  219. rule libraries-to-install ( existing-libraries * )
  220. {
  221. local argv = [ modules.peek : ARGV ] ;
  222. local with-parameter = [ MATCH --with-(.*) : $(argv) ] ;
  223. local without-parameter = [ MATCH --without-(.*) : $(argv) ] ;
  224. # Do some checks
  225. if $(with-parameter) && $(without-parameter)
  226. {
  227. ECHO "error: both --with-<library> and --without-<library> specified" ;
  228. EXIT ;
  229. }
  230. local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ;
  231. if $(wrong)
  232. {
  233. ECHO "error: wrong library name '$(wrong[1])' in the --with-<library> option." ;
  234. EXIT ;
  235. }
  236. local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ;
  237. if $(wrong)
  238. {
  239. ECHO "error: wrong library name '$(wrong[1])' in the --without-<library> option." ;
  240. EXIT ;
  241. }
  242. if $(with-parameter)
  243. {
  244. return [ set.intersection $(existing-libraries) : $(with-parameter) ] ;
  245. }
  246. else
  247. {
  248. return [ set.difference $(existing-libraries) : $(without-parameter) ] ;
  249. }
  250. }
  251. # what kind of layout are we doing?
  252. layout = [ MATCH "^--layout=(.*)" : [ modules.peek : ARGV ] ] ;
  253. layout ?= versioned ;
  254. layout-$(layout) = true ;
  255. # possible stage only location
  256. local stage-locate = [ MATCH "^--stagedir=(.*)" : [ modules.peek : ARGV ] ] ;
  257. stage-locate ?= stage ;
  258. path-constant BOOST_STAGE_LOCATE : $(stage-locate) ;
  259. # location of python
  260. local python-root = [ MATCH "^--with-python-root=(.*)" : [ modules.peek : ARGV ] ] ;
  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
  280. # target. We use it to encode build variant, compiler name and
  281. # boost version in the target name
  282. rule tag ( name : type ? : property-set )
  283. {
  284. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
  285. {
  286. if $(layout) = versioned
  287. {
  288. local result = [ common.format-name
  289. <base> <toolset> <threading> <runtime> -$(BOOST_VERSION_TAG)
  290. -$(BUILD_ID)
  291. : $(name) : $(type) : $(property-set) ] ;
  292. # Optionally add version suffix.
  293. # On NT, library with version suffix won't be recognized
  294. # by linkers. On CYGWIN, we get strage duplicate symbol
  295. # errors when library is generated with version suffix.
  296. # On OSX, version suffix is not needed -- the linker expets
  297. # libFoo.1.2.3.dylib format.
  298. # AIX linkers don't accept version suffixes either.
  299. # Pgi compilers can't accept library with version 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
  311. <base> <threading> <runtime> -$(BUILD_ID)
  312. : $(name) : $(type) : $(property-set) ] ;
  313. }
  314. }
  315. }
  316. # Install to system location.
  317. local install-requirements =
  318. <install-source-root>boost
  319. ;
  320. if $(layout-versioned)
  321. {
  322. install-requirements += <install-header-subdir>boost-$(BOOST_VERSION_TAG)/boost ;
  323. }
  324. else
  325. {
  326. install-requirements += <install-header-subdir>boost ;
  327. }
  328. if [ modules.peek : NT ]
  329. {
  330. install-requirements += <install-default-prefix>C:/Boost ;
  331. }
  332. else if [ modules.peek : UNIX ]
  333. {
  334. install-requirements += <install-default-prefix>/usr/local ;
  335. }
  336. local headers =
  337. # The .SUNWCCh files are present in tr1 include directory and have to be installed,
  338. # see http://lists.boost.org/Archives/boost/2007/05/121430.php
  339. [ path.glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc *.SUNWCCh : CVS .svn ]
  340. [ path.glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* : CVS .svn ]
  341. [ path.glob boost/tr1/tr1 : * : bcc32 sun CVS .svn ]
  342. ;
  343. # Complete install
  344. package.install install-proper
  345. : $(install-requirements) <install-no-version-symlinks>on
  346. :
  347. : libs/$(libraries)/build
  348. : $(headers)
  349. ;
  350. explicit install-proper ;
  351. # Install just library.
  352. install stage-proper
  353. : libs/$(libraries)/build
  354. : <location>$(stage-locate)/lib
  355. <install-dependencies>on <install-type>LIB
  356. <install-no-version-symlinks>on
  357. ;
  358. explicit stage-proper ;
  359. if $(layout-versioned)
  360. && ( [ modules.peek : NT ] || [ modules.peek : UNIX ] )
  361. {
  362. rule make-unversioned-links ( project name ? : property-set : sources * )
  363. {
  364. local result ;
  365. local filtered ;
  366. local pattern ;
  367. local nt = [ modules.peek : NT ] ;
  368. # Collect the libraries that have the version number in 'filtered'.
  369. for local s in $(sources)
  370. {
  371. local m ;
  372. if $(nt)
  373. {
  374. m = [ MATCH "(.*[.]lib)" : [ $(s).name ] ] ;
  375. }
  376. else
  377. {
  378. m = [ MATCH "(.*[.]so[.0-9]+)" "(.*[.]dylib)" "(.*[.]a)" : [ $(s).name ] ] ;
  379. }
  380. if $(m)
  381. {
  382. filtered += $(s) ;
  383. }
  384. }
  385. # Create links without version.
  386. for local s in $(filtered)
  387. {
  388. local name = [ $(s).name ] ;
  389. local ea = [ $(s).action ] ;
  390. local ep = [ $(ea).properties ] ;
  391. local a = [
  392. new non-scanning-action $(s) : symlink.ln : $(ep) ] ;
  393. local noversion-file ;
  394. if $(nt)
  395. {
  396. noversion-file = [ MATCH "(.*)-[0-9_]+([.]lib)" : $(name) ] ;
  397. }
  398. else
  399. {
  400. noversion-file =
  401. [ MATCH "(.*)-[0-9_]+([.]so)[.0-9]*" : $(name) ]
  402. [ MATCH "(.*)-[0-9_]+([.]dylib)" : $(name) ]
  403. [ MATCH "(.*)-[0-9_]+([.]a)" : $(name) ]
  404. [ MATCH "(.*)-[0-9_]+([.]dll[.]a)" : $(name) ] ;
  405. }
  406. local new-name =
  407. $(noversion-file[1])$(noversion-file[2]) ;
  408. result += [ new file-target $(new-name) exact : [ $(s).type ] : $(project)
  409. : $(a) ] ;
  410. }
  411. return $(result) ;
  412. }
  413. generate stage-unversioned : stage-proper :
  414. <generating-rule>@make-unversioned-links ;
  415. explicit stage-unversioned ;
  416. generate install-unversioned : install-proper :
  417. <generating-rule>@make-unversioned-links ;
  418. explicit install-unversioned ;
  419. }
  420. else
  421. {
  422. # Create do-nothing aliases
  423. alias stage-unversioned ;
  424. explicit stage-unversioned ;
  425. alias install-unversioned ;
  426. explicit install-unversioned ;
  427. }
  428. alias install : install-proper install-unversioned ;
  429. alias stage : stage-proper stage-unversioned ;
  430. explicit install ;
  431. explicit stage ;
  432. # Just build the libraries, don't install them anywhere.
  433. # This is what happens with just "bjam --v2".
  434. alias build_all : libs/$(libraries)/build ;
  435. # This rule should be called from libraries' Jamfiles and will
  436. # create two targets, "install" and "stage", that will install
  437. # or stage that library. The --prefix option is respected, but
  438. # --with and --without options, naturally, are ignored.
  439. #
  440. # - libraries -- list of library targets to install.
  441. rule boost-install ( libraries * )
  442. {
  443. package.install install
  444. : <dependency>/boost//install-headers $(install-requirements)
  445. : # No binaries
  446. : $(libraries)
  447. : # No headers, it's handled by the dependency
  448. ;
  449. install stage : $(libraries) : <location>$(BOOST_STAGE_LOCATE) ;
  450. local c = [ project.current ] ;
  451. local project-module = [ $(c).project-module ] ;
  452. module $(project-module)
  453. {
  454. explicit stage ;
  455. explicit install ;
  456. }
  457. }
  458. # Make project ids of all libraries known.
  459. for local l in $(all-libraries)
  460. {
  461. use-project /boost/$(l) : libs/$(l)/build ;
  462. }
粤ICP备19079148号