Jamfile.v2 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. # Usage:
  2. #
  3. # bjam [options] [install|stage]
  4. #
  5. # Builds and installs Boost.
  6. #
  7. # Targets and Related Options:
  8. #
  9. # install Install headers and compiled library files to the
  10. # ======= configured locations (below).
  11. #
  12. # --prefix=PREFIX Install architecture independent files here.
  13. # Default; C:\Boost on Win32
  14. # Default; /usr/local on Unix. Linux, etc.
  15. #
  16. # --exec-prefix=EPREFIX Install architecture dependent files here.
  17. # Default; PREFIX
  18. #
  19. # --libdir=DIR Install library files here.
  20. # Default; EPREFIX/lib
  21. #
  22. # --includedir=DIR Install header files here.
  23. # Default; PREFIX/include
  24. #
  25. # stage Build and install only compiled library files
  26. # ===== to the stage directory.
  27. #
  28. # --stagedir=DIR Install library files here
  29. # Default; ./stage
  30. #
  31. # Other Options:
  32. #
  33. # --builddir=DIR Build in this location instead of building
  34. # within the distribution tree. Recommended!
  35. #
  36. # --toolset=toolset Indicates the toolset to build with.
  37. #
  38. # --show-libraries Displays the list of Boost libraries that require
  39. # build and installation steps, then exit.
  40. #
  41. # --layout=<layout> Determines what kind of build layout to use. This
  42. # allows one to control the naming of the resulting
  43. # libraries, and the locations of the installed
  44. # files. Default is 'versioned'. Possible values:
  45. #
  46. # versioned - Uses the Boost standard names
  47. # which include version number for Boost the
  48. # release and version and name of the
  49. # compiler as part of the library names. Also
  50. # installs the includes to a versioned
  51. # sub-directory.
  52. #
  53. # system - Builds an install without the
  54. # Boost standard names, and does not install
  55. # includes to a versioned sub-directory. This
  56. # is intended for system integrators to build
  57. # for packaging of distributions.
  58. #
  59. # --help This message.
  60. #
  61. # --with-<library> Build and install the specified <library>
  62. # If this option is used, only libraries
  63. # specified using this option will be built.
  64. #
  65. # --without-<library> Do not build, stage, or install the specified
  66. # <library>. By default, all libraries are built.
  67. #
  68. # --with-python-root[=PYTHON_ROOT]
  69. # Build Boost.Python libraries with the Python
  70. # devel packages located at PYTHON_ROOT.
  71. # Default PYTHON_ROOT; C:\Python24 on Win32.
  72. # Default PYTHON_ROOT; /usr on Unix, Linux,
  73. # Cygwin, etc.
  74. #
  75. # --with-python-version[=2.4]
  76. # Build Boost.Python libraries with the Python
  77. # version indicated.
  78. # Default; 2.4.
  79. #
  80. # --with-pydebug Build Boost.Python libraries for use with a
  81. # debug build of Python.
  82. #
  83. # This is Boost Jamfile for Boost.Build V2.
  84. #
  85. # Pass --v2 option to bjam to use this file. For example:
  86. #
  87. # bjam --v2 link=static
  88. #
  89. # TODO:
  90. # - handle boost version
  91. import modules ;
  92. import set ;
  93. import stage ;
  94. import package ;
  95. import path ;
  96. constant BOOST_VERSION : 1.34.0 ;
  97. local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ] ;
  98. if $(version-tag[3]) = 0
  99. {
  100. version-tag = $(version-tag[1-2]) ;
  101. }
  102. constant BOOST_VERSION_TAG : $(version-tag:J="_") ;
  103. local default-build ;
  104. if $(__file__:D) = ""
  105. {
  106. default-build =
  107. debug release
  108. <threading>single <threading>multi
  109. <runtime-link>shared <runtime-link>static
  110. ;
  111. }
  112. else
  113. {
  114. default-build =
  115. debug
  116. ;
  117. }
  118. project boost
  119. : requirements <include>.
  120. # disable auto-linking for all targets here,
  121. # primarily because it caused troubles with V2
  122. <define>BOOST_ALL_NO_LIB=1
  123. # Used to encode variant in target name. See the
  124. # 'tag' rule below.
  125. <tag>@$(__name__).tag
  126. : usage-requirements <include>.
  127. : build-dir bin.v2
  128. : default-build $(default-build)
  129. ;
  130. # Setup convenient aliases for all libraries.
  131. all-libraries =
  132. [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ] ]
  133. ;
  134. # First, the complicated libraries: where the target name in
  135. # Jamfile is different from directory name.
  136. alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ;
  137. alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ;
  138. alias unit_test_framework : libs/test/build//boost_unit_test_framework ;
  139. alias bgl-vis : libs/graps/build//bgl-vis ;
  140. alias serialization : libs/serialization/build//boost_serialization ;
  141. alias wserialization : libs/serialization/build//boost_wserialization ;
  142. explicit prg_exec_monitor test_exec_monitor unit_test_framework
  143. bgl-vis serialization wserialization ;
  144. for local l in $(all-libraries)
  145. {
  146. if ! $(l) in test graph serialization
  147. {
  148. alias $(l) : libs/$(l)/build//boost_$(l) ;
  149. explicit $(l) ;
  150. }
  151. }
  152. alias headers : : : : <include>. ;
  153. # Decides which libraries are to be installed by looking at --with-<library>
  154. # --without-<library> arguments. Returns the list of directories under "libs"
  155. # which must be built at installed.
  156. rule libraries-to-install ( existing-libraries * )
  157. {
  158. local argv = [ modules.peek : ARGV ] ;
  159. local with-parameter = [ MATCH --with-(.*) : $(argv) ] ;
  160. local without-parameter = [ MATCH --without-(.*) : $(argv) ] ;
  161. # Do some checks
  162. if $(with-parameter) && $(without-parameter)
  163. {
  164. ECHO "error: both --with-<library> and --without-<library> specified" ;
  165. EXIT ;
  166. }
  167. local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ;
  168. if $(wrong)
  169. {
  170. ECHO "error: wrong library name '$(wrong[1])' in the --with-<library> option." ;
  171. EXIT ;
  172. }
  173. local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ;
  174. if $(wrong)
  175. {
  176. ECHO "error: wrong library name '$(wrong[1])' in the --without-<library> option." ;
  177. EXIT ;
  178. }
  179. if $(with-parameter)
  180. {
  181. return [ set.intersection $(existing-libraries) : $(with-parameter) ] ;
  182. }
  183. else
  184. {
  185. return [ set.difference $(existing-libraries) : $(without-parameter) ] ;
  186. }
  187. }
  188. # what kind of layout are we doing?
  189. layout = [ MATCH "^--layout=(.*)" : [ modules.peek : ARGV ] ] ;
  190. layout ?= versioned ;
  191. layout-$(layout) = true ;
  192. # possible stage only location
  193. local stage-locate = [ MATCH "^--stagedir=(.*)" : [ modules.peek : ARGV ] ] ;
  194. stage-locate ?= stage ;
  195. path-constant BOOST_STAGE_LOCATE : $(stage-locate) ;
  196. # location of python
  197. local python-root = [ MATCH "^--with-python-root=(.*)" : [ modules.peek : ARGV ] ] ;
  198. PYTHON_ROOT ?= $(python-root) ;
  199. # Select the libraries to install.
  200. libraries = [ libraries-to-install $(all-libraries) ] ;
  201. # This rule is called by Boost.Build to determine the name of
  202. # target. We use it to encode build variant, compiler name and
  203. # boost version in the target name
  204. rule tag ( name : type ? : property-set )
  205. {
  206. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
  207. {
  208. if $(layout) = versioned
  209. {
  210. name = [ stage.add-variant-and-compiler $(name)
  211. : $(type) : $(property-set) ] ;
  212. # Optionally add version suffix.
  213. if $(type) != SHARED_LIB ||
  214. [ $(property-set).get <os> ] in NT CYGWIN MACOSX AIX
  215. {
  216. # On NT, library with version suffix won't be recognized
  217. # by linkers. On CYGWIN, we get strage duplicate symbol
  218. # errors when library is generated with version suffix.
  219. # On OSX, version suffix is not needed -- the linker expets
  220. # libFoo.1.2.3.dylib format.
  221. # AIX linkers don't accept version suffixes either.
  222. return $(name:B)-$(BOOST_VERSION_TAG)$(name:S) ;
  223. }
  224. else
  225. {
  226. return $(name:B)-$(BOOST_VERSION_TAG)$(name:S).$(BOOST_VERSION) ;
  227. }
  228. }
  229. else
  230. {
  231. return [ stage.add-variant-and-compiler $(name)
  232. : $(type) : $(property-set) ] ;
  233. }
  234. }
  235. }
  236. # Install to system location.
  237. local patterns = *.hpp *.ipp *.h *.inc ;
  238. local dir = boost ;
  239. local headers ;
  240. while $(dir)
  241. {
  242. local files = [ glob $(dir)/$(patterns) ] ;
  243. if $(files)
  244. {
  245. headers += $(files) ;
  246. dir = $(dir)/* ;
  247. }
  248. else
  249. {
  250. dir = ;
  251. }
  252. }
  253. local header-subdir ;
  254. if $(layout-versioned) { header-subdir = boost-$(BOOST_VERSION_TAG) ; }
  255. else { header-subdir = boost ; }
  256. # Complete install
  257. package.install install
  258. : <install-source-root>boost
  259. <install-header-subdir>$(header-subdir)
  260. :
  261. : libs/$(libraries)/build
  262. : $(headers)
  263. ;
  264. # Install just library.
  265. install stage
  266. : libs/$(libraries)/build
  267. : <location>$(stage-locate)
  268. <install-dependencies>on <install-type>LIB
  269. ;
  270. # Just build the libraries, don't install them anywhere.
  271. # This is what happend with just "bjam --v2".
  272. alias build_all : libs/$(libraries)/build ;
  273. # This rule should be called from libraries' Jamfiles and will
  274. # create two targets, "install" and "stage", that will install
  275. # or stage that library. The --prefix option is respected, by
  276. # --with and --without options, naturally, are ignored.
  277. #
  278. # - libraries -- list of library targets to install.
  279. rule boost-install ( libraries * )
  280. {
  281. package.install install
  282. : <dependency>/boost//install-headers
  283. : # No binaries
  284. : $(libraries)
  285. : # No headers, it's handled by the dependency
  286. ;
  287. install stage : $(libraries) : <location>$(BOOST_STAGE_LOCATE) ;
  288. local c = [ project.current ] ;
  289. local project-module = [ $(c).project-module ] ;
  290. module $(project-module)
  291. {
  292. explicit stage ;
  293. }
  294. }
  295. # Make project ids of all libraries known.
  296. for local l in $(libraries)
  297. {
  298. use-project /boost/$(l) : libs/$(l)/build ;
  299. }
粤ICP备19079148号