/[Apache-SVN]/subversion/trunk/build/ac-macros/swig.m4
ViewVC logotype

Contents of /subversion/trunk/build/ac-macros/swig.m4

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1878379 - (show annotations) (download)
Tue Jun 2 03:08:35 2020 UTC (4 years, 1 month ago) by futatuki
File size: 13596 byte(s)
configure: Add new option to specify path to swig bindings targets

Before this commit, it was not possible to use distinct Python
installations for the build system and test suite on the one hand,
and for building language bindings against on the other hand.

So we introduce new variable "SWIG_PY_PYTHON" for a target of
the SWIG Python bindings and a configure option to specify it. 
Also, for the symmetry we introduce "SWIG_PL_PERL" and
"SWIG_RB_RUBY" for the Perl and Ruby SWIG bindings, and options
to specify them.

* configure.ac ():
  - Use variables "SWIG_PL_PERL", "SWIG_PY_PYTHON", "SWIG_RB_RUBY" for
    targets of the SWIG Perl, Python, Ruby bindings instead of "PERL",
    "PYTHON", "RUBY".
  - Introduce --with-swig-perl, --with-swig-python, --with-swig-ruby
    options for setting variables "SWIG_PL_PERL", "SWIG_PY_PYTHON",
    "SWIG_RB_RUBY".

* Makefile.in, build/ac-macros/swig.m4 ():
  Use variables "SWIG_PL_PERL", "SWIG_PY_PYTHON", "SWIG_RB_RUBY" for
  targets of the SWIG Perl, Python, Ruby bindings instead of "PERL",
  "PYTHON", "RUBY".

* subversion/bindings/swig/INSTALL
  (BUILDING SWIG BINDINGS FOR SVN ON UNIX step 2):
  - Describe how to specify the path to the target language interpreters
    with the new options, instead of using environment variables.
  - Fix the name of glue libraries.

