Fix compiler warning due to missing function prototype.
[svn.git] / build / ac-macros / swig.m4
blob7c8a80ddd046a12cd44dbd850481628f89cf0c09
1 dnl check to see if SWIG is current enough.
2 dnl
3 dnl if it is, then check to see if we have the correct version of python.
4 dnl
5 dnl if we do, then set up the appropriate SWIG_ variables to build the 
6 dnl python bindings.
8 AC_DEFUN(SVN_CHECK_SWIG,
10   AC_ARG_WITH(swig,
11               AS_HELP_STRING([--with-swig=PATH],
12                              [Try to use 'PATH/bin/swig' to build the
13                               swig bindings.  If PATH is not specified,
14                               look for a 'swig' binary in your PATH.]),
15   [
16     case "$withval" in
17       "no")
18         SWIG_SUITABLE=no
19         SVN_FIND_SWIG(no)
20       ;;
21       "yes")
22         SVN_FIND_SWIG(check)
23       ;;
24       *)
25         SVN_FIND_SWIG($withval)
26       ;;
27     esac
28   ],
29   [
30     SVN_FIND_SWIG(check)
31   ])
34 AC_DEFUN(SVN_FIND_SWIG,
36   where=$1
38   if test $where = no; then
39     AC_PATH_PROG(SWIG, none, none)
40   elif test $where = check; then
41     AC_PATH_PROG(SWIG, swig, none)
42   else
43     if test -f "$where"; then
44       SWIG="$where"
45     else
46       SWIG="$where/bin/swig"
47     fi
48     if test ! -f "$SWIG" || test ! -x "$SWIG"; then
49       AC_MSG_ERROR([Could not find swig binary at $SWIG])
50     fi 
51   fi
53   if test "$SWIG" != "none"; then
54     AC_MSG_CHECKING([swig version])
55     SWIG_VERSION_RAW="`$SWIG -version 2>&1 | \
56                        sed -ne 's/^.*Version \(.*\)$/\1/p'`"
57     # We want the version as an integer so we can test against
58     # which version we're using.  SWIG doesn't provide this
59     # to us so we have to come up with it on our own. 
60     # The major is passed straight through,
61     # the minor is zero padded to two places,
62     # and the patch level is zero padded to three places.
63     # e.g. 1.3.24 becomes 103024
64     SWIG_VERSION="`echo \"$SWIG_VERSION_RAW\" | \
65                   sed -e 's/[[^0-9\.]].*$//' \
66                       -e 's/\.\([[0-9]]\)$/.0\1/' \
67                       -e 's/\.\([[0-9]][[0-9]]\)$/.0\1/' \
68                       -e 's/\.\([[0-9]]\)\./0\1/; s/\.//g;'`"
69     AC_MSG_RESULT([$SWIG_VERSION_RAW])
70     # If you change the required swig version number, don't forget to update:
71     #   subversion/bindings/swig/INSTALL
72     #   packages/rpm/redhat-8+/subversion.spec
73     #   packages/rpm/redhat-7.x/subversion.spec
74     #   packages/rpm/rhel-3/subversion.spec
75     #   packages/rpm/rhel-4/subversion.spec
76     if test -n "$SWIG_VERSION" &&
77        test "$SWIG_VERSION" -ge "103024" &&
78        test "$SWIG_VERSION" -le "103031"; then
79       SWIG_SUITABLE=yes
80     else
81       SWIG_SUITABLE=no
82       AC_MSG_WARN([Detected SWIG version $SWIG_VERSION_RAW])
83       AC_MSG_WARN([Subversion requires 1.3.24 or later, and is known to work])
84       AC_MSG_WARN([with versions up to 1.3.31])
85     fi
86   fi
88   SWIG_PY_COMPILE="none"
89   SWIG_PY_LINK="none"
90   if test "$PYTHON" != "none"; then
91     AC_MSG_NOTICE([Configuring python swig binding])
93     AC_CACHE_CHECK([for Python includes], [ac_cv_python_includes],[
94       ac_cv_python_includes="`$PYTHON ${abs_srcdir}/build/get-py-info.py --includes`"
95     ])
96     SWIG_PY_INCLUDES="\$(SWIG_INCLUDES) $ac_cv_python_includes"
98     if test "$ac_cv_python_includes" = "none"; then
99       AC_MSG_WARN([python bindings cannot be built without distutils module])
100     fi
102     AC_CACHE_CHECK([for compiling Python extensions], [ac_cv_python_compile],[
103       ac_cv_python_compile="`$PYTHON ${abs_srcdir}/build/get-py-info.py --compile`"
104     ])
105     SWIG_PY_COMPILE="$ac_cv_python_compile"
107     AC_CACHE_CHECK([for linking Python extensions], [ac_cv_python_link],[
108       ac_cv_python_link="`$PYTHON ${abs_srcdir}/build/get-py-info.py --link`"
109     ])
110     SWIG_PY_LINK="$ac_cv_python_link"
112     AC_CACHE_CHECK([for linking Python libraries], [ac_cv_python_libs],[
113       ac_cv_python_libs="`$PYTHON ${abs_srcdir}/build/get-py-info.py --libs`"
114     ])
115     SWIG_PY_LIBS="$ac_cv_python_libs"
117     dnl Sun Forte adds an extra space before substituting APR_INT64_T_FMT
118     dnl gcc-2.95 adds an extra space after substituting APR_INT64_T_FMT
119     dnl thus the egrep patterns have a + in them.
120     SVN_PYCFMT_SAVE_CPPFLAGS="$CPPFLAGS"
121     CPPFLAGS="$CPPFLAGS $SVN_APR_INCLUDES"
122     AC_CACHE_CHECK([for apr_int64_t Python/C API format string],
123                    [svn_cv_pycfmt_apr_int64_t], [
124       if test "x$svn_cv_pycfmt_apr_int64_t" = "x"; then
125         AC_EGREP_CPP([MaTcHtHiS +\"lld\" +EnDeNd],
126                      [#include <apr.h>
127                       MaTcHtHiS APR_INT64_T_FMT EnDeNd],
128                      [svn_cv_pycfmt_apr_int64_t="L"])
129       fi
130       if test "x$svn_cv_pycfmt_apr_int64_t" = "x"; then
131         AC_EGREP_CPP([MaTcHtHiS +\"ld\" +EnDeNd],r
132                      [#include <apr.h>
133                       MaTcHtHiS APR_INT64_T_FMT EnDeNd],
134                      [svn_cv_pycfmt_apr_int64_t="l"])
135       fi
136       if test "x$svn_cv_pycfmt_apr_int64_t" = "x"; then
137         AC_EGREP_CPP([MaTcHtHiS +\"d\" +EnDeNd],
138                      [#include <apr.h>
139                       MaTcHtHiS APR_INT64_T_FMT EnDeNd],
140                      [svn_cv_pycfmt_apr_int64_t="i"])
141       fi
142     ])
143     CPPFLAGS="$SVN_PYCFMT_SAVE_CPPFLAGS"
144     if test "x$svn_cv_pycfmt_apr_int64_t" = "x"; then
145       AC_MSG_ERROR([failed to recognize APR_INT64_T_FMT on this platform])
146     fi
147     AC_DEFINE_UNQUOTED([SVN_APR_INT64_T_PYCFMT],
148                        ["$svn_cv_pycfmt_apr_int64_t"],
149                        [Define to the Python/C API format character suitable]
150                        [ for apr_int64_t])
151   fi
153   if test "$PERL" != "none"; then
154     AC_MSG_CHECKING([perl version])
155     dnl Note that the q() bit is there to avoid unbalanced brackets
156     dnl which m4 really doesn't like.
157     PERL_VERSION="`$PERL -e 'q([[); print $]] * 1000000,$/;'`"
158     AC_MSG_RESULT([$PERL_VERSION])
159     if test "$PERL_VERSION" -ge "5008000"; then
160       SWIG_PL_INCLUDES="\$(SWIG_INCLUDES) `$PERL -MExtUtils::Embed -e ccopts`"
161     else
162       AC_MSG_WARN([perl bindings require perl 5.8.0 or newer.])
163     fi
164   fi
166   SWIG_RB_COMPILE="none"
167   SWIG_RB_LINK="none"
168   if test "$RUBY" != "none"; then
169     rbconfig="$RUBY -rrbconfig -e "
171     for var_name in archdir CC CFLAGS LDSHARED DLEXT LIBRUBYARG \
172                     sitedir sitelibdir sitearchdir libdir
173     do
174       rbconfig_tmp=`$rbconfig "print Config::CONFIG@<:@'$var_name'@:>@"`
175       eval "rbconfig_$var_name=\"$rbconfig_tmp\""
176     done
178     AC_MSG_NOTICE([Configuring Ruby SWIG binding])
180     AC_CACHE_CHECK([for Ruby include path], [svn_cv_ruby_includes],[
181     svn_cv_ruby_includes="-I. -I$rbconfig_archdir"
182     ])
183     SWIG_RB_INCLUDES="\$(SWIG_INCLUDES) $svn_cv_ruby_includes"
185     AC_CACHE_CHECK([how to compile Ruby extensions], [svn_cv_ruby_compile],[
186       svn_cv_ruby_compile="$rbconfig_CC $rbconfig_CFLAGS"
187     ])
188     SWIG_RB_COMPILE="$svn_cv_ruby_compile"
190     AC_CACHE_CHECK([how to link Ruby extensions], [svn_cv_ruby_link],[
191       svn_cv_ruby_link="`$RUBY -e 'ARGV.shift; print ARGV.join(%q( ))' \
192                            $rbconfig_LDSHARED`"
193       svn_cv_ruby_link="$rbconfig_CC $svn_cv_ruby_link"
194       svn_cv_ruby_link="$svn_cv_ruby_link -shrext .$rbconfig_DLEXT"
195     ])
196     SWIG_RB_LINK="$svn_cv_ruby_link"
198     AC_CACHE_CHECK([for linking Ruby libraries], [ac_cv_ruby_libs], [
199       ac_cv_ruby_libs="$rbconfig_LIBRUBYARG"
200     ])
201     SWIG_RB_LIBS="$ac_cv_ruby_libs"
203     AC_CACHE_VAL([svn_cv_ruby_sitedir],[
204       svn_cv_ruby_sitedir="$rbconfig_sitedir"
205     ])
206     AC_ARG_WITH([ruby-sitedir],
207     AS_HELP_STRING([--with-ruby-sitedir=SITEDIR],
208                                [install Ruby bindings in SITEDIR
209                                 (default is same as ruby's one)]),
210     [svn_ruby_installdir="$withval"],
211     [svn_ruby_installdir="$svn_cv_ruby_sitedir"])
213     AC_MSG_CHECKING([where to install Ruby scripts])
214     AC_CACHE_VAL([svn_cv_ruby_sitedir_libsuffix],[
215       svn_cv_ruby_sitedir_libsuffix="`echo \"$rbconfig_sitelibdir\" | \
216                                         sed -e \"s,^$rbconfig_sitedir,,\"`"
217     ])
218     SWIG_RB_SITE_LIB_DIR="${svn_ruby_installdir}${svn_cv_ruby_sitedir_libsuffix}"
219     AC_MSG_RESULT([$SWIG_RB_SITE_LIB_DIR])
221     AC_MSG_CHECKING([where to install Ruby extensions])
222     AC_CACHE_VAL([svn_cv_ruby_sitedir_archsuffix],[
223       svn_cv_ruby_sitedir_archsuffix="`echo \"$rbconfig_sitearchdir\" | \
224                                         sed -e \"s,^$rbconfig_sitedir,,\"`"
225     ])
226     SWIG_RB_SITE_ARCH_DIR="${svn_ruby_installdir}${svn_cv_ruby_sitedir_archsuffix}"
227     AC_MSG_RESULT([$SWIG_RB_SITE_ARCH_DIR])
229     AC_MSG_CHECKING([how to use output level for Ruby bindings tests])
230     AC_CACHE_VAL([svn_cv_ruby_test_verbose],[
231       svn_cv_ruby_test_verbose="normal"
232     ])
233     AC_ARG_WITH([ruby-test-verbose],
234     AS_HELP_STRING([--with-ruby-test-verbose=LEVEL],
235                                [how to use output level for Ruby bindings tests
236                                 (default is normal)]),
237     [svn_ruby_test_verbose="$withval"],
238                   [svn_ruby_test_verbose="$svn_cv_ruby_test_verbose"])
239       SWIG_RB_TEST_VERBOSE="$svn_ruby_test_verbose"
240       AC_MSG_RESULT([$SWIG_RB_TEST_VERBOSE])
241   fi
242   AC_SUBST(SWIG)
243   AC_SUBST(SWIG_PY_INCLUDES)
244   AC_SUBST(SWIG_PY_COMPILE)
245   AC_SUBST(SWIG_PY_LINK)
246   AC_SUBST(SWIG_PY_LIBS)
247   AC_SUBST(SWIG_PL_INCLUDES)
248   AC_SUBST(SWIG_RB_LINK)
249   AC_SUBST(SWIG_RB_LIBS)
250   AC_SUBST(SWIG_RB_INCLUDES)
251   AC_SUBST(SWIG_RB_COMPILE)
252   AC_SUBST(SWIG_RB_SITE_LIB_DIR)
253   AC_SUBST(SWIG_RB_SITE_ARCH_DIR)
254   AC_SUBST(SWIG_RB_TEST_VERBOSE)