Jamfile.v2 14 KB

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