Jamfile.v2 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #
  2. # This is Boost Jamfile for Boost.Build V2.
  3. #
  4. # Pass --v2 option to bjam to use this file. For example:
  5. #
  6. # bjam --v2 link=static
  7. #
  8. # TODO:
  9. # - handle boost version
  10. import modules ;
  11. import set ;
  12. import stage ;
  13. constant BOOST_VERSION : 1.33.0 ;
  14. project boost
  15. : requirements <include>.
  16. # disable auto-linking for all targets here,
  17. # primarily because it caused troubles with V2
  18. <define>BOOST_ALL_NO_LIB=1
  19. # Used to encode variant in target name. See the
  20. # 'tag' rule below.
  21. <tag>@$(__name__).tag
  22. : usage-requirements <include>.
  23. : build-dir bin.v2
  24. ;
  25. # The code here selects the libraries that must be built and builds
  26. # and creates two targets:
  27. # 'stage', which builds only libraries and placed them in one location
  28. # 'install', which places both libraries and headers in system location
  29. rule libraries-to-install ( existing-libraries * )
  30. {
  31. local argv = [ modules.peek : ARGV ] ;
  32. local with-parameter = [ MATCH --with-(.*) : $(argv) ] ;
  33. local without-parameter = [ MATCH --without-(.*) : $(argv) ] ;
  34. # Do some checks
  35. if $(with-parameter) && $(without-parameter)
  36. {
  37. ECHO "error: both --with-<library> and --without-<library> specified" ;
  38. EXIT ;
  39. }
  40. local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ;
  41. if $(wrong)
  42. {
  43. ECHO "error: wrong library name '$(wrong[1])' in the --with-<library> option." ;
  44. EXIT ;
  45. }
  46. local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ;
  47. if $(wrong)
  48. {
  49. ECHO "error: wrong library name '$(wrong[1])' in the --without-<library> option." ;
  50. EXIT ;
  51. }
  52. if $(with-parameter)
  53. {
  54. return [ set.intersection $(existing-libraries) : $(with-parameter) ] ;
  55. }
  56. else
  57. {
  58. return [ set.difference $(existing-libraries) : $(without-parameter) ] ;
  59. }
  60. }
  61. # The following is a copy of V1 logic. We don't yet support
  62. # selecting versioned/unversioned install and changing the build
  63. # directory.
  64. ARGV = [ modules.peek : ARGV ] ;
  65. # what kind of layout are we doing?
  66. layout = [ MATCH "^--layout=(.*)" : $(ARGV) ] ;
  67. layout ?= versioned ;
  68. layout-$(layout) = true ;
  69. # possible stage only location
  70. local stage-locate = [ MATCH "^--stagedir=(.*)" : $(ARGV) ] ;
  71. stage-locate ?= stage ;
  72. # architecture independent files
  73. local boost-locate ;
  74. if ! $(with-stage)
  75. {
  76. boost-locate = [ MATCH "^--prefix=(.*)" : $(ARGV) ] ;
  77. }
  78. else
  79. {
  80. boost-locate = $(stage-locate) ;
  81. }
  82. if [ modules.peek : NT ] { boost-locate ?= C:\\Boost ; }
  83. else if [ modules.peek : UNIX ] { boost-locate ?= /usr/local ; }
  84. # architecture dependent files
  85. local exec-locate = [ MATCH "^--exec-prefix=(.*)" : $(ARGV) ] ;
  86. exec-locate ?= $(boost-locate) ;
  87. # object code libraries
  88. local lib-locate = [ MATCH "^--libdir=(.*)" : $(ARGV) ] ;
  89. lib-locate ?= $(exec-locate)/lib ;
  90. # where to build
  91. local all-locate = [ MATCH "^--builddir=(.*)" : $(ARGV) ] ;
  92. ALL_LOCATE_TARGET ?= $(all-locate) ;
  93. # source header files
  94. local include-locate = [ MATCH "^--includedir=(.*)" : $(ARGV) ] ;
  95. include-locate ?= $(boost-locate)/include ;
  96. # location of python
  97. local python-root = [ MATCH "^--with-python-root=(.*)" : $(ARGV) ] ;
  98. PYTHON_ROOT ?= $(python-root) ;
  99. # Select the libraries to install.
  100. libraries = [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ] ] ;
  101. libraries = [ libraries-to-install $(libraries) ] ;
  102. # This rule is called by Boost.Build to determine the name of
  103. # target. We use it to encode build variant, compiler name and
  104. # boost version in the target name
  105. rule tag ( name : type ? : property-set )
  106. {
  107. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
  108. {
  109. if $(layout) = versioned
  110. {
  111. name = [ stage.add-variant-and-compiler $(name)
  112. : $(type) : $(property-set) ] ;
  113. local version-tag = [ MATCH "^([^.]+)[.]([^.]+)" : $(BOOST_VERSION[1]) ] ;
  114. version-tag = $(version-tag:J="_") ;
  115. # On NT, library with version suffix won't be recognized
  116. # by linkers. On CYGWIN, we get strage duplicate symbol
  117. # errors when library is generated with version suffix.
  118. if [ $(property-set).get <os> ] in NT CYGWIN
  119. {
  120. return $(name:B)-$(version-tag)$(name:S) ;
  121. }
  122. else
  123. {
  124. return $(name:B)-$(version-tag)$(name:S).$(BOOST_VERSION) ;
  125. }
  126. }
  127. else
  128. {
  129. return [ stage.add-variant-and-compiler $(name)
  130. : $(type) : $(property-set) ] ;
  131. }
  132. }
  133. }
  134. # Install to system location.
  135. alias install : install-libs install-headers ;
  136. install install-libs : libs/$(libraries)/build
  137. : <so-version>1.33.0
  138. <location>$(lib-locate)
  139. ;
  140. local patterns = *.hpp *.ipp *.h *.inc ;
  141. local dirs = boost boost/* boost/*/* ;
  142. install install-headers :
  143. [ glob $(dirs)/$(patterns) ]
  144. :
  145. <location>$(include-locate)
  146. <install-source-root>.
  147. ;
  148. # Install just library.
  149. install stage : libs/$(libraries)/build
  150. : <location>$(stage-locate)
  151. ;
  152. explicit install install-libs install-headers stage ;
  153. # Just build the libraries, don't install them anywhere.
  154. # This is what happend with just "bjam --v2".
  155. alias build_all : libs/$(libraries)/build ;
  156. # Make project ids of all libraries known.
  157. for local l in $(libraries)
  158. {
  159. use-project /boost/$(l) : libs/$(l)/build ;
  160. }
粤ICP备19079148号