Index: Makefile.in
===================================================================
--- Makefile.in	(revision 8496)
+++ Makefile.in	(working copy)
@@ -92,8 +92,12 @@
 APACHE_LIBEXECDIR = $(DESTDIR)@APACHE_LIBEXECDIR@
 
 SWIG = @SWIG@
+SWIG_VERSION = @SWIG_VERSION@
+SWIG_LIBSWIG_DIR = @SWIG_LIBSWIG_DIR@
 SWIG_INCLUDES = -I$(SWIG_SRC_DIR) \
                 -I$(abs_srcdir)/subversion/include \
+                -I$(SWIG_LIBSWIG_DIR) \
+                -DSVN_SWIG_VERSION=$(SWIG_VERSION) \
                 $(SVN_APR_INCLUDES) $(SVN_APRUTIL_INCLUDES)
 SWIG_LDFLAGS = @SWIG_LDFLAGS@
 SWIG_PY_INCLUDES = @SWIG_PY_INCLUDES@
Index: subversion/bindings/swig/swigutil_pl.h
===================================================================
--- subversion/bindings/swig/swigutil_pl.h	(revision 8496)
+++ subversion/bindings/swig/swigutil_pl.h	(working copy)
@@ -52,11 +52,11 @@
 
 #ifdef SVN_NEED_SWIG_TYPES
 
-/* XXX: this has to be set by configure and also swig -swiglib needs
-   to be added to include paths.
-*/
-#if SWIG_VERSION >= 0x010320
+#if SVN_SWIG_VERSION >= 103020
 #include "perl5/precommon.swg"
+/* The following two aren't handled by the precommon.swg.  */
+#define SWIG_MakePtr SWIG_Perl_MakePtr
+#define SWIG_ConvertPtr SWIG_Perl_ConvertPtr
 #endif
 
 typedef struct _unnamed swig_type_info;
Index: subversion/bindings/swig/README
===================================================================
--- subversion/bindings/swig/README	(revision 8496)
+++ subversion/bindings/swig/README	(working copy)
@@ -51,8 +51,8 @@
 (4) limited symbols/functionality exported via the _util module
 
 
-NOTE: the bindings code is being developed using SWIG 1.3.16. Earlier
-versions of SWIG will simply *not* work.
+NOTE: the bindings code is being developed using SWIG 1.3.19 or
+later.  Earlier versions of SWIG will simply *not* work.
 
 
 
Index: subversion/bindings/swig/perl/Makefile.PL
===================================================================
--- subversion/bindings/swig/perl/Makefile.PL	(revision 8496)
+++ subversion/bindings/swig/perl/Makefile.PL	(working copy)
@@ -1,7 +1,23 @@
 #!/usr/bin/perl
 use ExtUtils::MakeMaker;
 use Cwd 'abs_path';
+use Config;
 
+my $perl_path = $Config{perlpath};
+if ($^O ne 'VMS') {
+  $perl_path .= $Config{_exe} unless $perl_path =~ m/$Config{_exe}$/i;
+}
+
+my $swig_version;
+open TOPMAKE, "<../../../../Makefile";
+while (<TOPMAKE>) {
+  /^SWIG_VERSION\s*=\s*(\d+)\s*$/;
+  if (defined($1)) {
+    $swig_version = $1;
+  }
+}
+close TOPMAKE;
+
 my @modules = qw/client delta fs ra repos wc/;
 my @ldpaths = ('../.libs',
                map {"../../../libsvn_$_/.libs"} (@modules, qw/diff subr/));
