Jamfile.v2 14 KB

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