Merge branch 'master' into gsoc2017-php7-classes-via-c-api
diff --git a/CCache/configure.ac b/CCache/configure.ac
index e1c7618..2db3553 100644
--- a/CCache/configure.ac
+++ b/CCache/configure.ac
@@ -1,12 +1,12 @@
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT([ccache-swig], [0.0]) # Get version from SWIG in ccache_swig_config.h.in
-AC_PREREQ(2.52)
+AC_INIT([ccache-swig],[0.0]) # Get version from SWIG in ccache_swig_config.h.in
+AC_PREREQ([2.60])
 AC_CONFIG_SRCDIR([ccache.h])
 
 AC_MSG_NOTICE([Configuring ccache])
 
-AC_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([config_win32.h])
 
 dnl Checks for programs.
@@ -41,7 +41,7 @@
 fi
 
 AC_HEADER_DIRENT
-AC_HEADER_TIME
+
 AC_HEADER_SYS_WAIT
 
 AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h)
@@ -51,19 +51,16 @@
 AC_CHECK_FUNCS(utimes)
 
 AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [
-    AC_TRY_COMPILE(
-[#include <stdlib.h>],
-[
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]], [[
 void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); }
-],
-	ccache_cv_COMPAR_FN_T=yes,ccache_cv_COMPAR_FN_T=no)])
+]])],[ccache_cv_COMPAR_FN_T=yes],[ccache_cv_COMPAR_FN_T=no])])
 if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then
    AC_DEFINE(HAVE_COMPAR_FN_T, 1, [ ])
 fi
 
 dnl Note: This could be replaced by AC_FUNC_SNPRINTF() in the autoconf macro archive
 AC_CACHE_CHECK([for C99 vsnprintf],ccache_cv_HAVE_C99_VSNPRINTF,[
-AC_TRY_RUN([
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <sys/types.h>
 #include <stdarg.h>
 void foo(const char *format, ...) { 
@@ -81,8 +78,7 @@
        exit(0);
 }
 main() { foo("hello"); }
-],
-ccache_cv_HAVE_C99_VSNPRINTF=yes,ccache_cv_HAVE_C99_VSNPRINTF=no,ccache_cv_HAVE_C99_VSNPRINTF=cross)])
+]])],[ccache_cv_HAVE_C99_VSNPRINTF=yes],[ccache_cv_HAVE_C99_VSNPRINTF=no],[ccache_cv_HAVE_C99_VSNPRINTF=cross])])
 if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
     AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
 fi
diff --git a/CHANGES.current b/CHANGES.current
index aa33c09..004b562 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,16 @@
 Version 4.1.0 (in progress)
 ===========================
 
+2021-04-30: olly
+	    #1984 Remove support for $source and $target.
+	    These were officially deprecated in 2001, and attempts to use them have
+	    resulted in a warning (including a pointer to what to update them to)
+	    for most if not all of that time.
+
+2021-04-27: wsfulton
+            #1987 [Java] Fix %interface family of macros for returning by const
+            pointer reference.
+
 2021-04-19: olly
 	    Fix use of uninitialised variable in the generated code for an
 	    empty typecheck typemap, such as the dummy one we include for
@@ -78,7 +88,7 @@
             unsigned long long values.
 
 2021-02-24: tomleavy, yegorich, tungntpham
-            #1746 [Javascript] Add support for Node v12 and v14.
+            #1746 [Javascript] Add support for Node v12, v14 and v16.
             SWIG support for Node is now for v6 and later only.
 
 2020-02-09: ZackerySpytz
diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html
index 1e7bd9f..85c2545 100644
--- a/Doc/Manual/Perl5.html
+++ b/Doc/Manual/Perl5.html
@@ -2243,7 +2243,7 @@
     EXTEND(sp, 1);              /* Extend the stack by 1 object */
   }
   $result = sv_newmortal();
-  sv_setiv($target, (IV) *($1));
+  sv_setiv($result, (IV) *($1));
   argvi++;
 }
 </pre></div>
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 0cf2a10..02197f1 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -483,7 +483,7 @@
 <li>401. Nothing known about class 'name'. Ignored.
 <li>402. Base class 'name' is incomplete.
 <li>403. Class 'name' might be abstract.
-<li>450. Deprecated typemap feature ($source/$target).
+<li>450. Reserved
 <li>451. Setting const char * variable may leak memory.
 <li>452. Reserved
 <li>453. Can't apply (pattern). No typemaps are defined.
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 2d4c6e5..2e719a6 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -165,6 +165,7 @@
 TCLLDSHARED = @TCLLDSHARED@
 TCLCXXSHARED = @TCLCXXSHARED@
 TCL_SCRIPT = $(SRCDIR)$(RUNME).tcl
+TCL_LINK   = @TCLLINK@
 
 # -----------------------------------------------------------
 # Build a new version of the tclsh shell
@@ -187,7 +188,7 @@
 tcl:  $(SRCDIR_SRCS)
 	$(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -o $(ISRCS) $(INTERFACEPATH)
 	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE)
