Jamroot 16 KB

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