Review by: danielsh

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 "$SWIG_PY_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="`$SWIG_PY_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="`$SWIG_PY_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="`$SWIG_PY_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="`$SWIG_PY_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 if test "$SWIG" = "none"; then
155 SWIG_PY_ERRMSG=""
156 else
157 # Look more closely at the SWIG and Python versions to
158 # determine SWIG_PY_OPTS. We can skip this if we already
159 # have the SWIG-generated files.
160 AC_CACHE_CHECK([for Python >= 3], [ac_cv_python_is_py3],[
161 ac_cv_python_is_py3="no"
162 $SWIG_PY_PYTHON -c 'import sys; sys.exit(0x3000000 > sys.hexversion)' && \
163 ac_cv_python_is_py3="yes"
164 ])
165
166 if test "$ac_cv_python_is_py3" = "yes"; then
167 if test "$SWIG_VERSION" -ge "300010"; then
168 dnl SWIG Python bindings successfully configured, clear the error message dnl
169 SWIG_PY_ERRMSG=""
170 else
171 SWIG_PY_ERRMSG="SWIG version is not suitable"
172 AC_MSG_WARN([Subversion Python bindings for Python 3 require SWIG 3.0.10 or newer])
173 fi
174 if test "$SWIG_VERSION" -lt "400000"; then
175 SWIG_PY_OPTS="-python -py3 -nofastunpack -modern"
176 else
177 SWIG_PY_OPTS="-python -py3 -nofastunpack"
178 fi
179 else
180 if test "$SWIG_VERSION" -lt "400000"; then
181 SWIG_PY_OPTS="-python -classic"
182 dnl SWIG Python bindings successfully configured, clear the error message dnl
183 SWIG_PY_ERRMSG=""
184 else
185 SWIG_PY_OPTS="-python -nofastunpack"
186 SWIG_PY_ERRMSG="SWIG version is not suitable"
187 AC_MSG_WARN([Subversion Python bindings for Python 2 require 1.3.24 <= SWIG < 4.0.0])
188 fi
189 fi
190 fi
191 fi
192 fi
193 fi
194
195 fi
196
197 SWIG_PL_ERRMSG="check config.log for details"
198 if test "$SWIG_PL_PERL" != "none"; then
199 AC_MSG_CHECKING([perl version])
200 dnl Note that the q() bit is there to avoid unbalanced brackets
201 dnl which m4 really doesn't like.
202 PERL_VERSION="`$SWIG_PL_PERL -e 'q([[); print $]] * 1000000,$/;'`"
203 AC_MSG_RESULT([$PERL_VERSION])
204 if test "$PERL_VERSION" -ge "5008000"; then
205 SWIG_PL_INCLUDES="\$(SWIG_INCLUDES) `$SWIG_PL_PERL -MExtUtils::Embed -e ccopts`"
206 SWIG_PL_LINK="`$SWIG_PL_PERL -MExtUtils::Embed -e ldopts`"
207 SWIG_PL_LINK="`SVN_REMOVE_STANDARD_LIB_DIRS($SWIG_PL_LINK)`"
208
209 dnl SWIG Perl bindings successfully configured, clear the error message
210 SWIG_PL_ERRMSG=""
211 else
212 AC_MSG_WARN([perl bindings require perl 5.8.0 or newer.])
213 fi
214 fi
215
216 SWIG_RB_COMPILE="none"
217 SWIG_RB_LINK="none"
218 SWIG_RB_ERRMSG="check config.log for details"
219 if test "$SWIG_RB_RUBY" != "none"; then
220 if test x"$SWIG_VERSION" = x"3""00""008"; then
221 # Use a local variable to escape the '#' sign.
222 ruby_swig_issue_602='https://subversion.apache.org/docs/release-notes/1.11#ruby-swig-issue-602'
223 AC_MSG_WARN([Ruby bindings are known not to support swig 3.0.8; see $ruby_swig_issue_602])
224 fi
225 rbconfig="$SWIG_RB_RUBY -rrbconfig -e "
226
227 for var_name in arch archdir CC LDSHARED DLEXT LIBS LIBRUBYARG \
228 rubyhdrdir rubyarchhdrdir sitedir sitelibdir sitearchdir libdir
229 do
230 rbconfig_tmp=`$rbconfig "print RbConfig::CONFIG@<:@'$var_name'@:>@"`
231 eval "rbconfig_$var_name=\"$rbconfig_tmp\""
232 done
233
234 AC_MSG_NOTICE([Configuring Ruby SWIG binding])
235
236 AC_CACHE_CHECK([for Ruby include path], [svn_cv_ruby_includes],[
237 if test -d "$rbconfig_rubyhdrdir"; then
238 dnl Ruby >=1.9
239 svn_cv_ruby_includes="-I. -I$rbconfig_rubyhdrdir"
240 if test -d "$rbconfig_rubyarchhdrdir"; then
241 dnl Ruby >=2.0
242 svn_cv_ruby_includes="$svn_cv_ruby_includes -I$rbconfig_rubyarchhdrdir"
243 else
244 svn_cv_ruby_includes="$svn_cv_ruby_includes -I$rbconfig_rubyhdrdir/$rbconfig_arch"
245 fi
246 else
247 dnl Ruby 1.8
248 svn_cv_ruby_includes="-I. -I$rbconfig_archdir"
249 fi
250 ])
251 SWIG_RB_INCLUDES="\$(SWIG_INCLUDES) $svn_cv_ruby_includes"
252
253 AC_CACHE_CHECK([how to compile Ruby extensions], [svn_cv_ruby_compile],[
254 svn_cv_ruby_compile="$rbconfig_CC $CFLAGS"
255 ])
256 SWIG_RB_COMPILE="$svn_cv_ruby_compile"
257 SVN_STRIP_FLAG([SWIG_RB_COMPILE], [-ansi])
258 SVN_STRIP_FLAG([SWIG_RB_COMPILE], [-std=c89])
259 SVN_STRIP_FLAG([SWIG_RB_COMPILE], [-std=c90])
260 dnl FIXME: Check that the compiler for Ruby actually supports this flag
261 SWIG_RB_COMPILE="$SWIG_RB_COMPILE -Wno-int-to-pointer-cast"
262
263 AC_CACHE_CHECK([how to link Ruby extensions], [svn_cv_ruby_link],[
264 svn_cv_ruby_link="`$SWIG_RB_RUBY -e 'ARGV.shift; print ARGV.join(%q( ))' \
265 $rbconfig_LDSHARED`"
266 svn_cv_ruby_link="$rbconfig_CC $svn_cv_ruby_link"
267 svn_cv_ruby_link="$svn_cv_ruby_link -shrext .$rbconfig_DLEXT"
268 ])
269 SWIG_RB_LINK="$svn_cv_ruby_link"
270
271 AC_CACHE_CHECK([how to link Ruby libraries], [ac_cv_ruby_libs], [
272 ac_cv_ruby_libs="$rbconfig_LIBRUBYARG $rbconfig_LIBS"
273 ])
274 SWIG_RB_LIBS="`SVN_REMOVE_STANDARD_LIB_DIRS($ac_cv_ruby_libs)`"
275
276 AC_MSG_CHECKING([for rb_errinfo])
277 old_CFLAGS="$CFLAGS"
278 old_LIBS="$LIBS"
279 CFLAGS="$CFLAGS $svn_cv_ruby_includes"
280 SVN_STRIP_FLAG([CFLAGS], [-ansi])
281 SVN_STRIP_FLAG([CFLAGS], [-std=c89])
282 SVN_STRIP_FLAG([CFLAGS], [-std=c90])
283 LIBS="$SWIG_RB_LIBS"
284 AC_LINK_IFELSE([AC_LANG_SOURCE([[
285 #include <ruby.h>
286 int main()
287 {rb_errinfo();}]])], have_rb_errinfo="yes", have_rb_errinfo="no")
288 if test "$have_rb_errinfo" = "yes"; then
289 AC_MSG_RESULT([yes])
290 AC_DEFINE([HAVE_RB_ERRINFO], [1],
291 [Define to 1 if you have the `rb_errinfo' function.])
292 else
293 AC_MSG_RESULT([no])
294 fi
295 CFLAGS="$old_CFLAGS"
296 LIBS="$old_LIBS"
297
298 AC_CACHE_VAL([svn_cv_ruby_sitedir],[
299 svn_cv_ruby_sitedir="$rbconfig_sitedir"
300 ])
301 AC_ARG_WITH([ruby-sitedir],
302 AS_HELP_STRING([--with-ruby-sitedir=SITEDIR],
303 [install Ruby bindings in SITEDIR
304 (default is same as ruby's one)]),
305 [svn_ruby_installdir="$withval"],
306 [svn_ruby_installdir="$svn_cv_ruby_sitedir"])
307
308 AC_MSG_CHECKING([where to install Ruby scripts])
309 AC_CACHE_VAL([svn_cv_ruby_sitedir_libsuffix],[
310 svn_cv_ruby_sitedir_libsuffix="`echo "$rbconfig_sitelibdir" | \
311 $SED -e "s,^$rbconfig_sitedir,,"`"
312 ])
313 SWIG_RB_SITE_LIB_DIR="${svn_ruby_installdir}${svn_cv_ruby_sitedir_libsuffix}"
314 AC_MSG_RESULT([$SWIG_RB_SITE_LIB_DIR])
315
316 AC_MSG_CHECKING([where to install Ruby extensions])
317 AC_CACHE_VAL([svn_cv_ruby_sitedir_archsuffix],[
318 svn_cv_ruby_sitedir_archsuffix="`echo "$rbconfig_sitearchdir" | \
319 $SED -e "s,^$rbconfig_sitedir,,"`"
320 ])
321 SWIG_RB_SITE_ARCH_DIR="${svn_ruby_installdir}${svn_cv_ruby_sitedir_archsuffix}"
322 AC_MSG_RESULT([$SWIG_RB_SITE_ARCH_DIR])
323
324 AC_MSG_CHECKING([how to use output level for Ruby bindings tests])
325 AC_CACHE_VAL([svn_cv_ruby_test_verbose],[
326 svn_cv_ruby_test_verbose="normal"
327 ])
328 AC_ARG_WITH([ruby-test-verbose],
329 AS_HELP_STRING([--with-ruby-test-verbose=LEVEL],
330 [how to use output level for Ruby bindings tests
331 (default is normal)]),
332 [svn_ruby_test_verbose="$withval"],
333 [svn_ruby_test_verbose="$svn_cv_ruby_test_verbose"])
334 SWIG_RB_TEST_VERBOSE="$svn_ruby_test_verbose"
335 AC_MSG_RESULT([$SWIG_RB_TEST_VERBOSE])
336
337 dnl SWIG Ruby bindings successfully configured, clear the error message
338 SWIG_RB_ERRMSG=""
339 fi
340 AC_SUBST(SWIG)
341 AC_SUBST(SWIG_PY_INCLUDES)
342 AC_SUBST(SWIG_PY_COMPILE)
343 AC_SUBST(SWIG_PY_LINK)
344 AC_SUBST(SWIG_PY_LIBS)
345 AC_SUBST(SWIG_PY_OPTS)
346 AC_SUBST(SWIG_PY_ERRMSG)
347 AC_SUBST(SWIG_PL_INCLUDES)
348 AC_SUBST(SWIG_PL_LINK)
349 AC_SUBST(SWIG_PL_ERRMSG)
350 AC_SUBST(SWIG_RB_LINK)
351 AC_SUBST(SWIG_RB_LIBS)
352 AC_SUBST(SWIG_RB_INCLUDES)
353 AC_SUBST(SWIG_RB_COMPILE)
354 AC_SUBST(SWIG_RB_SITE_LIB_DIR)
355 AC_SUBST(SWIG_RB_SITE_ARCH_DIR)
356 AC_SUBST(SWIG_RB_TEST_VERBOSE)
357 AC_SUBST(SWIG_RB_ERRMSG)
358 ])

Properties

Name Value
svn:eol-style native

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26