-	$(TCLLDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
+	$(TCLLDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) $(TCL_LINK)
 
 # -----------------------------------------------------------
 # Build a Tcl7.5 dynamic loadable module for C++
@@ -196,7 +197,7 @@
 tcl_cpp: $(SRCDIR_SRCS)
 	$(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -o $(ICXXSRCS) $(INTERFACEPATH)
 	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE)
-	$(TCLCXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
+	$(TCLCXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) $(TCL_LINK)
 
 # -----------------------------------------------------------------
 # Run Tcl example
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 1e59f6d..5a44980 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -677,7 +677,7 @@
 CPP_TEST_CASES += ${CPP_STD_TEST_CASES}
 endif
 
-ifneq (,$(HAVE_CXX11))
+ifeq (1,$(HAVE_CXX11))
 CPP_TEST_CASES += $(CPP11_TEST_CASES)
 endif
 
diff --git a/Examples/test-suite/csharp/multiple_inheritance_abstract_runme.cs b/Examples/test-suite/csharp/multiple_inheritance_abstract_runme.cs
index 4584be3..512fbf2 100644
--- a/Examples/test-suite/csharp/multiple_inheritance_abstract_runme.cs
+++ b/Examples/test-suite/csharp/multiple_inheritance_abstract_runme.cs
@@ -216,6 +216,7 @@
     check(multiple_inheritance_abstract.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
     check(multiple_inheritance_abstract.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
     check(multiple_inheritance_abstract.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
+
     // Return pointers
     check(multiple_inheritance_abstract.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
     check(multiple_inheritance_abstract.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
@@ -234,6 +235,15 @@
     check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
     check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
 
+    // Return const pointer references
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived1_CBase1().cbase1y()!=3, "MakeConstPtrRefDerived1_CBase1 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived1_CBase2().cbase2()!=4, "MakeConstPtrRefDerived1_CBase2 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived2_CBase1().cbase1y()!=6, "MakeConstPtrRefDerived2_CBase1 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived2_ABase1().abase1()!=5, "MakeConstPtrRefDerived2_ABase1 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived3_ABase1().abase1()!=9, "MakeConstPtrRefDerived3_ABase1 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived3_CBase1().cbase1y()!=7, "MakeConstPtrRefDerived3_CBase1 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived3_CBase2().cbase2()!=8, "MakeConstPtrRefDerived3_CBase2 failed");
+
     // Return by value (sliced objects)
     check(multiple_inheritance_abstract.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
     check(multiple_inheritance_abstract.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
diff --git a/Examples/test-suite/csharp/multiple_inheritance_nspace_runme.cs b/Examples/test-suite/csharp/multiple_inheritance_nspace_runme.cs
index 6ed13a6..c279251 100644
--- a/Examples/test-suite/csharp/multiple_inheritance_nspace_runme.cs
+++ b/Examples/test-suite/csharp/multiple_inheritance_nspace_runme.cs
@@ -217,6 +217,7 @@
     check(multiple_inheritance_nspace.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
     check(multiple_inheritance_nspace.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
     check(multiple_inheritance_nspace.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
+
     // Return pointers
     check(multiple_inheritance_nspace.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
     check(multiple_inheritance_nspace.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
@@ -235,6 +236,15 @@
     check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
     check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
 
+    // Return const pointer references
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived1_CBase1().cbase1y()!=3, "MakeConstPtrRefDerived1_CBase1 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived1_CBase2().cbase2()!=4, "MakeConstPtrRefDerived1_CBase2 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived2_CBase1().cbase1y()!=6, "MakeConstPtrRefDerived2_CBase1 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived2_ABase1().abase1()!=5, "MakeConstPtrRefDerived2_ABase1 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived3_ABase1().abase1()!=9, "MakeConstPtrRefDerived3_ABase1 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived3_CBase1().cbase1y()!=7, "MakeConstPtrRefDerived3_CBase1 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived3_CBase2().cbase2()!=8, "MakeConstPtrRefDerived3_CBase2 failed");
+
     // Return by value (sliced objects)
     check(multiple_inheritance_nspace.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
     check(multiple_inheritance_nspace.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
diff --git a/Examples/test-suite/csharp/multiple_inheritance_shared_ptr_runme.cs b/Examples/test-suite/csharp/multiple_inheritance_shared_ptr_runme.cs
index 13ffc62..fc2263e 100644
--- a/Examples/test-suite/csharp/multiple_inheritance_shared_ptr_runme.cs
+++ b/Examples/test-suite/csharp/multiple_inheritance_shared_ptr_runme.cs
@@ -301,6 +301,15 @@
     check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
     check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
 
+    // Return const pointer references
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived1_CBase1().cbase1y()!=3, "MakeConstPtrRefDerived1_CBase1 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived1_CBase2().cbase2()!=4, "MakeConstPtrRefDerived1_CBase2 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived2_CBase1().cbase1y()!=6, "MakeConstPtrRefDerived2_CBase1 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived2_ABase1().abase1()!=5, "MakeConstPtrRefDerived2_ABase1 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived3_ABase1().abase1()!=9, "MakeConstPtrRefDerived3_ABase1 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived3_CBase1().cbase1y()!=7, "MakeConstPtrRefDerived3_CBase1 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived3_CBase2().cbase2()!=8, "MakeConstPtrRefDerived3_CBase2 failed");
+
     // Return by value (sliced objects)
     check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
     check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
diff --git a/Examples/test-suite/errors/swig_typemap_old.stderr b/Examples/test-suite/errors/swig_typemap_old.stderr
index 2374116..91bf115 100644
--- a/Examples/test-suite/errors/swig_typemap_old.stderr
+++ b/Examples/test-suite/errors/swig_typemap_old.stderr
@@ -1,5 +1,5 @@
-swig_typemap_old.i:6: Warning 450: Deprecated typemap feature ($source/$target).
-swig_typemap_old.i:6: Warning 450: The use of $source and $target in a typemap declaration is deprecated.
+swig_typemap_old.i:6: Error: Obsolete typemap feature ($source/$target).
+swig_typemap_old.i:6: Error: The use of $source and $target in a typemap declaration is no longer supported.
 For typemaps related to argument input (in,ignore,default,arginit,check), replace
 $source by $input and $target by $1.   For typemaps related to return values (out,
 argout,ret,except), replace $source by $1 and $target by $result.  See the file
diff --git a/Examples/test-suite/java/multiple_inheritance_abstract_runme.java b/Examples/test-suite/java/multiple_inheritance_abstract_runme.java
index 1489d92..4230e7b 100644
--- a/Examples/test-suite/java/multiple_inheritance_abstract_runme.java
+++ b/Examples/test-suite/java/multiple_inheritance_abstract_runme.java
@@ -224,6 +224,7 @@
     check(multiple_inheritance_abstract.InputCPtrRefBottom1(b1)!=103+104, "InputCPtrRefBottom1() failed");
     check(multiple_inheritance_abstract.InputCPtrRefBottom2(b2)!=206+205, "InputCPtrRefBottom2() failed");
     check(multiple_inheritance_abstract.InputCPtrRefBottom3(b3)!=307+308+309, "InputCPtrRefBottom3() failed");
+
     // Return pointers
     check(multiple_inheritance_abstract.MakePtrDerived1_CBase1().cbase1y()!=3, "MakePtrDerived1_CBase1 failed");
     check(multiple_inheritance_abstract.MakePtrDerived1_CBase2().cbase2()!=4, "MakePtrDerived1_CBase2 failed");
@@ -242,6 +243,15 @@
     check(multiple_inheritance_abstract.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
     check(multiple_inheritance_abstract.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
 
+    // Return const pointer references
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived1_CBase1().cbase1y()!=3, "MakeConstPtrRefDerived1_CBase1 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived1_CBase2().cbase2()!=4, "MakeConstPtrRefDerived1_CBase2 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived2_CBase1().cbase1y()!=6, "MakeConstPtrRefDerived2_CBase1 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived2_ABase1().abase1()!=5, "MakeConstPtrRefDerived2_ABase1 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived3_ABase1().abase1()!=9, "MakeConstPtrRefDerived3_ABase1 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived3_CBase1().cbase1y()!=7, "MakeConstPtrRefDerived3_CBase1 failed");
+    check(multiple_inheritance_abstract.MakeConstPtrRefDerived3_CBase2().cbase2()!=8, "MakeConstPtrRefDerived3_CBase2 failed");
+
     // Return by value (sliced objects)
     check(multiple_inheritance_abstract.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
     check(multiple_inheritance_abstract.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
diff --git a/Examples/test-suite/java/multiple_inheritance_nspace_runme.java b/Examples/test-suite/java/multiple_inheritance_nspace_runme.java
index 461c7a1..ed2d337 100644
--- a/Examples/test-suite/java/multiple_inheritance_nspace_runme.java
+++ b/Examples/test-suite/java/multiple_inheritance_nspace_runme.java
@@ -244,6 +244,15 @@
     check(multiple_inheritance_nspace.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
     check(multiple_inheritance_nspace.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
 
+    // Return const pointer references
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived1_CBase1().cbase1y()!=3, "MakeConstPtrRefDerived1_CBase1 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived1_CBase2().cbase2()!=4, "MakeConstPtrRefDerived1_CBase2 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived2_CBase1().cbase1y()!=6, "MakeConstPtrRefDerived2_CBase1 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived2_ABase1().abase1()!=5, "MakeConstPtrRefDerived2_ABase1 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived3_ABase1().abase1()!=9, "MakeConstPtrRefDerived3_ABase1 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived3_CBase1().cbase1y()!=7, "MakeConstPtrRefDerived3_CBase1 failed");
+    check(multiple_inheritance_nspace.MakeConstPtrRefDerived3_CBase2().cbase2()!=8, "MakeConstPtrRefDerived3_CBase2 failed");
+
     // Return by value (sliced objects)
     check(multiple_inheritance_nspace.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
     check(multiple_inheritance_nspace.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
diff --git a/Examples/test-suite/java/multiple_inheritance_shared_ptr_runme.java b/Examples/test-suite/java/multiple_inheritance_shared_ptr_runme.java
index 6472a91..9109130 100644
--- a/Examples/test-suite/java/multiple_inheritance_shared_ptr_runme.java
+++ b/Examples/test-suite/java/multiple_inheritance_shared_ptr_runme.java
@@ -309,6 +309,15 @@
     check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase1().cbase1y()!=7, "MakeRefDerived3_CBase1 failed");
     check(multiple_inheritance_shared_ptr.MakeRefDerived3_CBase2().cbase2()!=8, "MakeRefDerived3_CBase2 failed");
 
+    // Return const pointer references
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived1_CBase1().cbase1y()!=3, "MakeConstPtrRefDerived1_CBase1 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived1_CBase2().cbase2()!=4, "MakeConstPtrRefDerived1_CBase2 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived2_CBase1().cbase1y()!=6, "MakeConstPtrRefDerived2_CBase1 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived2_ABase1().abase1()!=5, "MakeConstPtrRefDerived2_ABase1 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived3_ABase1().abase1()!=9, "MakeConstPtrRefDerived3_ABase1 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived3_CBase1().cbase1y()!=7, "MakeConstPtrRefDerived3_CBase1 failed");
+    check(multiple_inheritance_shared_ptr.MakeConstPtrRefDerived3_CBase2().cbase2()!=8, "MakeConstPtrRefDerived3_CBase2 failed");
+
     // Return by value (sliced objects)
     check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase1().cbase1y()!=1, "MakeValDerived1_CBase1 failed");
     check(multiple_inheritance_shared_ptr.MakeValDerived1_CBase2().cbase2()!=2, "MakeValDerived1_CBase2 failed");
diff --git a/Examples/test-suite/multiple_inheritance_abstract.i b/Examples/test-suite/multiple_inheritance_abstract.i
index 12ea2f7..9ac16a2 100644
--- a/Examples/test-suite/multiple_inheritance_abstract.i
+++ b/Examples/test-suite/multiple_inheritance_abstract.i
@@ -22,7 +22,7 @@
   struct CBase1 {
     virtual void cbase1x() {
       return;
-    } 
+    }
     virtual int cbase1y() {
       return 1;
     }
@@ -306,6 +306,36 @@
     return d;
   }
 
+  // Return const pointer references
+  CBase1 *const&MakeConstPtrRefDerived1_CBase1() {
+    static CBase1 *d = new Derived1();
+    return d;
+  }
+  CBase2 *const&MakeConstPtrRefDerived1_CBase2() {
+    static CBase2 *const& d = new Derived1();
+    return d;
+  }
+  CBase1 *const&MakeConstPtrRefDerived2_CBase1() {
+    static CBase1 *const& d = new Derived2();
+    return d;
+  }
+  ABase1 *const&MakeConstPtrRefDerived2_ABase1() {
+    static ABase1 *const& d = new Derived2();
+    return d;
+  }
+  ABase1 *const&MakeConstPtrRefDerived3_ABase1() {
+    static ABase1 *const& d = new Derived3();
+    return d;
+  }
+  CBase1 *const&MakeConstPtrRefDerived3_CBase1() {
+    static CBase1 *const& d = new Derived3();
+    return d;
+  }
+  CBase2 *const&MakeConstPtrRefDerived3_CBase2() {
+    static CBase2 *const& d = new Derived3();
+    return d;
+  }
+
   // Return by value (sliced objects)
   CBase1 MakeValDerived1_CBase1() {
     return Derived1();
diff --git a/Examples/test-suite/multiple_inheritance_nspace.i b/Examples/test-suite/multiple_inheritance_nspace.i
index 07b9fb1..002e6d6 100644
--- a/Examples/test-suite/multiple_inheritance_nspace.i
+++ b/Examples/test-suite/multiple_inheritance_nspace.i
@@ -31,7 +31,7 @@
   struct CBase1 {
     virtual void cbase1x() {
       return;
-    } 
+    }
     virtual int cbase1y() {
       return 1;
     }
@@ -315,6 +315,36 @@
     return d;
   }
 
+  // Return const pointer references
+  CBase1 *const&MakeConstPtrRefDerived1_CBase1() {
+    static CBase1 *d = new Derived1();
+    return d;
+  }
+  CBase2 *const&MakeConstPtrRefDerived1_CBase2() {
+    static CBase2 *const& d = new Derived1();
+    return d;
+  }
+  CBase1 *const&MakeConstPtrRefDerived2_CBase1() {
+    static CBase1 *const& d = new Derived2();
+    return d;
+  }
+  ABase1 *const&MakeConstPtrRefDerived2_ABase1() {
+    static ABase1 *const& d = new Derived2();
+    return d;
+  }
+  ABase1 *const&MakeConstPtrRefDerived3_ABase1() {
+    static ABase1 *const& d = new Derived3();
+    return d;
+  }
+  CBase1 *const&MakeConstPtrRefDerived3_CBase1() {
+    static CBase1 *const& d = new Derived3();
+    return d;
+  }
+  CBase2 *const&MakeConstPtrRefDerived3_CBase2() {
+    static CBase2 *const& d = new Derived3();
+    return d;
+  }
+
   // Return by value (sliced objects)
   CBase1 MakeValDerived1_CBase1() {
     return Derived1();
diff --git a/Examples/test-suite/multiple_inheritance_shared_ptr.i b/Examples/test-suite/multiple_inheritance_shared_ptr.i
index 891a5bf..061db57 100644
--- a/Examples/test-suite/multiple_inheritance_shared_ptr.i
+++ b/Examples/test-suite/multiple_inheritance_shared_ptr.i
@@ -424,6 +424,36 @@
     return d;
   }
 
+  // Return const pointer references
+  CBase1 *const&MakeConstPtrRefDerived1_CBase1() {
+    static CBase1 *d = new Derived1();
+    return d;
+  }
+  CBase2 *const&MakeConstPtrRefDerived1_CBase2() {
+    static CBase2 *const& d = new Derived1();
+    return d;
+  }
+  CBase1 *const&MakeConstPtrRefDerived2_CBase1() {
+    static CBase1 *const& d = new Derived2();
+    return d;
+  }
+  ABase1 *const&MakeConstPtrRefDerived2_ABase1() {
+    static ABase1 *const& d = new Derived2();
+    return d;
+  }
+  ABase1 *const&MakeConstPtrRefDerived3_ABase1() {
+    static ABase1 *const& d = new Derived3();
+    return d;
+  }
+  CBase1 *const&MakeConstPtrRefDerived3_CBase1() {
+    static CBase1 *const& d = new Derived3();
+    return d;
+  }
+  CBase2 *const&MakeConstPtrRefDerived3_CBase2() {
+    static CBase2 *const& d = new Derived3();
+    return d;
+  }
+
   // Return by value (sliced objects)
   CBase1 MakeValDerived1_CBase1() {
     return Derived1();
diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg
index 7df6767..f42fd27 100644
--- a/Lib/chicken/chicken.swg
+++ b/Lib/chicken/chicken.swg
@@ -258,7 +258,7 @@
     if (!SWIG_ConvertPtr(C_block_item($input,1), &result, $descriptor, 0)) {
       C_word ptr = C_block_item($input,0);
       if (C_swig_is_string(ptr)) {
-        SWIG_UnpackData(C_c_string(ptr), (void *) &$1, sizeof($type));
+        SWIG_UnpackData(C_c_string(ptr), (void *) &$1, sizeof($1));
       } else {
         snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", $argnum, ($descriptor->str ? $descriptor->str : $descriptor->name));
         SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg);
@@ -293,7 +293,7 @@
     if (!SWIG_ConvertPtr(C_block_item($input,1), &result, $descriptor, 0)) {
       C_word ptr = C_block_item($input,0);
       if (C_swig_is_string(ptr)) {
-        SWIG_UnpackData(C_c_string(ptr), (void *) &$1, sizeof($type));
+        SWIG_UnpackData(C_c_string(ptr), (void *) &$1, sizeof($1));
       } else {
         snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", 1, ($descriptor->str ? $descriptor->str : $descriptor->name));
         SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg);
diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i
index cfccced..84a754d 100644
--- a/Lib/guile/typemaps.i
+++ b/Lib/guile/typemaps.i
@@ -378,26 +378,26 @@
 #define %argument_fail(code, type, name, argn)	scm_wrong_type_arg((char *) FUNC_NAME, argn, $input);
 #define %as_voidptr(ptr)		(void*)(ptr)
 
-%typemap(in) SWIGTYPE (CLASS::*) {  
-  int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor);
+%typemap(in) SWIGTYPE (CLASS::*) {
+  int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($1), $descriptor);
   if (!SWIG_IsOK(res)) {
-    %argument_fail(res,"$type",$symname, $argnum); 
+    %argument_fail(res,"$type",$symname, $argnum);
   }
 }
 
 %typemap(out,noblock=1) SWIGTYPE (CLASS::*) {
-  %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
+  %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor));
 }
 
 %typemap(varin) SWIGTYPE (CLASS::*) {
-  int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor);
+  int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($1), $descriptor);
   if (!SWIG_IsOK(res)) {
     scm_wrong_type_arg((char *) FUNC_NAME, 1, $input);
   }
 }
 
 %typemap(varout,noblock=1) SWIGTYPE (CLASS::*) {
-  %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
+  %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor));
 }
 
 /* ------------------------------------------------------------
diff --git a/Lib/java/swiginterface.i b/Lib/java/swiginterface.i
index 3344641..0a0f780 100644
--- a/Lib/java/swiginterface.i
+++ b/Lib/java/swiginterface.i
@@ -28,7 +28,7 @@
   }
 %typemap(javaout) CTYPE *const& {
     long cPtr = $jnicall;
-    return (cPtr == 0) ? null : ($javainterfacename)new $javaclassname(cPtr, $owner);
+    return (cPtr == 0) ? null : ($*javainterfacename)new $*javaclassname(cPtr, $owner);
   }
 
 %typemap(javadirectorin) CTYPE "($&javainterfacename)new $&javaclassname($jniinput, true)"
diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg
index 8959f20..6c92e3b 100644
--- a/Lib/lua/luatypemaps.swg
+++ b/Lib/lua/luatypemaps.swg
@@ -237,13 +237,13 @@
 // therefore a special wrapping functions SWIG_ConvertMember() & SWIG_NewMemberObj() were written
 %typemap(in,checkfn="lua_isuserdata") SWIGTYPE (CLASS::*)
 %{
-  if (!SWIG_IsOK(SWIG_ConvertMember(L,$input,(void*)(&$1),sizeof($type),$descriptor)))
+  if (!SWIG_IsOK(SWIG_ConvertMember(L,$input,(void*)(&$1),sizeof($1),$descriptor)))
     SWIG_fail_ptr("$symname",$argnum,$descriptor);
 %}
 
 %typemap(out) SWIGTYPE (CLASS::*)
-%{ 
-  SWIG_NewMemberObj(L,(void*)(&$1),sizeof($type),$descriptor); SWIG_arg++; 
+%{
+  SWIG_NewMemberObj(L,(void*)(&$1),sizeof($1),$descriptor); SWIG_arg++;
 %}
 
 
diff --git a/Lib/perl5/perltypemaps.swg b/Lib/perl5/perltypemaps.swg
index bf1596e..bab3d7a 100644
--- a/Lib/perl5/perltypemaps.swg
+++ b/Lib/perl5/perltypemaps.swg
@@ -95,7 +95,7 @@
     "sv_setiv(SvRV($result), PTR2IV(&$1));";
 
 %typemap(varout,type="$1_descriptor") SWIGTYPE (CLASS::*) {
-  SWIG_MakePackedObj($result, (void *) &$1, sizeof($1_type), $1_descriptor);
+  SWIG_MakePackedObj($result, (void *) &$1, sizeof($1), $1_descriptor);
 }
 
 %typemap(varout) SWIGTYPE *const = SWIGTYPE *;
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index 581de1a..402313e 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -562,29 +562,29 @@
  * ------------------------------------------------------------ */
 
 %typemap(in) SWIGTYPE (CLASS::*) {  
-  int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($type),$descriptor);
+  int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($1),$descriptor);
   if (!SWIG_IsOK(res)) {
     %argument_fail(res,"$type",$symname, $argnum); 
   }
 }
 
 %typemap(out,noblock=1) SWIGTYPE (CLASS::*) {
-  %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
+  %set_output(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor));
 }
 
 %typemap(varin) SWIGTYPE (CLASS::*) {
-  int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($type), $descriptor);
+  int res = SWIG_ConvertMember($input,%as_voidptr(&$1), sizeof($1), $descriptor);
   if (!SWIG_IsOK(res)) {
     %variable_fail(res, "$type", "$name"); 
   }
 }
 
 %typemap(varout,noblock=1) SWIGTYPE (CLASS::*) {
-  %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor));
+  %set_varoutput(SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor));
 }
 
 %typemap(constcode,noblock=1) SWIGTYPE (CLASS::*) {
-  %set_constant("$symname", SWIG_NewMemberObj(%as_voidptr(&$value), sizeof($type), $descriptor));
+  %set_constant("$symname", SWIG_NewMemberObj(%as_voidptr(&$value), sizeof($value), $descriptor));
 }
 
 #if defined(SWIG_DIRECTOR_TYPEMAPS)
@@ -592,13 +592,13 @@
 /* directorin */
 
 %typemap(directorin,noblock=1) SWIGTYPE (CLASS::*) {
-  $input = SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($type), $descriptor);
+  $input = SWIG_NewMemberObj(%as_voidptr(&$1), sizeof($1), $descriptor);
 }
 
 /* directorout */
 
 %typemap(directorout) SWIGTYPE (CLASS::*) {
-  int swig_res = SWIG_ConvertMember($input,%as_voidptr(&$result), sizeof($type), $descriptor);
+  int swig_res = SWIG_ConvertMember($input,%as_voidptr(&$result), sizeof($result), $descriptor);
   if (!SWIG_IsOK(swig_res)) {
     %dirout_fail(swig_res,"$type");
   }
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index a370270..2113b9c 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -93,7 +93,7 @@
     const size_t len = strlen(structuralTags[n]);
     if (strncmp(slashPointer, structuralTags[n], len) == 0) {
       /* Take care to avoid false positives with prefixes of other tags. */
-      if (slashPointer[len] == '\0' || isspace(slashPointer[len]))
+      if (slashPointer[len] == '\0' || isspace((int)slashPointer[len]))
 	return 1;
     }
   }
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index 8362cc0..48b98d4 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -157,9 +157,9 @@
 #define WARN_TYPE_REDEFINED           404
 #define WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405
 
-#define WARN_TYPEMAP_SOURCETARGET     450
+#define WARN_TYPEMAP_SOURCETARGET     450 /* No longer issued */
 #define WARN_TYPEMAP_CHARLEAK         451
-#define WARN_TYPEMAP_SWIGTYPE         452
+#define WARN_TYPEMAP_SWIGTYPE         452 /* No longer issued */
 #define WARN_TYPEMAP_APPLY_UNDEF      453
 #define WARN_TYPEMAP_SWIGTYPELEAK     454
 
diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx
index 97af186..e39abed 100644
--- a/Source/Modules/allegrocl.cxx
+++ b/Source/Modules/allegrocl.cxx
@@ -2445,7 +2445,6 @@
 
   /* See if there is any return cleanup code */
   if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-    Replaceall(tm, "$source", Swig_cresult_name());
     Printf(f->code, "%s\n", tm);
     Delete(tm);
   }
diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx
index bf33388..7f584db 100644
--- a/Source/Modules/cffi.cxx
+++ b/Source/Modules/cffi.cxx
@@ -426,7 +426,6 @@
   if (GetFlag(n, "feature:new")) {
     String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0);
     if (tm) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printv(f->code, tm, "\n", NULL);
       Delete(tm);
     }
@@ -546,7 +545,6 @@
   /* See if there is any return cleanup code */
   String *tm = 0;
   if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-    Replaceall(tm, "$source", Swig_cresult_name());
     Printf(f->code, "%s\n", tm);
     Delete(tm);
   }
diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx
index 76b6455..3f4bff3 100644
--- a/Source/Modules/chicken.cxx
+++ b/Source/Modules/chicken.cxx
@@ -400,7 +400,6 @@
     }
 
     SwigType *pt = Getattr(p, "type");
-    String *ln = Getattr(p, "lname");
 
     Printf(f->def, ", C_word scm%d", i + 1);
     Printf(declfunc, ",C_word");
@@ -410,8 +409,6 @@
       String *parse = Getattr(p, "tmap:in:parse");
       if (!parse) {
         String *source = NewStringf("scm%d", i + 1);
-	Replaceall(tm, "$source", source);
-	Replaceall(tm, "$target", ln);
 	Replaceall(tm, "$input", source);
 	Setattr(p, "emit:input", source);	/* Save the location of
 						   the object */
@@ -480,7 +477,6 @@
   /* Insert constraint checking code */
   for (p = l; p;) {
     if ((tm = Getattr(p, "tmap:check"))) {
-      Replaceall(tm, "$target", Getattr(p, "lname"));
       Printv(f->code, tm, "\n", NIL);
       p = Getattr(p, "tmap:check:next");
     } else {
@@ -491,7 +487,6 @@
   /* Insert cleanup code */
   for (p = l; p;) {
     if ((tm = Getattr(p, "tmap:freearg"))) {
-      Replaceall(tm, "$source", Getattr(p, "lname"));
       Printv(cleanup, tm, "\n", NIL);
       p = Getattr(p, "tmap:freearg:next");
     } else {
@@ -510,8 +505,6 @@
 	Printf(argout, "SWIG_Chicken_SetupArgout\n");
       }
 
-      Replaceall(tm, "$source", Getattr(p, "lname"));
-      Replaceall(tm, "$target", "resultobj");
       Replaceall(tm, "$arg", Getattr(p, "emit:input"));
       Replaceall(tm, "$input", Getattr(p, "emit:input"));
       Printf(argout, "%s", tm);
@@ -528,8 +521,6 @@
 
   /* Return the function value */
   if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
-    Replaceall(tm, "$source", Swig_cresult_name());
-    Replaceall(tm, "$target", "resultobj");
     Replaceall(tm, "$result", "resultobj");
     if (GetFlag(n, "feature:new")) {
       Replaceall(tm, "$owner", "1");
@@ -556,14 +547,12 @@
   /* Look to see if there is any newfree cleanup code */
   if (GetFlag(n, "feature:new")) {
     if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printf(f->code, "%s\n", tm);
     }
   }
 
   /* See if there is any return cleanup code */
   if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-    Replaceall(tm, "$source", Swig_cresult_name());
     Printf(f->code, "%s\n", tm);
   }
 
@@ -719,8 +708,6 @@
     if (!GetFlag(n, "feature:immutable")) {
       Printf(f->code, "if (argc > 2) {\n");
       if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
-	Replaceall(tm, "$source", "value");
-	Replaceall(tm, "$target", name);
 	Replaceall(tm, "$input", "value");
 	/* Printv(f->code, tm, "\n",NIL); */
 	emit_action_code(n, f->code, tm);
@@ -740,9 +727,7 @@
     // Now return the value of the variable - regardless
     // of evaluating or setting.
     if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
-      Replaceall(tm, "$source", varname);
       Replaceall(tm, "$varname", varname);
-      Replaceall(tm, "$target", "resultobj");
       Replaceall(tm, "$result", "resultobj");
       /* Printf(f->code, "%s\n", tm); */
       emit_action_code(n, f->code, tm);
@@ -871,8 +856,6 @@
     Printf(f_header, "static %s = %s;\n", SwigType_str(t, source), rvalue);
   } else {
     if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
-      Replaceall(tm, "$source", rvalue);
-      Replaceall(tm, "$target", source);
       Replaceall(tm, "$result", source);
       Replaceall(tm, "$value", rvalue);
       Printf(f_header, "%s\n", tm);
@@ -907,9 +890,7 @@
     // Return the value of the variable
     if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
 
-      Replaceall(tm, "$source", source);
       Replaceall(tm, "$varname", source);
-      Replaceall(tm, "$target", "resultobj");
       Replaceall(tm, "$result", "resultobj");
       /* Printf(f->code, "%s\n", tm); */
       emit_action_code(n, f->code, tm);
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index 5fef4ca..edb79e1 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -901,8 +901,6 @@
       // Get typemap for this argument
       if ((tm = Getattr(p, "tmap:in"))) {
 	canThrow(n, "in", p);
-	Replaceall(tm, "$source", arg);	/* deprecated */
-	Replaceall(tm, "$target", ln);	/* deprecated */
 	Replaceall(tm, "$arg", arg);	/* deprecated? */
 	Replaceall(tm, "$input", arg);
 	Setattr(p, "emit:input", arg);
@@ -921,7 +919,6 @@
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
 	canThrow(n, "check", p);
-	Replaceall(tm, "$target", Getattr(p, "lname"));	/* deprecated */
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));	/* deprecated? */
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(f->code, tm, "\n", NIL);
@@ -935,7 +932,6 @@
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:freearg"))) {
 	canThrow(n, "freearg", p);
-	Replaceall(tm, "$source", Getattr(p, "emit:input"));	/* deprecated */
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));	/* deprecated? */
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(cleanup, tm, "\n", NIL);
@@ -949,8 +945,6 @@
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:argout"))) {
 	canThrow(n, "argout", p);
-	Replaceall(tm, "$source", Getattr(p, "emit:input"));	/* deprecated */
-	Replaceall(tm, "$target", Getattr(p, "lname"));	/* deprecated */
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));	/* deprecated? */
 	Replaceall(tm, "$result", "jresult");
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
@@ -982,8 +976,6 @@
       /* Return value if necessary  */
       if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
 	canThrow(n, "out", n);
-	Replaceall(tm, "$source", Swig_cresult_name());	/* deprecated */
-	Replaceall(tm, "$target", "jresult");	/* deprecated */
 	Replaceall(tm, "$result", "jresult");
 
         if (GetFlag(n, "feature:new"))
@@ -1011,7 +1003,6 @@
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
 	canThrow(n, "newfree", n);
-	Replaceall(tm, "$source", Swig_cresult_name());	/* deprecated */
 	Printf(f->code, "%s\n", tm);
       }
     }