@@ -26,7 +42,7 @@
 my %config = (
     ABSTRACT => 'Perl bindings for Subversion',
     CCFLAGS  => join(' ', $apr_cflags, $apu_cflags, 
-                     `perl -MExtUtils::Embed -e ccopts`,
+                     `$perl_path -MExtUtils::Embed -e ccopts`,
                      ' -I.. -I../../../include -g'),
     OBJECT => q/$(O_FILES)/,
     LIBS => [join(' ', $apr_ldflags,
@@ -61,23 +77,59 @@
 
 sub MY::postamble {
    package MY ;
-   return join('', "all :: modules\ntest :: modules\ninstall :: modules\n\n",
-	       "par :: all\n\t",
-	       q{perl -MPAR::Dist -e"blib_to_par(name=>'SVN',version=>'`perl -Mblib -MSVN::Core -e'print $$SVN::Core::VERSION'`')"},"\n\n",
-	       # h2i
-	       "ra_plugin.hi: ../../../include/svn_ra.h\n\tperl h2i.pl ../../../include/svn_ra.h svn_ra_plugin_t > \$@\n\n",
-	       "ra_reporter.hi: ../../../include/svn_ra.h\n\tperl h2i.pl ../../../include/svn_ra.h svn_ra_reporter_t > \$@\n\n",
-	       "delta_editor.hi: ../../../include/svn_delta.h\n\tperl h2i.pl ../../../include/svn_delta.h svn_delta_editor_t > \$@\n\n",
-	       "modules :: ",(map { " svn_$_.c"} @modules),"\n",
-	       (map {"\tmake -f Makefile.$_\n"} @modules),
-	       "\t\$(NOECHO) \$(TOUCH) \$\@",
-	       # swig
-	       "\ncore.c :: ../core.i\n",
-	       "\tswig -c -nopm -perl -I.. -I../../../include $apr_cflags -module SVN::_Core -o core.c ../core.i\n", 
-	       (map {"\nsvn_$_.c : ../svn_$_.i ra_plugin.hi ra_reporter.hi delta_editor.hi\n".
-			"\tswig -c -nopm -perl -I.. -I../../../include $apr_cflags -module SVN::_".main::perlish($_)." -o svn_$_.c ../svn_$_.i\n"}
-	       @modules),
-               "\nFULLPERLRUN=$apr_shlib_path_var=",join(':',@ldpaths),
-               " \$(FULLPERL)\n",
-	      );
+   
+   my $module_c_files = join (' ',map { "svn_$_.c"} @modules);
+   my $module_make_commands = join ('',map {"\tmake -f Makefile.$_\n"} @modules);
+
+   my $flags;
+   if ($swig_version >= 103020) {
+     $flags = '-noruntime -noproxy';
+   } else {
+     $flags = '-c';
+   }
+   
+   my $swig_command = "swig $flags -nopm -perl " .
+                      "-I.. -I../../../include $apr_cflags";
+
+   my $swig_modules_command = join ('',
+                                    map {"\nsvn_$_.c : ../svn_$_.i ".
+                                         "ra_plugin.hi ra_reporter.hi ".
+                                         "delta_editor.hi\n" .
+                                         "\t$swig_command -module SVN::_".
+                                         main::perlish($_) .
+                                         " -o svn_$_.c ../svn_$_.i\n"}
+                                         @modules
+                                   );
+
+  my $fullperlrun = "$apr_shlib_path_var=" . join(':',@ldpaths);
+  
+   return <<"EOPOST";
+all :: modules
+test :: modules
+install :: modules
+
+par :: all
+\t$perl_path -MPAR::Dist -e"blip_to_par(name=>'SVN",version=>'`$perl_path -Mblib -MSVN::Core -e 'print $SVN::Core::VERSION'`')"
+
+ra_plugin.hi: ../../../include/svn_ra.h
+\t$perl_path h2i.pl ../../../include/svn_ra.h svn_ra_plugin_t > \$@
+
+ra_reporter.hi: ../../../include/svn_ra.h
+\t$perl_path h2i.pl ../../../include/svn_ra.h svn_ra_reporter_t > \$@
+
+delta_editor.hi: ../../../include/svn_delta.h
+\t$perl_path h2i.pl ../../../include/svn_delta.h svn_delta_editor_t > \$@
+
+modules :: $module_c_files
+$module_make_commands\t\$(NOECHO) \$(TOUCH) \$\@
+
+core.c :: ../core.i
+\t$swig_command -module SVN::_Core -o core.c ../core.i
+
+$swig_modules_command
+
+FULLPERLRUN=$fullperlrun \$(FULLPERL)
+
+EOPOST
+
 }
Index: subversion/bindings/swig/swigutil_py.h
===================================================================
--- subversion/bindings/swig/swigutil_py.h	(revision 8496)
+++ subversion/bindings/swig/swigutil_py.h	(working copy)
@@ -34,6 +34,11 @@
 #include "svn_client.h"
 #include "svn_repos.h"
 
+#if SVN_SWIG_VERSION >= 103020
+#include "python/precommon.swg"
+#define SWIG_NewPointerObj SWIG_Python_NewPointerObj
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
Index: subversion/bindings/swig/INSTALL
===================================================================
--- subversion/bindings/swig/INSTALL	(revision 8496)
+++ subversion/bindings/swig/INSTALL	(working copy)
@@ -4,7 +4,7 @@
 
 
 Step 1:  Build & install the proper version of SWIG (which is
-         currently swig 1.3.16).
+         currently swig 1.3.19 or newer).
 
     * Go to http://www.swig.org/, download the sourceball, unpack.
 
@@ -19,8 +19,16 @@
        to the configure script.  You certainly don't want to use any
        version of python older than 2.0.
 
-    * run 'make && make install'
+       If you plan to build the perl bindings, and have a system
+       with more than one version of perl installed, you may need
+       to pass
 
+             --with-perl5=/path/to/correct/perl/binary
+
+       to the configure script.  You need Perl 5.8.0 or above.
+
+    * run 'make && make runtime && make install && make install-runtime'
+
     * To verify you have the goodz installed, check that these things
       were created, assuming your $PREFIX was /usr/local/lib:
 
@@ -28,7 +36,7 @@
            - /usr/local/lib/libswig*.so
            - /usr/local/bin/swig
 
-      In particular, you want to make sure that libswig_py.so was
+      In particular, you want to make sure that libswigpy.so was
       built and installed, since the python bindings are the most-used
       ones at the moment.
 
@@ -88,6 +96,9 @@
    2.  Go to subversion/bindings/swig/perl and run
        `env APR_CONFIG=/path/to/apr-config perl Makefile.PL'.
 
+       Be sure to use the same perl binary here that you configured
+       SWIG to run against during the SWIG configure (see above).
+
    3.  run `make all test'.
 
    4.  to install, run `make install-swig-pl-lib' from the top of the
Index: build/ac-macros/swig.m4
===================================================================
--- build/ac-macros/swig.m4	(revision 8496)
+++ build/ac-macros/swig.m4	(working copy)
@@ -79,32 +79,43 @@
 
   if test "$SWIG" != "none"; then
     AC_MSG_CHECKING([swig version])
-    SWIG_VERSION="`$SWIG -version 2>&1 | sed -ne 's/^.*Version \(.*\)$/\1/p'`"
-    AC_MSG_RESULT([$SWIG_VERSION])
+    SWIG_VERSION_RAW="`$SWIG -version 2>&1 | \
+                       sed -ne 's/^.*Version \(.*\)$/\1/p'`"
+    # We want the version as an integer so we can test against
+    # which version we're using.  SWIG doesn't provide this 
+    # to us so we have to come up with it on our own.  
+    # The major is passed straight through,
+    # the minor is zero padded to two places,
+    # and the patch level is zero padded to three places.
+    # e.g. 1.3.21 becomes 103021
+    SWIG_VERSION="`echo \"$SWIG_VERSION_RAW\" | \
+                  sed -e 's/[[^0-9\.]].*$//' \
+                      -e 's/\.\([[0-9]]\)$/.0\1/' \
+                      -e 's/\.\([[0-9]][[0-9]]\)$/.0\1/' \
+                      -e 's/\.\([[0-9]]\)\./0\1/; s/\.//g;'`"
+    AC_MSG_RESULT([$SWIG_VERSION_RAW])
+    AC_SUBST(SWIG_VERSION)
     # If you change the required swig version number, don't forget to update:
     #   subversion/bindings/swig/INSTALL
     #   subversion/bindings/swig/README
     #   packages/rpm/mandrake-9.0/subversion.spec
     #   packages/rpm/redhat-7.x/subversion.spec
     #   packages/rpm/redhat-8.x/subversion.spec
-    case $SWIG_VERSION in
-        [1.3.1[679]*])
-          SWIG_SUITABLE=yes
-          ;;
-        *)
-          SWIG_SUITABLE=no
-          AC_MSG_WARN([swig bindings require 1.3.19.])
-          ;;
-    esac
+    if test -n "$SWIG_VERSION" && test "$SWIG_VERSION" -ge "103019"; then
+        SWIG_SUITABLE=yes
+        AC_CACHE_CHECK([for swig library directory], [ac_cv_swig_swiglib_dir],[
+                        ac_cv_swig_swiglib_dir="`$SWIG -swiglib`"
+                       ])
+        SWIG_LIBSWIG_DIR="$ac_cv_swig_swiglib_dir"
+    else
+        SWIG_SUITABLE=no
+        AC_MSG_WARN([swig bindings version 1.3.19 or newer needed for swig support.])
+    fi
     if test "$PYTHON" != "none" -a "$SWIG_SUITABLE" = "yes" -a "$svn_swig_bindings_enable_python" = "yes"; then
       AC_MSG_NOTICE("Configuring python swig binding")
       SWIG_BUILD_RULES="$SWIG_BUILD_RULES swig-py-lib"
       SWIG_INSTALL_RULES="$SWIG_INSTALL_RULES install-swig-py-lib"
 
