Jamroot 16 KB

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