@@ -1020,7 +1011,6 @@
     if (!native_function_flag) {
       if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
 	canThrow(n, "ret", n);
-	Replaceall(tm, "$source", Swig_cresult_name());	/* deprecated */
 	Printf(f->code, "%s\n", tm);
       }
     }
diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx
index 7a4c2dc..edfa57c 100644
--- a/Source/Modules/emit.cxx
+++ b/Source/Modules/emit.cxx
@@ -74,7 +74,6 @@
   while (p) {
     tm = Getattr(p, "tmap:arginit");
     if (tm) {
-      Replace(tm, "$target", Getattr(p, "lname"), DOH_REPLACE_ANY);
       Printv(f->code, tm, "\n", NIL);
       p = Getattr(p, "tmap:arginit:next");
     } else {
@@ -87,7 +86,6 @@
   while (p) {
     tm = Getattr(p, "tmap:default");
     if (tm) {
-      Replace(tm, "$target", Getattr(p, "lname"), DOH_REPLACE_ANY);
       Printv(f->code, tm, "\n", NIL);
       p = Getattr(p, "tmap:default:next");
     } else {
@@ -116,7 +114,6 @@
     while (p) {
       String *tm = Getattr(p, "tmap:in");
       if (tm && checkAttribute(p, "tmap:in:numinputs", "0")) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	np = Getattr(p, "tmap:in:next");
 	while (p && (p != np)) {
diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
index f2d8ff3..f909213 100644
--- a/Source/Modules/go.cxx
+++ b/Source/Modules/go.cxx
@@ -2615,7 +2615,6 @@
     if (GetFlag(n, "feature:new")) {
       String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0);
       if (tm) {
-	Replaceall(tm, "$source", Swig_cresult_name());
 	Printv(f->code, tm, "\n", NULL);
 	Delete(tm);
       }
@@ -2627,7 +2626,6 @@
     /* See if there is any return cleanup code */
     String *tm;
     if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printf(f->code, "%s\n", tm);
       Delete(tm);
     }
diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx
index 461c69e..d7d3da8 100644
--- a/Source/Modules/guile.cxx
+++ b/Source/Modules/guile.cxx
@@ -719,7 +719,6 @@
 	sprintf(source, "argv[%d]", i);
       else
 	sprintf(source, "s_%d", i);
-      String *target = Getattr(p, "lname");
 
       if (!args_passed_as_array) {
 	if (i != 0)
@@ -730,8 +729,6 @@
 	Printf(f->code, "    if (%s != SCM_UNDEFINED) {\n", source);
       }
       if ((tm = Getattr(p, "tmap:in"))) {
-	Replaceall(tm, "$source", source);
-	Replaceall(tm, "$target", target);
 	Replaceall(tm, "$input", source);
 	Setattr(p, "emit:input", source);
 	Printv(f->code, tm, "\n", NIL);
@@ -794,7 +791,6 @@
     /* Insert constraint checking code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	p = Getattr(p, "tmap:check:next");
       } else {
@@ -807,8 +803,6 @@
     String *returns_argout = NewString("");
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:argout"))) {
-	Replaceall(tm, "$source", Getattr(p, "lname"));
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(outarg, tm, "\n", NIL);
@@ -828,7 +822,6 @@
     /* Insert cleanup code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:freearg"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(cleanup, tm, "\n", NIL);
 	p = Getattr(p, "tmap:freearg:next");
@@ -859,8 +852,6 @@
     // Now have return value, figure out what to do with it.
     if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
       Replaceall(tm, "$result", "gswig_result");
-      Replaceall(tm, "$target", "gswig_result");
-      Replaceall(tm, "$source", Swig_cresult_name());
       if (GetFlag(n, "feature:new"))
 	Replaceall(tm, "$owner", "1");
       else
@@ -898,13 +889,11 @@
 
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-	Replaceall(tm, "$source", Swig_cresult_name());
 	Printv(f->code, tm, "\n", NIL);
       }
     }
     // Free any memory allocated by the function being wrapped..
     if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printv(f->code, tm, "\n", NIL);
     }
     // Wrap things up (in a manner of speaking)
@@ -1141,9 +1130,7 @@
 	/* Check for a setting of the variable value */
 	Printf(f->code, "if (s_0 != SCM_UNDEFINED) {\n");
 	if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
-	  Replaceall(tm, "$source", "s_0");
 	  Replaceall(tm, "$input", "s_0");
-	  Replaceall(tm, "$target", name);
 	  /* Printv(f->code,tm,"\n",NIL); */
 	  emit_action_code(n, f->code, tm);
 	} else {
@@ -1155,8 +1142,6 @@
       // of evaluating or setting)
 
       if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
-	Replaceall(tm, "$source", name);
-	Replaceall(tm, "$target", "gswig_result");
 	Replaceall(tm, "$result", "gswig_result");
 	/* Printv(f->code,tm,"\n",NIL); */
 	emit_action_code(n, f->code, tm);
@@ -1334,9 +1319,7 @@
     // See if there's a typemap
 
     if ((tm = Swig_typemap_lookup("constant", n, name, 0))) {
-      Replaceall(tm, "$source", value);
       Replaceall(tm, "$value", value);
-      Replaceall(tm, "$target", name);
       Printv(f_header, tm, "\n", NIL);
     } else {
       // Create variable and assign it a value
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index 7c8bed4..958da8e 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -1001,8 +1001,6 @@
       // Get typemap for this argument
       if ((tm = Getattr(p, "tmap:in"))) {
 	addThrows(n, "tmap:in", p);
-	Replaceall(tm, "$source", arg);	/* deprecated */
-	Replaceall(tm, "$target", ln);	/* deprecated */
 	Replaceall(tm, "$arg", arg);	/* deprecated? */
 	Replaceall(tm, "$input", arg);
 	Setattr(p, "emit:input", arg);
@@ -1027,7 +1025,6 @@
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
 	addThrows(n, "tmap:check", p);
-	Replaceall(tm, "$target", Getattr(p, "lname"));	/* deprecated */
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));	/* deprecated? */
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(f->code, tm, "\n", NIL);
@@ -1041,7 +1038,6 @@
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:freearg"))) {
 	addThrows(n, "tmap:freearg", p);
-	Replaceall(tm, "$source", Getattr(p, "emit:input"));	/* deprecated */
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));	/* deprecated? */
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(cleanup, tm, "\n", NIL);
@@ -1055,8 +1051,6 @@
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:argout"))) {
 	addThrows(n, "tmap:argout", p);
-	Replaceall(tm, "$source", Getattr(p, "emit:input"));	/* deprecated */
-	Replaceall(tm, "$target", Getattr(p, "lname"));	/* deprecated */
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));	/* deprecated? */
 	Replaceall(tm, "$result", "jresult");
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
@@ -1090,8 +1084,6 @@
       /* Return value if necessary  */
       if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
 	addThrows(n, "tmap:out", n);
-	Replaceall(tm, "$source", Swig_cresult_name());	/* deprecated */
-	Replaceall(tm, "$target", "jresult");	/* deprecated */
 	Replaceall(tm, "$result", "jresult");
 
         if (GetFlag(n, "feature:new"))
@@ -1118,7 +1110,6 @@
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
 	addThrows(n, "tmap:newfree", n);
-	Replaceall(tm, "$source", Swig_cresult_name());	/* deprecated */
 	Printf(f->code, "%s\n", tm);
       }
     }
