Jamroot 14 KB

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