Jamfile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Copyright David Abrahams 2001-2006. Distributed under the Boost
  2. # Software License, Version 1.0. (See accompanying
  3. # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. import os ;
  5. import indirect ;
  6. import modules ;
  7. import feature ;
  8. import property ;
  9. import python ;
  10. if ! [ python.configured ] && ! ( --without-python in [ modules.peek : ARGV ] )
  11. {
  12. # Attempt default configuration of python
  13. import toolset : using ;
  14. using python ;
  15. }
  16. if [ python.configured ] || ( --without-python in [ modules.peek : ARGV ] )
  17. {
  18. alias config-warning ;
  19. }
  20. else
  21. {
  22. message config-warning
  23. : "warning: No python installation configured and autoconfiguration"
  24. : "note: failed. See http://www.boost.org/libs/python/doc/building.html"
  25. : "note: for configuration instructions or pass --without-python to"
  26. : "note: suppress this message and silently skip all Boost.Python targets"
  27. ;
  28. }
  29. if [ python.configured ]
  30. {
  31. project boost/python
  32. : source-location ../src
  33. ;
  34. rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } }
  35. rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } }
  36. local rule eq ( a : b ) { if $(a) = $(b) { return 1 ; } }
  37. lib boost_python
  38. : # sources
  39. list.cpp
  40. long.cpp
  41. dict.cpp
  42. tuple.cpp
  43. str.cpp
  44. slice.cpp
  45. converter/from_python.cpp
  46. converter/registry.cpp
  47. converter/type_id.cpp
  48. object/enum.cpp
  49. object/class.cpp
  50. object/function.cpp
  51. object/inheritance.cpp
  52. object/life_support.cpp
  53. object/pickle_support.cpp
  54. errors.cpp
  55. module.cpp
  56. converter/builtin_converters.cpp
  57. converter/arg_to_python_base.cpp
  58. object/iterator.cpp
  59. object/stl_iterator.cpp
  60. object_protocol.cpp
  61. object_operators.cpp
  62. wrapper.cpp
  63. import.cpp
  64. exec.cpp
  65. object/function_doc_signature.cpp
  66. : # requirements
  67. <link>static:<define>BOOST_PYTHON_STATIC_LIB
  68. <define>BOOST_PYTHON_SOURCE
  69. # On Windows, all code using Python has to link to the Python
  70. # import library.
  71. #
  72. # On *nix we never link libboost_python to libpython. When
  73. # extending Python, all Python symbols are provided by the
  74. # Python interpreter executable. When embedding Python, the
  75. # client executable is expected to explicitly link to
  76. # /python//python (the target representing libpython) itself.
  77. #
  78. # python_for_extensions is a target defined by Boost.Build to
  79. # provide the Python include paths, and on Windows, the Python
  80. # import library, as usage requirements.
  81. [ cond [ python.configured ] : <library>/python//python_for_extensions ]
  82. # we prevent building when there is no python available
  83. # as it's not possible anyway, and to cause dependents to
  84. # fail to build
  85. [ unless [ python.configured ] : <build>no ]
  86. <dependency>config-warning
  87. <python-debugging>on:<define>BOOST_DEBUG_PYTHON
  88. -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
  89. <tag>@$(__name__).python-tag
  90. <conditional>@python.require-py
  91. : # default build
  92. <link>shared
  93. : # usage requirements
  94. <link>static:<define>BOOST_PYTHON_STATIC_LIB
  95. <python-debugging>on:<define>BOOST_DEBUG_PYTHON
  96. ;
  97. numpy-include = [ python.numpy-include ] ;
  98. lib boost_numpy
  99. : # sources
  100. numpy/dtype.cpp
  101. numpy/matrix.cpp
  102. numpy/ndarray.cpp
  103. numpy/numpy.cpp
  104. numpy/scalars.cpp
  105. numpy/ufunc.cpp
  106. : # requirements
  107. <link>static:<define>BOOST_NUMPY_STATIC_LIB
  108. <define>BOOST_NUMPY_SOURCE
  109. [ cond [ python.numpy ] : <library>/python//python_for_extensions ]
  110. [ unless [ python.numpy ] : <build>no ]
  111. <include>$(numpy-include)
  112. <library>boost_python
  113. <python-debugging>on:<define>BOOST_DEBUG_PYTHON
  114. -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
  115. <tag>@$(__name__).python-tag
  116. <conditional>@python.require-py
  117. : # default build
  118. <link>shared
  119. : # usage requirements
  120. <link>static:<define>BOOST_NUMPY_STATIC_LIB
  121. <python-debugging>on:<define>BOOST_DEBUG_PYTHON
  122. ;
  123. # boost-install creates `stage` and `install` targets
  124. #
  125. # `stage` stages (builds and copies into `stage/lib`) the given libraries
  126. # `boost_python` and `boost_numpy` and their dependencies and is similar
  127. # to issuing `b2 --with-python stage` from top level
  128. #
  129. # `install` installs the two libraries and their dependencies and is similar
  130. # to issuing `b2 --with-python install` from top level
  131. boost-install boost_python boost_numpy ;
  132. }
  133. else
  134. {
  135. # When Python isn't configured, the above `boost-install` is not executed,
  136. # so we create empty `stage` and `install` targets that do nothing but issue
  137. # a warning message unless `--without-python` is given
  138. alias stage : config-warning ;
  139. explicit stage ;
  140. alias install : config-warning ;
  141. explicit install ;
  142. }