@@ -1127,7 +1118,6 @@
     if (!native_function_flag) {
       if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
 	addThrows(n, "tmap:ret", n);
-	Replaceall(tm, "$source", Swig_cresult_name());	/* deprecated */
 	Printf(f->code, "%s\n", tm);
       }
     }
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index f7979b6..66aebde 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -722,18 +722,18 @@
   String *code = Getattr(n, "code");
   Parm *kwargs = Getattr(n, "kwargs");
   Node *items = firstChild(n);
-  static int namewarn = 0;
+  static int nameerror = 0;
 
 
   if (code && (Strstr(code, "$source") || (Strstr(code, "$target")))) {
-    Swig_warning(WARN_TYPEMAP_SOURCETARGET, Getfile(n), Getline(n), "Deprecated typemap feature ($source/$target).\n");
-    if (!namewarn) {
-      Swig_warning(WARN_TYPEMAP_SOURCETARGET, Getfile(n), Getline(n), "The use of $source and $target in a typemap declaration is deprecated.\n\
+    Swig_error(Getfile(n), Getline(n), "Obsolete typemap feature ($source/$target).\n");
+    if (!nameerror) {
+      Swig_error(Getfile(n), Getline(n), "The use of $source and $target in a typemap declaration is no longer supported.\n\
 For typemaps related to argument input (in,ignore,default,arginit,check), replace\n\
 $source by $input and $target by $1.   For typemaps related to return values (out,\n\
 argout,ret,except), replace $source by $1 and $target by $result.  See the file\n\
 Doc/Manual/Typemaps.html for complete details.\n");
-      namewarn = 1;
+      nameerror = 1;
     }
   }
 
@@ -1481,8 +1481,6 @@
 	} else {
 	  String *pname0 = Swig_cparm_name(0, 0);
 	  String *pname1 = Swig_cparm_name(0, 1);
-	  Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
-	  Replace(tm, "$target", target, DOH_REPLACE_ANY);
 	  Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
 	  Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
 	  Setattr(n, "wrap:action", tm);
@@ -3049,8 +3047,6 @@
       }
     } else {
       String *pname0 = Swig_cparm_name(0, 0);
-      Replace(tm, "$source", pname0, DOH_REPLACE_ANY);
-      Replace(tm, "$target", name, DOH_REPLACE_ANY);
       Replace(tm, "$input", pname0, DOH_REPLACE_ANY);
       Setattr(n, "wrap:action", tm);
       Delete(tm);
diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
index 8723ad6..4ba9cb8 100644
--- a/Source/Modules/lua.cxx
+++ b/Source/Modules/lua.cxx
@@ -613,13 +613,9 @@
       }
 
       SwigType *pt = Getattr(p, "type");
-      String *ln = Getattr(p, "lname");
-
       /* Look for an input typemap */
       sprintf(source, "%d", i + 1);
       if ((tm = Getattr(p, "tmap:in"))) {
-	Replaceall(tm, "$source", source);
-	Replaceall(tm, "$target", ln);
 	Replaceall(tm, "$input", source);
 	Setattr(p, "emit:input", source);
 	if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) {
@@ -678,7 +674,6 @@
     /* Insert constraint checking code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	p = Getattr(p, "tmap:check:next");
       } else {
@@ -690,7 +685,6 @@
     String *cleanup = NewString("");
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:freearg"))) {
-	Replaceall(tm, "$source", Getattr(p, "lname"));
 	Printv(cleanup, tm, "\n", NIL);
 	p = Getattr(p, "tmap:freearg:next");
       } else {
@@ -709,8 +703,6 @@
 	//                      returnval+=GetInt(p,"tmap:argout:numoutputs");
 	//        }
 	//        else returnval++;
-	Replaceall(tm, "$source", Getattr(p, "lname"));
-	Replaceall(tm, "$target", Swig_cresult_name());
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(outarg, tm, "\n", NIL);
@@ -740,7 +732,6 @@
       //              returnval+=GetInt(tm,"numoutputs");
       //      }
       //        else returnval++;
-      Replaceall(tm, "$source", Swig_cresult_name());
       if (GetFlag(n, "feature:new")) {
 	Replaceall(tm, "$owner", "1");
       } else {
@@ -762,14 +753,12 @@
     /* Look to see if there is any newfree cleanup code */
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-	Replaceall(tm, "$source", Swig_cresult_name());
 	Printf(f->code, "%s\n", tm);
       }
     }
 
     /* See if there is any return cleanup code */
     if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printf(f->code, "%s\n", tm);
     }
 
