]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
5 | import os ; | |
6 | import indirect ; | |
7 | import modules ; | |
8 | import feature ; | |
9 | ||
10 | import python ; | |
11 | ||
12 | if ! [ python.configured ] && ! ( --without-python in [ modules.peek : ARGV ] ) | |
13 | { | |
14 | # Attempt default configuration of python | |
15 | import toolset : using ; | |
16 | using python ; | |
17 | } | |
18 | ||
19 | if [ python.configured ] || ( --without-python in [ modules.peek : ARGV ] ) | |
20 | { | |
21 | alias config-warning ; | |
22 | } | |
23 | else | |
24 | { | |
25 | message config-warning | |
26 | : "warning: No python installation configured and autoconfiguration" | |
27 | : "note: failed. See http://www.boost.org/libs/python/doc/building.html" | |
28 | : "note: for configuration instructions or pass --without-python to" | |
29 | : "note: suppress this message and silently skip all Boost.Python targets" | |
30 | ; | |
31 | } | |
32 | ||
33 | rule find-py3-version | |
34 | { | |
35 | local versions = [ feature.values python ] ; | |
36 | local py3ver ; | |
37 | for local v in $(versions) | |
38 | { | |
39 | if $(v) >= 3.0 | |
40 | { | |
41 | py3ver = $(v) ; | |
42 | } | |
43 | } | |
44 | return $(py3ver) ; | |
45 | } | |
46 | ||
47 | py3-version = [ find-py3-version ] ; | |
48 | ||
49 | project boost/python | |
50 | : source-location ../src | |
51 | ; | |
52 | ||
53 | rule cond ( test ? : yes * : no * ) { if $(test) { return $(yes) ; } else { return $(no) ; } } | |
54 | rule unless ( test ? : yes * : no * ) { if ! $(test) { return $(yes) ; } else { return $(no) ; } } | |
55 | ||
56 | rule lib_boost_python ( is-py3 ? ) | |
57 | { | |
58 | ||
59 | lib [ cond $(is-py3) : boost_python3 : boost_python ] | |
60 | : # sources | |
61 | numeric.cpp | |
62 | list.cpp | |
63 | long.cpp | |
64 | dict.cpp | |
65 | tuple.cpp | |
66 | str.cpp | |
67 | slice.cpp | |
68 | ||
69 | converter/from_python.cpp | |
70 | converter/registry.cpp | |
71 | converter/type_id.cpp | |
72 | object/enum.cpp | |
73 | object/class.cpp | |
74 | object/function.cpp | |
75 | object/inheritance.cpp | |
76 | object/life_support.cpp | |
77 | object/pickle_support.cpp | |
78 | errors.cpp | |
79 | module.cpp | |
80 | converter/builtin_converters.cpp | |
81 | converter/arg_to_python_base.cpp | |
82 | object/iterator.cpp | |
83 | object/stl_iterator.cpp | |
84 | object_protocol.cpp | |
85 | object_operators.cpp | |
86 | wrapper.cpp | |
87 | import.cpp | |
88 | exec.cpp | |
89 | object/function_doc_signature.cpp | |
90 | : # requirements | |
91 | <link>static:<define>BOOST_PYTHON_STATIC_LIB | |
92 | <define>BOOST_PYTHON_SOURCE | |
93 | ||
94 | # On Windows, all code using Python has to link to the Python | |
95 | # import library. | |
96 | # | |
97 | # On *nix we never link libboost_python to libpython. When | |
98 | # extending Python, all Python symbols are provided by the | |
99 | # Python interpreter executable. When embedding Python, the | |
100 | # client executable is expected to explicitly link to | |
101 | # /python//python (the target representing libpython) itself. | |
102 | # | |
103 | # python_for_extensions is a target defined by Boost.Build to | |
104 | # provide the Python include paths, and on Windows, the Python | |
105 | # import library, as usage requirements. | |
106 | [ cond [ python.configured ] : <library>/python//python_for_extensions ] | |
107 | ||
108 | # we prevent building when there is no python available | |
109 | # as it's not possible anyway, and to cause dependents to | |
110 | # fail to build | |
111 | [ unless [ python.configured ] : <build>no ] | |
112 | <dependency>config-warning | |
113 | ||
114 | <python-debugging>on:<define>BOOST_DEBUG_PYTHON | |
115 | [ cond $(is-py3) : <python>$(py3-version) ] | |
116 | ||
117 | -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag | |
118 | <tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).python-tag | |
119 | ||
120 | : # default build | |
121 | <link>shared | |
122 | : # usage requirements | |
123 | <link>static:<define>BOOST_PYTHON_STATIC_LIB | |
124 | <python-debugging>on:<define>BOOST_DEBUG_PYTHON | |
125 | ; | |
126 | } | |
127 | ||
128 | rule lib_boost_numpy ( is-py3 ? ) | |
129 | { | |
130 | numpy-include = [ python.numpy-include ] ; | |
131 | lib [ cond $(is-py3) : boost_numpy3 : boost_numpy ] | |
132 | : # sources | |
133 | numpy/dtype.cpp | |
134 | numpy/matrix.cpp | |
135 | numpy/ndarray.cpp | |
136 | numpy/numpy.cpp | |
137 | numpy/scalars.cpp | |
138 | numpy/ufunc.cpp | |
139 | : # requirements | |
140 | [ cond [ python.numpy ] : <library>/python//python_for_extensions ] | |
141 | [ unless [ python.numpy ] : <build>no ] | |
142 | <include>$(numpy-include) | |
143 | <library>boost_python | |
144 | <python-debugging>on:<define>BOOST_DEBUG_PYTHON | |
145 | [ cond $(is-py3) : <python>$(py3-version) ] | |
146 | ||
147 | -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag | |
148 | <tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).python-tag | |
149 | ||
150 | : # default build | |
151 | <link>shared | |
152 | : # usage requirements | |
153 | <python-debugging>on:<define>BOOST_DEBUG_PYTHON | |
154 | ; | |
155 | } | |
156 | ||
157 | libraries = boost_python ; | |
158 | libraries3 = boost_python3 ; | |
159 | if [ python.numpy ] | |
160 | { | |
161 | libraries += boost_numpy ; | |
162 | libraries3 += boost_numpy3 ; | |
163 | } | |
164 | ||
165 | lib_boost_python ; | |
166 | lib_boost_numpy ; | |
167 | ||
168 | if $(py3-version) | |
169 | { | |
170 | lib_boost_python yes ; | |
171 | lib_boost_numpy yes ; | |
172 | libraries += $(libraries3) ; | |
173 | } | |
174 | ||
175 | boost-install $(libraries) ; |