1 |
dnl =================================================================== |
2 |
dnl Licensed to the Apache Software Foundation (ASF) under one |
3 |
dnl or more contributor license agreements. See the NOTICE file |
4 |
dnl distributed with this work for additional information |
5 |
dnl regarding copyright ownership. The ASF licenses this file |
6 |
dnl to you under the Apache License, Version 2.0 (the |
7 |
dnl "License"); you may not use this file except in compliance |
8 |
dnl with the License. You may obtain a copy of the License at |
9 |
dnl |
10 |
dnl http://www.apache.org/licenses/LICENSE-2.0 |
11 |
dnl |
12 |
dnl Unless required by applicable law or agreed to in writing, |
13 |
dnl software distributed under the License is distributed on an |
14 |
dnl "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
15 |
dnl KIND, either express or implied. See the License for the |
16 |
dnl specific language governing permissions and limitations |
17 |
dnl under the License. |
18 |
dnl =================================================================== |
19 |
dnl |
20 |
dnl check to see if SWIG is current enough. |
21 |
dnl |
22 |
dnl if it is, then check to see if we have the correct version of python. |
23 |
dnl |
24 |
dnl if we do, then set up the appropriate SWIG_ variables to build the |
25 |
dnl python bindings. |
26 |
|
27 |
AC_DEFUN(SVN_CHECK_SWIG, |
28 |
[ |
29 |
AC_ARG_WITH(swig, |
30 |
AS_HELP_STRING([--with-swig=PATH], |
31 |
[Try to use 'PATH/bin/swig' to build the |
32 |
swig bindings. If PATH is not specified, |
33 |
look for a 'swig' binary in your PATH.]), |
34 |
[ |
35 |
case "$withval" in |
36 |
"no") |
37 |
SWIG_SUITABLE=no |
38 |
SVN_FIND_SWIG(no) |
39 |
;; |
40 |
"yes") |
41 |
SVN_FIND_SWIG(required) |
42 |
;; |
43 |
*) |
44 |
SVN_FIND_SWIG($withval) |
45 |
;; |
46 |
esac |
47 |
], |
48 |
[ |
49 |
SVN_FIND_SWIG(check) |
50 |
]) |
51 |
]) |
52 |
|
53 |
AC_DEFUN(SVN_FIND_SWIG, |
54 |
[ |
55 |
where=$1 |
56 |
|
57 |
if test $where = no; then |
58 |
SWIG=none |
59 |
elif test $where = required || test $where = check; then |
60 |
AC_PATH_PROG(SWIG, swig, none) |
61 |
if test "$SWIG" = "none" && test $where = required; then |
62 |
AC_MSG_ERROR([SWIG required, but not found]) |
63 |
fi |
64 |
else |
65 |
if test -f "$where"; then |
66 |
SWIG="$where" |
67 |
else |
68 |
SWIG="$where/bin/swig" |
69 |
fi |
70 |
if test ! -f "$SWIG" || test ! -x "$SWIG"; then |
71 |
AC_MSG_ERROR([Could not find swig binary at $SWIG]) |
72 |
fi |
73 |
fi |
74 |
|
75 |
if test "$SWIG" != "none"; then |
76 |
AC_MSG_CHECKING([swig version]) |
77 |
SWIG_VERSION_RAW="`$SWIG -version 2>&1 | \ |
78 |
$SED -ne 's/^.*Version \(.*\)$/\1/p'`" |
79 |
# We want the version as an integer so we can test against |
80 |
# which version we're using. SWIG doesn't provide this |
81 |
# to us so we have to come up with it on our own. |
82 |
# The major is passed straight through, |
83 |
# the minor is zero padded to two places, |
84 |
# and the patch level is zero padded to three places. |
85 |
# e.g. 1.3.24 becomes 103024 |
86 |
SWIG_VERSION="`echo \"$SWIG_VERSION_RAW\" | \ |
87 |
$SED -e 's/[[^0-9\.]].*$//' \ |
88 |
-e 's/\.\([[0-9]]\)$/.0\1/' \ |
89 |
-e 's/\.\([[0-9]][[0-9]]\)$/.0\1/' \ |
90 |
-e 's/\.\([[0-9]]\)\./0\1/; s/\.//g;'`" |
91 |
AC_MSG_RESULT([$SWIG_VERSION_RAW]) |
92 |
# If you change the required swig version number, don't forget to update: |
93 |
# subversion/bindings/swig/INSTALL |
94 |
if test -n "$SWIG_VERSION" && test "$SWIG_VERSION" -ge "103024"; then |
95 |
SWIG_SUITABLE=yes |
96 |
else |
97 |
SWIG_SUITABLE=no |
98 |
AC_MSG_WARN([Detected SWIG version $SWIG_VERSION_RAW]) |
99 |
AC_MSG_WARN([Subversion requires SWIG >= 1.3.24]) |
100 |
fi |
101 |
fi |
102 |
|
103 |
SWIG_PY_COMPILE="none" |
104 |
SWIG_PY_LINK="none" |
105 |
SWIG_PY_OPTS="none" |
106 |
SWIG_PY_ERRMSG="check config.log for details" |
107 |
if test "$PYTHON" != "none"; then |
108 |
AC_MSG_NOTICE([Configuring python swig binding]) |
109 |
|
110 |
AC_CACHE_CHECK([for Python includes], [ac_cv_python_includes],[ |
111 |
ac_cv_python_includes="`$PYTHON ${abs_srcdir}/build/get-py-info.py --includes`" |
112 |
]) |
113 |
SWIG_PY_INCLUDES="\$(SWIG_INCLUDES) $ac_cv_python_includes" |
114 |
|
115 |
if test "$ac_cv_python_includes" = "none"; then |
116 |
SWIG_PY_ERRMSG="no distutils found" |
117 |
AC_MSG_WARN([python bindings cannot be built without distutils module]) |
118 |
else |
119 |
|
120 |
python_header_found="no" |
121 |
|
122 |
save_cppflags="$CPPFLAGS" |
123 |
CPPFLAGS="$CPPFLAGS $ac_cv_python_includes" |
124 |
AC_CHECK_HEADER(Python.h, [ |
125 |
python_header_found="yes" |
126 |
]) |
127 |
CPPFLAGS="$save_cppflags" |
128 |
|
129 |
if test "$python_header_found" = "no"; then |
130 |
SWIG_PY_ERRMSG="no Python.h found" |
131 |
AC_MSG_WARN([Python.h not found; disabling python swig bindings]) |
132 |
else |
133 |
SVN_PY3C() |
134 |
|
135 |
if test "$py3c_found" = "no"; then |
136 |
SWIG_PY_ERRMSG="py3c library not found" |
137 |
AC_MSG_WARN([py3c library not found; disabling python swig bindings]) |
138 |
else |
139 |
AC_CACHE_CHECK([for compiling Python extensions], [ac_cv_python_compile],[ |
140 |
ac_cv_python_compile="`$PYTHON ${abs_srcdir}/build/get-py-info.py --compile`" |
141 |
]) |
142 |
SWIG_PY_COMPILE="$ac_cv_python_compile $CFLAGS" |
143 |
|
144 |
AC_CACHE_CHECK([for linking Python extensions], [ac_cv_python_link],[ |
145 |
ac_cv_python_link="`$PYTHON ${abs_srcdir}/build/get-py-info.py --link`" |
146 |
]) |
147 |
SWIG_PY_LINK="$ac_cv_python_link" |
148 |
|
149 |
AC_CACHE_CHECK([for linking Python libraries], [ac_cv_python_libs],[ |
150 |
ac_cv_python_libs="`$PYTHON ${abs_srcdir}/build/get-py-info.py --libs`" |
151 |
]) |
152 |
SWIG_PY_LIBS="`SVN_REMOVE_STANDARD_LIB_DIRS($ac_cv_python_libs)`" |
153 |
|
154 |
AC_CACHE_CHECK([for Python >= 3], [ac_cv_python_is_py3],[ |
155 |
ac_cv_python_is_py3="no" |
156 |
$PYTHON -c 'import sys; sys.exit(0x3000000 > sys.hexversion)' && \ |
157 |
ac_cv_python_is_py3="yes" |
158 |
]) |
159 |
|
160 |
if test "$ac_cv_python_is_py3" = "yes"; then |
161 |
if test "$SWIG_VERSION" -ge "300010"; then |
162 |
dnl SWIG Python bindings successfully configured, clear the error message dnl |
163 |
SWIG_PY_ERRMSG="" |
164 |
else |
165 |
SWIG_PY_ERRMSG="SWIG version is not suitable" |
166 |
AC_MSG_WARN([Subversion Python bindings for Python 3 require SWIG 3.0.10 or newer]) |
167 |
fi |
168 |
if test "$SWIG_VERSION" -lt "400000"; then |
169 |
SWIG_PY_OPTS="-python -py3 -nofastunpack -modern" |
170 |
else |
171 |
SWIG_PY_OPTS="-python -py3 -nofastunpack" |
172 |
fi |
173 |
else |
174 |
if test "$SWIG_VERSION" -lt "400000"; then |
175 |
SWIG_PY_OPTS="-python -classic" |
176 |
dnl SWIG Python bindings successfully configured, clear the error message dnl |
177 |
SWIG_PY_ERRMSG="" |
178 |
else |
179 |
SWIG_PY_OPTS="-python -nofastunpack" |
180 |
SWIG_PY_ERRMSG="SWIG version is not suitable" |
181 |
AC_MSG_WARN([Subversion Python bindings for Python 2 require 1.3.24 <= SWIG < 4.0.0]) |
182 |
fi |
183 |
fi |
184 |
fi |
185 |
|
186 |
fi |
187 |
fi |
188 |
|
189 |
fi |
190 |
|
191 |
SWIG_PL_ERRMSG="check config.log for details" |
192 |
if test "$PERL" != "none"; then |
193 |
AC_MSG_CHECKING([perl version]) |
194 |
dnl Note that the q() bit is there to avoid unbalanced brackets |
195 |
dnl which m4 really doesn't like. |
196 |
PERL_VERSION="`$PERL -e 'q([[); print $]] * 1000000,$/;'`" |
197 |
AC_MSG_RESULT([$PERL_VERSION]) |
198 |
if test "$PERL_VERSION" -ge "5008000"; then |
199 |
SWIG_PL_INCLUDES="\$(SWIG_INCLUDES) `$PERL -MExtUtils::Embed -e ccopts`" |
200 |
SWIG_PL_LINK="`$PERL -MExtUtils::Embed -e ldopts`" |
201 |
SWIG_PL_LINK="`SVN_REMOVE_STANDARD_LIB_DIRS($SWIG_PL_LINK)`" |
202 |
|
203 |
dnl SWIG Perl bindings successfully configured, clear the error message |
204 |
SWIG_PL_ERRMSG="" |
205 |
else |
206 |
AC_MSG_WARN([perl bindings require perl 5.8.0 or newer.]) |
207 |
fi |
208 |
fi |
209 |
|
210 |
SWIG_RB_COMPILE="none" |
211 |
SWIG_RB_LINK="none" |
212 |
SWIG_RB_ERRMSG="check config.log for details" |
213 |
if test "$RUBY" != "none"; then |
214 |
if test x"$SWIG_VERSION" = x"3""00""008"; then |
215 |
# Use a local variable to escape the '#' sign. |
216 |
ruby_swig_issue_602='https://subversion.apache.org/docs/release-notes/1.11#ruby-swig-issue-602' |
217 |
AC_MSG_WARN([Ruby bindings are known not to support swig 3.0.8; see $ruby_swig_issue_602]) |
218 |
fi |
219 |
rbconfig="$RUBY -rrbconfig -e " |
220 |
|
221 |
for var_name in arch archdir CC LDSHARED DLEXT LIBS LIBRUBYARG \ |
222 |
rubyhdrdir rubyarchhdrdir sitedir sitelibdir sitearchdir libdir |
223 |
do |
224 |
rbconfig_tmp=`$rbconfig "print RbConfig::CONFIG@<:@'$var_name'@:>@"` |
225 |
eval "rbconfig_$var_name=\"$rbconfig_tmp\"" |
226 |
done |
227 |
|
228 |
AC_MSG_NOTICE([Configuring Ruby SWIG binding]) |
229 |
|
230 |
AC_CACHE_CHECK([for Ruby include path], [svn_cv_ruby_includes],[ |
231 |
if test -d "$rbconfig_rubyhdrdir"; then |
232 |
dnl Ruby >=1.9 |
233 |
svn_cv_ruby_includes="-I. -I$rbconfig_rubyhdrdir -I$rbconfig_rubyhdrdir/ruby -I$rbconfig_rubyhdrdir/ruby/backward" |
234 |
if test -d "$rbconfig_rubyarchhdrdir"; then |
235 |
dnl Ruby >=2.0 |
236 |
svn_cv_ruby_includes="$svn_cv_ruby_includes -I$rbconfig_rubyarchhdrdir" |
237 |
else |
238 |
svn_cv_ruby_includes="$svn_cv_ruby_includes -I$rbconfig_rubyhdrdir/$rbconfig_arch" |
239 |
fi |
240 |
else |
241 |
dnl Ruby 1.8 |
242 |
svn_cv_ruby_includes="-I. -I$rbconfig_archdir" |
243 |
fi |
244 |
]) |
245 |
SWIG_RB_INCLUDES="\$(SWIG_INCLUDES) $svn_cv_ruby_includes" |
246 |
|
247 |
AC_CACHE_CHECK([how to compile Ruby extensions], [svn_cv_ruby_compile],[ |
248 |
svn_cv_ruby_compile="$rbconfig_CC $CFLAGS" |
249 |
]) |
250 |
SWIG_RB_COMPILE="$svn_cv_ruby_compile" |
251 |
SVN_STRIP_FLAG([SWIG_RB_COMPILE], [-ansi]) |
252 |
SVN_STRIP_FLAG([SWIG_RB_COMPILE], [-std=c89]) |
253 |
SVN_STRIP_FLAG([SWIG_RB_COMPILE], [-std=c90]) |
254 |
dnl FIXME: Check that the compiler for Ruby actually supports this flag |
255 |
SWIG_RB_COMPILE="$SWIG_RB_COMPILE -Wno-int-to-pointer-cast" |
256 |
|
257 |
AC_CACHE_CHECK([how to link Ruby extensions], [svn_cv_ruby_link],[ |
258 |
svn_cv_ruby_link="`$RUBY -e 'ARGV.shift; print ARGV.join(%q( ))' \ |
259 |
$rbconfig_LDSHARED`" |
260 |
svn_cv_ruby_link="$rbconfig_CC $svn_cv_ruby_link" |
261 |
svn_cv_ruby_link="$svn_cv_ruby_link -shrext .$rbconfig_DLEXT" |
262 |
]) |
263 |
SWIG_RB_LINK="$svn_cv_ruby_link" |
264 |
|
265 |
AC_CACHE_CHECK([how to link Ruby libraries], [ac_cv_ruby_libs], [ |
266 |
ac_cv_ruby_libs="$rbconfig_LIBRUBYARG $rbconfig_LIBS" |
267 |
]) |
268 |
SWIG_RB_LIBS="`SVN_REMOVE_STANDARD_LIB_DIRS($ac_cv_ruby_libs)`" |
269 |
|
270 |
AC_MSG_CHECKING([for rb_errinfo]) |
271 |
old_CFLAGS="$CFLAGS" |
272 |
old_LIBS="$LIBS" |
273 |
CFLAGS="$CFLAGS $svn_cv_ruby_includes" |
274 |
SVN_STRIP_FLAG([CFLAGS], [-ansi]) |
275 |
SVN_STRIP_FLAG([CFLAGS], [-std=c89]) |
276 |
SVN_STRIP_FLAG([CFLAGS], [-std=c90]) |
277 |
LIBS="$SWIG_RB_LIBS" |
278 |
AC_LINK_IFELSE([AC_LANG_SOURCE([[ |
279 |
#include <ruby.h> |
280 |
int main() |
281 |
{rb_errinfo();}]])], have_rb_errinfo="yes", have_rb_errinfo="no") |
282 |
if test "$have_rb_errinfo" = "yes"; then |
283 |
AC_MSG_RESULT([yes]) |
284 |
AC_DEFINE([HAVE_RB_ERRINFO], [1], |
285 |
[Define to 1 if you have the `rb_errinfo' function.]) |
286 |
else |
287 |
AC_MSG_RESULT([no]) |
288 |
fi |
289 |
CFLAGS="$old_CFLAGS" |
290 |
LIBS="$old_LIBS" |
291 |
|
292 |
AC_CACHE_VAL([svn_cv_ruby_sitedir],[ |
293 |
svn_cv_ruby_sitedir="$rbconfig_sitedir" |
294 |
]) |
295 |
AC_ARG_WITH([ruby-sitedir], |
296 |
AS_HELP_STRING([--with-ruby-sitedir=SITEDIR], |
297 |
[install Ruby bindings in SITEDIR |
298 |
(default is same as ruby's one)]), |
299 |
[svn_ruby_installdir="$withval"], |
300 |
[svn_ruby_installdir="$svn_cv_ruby_sitedir"]) |
301 |
|
302 |
AC_MSG_CHECKING([where to install Ruby scripts]) |
303 |
AC_CACHE_VAL([svn_cv_ruby_sitedir_libsuffix],[ |
304 |
svn_cv_ruby_sitedir_libsuffix="`echo "$rbconfig_sitelibdir" | \ |
305 |
$SED -e "s,^$rbconfig_sitedir,,"`" |
306 |
]) |
307 |
SWIG_RB_SITE_LIB_DIR="${svn_ruby_installdir}${svn_cv_ruby_sitedir_libsuffix}" |
308 |
AC_MSG_RESULT([$SWIG_RB_SITE_LIB_DIR]) |
309 |
|
310 |
AC_MSG_CHECKING([where to install Ruby extensions]) |
311 |
AC_CACHE_VAL([svn_cv_ruby_sitedir_archsuffix],[ |
312 |
svn_cv_ruby_sitedir_archsuffix="`echo "$rbconfig_sitearchdir" | \ |
313 |
$SED -e "s,^$rbconfig_sitedir,,"`" |
314 |
]) |
315 |
SWIG_RB_SITE_ARCH_DIR="${svn_ruby_installdir}${svn_cv_ruby_sitedir_archsuffix}" |
316 |
AC_MSG_RESULT([$SWIG_RB_SITE_ARCH_DIR]) |
317 |
|
318 |
AC_MSG_CHECKING([how to use output level for Ruby bindings tests]) |
319 |
AC_CACHE_VAL([svn_cv_ruby_test_verbose],[ |
320 |
svn_cv_ruby_test_verbose="normal" |
321 |
]) |
322 |
AC_ARG_WITH([ruby-test-verbose], |
323 |
AS_HELP_STRING([--with-ruby-test-verbose=LEVEL], |
324 |
[how to use output level for Ruby bindings tests |
325 |
(default is normal)]), |
326 |
[svn_ruby_test_verbose="$withval"], |
327 |
[svn_ruby_test_verbose="$svn_cv_ruby_test_verbose"]) |
328 |
SWIG_RB_TEST_VERBOSE="$svn_ruby_test_verbose" |
329 |
AC_MSG_RESULT([$SWIG_RB_TEST_VERBOSE]) |
330 |
|
331 |
dnl SWIG Ruby bindings successfully configured, clear the error message |
332 |
SWIG_RB_ERRMSG="" |
333 |
fi |
334 |
AC_SUBST(SWIG) |
335 |
AC_SUBST(SWIG_PY_INCLUDES) |
336 |
AC_SUBST(SWIG_PY_COMPILE) |
337 |
AC_SUBST(SWIG_PY_LINK) |
338 |
AC_SUBST(SWIG_PY_LIBS) |
339 |
AC_SUBST(SWIG_PY_OPTS) |
340 |
AC_SUBST(SWIG_PY_ERRMSG) |
341 |
AC_SUBST(SWIG_PL_INCLUDES) |
342 |
AC_SUBST(SWIG_PL_LINK) |
343 |
AC_SUBST(SWIG_PL_ERRMSG) |
344 |
AC_SUBST(SWIG_RB_LINK) |
345 |
AC_SUBST(SWIG_RB_LIBS) |
346 |
AC_SUBST(SWIG_RB_INCLUDES) |
347 |
AC_SUBST(SWIG_RB_COMPILE) |
348 |
AC_SUBST(SWIG_RB_SITE_LIB_DIR) |
349 |
AC_SUBST(SWIG_RB_SITE_ARCH_DIR) |
350 |
AC_SUBST(SWIG_RB_TEST_VERBOSE) |
351 |
AC_SUBST(SWIG_RB_ERRMSG) |
352 |
]) |