@@ -1074,14 +1063,10 @@
     }
 
     if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", lua_name);
       Replaceall(tm, "$value", value);
       Replaceall(tm, "$nsname", nsname);
       registerConstant(luaCurrentSymbolNSpace(), tm);
     } else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", lua_name);
       Replaceall(tm, "$value", value);
       Replaceall(tm, "$nsname", nsname);
       Printf(f_init, "%s\n", tm);
@@ -1110,8 +1095,6 @@
         Setattr(n_v2, "sym:name", lua_name_v2);
         tm_v2 = Swig_typemap_lookup("consttab", n_v2, name, 0);
         if (tm_v2) {
-          Replaceall(tm_v2, "$source", value);
-          Replaceall(tm_v2, "$target", lua_name_v2);
           Replaceall(tm_v2, "$value", value);
           Replaceall(tm_v2, "$nsname", nsname);
           registerConstant(getNSpace(), tm_v2);
@@ -1123,8 +1106,6 @@
             Swig_restore(n);
             return SWIG_ERROR;
           }
-          Replaceall(tm_v2, "$source", value);
-          Replaceall(tm_v2, "$target", lua_name_v2);
           Replaceall(tm_v2, "$value", value);
           Replaceall(tm_v2, "$nsname", nsname);
           Printf(f_init, "%s\n", tm_v2);
diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
index c606845..555d026 100644
--- a/Source/Modules/modula3.cxx
+++ b/Source/Modules/modula3.cxx
@@ -1346,7 +1346,6 @@
 	String *tm = Getattr(p, "tmap:check");
 	if (tm != NIL) {
 	  addThrows(throws_hash, "check", p);
-	  Replaceall(tm, "$target", Getattr(p, "lname"));	/* deprecated */
 	  Replaceall(tm, "$arg", Getattr(p, "emit:input"));	/* deprecated? */
 	  Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	  Printv(f->code, tm, "\n", NIL);
@@ -1364,7 +1363,6 @@
 	String *tm = Getattr(p, "tmap:freearg");
 	if (tm != NIL) {
 	  addThrows(throws_hash, "freearg", p);
-	  Replaceall(tm, "$source", Getattr(p, "emit:input"));	/* deprecated */
 	  Replaceall(tm, "$arg", Getattr(p, "emit:input"));	/* deprecated? */
 	  Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	  Printv(cleanup, tm, "\n", NIL);
@@ -1382,8 +1380,6 @@
 	String *tm = Getattr(p, "tmap:argout");
 	if (tm != NIL) {
 	  addThrows(throws_hash, "argout", p);
-	  Replaceall(tm, "$source", Getattr(p, "emit:input"));	/* deprecated */
-	  Replaceall(tm, "$target", Getattr(p, "lname"));	/* deprecated */
 	  Replaceall(tm, "$arg", Getattr(p, "emit:input"));	/* deprecated? */
 	  Replaceall(tm, "$result", "cresult");
 	  Replaceall(tm, "$input", Getattr(p, "emit:input"));
@@ -1415,8 +1411,6 @@
       String *tm;
       if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
 	addThrows(throws_hash, "out", n);
-	Replaceall(tm, "$source", Swig_cresult_name());	/* deprecated */
-	Replaceall(tm, "$target", "cresult");	/* deprecated */
 	Replaceall(tm, "$result", "cresult");
 	Printf(f->code, "%s", tm);
 	if (hasContent(tm))
@@ -1438,7 +1432,6 @@
       String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0);
       if (tm != NIL) {
 	addThrows(throws_hash, "newfree", n);
-	Replaceall(tm, "$source", Swig_cresult_name());	/* deprecated */
 	Printf(f->code, "%s\n", tm);
       }
     }
@@ -1447,7 +1440,6 @@
     if (!native_function_flag) {
       String *tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0);
       if (tm != NIL) {
-	Replaceall(tm, "$source", Swig_cresult_name());	/* deprecated */
 	Printf(f->code, "%s\n", tm);
       }
     }
diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
index 5ee5c67..3ff6916 100644
--- a/Source/Modules/mzscheme.cxx
+++ b/Source/Modules/mzscheme.cxx
@@ -322,8 +322,6 @@
       }
       // Handle parameter types.
       if ((tm = Getattr(p, "tmap:in"))) {
-	Replaceall(tm, "$source", source);
-	Replaceall(tm, "$target", target);
 	Replaceall(tm, "$input", source);
 	Setattr(p, "emit:input", source);
 	Printv(f->code, tm, "\n", NIL);
@@ -343,7 +341,6 @@
     /* Insert constraint checking code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	p = Getattr(p, "tmap:check:next");
       } else {
@@ -355,8 +352,6 @@
 
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:argout"))) {
-	Replaceall(tm, "$source", Getattr(p, "emit:input"));	/* Deprecated */
-	Replaceall(tm, "$target", Getattr(p, "lname"));	/* Deprecated */
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(outarg, tm, "\n", NIL);
@@ -371,7 +366,6 @@
     /* Insert cleanup code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:freearg"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(cleanup, tm, "\n", NIL);
 	p = Getattr(p, "tmap:freearg:next");
       } else {
@@ -385,8 +379,6 @@
 
     // Now have return value, figure out what to do with it.
     if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
-      Replaceall(tm, "$target", "values[0]");
       Replaceall(tm, "$result", "values[0]");
       if (GetFlag(n, "feature:new"))
 	Replaceall(tm, "$owner", "1");
@@ -408,14 +400,12 @@
 
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-	Replaceall(tm, "$source", Swig_cresult_name());
 	Printv(f->code, tm, "\n", NIL);
       }
     }
     // Free any memory allocated by the function being wrapped..
 
     if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printv(f->code, tm, "\n", NIL);
     }
     // Wrap things up (in a manner of speaking)
@@ -521,8 +511,6 @@
 	/* Check for a setting of the variable value */
 	Printf(f->code, "if (argc) {\n");
 	if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
-	  Replaceall(tm, "$source", "argv[0]");
-	  Replaceall(tm, "$target", name);
 	  Replaceall(tm, "$input", "argv[0]");
 	  Replaceall(tm, "$argnum", "1");
 	  emit_action_code(n, f->code, tm);
@@ -535,8 +523,6 @@
       // of evaluating or setting)
 
       if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
-	Replaceall(tm, "$source", name);
-	Replaceall(tm, "$target", "swig_result");
 	Replaceall(tm, "$result", "swig_result");
 	/* Printf (f->code, "%s\n", tm); */
 	emit_action_code(n, f->code, tm);
@@ -609,9 +595,7 @@
       Printv(rvalue, "'", temp, "'", NIL);
     }
     if ((tm = Swig_typemap_lookup("constant", n, name, 0))) {
-      Replaceall(tm, "$source", rvalue);
       Replaceall(tm, "$value", rvalue);
-      Replaceall(tm, "$target", name);
       Printf(f_init, "%s\n", tm);
     } else {
       // Create variable and assign it a value
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
index 9f7504b..caa9725 100644
--- a/Source/Modules/ocaml.cxx
+++ b/Source/Modules/ocaml.cxx
@@ -590,8 +590,6 @@
       }
       // Handle parameter types.
       if ((tm = Getattr(p, "tmap:in"))) {
-	Replaceall(tm, "$source", source);
-	Replaceall(tm, "$target", target);
 	Replaceall(tm, "$input", source);
 	Setattr(p, "emit:input", source);
 	Printv(f->code, tm, "\n", NIL);
@@ -611,7 +609,6 @@
     /* Insert constraint checking code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	p = Getattr(p, "tmap:check:next");
       } else {
@@ -623,8 +620,6 @@
 
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:argout"))) {
-	Replaceall(tm, "$source", Getattr(p, "emit:input"));	/* Deprecated */
-	Replaceall(tm, "$target", Getattr(p, "lname"));	/* Deprecated */
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Replaceall(tm, "$ntype", normalizeTemplatedClassName(Getattr(p, "type")));
@@ -640,7 +635,6 @@
     /* Insert cleanup code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:freearg"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(cleanup, tm, "\n", NIL);
 	p = Getattr(p, "tmap:freearg:next");
       } else {
@@ -681,8 +675,6 @@
     String *actioncode = emit_action(n);
 
     if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
-      Replaceall(tm, "$source", "swig_result");
-      Replaceall(tm, "$target", "rv");
       Replaceall(tm, "$result", "rv");
       Replaceall(tm, "$ntype", return_type_normalized);
       Printv(f->code, tm, "\n", NIL);
@@ -701,14 +693,12 @@
 
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-	Replaceall(tm, "$source", "swig_result");
 	Printv(f->code, tm, "\n", NIL);
       }
     }
 
     /* See if there is any return cleanup code */
     if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printf(f->code, "%s\n", tm);
       Delete(tm);
     }
@@ -716,7 +706,6 @@
     // Free any memory allocated by the function being wrapped..
 
     if ((tm = Swig_typemap_lookup("swig_result", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printv(f->code, tm, "\n", NIL);
     }
     // Wrap things up (in a manner of speaking)
@@ -853,13 +842,9 @@
       /* Check for a setting of the variable value */
       Printf(f->code, "if (args != Val_int(0)) {\n");
       if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
-	Replaceall(tm, "$source", "args");
-	Replaceall(tm, "$target", name);
 	Replaceall(tm, "$input", "args");
 	emit_action_code(n, f->code, tm);
       } else if ((tm = Swig_typemap_lookup("in", n, name, 0))) {
-	Replaceall(tm, "$source", "args");
-	Replaceall(tm, "$target", name);
 	Replaceall(tm, "$input", "args");
 	emit_action_code(n, f->code, tm);
       } else {
@@ -871,13 +856,9 @@
     // of evaluating or setting)
 
     if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
-      Replaceall(tm, "$source", name);
-      Replaceall(tm, "$target", "swig_result");
       Replaceall(tm, "$result", "swig_result");
       emit_action_code(n, f->code, tm);
     } else if ((tm = Swig_typemap_lookup("out", n, name, 0))) {
-      Replaceall(tm, "$source", name);
-      Replaceall(tm, "$target", "swig_result");
       Replaceall(tm, "$result", "swig_result");
       emit_action_code(n, f->code, tm);
     } else {
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index fc45a8d..04b315e 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -611,9 +611,7 @@
         sprintf(source, "args(%d)", j);
         Setattr(p, "emit:input", source);
 
-        Replaceall(tm, "$source", Getattr(p, "emit:input"));
         Replaceall(tm, "$input", Getattr(p, "emit:input"));
-        Replaceall(tm, "$target", Getattr(p, "lname"));
 
         if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) {
           Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN");
@@ -658,7 +656,6 @@
     // Insert constraint checking code
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-        Replaceall(tm, "$target", Getattr(p, "lname"));
         Printv(f->code, tm, "\n", NIL);
         p = Getattr(p, "tmap:check:next");
       } else {
@@ -681,7 +678,6 @@
           }
         }
         if (tm && (Len(tm) != 0)) {
-          Replaceall(tm, "$source", Getattr(p, "lname"));
           Printv(cleanup, tm, "\n", NIL);
         }
         p = Getattr(p, "tmap:freearg:next");
@@ -694,8 +690,6 @@
     String *outarg = NewString("");
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:argout"))) {
-        Replaceall(tm, "$source", Getattr(p, "lname"));
-        Replaceall(tm, "$target", "_outp");
         Replaceall(tm, "$result", "_outp");
         Replaceall(tm, "$arg", Getattr(p, "emit:input"));
         Replaceall(tm, "$input", Getattr(p, "emit:input"));
@@ -723,8 +717,6 @@
 
     // Return the function value
     if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