-      AC_CACHE_CHECK([for swig library directory], [ac_cv_swig_swiglib_dir],[
-        ac_cv_swig_swiglib_dir="`$SWIG -swiglib`"
-      ])
-      SWIG_LIBSWIG_DIR="$ac_cv_swig_swiglib_dir"
 
       AC_CACHE_CHECK([if swig needs -L for its libraries],
         [ac_cv_swig_ldflags],[
@@ -123,7 +134,7 @@
       AC_CACHE_CHECK([for Python includes], [ac_cv_python_includes],[
         ac_cv_python_includes="`$PYTHON ${abs_srcdir}/build/get-py-info.py --includes`"
       ])
-      SWIG_PY_INCLUDES="$ac_cv_python_includes"
+      SWIG_PY_INCLUDES="\$(SWIG_INCLUDES) $ac_cv_python_includes"
 
       AC_CACHE_CHECK([for compiling Python extensions], [ac_cv_python_compile],[
         ac_cv_python_compile="`$PYTHON ${abs_srcdir}/build/get-py-info.py --compile`"
@@ -155,7 +166,7 @@
       ### TODO: enable when the target is implemented correctly
 #      SWIG_BUILD_RULES="$SWIG_BUILD_RULES swig-pl-lib"
 #      SWIG_INSTALL_RULES="$SWIG_INSTALL_RULES install-swig-pl-lib"
-      SWIG_PL_INCLUDES="`$PERL -MExtUtils::Embed -e ccopts`"
+      SWIG_PL_INCLUDES="\$(SWIG_INCLUDES) `$PERL -MExtUtils::Embed -e ccopts`"
       SWIG_PL_COMPILE="`$PERL -MConfig -e 'print $Config{cc}'` \$(SWIG_PL_INCLUDES)"
       SWIG_PL_LINK="`$PERL -MConfig -e 'print $Config{ld}'` `$PERL -MConfig -e 'print $Config{lddlflags}'` `$PERL -MExtUtils::Embed -e ldopts`"
     fi
Index: packages/rpm/mandrake-9.0/Makefile
===================================================================
--- packages/rpm/mandrake-9.0/Makefile	(revision 8496)
+++ packages/rpm/mandrake-9.0/Makefile	(working copy)
@@ -105,7 +105,7 @@
 
 # Minimal versions
 # NEON_MIN   := 0.23.0
-# SWIG_MIN   := 1.3.16
+# SWIG_MIN   := 1.3.19
 # APACHE_MIN := 2.0.43
 # DB4_MIN    := 4.0.14
 
@@ -188,7 +188,7 @@
 NEON_RPM        := $(if $(NEON),$(NEON),libneon0)
 SWIG_RPM        := $(if $(SWIG),$(SWIG),swig)
 SWIG_BUILD_RPM  := $(if $(SWIG_BUILD),$(SWIG_BUILD),swig)
-SWIG_MIN        := $(if $(SWIG_MIN),$(SWIG_MIN),$(if $(GE_30),1.3.16,1.3.16))
+SWIG_MIN        := $(if $(SWIG_MIN),$(SWIG_MIN),$(if $(GE_30),1.3.21,1.3.19))
 NEON_MIN        := $(if $(NEON_MIN),$(NEON_MIN),$(if $(GE_30),0.24.0,0.23.0))
 APACHE_MIN      := $(if $(APACHE_MIN),$(APACHE_MIN),$(if $(GE_30),2.0.47,2.0.43))
 DB4_MIN         := $(if $(DB4_MIN),$(DB4_MIN),$(if $(GE_30),4.1.25,4.0.14))
Index: packages/rpm/mandrake-9.1/Makefile
===================================================================
--- packages/rpm/mandrake-9.1/Makefile	(revision 8496)
+++ packages/rpm/mandrake-9.1/Makefile	(working copy)
@@ -111,7 +111,7 @@
 
 # Minimal versions
 # NEON_MIN   := 0.23.0
-# SWIG_MIN   := 1.3.16
+# SWIG_MIN   := 1.3.19
 # APACHE_MIN := 2.0.43
 # DB4_MIN    := 4.0.14
 
@@ -206,7 +206,7 @@
 SWIG_BUILD_RPM  := $(if $(SWIG_BUILD),$(SWIG_BUILD),swig)
 LIBXML2         := $(if $(GE_30),\%define libxml2 BuildRequires: libxml2 >= 2.5.4,\%undefine libxml2)
 IDEAS           := $(if $(GE_30),\%undefine ideas,\%define ideas IDEAS)
-SWIG_MIN        := $(if $(SWIG_MIN),$(SWIG_MIN),$(if $(GE_30),1.3.16,1.3.16))
+SWIG_MIN        := $(if $(SWIG_MIN),$(SWIG_MIN),$(if $(GE_30),1.3.21,1.3.19))
 NEON_MIN        := $(if $(NEON_MIN),$(NEON_MIN),$(if $(GE_30),0.24.0,0.23.0))
 APACHE_MIN      := $(if $(APACHE_MIN),$(APACHE_MIN),$(if $(GE_30),2.0.47,2.0.43))
 DB4_MIN         := $(if $(DB4_MIN),$(DB4_MIN),$(if $(GE_30),4.1.25,4.0.14))
Index: packages/rpm/mandrake-9.2/Makefile
===================================================================
--- packages/rpm/mandrake-9.2/Makefile	(revision 8496)
+++ packages/rpm/mandrake-9.2/Makefile	(working copy)
@@ -105,7 +105,7 @@
 
 # Minimal versions
 # NEON_MIN   := 0.23.0
-# SWIG_MIN   := 1.3.16
+# SWIG_MIN   := 1.3.19
 # APACHE_MIN := 2.0.43
 # DB4_MIN    := 4.0.14
 
@@ -188,7 +188,7 @@
 NEON_RPM        := $(if $(NEON),$(NEON),libneon0)
 SWIG_RPM        := $(if $(SWIG),$(SWIG),swig)
 SWIG_BUILD_RPM  := $(if $(SWIG_BUILD),$(SWIG_BUILD),swig)
-SWIG_MIN        := $(if $(SWIG_MIN),$(SWIG_MIN),$(if $(GE_30),1.3.16,1.3.16))
+SWIG_MIN        := $(if $(SWIG_MIN),$(SWIG_MIN),$(if $(GE_30),1.3.21,1.3.19))
 NEON_MIN        := $(if $(NEON_MIN),$(NEON_MIN),$(if $(GE_30),0.24.0,0.23.0))
 APACHE_MIN      := $(if $(APACHE_MIN),$(APACHE_MIN),$(if $(GE_30),2.0.47,2.0.43))
 DB4_MIN         := $(if $(DB4_MIN),$(DB4_MIN),$(if $(GE_30),4.1.25,4.0.14))