-      Replaceall(tm, "$target", "_outv");
       Replaceall(tm, "$result", "_outv");
 
       if (GetFlag(n, "feature:new"))
@@ -745,13 +737,11 @@
 
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-        Replaceall(tm, "$source", Swig_cresult_name());
         Printf(f->code, "%s\n", tm);
       }
     }
 
     if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Replaceall(tm, "$result", "_outv");
       Printf(f->code, "%s\n", tm);
       Delete(tm);
@@ -849,8 +839,6 @@
     if (is_assignable(n)) {
       Setattr(n, "wrap:name", setname);
       if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
-        Replaceall(tm, "$source", "args(0)");
-        Replaceall(tm, "$target", name);
         Replaceall(tm, "$input", "args(0)");
         if (Getattr(n, "tmap:varin:implicitconv")) {
           Replaceall(tm, "$implicitconv", get_implicitconv_flag(n));
@@ -874,8 +862,6 @@
     Octave_begin_function(n, getf->def, getname, getwname, true);
     Wrapper_add_local(getf, "obj", "octave_value obj");
     if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
-      Replaceall(tm, "$source", name);
-      Replaceall(tm, "$target", "obj");
       Replaceall(tm, "$result", "obj");
       addfail = emit_action_code(n, getf->code, tm);
       Delete(tm);
@@ -920,8 +906,6 @@
       value = wname;
     }
     if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", name);
       Replaceall(tm, "$value", cppvalue ? cppvalue : value);
       Replaceall(tm, "$nsname", iname);
       Printf(f_init, "%s\n", tm);
diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx
index e63e2b0..e87f9f3 100644
--- a/Source/Modules/perl5.cxx
+++ b/Source/Modules/perl5.cxx
@@ -725,14 +725,11 @@
 
       /* Produce string representation of source and target arguments */
       sprintf(source, "ST(%d)", i);
-      String *target = Getattr(p, "lname");
 
       if (i >= num_required) {
 	Printf(f->code, "    if (items > %d) {\n", i);
       }
       if ((tm = Getattr(p, "tmap:in"))) {
-	Replaceall(tm, "$target", target);
-	Replaceall(tm, "$source", source);
 	Replaceall(tm, "$input", source);
 	Setattr(p, "emit:input", source);	/* Save input location */
 
@@ -767,7 +764,6 @@
     /* Insert constraint checking code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	p = Getattr(p, "tmap:check:next");
       } else {
@@ -778,7 +774,6 @@
     /* Insert cleanup code */
     for (i = 0, p = l; p; i++) {
       if ((tm = Getattr(p, "tmap:freearg"))) {
-	Replaceall(tm, "$source", Getattr(p, "lname"));
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(cleanup, tm, "\n", NIL);
@@ -793,8 +788,6 @@
     for (i = 0, p = l; p; i++) {
       if ((tm = Getattr(p, "tmap:argout"))) {
 	SwigType *t = Getattr(p, "type");
-	Replaceall(tm, "$source", Getattr(p, "lname"));
-	Replaceall(tm, "$target", "ST(argvi)");
 	Replaceall(tm, "$result", "ST(argvi)");
 	if (is_shadow(t)) {
 	  Replaceall(tm, "$shadow", "SWIG_SHADOW");
@@ -855,8 +848,6 @@
 
     if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
       SwigType *t = Getattr(n, "type");
-      Replaceall(tm, "$source", Swig_cresult_name());
-      Replaceall(tm, "$target", "ST(argvi)");
       Replaceall(tm, "$result", "ST(argvi)");
       if (is_shadow(t)) {
 	Replaceall(tm, "$shadow", "SWIG_SHADOW");
@@ -884,13 +875,11 @@
 
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-	Replaceall(tm, "$source", Swig_cresult_name());
 	Printf(f->code, "%s\n", tm);
       }
     }
 
     if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printf(f->code, "%s\n", tm);
     }
 
@@ -995,8 +984,6 @@
       /* Check for a few typemaps */
       tm = Swig_typemap_lookup("varin", n, name, 0);
       if (tm) {
-	Replaceall(tm, "$source", "sv");
-	Replaceall(tm, "$target", name);
 	Replaceall(tm, "$input", "sv");
 	/* Printf(setf->code,"%s\n", tm); */
 	emit_action_code(n, setf->code, tm);
@@ -1019,9 +1006,7 @@
     Printv(getf->code, tab4, "MAGIC_PPERL\n", NIL);
 
     if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
-      Replaceall(tm, "$target", "sv");
       Replaceall(tm, "$result", "sv");
-      Replaceall(tm, "$source", name);
       if (is_shadow(t)) {
 	Replaceall(tm, "$shadow", "SWIG_SHADOW");
       } else {
@@ -1111,8 +1096,6 @@
     }
 
     if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", name);
       Replaceall(tm, "$value", value);
       if (is_shadow(type)) {
 	Replaceall(tm, "$shadow", "SWIG_SHADOW");
@@ -1121,8 +1104,6 @@
       }
       Printf(constant_tab, "%s,\n", tm);
     } else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", name);
       Replaceall(tm, "$value", value);
       if (is_shadow(type)) {
 	Replaceall(tm, "$shadow", "SWIG_SHADOW");
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index 79c2bd5..540fd35 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -1345,7 +1345,6 @@
     /* Insert constraint checking code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	p = Getattr(p, "tmap:check:next");
       } else {
@@ -1493,7 +1492,6 @@
     if (!wrapping_member_constant) {
       {
 	tm = Swig_typemap_lookup("consttab", n, name, 0);
-	Replaceall(tm, "$target", name);
 	Replaceall(tm, "$value", value);
 	Printf(s_cinit, "%s\n", tm);
       }
diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx
index b8ed403..c8cd087 100644
--- a/Source/Modules/pike.cxx
+++ b/Source/Modules/pike.cxx
@@ -341,8 +341,6 @@
 	/* Look for an input typemap */
 	sprintf(source, "Pike_sp[%d-args]", i - start + offset);
 	if ((tm = Getattr(p, "tmap:in"))) {
-	  Replaceall(tm, "$source", source);
-	  Replaceall(tm, "$target", ln);
 	  Replaceall(tm, "$input", source);
 	  Setattr(p, "emit:input", source);
 	  Printf(f->code, "%s\n", tm);
@@ -371,7 +369,6 @@
     /* Insert constraint checking code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	p = Getattr(p, "tmap:check:next");
       } else {
@@ -383,7 +380,6 @@
     String *cleanup = NewString("");
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:freearg"))) {
-	Replaceall(tm, "$source", Getattr(p, "lname"));
 	Printv(cleanup, tm, "\n", NIL);
 	p = Getattr(p, "tmap:freearg:next");
       } else {
@@ -395,8 +391,6 @@
     String *outarg = NewString("");
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:argout"))) {
-	Replaceall(tm, "$source", Getattr(p, "lname"));
-	Replaceall(tm, "$target", "resultobj");
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(outarg, tm, "\n", NIL);
@@ -422,8 +416,6 @@
       Printv(description, ", ", NIL);
       if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
         actioncode = 0;
-	Replaceall(tm, "$source", Swig_cresult_name());
-	Replaceall(tm, "$target", "resultobj");
 	Replaceall(tm, "$result", "resultobj");
 	if (GetFlag(n, "feature:new")) {
 	  Replaceall(tm, "$owner", "1");
@@ -454,14 +446,12 @@
     /* Look to see if there is any newfree cleanup code */
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-	Replaceall(tm, "$source", Swig_cresult_name());
 	Printf(f->code, "%s\n", tm);
       }
     }
 
     /* See if there is any return cleanup code */
     if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printf(f->code, "%s\n", tm);
     }
 
@@ -586,8 +576,6 @@
     /* Perform constant typemap substitution */
     String *tm = Swig_typemap_lookup("constant", n, value, 0);
     if (tm) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", symname);
       Replaceall(tm, "$symname", symname);
       Replaceall(tm, "$value", value);
       Printf(f_init, "%s\n", tm);
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index d10e0b9..6bc7ef7 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -2867,8 +2867,6 @@
 	  } else {
 	    Replaceall(tm, "$self", "obj0");
 	  }
-	  Replaceall(tm, "$source", source);
-	  Replaceall(tm, "$target", ln);
 	  Replaceall(tm, "$input", source);
 	  Setattr(p, "emit:input", source);	/* Save the location of the object */
 
@@ -2976,7 +2974,6 @@
     /* Insert constraint checking code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	p = Getattr(p, "tmap:check:next");
       } else {
@@ -2998,7 +2995,6 @@
 	  }
 	}
 	if (tm && (Len(tm) != 0)) {
-	  Replaceall(tm, "$source", Getattr(p, "lname"));
 	  Printv(cleanup, tm, "\n", NIL);
 	}
 	p = Getattr(p, "tmap:freearg:next");
@@ -3010,8 +3006,6 @@
     /* Insert argument output code */
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:argout"))) {
-	Replaceall(tm, "$source", Getattr(p, "lname"));
-	Replaceall(tm, "$target", "resultobj");
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(outarg, tm, "\n", NIL);
@@ -3100,8 +3094,6 @@
       } else {
 	Replaceall(tm, "$self", "obj0");
       }
-      Replaceall(tm, "$source", Swig_cresult_name());
-      Replaceall(tm, "$target", "resultobj");
       Replaceall(tm, "$result", "resultobj");
       if (builtin_ctor) {
 	Replaceall(tm, "$owner", "SWIG_BUILTIN_INIT");
@@ -3167,7 +3159,6 @@
     /* Look to see if there is any newfree cleanup code */
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-	Replaceall(tm, "$source", Swig_cresult_name());
 	Printf(f->code, "%s\n", tm);
 	Delete(tm);
       }
@@ -3175,7 +3166,6 @@
 
     /* See if there is any return cleanup code */
     if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printf(f->code, "%s\n", tm);
       Delete(tm);
     }
@@ -3461,8 +3451,6 @@
       }
       Printf(setf->def, "SWIGINTERN int %s(PyObject *_val) {", varsetname);
       if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
-	Replaceall(tm, "$source", "_val");
-	Replaceall(tm, "$target", name);
 	Replaceall(tm, "$input", "_val");
 	if (Getattr(n, "tmap:varin:implicitconv")) {
 	  Replaceall(tm, "$implicitconv", get_implicitconv_flag(n));
@@ -3503,8 +3491,6 @@
       Append(getf->code, "  (void)self;\n");
     }
     if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
-      Replaceall(tm, "$source", name);
-      Replaceall(tm, "$target", "pyobj");
       Replaceall(tm, "$result", "pyobj");
       addfail = emit_action_code(n, getf->code, tm);
       Delete(tm);
@@ -3584,8 +3570,6 @@
     }
 
     if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", name);
       Replaceall(tm, "$value", value);
       Printf(const_code, "%s,\n", tm);
       Delete(tm);
@@ -3600,8 +3584,6 @@
     }
 
     if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", name);
       Replaceall(tm, "$value", value);
       if (needs_swigconstant(n) && !builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER)) && (!in_class || !Getattr(n, "feature:python:callback"))) {
 	// Generate `*_swigconstant()` method which registers the new constant.
diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
index 3e3c23e..b3f109f 100644
--- a/Source/Modules/r.cxx
+++ b/Source/Modules/r.cxx
@@ -634,7 +634,6 @@
     if(returnTM) {
       String *tm = returnTM;
       Replaceall(tm,"$input", "r_swig_cb_data->retValue");
-      Replaceall(tm,"$target", Swig_cresult_name());
       replaceRClass(tm, rettype);
       Replaceall(tm,"$owner", "0");
       Replaceall(tm,"$disown","0");
@@ -1745,7 +1744,7 @@
     /* Add the name of this member to a list for this class_name.
        We will dump all these at the end. */
 
-    bool isSet(GetFlag(n, "memberset"));
+    bool isSet = GetFlag(n, "memberset") ? true : false;
 
     String *tmp = NewString(isSet ? Swig_name_set(NSPACE_TODO, class_name) : Swig_name_get(NSPACE_TODO, class_name));
 
@@ -1912,8 +1911,6 @@
 
     if ((tm = Getattr(p,"tmap:scheck"))) {
 
-      Replaceall(tm,"$target", lname);
-      Replaceall(tm,"$source", name);
       Replaceall(tm,"$input", name);
       replaceRClass(tm, Getattr(p, "type"));
       Printf(sfun->code,"%s\n",tm);
@@ -1924,8 +1921,6 @@
     curP = p;
     if ((tm = Getattr(p,"tmap:in"))) {
 
-      Replaceall(tm,"$target", lname);
-      Replaceall(tm,"$source", name);
       Replaceall(tm,"$input", name);
 
       if (Getattr(p,"wrap:disown") || (Getattr(p,"tmap:in:disown"))) {
@@ -1984,7 +1979,6 @@
   String *cleanup = NewString("");
   for (p = l; p;) {
     if ((tm = Getattr(p, "tmap:freearg"))) {
-      Replaceall(tm, "$source", Getattr(p, "lname"));
       if (tm && (Len(tm) != 0)) {
         Printv(cleanup, tm, "\n", NIL);
       }
@@ -2001,7 +1995,6 @@
       //       String *lname =  Getattr(p, "lname");
       numOutArgs++;
       String *pos = NewStringf("%d", numOutArgs);
-      Replaceall(tm,"$source", Getattr(p, "lname"));
       Replaceall(tm,"$result", "r_ans");
       Replaceall(tm,"$n", pos); // The position into which to store the answer.
       Replaceall(tm,"$arg", Getattr(p, "emit:input"));
@@ -2076,14 +2069,12 @@
   /* Look to see if there is any newfree cleanup code */
   if (GetFlag(n, "feature:new")) {
     if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());	/* deprecated */
       Printf(f->code, "%s\n", tm);
     }
   }
 
   /* See if there is any return cleanup code */
   if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-    Replaceall(tm, "$source", Swig_cresult_name());
     Printf(f->code, "%s\n", tm);
     Delete(tm);
   }
@@ -2092,7 +2083,6 @@
 
   /*If the user gave us something to convert the result in  */
   if ((tm = Swig_typemap_lookup("scoerceout", n, Swig_cresult_name(), sfun))) {
-    Replaceall(tm,"$source","ans");
     Replaceall(tm,"$result","ans");
     if (constructor) {
       Node * parent = Getattr(n, "parentNode");
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index 48b0efa..bb4d19d 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -1425,16 +1425,14 @@
    * applyInputTypemap()
    *
    * Look up the appropriate "in" typemap for this parameter (p),
-   * substitute the correct strings for the $target and $input typemap
-   * parameters, and dump the resulting code to the wrapper file.
+   * substitute the correct strings for the typemap parameters, and dump the
+   * resulting code to the wrapper file.
    * --------------------------------------------------------------------- */
 
-  Parm *applyInputTypemap(Parm *p, String *ln, String *source, Wrapper *f, String *symname) {
+  Parm *applyInputTypemap(Parm *p, String *source, Wrapper *f, String *symname) {
     String *tm;
     SwigType *pt = Getattr(p, "type");
     if ((tm = Getattr(p, "tmap:in"))) {
-      Replaceall(tm, "$target", ln);
-      Replaceall(tm, "$source", source);
       Replaceall(tm, "$input", source);
       Replaceall(tm, "$symname", symname);
 
@@ -1474,10 +1472,8 @@
     Parm *p;
     String *tm;
     String *source;
-    String *target;
 
     source = NewString("");
-    target = NewString("");
 
     bool ctor_director = (current == CONSTRUCTOR_INITIALIZE && Swig_directorclass(n));
 
@@ -1498,7 +1494,6 @@
       p = skipIgnoredArgs(p);
 
       String *pn = Getattr(p, "name");
-      String *ln = Getattr(p, "lname");
 
       /* Produce string representation of source argument */
       Clear(source);
@@ -1510,10 +1505,6 @@
 	Printf(source, "argv[%d]", i - start);
       }
 
-      /* Produce string representation of target argument */
-      Clear(target);
-      Printf(target, "%s", Char(ln));
-
       if (i >= (numreq)) {	/* Check if parsing an optional argument */
 	Printf(f->code, "    if (argc > %d) {\n", i - start);
       }
@@ -1526,7 +1517,7 @@
       }
 
       /* Look for an input typemap */
-      p = applyInputTypemap(p, ln, source, f, Getattr(n, "name"));
+      p = applyInputTypemap(p, source, f, Getattr(n, "name"));
       if (i >= numreq) {
 	Printf(f->code, "}\n");
       }
@@ -1553,7 +1544,6 @@
     }
 
     Delete(source);
-    Delete(target);
   }
 
   /* ---------------------------------------------------------------------
@@ -1569,7 +1559,6 @@
     String *tm;
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	p = Getattr(p, "tmap:check:next");
       } else {
@@ -1591,7 +1580,6 @@
     for (Parm *p = l; p;) {
       if ((tm = Getattr(p, "tmap:freearg"))) {
 	if (Len(tm) != 0) {
-	  Replaceall(tm, "$source", Getattr(p, "lname"));
 	  Printv(cleanup, tm, "\n", NIL);
 	}
 	p = Getattr(p, "tmap:freearg:next");
@@ -1613,8 +1601,6 @@
     String *tm;
     for (Parm *p = l; p;) {
       if ((tm = Getattr(p, "tmap:argout"))) {
-	Replaceall(tm, "$source", Getattr(p, "lname"));
-	Replaceall(tm, "$target", "vresult");
 	Replaceall(tm, "$result", "vresult");
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
@@ -1876,8 +1862,6 @@
           actioncode = 0;
           if (tm) {
             Replaceall(tm, "$result", "vresult");
-            Replaceall(tm, "$source", Swig_cresult_name());
-            Replaceall(tm, "$target", "vresult");
 
             if (GetFlag(n, "feature:new"))
               Replaceall(tm, "$owner", "SWIG_POINTER_OWN");
@@ -1975,7 +1959,6 @@
     if (current != CONSTRUCTOR_ALLOCATE && GetFlag(n, "feature:new")) {
       tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0);
       if (tm) {
-	Replaceall(tm, "$source", Swig_cresult_name());
 	Printv(f->code, tm, "\n", NIL);
 	Delete(tm);
       }
@@ -1984,7 +1967,6 @@
     /* Special processing on return value. */
     tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0);
     if (tm) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printv(f->code, tm, NIL);
       Delete(tm);
     }
@@ -2214,8 +2196,6 @@
     tm = Swig_typemap_lookup("varout", n, name, 0);
     if (tm) {
       Replaceall(tm, "$result", "_val");
-      Replaceall(tm, "$target", "_val");
-      Replaceall(tm, "$source", name);
       /* Printv(getf->code,tm, NIL); */
       addfail = emit_action_code(n, getf->code, tm);
     } else {
@@ -2250,8 +2230,6 @@
       tm = Swig_typemap_lookup("varin", n, name, 0);
       if (tm) {
 	Replaceall(tm, "$input", "_val");
-	Replaceall(tm, "$source", "_val");
-	Replaceall(tm, "$target", name);
 	/* Printv(setf->code,tm,"\n",NIL); */
 	emit_action_code(n, setf->code, tm);
       } else {
@@ -2363,8 +2341,6 @@
     if (!tm)
       tm = Swig_typemap_lookup("constcode", n, value, 0);
     if (tm) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", iname);
       Replaceall(tm, "$symname", iname);
       Replaceall(tm, "$value", value);
       if (current == CLASS_CONST) {
diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx
index 23e45f7..697284a 100644
--- a/Source/Modules/scilab.cxx
+++ b/Source/Modules/scilab.cxx
@@ -472,7 +472,6 @@
       String *tm;
       if ((tm = Getattr(param, "tmap:freearg"))) {
 	if (tm && (Len(tm) != 0)) {
-	  Replaceall(tm, "$source", Getattr(param, "lname"));
 	  Printf(wrapper->code, "%s\n", tm);
 	}
 	param = Getattr(param, "tmap:freearg:next");
@@ -484,7 +483,6 @@
     /* See if there is any return cleanup code */
     String *tm;
     if ((tm = Swig_typemap_lookup("ret", node, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printf(wrapper->code, "%s\n", tm);
       Delete(tm);
     }
diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx
index 7a78ede..fcf36d1 100644
--- a/Source/Modules/tcl8.cxx
+++ b/Source/Modules/tcl8.cxx
@@ -336,8 +336,6 @@
       if ((tm = Getattr(p, "tmap:in"))) {
 	String *parse = Getattr(p, "tmap:in:parse");
 	if (!parse) {
-	  Replaceall(tm, "$target", ln);
-	  Replaceall(tm, "$source", source);
 	  Replaceall(tm, "$input", source);
 	  Setattr(p, "emit:input", source);
 
@@ -401,7 +399,6 @@
     /* Insert constraint checking code */
     for (p = parms; p;) {
       if ((tm = Getattr(p, "tmap:check"))) {
-	Replaceall(tm, "$target", Getattr(p, "lname"));
 	Printv(f->code, tm, "\n", NIL);
 	p = Getattr(p, "tmap:check:next");
       } else {
@@ -414,7 +411,6 @@
       if (!checkAttribute(p, "tmap:in:numinputs", "0")
 	  && !Getattr(p, "tmap:in:parse") && (tm = Getattr(p, "tmap:freearg"))) {
 	if (Len(tm) != 0) {
-	  Replaceall(tm, "$source", Getattr(p, "lname"));
 	  Printv(cleanup, tm, "\n", NIL);
 	}
 	p = Getattr(p, "tmap:freearg:next");
@@ -426,12 +422,9 @@
     /* Insert argument output code */
     for (i = 0, p = parms; p; i++) {
       if ((tm = Getattr(p, "tmap:argout"))) {
-	Replaceall(tm, "$source", Getattr(p, "lname"));
 #ifdef SWIG_USE_RESULTOBJ
-	Replaceall(tm, "$target", "resultobj");
 	Replaceall(tm, "$result", "resultobj");
 #else
-	Replaceall(tm, "$target", "(Tcl_GetObjResult(interp))");
 	Replaceall(tm, "$result", "(Tcl_GetObjResult(interp))");
 #endif
 	Replaceall(tm, "$arg", Getattr(p, "emit:input"));
@@ -450,12 +443,9 @@
 
     /* Return value if necessary  */
     if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
 #ifdef SWIG_USE_RESULTOBJ
-      Replaceall(tm, "$target", "resultobj");
       Replaceall(tm, "$result", "resultobj");
 #else
-      Replaceall(tm, "$target", "(Tcl_GetObjResult(interp))");
       Replaceall(tm, "$result", "(Tcl_GetObjResult(interp))");
 #endif
       if (GetFlag(n, "feature:new")) {
@@ -478,13 +468,11 @@
     /* Look for any remaining cleanup */
     if (GetFlag(n, "feature:new")) {
       if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
-	Replaceall(tm, "$source", Swig_cresult_name());
 	Printf(f->code, "%s\n", tm);
       }
     }
 
     if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
-      Replaceall(tm, "$source", Swig_cresult_name());
       Printf(f->code, "%s\n", tm);
     }
 #ifdef SWIG_USE_RESULTOBJ
@@ -580,8 +568,6 @@
     Printv(getf->def, "SWIGINTERN const char *", getfname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2, int flags) {", NIL);
     Wrapper_add_local(getf, "value", "Tcl_Obj *value = 0");
     if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
-      Replaceall(tm, "$source", name);
-      Replaceall(tm, "$target", "value");
       Replaceall(tm, "$result", "value");
       /* Printf(getf->code, "%s\n",tm); */
       addfail = emit_action_code(n, getf->code, tm);
@@ -616,8 +602,6 @@
         Wrapper_add_local(setf, "name1o", "Tcl_Obj *name1o = 0");
 
         if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
-	  Replaceall(tm, "$source", "value");
-	  Replaceall(tm, "$target", name);
 	  Replaceall(tm, "$input", "value");
 	  Printf(setf->code, "name1o = Tcl_NewStringObj(name1,-1);\n");
 	  Printf(setf->code, "value = Tcl_ObjGetVar2(interp, name1o, 0, flags);\n");
@@ -690,14 +674,10 @@
     }
 
     if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", name);
       Replaceall(tm, "$value", value);
       Replaceall(tm, "$nsname", nsname);
       Printf(const_tab, "%s,\n", tm);
     } else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
-      Replaceall(tm, "$source", value);
-      Replaceall(tm, "$target", name);
       Replaceall(tm, "$value", value);
       Replaceall(tm, "$nsname", nsname);
       Printf(f_init, "%s\n", tm);
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index 557b548..75bec61 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -113,7 +113,7 @@
   const char *s = Char(str);
   int isdigits = (*s != 0);
   while (*s) {
-    if (!isdigit(*s)) {
+    if (!isdigit((int)*s)) {
       isdigits = 0;
       break;
     }
diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh
index 3259ad4..cb7d9d2 100755
--- a/Tools/travis-linux-install.sh
+++ b/Tools/travis-linux-install.sh
@@ -44,6 +44,8 @@
 					travis_retry npm install -g node-gyp@$VER
 				elif [ "$VER" == "8" ] ; then
 					travis_retry npm install -g node-gyp@6
+				elif [ "$VER" == "10" ] || [ "$VER" == "12" ] || [ "$VER" == "14" ]  || [ "$VER" == "16" ]; then
+					travis_retry npm install -g node-gyp@7
 				else
 					travis_retry npm install -g node-gyp
 				fi
diff --git a/appveyor.yml b/appveyor.yml
index 6838f7b..6044e19 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -12,8 +12,10 @@
     PY3: 3
     APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
 
-#matrix:
-#  allow_failures:
+matrix:
+  allow_failures:
+  - SWIGLANG: python
+    OSVARIANT: cygwin
 
 install:
 - date /T & time /T
@@ -76,7 +78,7 @@
         $env:CHECK_OPTIONS2="CFLAGS+=-DMS_WIN64 CXXFLAGS+=-DMS_WIN64"
       }
     }
-- if "%OSVARIANT%"=="" bash -c "cd /usr/bin && curl --retry 15 -s -L https://github.com/swig/cccl/archive/cccl-1.0.tar.gz | tar -xz --strip 1 cccl-cccl-1.0/cccl"
+- if "%OSVARIANT%"=="" bash -c "cd /usr/bin && curl --retry 15 -s -L https://github.com/swig/cccl/archive/cccl-1.2.tar.gz | tar -xz --strip 1 cccl-cccl-1.2/cccl"
 - if "%OSVARIANT%"=="" call "%VCVARSBAT%" %VCVARSARG%
 - if "%OSVARIANT%"=="" Tools\nuget-install.cmd pcre -Verbosity quiet -Version 8.33.0.1 -OutputDirectory C:\pcre
 - if "%OSVARIANT%"=="" set PCRE_ROOT=C:/pcre/pcre.8.33.0.1/build/native
@@ -105,7 +107,7 @@
 - set CHECK_OPTIONS=CSHARPOPTIONS=-platform:%Platform%
 - if "%BUILDSYSTEM%"=="cmake" cmake --version && cmake -G "Visual Studio 14 2015%VSARCH%" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/WX /DPCRE_STATIC" -DCMAKE_CXX_FLAGS="/WX /DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/cygwin/bin/bison.exe . && cmake --build . --config Release --target install && ctest --output-on-failure -V -C Release && appveyor exit
   # Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor
-- if "%OSVARIANT%"=="" bash -c "exec 0</dev/null && ./autogen.sh && time ./configure --disable-dependency-tracking --disable-ccache CC=$CC CXX=$CXX CFLAGS='-O2' CXXFLAGS='-O2' LDFLAGS='--cccl-link /LTCG' PCRE_CFLAGS='-I%PCRE_ROOT%/include -DPCRE_STATIC' PCRE_LIBS='-L%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8 -lpcre8' --without-perl5 --without-go --with-boost=%BOOSTROOT% || cat config.log"
+- if "%OSVARIANT%"=="" bash -c "exec 0</dev/null && ./autogen.sh && time ./configure --disable-dependency-tracking --disable-ccache --enable-cpp11-testing CC=$CC CXX=$CXX CFLAGS='-O2' CXXFLAGS='-O2' LDFLAGS='--cccl-link /LTCG' PCRE_CFLAGS='-I%PCRE_ROOT%/include -DPCRE_STATIC' PCRE_LIBS='-L%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8 -lpcre8' --without-perl5 --without-go --with-boost=%BOOSTROOT% || cat config.log"
 - if not "%OSVARIANT%"=="" bash -c "exec 0</dev/null && ./autogen.sh && time ./configure CC=%CC% CXX=%CXX% --without-alllang --with-$SWIGLANG$PY3$SWIGWITHLANG --enable-cpp11-testing || cat config.log"
 - bash -c "time make -s -j%MAKEJOBS%"
 
diff --git a/configure.ac b/configure.ac
index e8cdfb0..23d0a37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
 dnl Tools/config directory in .m4 files.
 
 AC_INIT([swig],[4.1.0],[http://www.swig.org])
-AC_PREREQ(2.60)
+AC_PREREQ([2.60])
 
 AC_CONFIG_SRCDIR([Source/Swig/swig.h])
 AC_CONFIG_AUX_DIR([Tools/config])
@@ -34,8 +34,8 @@
 AC_DEFINE_UNQUOTED(SWIG_CXX, ["$CXX"], [Compiler that built SWIG])
 AC_DEFINE_UNQUOTED(SWIG_PLATFORM, ["$host"], [Platform that SWIG is built for])
 
-dnl Checks for header files.
-AC_HEADER_STDC
+# For AC_EGREP_CPP
+AC_PROG_EGREP
 
 dnl Look for popen
 AC_ARG_WITH(popen, AS_HELP_STRING([--without-popen], [Disable popen]), with_popen="$withval")
@@ -301,18 +301,51 @@
 if test x"$enable_cpp11_testing" = xyes; then
   CXX_SAVED=$CXX
   CXXCPP_SAVED=$CXXCPP
+
+  # Test for c++17
   CXXCPP=" "
-  AX_CXX_COMPILE_STDCXX(11, [noext], [optional])
-  AC_MSG_CHECKING([whether C++11 testing is actually enabled])
-  if test "$HAVE_CXX11" = "1"; then
+  AX_CXX_COMPILE_STDCXX(17, [noext], [optional])
+  AC_MSG_CHECKING([whether C++17 and earlier testing is enabled])
+  if test "$HAVE_CXX17" = "1"; then
     AC_MSG_RESULT([yes])
     PLATCXXFLAGS="$CXXCPP $PLATCXXFLAGS"
+    HAVE_CXX14="1"
+    HAVE_CXX11="1"
   else
     AC_MSG_RESULT([no])
+
+    # Test for c++14
+    CXXCPP=" "
+    CXX=$CXX_SAVED
+    AX_CXX_COMPILE_STDCXX(14, [noext], [optional])
+    AC_MSG_CHECKING([whether C++14 and earlier testing is enabled])
+    if test "$HAVE_CXX14" = "1"; then
+      AC_MSG_RESULT([yes])
+      PLATCXXFLAGS="$CXXCPP $PLATCXXFLAGS"
+      HAVE_CXX11="1"
+    else
+      AC_MSG_RESULT([no])
+
+      # Test for c++11
+      CXXCPP=" "
+      CXX=$CXX_SAVED
+      AX_CXX_COMPILE_STDCXX(11, [noext], [optional])
+      AC_MSG_CHECKING([whether C++11 and earlier testing is enabled])
+      if test "$HAVE_CXX11" = "1"; then
+        AC_MSG_RESULT([yes])
+        PLATCXXFLAGS="$CXXCPP $PLATCXXFLAGS"
+      else
+        AC_MSG_RESULT([no])
+      fi
+
+    fi
+
   fi
+
   CXX=$CXX_SAVED
   CXXCPP=$CXXCPP_SAVED
 fi
+AC_SUBST(HAVE_CXX11)
 
 # On darwin 10.7,10.8,10.9 using clang++, need to ensure using
 # libc++ for tests and examples to run under mono. May affect
@@ -369,7 +402,6 @@
 AC_SUBST(RPATH)
 AC_SUBST(PLATCFLAGS)
 AC_SUBST(PLATCXXFLAGS)
-AC_SUBST(HAVE_CXX11)
 AC_SUBST(LINKFORSHARED)
 
 # This variation is needed on OS-X because there is no (apparent) consistency in shared library naming.
@@ -471,6 +503,7 @@
 TCLINCLUDE=
 TCLLIB=
 TCLPACKAGE=
+TCLLINK=
 
 AC_ARG_WITH(tclconfig, AS_HELP_STRING([--without-tcl], [Disable Tcl])
 AS_HELP_STRING([--with-tclconfig=path], [Set location of tclConfig.sh]), [with_tclconfig="$withval"], [with_tclconfig=])
@@ -543,7 +576,7 @@
 
 AC_MSG_CHECKING(for Tcl header files)
 if test -z "$TCLINCLUDE"; then
-AC_TRY_CPP([#include <tcl.h>], , TCLINCLUDE="")
+AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <tcl.h>]])],[],[TCLINCLUDE=""])
 if test -z "$TCLINCLUDE"; then
 	dirs="/usr/local/include /usr/include /opt/local/include"
 	for i in $dirs ; do
@@ -563,7 +596,7 @@
 
 AC_MSG_CHECKING(for Tcl library)
 if test -z "$TCLLIB"; then
-dirs="/usr/local/lib /usr/lib /opt/local/lib"
+dirs="/usr/local/lib /usr/lib /opt/local/lib /opt/freeware/lib"
 for i in $dirs ; do
 	if test -r $i/libtcl.a; then
 	    AC_MSG_RESULT($i)
@@ -581,9 +614,16 @@
 # Cygwin (Windows) needs the library for dynamic linking
 case $host in
 *-*-cygwin* | *-*-mingw*) TCLDYNAMICLINKING="$TCLLIB";;
+*-*-aix*) TCLDYNAMICLINKING="$TCLLIB";;
 *)TCLDYNAMICLINKING="";;
 esac
 
+# AIX needs -ltcl for linking at test time
+case $host in
+*-*-aix*) TCLLINK="-ltcl";;
+*)TCLLINK="";;
+esac
+
 case $host in
 *-*-darwin*)
     TCLLDSHARED='$(CC) -dynamiclib -undefined suppress -flat_namespace'
@@ -602,6 +642,7 @@
 AC_SUBST(TCLDYNAMICLINKING)
 AC_SUBST(TCLLDSHARED)
 AC_SUBST(TCLCXXSHARED)
+AC_SUBST(TCLLINK)
 
 #----------------------------------------------------------------
 # Look for Python
@@ -1603,15 +1644,15 @@
 
   if test -z "$JSCORELIB" -a -n "$PKG_CONFIG "; then
     AC_MSG_CHECKING(for JavaScriptCore/Webkit library)
-    if $PKG_CONFIG  javascriptcoregtk-4.0; then
+    if $PKG_CONFIG  javascriptcoregtk-4.0 2>/dev/null ; then
       JSCORELIB=`$PKG_CONFIG  --libs javascriptcoregtk-4.0`
       JSCOREINC=`$PKG_CONFIG  --cflags-only-I javascriptcoregtk-4.0`
       JSCOREVERSION=`$PKG_CONFIG  --modversion javascriptcoregtk-4.0`
-    elif $PKG_CONFIG  javascriptcoregtk-3.0; then
+    elif $PKG_CONFIG  javascriptcoregtk-3.0 2>/dev/null ; then
       JSCORELIB=`$PKG_CONFIG  --libs javascriptcoregtk-3.0`
       JSCOREINC=`$PKG_CONFIG  --cflags-only-I javascriptcoregtk-3.0`
       JSCOREVERSION=`$PKG_CONFIG  --modversion javascriptcoregtk-3.0`
-    elif $PKG_CONFIG  javascriptcoregtk-1.0; then
+    elif $PKG_CONFIG  javascriptcoregtk-1.0 2>/dev/null ; then
       JSCORELIB=`$PKG_CONFIG  --libs javascriptcoregtk-1.0`
       JSCOREVERSION=`$PKG_CONFIG  --modversion javascriptcoregtk-1.0`
     fi