Merge branch 'master' into coverity-scan

* master: (478 commits)
  Use -rrbconfig rather than -rmkmf to load rbconfig
  Add suggestion to check block delimiter
  Add explanatory comment to pp_unknowndirective2.i
  Fix PHP crash in director_finalizer
  Add 3.0.4 release information
  Fix typo
  Note 1.8 as the oldest supported version
  Fix PHP backend for default_args testcase
  Update html
  Python 3 default args fix
  Revert introduction of python:defaultargs feature
  Ruby: Replace Config::CONFIG with RbConfig::CONFIG in configure.ac
  Add regression test for #217
  [PHP] Fix segfault in director upcall check
  Fix linux gcc warnings and strtol corrections
  Tests for Python default arguments and %pythondefaultargs.
  Python default arg improvements
  [lua/luarun] change return type from int to void on functions not returning anything
  Add note about delimiting blocks of Python code
  Fix python default_args testcase for Python 3
  Fix Python default argument handing broken since swig-3.0.3
  Python default argument test cases from issue #294
  Wording change for missing semicolon error
  Handle "constexpr explicit" and "constexpr static"
  Allow C++11 "explicit constexpr"
  Improve errors for missing ; and unexpected )
  Fix typo in old entry
  Add test coverage for unterminated %{ ... %} block
  When reporting an error for a construct which hasn't been terminated when the end of the file is reached, report it at the start line rather than "EOF" as then tools like editors and IDEs will take you to a generally more useful place for fixing the problem.
  Improve error message for extraneous '%}'.
  Add .gitignore for Examples/test-suite/errors/
  Fix testcase name in expected output
  Improve error message when an unknown SWIG directive is used
  Update link to point to 3.0 docs
  Fix links to the online 1.3 docs to instead be relative
  Drop deprecated warnings for ancient options
  Fix tab to space in HTML preformatted block
  Provide -cppext as a general command line option
  Split -help output into 4 chunks instead of 3
  More on Go examples [skip ci]
  Properly quote parameters in preinst-swig wrapper.
  Fix typo
  Bump version to 3.0.4
  HTML tweaks
  Add 3.0.3 release information
  Minor tweaks to the changes file
  %constant and structs support for Lua
  Fix D examples when run 'in-source'
  Fix D examples clean
  Revert "Fix D examples clean"
  Fix javascript clean
  Let Octave 3.8 fail in Travis
  Fix D examples clean
  Fix javascript clean
  Tidy up Javascript build system
  Don't delete checked in files with 'make distclean'
  Reduce scope of template_default_class_parms testcase
  Fix abort using template default parameters
  Test suite warning fixes
  [Perl] tidy "warning: duplicate 'extern' declaration specifier" when building generated code under clang
  Issue #282 perl5 archlib vs archlibexp
  [Go] Changed link 'https://github.com/golang/go/tree/master/misc/swig' to 'https://golang.org/misc/swig' in the Go documentation.
  [Go] Updated Go documentation (examples, runtime.SetFinalizer, object ownership).
  Added auto-generated 'Examples/d/example.mk' to '.gitignore'.
  Warning suppressions in tests
  nested_scope test fixes for clang
  Fix use of preprocessor null directive
  Add testcase for nested inner class deriving from a templated base class and defined outside of the outer class.
  Add in missing constant_directive.i test
  Improve Python builtin and %constant structs
  fixed python global object constants
  Partial support for %constant and structs
  Ignore E402 (import not on top of file) PEP8 error.
  Add PEP8_FLAGS variable to the test suite Python makefile.
  Fix templated constructors regression
  Correctly detect Go1 during configure
  Fix regression in introduced in merge of C++11 strongly typed enums support - Guile constants bad casts generated - Go non-public enum value wrappers assert failure
  Document new C++11 strongly typed enumerations support.
  Add more docs about _global_ prefix in typemap temporary variables
  Add clarification on _global_ prefix.
  Improve Javascript Webkit detection
  Add c++11 strongly typed enums runtime test for Javascript
  Add c++11 strongly typed enums runtime test for Octave
  Add c++11 strongly typed enum support for Guile
  Add c++11 strongly typed enum support for Go
  Add c++11 strongly typed enum support for D
  Add c++11 strongly typed enum support for Lua
  Fix line endings in lua example
  Add c++11 strongly typed enums runtime test for Tcl
  Add c++11 strongly typed enum support for PHP
  Add c++11 strongly typed enums runtime test for Ruby
  Add c++11 strongly typed enums runtime test for Perl
  Enhance C++11 strongly typed enums testcase
  C++11 strongly typed enums runtime test for python
  fix for nested template defined out of class (issue #265)
  C++11 strongly typed enum support
  Add Java runtime testcases for C++11 strongly typed enums
  add director_nested_class to list of broken tests
  Add C# support for wrapping C++11 strongly typed enums
  Enhance strongly typed enums testcase
  ...

Conflicts:
	.travis.yml
diff --git a/.gitignore b/.gitignore
index d4d70b0..3bf0879 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,6 +67,7 @@
 CCache/config.log
 CCache/config.status
 Examples/Makefile
+Examples/d/example.mk
 Examples/guile/Makefile
 Examples/test-suite/*/Makefile
 Examples/xml/Makefile
@@ -85,10 +86,12 @@
 .dirstamp
 CCache/ccache-swig
 CCache/ccache-swig.1
+CCache/web/ccache-man.html
 Lib/swigwarn.swg
 Source/CParse/parser.c
 Source/CParse/parser.h
 Source/eswig
+Source/TAGS
 swig
 Tools/javascript/javascript
 
@@ -123,6 +126,18 @@
 Examples/test-suite/uffi/*/
 *_wrap.c
 *_wrap.cxx
+*-gypcopy.cxx
+
+# C# generated files
+*_runme.exe.mdb
+*_runme.exe
+
+# Javascript generated files
+*.gyp
+
+# Octave generated files
+swigexample*.oct
+Examples/test-suite/octave/*.oct
 
 # Python generated files, based on:
 #   https://github.com/github/gitignore/blob/master/Python.gitignore
@@ -130,9 +145,12 @@
 */__pycache__/
 /__pycache__/
 
-# C# generated files
-*_runme.exe.mdb
-*_runme.exe
+# Go generated files
+*.[5689]
+*_gc.c
 
 # Scratch directories
 Examples/scratch
+
+# Out of source tree build directories
+*build*/
diff --git a/ANNOUNCE b/ANNOUNCE
index 6229edc..894010d 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,8 +1,8 @@
-*** ANNOUNCE: SWIG 3.0.1 (in progress) ***
+*** ANNOUNCE: SWIG 3.0.4 (14 Jan 2015) ***
 
 http://www.swig.org
 
-We're pleased to announce SWIG-3.0.1, the latest SWIG release.
+We're pleased to announce SWIG-3.0.4, the latest SWIG release.
 
 What is SWIG?
 =============
@@ -10,22 +10,22 @@
 SWIG is a software development tool that reads C/C++ header files and
 generates the wrapper code needed to make C and C++ code accessible
 from other programming languages including Perl, Python, Tcl, Ruby,
-PHP, C#, Go, Java, Lua, Scheme (Guile, MzScheme, CHICKEN), D, Ocaml,
-Pike, Modula-3, Octave, R, Common Lisp (CLISP, Allegro CL, CFFI, UFFI).
-SWIG can also export its parse tree in the form of XML and Lisp
-s-expressions.  Major applications of SWIG include generation of
-scripting language extension modules, rapid prototyping, testing,
+PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN),
+D, Ocaml, Pike, Modula-3, Octave, R, Common Lisp (CLISP, Allegro CL,
+CFFI, UFFI).  SWIG can also export its parse tree in the form of XML
+and Lisp s-expressions.  Major applications of SWIG include generation
+of scripting language extension modules, rapid prototyping, testing,
 and user interface development for large C/C++ systems.
 
 Availability
 ============
 The release is available for download on Sourceforge at
 
-     http://prdownloads.sourceforge.net/swig/swig-3.0.1.tar.gz
+     http://prdownloads.sourceforge.net/swig/swig-3.0.4.tar.gz
 
 A Windows version is also available at
 
-     http://prdownloads.sourceforge.net/swig/swigwin-3.0.1.zip
+     http://prdownloads.sourceforge.net/swig/swigwin-3.0.4.zip
 
 Please report problems with this release to the swig-devel mailing list,
 details at http://www.swig.org/mail.html.
diff --git a/CCache/Makefile.in b/CCache/Makefile.in
index d8f9042..6cded08 100644
--- a/CCache/Makefile.in
+++ b/CCache/Makefile.in
@@ -14,7 +14,7 @@
 CC=@CC@
 CFLAGS=@CFLAGS@ -I.
 SWIG=swig
-SWIG_LIB=../../Lib
+SWIG_LIB=../$(srcdir)/../Lib
 EXEEXT=@EXEEXT@
 
 # Use standard autoconf approach to transform executable name using --program-prefix and --program-suffix
@@ -27,38 +27,40 @@
 
 all: $(PACKAGE_NAME)$(EXEEXT)
 
+# Regenerate Makefile if Makefile.in or config.status have changed.
+Makefile: $(srcdir)/Makefile.in ./config.status
+	$(SHELL) ./config.status
+
 # Note that HTML documentation is actually generated and used from the main SWIG documentation Makefile
-docs: $(PACKAGE_NAME).1 web/ccache-man.html
+docs: $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/ccache-man.html
 
 $(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS)
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
 
-$(PACKAGE_NAME).1: ccache.yo
-	-yodl2man -o $(PACKAGE_NAME).1 ccache.yo
+$(srcdir)/$(PACKAGE_NAME).1: $(srcdir)/ccache.yo
+	-yodl2man -o $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/ccache.yo
 
-web/ccache-man.html: ccache.yo
-	yodl2html -o web/ccache-man.html ccache.yo
+$(srcdir)/web/ccache-man.html: $(srcdir)/ccache.yo
+	yodl2html -o $(srcdir)/web/ccache-man.html $(srcdir)/ccache.yo
 
-install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
+install: $(PACKAGE_NAME)$(EXEEXT) $(srcdir)/$(PACKAGE_NAME).1
 	@echo "Installing $(PACKAGE_NAME)"
 	@echo "Installing $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)"
 	${INSTALLCMD} -d $(DESTDIR)${bindir}
 	${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
 	@echo "Installing $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1"
 	${INSTALLCMD} -d $(DESTDIR)${mandir}/man1
-	${INSTALLCMD} -m 644 ${srcdir}/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
+	${INSTALLCMD} -m 644 $(srcdir)/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
 
-uninstall: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
+uninstall: $(PACKAGE_NAME)$(EXEEXT) $(srcdir)/$(PACKAGE_NAME).1
 	rm -f $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
 	rm -f $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
 
 clean:
 	/bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT)
 
-check : test
-
 test: test.sh
-	SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' ./test.sh
+	SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' $(srcdir)/test.sh
 
 check: test
 
@@ -67,11 +69,11 @@
 	/bin/rm -rf autom4te.cache
 
 maintainer-clean: distclean
-	/bin/rm -f $(PACKAGE_NAME).1 web/ccache-man.html
+	/bin/rm -f $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/ccache-man.html
 
-	
+
 # FIXME: To fix this, test.sh needs to be able to take ccache from the
 # installed prefix, not from the source dir.
-installcheck: 
+installcheck:
 	@echo "WARNING!  This is not really \"installcheck\" yet."
 	$(MAKE) check
diff --git a/CHANGES b/CHANGES
index 821d76b..5b8355f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,249 @@
 See the CHANGES.current file for changes in the current version.
 See the RELEASENOTES file for a summary of changes in each release.
 
+Version 3.0.3 (30 Dec 2014)
+===========================
+
+2014-12-27: wsfulton
+            Fix #280 - abort using all default template parameters within other template
+            parameters.
+
+2014-12-27: talby
+            [Perl] Issue #282 perl5 archlib vs archlibexp
+            [Perl] tidy "warning: duplicate 'extern' declaration specifier" when building generated code
+            under clang
+
+2014-12-18: wsfulton
+            Add support for %constant and structs/classes - issue #272
+
+2014-12-09: wsfulton
+            Fix #245 - regression (since swig-3.0.0) in templated constructors.
+            Templated constructors could not be instantiated - they were incorrectly ignored with a warning 504:
+            "Function: xyz must have a return type. Ignored."
+
+2014-12-07: wsfulton
+            Add support for C++11 strongly typed enumerations.
+
+2014-11-21: wsfulton
+            [Java C#] Fix multiply defined error when using %rename of enum items when using the "simple enum"
+            wrappers.
+
+2014-10-28: vadz
+            [Python] Patch #201 The generated .py file no longer uses *args for all Python parameters.
+            Instead, the parameters are named using the C++ parameter names.
+
+2014-10-24: timotheecour
+            [D] Patch #204 Use core.atomic.atomicOp to mutate shared variables
+
+2014-10-21: wsfulton
+            Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
+            "compactdefaultargs" feature if the target language does not support kwargs.
+            Only Java and Python support kwargs, so this affects all the other languages.
+
+            *** POTENTIAL INCOMPATIBILITY  ***
+
+2014-10-10: diorcety
+            [Python] Patch #232 Fix property access using directors
+
+2014-10-06: wsfulton
+            [Python] Fixes when using -builtin and std::vector/std::list wrappers to allow deletion
+            of single elements, such as 'del vec[0]'.
+
+2014-09-30: oliverb
+            [Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript.
+
+2014-09-30: oliverb
+            [Javascript] Merge patch #195 by zittix - Fixed JSClassRef declaration not using the static one.
+
+2014-09-30: ianlancetaylor
+	    [Go] In configure script, require Go 1.1 or later.
+
+2014-09-30: wsfulton
+            [Python] Patch #207 - Fix No module error with -relativeimport when using single
+            header file import.
+
+2014-09-27: wsfulton
+            Patch #208 - Initialise newly created array when using array_functions in the
+            carrays.i library (C++ usage).
+
+2014-09-27: wsfulton
+            [Ruby] Patch #187 - Fix crash on shutdown of the Ruby interpreter if more than one
+            module was loaded at a time when data is being shared between modules.
+
+2014-09-27: wsfulton
+            [Java] Patch #168 - Fix leak in Java director string handling after the Java
+            upcall when called from a native thread.
+
+2014-09-25: ianlancetaylor
+	    [Go] Adjust generated code to work with upcoming Go 1.4
+	    release.
+
+2014-09-23: wsfulton
+            [Python] Add patch from Thomas Maslach to fix crash in wrappers when using -threads in
+            the STL iterators (SwigPyIterator destructor).
+
+2014-09-17: wsfulton
+            [C#] Merge patch #229 from contre - Add bool array types to arrays_csharp.i
+
+2014-09-12: olly
+	    [PHP] Add support for specifying any PHP interfaces a wrapped class
+	    implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
+
+2014-09-11: olly
+	    [PHP] Fix throwing a PHP exception through C++ from a subclassed
+	    director method - PHP NULL gets returned by the subclassed method
+	    in this case, so the directorout typemap needs to allow that (at
+	    least if an exception is active).
+
+2014-09-09: ianlancetaylor
+	    [Go] Add goargout typemap.
+
+2014-09-09: olly
+	    [PHP] Fix segmentation faults with directors in PHP >= 5.4, and
+	    reenable runme tests for director_basic testcase.  Fix from
+	    pavel-charvat in issue#164.
+
+2014-09-05: ianlancetaylor
+	    [Go] Add imtype, goin, goout, godirectorin, and
+	    godirectorout typemaps, to support writing Go code to
+	    convert between types.
+
+2014-09-02: olly
+	    [Python] Fix regression in indentation of python code produced with
+	    -modern, introduced by changes in #188.  Reported by fabiencastan
+	    in #218.
+
+2014-09-01: olly
+	    Issue an error for unknown SWIG preprocessor directives, rather
+	    than quietly ignoring them.  Reported by jrhelsey in issue#217.
+
+            *** POTENTIAL INCOMPATIBILITY  ***
+
+2014-08-15: talby
+            [Perl] Include guard fix for nested modules from Anthony Heading (SF Patch #350).
+
+2014-08-04: wsfulton
+            [C#] Merge patch #200 from gpetrou - Changed CSharp license header to include auto-generated
+            tag so that StyleCop ignores the files.
+
+2014-08-04: wsfulton
+            [Java] Merge patch #198 from Yuval Kashtan - Support for java.nio.ByteBuffer mapping to
+            unsigned char * in various.i in NIOBUFFER typemaps.
+
+2014-07-14: ianlancetaylor
+	    [Go] Change struct definition to use void *, not uint8, so
+	    that the type is recorded as possibly containing
+	    pointers.  This ensures that the 1.3 garbage collector
+	    does not collect pointers passed to C++ code.
+
+2014-07-01: wsfulton
+            Fix SF Bug #1375 - Expansion of the $parentclassname special variable incorrectly contains
+            brackets in the expanded name.
+
+Version 3.0.2 (4 Jun 2014)
+==========================
+
+2014-06-02: v-for-vandal
+            [Lua] Pull request #176:
+            If class has no __eq implemented, then default __eq is generated. 
+            Default __eq compares actual pointers stored inside Lua userdata.
+
+2014-06-02: vkalinin
+            Fix #183 - %extend and unnamed nested structs
+
+2014-05-28: kwwette
+            Fix install failure when using an 'out of source' build using the shipped
+            tarball - regression introduced in swig-3.0.1.
+
+2014-05-24: kwwette
+            [Octave] Remove deprecated -global/-noglobal command-line arguments
+
+            *** POTENTIAL INCOMPATIBILITY  ***
+
+Version 3.0.1 (27 May 2014)
+===========================
+
+2014-05-25: hfalcic
+	    [Python] Python 3 byte string output: use errors="surrogateescape"
+            if available on the version of Python that's in use. This allows
+            obtaining the original byte string (and potentially trying a fallback
+            encoding) if the bytes can't be decoded as UTF-8.
+
+            Previously, a UnicodeDecodeError would be raised with no way to treat
+            the data as bytes or try another codec.
+
+2014-05-18: vkalinin
+	    Bug #175 - Restore %extend to work for unnamed nested structures by using a C
+            symbol comprising the outer structure name and unnamed variable instance name.
+
+2014-05-15: kwwette
+	    Add #166 - 'make check' now works out of source. This required the examples to build
+            out of source. The main languages have been tested - C#, Go, Guile, Java, Javascript,
+            Lua, Octave, Perl, PHP, Python, Ruby and Tcl.
+
+2014-05-01: Oliver Buchtala
+	    Javascript support added, see Javascript chapter in the documentation.
+
+2014-05-01: olly
+	    [PHP] The generated __isset() method now returns true for read-only properties.
+
+2014-04-24: kwwette
+            [Go] Fix go ./configure parsing of gccgo --version, and
+            goruntime.swg typo in __GNUC_PATCHLEVEL__ (SF Bug #1298)
+
+2014-04-24: kwwette
+            Fix {python|perl5|ruby|tcl}/java examples
+
+            In Lib/gcj/cni.i, for compatibility with newer gcj versions:
+
+            - remove JvAllocObject() which gcj no longer defines, from gcj Changelog:
+              2004-04-16  Bryce McKinlay  <mckinlay@redhat.com>
+                * gcj/cni.h (JvAllocObject): Remove these obsolete,
+                undocumented CNI calls.
+
+            - change JvCreateJavaVM() argument from void* to JvVMInitArgs*, from gcj Changelog:
+              2005-02-23  Thomas Fitzsimmons  <fitzsim@redhat.com>
+              PR libgcj/16923
+              ...
+              (JvCreateJavaVM): Declare vm_args as JvVMInitArgs* rather than void*.
+
+            *** POTENTIAL INCOMPATIBILITY  ***
+
+2014-04-08: wsfulton
+            SF Bug #1366 - Remove duplicate declarations of strtoimax and strtoumax in inttypes.i
+
+2014-04-08: wsfulton
+            [Java C#] Enums which have been ignored via %ignore and are subsequently
+            used are handled slightly differently. Type wrapper classes are now generated
+            which are effectively a wrapper of an empty enum. Previously in Java uncompilable
+            code was generated and in C# an int was used.
+
+2014-04-04: wsfulton
+            Fix regression in 3.0.0 where legal code following an operator<< definition might
+            give a syntax error. SF Bug #1365.
+
+2014-04-03: olly
+	    [PHP] Fix wrapping director constructors with default parameters
+	    with a ZTS-enabled build of PHP.
+
+2014-04-02: olly
+	    [PHP] Pass the ZTS context we already have to avoid needing to
+	    call TSRMLS_FETCH, which is relatively expensive.
+
+2014-04-02: olly
+	    [PHP] Pass ZTS context through to t_output_helper() so it works
+	    with a ZTS-enabled build of PHP.  Reported by Pierre Labastie in
+	    github PR#155.
+
+2014-03-28: wsfulton
+            [Java C# D Go] Fixes for C enums used in an API and the definition of the enum
+            has not been parsed. For D, this fixes a segfault in SWIG. The other languages
+            now produce code that compiles, although the definition of the enum is needed
+            in order to use the enum properly from the target language.
+
+2014-03-23: v-for-vandal
+            [Lua] Fix for usage of snprintf in Lua runtime which Visual Studio does not have.
+
 Version 3.0.0 (16 Mar 2014)
 ===========================
 
@@ -917,13 +1160,13 @@
 
 2012-10-11: wsfulton
             Most of the special variables available for use in %exception are now also available for expansion in
-            %extend blocks. These are: $name $symname $overname $decl $fulldecl $parentname $parentsymname, see docs
+            %extend blocks. These are: $name $symname $overname $decl $fulldecl $parentclassname $parentclasssymname, see docs
             on "Class extension" in SWIGPlus.html. Patch based on submission from Kris Thielemans.
 
 2012-10-10: wsfulton
             Additional new special variables in %exception are expanded as follows:
-              $parentname - The parent class name (if any) for a method.
-              $parentsymname - The target language parent class name (if any) for a method.
+              $parentclassname - The parent class name (if any) for a method.
+              $parentclasssymname - The target language parent class name (if any) for a method.
 
 2012-10-08: iant
 	    [Go] Generating Go code now requires using the -intgosize option to
@@ -1518,7 +1761,7 @@
             -tmsearch and -tmused.
 
 2011-08-26: wsfulton
-            [C#, D] Fix %callback which was generating uncompileable code.
+            [C#, D] Fix %callback which was generating uncompilable code.
 
 2011-08-25: wsfulton
             Fix constructors in named typedef class declarations as reported by Gregory Bronner:
@@ -1757,7 +2000,7 @@
 	    PySlice_GetIndices, which changed signatures in python3.2.
 
 2011-04-07: wsfulton
-            Fix wrapping of const array typedefs which were generating uncompileable code as
+            Fix wrapping of const array typedefs which were generating uncompilable code as
             reported by Karl Wette.
 
 2011-04-03: szager
@@ -1984,8 +2227,8 @@
 	    Fix handling of multiple regex-using %renames attached to the same
 	    declaration. For example, now
 
-	      %rename("%(regex/^Set(.*)/put\\1/)s") "";
-	      %rename("%(regex/^Get(.*)/get\\1/)s") "";
+	      %rename("%(regex:/^Set(.*)/put\\1/)s") "";
+	      %rename("%(regex:/^Get(.*)/get\\1/)s") "";
 
 	    works as expected whereas before only the last anonymous rename was
 	    taken into account.
@@ -2195,7 +2438,7 @@
 	    in this case).
 
 2010-06-03: wsfulton
-            Fix uncompileable code when %rename results in two enum items
+            Fix uncompilable code when %rename results in two enum items
             with the same name. Reported by Vadim Zeitlin.
 
 Version 2.0.0 (2 June 2010)
@@ -2708,7 +2951,7 @@
             Fix #2310483 - function pointer typedef within extern "C" block.
 
 2009-11-13: wsfulton
-            Fix usage of nested template classes within templated classes so that compileable code 
+            Fix usage of nested template classes within templated classes so that compilable code 
             is generated.
 
 2009-11-13: olly
@@ -2716,7 +2959,7 @@
 	    wasn't being used.  Patch from gverbruggen in SF#2892647.
 
 2009-11-12: wsfulton
-            Fix usage of nested template classes so that compileable code is generated - the nested
+            Fix usage of nested template classes so that compilable code is generated - the nested
             template class is now treated like a normal nested classes, that is, as an opaque type
             unless the nestedworkaround feature is used.
 
@@ -2742,7 +2985,7 @@
 
 2009-11-11: wsfulton
             There were a number of C++ cases where nested classes/structs/unions were being handled
-            as if C code was being parsed which would oftentimes lead to uncompileable code as an
+            as if C code was being parsed which would oftentimes lead to uncompilable code as an
             attempt was made to wrap the nested structs like it is documented for C code. Now all
             nested structs/classes/unions are ignored in C++ mode, as was always documented. However,
             there is an improvement as usage of nested structs/classes/unions is now always treated
@@ -2754,7 +2997,7 @@
 	    Fix R for -fcompact and add std_map.i
 
 2009-11-08: wsfulton
-            Fix inconsistency for nested structs/unions/classes. Uncompileable code was being
+            Fix inconsistency for nested structs/unions/classes. Uncompilable code was being
             generated when inner struct and union declarations were used as types within the
             inner struct. The inner struct/union is now treated as a forward declaration making the
             behaviour the same as an inner class. (C++ code), eg:
@@ -2768,7 +3011,7 @@
 	    Ignored nested class/struct warnings now display the name of the ignored class/struct.
 
 2009-11-07: wsfulton
-	    Bug #1514681 - Fix nested template classes within a namespace generated uncompileable
+	    Bug #1514681 - Fix nested template classes within a namespace generated uncompilable
             code and introduced strange side effects to other wrapper code especially code
             after the nested template class. Note that nested template classes are still ignored.
 
@@ -2794,8 +3037,8 @@
             and in template parameter specializations:
 
               struct S {};
-              template <typename T> struct X { void a() {}; };
-              template <> struct X<S> { void b() {}; };
+              template <typename T> struct X { void a() {} };
+              template <> struct X<S> { void b() {} };
               %template(MyTConcrete) X< ::S >;
 
             plus probably some other corner case usage of ::.
@@ -3623,7 +3866,7 @@
 
 06/19/2008: wsfulton
             [Java, C#] C# and Java keywords will be renamed instead of just issuing a warning
-            and then generating uncompileable code. Warning 314 gives the new name when a 
+            and then generating uncompilable code. Warning 314 gives the new name when a 
             keyword is found.
 
 06/19/2008: wsfulton
@@ -4066,7 +4309,7 @@
 11/30/2007: wsfulton
 	    Fix using statements using a base class method where the methods were overloaded.
             Depending on the order of the using statements and method declarations, these
-            were previously generating uncompileable wrappers, eg:
+            were previously generating uncompilable wrappers, eg:
 
               struct Derived : Base {
                 virtual void funk();
@@ -4204,7 +4447,7 @@
               %attributeref(Class, AttributeType, AttributeName, AccessorMethod)
 
 10/16/2007: olly
-	    [Tcl] Fix several ocurrences of "warning: deprecated conversion
+	    [Tcl] Fix several occurrences of "warning: deprecated conversion
 	    from string constant to 'char*'" from GCC 4.2 in generated C/C++
 	    code.
 
@@ -5154,7 +5397,7 @@
 
 10/03/2006: wsfulton
             [Ruby] Fix #1527885 - Overloaded director virtual methods sometimes produced
-            uncompileable code when used with the director:except feature.
+            uncompilable code when used with the director:except feature.
 
 10/03/2006: wsfulton
             Directors: Directors are output in the order in which they are declared in 
@@ -9352,7 +9595,7 @@
             wrapper method only and not the extra overloaded methods that SWIG generates.
             For example:
 
-              %feature("except") void hello(int i=0, double d=0.0);
+              %feature("except") hello(int i=0, double d=0.0);
               void hello(int i=0, double d=0.0);
 
            will apply the feature to all three wrapper methods, that is:
@@ -9363,7 +9606,7 @@
 
            If the default arguments are not specified in the feature:
 
-              %feature("except") void hello(int i, double d);
+              %feature("except") hello(int i, double d);
               void hello(int i=0, double d=0.0);
 
            then the feature will only apply to this wrapper method:
@@ -10738,7 +10981,7 @@
                 ...
               }
 
-            Previously, none of BIG, LARGE or BAR would have produced compileable code
+            Previously, none of BIG, LARGE or BAR would have produced compilable code
             when using %javaconst(1).
 
 06/27/2004: wsfulton
@@ -20130,13 +20373,13 @@
 	   class TestClass
 	   {
 	   public:
-	     TestClass() {};
-	     TestClass(int a) {};
-	     ~TestClass() {};
-	     unsigned long xyz(short k) {};
-	     unsigned long xyz(int n) {};
-	     static void static_func() {};
-	     static void static_func(int a) {};
+	     TestClass() {}
+	     TestClass(int a) {}
+	     ~TestClass() {}
+	     unsigned long xyz(short k) {}
+	     unsigned long xyz(int n) {}
+	     static void static_func() {}
+	     static void static_func(int a) {}
 	   };
 	   void delete_TestClass(int a);
 
diff --git a/CHANGES.current b/CHANGES.current
index 826b1a2..1787477 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,43 +2,37 @@
 See the CHANGES file for changes in older releases.
 See the RELEASENOTES file for a summary of changes in each release.
 
-Version 3.0.1 (in progress)
+Version 3.0.4 (14 Jan 2015)
 ===========================
 
-2014-05-01: olly
-	    [PHP] The generated __isset() method now returns true for read-only properties.
+2015-01-12: olly
+	    [PHP] Fix segfault in director upcall check when using PHP built with
+	    ZTS enabled.  Fixes #155, reported by Pierre Labastie.
 
-2014-04-08: wsfulton
-            SF Bug #1366 - Remove duplicate declarations of strtoimax and strtoumax in inttypes.i
+2015-01-12: vadz
+            [Python] Fix #294 #296 - Regression introduced in SWIG-3.0.3 when
+            wrapping functions with default arguments. Invalid or missing default
+            arguments were sometimes being generated into the python layer.
 
-2014-04-08: wsfulton
-            [Java C#] Enums which have been ignored via %ignore and are subsequently
-            used are handled slightly differently. Type wrapper classes are now generated
-            which are effectively a wrapper of an empty enum. Previously in Java uncompilable
-            code was generated and in C# an int was used.
+2015-01-08: olly
+	    Allow C++11 "explicit constexpr".  Fixes github issue #284 reported
+	    by Paweł Tomulik.  Also handle "constexpr explicit" and "constexpr
+	    static".
 
-2014-04-04: wsfulton
-            Fix regression in 3.0.0 where legal code following an operator<< definition might
-            give a syntax error. SF Bug #1365.
+2015-01-08: olly
+	    When reporting an error for a construct which hasn't been
+	    terminated when the end of the file is reached, report it at the
+	    start line rather than "EOF" as then tools like editors and IDEs
+	    will take you to a generally more useful place for fixing the
+	    problem.
 
-2014-04-03: olly
-	    [PHP] Fix wrapping director constructors with default parameters
-	    with a ZTS-enabled build of PHP.
+2015-01-08: olly
+	    Improve error messages for a few cases which previously gave the
+	    one of the cryptic catch-all errors "Syntax error in input".
 
-2014-04-02: olly
-	    [PHP] Pass the ZTS context we already have to avoid needing to
-	    call TSRMLS_FETCH, which is relatively expensive.
-
-2014-04-02: olly
-	    [PHP] Pass ZTS context through to t_output_helper() so it works
-	    with a ZTS-enabled build of PHP.  Reported by Pierre Labastie in
-	    github PR#155.
-
-2014-03-28: wsfulton
-            [Java C# D Go] Fixes for C enums used in an API and the definition of the enum
-            has not been parsed. For D, this fixes a segfault in SWIG. The other languages
-            now produce code that compiles, although the definition of the enum is needed
-            in order to use the enum properly from the target language.
-
-2014-03-23: v-for-vandal
-            [Lua] Fix for usage of snprintf in Lua runtime which Visual Studio does not have.
+2015-01-08: olly
+	    Provide -cppext as a general command line option for setting the
+	    extension used for generated C++ files (previously it was specific
+	    to the PHP backend).  Deprecate the equivalent -suffix option
+	    provided by the Ocaml backend, but continue to support that for
+	    now.
diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html
index e621397..2890e24 100644
--- a/Doc/Manual/Android.html
+++ b/Doc/Manual/Android.html
@@ -56,7 +56,7 @@
 <pre>
 $ export PATH=$HOME/android/android-sdk-linux_x86/tools:$HOME/android/android-sdk-linux_x86/platform-tools:$HOME/android/android-ndk-r6b:$PATH
 $ mkdir AndroidApps 
-$ cd AnrdoidApps
+$ cd AndroidApps
 </pre>
 </div>
 
diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html
index ce91742..b7e1d63 100644
--- a/Doc/Manual/CPlusPlus11.html
+++ b/Doc/Manual/CPlusPlus11.html
@@ -495,59 +495,59 @@
 <H3><a name="CPlusPlus11_strongly_typed_enumerations"></a>7.2.13 Strongly typed enumerations</H3>
 
 
-<p>SWIG parses the new <tt>enum class</tt> syntax and forward declarator for the enums:</p>
+<p>SWIG supports strongly typed enumerations and parses the new <tt>enum class</tt> syntax and forward declarator for the enums, such as:</p>
 <div class="code"><pre>
 enum class MyEnum : unsigned int;
 </pre></div>
 
-<p>The strongly typed enumerations are treated the same as the ordinary and anonymous enums.
-This is because the required nested class support in SWIG is new and has not yet been incorporated into the wrapping of these strongly typed enum classes.
-This is usually not a problem, however,
-there may be some name clashes. For example, the following code:</p>
+<p>
+Strongly typed enums are often used to avoid name clashes such as the following:
+</p>
 
 <div class="code"><pre>
-class Color {
-  enum class PrintingColors : unsigned int {
-    Cyan, Magenta, Yellow, Black
+struct Color {
+  enum class RainbowColors : unsigned int {
+    Red, Orange, Yellow, Green, Blue, Indigo, Violet
   };
   
-  enum class BasicColors {
-    Red, Green, Blue
+  enum class WarmColors {
+    Yellow, Orange, Red
   };
-  
-  enum class AllColors {
-    // produces warnings because of duplicate names
-    Yellow, Orange, Red, Magenta, Blue, Cyan, Green, Pink, Black, White
-  };
-};
-</pre></div>
 
-<p>A workaround is to write these as a series of separate classes containing anonymous enums:</p>
-
-<div class="code"><pre>
-class PrintingColors {
-  enum : unsigned int {
-    Cyan, Magenta, Yellow, Black
-  };
-};
-
-class BasicColors {
-  enum : unsigned int {
-    Red, Green, Blue
-  };
-};
-
-class AllColors {
-  enum : unsigned int {
-    Yellow, Orange, Red, Magenta, Blue, Cyan, Green, Pink, Black, White
+  // Note normal enum
+  enum PrimeColors {
+    Red=100, Green, Blue
   };
 };
 </pre></div>
 
 <p>
-Expect to see this improved in a future version of SWIG.
+There are various ways that the target languages handle enums, so it is not possible to precisely state how they are handled in this section.
+However, generally, most scripting languages mangle in the strongly typed enumeration's class name,
+but do not use any additional mangling for normal enumerations. For example, in Python, the following code
 </p>
 
+<div class="targetlang"><pre>
+print Color.RainbowColors_Red, Color.WarmColors_Red, Color.Red
+</pre></div>
+
+<p>
+results in
+</p>
+
+<div class="shell"><pre>
+0 2 100
+</pre></div>
+
+<p>
+The strongly typed languages often wrap normal enums into an enum class and so treat normal enums and strongly typed enums the same.
+The equivalent in Java is:
+</p>
+
+<div class="targetlang"><pre>
+System.out.println(Color.RainbowColors.Red.swigValue() + " " + Color.WarmColors.Red.swigValue() + " " + Color.PrimeColors.Red.swigValue());
+</pre></div>
+
 <H3><a name="CPlusPlus11_double_angle_brackets"></a>7.2.14 Double angle brackets</H3>
 
 
@@ -611,6 +611,7 @@
 <div class="code"><pre>
 template&lt; typename T1, typename T2, int &gt;
 class SomeType {
+public:
   T1 a;
   T2 b;
   int c;
diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html
index 7f53423..ba49fa0 100644
--- a/Doc/Manual/CSharp.html
+++ b/Doc/Manual/CSharp.html
@@ -1075,6 +1075,7 @@
   $action
 } catch (std::out_of_range e) {
   SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, e.what());
+  return $null;
 }
 %}
 
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 7cf40b9..51d4eda 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -841,6 +841,7 @@
 <div class="sectiontoc">
 <ul>
 <li><a href="Go.html#Go_overview">Overview</a>
+<li><a href="Go.html#Go_examples">Examples</a>
 <li><a href="Go.html#Go_running_swig">Running SWIG with Go</a>
 <ul>
 <li><a href="Go.html#Go_commandline">Additional Commandline Options</a>
@@ -854,6 +855,7 @@
 <li><a href="Go.html#Go_enumerations">Go Enumerations</a>
 <li><a href="Go.html#Go_classes">Go Classes</a>
 <ul>
+<li><a href="Go.html#Go_class_memory">Go Class Memory Management</a>
 <li><a href="Go.html#Go_class_inheritance">Go Class Inheritance</a>
 </ul>
 <li><a href="Go.html#Go_templates">Go Templates</a>
@@ -861,6 +863,7 @@
 <li><a href="Go.html#Go_primitive_type_mappings">Default Go primitive type mappings</a>
 <li><a href="Go.html#Go_output_arguments">Output arguments</a>
 <li><a href="Go.html#Go_adding_additional_code">Adding additional go code</a>
+<li><a href="Go.html#Go_typemaps">Go typemaps</a>
 </ul>
 </ul>
 </div>
@@ -1046,7 +1049,49 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Lisp.html#Lisp">26 SWIG and Common Lisp</a></h3>
+<h3><a href="Javascript.html#Javascript">26 SWIG and Javascript</a></h3>
+
+<!-- INDEX -->
+<div class="sectiontoc">
+<ul>
+<li><a href="Javascript.html#Javascript_overview">Overview</a>
+<li><a href="Javascript.html#Javascript_preliminaries">Preliminaries</a>
+<ul>
+<li><a href="Javascript.html#Javascript_running_swig">Running SWIG</a>
+<li><a href="Javascript.html#Javascript_running_tests_examples">Running Tests and Examples</a>
+<li><a href="Javascript.html#Javascript_known_issues">Known Issues</a>
+</ul>
+<li><a href="Javascript.html#Javascript_integration">Integration</a>
+<ul>
+<li><a href="Javascript.html#Javascript_node_extensions">Creating node.js Extensions</a>
+<ul>
+<li><a href="Javascript.html#Javascript_troubleshooting">Troubleshooting</a>
+</ul>
+<li><a href="Javascript.html#Javascript_embedded_webkit">Embedded Webkit</a>
+<ul>
+<li><a href="Javascript.html#Javascript_osx">OSX</a>
+<li><a href="Javascript.html#Javascript_gtk">GTK</a>
+</ul>
+<li><a href="Javascript.html#Javascript_applications_webkit">Creating Applications with node-webkit</a>
+</ul>
+<li><a href="Javascript.html#Javascript_nn14">Examples</a>
+<ul>
+<li><a href="Javascript.html#Javascript_simple_example">Simple</a>
+<li><a href="Javascript.html#Javascript_class_example">Class</a>
+</ul>
+<li><a href="Javascript.html#Javascript_implementation">Implementation</a>
+<ul>
+<li><a href="Javascript.html#Javascript_source_code">Source Code</a>
+<li><a href="Javascript.html#Javascript_code_templates">Code Templates</a>
+<li><a href="Javascript.html#Javascript_emitter">Emitter</a>
+<li><a href="Javascript.html#Javascript_emitter_states">Emitter states</a>
+<li><a href="Javascript.html#Javascript_jsc_exceptions">Handling Exceptions in JavascriptCore</a>
+</ul>
+</ul>
+</div>
+<!-- INDEX -->
+
+<h3><a href="Lisp.html#Lisp">27 SWIG and Common Lisp</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1069,7 +1114,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Lua.html#Lua">27 SWIG and Lua</a></h3>
+<h3><a href="Lua.html#Lua">28 SWIG and Lua</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1137,7 +1182,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Modula3.html#Modula3">28 SWIG and Modula-3</a></h3>
+<h3><a href="Modula3.html#Modula3">29 SWIG and Modula-3</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1175,7 +1220,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Mzscheme.html#Mzscheme">29 SWIG and MzScheme/Racket</a></h3>
+<h3><a href="Mzscheme.html#Mzscheme">30 SWIG and MzScheme/Racket</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1187,7 +1232,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Ocaml.html#Ocaml">30 SWIG and Ocaml</a></h3>
+<h3><a href="Ocaml.html#Ocaml">31 SWIG and Ocaml</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1238,7 +1283,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Octave.html#Octave">31 SWIG and Octave</a></h3>
+<h3><a href="Octave.html#Octave">32 SWIG and Octave</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1274,7 +1319,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Perl5.html#Perl5">32 SWIG and Perl5</a></h3>
+<h3><a href="Perl5.html#Perl5">33 SWIG and Perl5</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1350,7 +1395,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Php.html#Php">33 SWIG and PHP</a></h3>
+<h3><a href="Php.html#Php">34 SWIG and PHP</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1373,6 +1418,7 @@
 <li><a href="Php.html#Php_nn2_6_2">Constructors and Destructors</a>
 <li><a href="Php.html#Php_nn2_6_3">Static Member Variables</a>
 <li><a href="Php.html#Php_nn2_6_4">Static Member Functions</a>
+<li><a href="Php.html#Php_nn2_6_5">Specifying Implemented Interfaces</a>
 </ul>
 <li><a href="Php.html#Php_nn2_7">PHP Pragmas, Startup and Shutdown code</a>
 </ul>
@@ -1390,7 +1436,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Pike.html#Pike">34 SWIG and Pike</a></h3>
+<h3><a href="Pike.html#Pike">35 SWIG and Pike</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1414,7 +1460,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Python.html#Python">35 SWIG and Python</a></h3>
+<h3><a href="Python.html#Python">36 SWIG and Python</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1525,12 +1571,13 @@
 <li><a href="Python.html#Python_nn74">Function annotation</a>
 <li><a href="Python.html#Python_nn75">Buffer interface</a>
 <li><a href="Python.html#Python_nn76">Abstract base classes</a>
+<li><a href="Python.html#Python_nn77">Byte string output conversion</a>
 </ul>
 </ul>
 </div>
 <!-- INDEX -->
 
-<h3><a href="R.html#R">36 SWIG and R</a></h3>
+<h3><a href="R.html#R">37 SWIG and R</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1546,7 +1593,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Ruby.html#Ruby">37 SWIG and Ruby</a></h3>
+<h3><a href="Ruby.html#Ruby">38 SWIG and Ruby</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1680,7 +1727,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Tcl.html#Tcl">38 SWIG and Tcl</a></h3>
+<h3><a href="Tcl.html#Tcl">39 SWIG and Tcl</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
@@ -1746,7 +1793,7 @@
 </div>
 <!-- INDEX -->
 
-<h3><a href="Extending.html#Extending">39 Extending SWIG to support new languages</a></h3>
+<h3><a href="Extending.html#Extending">40 Extending SWIG to support new languages</a></h3>
 
 <!-- INDEX -->
 <div class="sectiontoc">
diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html
index a0a89c0..8e26a7e 100644
--- a/Doc/Manual/Customization.html
+++ b/Doc/Manual/Customization.html
@@ -485,12 +485,12 @@
 </tr>
 
 <tr>
-<td>$parentname</td>
+<td>$parentclassname</td>
 <td>The parent class name (if any) for a method.</td>
 </tr>
 
 <tr>
-<td>$parentsymname</td>
+<td>$parentclasssymname</td>
 <td>The target language parent class name (if any) for a method.</td>
 </tr>
 
@@ -547,7 +547,7 @@
 The <tt>exception.i</tt> library file provides support for creating
 language independent exceptions in your interfaces.  To use it, simply
 put an "<tt>%include exception.i</tt>" in your interface file.  This
-creates a function<tt> SWIG_exception()</tt> that can be used to raise
+provides a function <tt>SWIG_exception()</tt> that can be used to raise
 common scripting language exceptions in a portable manner.  For example :</p>
 
 <div class="code"><pre>
@@ -1082,7 +1082,7 @@
 
 <div class="code">
 <pre>
-%feature("except") void hello(int i=0, double d=0.0) { ... }
+%feature("except") hello(int i=0, double d=0.0) { ... }
 void hello(int i=0, double d=0.0);
 </pre>
 </div>
@@ -1105,7 +1105,7 @@
 
 <div class="code">
 <pre>
-%feature("except") void hello(int i, double d) { ... }
+%feature("except") hello(int i, double d) { ... }
 void hello(int i=0, double d=0.0);
 </pre>
 </div>
diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
index 5c209bb..00302d7 100644
--- a/Doc/Manual/Extending.html
+++ b/Doc/Manual/Extending.html
@@ -6,7 +6,7 @@
 </head>
 
 <body bgcolor="#ffffff">
-<H1><a name="Extending"></a>39 Extending SWIG to support new languages</H1>
+<H1><a name="Extending"></a>40 Extending SWIG to support new languages</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -75,7 +75,7 @@
 
 
 
-<H2><a name="Extending_nn2"></a>39.1 Introduction</H2>
+<H2><a name="Extending_nn2"></a>40.1 Introduction</H2>
 
 
 <p>
@@ -91,7 +91,7 @@
 you should probably look at one of SWIG's existing modules.
 </p>
 
-<H2><a name="Extending_nn3"></a>39.2 Prerequisites</H2>
+<H2><a name="Extending_nn3"></a>40.2 Prerequisites</H2>
 
 
 <p>
@@ -121,7 +121,7 @@
 wrapper code are driven by C++ datatypes.
 </p>
 
-<H2><a name="Extending_nn4"></a>39.3 The Big Picture</H2>
+<H2><a name="Extending_nn4"></a>40.3 The Big Picture</H2>
 
 
 <p>
@@ -158,7 +158,7 @@
 based on pattern matching and interact heavily with the underlying type system.
 </p>
 
-<H2><a name="Extending_nn5"></a>39.4 Execution Model</H2>
+<H2><a name="Extending_nn5"></a>40.4 Execution Model</H2>
 
 
 <p>
@@ -203,7 +203,7 @@
 The next few sections briefly describe some of these stages.
 </p>
 
-<H3><a name="Extending_nn6"></a>39.4.1 Preprocessing</H3>
+<H3><a name="Extending_nn6"></a>40.4.1 Preprocessing</H3>
 
 
 <p>
@@ -284,7 +284,7 @@
 construction of the wrapper code.
 </p>
 
-<H3><a name="Extending_nn7"></a>39.4.2 Parsing</H3>
+<H3><a name="Extending_nn7"></a>40.4.2 Parsing</H3>
 
 
 <p>
@@ -385,7 +385,7 @@
 arguments).
 </p>
 
-<H3><a name="Extending_nn8"></a>39.4.3 Parse Trees</H3>
+<H3><a name="Extending_nn8"></a>40.4.3 Parse Trees</H3>
 
 
 <p>
@@ -640,7 +640,7 @@
 </pre>
 </div>
 
-<H3><a name="Extending_nn9"></a>39.4.4 Attribute namespaces</H3>
+<H3><a name="Extending_nn9"></a>40.4.4 Attribute namespaces</H3>
 
 
 <p>
@@ -659,7 +659,7 @@
 <tt>perl:foo</tt>.
 </p>
 
-<H3><a name="Extending_nn10"></a>39.4.5 Symbol Tables</H3>
+<H3><a name="Extending_nn10"></a>40.4.5 Symbol Tables</H3>
 
 
 <p>
@@ -750,7 +750,7 @@
 </pre>
 </div>
 
-<H3><a name="Extending_nn11"></a>39.4.6 The %feature directive</H3>
+<H3><a name="Extending_nn11"></a>40.4.6 The %feature directive</H3>
 
 
 <p>
@@ -806,7 +806,7 @@
 stored without any modifications.
 </p>
 
-<H3><a name="Extending_nn12"></a>39.4.7 Code Generation</H3>
+<H3><a name="Extending_nn12"></a>40.4.7 Code Generation</H3>
 
 
 <p>
@@ -928,7 +928,7 @@
 The role of these functions is described shortly.
 </p>
 
-<H3><a name="Extending_nn13"></a>39.4.8 SWIG and XML</H3>
+<H3><a name="Extending_nn13"></a>40.4.8 SWIG and XML</H3>
 
 
 <p>
@@ -941,7 +941,7 @@
 your mind as a model.
 </p>
 
-<H2><a name="Extending_nn14"></a>39.5 Primitive Data Structures</H2>
+<H2><a name="Extending_nn14"></a>40.5 Primitive Data Structures</H2>
 
 
 <p>
@@ -987,7 +987,7 @@
 </pre>
 </div>
 
-<H3><a name="Extending_nn15"></a>39.5.1 Strings</H3>
+<H3><a name="Extending_nn15"></a>40.5.1 Strings</H3>
 
 
 <p>
@@ -1128,7 +1128,7 @@
 
 </div>
 
-<H3><a name="Extending_nn16"></a>39.5.2 Hashes</H3>
+<H3><a name="Extending_nn16"></a>40.5.2 Hashes</H3>
 
 
 <p>
@@ -1205,7 +1205,7 @@
 </div>
 
 
-<H3><a name="Extending_nn17"></a>39.5.3 Lists</H3>
+<H3><a name="Extending_nn17"></a>40.5.3 Lists</H3>
 
 
 <p>
@@ -1294,7 +1294,7 @@
 and is used to create a String object.
 </div>
 
-<H3><a name="Extending_nn18"></a>39.5.4 Common operations</H3>
+<H3><a name="Extending_nn18"></a>40.5.4 Common operations</H3>
 
 
 The following operations are applicable to all datatypes.
@@ -1349,7 +1349,7 @@
 Gets the line number associated with <tt>x</tt>.
 </div>
 
-<H3><a name="Extending_nn19"></a>39.5.5 Iterating over Lists and Hashes</H3>
+<H3><a name="Extending_nn19"></a>40.5.5 Iterating over Lists and Hashes</H3>
 
 
 To iterate over the elements of a list or a hash table, the following functions are used:
@@ -1394,7 +1394,7 @@
 
 </div>
 
-<H3><a name="Extending_nn20"></a>39.5.6 I/O</H3>
+<H3><a name="Extending_nn20"></a>40.5.6 I/O</H3>
 
 
 Special I/O functions are used for all internal I/O.  These operations
@@ -1528,7 +1528,7 @@
 Similarly, the preprocessor and parser all operate on string-files.
 </p>
 
-<H2><a name="Extending_nn21"></a>39.6 Navigating and manipulating parse trees</H2>
+<H2><a name="Extending_nn21"></a>40.6 Navigating and manipulating parse trees</H2>
 
 
 Parse trees are built as collections of hash tables.   Each node is a hash table in which
@@ -1662,7 +1662,7 @@
 the parent so that sibling nodes are unaffected.
 </div>
 
-<H2><a name="Extending_nn22"></a>39.7 Working with attributes</H2>
+<H2><a name="Extending_nn22"></a>40.7 Working with attributes</H2>
 
 
 <p>
@@ -1779,7 +1779,7 @@
 function.
 </div>
 
-<H2><a name="Extending_nn23"></a>39.8 Type system</H2>
+<H2><a name="Extending_nn23"></a>40.8 Type system</H2>
 
 
 <p>
@@ -1788,7 +1788,7 @@
 type theory is impossible here.   However, let's cover the highlights.
 </p>
 
-<H3><a name="Extending_nn24"></a>39.8.1 String encoding of types</H3>
+<H3><a name="Extending_nn24"></a>40.8.1 String encoding of types</H3>
 
 
 <p>
@@ -1889,7 +1889,7 @@
 string concatenation.
 </p>
 
-<H3><a name="Extending_nn25"></a>39.8.2 Type construction</H3>
+<H3><a name="Extending_nn25"></a>40.8.2 Type construction</H3>
 
 
 <p>
@@ -2058,7 +2058,7 @@
 <tt>ty</tt> is unmodified.
 </div>
 
-<H3><a name="Extending_nn26"></a>39.8.3 Type tests</H3>
+<H3><a name="Extending_nn26"></a>40.8.3 Type tests</H3>
 
 
 <p>
@@ -2145,7 +2145,7 @@
 Checks if <tt>ty</tt> is a templatized type.
 </div>
 
-<H3><a name="Extending_nn27"></a>39.8.4 Typedef and inheritance</H3>
+<H3><a name="Extending_nn27"></a>40.8.4 Typedef and inheritance</H3>
 
 
 <p>
@@ -2247,7 +2247,7 @@
 will consist only of primitive typenames.
 </div>
 
-<H3><a name="Extending_nn28"></a>39.8.5 Lvalues</H3>
+<H3><a name="Extending_nn28"></a>40.8.5 Lvalues</H3>
 
 
 <p>
@@ -2284,7 +2284,7 @@
 </pre>
 </div>
 
-<H3><a name="Extending_nn29"></a>39.8.6 Output functions</H3>
+<H3><a name="Extending_nn29"></a>40.8.6 Output functions</H3>
 
 
 <p>
@@ -2346,7 +2346,7 @@
 that appear in wrappers (e.g., <tt>SWIGTYPE_p_double</tt>).
 </div>
 
-<H2><a name="Extending_nn30"></a>39.9 Parameters</H2>
+<H2><a name="Extending_nn30"></a>40.9 Parameters</H2>
 
 
 <p>
@@ -2445,7 +2445,7 @@
 Returns the number of required (non-optional) arguments in <tt>p</tt>.
 </div>
 
-<H2><a name="Extending_nn31"></a>39.10 Writing a Language Module</H2>
+<H2><a name="Extending_nn31"></a>40.10 Writing a Language Module</H2>
 
 
 <p>
@@ -2460,7 +2460,7 @@
 this to other languages.
 </p>
 
-<H3><a name="Extending_nn32"></a>39.10.1 Execution model</H3>
+<H3><a name="Extending_nn32"></a>40.10.1 Execution model</H3>
 
 
 <p>
@@ -2470,7 +2470,7 @@
 different methods of the <tt>Language</tt> that must be defined by your module.
 </p>
 
-<H3><a name="Extending_starting_out"></a>39.10.2 Starting out</H3>
+<H3><a name="Extending_starting_out"></a>40.10.2 Starting out</H3>
 
 
 <p>
@@ -2578,7 +2578,7 @@
 messages from your new module should appear.
 </p>
 
-<H3><a name="Extending_nn34"></a>39.10.3 Command line options</H3>
+<H3><a name="Extending_nn34"></a>40.10.3 Command line options</H3>
 
 
 <p>
@@ -2637,7 +2637,7 @@
 unrecognized command line option error.
 </p>
 
-<H3><a name="Extending_nn35"></a>39.10.4 Configuration and preprocessing</H3>
+<H3><a name="Extending_nn35"></a>40.10.4 Configuration and preprocessing</H3>
 
 
 <p>
@@ -2686,7 +2686,7 @@
 <tt>python.swg</tt>.
 </p>
 
-<H3><a name="Extending_nn36"></a>39.10.5 Entry point to code generation</H3>
+<H3><a name="Extending_nn36"></a>40.10.5 Entry point to code generation</H3>
 
 
 <p>
@@ -2744,7 +2744,7 @@
 </pre>
 </div>
 
-<H3><a name="Extending_nn37"></a>39.10.6 Module I/O and wrapper skeleton</H3>
+<H3><a name="Extending_nn37"></a>40.10.6 Module I/O and wrapper skeleton</H3>
 
 
 <!-- please report bugs in this section to mgossage -->
@@ -2892,7 +2892,7 @@
 </pre>
 </div>
 
-<H3><a name="Extending_nn38"></a>39.10.7 Low-level code generators</H3>
+<H3><a name="Extending_nn38"></a>40.10.7 Low-level code generators</H3>
 
 
 <!-- please report bugs in this section to mgossage -->
@@ -3046,7 +3046,7 @@
 </p>
 
 
-<H3><a name="Extending_configuration_files"></a>39.10.8 Configuration files</H3>
+<H3><a name="Extending_configuration_files"></a>40.10.8 Configuration files</H3>
 
 
 <!-- please report bugs in this section to ttn -->
@@ -3190,7 +3190,7 @@
 </dl>
 
 
-<H3><a name="Extending_nn40"></a>39.10.9 Runtime support</H3>
+<H3><a name="Extending_nn40"></a>40.10.9 Runtime support</H3>
 
 
 <p>
@@ -3199,7 +3199,7 @@
 the SWIG files that implement those functions.
 </p>
 
-<H3><a name="Extending_nn41"></a>39.10.10 Standard library files</H3>
+<H3><a name="Extending_nn41"></a>40.10.10 Standard library files</H3>
 
 
 <p>
@@ -3218,7 +3218,7 @@
 Please copy these and modify for any new language.
 </p>
 
-<H3><a name="Extending_nn42"></a>39.10.11 User examples</H3>
+<H3><a name="Extending_nn42"></a>40.10.11 User examples</H3>
 
 
 <p>
@@ -3247,7 +3247,7 @@
 files</a>.
 </p>
 
-<H3><a name="Extending_test_suite"></a>39.10.12 Test driven development and the test-suite</H3>
+<H3><a name="Extending_test_suite"></a>40.10.12 Test driven development and the test-suite</H3>
 
 
 <p>
@@ -3306,7 +3306,7 @@
 but error/exception out with an error message on stderr on failure.
 </p>
 
-<H4><a name="Extending_running_test_suite"></a>39.10.12.1 Running the test-suite</H4>
+<H4><a name="Extending_running_test_suite"></a>40.10.12.1 Running the test-suite</H4>
 
 
 <p>
@@ -3498,7 +3498,7 @@
 The test cases used and the way it works is described in <tt>Examples/test-suite/errors/Makefile.in</tt>.
 </p>
 
-<H3><a name="Extending_nn43"></a>39.10.13 Documentation</H3>
+<H3><a name="Extending_nn43"></a>40.10.13 Documentation</H3>
 
 
 <p>
@@ -3530,7 +3530,7 @@
      if available.
 </ul>
 
-<H3><a name="Extending_prerequisites"></a>39.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
+<H3><a name="Extending_prerequisites"></a>40.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
 
 
 <p>
@@ -3587,7 +3587,7 @@
 the existing tests.
 </p>
 
-<H3><a name="Extending_coding_style_guidelines"></a>39.10.15 Coding style guidelines</H3>
+<H3><a name="Extending_coding_style_guidelines"></a>40.10.15 Coding style guidelines</H3>
 
 
 <p>
@@ -3611,7 +3611,7 @@
 should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
 </p>
 
-<H2><a name="Extending_debugging_options"></a>39.11 Debugging Options</H2>
+<H2><a name="Extending_debugging_options"></a>40.11 Debugging Options</H2>
 
 
 <p>
@@ -3638,7 +3638,7 @@
 The complete list of command line options for SWIG are available by running <tt>swig -help</tt>.
 </p>
 
-<H2><a name="Extending_nn46"></a>39.12 Guide to parse tree nodes</H2>
+<H2><a name="Extending_nn46"></a>40.12 Guide to parse tree nodes</H2>
 
 
 <p>
@@ -4046,7 +4046,7 @@
 </pre>
 </div>
 
-<H2><a name="Extending_further_info"></a>39.13 Further Development Information</H2>
+<H2><a name="Extending_further_info"></a>40.13 Further Development Information</H2>
 
 
 <p>
diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html
index 93b87a4..9a6de95 100644
--- a/Doc/Manual/Go.html
+++ b/Doc/Manual/Go.html
@@ -10,6 +10,7 @@
 <div class="sectiontoc">
 <ul>
 <li><a href="#Go_overview">Overview</a>
+<li><a href="#Go_examples">Examples</a>
 <li><a href="#Go_running_swig">Running SWIG with Go</a>
 <ul>
 <li><a href="#Go_commandline">Additional Commandline Options</a>
@@ -23,6 +24,7 @@
 <li><a href="#Go_enumerations">Go Enumerations</a>
 <li><a href="#Go_classes">Go Classes</a>
 <ul>
+<li><a href="#Go_class_memory">Go Class Memory Management</a>
 <li><a href="#Go_class_inheritance">Go Class Inheritance</a>
 </ul>
 <li><a href="#Go_templates">Go Templates</a>
@@ -30,6 +32,7 @@
 <li><a href="#Go_primitive_type_mappings">Default Go primitive type mappings</a>
 <li><a href="#Go_output_arguments">Output arguments</a>
 <li><a href="#Go_adding_additional_code">Adding additional go code</a>
+<li><a href="#Go_typemaps">Go typemaps</a>
 </ul>
 </ul>
 </div>
@@ -67,7 +70,22 @@
 borne in mind when reading the rest of the SWIG documentation.
 </p>
 
-<H2><a name="Go_running_swig"></a>23.2 Running SWIG with Go</H2>
+<H2><a name="Go_examples"></a>23.2 Examples</H2>
+
+
+<p>
+Working examples can be found here:
+</p>
+<ul>
+<li><a href="https://golang.org/misc/swig">Examples from the Go source tree</a>
+<li><a href="https://github.com/swig/swig/tree/master/Examples/go">Examples from the SWIG source tree</a>
+</ul>
+<p>
+The examples in the 2nd link are shipped with the SWIG distribution under the Examples/go directory.
+</p>
+
+
+<H2><a name="Go_running_swig"></a>23.3 Running SWIG with Go</H2>
 
 
 <p>
@@ -76,7 +94,7 @@
 code for gccgo, you should also use the <tt>-gccgo</tt> option.
 </p>
 
-<H3><a name="Go_commandline"></a>23.2.1 Additional Commandline Options</H3>
+<H3><a name="Go_commandline"></a>23.3.1 Additional Commandline Options</H3>
 
 
 <p>
@@ -150,7 +168,7 @@
 
 </table>
 
-<H3><a name="Go_outputs"></a>23.2.2 Go Output Files</H3>
+<H3><a name="Go_outputs"></a>23.3.2 Go Output Files</H3>
 
 
 <p> When generating Go code, SWIG will generate the following
@@ -226,7 +244,7 @@
 % go tool 6l main.6
 </pre></div>
 
-<H2><a name="Go_basic_tour"></a>23.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Go_basic_tour"></a>23.4 A tour of basic C/C++ wrapping</H2>
 
 
 <p>
@@ -236,7 +254,7 @@
 essential aspects of this wrapping.
 </p>
 
-<H3><a name="Go_package"></a>23.3.1 Go Package Name</H3>
+<H3><a name="Go_package"></a>23.4.1 Go Package Name</H3>
 
 
 <p>
@@ -246,7 +264,7 @@
 command line option.
 </p>
 
-<H3><a name="Go_names"></a>23.3.2 Go Names</H3>
+<H3><a name="Go_names"></a>23.4.2 Go Names</H3>
 
 
 <p>
@@ -278,7 +296,7 @@
 named <tt>Delete</tt> followed by that name.
 </p>
 
-<H3><a name="Go_constants"></a>23.3.3 Go Constants</H3>
+<H3><a name="Go_constants"></a>23.4.3 Go Constants</H3>
 
 
 <p>
@@ -286,7 +304,7 @@
 directive become Go constants, declared with a <tt>const</tt>
 declaration.
 
-<H3><a name="Go_enumerations"></a>23.3.4 Go Enumerations</H3>
+<H3><a name="Go_enumerations"></a>23.4.4 Go Enumerations</H3>
 
 
 <p>
@@ -296,7 +314,7 @@
 code should avoid modifying those variables.
 </p>
 
-<H3><a name="Go_classes"></a>23.3.5 Go Classes</H3>
+<H3><a name="Go_classes"></a>23.4.5 Go Classes</H3>
 
 
 <p>
@@ -374,7 +392,43 @@
 for this by calling the Swigcptr() method.
 </p>
 
-<H4><a name="Go_class_inheritance"></a>23.3.5.1 Go Class Inheritance</H4>
+<H4><a name="Go_class_memory"></a>23.4.5.1 Go Class Memory Management</H4>
+
+
+<p>
+Calling <tt>NewClassName</tt> for some C++ class <tt>ClassName</tt>
+will allocate memory using the C++ memory allocator.  This memory will
+not be automatically freed by Go's garbage collector as the object ownership is
+not tracked.  When you are done with the C++ object you must free it manually
+using <tt>DeleteClassName</tt>.
+</p>
+
+<p>
+A common technique is to store the C++ object into a Go object, and
+use the Go function <tt>runtime.SetFinalizer</tt> to free the C++ object when
+the Go object is freed. It is strongly recommended to read the
+<a href="https://golang.org/pkg/runtime/#SetFinalizer">runtime.SetFinalizer</a>
+documentation before using this technique to understand its limitations.
+For example, if the SWIG package is imported as "wrap":
+</p>
+<div class="code">
+<pre>
+type GoClassName struct {
+	w wrap.ClassName
+}
+
+func NewGoClassName() *GoClassName {
+	r := &amp;GoClassName{wrap.NewClassName()}
+	runtime.SetFinalizer(r,
+		func(r *GoClassName) {
+			wrap.DeleteClassName(r.w)
+		})
+	return r
+}
+</pre>
+</div>
+
+<H4><a name="Go_class_inheritance"></a>23.4.5.2 Go Class Inheritance</H4>
 
 
 <p>
@@ -386,7 +440,7 @@
 be checked dynamically.
 </p>
 
-<H3><a name="Go_templates"></a>23.3.6 Go Templates</H3>
+<H3><a name="Go_templates"></a>23.4.6 Go Templates</H3>
 
 
 <p>
@@ -394,7 +448,7 @@
 wrappers for a particular template instantation.  To do this, use
 the <tt>%template</tt> directive.
 
-<H3><a name="Go_director_classes"></a>23.3.7 Go Director Classes</H3>
+<H3><a name="Go_director_classes"></a>23.4.7 Go Director Classes</H3>
 
 
 <p>
@@ -437,7 +491,7 @@
 itself, and those methods may be defined either in Go or in C++.
 </p>
 
-<H3><a name="Go_primitive_type_mappings"></a>23.3.8 Default Go primitive type mappings</H3>
+<H3><a name="Go_primitive_type_mappings"></a>23.4.8 Default Go primitive type mappings</H3>
 
 
 <p>
@@ -544,7 +598,7 @@
 into Go types.
 </p>
 
-<H3><a name="Go_output_arguments"></a>23.3.9 Output arguments</H3>
+<H3><a name="Go_output_arguments"></a>23.4.9 Output arguments</H3>
 
 
 <p>Because of limitations in the way output arguments are processed in swig,
@@ -597,7 +651,7 @@
 </pre>
 </div>
 
-<H3><a name="Go_adding_additional_code"></a>23.3.10 Adding additional go code</H3>
+<H3><a name="Go_adding_additional_code"></a>23.4.10 Adding additional go code</H3>
 
 
 <p>Often the APIs generated by swig are not very natural in go, especially if
@@ -692,5 +746,144 @@
 </pre>
 </div>
 
+<H3><a name="Go_typemaps"></a>23.4.11 Go typemaps</H3>
+
+
+<p>
+You can use the <tt>%typemap</tt> directive to modify SWIG's default
+wrapping behavior for specific C/C++ types.  You need to be familiar
+with the material in the general
+"<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter.  That chapter
+explains how to define a typemap.  This section describes some
+specific typemaps used for Go.
+</p>
+
+<p>
+In general type conversion code may be written either in C/C++ or in
+Go.  The choice to make normally depends on where memory should be
+allocated.  To allocate memory controlled by the Go garbage collector,
+write Go code.  To allocate memory in the C/C++ heap, write C code.
+</p>
+
+<table BORDER summary="Go Typemaps">
+<tr>
+<td><b>Typemap</b></td>
+<td><b>Description</b></td>
+</tr>
+
+<tr>
+<td>gotype</td>
+<td>
+The Go type to use for a C++ type.  This type will appear in the
+generated Go wrapper function.  If this is not defined SWIG will use a
+default as <a href="#Go_primitive_type_mappings">described above</a>.
+</td>
+</tr>
+
+<tr>
+<td>imtype</td>
+<td>
+An intermediate Go type used by the "goin", "goout", "godirectorin",
+and "godirectorout" typemaps.  If this typemap is not defined for a
+C/C++ type, the gotype typemape will be used.  This is useful when
+gotype is best converted to C/C++ using Go code.
+</td>
+</tr>
+
+<tr>
+<td>goin</td>
+<td>
+Go code to convert from gotype to imtype when calling a C/C++
+function.  SWIG will then internally convert imtype to a C/C++ type
+and pass it down.  If this is not defined no conversion is done.
+</td>
+</tr>
+
+<tr>
+<td>in</td>
+<td>
+C/C++ code to convert the internally generated C/C++ type, based on
+imtype, into the C/C++ type that a function call expects.  If this is
+not defined the value will simply be cast to the desired type.
+</td>
+</tr>
+
+<tr>
+<td>out</td>
+<td>
+C/C++ code to convert the C/C++ type that a function call returns into
+the internally generated C/C++ type, based on imtype, that will be
+returned to Go.  If this is not defined the value will simply be cast
+to the desired type.
+</td>
+</tr>
+
+<tr>
+<td>goout</td>
+<td>
+Go code to convert a value returned from a C/C++ function from imtype
+to gotype.  If this is not defined no conversion is done.
+</td>
+</tr>
+
+<tr>
+<td>argout</td>
+<td>
+C/C++ code to adjust an argument value when returning from a function.
+This is called after the real C/C++ function has run.  This uses the
+internally generated C/C++ type, based on imtype.  This is only useful
+for a pointer type of some sort.  If this is not defined nothing will
+be done.
+</td>
+</tr>
+
+<tr>
+<td>goargout</td>
+<td>
+Go code to adjust an argument value when returning from a function.
+This is called after the real C/C++ function has run.  The value will
+be in imtype.  This is only useful for a pointer type of some sort.
+If this is not defined nothing will be done.
+</td>
+</tr>
+
+<tr>
+<td>directorin</td>
+<td>
+C/C++ code to convert the C/C++ type used to call a director method
+into the internally generated C/C++ type, based on imtype, that will
+be passed to Go.  If this is not defined the value will simply be cast
+to the desired type.
+</td>
+</tr>
+
+<tr>
+<td>godirectorin</td>
+<td>
+Go code to convert a value used to call a director method from imtype
+to gotype.  If this is not defined no conversion is done.
+</td>
+</tr>
+
+<tr>
+<td>godirectorout</td>
+<td>
+Go code to convert a value returned from a director method from gotype
+to imtype.  If this is not defined no conversion is done.
+</td>
+</tr>
+
+<tr>
+<td>directorout</td>
+<td>
+C/C++ code to convert a value returned from a director method from the
+internally generated C/C++ type, based on imtype, into the type that
+the method should return  If this is not defined the value will simply
+be cast to the desired type.
+</td>
+</tr>
+
+</table>
+
 </body>
 </html>
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index fb8e5d6..3a4f7ee 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -358,7 +358,7 @@
 <p>
 The name of the shared library output file is important. 
 If the name of your SWIG module is "<tt>example</tt>", the name of the corresponding shared library file should be "<tt>libexample.so</tt>" (or equivalent depending on your machine, see <a href="#Java_dynamic_linking_problems">Dynamic linking problems</a> for more information). 
-The name of the module is specified using the <tt>%module</tt> directive or<tt> -module</tt> command line option.</p>
+The name of the module is specified using the <tt>%module</tt> directive or <tt>-module</tt> command line option.</p>
 
 <H3><a name="Java_using_module"></a>25.2.5 Using your module</H3>
 
@@ -2441,7 +2441,7 @@
 member variables. These functions call the native methods in the intermediary JNI class. 
 The advantage of having this extra layer is the type safety that the proxy class functions offer. 
 It adds static type checking which leads to fewer surprises at runtime. 
-For example, you can see that if you attempt to use the <tt> spam() </tt> 
+For example, you can see that if you attempt to use the <tt>spam()</tt>
 function it will only compile when the parameters passed are an <tt>int</tt> and a <tt>Foo</tt>. 
 From a user's point of view, it makes the class work as if it were a Java class:
 </p>
@@ -4173,8 +4173,8 @@
 
 <p>
 If no declaration name is given to <tt>%exception</tt>, it is applied to all wrapper functions.
-The <tt> $action </tt> is a SWIG special variable and is replaced by the C/C++ function call being wrapped.
-The <tt> return $null; </tt> handles all native method return types, namely those that have a void return and those that do not. 
+The <tt>$action</tt> is a SWIG special variable and is replaced by the C/C++ function call being wrapped.
+The <tt>return $null;</tt> handles all native method return types, namely those that have a void return and those that do not.
 This is useful for typemaps that will be used in native method returning all return types. 
 See the section on
 <a href="#Java_special_variables">Java special variables</a> for further explanation.
@@ -5490,6 +5490,15 @@
 <td>Use for mapping NULL terminated arrays of C strings to Java String arrays</td>
 </tr>
 
+<tr>
+<td>unsigned char *</td>
+<td>NIOBUFFER</td>
+<td>various.i</td>
+<td>input<br> output</td>
+<td>java.nio.Buffer</td>
+<td>Use for mapping directly allocated buffers to c/c++. useful with directors and long lived memory objects</td>
+</tr>
+
 </table>
 
 <H3><a name="Java_typemap_attributes"></a>25.9.6 Java typemap attributes</H3>
@@ -5570,7 +5579,7 @@
 </p>
 
 <p>
-<b><tt>$null </tt></b><br>
+<b><tt>$null</tt></b><br>
 Used in input typemaps to return early from JNI functions that have either void or a non-void return type. Example:
 </p>
 
diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html
index e589d9d..cae1990 100644
--- a/Doc/Manual/Javascript.html
+++ b/Doc/Manual/Javascript.html
@@ -6,21 +6,67 @@
 </head>
 <body>
 
-<H1>SWIG and Javascript</H1>
+<H1><a name="Javascript"></a>26 SWIG and Javascript</H1>
+<!-- INDEX -->
+<div class="sectiontoc">
+<ul>
+<li><a href="#Javascript_overview">Overview</a>
+<li><a href="#Javascript_preliminaries">Preliminaries</a>
+<ul>
+<li><a href="#Javascript_running_swig">Running SWIG</a>
+<li><a href="#Javascript_running_tests_examples">Running Tests and Examples</a>
+<li><a href="#Javascript_known_issues">Known Issues</a>
+</ul>
+<li><a href="#Javascript_integration">Integration</a>
+<ul>
+<li><a href="#Javascript_node_extensions">Creating node.js Extensions</a>
+<ul>
+<li><a href="#Javascript_troubleshooting">Troubleshooting</a>
+</ul>
+<li><a href="#Javascript_embedded_webkit">Embedded Webkit</a>
+<ul>
+<li><a href="#Javascript_osx">OSX</a>
+<li><a href="#Javascript_gtk">GTK</a>
+</ul>
+<li><a href="#Javascript_applications_webkit">Creating Applications with node-webkit</a>
+</ul>
+<li><a href="#Javascript_nn14">Examples</a>
+<ul>
+<li><a href="#Javascript_simple_example">Simple</a>
+<li><a href="#Javascript_class_example">Class</a>
+</ul>
+<li><a href="#Javascript_implementation">Implementation</a>
+<ul>
+<li><a href="#Javascript_source_code">Source Code</a>
+<li><a href="#Javascript_code_templates">Code Templates</a>
+<li><a href="#Javascript_emitter">Emitter</a>
+<li><a href="#Javascript_emitter_states">Emitter states</a>
+<li><a href="#Javascript_jsc_exceptions">Handling Exceptions in JavascriptCore</a>
+</ul>
+</ul>
+</div>
+<!-- INDEX -->
+
+
+
 <p>This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.</p>
 
-<H2>Overview</H2>
+<H2><a name="Javascript_overview"></a>26.1 Overview</H2>
+
+
 <p>Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development.
 Javascript has gone beyond being a browser-based scripting language and with <a href="http://nodejs.org">node.js</a>, it is also used as a backend development language.</p>
 <p>Native Javascript extensions can be used for applications that embed a web-browser view or that embed a Javascript engine (such as <em>node.js</em>). Extending a general purpose web-browser is not possible as this would be a severe security issue.</p>
-<p>SWIG Javascript currently supports <strong>JavascriptCore</strong>, the Javascript engine used by <code>Safari/Webkit</code>, and <strong>v8</strong>, which is used by <code>Chromium</code> and <code>node.js</code>.</p>
+<p>SWIG Javascript currently supports <strong>JavascriptCore</strong>, the Javascript engine used by <code>Safari/Webkit</code>, and <a href="https://developers.google.com/v8"><strong>v8</strong></a>, which is used by <code>Chromium</code> and <code>node.js</code>.</p>
 <p><a href="http://www.webkit.org/">WebKit</a> is a modern browser implementation available as open-source which can be embedded into an application.
 With <a href="https://github.com/rogerwang/node-webkit">node-webkit</a> there is a platform which uses Google's <code>Chromium</code> as Web-Browser widget and <code>node.js</code> for javascript extensions.
 </p>
 
-<H2>Preliminaries</H2>
+<H2><a name="Javascript_preliminaries"></a>26.2 Preliminaries</H2>
 
-<H3>Running SWIG</H3>
+
+<H3><a name="Javascript_running_swig"></a>26.2.1 Running SWIG</H3>
+
 
 <p>Suppose that you defined a SWIG module such as the following:</p>
 <div class="code">
@@ -42,6 +88,12 @@
 <pre>
 $ swig -c++ -javascript -jsc example.i</pre>
 </div>
+<p>The V8 code that SWIG generates should work with most versions from 3.11.10 up to 3.29.14 and later.</p>
+<p>Specify the V8 version when running SWIG (e.g. 3.25.30)</p>
+<div class="shell">
+<pre>
+$ swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i</pre>
+</div>
 <p>This creates a C/C++ source file <code>example_wrap.c</code> or <code>example_wrap.cxx</code>. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.</p>
 <p>The name of the wrapper file is derived from the name of the input file. For example, if the input file is <code>example.i</code>, the name of the wrapper file is <code>example_wrap.c</code>. To change this, you can use the -o option. The wrapped module will export one function which must be called to register the module with the Javascript interpreter. For example, if your module is named <code>example</code> the corresponding initializer for JavascriptCore would be</p>
 <div class="code">
@@ -51,13 +103,15 @@
 <p>and for v8:</p>
 <div class="code">
 <pre>
-void example_initialize(v8::Handle<v8::Object> exports)</pre>
+void example_initialize(v8::Handle&lt;v8::Object&gt; exports)</pre>
 </div>
 <p>
-<p><b>Note</b>: be aware that <code>v8</code> has a C++ API, and thus, the generated modules must be compiled as C++.</p>
+<b>Note</b>: be aware that <code>v8</code> has a C++ API, and thus, the generated modules must be compiled as C++.
 </p>
 
-<H3>Running Tests and Examples</H3>
+<H3><a name="Javascript_running_tests_examples"></a>26.2.2 Running Tests and Examples</H3>
+
+
 <p>The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.</p>
 <p>The default interpreter is <code>node.js</code> as it is available on all platforms and convenient to use.</p>
 <p>Running the examples with JavascriptCore requires <code>libjavascriptcoregtk-1.0</code> to be installed, e.g., under Ubuntu with</p>
@@ -81,36 +135,37 @@
 <pre>
 $ make check-javascript-test-suite ENGINE=jsc</pre>
 </div>
-<p>Tests should run without any problems, i.e., have been tried out, on the following platforms/interpreters:</p>
-<div class="code">
+<p>You can specify a specific <code>V8</code> version for running the examples and tests</p>
+<div class="shell">
 <pre>
-- Ubuntu Precise 12.04 64bit
-    - JavascriptCore (Webkit 1.8.3)
-    - Node.js (0.10.26)
-    - v8 (3.7.12)
-- Ubuntu Saucy 13.10 64bit
-    - JavascriptCore (Webkit 1.10.2)
-    - Node.js
-    - v8 (3.14.5)
-- Mac OSX Mountain Lion 10.8
-    - JavascriptCore (built-in)
-    - Node.js
-- Windows 7 64bit (VS 2010)
-    - Node.js</pre>
+$ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8</pre>
 </div>
-<p>
 
-<H3>Future work</H3>
-<p>The Javascript module is not yet as mature as other modules and some things are still missing. As it makes use of SWIG's Unified Typemap Library (UTL), many typemaps are inherited. We could work on that if requested:</p>
+<H3><a name="Javascript_known_issues"></a>26.2.3 Known Issues</H3>
+
+
+<p>At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.</p>
+
 <ul>
-<li><p>More typemaps: compared to other modules there are only a few typemaps implemented. For instance a lot of the <code>std_*.i</code> typemaps are missing, such as <code>std_iostream</code>, for instance.</p></li>
-<li><p>Director support: this would allow to extend a C++ abstract base class in Javascript. A pragmatic intermediate step for the most important usecase would be to support Javascript callbacks as arguments.</p></li>
+    <li><p>Default optional arguments do not work for all targeted interpreters</p></li>
+    <li><p>Multiple output arguments do not work for JSC</p></li>
+    <li><p>C89 incompatibily: the JSC generator might still generate C89 violating code</p></li>
+    <li><p><code>long long</code> is not supported</p></li>
+    <li><p><code>%native</code> is not supported</p></li>
+    <li><p>Javascript callbacks are not supported</p></li>
+    <li><p><code>instanceOf</code> does not work under JSC</p></li>
 </ul>
 
-<H2>Integration</H2>
+<p>The primary development environment has been Linux (Ubuntu 12.04). Windows and OSX have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.</p>
+
+<H2><a name="Javascript_integration"></a>26.3 Integration</H2>
+
+
 <p>This chapter gives a short introduction how to use a native Javascript extension: as a <code>node.js</code> module, and as an extension for an embedded Webkit.</p>
 
-<H3>Creating <code>node.js</code> Extensions</H3>
+<H3><a name="Javascript_node_extensions"></a>26.3.1 Creating node.js Extensions</H3>
+
+
 <p>To install <code>node.js</code> you can download an installer from their <a href="https://launchpad.net/~chris-lea/+archive/node.js">web-site</a> for OSX and Windows. For Linux you can either build the source yourself and run <code>sudo checkinstall</code> or keep to the (probably stone-age) packaged version. For Ubuntu there is a <a href="https://launchpad.net/~chris-lea/+archive/node.js/">PPA</a> available.</p>
 <div class="shell">
 <pre>
@@ -140,7 +195,7 @@
 <p>First create the wrapper using SWIG:</p>
 <div class="shell">
 <pre>
-$ swig -javascript -node -c++ example.cxx</pre>
+$ swig -javascript -node -c++ example.i</pre>
 </div>
 <p>Then run <code>node-gyp</code></p>
 <div class="shell">
@@ -154,7 +209,9 @@
 </div>
 <p>A more detailed explanation is given in the <a href="#Javascript_examples">Examples</a> section.</p>
 
-<H4>Troubleshooting</H4>
+<H4><a name="Javascript_troubleshooting"></a>26.3.1.1 Troubleshooting</H4>
+
+
 <ul>
 <li><em>'module' object has no attribute 'script_main'</em></li>
 </ul>
@@ -164,23 +221,35 @@
 $ sudo apt-get remove gyp</pre>
 </div>
 
-<H3>Embedded Webkit</H3>
+<H3><a name="Javascript_embedded_webkit"></a>26.3.2 Embedded Webkit</H3>
+
+
 <p>Webkit is pre-installed on OSX and available as a library for GTK.</p>
 
-<H4>OSX</H4>
+<H4><a name="Javascript_osx"></a>26.3.2.1 OSX</H4>
+
+
 <p>There is general information about programming with WebKit on <a href="https://developer.apple.com/library/mac/documentation/cocoa/conceptual/DisplayWebContent/DisplayWebContent.html">Apple Developer Documentation</a>. Details about <code>Cocoa</code> programming are not covered here.</p>
 <p>An integration of a native extension 'example' would look like this:</p>
 <div class="code">
 <pre>
 #import "appDelegate.h"
 
-extern bool example_initialize(JSGlobalContextRef context);
+extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports);
 
 
 @implementation ExampleAppDelegate
 
 @synthesize webView;
 
+- (void)addGlobalObject:(JSContextRef) context:(NSString *)objectName:(JSObjectRef) theObject {
+  JSObjectRef global = JSContextGetGlobalObject(context);
+  JSStringRef objectJSName = JSStringCreateWithCFString( (CFStringRef) objectName )
+  if ( objectJSName != NULL ) {
+    JSObjectSetProperty(context, global, objectJSName, theObject, kJSPropertyAttributeReadOnly, NULL);
+    JSStringRelease( objectJSName );
+  }
+}
 
 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
 
@@ -191,7 +260,11 @@
   WebFrame *webframe = [webView mainFrame];
   JSGlobalContextRef context = [webframe globalContext];
 
-  example_initialize(context);
+  JSObjectRef example;
+  example_initialize(context, &amp;example);
+  [self addGlobalObject:context:@"example":example]
+
+  JSObjectSetProperty(context, global, JSStringRef propertyName, example, JSPropertyAttributes attributes, NULL);
 
   [ [webView mainFrame] loadRequest:
     [NSURLRequest requestWithURL: [NSURL URLWithString:url] ]
@@ -201,20 +274,22 @@
 @end</pre>
 </div>
 
-<H4>GTK</H4>
+<H4><a name="Javascript_gtk"></a>26.3.2.2 GTK</H4>
+
+
 <p>There is general information about programming GTK at <a href="https://developer.gnome.org/gtk2/">GTK documentation</a> and in the <a href="https://developer.gnome.org/gtk-tutorial">GTK tutorial</a>, and for Webkit there is a <a href="http://webkitgtk.org/reference/webkitgtk/stable/index.html">Webkit GTK+ API Reference</a>.</p>
 <p>An integration of a native extension 'example' would look like this:</p>
 <div class="code">
 <pre>
-#include <gtk/gtk.h>
-#include <webkit/webkit.h>
+#include &lt;gtk/gtk.h&gt;
+#include &lt;webkit/webkit.h&gt;
 
 extern bool example_initialize(JSGlobalContextRef context);
 
 int main(int argc, char* argv[])
 {
     // Initialize GTK+
-    gtk_init(&argc, &argv);
+    gtk_init(&amp;argc, &amp;argv);
 
     ...
 
@@ -222,7 +297,13 @@
     WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
     WebFrame *webframe = webkit_web_view_get_main_frame(webView);
     JSGlobalContextRef context = webkit_web_frame_get_global_context(webFrame);
-    example_initialize(context);
+    JSObjectRef global = JSContextGetGlobalObject(context);
+
+    JSObjectRef exampleModule;
+    example_initialize(context, &amp;exampleModule);
+    JSStringRef jsName = JSStringCreateWithUTF8CString("example");
+    JSObjectSetProperty(context, global, jsName, exampleModule, kJSPropertyAttributeReadOnly, NULL);
+    JSStringRelease(jsName);
 
     ...
 
@@ -238,8 +319,9 @@
 }</pre>
 </div>
 
-<H3>Creating Applications with <code>node-webkit</code></H3>
-<p>
+<H3><a name="Javascript_applications_webkit"></a>26.3.3 Creating Applications with node-webkit</H3>
+
+
 <p>To get started with <code>node-webkit</code> there is a very informative set of <a href="https://github.com/rogerwang/node-webkit/wiki">wiki pages</a>.</p>
 <p>Similar to <code>node.js</code>, <code>node-webkit</code> is started from command line within a <code>node.js</code> project directory.
 Native extensions are created in the very same way as for <code>node.js</code>, except that a customized <code>gyp</code> derivate has to be used: <a href="https://github.com/rogerwang/nw-gyp">nw-gyp</a>.
@@ -262,7 +344,7 @@
 
 <p>
 The configuration file essentially conforms to <code>node.js</code> syntax.
-It has some extras to configure <code>node-webkit</code>. See the <a href="">Manifest</a> specification for more details.
+It has some extras to configure <code>node-webkit</code>. See the <a href="https://github.com/rogerwang/node-webkit/wiki/Manifest-format">Manifest</a> specification for more details.
 </p>
 
 <p>
@@ -271,8 +353,8 @@
 <div class="code">
 <pre>
 {
-  "name": "example"
-  "main": "app.html"
+  "name": "example",
+  "main": "app.html",
   "window": {
     "show": true,
     "width": 800,
@@ -328,10 +410,14 @@
 };</pre>
 </div>
 
-<H2><a name="Javascript_examples">Examples</H2>
+<H2><a name="Javascript_nn14"></a>26.4 Examples</H2>
+
+
 <p>Some basic examples are shown here in more detail.</p>
 
-<H3>Simple</H3>
+<H3><a name="Javascript_simple_example"></a>26.4.1 Simple</H3>
+
+
 <p>The common example <code>simple</code> looks like this:</p>
 <div class="code">
 <pre>
@@ -371,16 +457,17 @@
 var y = 105;
 var g = example.gcd(x,y);
 
-// Accessing the globak variable
+// Accessing the global variable
 var f = example.Foo;
 example.Foo = 3.1415926;</pre>
 </div>
 <p>First the module <code>example</code> is loaded from the previously built extension. Global methods and variables are available in the scope of the module.</p>
-<p>
-<p><b>Note</b>: ECMAScript 5, the currently implemented Javascript standard, does not have modules. <code>node.js</code> and other implementations provide this mechanism defined by the <a href="http://wiki.commonjs.org/wiki/CommonJS">CommonJS</a> group. For browsers this is provided by <a href="http://browserify.org">Browserify</a>, for instance.</p>
-</p>
 
-<H3>Class</H3>
+<p><b>Note</b>: ECMAScript 5, the currently implemented Javascript standard, does not have modules. <code>node.js</code> and other implementations provide this mechanism defined by the <a href="http://wiki.commonjs.org/wiki/CommonJS">CommonJS</a> group. For browsers this is provided by <a href="http://browserify.org">Browserify</a>, for instance.</p>
+
+<H3><a name="Javascript_class_example"></a>26.4.2 Class</H3>
+
+
 <p>The common example <code>class</code> defines three classes, <code>Shape</code>, <code>Circle</code>, and <code>Square</code>:</p>
 <div class="code">
 <pre>
@@ -391,7 +478,7 @@
   }
   virtual ~Shape() {
     nshapes--;
-  };
+  }
   double  x, y;
   void    move(double dx, double dy);
   virtual double area(void) = 0;
@@ -403,7 +490,7 @@
 private:
   double radius;
 public:
-  Circle(double r) : radius(r) { };
+  Circle(double r) : radius(r) { }
   virtual double area(void);
   virtual double perimeter(void);
 };
@@ -412,7 +499,7 @@
 private:
   double width;
 public:
-  Square(double w) : width(w) { };
+  Square(double w) : width(w) { }
   virtual double area(void);
   virtual double perimeter(void);
 };</pre>
@@ -455,47 +542,47 @@
 <div class="shell">
 <pre>
 $ node -i
-> var example = require("./build/Release/example");
+&amp; var example = require("./build/Release/example");
 undefined
-> var Shape = example.Shape;
+&amp; var Shape = example.Shape;
 undefined
-> var Circle = example.Circle;
+&amp; var Circle = example.Circle;
 undefined
-> var Square = example.Square;
+&amp; var Square = example.Square;
 undefined
-> var c = new Circle(10);
+&amp; var c = new Circle(10);
 undefined
-> var s = new Square(10);
+&amp; var s = new Square(10);
 undefined
-> Shape.nshapes;
+&amp; Shape.nshapes;
 2
-> c.x = 20;
+&amp; c.x = 20;
 20
-> c.y = 30;
+&amp; c.y = 30;
 30
-> s.x = -10;
+&amp; s.x = -10;
 -10
-> s.y = 5;
+&amp; s.y = 5;
 5
-> c.area();
+&amp; c.area();
 314.1592653589793
-> c.perimeter();
+&amp; c.perimeter();
 62.83185307179586
-> s.area();
+&amp; s.area();
 100
-> s.perimeter();
+&amp; s.perimeter();
 40
-> c.move(40, 40)
+&amp; c.move(40, 40)
 undefined
-> c.x
+&amp; c.x
 60
-> c.y
+&amp; c.y
 70
-> new Shape()
+&amp; new Shape()
 Error: Class Shape can not be instantiated
 at repl:1:2
 at REPLServer.self.eval (repl.js:110:21)
-at Interface.<anonymous> (repl.js:239:12)
+at Interface.&lt;anonymous&gt; (repl.js:239:12)
 at Interface.EventEmitter.emit (events.js:95:17)
 at Interface._onLine (readline.js:202:10)
 at Interface._line (readline.js:531:8)
@@ -505,13 +592,17 @@
 at emitKey (readline.js:1095:12)</pre>
 </div>
 <p>
-<p><b>Note</b>: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property <code>prototype</code> of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain">Inheritance and the prototype chain</a>, for instance.</p>
+<b>Note</b>: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property <code>prototype</code> of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Inheritance_and_the_prototype_chain">Inheritance and the prototype chain</a>, for instance.
 </p>
 
-<H2>Implementation</H2>
+<H2><a name="Javascript_implementation"></a>26.5 Implementation</H2>
+
+
 <p>The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.</p>
 
-<H3>Source Code</H3>
+<H3><a name="Javascript_source_code"></a>26.5.1 Source Code</H3>
+
+
 <p>The Javascript module is implemented in <code>Source/Modules/javascript.cxx</code>. It dispatches the code generation to a <code>JSEmitter</code> instance, <code>V8Emitter</code> or <code>JSCEmitter</code>. Additionally there are some helpers: <code>Template</code>, for templated code generation, and <code>JSEmitterState</code>, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:</p>
 <div class="code">
 <pre>
@@ -610,7 +701,9 @@
 ...</pre>
 </div>
 
-<H3>Code Templates</H3>
+<H3><a name="Javascript_code_templates"></a>26.5.2 Code Templates</H3>
+
+
 <p>All generated code is created on the basis of code templates. The templates for <em>JavascriptCore</em> can be found in <code>Lib/javascript/jsc/javascriptcode.swg</code>, for <em>v8</em> in <code>Lib/javascript/v8/javascriptcode.swg</code>.</p>
 <p>To track the originating code template for generated code you can run</p>
 <div class="shell">
@@ -647,7 +740,9 @@
 </div>
 <p><code>Template</code> creates a copy of that string and <code>Template::replace</code> uses Swig's <code>Replaceall</code> to replace variables in the template. <code>Template::trim</code> can be used to eliminate leading and trailing whitespaces. <code>Template::print</code> is used to write the final template string to a Swig <code>DOH</code> (based on <code>Printv</code>). All methods allow chaining.</p>
 
-<H3>Emitter</H3>
+<H3><a name="Javascript_emitter"></a>26.5.3 Emitter</H3>
+
+
 <p>The Javascript module delegates code generation to a <code>JSEmitter</code> instance. The following extract shows the essential interface:</p>
 <div class="code">
 <pre>
@@ -681,7 +776,7 @@
    */
   virtual int exitClass(Node *) {
     return SWIG_OK;
-  };
+  }
 
   /**
    * Invoked at the beginning of the variableHandler.
@@ -693,7 +788,7 @@
    */
   virtual int exitVariable(Node *) {
     return SWIG_OK;
-  };
+  }
 
   /**
    * Invoked at the beginning of the functionHandler.
@@ -705,7 +800,7 @@
    */
   virtual int exitFunction(Node *) {
     return SWIG_OK;
-  };
+  }
 
   /**
    * Invoked by functionWrapper callback after call to Language::functionWrapper.
@@ -730,7 +825,7 @@
    */
   Template getTemplate(const String *name);
 
-  State &getState();
+  State &amp;getState();
 
   ...
 
@@ -740,12 +835,12 @@
 <div class="code">
 <pre>
 int JAVASCRIPT::top(Node *n) {
-  emitter->initialize(n);
+  emitter-&gt;initialize(n);
 
   Language::top(n);
 
-  emitter->dump(n);
-  emitter->close();
+  emitter-&gt;dump(n);
+  emitter-&gt;close();
 
   return SWIG_OK;
 }</pre>
@@ -755,16 +850,18 @@
 <pre>
 int JAVASCRIPT::classHandler(Node *n) {
 
-  emitter->enterClass(n);
+  emitter-&gt;enterClass(n);
   Language::classHandler(n);
-  emitter->exitClass(n);
+  emitter-&gt;exitClass(n);
 
   return SWIG_OK;
 }</pre>
 </div>
 <p>In <code>enterClass</code> the emitter stores state information that is necessary when processing class members. In <code>exitClass</code> the wrapper code for the whole class is generated.</p>
 
-<H3>Emitter states</H3>
+<H3><a name="Javascript_emitter_states"></a>26.5.4 Emitter states</H3>
+
+
 <p>For storing information during the AST traversal the emitter provides a <code>JSEmitterState</code> with different slots to store data representing the scopes global, class, function, and variable.</p>
 <div class="code">
 <pre>
@@ -804,5 +901,87 @@
 state.clazz(NAME, Getattr(n, "sym:name"));</pre>
 </div>
 <p>State information can be retrieved using <code>state.clazz(NAME)</code> or with <code>Getattr</code> on <code>state.clazz()</code> which actually returns a <code>Hash</code> instance.</p>
+
+
+<H3><a name="Javascript_jsc_exceptions"></a>26.5.5 Handling Exceptions in JavascriptCore</H3>
+
+
+<p>Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.</p>
+<div class="code">
+<pre>
+void script_exception_to_string(JSContextRef js_context,JSValueRef exception_value_ref,char* return_error_string, int return_error_string_max_length)
+{
+  JSObjectRef exception_object;
+  JSValueRef value_ref;
+  JSStringRef jsstring_property_name = NULL;
+  JSValueRef temporary_exception = NULL;
+  JSStringRef js_return_string = NULL;
+  size_t bytes_needed;
+  char* c_result_string = NULL;
+  exception_object = JSValueToObject(js_context, exception_value_ref, NULL);
+
+  /* source url */
+  strcpy(return_error_string,&quot;[&quot;);
+  jsstring_property_name = JSStringCreateWithUTF8CString(&quot;sourceURL&quot;);
+  value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &amp;temporary_exception);
+  JSStringRelease(jsstring_property_name);
+  js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
+  bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
+  c_result_string = (char*)calloc(bytes_needed, sizeof(char));
+  JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
+  JSStringRelease(js_return_string);
+  strncat(return_error_string, c_result_string, return_error_string_max_length-1);
+  free(c_result_string);
+
+  strncat(return_error_string, &quot;:&quot;, return_error_string_max_length-1);
+
+  /* line number */
+
+  jsstring_property_name = JSStringCreateWithUTF8CString(&quot;line&quot;);
+  value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &amp;temporary_exception);
+  JSStringRelease(jsstring_property_name);
+  js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
+  bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
+  c_result_string = (char*)calloc(bytes_needed, sizeof(char));
+  JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
+  JSStringRelease(js_return_string);
+  strncat(return_error_string, c_result_string, return_error_string_max_length-1);
+  free(c_result_string);
+
+  strncat(return_error_string, &quot;]&quot;, return_error_string_max_length-1);
+
+  /* error message */
+
+  jsstring_property_name = JSStringCreateWithUTF8CString(&quot;message&quot;);
+  value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &amp;temporary_exception);
+  JSStringRelease(jsstring_property_name);
+  if(NULL == value_ref)
+  {
+    strncat(return_error_string, &quot;Unknown Error&quot;, return_error_string_max_length-1);
+  }
+  else
+  {
+    js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
+    bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
+    c_result_string = (char*)calloc(bytes_needed, sizeof(char));
+    JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
+    JSStringRelease(js_return_string);
+    strncat(return_error_string, c_result_string, return_error_string_max_length-1);
+    free(c_result_string);
+  }
+}</pre>
+</div>
+
+<p>It would be used in the following way:</p>
+<div class="code">
+<pre>
+if(js_exception)
+{
+  char return_error_string[256];
+  script_exception_to_string(js_context, js_exception, return_error_string, 256);
+  printf("Compile error is %s", return_error_string);
+}</pre>
+</div>
+
 </body>
 </html>
diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html
index 7ea9139..0b8d478 100644
--- a/Doc/Manual/Lisp.html
+++ b/Doc/Manual/Lisp.html
@@ -6,7 +6,7 @@
 </head>
 
 <body bgcolor="#ffffff">
-<H1><a name="Lisp"></a>26 SWIG and Common Lisp</H1>
+<H1><a name="Lisp"></a>27 SWIG and Common Lisp</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -41,7 +41,7 @@
       Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI
       foreign function interfaces.  
 </p>
-<H2><a name="Lisp_nn2"></a>26.1 Allegro Common Lisp</H2>
+<H2><a name="Lisp_nn2"></a>27.1 Allegro Common Lisp</H2>
 
 
 <p>
@@ -50,7 +50,7 @@
   <a href="Allegrocl.html#Allegrocl">here</a>
 </p>
 
-<H2><a name="Lisp_nn3"></a>26.2 Common Foreign Function Interface(CFFI)</H2>
+<H2><a name="Lisp_nn3"></a>27.2 Common Foreign Function Interface(CFFI)</H2>
 
 
 <p>
@@ -77,7 +77,7 @@
       files and the various things which you can do with them.
 </p>
 
-<H3><a name="Lisp_nn4"></a>26.2.1 Additional Commandline Options </H3>
+<H3><a name="Lisp_nn4"></a>27.2.1 Additional Commandline Options </H3>
 
 
 <p>
@@ -118,7 +118,7 @@
 
 </table>
 
-<H3><a name="Lisp_nn5"></a>26.2.2 Generating CFFI bindings</H3>
+<H3><a name="Lisp_nn5"></a>27.2.2 Generating CFFI bindings</H3>
 
 
 As we mentioned earlier the ideal way to use SWIG is to use interface
@@ -392,7 +392,7 @@
 
 </pre></div>
 
-<H3><a name="Lisp_nn6"></a>26.2.3 Generating CFFI bindings for C++ code</H3>
+<H3><a name="Lisp_nn6"></a>27.2.3 Generating CFFI bindings for C++ code</H3>
 
 
 <p>This feature to SWIG (for CFFI) is very new and still far from
@@ -568,7 +568,7 @@
       module feel free to contact us on the SWIG mailing list, and
       also please add a "[CFFI]" tag in the subject line.
 
-<H3><a name="Lisp_nn7"></a>26.2.4 Inserting user code into generated files</H3>
+<H3><a name="Lisp_nn7"></a>27.2.4 Inserting user code into generated files</H3>
 
 
 <p>
@@ -608,7 +608,7 @@
 </p>
 
 
-<H2><a name="Lisp_nn8"></a>26.3 CLISP</H2>
+<H2><a name="Lisp_nn8"></a>27.3 CLISP</H2>
 
 
 <p>
@@ -638,7 +638,7 @@
     interface file for the CLISP module. The CLISP module tries to
     produce code which is both human readable and easily modifyable.
 </p>
-<H3><a name="Lisp_nn9"></a>26.3.1 Additional Commandline Options </H3>
+<H3><a name="Lisp_nn9"></a>27.3.1 Additional Commandline Options </H3>
 
 
 <p>
@@ -671,7 +671,7 @@
 
 </table>
 
-<H3><a name="Lisp_nn10"></a>26.3.2 Details on CLISP bindings</H3>
+<H3><a name="Lisp_nn10"></a>27.3.2 Details on CLISP bindings</H3>
 
 
 <p>
@@ -795,7 +795,7 @@
 
 </pre></div>
 
-<H2><a name="Lisp_nn11"></a>26.4 UFFI </H2>
+<H2><a name="Lisp_nn11"></a>27.4 UFFI </H2>
 
 
 </body>
diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html
index c67e088..61f19be 100644
--- a/Doc/Manual/Lua.html
+++ b/Doc/Manual/Lua.html
@@ -6,7 +6,7 @@
 </head>
 
 <body bgcolor="#ffffff">
-<H1><a name="Lua"></a>27 SWIG and Lua</H1>
+<H1><a name="Lua"></a>28 SWIG and Lua</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -82,14 +82,14 @@
 eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: <a href="http://www.eluaproject.net">http://www.eluaproject.net</a>
 </p>
 
-<H2><a name="Lua_nn2"></a>27.1 Preliminaries</H2>
+<H2><a name="Lua_nn2"></a>28.1 Preliminaries</H2>
 
 
 <p>
 The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.
 </p>
 
-<H2><a name="Lua_nn3"></a>27.2 Running SWIG</H2>
+<H2><a name="Lua_nn3"></a>28.2 Running SWIG</H2>
 
 
 <p>
@@ -137,7 +137,7 @@
 The <tt>-elua</tt> option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the <tt>-eluac</tt> option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with <tt>-eluac</tt>. To access any value from eLua, one must directly call the wrapper function associated with that value.
 </p>
 
-<H3><a name="Lua_commandline"></a>27.2.1 Additional command line options</H3>
+<H3><a name="Lua_commandline"></a>28.2.1 Additional command line options</H3>
 
 
 <p>
@@ -178,7 +178,7 @@
 </tr>
 </table>
 
-<H3><a name="Lua_nn4"></a>27.2.2 Compiling and Linking and Interpreter</H3>
+<H3><a name="Lua_nn4"></a>28.2.2 Compiling and Linking and Interpreter</H3>
 
 
 <p>
@@ -249,7 +249,7 @@
 More information on building and configuring eLua can be found here: <a href="http://www.eluaproject.net/doc/v0.8/en_building.html">http://www.eluaproject.net/doc/v0.8/en_building.html</a>
 </p>
 
-<H3><a name="Lua_nn5"></a>27.2.3 Compiling a dynamic module</H3>
+<H3><a name="Lua_nn5"></a>28.2.3 Compiling a dynamic module</H3>
 
 
 <p>
@@ -317,7 +317,7 @@
 
 
 
-<H3><a name="Lua_nn6"></a>27.2.4 Using your module</H3>
+<H3><a name="Lua_nn6"></a>28.2.4 Using your module</H3>
 
 
 <p>
@@ -335,19 +335,19 @@
 &gt;
 </pre></div>
 
-<H2><a name="Lua_nn7"></a>27.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Lua_nn7"></a>28.3 A tour of basic C/C++ wrapping</H2>
 
 
 <p>
 By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.
 </p>
-<H3><a name="Lua_nn8"></a>27.3.1 Modules</H3>
+<H3><a name="Lua_nn8"></a>28.3.1 Modules</H3>
 
 
 <p>
 The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.
 </p>
-<H3><a name="Lua_nn9"></a>27.3.2 Functions</H3>
+<H3><a name="Lua_nn9"></a>28.3.2 Functions</H3>
 
 
 <p>
@@ -388,7 +388,7 @@
 24
 </pre></div>
 
-<H3><a name="Lua_nn10"></a>27.3.3 Global variables</H3>
+<H3><a name="Lua_nn10"></a>28.3.3 Global variables</H3>
 
 
 <p>
@@ -476,7 +476,7 @@
 In general, functions of the form <tt>"variable_get()"</tt> and <tt>"variable_set()"</tt> are automatically generated by SWIG for use with <tt>-eluac</tt>.
 </p>
 
-<H3><a name="Lua_nn11"></a>27.3.4 Constants and enums</H3>
+<H3><a name="Lua_nn11"></a>28.3.4 Constants and enums</H3>
 
 
 <p>
@@ -511,7 +511,7 @@
 Hello World
 </pre></div>
 
-<H4><a name="Lua_nn13"></a>27.3.4.1 Constants/enums and classes/structures</H4>
+<H4><a name="Lua_nn13"></a>28.3.4.1 Constants/enums and classes/structures</H4>
 
 
 <p>
@@ -567,7 +567,7 @@
 It is worth mentioning, that <tt>example.Test.TEST1</tt> and <tt>example.Test_TEST1</tt> are different entities and changing one does not change the other. 
 Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.
 </p>
-<H3><a name="Lua_nn12"></a>27.3.5 Pointers</H3>
+<H3><a name="Lua_nn12"></a>28.3.5 Pointers</H3>
 
 
 <p>
@@ -605,7 +605,7 @@
 nil
 </pre></div>
 
-<H3><a name="Lua_structures"></a>27.3.6 Structures</H3>
+<H3><a name="Lua_structures"></a>28.3.6 Structures</H3>
 
 
 <p>
@@ -709,7 +709,7 @@
 In general, functions of the form <tt>"new_struct()"</tt>, <tt>"struct_member_get()"</tt>, <tt>"struct_member_set()"</tt> and <tt>"free_struct()"</tt> are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the <tt>-elua</tt> option)
 </p>
 
-<H3><a name="Lua_nn14"></a>27.3.7 C++ classes</H3>
+<H3><a name="Lua_nn14"></a>28.3.7 C++ classes</H3>
 
 
 <p>
@@ -784,7 +784,7 @@
 However, if the <tt>-no-old-metatable-bindings</tt> option is used, then the backward compatible names are not generated in addition to ordinary ones.
 </p>
 
-<H3><a name="Lua_nn15"></a>27.3.8 C++ inheritance</H3>
+<H3><a name="Lua_nn15"></a>28.3.8 C++ inheritance</H3>
 
 
 <p>
@@ -809,7 +809,7 @@
 <p>
 It is safe to use multiple inheritance with SWIG.
 </p>
-<H3><a name="Lua_nn16"></a>27.3.9 Pointers, references, values, and arrays</H3>
+<H3><a name="Lua_nn16"></a>28.3.9 Pointers, references, values, and arrays</H3>
 
 
 <p>
@@ -840,7 +840,7 @@
 <p>
 then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.
 </p>
-<H3><a name="Lua_nn17"></a>27.3.10 C++ overloaded functions</H3>
+<H3><a name="Lua_nn17"></a>28.3.10 C++ overloaded functions</H3>
 
 
 <p>
@@ -926,7 +926,7 @@
 <p>
 Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.
 </p>
-<H3><a name="Lua_nn18"></a>27.3.11 C++ operators</H3>
+<H3><a name="Lua_nn18"></a>28.3.11 C++ operators</H3>
 
 
 <p>
@@ -993,7 +993,7 @@
 <li><tt>__unm__</tt> unary minus
 <li><tt>__call__</tt> operator<tt>()</tt> (often used in functor classes)
 <li><tt>__pow__</tt> the exponential fn (no C++ equivalent, Lua uses <tt>^</tt>)
-<li><tt>__concat__</tt> the concatenation operator (SWIG maps C++'s <tt>~</tt> to Lua's <tt>..</tt>)
+<li><tt>__concat__</tt> the concatenation operator (Lua's <tt>..</tt>)
 <li><tt>__eq__</tt> operator<tt>==</tt>
 <li><tt>__lt__</tt> operator<tt>&lt;</tt>
 <li><tt>__le__</tt> operator<tt>&lt;=</tt>
@@ -1058,9 +1058,9 @@
 <li><tt>__setitem__</tt>
 <li><tt>__tostring</tt> used internally by Lua for tostring() function. __str__ is mapped to this function
 </ul>
-<p>No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. <tt>__tostring</tt> is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG</p>
+<p>No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. <tt>__tostring</tt> is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.
 </p>
-<H3><a name="Lua_nn19"></a>27.3.12 Class extension with %extend</H3>
+<H3><a name="Lua_nn19"></a>28.3.12 Class extension with %extend</H3>
 
 
 <p>
@@ -1116,7 +1116,7 @@
 Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).
 </p>
 
-<H3><a name="Lua_nn20"></a>27.3.13 Using %newobject to release memory</H3>
+<H3><a name="Lua_nn20"></a>28.3.13 Using %newobject to release memory</H3>
 
 
 <p> If you have a function that allocates memory like this,</p>
@@ -1140,7 +1140,7 @@
 </div>
 <p> This will release the allocated memory.</p>
 
-<H3><a name="Lua_nn21"></a>27.3.14 C++ templates</H3>
+<H3><a name="Lua_nn21"></a>28.3.14 C++ templates</H3>
 
 
 <p>
@@ -1175,7 +1175,7 @@
 <p>
 Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.
 </p>
-<H3><a name="Lua_nn22"></a>27.3.15 C++ Smart Pointers</H3>
+<H3><a name="Lua_nn22"></a>28.3.15 C++ Smart Pointers</H3>
 
 
 <p>
@@ -1227,7 +1227,7 @@
 &gt; f = p:__deref__()     -- Returns underlying Foo *
 </pre></div>
 
-<H3><a name="Lua_nn23"></a>27.3.16 C++ Exceptions</H3>
+<H3><a name="Lua_nn23"></a>28.3.16 C++ Exceptions</H3>
 
 
 <p>
@@ -1370,7 +1370,7 @@
 add exception specification to functions or globally (respectively).
 </p>
 
-<H3><a name="Lua_namespaces"></a>27.3.17 Namespaces </H3>
+<H3><a name="Lua_namespaces"></a>28.3.17 Namespaces </H3>
 
 
 <p>
@@ -1421,7 +1421,7 @@
 19
 &gt;
 </pre></div>
-<H4><a name="Lua_nn27"></a>27.3.17.1 Compatibility Note </H4>
+<H4><a name="Lua_nn27"></a>28.3.17.1 Compatibility Note </H4>
 
 
 <p>
@@ -1437,7 +1437,7 @@
 </pre></div>
 
 
-<H4><a name="Lua_nn29"></a>27.3.17.2 Names </H4>
+<H4><a name="Lua_nn29"></a>28.3.17.2 Names </H4>
 
 
 <p> If SWIG is launched without <tt>-no-old-metatable-bindings</tt> option, then it enters backward-compatible mode. While in this mode, it tries
@@ -1481,7 +1481,7 @@
 &gt;
 </pre></div>
 
-<H4><a name="Lua_nn30"></a>27.3.17.3 Inheritance </H4>
+<H4><a name="Lua_nn30"></a>28.3.17.3 Inheritance </H4>
 
 
 <p> The internal organization of inheritance has changed. 
@@ -1522,12 +1522,12 @@
 &gt;
 </pre></div>
 
-<H2><a name="Lua_nn24"></a>27.4 Typemaps</H2>
+<H2><a name="Lua_nn24"></a>28.4 Typemaps</H2>
 
 
 <p>This section explains what typemaps are and how to use them. The default wrapping behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrapping. This section will be explaining how to use typemaps to best effect</p>
 
-<H3><a name="Lua_nn25"></a>27.4.1 What is a typemap?</H3>
+<H3><a name="Lua_nn25"></a>28.4.1 What is a typemap?</H3>
 
 
 <p>A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:</p>
@@ -1555,7 +1555,7 @@
 720
 </pre></div>
 
-<H3><a name="Lua_nn26"></a>27.4.2 Using typemaps</H3>
+<H3><a name="Lua_nn26"></a>28.4.2 Using typemaps</H3>
 
 
 <p>There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.</p>
@@ -1608,7 +1608,7 @@
 
 <p>Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a <tt>const int&amp;</tt>  as an input parameter (since that it obviously input).</p>
 
-<H3><a name="Lua_typemap_arrays"></a>27.4.3 Typemaps and arrays</H3>
+<H3><a name="Lua_typemap_arrays"></a>28.4.3 Typemaps and arrays</H3>
 
 
 <p>Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor
@@ -1672,7 +1672,7 @@
 
 <p>Note: SWIG also can support arrays of pointers in a similar manner.</p>
 
-<H3><a name="Lua_typemaps_ptr_ptr_functions"></a>27.4.4 Typemaps and pointer-pointer functions</H3>
+<H3><a name="Lua_typemaps_ptr_ptr_functions"></a>28.4.4 Typemaps and pointer-pointer functions</H3>
 
 
 <p>Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:</p>
@@ -1706,7 +1706,7 @@
 ptr=nil -- the iMath* will be GC'ed as normal
 </pre></div>
 
-<H2><a name="Lua_writing_typemaps"></a>27.5 Writing typemaps</H2>
+<H2><a name="Lua_writing_typemaps"></a>28.5 Writing typemaps</H2>
 
 
 <p>This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the <tt>%typemap</tt> directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter.</p>
@@ -1715,7 +1715,7 @@
 
 <p>Before proceeding, you should read the previous section on using typemaps, and look at the existing typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you an idea to base your work on).</p>
 
-<H3><a name="Lua_typemaps_write"></a>27.5.1 Typemaps you can write</H3>
+<H3><a name="Lua_typemaps_write"></a>28.5.1 Typemaps you can write</H3>
 
 
 <p>There are many different types of typemap that can be written, the full list can be found in the "<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter. However the following are the most commonly used ones.</p>
@@ -1728,7 +1728,7 @@
 (the syntax for the typecheck is different from the typemap, see typemaps for details).</li>
 </ul>
 
-<H3><a name="Lua_nn31"></a>27.5.2 SWIG's Lua-C API</H3>
+<H3><a name="Lua_nn31"></a>28.5.2 SWIG's Lua-C API</H3>
 
 
 <p>This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.</p>
@@ -1777,7 +1777,7 @@
 <div class="indent">
 Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.</div>
 
-<H2><a name="Lua_nn32"></a>27.6 Customization of your Bindings</H2>
+<H2><a name="Lua_nn32"></a>28.6 Customization of your Bindings</H2>
 
 
 <p>
@@ -1786,7 +1786,7 @@
 
 
 
-<H3><a name="Lua_nn33"></a>27.6.1 Writing your own custom wrappers</H3>
+<H3><a name="Lua_nn33"></a>28.6.1 Writing your own custom wrappers</H3>
 
 
 <p>
@@ -1805,7 +1805,7 @@
 The <tt>%native</tt> directive in the above example, tells SWIG that there is a function <tt>int native_function(lua_State*L);</tt> which is to be added into the module under the name '<tt>my_func</tt>'. SWIG will not add any wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.
 </p>
 
-<H3><a name="Lua_nn34"></a>27.6.2 Adding additional Lua code</H3>
+<H3><a name="Lua_nn34"></a>28.6.2 Adding additional Lua code</H3>
 
 
 <p>
@@ -1843,7 +1843,7 @@
 See Examples/lua/arrays for an example of this code.
 </p>
 
-<H2><a name="Lua_nn35"></a>27.7 Details on the Lua binding</H2>
+<H2><a name="Lua_nn35"></a>28.7 Details on the Lua binding</H2>
 
 
 <p>
@@ -1854,7 +1854,7 @@
  </i>
 </p>
 
-<H3><a name="Lua_nn36"></a>27.7.1 Binding global data into the module.</H3>
+<H3><a name="Lua_nn36"></a>28.7.1 Binding global data into the module.</H3>
 
 
 <p>
@@ -1914,7 +1914,7 @@
 <p>
 That way when you call '<tt>a=example.Foo</tt>', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code '<tt>example.Foo=10</tt>', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
 </p>
-<H3><a name="Lua_nn37"></a>27.7.2 Userdata and Metatables</H3>
+<H3><a name="Lua_nn37"></a>28.7.2 Userdata and Metatables</H3>
 
 
 <p>
@@ -1994,7 +1994,7 @@
 <p>
 Note: Operator overloads are basically done in the same way, by adding functions such as '__add' &amp; '__call' to the class' metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
 </p>
-<H3><a name="Lua_nn38"></a>27.7.3 Memory management</H3>
+<H3><a name="Lua_nn38"></a>28.7.3 Memory management</H3>
 
 
 <p>
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index 42149ba..5112afa 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -75,4 +75,3 @@
 	@echo Note linkchecker versions prior to 6.1 do not work properly wrt anchors
 	@echo -----------------------------------------------------------------------
 	linkchecker --config=./linkchecker.config index.html
-
diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html
index 0bf9f29..ffbf613 100644
--- a/Doc/Manual/Modula3.html
+++ b/Doc/Manual/Modula3.html
@@ -5,7 +5,7 @@
 <link rel="stylesheet" type="text/css" href="style.css">
 </head>
 <body bgcolor="#FFFFFF">
-<H1><a name="Modula3"></a>28 SWIG and Modula-3</H1>
+<H1><a name="Modula3"></a>29 SWIG and Modula-3</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -54,7 +54,7 @@
 <a href="Typemaps.html#Typemaps">typemaps</a>.
 </p>
 
-<H2><a name="Modula3_modula3_overview"></a>28.1 Overview</H2>
+<H2><a name="Modula3_modula3_overview"></a>29.1 Overview</H2>
 
 
 <p>
@@ -84,7 +84,7 @@
 </li>
 </ol>
 
-<H3><a name="Modula3_motivation"></a>28.1.1 Motivation</H3>
+<H3><a name="Modula3_motivation"></a>29.1.1 Motivation</H3>
 
 
 <p>
@@ -131,10 +131,10 @@
 a C/C++ project.
 </p>
 
-<H2><a name="Modula3_conception"></a>28.2 Conception</H2>
+<H2><a name="Modula3_conception"></a>29.2 Conception</H2>
 
 
-<H3><a name="Modula3_cinterface"></a>28.2.1 Interfaces to C libraries</H3>
+<H3><a name="Modula3_cinterface"></a>29.2.1 Interfaces to C libraries</H3>
 
 
 <p>
@@ -283,7 +283,7 @@
 </p>
 
 
-<H3><a name="Modula3_cppinterface"></a>28.2.2 Interfaces to C++ libraries</H3>
+<H3><a name="Modula3_cppinterface"></a>29.2.2 Interfaces to C++ libraries</H3>
 
 
 <p>
@@ -384,10 +384,10 @@
 so I'm not sure if this is possible or sensible, yet.
 </p>
 
-<H2><a name="Modula3_preliminaries"></a>28.3 Preliminaries</H2>
+<H2><a name="Modula3_preliminaries"></a>29.3 Preliminaries</H2>
 
 
-<H3><a name="Modula3_compilers"></a>28.3.1 Compilers</H3>
+<H3><a name="Modula3_compilers"></a>29.3.1 Compilers</H3>
 
 
 <p>
@@ -400,7 +400,7 @@
 </p>
 
 
-<H3><a name="Modula3_commandline"></a>28.3.2 Additional Commandline Options</H3>
+<H3><a name="Modula3_commandline"></a>29.3.2 Additional Commandline Options</H3>
 
 
 <p>
@@ -477,10 +477,10 @@
 </tr>
 </table>
 
-<H2><a name="Modula3_typemaps"></a>28.4 Modula-3 typemaps</H2>
+<H2><a name="Modula3_typemaps"></a>29.4 Modula-3 typemaps</H2>
 
 
-<H3><a name="Modula3_inoutparam"></a>28.4.1 Inputs and outputs</H3>
+<H3><a name="Modula3_inoutparam"></a>29.4.1 Inputs and outputs</H3>
 
 
 <p>
@@ -694,7 +694,7 @@
 </table>
 
 
-<H3><a name="Modula3_ordinals"></a>28.4.2 Subranges, Enumerations, Sets</H3>
+<H3><a name="Modula3_ordinals"></a>29.4.2 Subranges, Enumerations, Sets</H3>
 
 
 <p>
@@ -746,7 +746,7 @@
 </p>
 
 
-<H3><a name="Modula3_class"></a>28.4.3 Objects</H3>
+<H3><a name="Modula3_class"></a>29.4.3 Objects</H3>
 
 
 <p>
@@ -759,7 +759,7 @@
 </p>
 
 
-<H3><a name="Modula3_imports"></a>28.4.4 Imports</H3>
+<H3><a name="Modula3_imports"></a>29.4.4 Imports</H3>
 
 
 <p>
@@ -792,7 +792,7 @@
 </pre></div>
 
 
-<H3><a name="Modula3_exceptions"></a>28.4.5 Exceptions</H3>
+<H3><a name="Modula3_exceptions"></a>29.4.5 Exceptions</H3>
 
 
 <p>
@@ -816,7 +816,7 @@
 <tt>%typemap("m3wrapinconv:throws") blah * %{OSError.E%}</tt>.
 </p>
 
-<H3><a name="Modula3_typemap_example"></a>28.4.6 Example</H3>
+<H3><a name="Modula3_typemap_example"></a>29.4.6 Example</H3>
 
 
 <p>
@@ -863,10 +863,10 @@
 </pre></div>
 
 
-<H2><a name="Modula3_hints"></a>28.5 More hints to the generator</H2>
+<H2><a name="Modula3_hints"></a>29.5 More hints to the generator</H2>
 
 
-<H3><a name="Modula3_features"></a>28.5.1 Features</H3>
+<H3><a name="Modula3_features"></a>29.5.1 Features</H3>
 
 
 <table border summary="Modula-3 features">
@@ -903,7 +903,7 @@
 </tr>
 </table>
 
-<H3><a name="Modula3_pragmas"></a>28.5.2 Pragmas</H3>
+<H3><a name="Modula3_pragmas"></a>29.5.2 Pragmas</H3>
 
 
 <table border summary="Modula-3 pragmas">
@@ -926,7 +926,7 @@
 </tr>
 </table>
 
-<H2><a name="Modula3_remarks"></a>28.6 Remarks</H2>
+<H2><a name="Modula3_remarks"></a>29.6 Remarks</H2>
 
 
 <ul>
diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html
index 40173d7..fadda5f 100644
--- a/Doc/Manual/Mzscheme.html
+++ b/Doc/Manual/Mzscheme.html
@@ -8,7 +8,7 @@
 
 <body bgcolor="#ffffff">
 
-<H1><a name="Mzscheme"></a>29 SWIG and MzScheme/Racket</H1>
+<H1><a name="Mzscheme"></a>30 SWIG and MzScheme/Racket</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -24,7 +24,7 @@
 <p>
 This section contains information on SWIG's support of Racket, formally known as MzScheme.
 
-<H2><a name="MzScheme_nn2"></a>29.1 Creating native structures</H2>
+<H2><a name="MzScheme_nn2"></a>30.1 Creating native structures</H2>
 
 
 <p>
@@ -65,7 +65,7 @@
 </pre>
 </div>
 
-<H2><a name="MzScheme_simple"></a>29.2 Simple example</H2>
+<H2><a name="MzScheme_simple"></a>30.2 Simple example</H2>
 
 
 <p>
@@ -166,7 +166,7 @@
   <li> The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it.
 </ul>
 
-<H2><a name="MzScheme_external_docs"></a>29.3 External documentation</H2>
+<H2><a name="MzScheme_external_docs"></a>30.3 External documentation</H2>
 
 
 <p>
diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html
index ec46d6e..aa6679f 100644
--- a/Doc/Manual/Ocaml.html
+++ b/Doc/Manual/Ocaml.html
@@ -6,7 +6,7 @@
 </head>
   <body bgcolor="#ffffff">
           <a name="n1"></a>         
-<H1><a name="Ocaml"></a>30 SWIG and Ocaml</H1>
+<H1><a name="Ocaml"></a>31 SWIG and Ocaml</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -80,7 +80,7 @@
 <a href="http://www.ocaml.org/">The Ocaml Website</a>.
 </p>
 
-<H2><a name="Ocaml_nn2"></a>30.1 Preliminaries</H2>
+<H2><a name="Ocaml_nn2"></a>31.1 Preliminaries</H2>
 
 
 <p>
@@ -99,7 +99,7 @@
 will be loaded dynamically.  This has only been tested on Linux so far.
 </p>
 
-<H3><a name="Ocaml_nn3"></a>30.1.1 Running SWIG</H3>
+<H3><a name="Ocaml_nn3"></a>31.1.1 Running SWIG</H3>
 
 
 <p>
@@ -122,7 +122,7 @@
 the resulting .ml and .mli files as well, and do the final link with -custom
 (not needed for native link). </p>
                
-<H3><a name="Ocaml_nn4"></a>30.1.2 Compiling the code</H3>
+<H3><a name="Ocaml_nn4"></a>31.1.2 Compiling the code</H3>
 
 
 <p>
@@ -158,7 +158,7 @@
   </pre>
 </div>
 
-<H3><a name="Ocaml_nn5"></a>30.1.3 The camlp4 module</H3>
+<H3><a name="Ocaml_nn5"></a>31.1.3 The camlp4 module</H3>
 
 
 <p>
@@ -234,7 +234,7 @@
 </td></tr>
 </table>
 
-<H3><a name="Ocaml_nn6"></a>30.1.4 Using your module</H3>
+<H3><a name="Ocaml_nn6"></a>31.1.4 Using your module</H3>
 
 
 <p>
@@ -248,7 +248,7 @@
       option is not needed when you build native code.
 </p>
 
-<H3><a name="Ocaml_nn7"></a>30.1.5 Compilation problems and compiling with C++</H3>
+<H3><a name="Ocaml_nn7"></a>31.1.5 Compilation problems and compiling with C++</H3>
 
 
 <p>
@@ -259,7 +259,7 @@
 Most code meant to be compiled as C++ will not have problems.
 </p>
 
-<H2><a name="Ocaml_nn8"></a>30.2 The low-level Ocaml/C interface</H2>
+<H2><a name="Ocaml_nn8"></a>31.2 The low-level Ocaml/C interface</H2>
 
 
 <p>
@@ -360,7 +360,7 @@
     signature for a function that uses value in this way.
     </p>
 
-<H3><a name="Ocaml_nn9"></a>30.2.1 The generated module</H3>
+<H3><a name="Ocaml_nn9"></a>31.2.1 The generated module</H3>
 
 
 <p>
@@ -394,7 +394,7 @@
 </td></tr>
 </table>
                
-<H3><a name="Ocaml_nn10"></a>30.2.2 Enums</H3>
+<H3><a name="Ocaml_nn10"></a>31.2.2 Enums</H3>
 
 
 <p>
@@ -457,7 +457,7 @@
 </pre>
   </div>
 
-<H4><a name="Ocaml_nn11"></a>30.2.2.1 Enum typing in Ocaml</H4>
+<H4><a name="Ocaml_nn11"></a>31.2.2.1 Enum typing in Ocaml</H4>
 
 
 <p>
@@ -470,10 +470,10 @@
 values using the swig_val function before sharing them with another module.
 </p>
 
-<H3><a name="Ocaml_nn12"></a>30.2.3 Arrays</H3>
+<H3><a name="Ocaml_nn12"></a>31.2.3 Arrays</H3>
 
 
-<H4><a name="Ocaml_nn13"></a>30.2.3.1 Simple types of bounded arrays</H4>
+<H4><a name="Ocaml_nn13"></a>31.2.3.1 Simple types of bounded arrays</H4>
 
 
 <p>
@@ -494,7 +494,7 @@
 for arrays whose bounds are completely specified.
 </p>
 
-<H4><a name="Ocaml_nn14"></a>30.2.3.2 Complex and unbounded arrays</H4>
+<H4><a name="Ocaml_nn14"></a>31.2.3.2 Complex and unbounded arrays</H4>
 
 
 <p>
@@ -507,7 +507,7 @@
 so you have to specify it for yourself in the form of a typemap.
 </p>
 
-<H4><a name="Ocaml_nn15"></a>30.2.3.3 Using an object</H4>
+<H4><a name="Ocaml_nn15"></a>31.2.3.3 Using an object</H4>
 
 
 <p>
@@ -521,7 +521,7 @@
 such as using a required sentinel, etc.
 </p>
 
-<H4><a name="Ocaml_nn16"></a>30.2.3.4 Example typemap for a function taking float * and int</H4>
+<H4><a name="Ocaml_nn16"></a>31.2.3.4 Example typemap for a function taking float * and int</H4>
 
 
 <p>
@@ -572,7 +572,7 @@
 </pre></td></tr></table>
 
 
-<H3><a name="Ocaml_nn17"></a>30.2.4 C++ Classes</H3>
+<H3><a name="Ocaml_nn17"></a>31.2.4 C++ Classes</H3>
 
 
 <p>
@@ -615,7 +615,7 @@
 returned value for the same object.
 </p>
 
-<H4><a name="Ocaml_nn18"></a>30.2.4.1 STL vector and string Example</H4>
+<H4><a name="Ocaml_nn18"></a>31.2.4.1 STL vector and string Example</H4>
 
 
 <p>
@@ -695,7 +695,7 @@
 # 
 </pre></div>
 
-<H4><a name="Ocaml_nn19"></a>30.2.4.2 C++ Class Example</H4>
+<H4><a name="Ocaml_nn19"></a>31.2.4.2 C++ Class Example</H4>
 
 
 <p>
@@ -725,7 +725,7 @@
 };
 </pre></td></tr></table>
 
-<H4><a name="Ocaml_nn20"></a>30.2.4.3 Compiling the example</H4>
+<H4><a name="Ocaml_nn20"></a>31.2.4.3 Compiling the example</H4>
 
 
 <div class="code"><pre>
@@ -743,7 +743,7 @@
   -L$QTPATH/lib -cclib -lqt
 </pre></div>
 
-<H4><a name="Ocaml_nn21"></a>30.2.4.4 Sample Session</H4>
+<H4><a name="Ocaml_nn21"></a>31.2.4.4 Sample Session</H4>
 
 
 <div class="code"><pre>
@@ -770,10 +770,10 @@
 containing the string "hi" in a button.  
 </p>
 
-<H3><a name="Ocaml_nn22"></a>30.2.5 Director Classes</H3>
+<H3><a name="Ocaml_nn22"></a>31.2.5 Director Classes</H3>
 
 
-<H4><a name="Ocaml_nn23"></a>30.2.5.1 Director Introduction</H4>
+<H4><a name="Ocaml_nn23"></a>31.2.5.1 Director Introduction</H4>
 
 
 <p>
@@ -800,7 +800,7 @@
 };
 </pre></div>
 
-<H4><a name="Ocaml_nn24"></a>30.2.5.2 Overriding Methods in Ocaml</H4>
+<H4><a name="Ocaml_nn24"></a>31.2.5.2 Overriding Methods in Ocaml</H4>
 
 
 <p>
@@ -828,7 +828,7 @@
 an overloaded class.  This example is contained in Examples/ocaml/shapes.
 </p>
 
-<H4><a name="Ocaml_nn25"></a>30.2.5.3 Director Usage Example</H4>
+<H4><a name="Ocaml_nn25"></a>31.2.5.3 Director Usage Example</H4>
 
 
 <table border="1" bgcolor="#dddddd" summary="Director usage example">
@@ -887,7 +887,7 @@
 program in C++.
 </p>
 
-<H4><a name="Ocaml_nn26"></a>30.2.5.4 Creating director objects</H4>
+<H4><a name="Ocaml_nn26"></a>31.2.5.4 Creating director objects</H4>
 
 
 <p>
@@ -928,7 +928,7 @@
 properly.
 </p>
 
-<H4><a name="Ocaml_nn27"></a>30.2.5.5 Typemaps for directors, <tt>directorin, directorout, directorargout</tt></H4>
+<H4><a name="Ocaml_nn27"></a>31.2.5.5 Typemaps for directors, <tt>directorin, directorout, directorargout</tt></H4>
 
 
 <p>
@@ -939,7 +939,7 @@
 and to receive arguments the same way you normally receive function returns.
 </p>
 
-<H4><a name="Ocaml_nn28"></a>30.2.5.6 <tt>directorin</tt> typemap</H4>
+<H4><a name="Ocaml_nn28"></a>31.2.5.6 <tt>directorin</tt> typemap</H4>
 
 
 <p>
@@ -950,7 +950,7 @@
 can use the same body as a simple <tt>out</tt> typemap.
 </p>
 
-<H4><a name="Ocaml_nn29"></a>30.2.5.7 <tt>directorout</tt> typemap</H4>
+<H4><a name="Ocaml_nn29"></a>31.2.5.7 <tt>directorout</tt> typemap</H4>
 
 
 <p>
@@ -961,7 +961,7 @@
 ownership, etc.
 </p>
 
-<H4><a name="Ocaml_nn30"></a>30.2.5.8 <tt>directorargout</tt> typemap</H4>
+<H4><a name="Ocaml_nn30"></a>31.2.5.8 <tt>directorargout</tt> typemap</H4>
 
 
 <p>
@@ -978,7 +978,7 @@
 values will read zero, and struct or object returns have undefined results.
 </p>
 
-<H3><a name="Ocaml_nn31"></a>30.2.6 Exceptions</H3>
+<H3><a name="Ocaml_nn31"></a>31.2.6 Exceptions</H3>
 
 
 <p>
diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html
index bc6873c..46a8941 100644
--- a/Doc/Manual/Octave.html
+++ b/Doc/Manual/Octave.html
@@ -8,7 +8,7 @@
 
 <body bgcolor="#ffffff">
 
-<H1><a name="Octave"></a>31 SWIG and Octave</H1>
+<H1><a name="Octave"></a>32 SWIG and Octave</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -55,15 +55,15 @@
 Also, there are a dozen or so examples in the Examples/octave directory, and hundreds in the test suite (Examples/test-suite and Examples/test-suite/octave).
 </p>
 
-<H2><a name="Octave_nn2"></a>31.1 Preliminaries</H2>
+<H2><a name="Octave_nn2"></a>32.1 Preliminaries</H2>
 
 
 <p>
-As of SWIG 3.0.0, the Octave module has been tested with Octave versions 3.0.5, 3.2.4, 3.4.3, 3.6.4, and 3.8.0.
-Use of Octave versions older than 3.x.x is not recommended, as these versions are no longer tested with SWIG.
+As of SWIG 3.0.3, the Octave module has been tested with Octave versions 3.2.4, 3.4.3, 3.6.4, and 3.8.1.
+Use of older Octave versions is not recommended, as these versions are no longer tested with SWIG.
 </p>
 
-<H2><a name="Octave_nn3"></a>31.2 Running SWIG</H2>
+<H2><a name="Octave_nn3"></a>32.2 Running SWIG</H2>
 
 
 <p>
@@ -95,7 +95,7 @@
 This creates a C++ source file "example_wrap.cpp". A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.
 </p>
 
-<H3><a name="Octave_nn4"></a>31.2.1 Command-line options</H3>
+<H3><a name="Octave_nn4"></a>32.2.1 Command-line options</H3>
 
 
 <p>
@@ -118,7 +118,7 @@
 The <em>-opprefix</em> options sets the prefix of the names of global/friend <a href="#Octave_nn18">operator</a> functions.
 </p>
 
-<H3><a name="Octave_nn5"></a>31.2.2 Compiling a dynamic module</H3>
+<H3><a name="Octave_nn5"></a>32.2.2 Compiling a dynamic module</H3>
 
 
 <p>
@@ -145,7 +145,7 @@
 
           <div class="targetlang"><pre>octave:1&gt; swigexample</pre></div>
 
-<H3><a name="Octave_nn6"></a>31.2.3 Using your module</H3>
+<H3><a name="Octave_nn6"></a>32.2.3 Using your module</H3>
 
 
 <p>
@@ -163,10 +163,10 @@
 octave:5&gt; swigexample.cvar.Foo
 ans =  4 </pre></div>
 
-<H2><a name="Octave_nn7"></a>31.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Octave_nn7"></a>32.3 A tour of basic C/C++ wrapping</H2>
 
 
-<H3><a name="Octave_nn8"></a>31.3.1 Modules</H3>
+<H3><a name="Octave_nn8"></a>32.3.1 Modules</H3>
 
 
 <p>
@@ -211,7 +211,7 @@
 ans =  2
 </pre></div>
 
-<H3><a name="Octave_nn9"></a>31.3.2 Functions</H3>
+<H3><a name="Octave_nn9"></a>32.3.2 Functions</H3>
 
 
 <p>
@@ -228,7 +228,7 @@
     <div class="targetlang"><pre>octave:1&gt; swigexample.fact(4)
 24 </pre></div>
 
-<H3><a name="Octave_nn10"></a>31.3.3 Global variables</H3>
+<H3><a name="Octave_nn10"></a>32.3.3 Global variables</H3>
 
 
 <p>
@@ -281,7 +281,7 @@
 octave:3&gt; swigexample.PI
 ans =  3.1420 </pre></div>
 
-<H3><a name="Octave_nn11"></a>31.3.4 Constants and enums</H3>
+<H3><a name="Octave_nn11"></a>32.3.4 Constants and enums</H3>
 
 
 <p>
@@ -303,7 +303,7 @@
 swigexample.SUNDAY=0
 .... </pre></div>
 
-<H3><a name="Octave_nn12"></a>31.3.5 Pointers</H3>
+<H3><a name="Octave_nn12"></a>32.3.5 Pointers</H3>
 
 
 <p>
@@ -350,7 +350,7 @@
 error: value on right hand side of assignment is undefined
 error: evaluating assignment expression near line 2, column 2 </pre></div>
 
-<H3><a name="Octave_nn13"></a>31.3.6 Structures and C++ classes</H3>
+<H3><a name="Octave_nn13"></a>32.3.6 Structures and C++ classes</H3>
 
 
 <p>
@@ -485,7 +485,7 @@
 Depending on the ownership setting of a <tt>swig_ref</tt>, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.
 </p>
 
-<H3><a name="Octave_nn15"></a>31.3.7 C++ inheritance</H3>
+<H3><a name="Octave_nn15"></a>32.3.7 C++ inheritance</H3>
 
 
 <p>
@@ -494,7 +494,7 @@
 the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the <tt>swig_ref</tt>.
 </p>
 
-<H3><a name="Octave_nn17"></a>31.3.8 C++ overloaded functions</H3>
+<H3><a name="Octave_nn17"></a>32.3.8 C++ overloaded functions</H3>
 
 
 <p>
@@ -504,7 +504,7 @@
 <tt>typecheck</tt> typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.
 </p>
 
-<H3><a name="Octave_nn18"></a>31.3.9 C++ operators</H3>
+<H3><a name="Octave_nn18"></a>32.3.9 C++ operators</H3>
 
 
 <p>
@@ -608,7 +608,7 @@
 Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.
 </p>
 
-<H3><a name="Octave_nn19"></a>31.3.10 Class extension with %extend</H3>
+<H3><a name="Octave_nn19"></a>32.3.10 Class extension with %extend</H3>
 
 
 <p>
@@ -638,7 +638,7 @@
 octave:4&gt; a.__str()
 4
 </pre></div>
-<H3><a name="Octave_nn20"></a>31.3.11 C++ templates</H3>
+<H3><a name="Octave_nn20"></a>32.3.11 C++ templates</H3>
 
 
 <p>
@@ -715,14 +715,14 @@
 </pre></div>
 
 
-<H3><a name="Octave_nn21"></a>31.3.12 C++ Smart Pointers</H3>
+<H3><a name="Octave_nn21"></a>32.3.12 C++ Smart Pointers</H3>
 
 
 <p>
 C++ smart pointers are fully supported as in other modules.
 </p>
 
-<H3><a name="Octave_nn22"></a>31.3.13 Directors (calling Octave from C++ code)</H3>
+<H3><a name="Octave_nn22"></a>32.3.13 Directors (calling Octave from C++ code)</H3>
 
 
 <p>
@@ -803,14 +803,14 @@
 octave-side routine called
 </pre></div>
 
-<H3><a name="Octave_nn23"></a>31.3.14 Threads</H3>
+<H3><a name="Octave_nn23"></a>32.3.14 Threads</H3>
 
 
 <p>
 The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.
 </p>
 
-<H3><a name="Octave_nn24"></a>31.3.15 Memory management</H3>
+<H3><a name="Octave_nn24"></a>32.3.15 Memory management</H3>
 
 
 <p>
@@ -844,14 +844,14 @@
 In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/<tt>subclass()</tt>'ing).
 </p>
 
-<H3><a name="Octave_nn25"></a>31.3.16 STL support</H3>
+<H3><a name="Octave_nn25"></a>32.3.16 STL support</H3>
 
 
 <p>
 Various STL library files are provided for wrapping STL containers.
 </p>
 
-<H3><a name="Octave_nn26"></a>31.3.17 Matrix typemaps</H3>
+<H3><a name="Octave_nn26"></a>32.3.17 Matrix typemaps</H3>
 
 
 <p>
diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html
index 010eb48..8bc7cbf 100644
--- a/Doc/Manual/Perl5.html
+++ b/Doc/Manual/Perl5.html
@@ -6,7 +6,7 @@
 </head>
 
 <body bgcolor="#ffffff">
-<H1><a name="Perl5"></a>32 SWIG and Perl5</H1>
+<H1><a name="Perl5"></a>33 SWIG and Perl5</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -96,7 +96,7 @@
 Perl 5.6 seems to mostly work, while older versions don't.
 </p>
 
-<H2><a name="Perl5_nn2"></a>32.1 Overview</H2>
+<H2><a name="Perl5_nn2"></a>33.1 Overview</H2>
 
 
 <p>
@@ -117,7 +117,7 @@
 options are found near the end of the chapter.
 </p>
 
-<H2><a name="Perl5_nn3"></a>32.2 Preliminaries</H2>
+<H2><a name="Perl5_nn3"></a>33.2 Preliminaries</H2>
 
 
 <p>
@@ -142,7 +142,7 @@
 <tt>example_wrap.c</tt> and link it with the rest of your program.
 </p>
 
-<H3><a name="Perl5_nn4"></a>32.2.1 Getting the right header files</H3>
+<H3><a name="Perl5_nn4"></a>33.2.1 Getting the right header files</H3>
 
 
 <p>
@@ -174,7 +174,7 @@
 </pre>
 </div>
 
-<H3><a name="Perl5_nn5"></a>32.2.2 Compiling a dynamic module</H3>
+<H3><a name="Perl5_nn5"></a>33.2.2 Compiling a dynamic module</H3>
 
 
 <p>
@@ -207,7 +207,7 @@
 `<tt>example.sl</tt>', or the appropriate dynamic module name on your system.
 </p>
 
-<H3><a name="Perl5_nn6"></a>32.2.3 Building a dynamic module with MakeMaker</H3>
+<H3><a name="Perl5_nn6"></a>33.2.3 Building a dynamic module with MakeMaker</H3>
 
 
 <p>
@@ -241,7 +241,7 @@
 found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen,
 and Randal Schwartz.</p>
 
-<H3><a name="Perl5_nn7"></a>32.2.4 Building a static version of Perl</H3>
+<H3><a name="Perl5_nn7"></a>33.2.4 Building a static version of Perl</H3>
 
 
 <p>
@@ -310,7 +310,7 @@
 additional libraries such as <tt>-lsocket, -lnsl, -ldl</tt>, etc.
 </p>
 
-<H3><a name="Perl5_nn8"></a>32.2.5 Using the module</H3>
+<H3><a name="Perl5_nn8"></a>33.2.5 Using the module</H3>
 
 
 <p>
@@ -463,7 +463,7 @@
 read the man pages).
 </p>
 
-<H3><a name="Perl5_nn9"></a>32.2.6 Compilation problems and compiling with C++</H3>
+<H3><a name="Perl5_nn9"></a>33.2.6 Compilation problems and compiling with C++</H3>
 
 
 <p>
@@ -606,7 +606,7 @@
 any conflicting macros you find to <a href="http://www.swig.org/mail.html">swig-user mailing list</a>.
 </p>
 
-<H3><a name="Perl5_nn10"></a>32.2.7 Compiling for 64-bit platforms</H3>
+<H3><a name="Perl5_nn10"></a>33.2.7 Compiling for 64-bit platforms</H3>
 
 
 <p>
@@ -633,7 +633,7 @@
 linking standard (e.g., -o32 and -n32 on Irix).
 </p>
 
-<H2><a name="Perl5_nn11"></a>32.3 Building Perl Extensions under Windows</H2>
+<H2><a name="Perl5_nn11"></a>33.3 Building Perl Extensions under Windows</H2>
 
 
 <p>
@@ -644,7 +644,7 @@
 although the procedure may be similar with other compilers.  
 </p>
 
-<H3><a name="Perl5_nn12"></a>32.3.1 Running SWIG from Developer Studio</H3>
+<H3><a name="Perl5_nn12"></a>33.3.1 Running SWIG from Developer Studio</H3>
 
 
 <p>
@@ -707,7 +707,7 @@
 
 </pre></div>
 
-<H3><a name="Perl5_nn13"></a>32.3.2 Using other compilers</H3>
+<H3><a name="Perl5_nn13"></a>33.3.2 Using other compilers</H3>
 
 
 <p>
@@ -715,7 +715,7 @@
 For general hints and suggestions refer to the <a href="Windows.html#Windows">Windows</a> chapter.
 </p>
 
-<H2><a name="Perl5_nn14"></a>32.4 The low-level interface</H2>
+<H2><a name="Perl5_nn14"></a>33.4 The low-level interface</H2>
 
 
 <p>
@@ -725,7 +725,7 @@
 construct more user-friendly proxy classes as described in the next section.
 </p>
 
-<H3><a name="Perl5_nn15"></a>32.4.1 Functions</H3>
+<H3><a name="Perl5_nn15"></a>33.4.1 Functions</H3>
 
 
 <p>
@@ -748,7 +748,7 @@
 $a = &amp;example::fact(2);
 </pre></div>
 
-<H3><a name="Perl5_nn16"></a>32.4.2 Global variables</H3>
+<H3><a name="Perl5_nn16"></a>33.4.2 Global variables</H3>
 
 
 <p>
@@ -818,7 +818,7 @@
 </pre>
 </div>
 
-<H3><a name="Perl5_nn17"></a>32.4.3 Constants</H3>
+<H3><a name="Perl5_nn17"></a>33.4.3 Constants</H3>
 
 
 <p>
@@ -858,7 +858,7 @@
 </pre>
 </div>
 
-<H3><a name="Perl5_nn18"></a>32.4.4 Pointers</H3>
+<H3><a name="Perl5_nn18"></a>33.4.4 Pointers</H3>
 
 
 <p>
@@ -967,7 +967,7 @@
 SWIG and XS, this is no longer supported.
 </p>
 
-<H3><a name="Perl5_nn19"></a>32.4.5 Structures</H3>
+<H3><a name="Perl5_nn19"></a>33.4.5 Structures</H3>
 
 
 <p>
@@ -1101,7 +1101,7 @@
 </div>
 
 
-<H3><a name="Perl5_nn20"></a>32.4.6 C++ classes</H3>
+<H3><a name="Perl5_nn20"></a>33.4.6 C++ classes</H3>
 
 
 <p>
@@ -1166,7 +1166,7 @@
 can be built using these low-level accessors.  This is described shortly.
 </p>
 
-<H3><a name="Perl5_nn21"></a>32.4.7 C++ classes and type-checking</H3>
+<H3><a name="Perl5_nn21"></a>33.4.7 C++ classes and type-checking</H3>
 
 
 <p>
@@ -1202,7 +1202,7 @@
 multiple inheritance is used).
 </p>
 
-<H3><a name="Perl5_nn22"></a>32.4.8 C++ overloaded functions</H3>
+<H3><a name="Perl5_nn22"></a>33.4.8 C++ overloaded functions</H3>
 
 
 <p>
@@ -1246,7 +1246,7 @@
 Please refer to the "SWIG Basics" chapter for more information. 
 </p>
 
-<H3><a name="Perl5_nn23"></a>32.4.9 Operators</H3>
+<H3><a name="Perl5_nn23"></a>33.4.9 Operators</H3>
 
 
     <p>
@@ -1273,7 +1273,7 @@
 <li>operator or  </li>
     </ul>
 
-<H3><a name="Perl5_nn24"></a>32.4.10 Modules and packages</H3>
+<H3><a name="Perl5_nn24"></a>33.4.10 Modules and packages</H3>
 
 
 <p>
@@ -1368,7 +1368,7 @@
 </pre></div>
 -->
 
-<H2><a name="Perl5_nn25"></a>32.5 Input and output parameters</H2>
+<H2><a name="Perl5_nn25"></a>33.5 Input and output parameters</H2>
 
 
 <p>
@@ -1587,7 +1587,7 @@
 <b>Note:</b> The <tt>REFERENCE</tt> feature is only currently supported for numeric types (integers and floating point).
 </p>
 
-<H2><a name="Perl5_nn26"></a>32.6 Exception handling</H2>
+<H2><a name="Perl5_nn26"></a>33.6 Exception handling</H2>
 
 
 <p>
@@ -1752,7 +1752,7 @@
 functionality, but it has additional capabilities that make it more powerful.
 </p>
 
-<H2><a name="Perl5_nn27"></a>32.7 Remapping datatypes with typemaps</H2>
+<H2><a name="Perl5_nn27"></a>33.7 Remapping datatypes with typemaps</H2>
 
 
 <p>
@@ -1769,7 +1769,7 @@
 C-Perl interface.
 </p>
 
-<H3><a name="Perl5_nn28"></a>32.7.1 A simple typemap example</H3>
+<H3><a name="Perl5_nn28"></a>33.7.1 A simple typemap example</H3>
 
 
 <p>
@@ -1873,7 +1873,7 @@
 </div>
 
 
-<H3><a name="Perl5_nn29"></a>32.7.2 Perl5 typemaps</H3>
+<H3><a name="Perl5_nn29"></a>33.7.2 Perl5 typemaps</H3>
 
 
 <p>
@@ -1978,7 +1978,7 @@
 Check value of input parameter.
 </div>
 
-<H3><a name="Perl5_nn30"></a>32.7.3 Typemap variables</H3>
+<H3><a name="Perl5_nn30"></a>33.7.3 Typemap variables</H3>
 
 
 <p>
@@ -2049,7 +2049,7 @@
 The Perl name of the wrapper function being created.
 </div>
 
-<H3><a name="Perl5_nn31"></a>32.7.4 Useful functions</H3>
+<H3><a name="Perl5_nn31"></a>33.7.4 Useful functions</H3>
 
 
 <p>
@@ -2118,7 +2118,7 @@
 </div>
 
 
-<H2><a name="Perl5_nn32"></a>32.8 Typemap Examples</H2>
+<H2><a name="Perl5_nn32"></a>33.8 Typemap Examples</H2>
 
 
 <p>
@@ -2127,7 +2127,7 @@
 the SWIG library.
 </p>
 
-<H3><a name="Perl5_nn33"></a>32.8.1 Converting a Perl5 array to a char **</H3>
+<H3><a name="Perl5_nn33"></a>33.8.1 Converting a Perl5 array to a char **</H3>
 
 
 <p>
@@ -2219,7 +2219,7 @@
 </pre></div>
 
 
-<H3><a name="Perl5_nn34"></a>32.8.2 Return values</H3>
+<H3><a name="Perl5_nn34"></a>33.8.2 Return values</H3>
 
 
 <p>
@@ -2248,7 +2248,7 @@
 }
 </pre></div>
 
-<H3><a name="Perl5_nn35"></a>32.8.3 Returning values from arguments</H3>
+<H3><a name="Perl5_nn35"></a>33.8.3 Returning values from arguments</H3>
 
 
 <p>
@@ -2302,7 +2302,7 @@
 ($x,$y) = multout(7,13);
 </pre></div>
 
-<H3><a name="Perl5_nn36"></a>32.8.4 Accessing array structure members</H3>
+<H3><a name="Perl5_nn36"></a>33.8.4 Accessing array structure members</H3>
 
 
 <p>
@@ -2365,7 +2365,7 @@
 to copy the converted array into a C data structure.
 </p>
 
-<H3><a name="Perl5_nn37"></a>32.8.5 Turning Perl references into C pointers</H3>
+<H3><a name="Perl5_nn37"></a>33.8.5 Turning Perl references into C pointers</H3>
 
 
 <p>
@@ -2430,7 +2430,7 @@
 
 </pre></div>
 
-<H3><a name="Perl5_nn38"></a>32.8.6 Pointer handling</H3>
+<H3><a name="Perl5_nn38"></a>33.8.6 Pointer handling</H3>
 
 
 <p>
@@ -2509,7 +2509,7 @@
 </pre>
 </div>
 
-<H2><a name="Perl5_nn39"></a>32.9 Proxy classes</H2>
+<H2><a name="Perl5_nn39"></a>33.9 Proxy classes</H2>
 
 
 <p>
@@ -2525,7 +2525,7 @@
 details of the proxy interface.
 </p>
 
-<H3><a name="Perl5_nn40"></a>32.9.1 Preliminaries</H3>
+<H3><a name="Perl5_nn40"></a>33.9.1 Preliminaries</H3>
 
 
 <p>
@@ -2547,7 +2547,7 @@
 high level wrappers.  The wrappers, in turn, interact with the low-level procedural module.
 </p>
 
-<H3><a name="Perl5_nn41"></a>32.9.2 Structure and class wrappers</H3>
+<H3><a name="Perl5_nn41"></a>33.9.2 Structure and class wrappers</H3>
 
 
 <p>
@@ -2673,7 +2673,7 @@
 
 </pre></div>
 
-<H3><a name="Perl5_nn42"></a>32.9.3 Object Ownership</H3>
+<H3><a name="Perl5_nn42"></a>33.9.3 Object Ownership</H3>
 
 
 <p>
@@ -2760,7 +2760,7 @@
 sophisticated languages.
 </p>
 
-<H3><a name="Perl5_nn43"></a>32.9.4 Nested Objects</H3>
+<H3><a name="Perl5_nn43"></a>33.9.4 Nested Objects</H3>
 
 
 <p>
@@ -2813,7 +2813,7 @@
 %${$p-&gt;{v}} = ( x=&gt;0, y=&gt;0, z=&gt;0);         
 </pre></div>
 
-<H3><a name="Perl5_nn44"></a>32.9.5 Proxy Functions</H3>
+<H3><a name="Perl5_nn44"></a>33.9.5 Proxy Functions</H3>
 
 
 <p>
@@ -2847,7 +2847,7 @@
 identical manner.
 </p>
 
-<H3><a name="Perl5_nn45"></a>32.9.6 Inheritance</H3>
+<H3><a name="Perl5_nn45"></a>33.9.6 Inheritance</H3>
 
 
 <p>
@@ -2923,7 +2923,7 @@
 not even sure if it really works).
 </p>
 
-<H3><a name="Perl5_nn46"></a>32.9.7 Modifying the proxy methods</H3>
+<H3><a name="Perl5_nn46"></a>33.9.7 Modifying the proxy methods</H3>
 
 
 <p>
@@ -2951,7 +2951,7 @@
 };
 </pre></div>
 
-<H2><a name="Perl5_nn47"></a>32.10 Adding additional Perl code</H2>
+<H2><a name="Perl5_nn47"></a>33.10 Adding additional Perl code</H2>
 
 
 <p>
@@ -3002,7 +3002,7 @@
 </pre>
 </div>
 
-<H2><a name="Perl5_directors"></a>32.11 Cross language polymorphism</H2>
+<H2><a name="Perl5_directors"></a>33.11 Cross language polymorphism</H2>
 
 
 <p>
@@ -3036,7 +3036,7 @@
 all the cross-language method routing transparently.
 </p>
 
-<H3><a name="Perl5_nn48"></a>32.11.1 Enabling directors</H3>
+<H3><a name="Perl5_nn48"></a>33.11.1 Enabling directors</H3>
 
 
 <p>
@@ -3126,7 +3126,7 @@
 </div>
 
 
-<H3><a name="Perl5_nn49"></a>32.11.2 Director classes</H3>
+<H3><a name="Perl5_nn49"></a>33.11.2 Director classes</H3>
 
 
  
@@ -3206,7 +3206,7 @@
 calls through Perl.
 </p>
 
-<H3><a name="Perl5_nn50"></a>32.11.3 Ownership and object destruction</H3>
+<H3><a name="Perl5_nn50"></a>33.11.3 Ownership and object destruction</H3>
 
 
 <p>
@@ -3255,7 +3255,7 @@
 </div>
 
 
-<H3><a name="Perl5_nn51"></a>32.11.4 Exception unrolling</H3>
+<H3><a name="Perl5_nn51"></a>33.11.4 Exception unrolling</H3>
 
 
 <p>
@@ -3311,7 +3311,7 @@
 exception as soon as the C wrapper function returns.
 </p>
 
-<H3><a name="Perl5_nn52"></a>32.11.5 Overhead and code bloat</H3>
+<H3><a name="Perl5_nn52"></a>33.11.5 Overhead and code bloat</H3>
 
 
 <p>
@@ -3345,7 +3345,7 @@
 Perl.
 </p>
 
-<H3><a name="Perl5_nn53"></a>32.11.6 Typemaps</H3>
+<H3><a name="Perl5_nn53"></a>33.11.6 Typemaps</H3>
 
 
 <p>
diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
index 493c861..623adb6 100644
--- a/Doc/Manual/Php.html
+++ b/Doc/Manual/Php.html
@@ -7,7 +7,7 @@
 </head>
 
 <body bgcolor="#ffffff">
-<H1><a name="Php"></a>33 SWIG and PHP</H1>
+<H1><a name="Php"></a>34 SWIG and PHP</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -29,6 +29,7 @@
 <li><a href="#Php_nn2_6_2">Constructors and Destructors</a>
 <li><a href="#Php_nn2_6_3">Static Member Variables</a>
 <li><a href="#Php_nn2_6_4">Static Member Functions</a>
+<li><a href="#Php_nn2_6_5">Specifying Implemented Interfaces</a>
 </ul>
 <li><a href="#Php_nn2_7">PHP Pragmas, Startup and Shutdown code</a>
 </ul>
@@ -79,7 +80,7 @@
 available.
 </p>
 
-<H2><a name="Php_nn1"></a>33.1 Generating PHP Extensions</H2>
+<H2><a name="Php_nn1"></a>34.1 Generating PHP Extensions</H2>
 
 
 <p>
@@ -113,9 +114,7 @@
 <p>
 The usual (and recommended) way is to build the extension as a separate
 dynamically loaded module (which is supported by all modern operating
-systems).  You can then specify that this be loaded
-automatically in <tt>php.ini</tt> or load it explicitly for any script which
-needs it.
+systems).
 </p>
 
 <p>
@@ -126,7 +125,7 @@
 this approach, or provide explicit support for it.
 </p>
 
-<H3><a name="Php_nn1_1"></a>33.1.1 Building a loadable extension</H3>
+<H3><a name="Php_nn1_1"></a>34.1.1 Building a loadable extension</H3>
 
 
 <p>
@@ -137,16 +136,16 @@
 </p>
 
 <div class="code"><pre>
-	gcc `php-config --includes` -fpic -c example_wrap.c
-	gcc -shared example_wrap.o -o example.so
+	gcc `php-config --includes` -fpic -c example_wrap.c example.c
+	gcc -shared example_wrap.o example.o -o example.so
 </pre></div>
 
-<H3><a name="Php_nn1_3"></a>33.1.2 Using PHP Extensions</H3>
+<H3><a name="Php_nn1_3"></a>34.1.2 Using PHP Extensions</H3>
 
 
 <p>
-To test the extension from a PHP script, you need to load it first. You
-can load it for every script by adding this line to the <tt>[PHP]</tt> section of
+To test the extension from a PHP script, you first need to tell PHP to
+load it.  To do this, add a line like this to the <tt>[PHP]</tt> section of
 <tt>php.ini</tt>:
 </p>
 
@@ -155,8 +154,14 @@
 </pre></div>
 
 <p>
-Alternatively, you can load it explicitly only for scripts which need it
-by adding this line to the start of each such PHP script::
+If the module is in PHP's default extension directory, you can omit the path.
+</p>
+
+<p>
+For some SAPIs (for example, the CLI SAPI) you can instead use the
+<a href="http://php.net/manual/en/function.dl.php">dl() function</a> to load
+an extension at run time, by adding a like like this to the start of each
+PHP script which uses your extension:
 </p>
 
 <div class="code"><pre>
@@ -164,15 +169,26 @@
 </pre></div>
 
 <p>
-SWIG also generates a php module, which
-attempts to do the <tt>dl()</tt> call for you:
+But note that this doesn't work when running PHP through a webserver in PHP5.3
+and later - you'll need to use <tt>extension</tt> in <tt>php.ini</tt> as
+described above.
+</p>
+
+<p>
+The PHP module which SWIG generates will also attempt to do the <tt>dl()</tt>
+call for you if the extension isn't already loaded:
 </p>
 
 <div class="code"><pre>
 	include("example.php");
 </pre></div>
 
-<H2><a name="Php_nn2"></a>33.2 Basic PHP interface</H2>
+<p>
+This PHP module also defines the PHP classes for the wrapped API, so you'll
+almost certainly want to include it anyway.
+</p>
+
+<H2><a name="Php_nn2"></a>34.2 Basic PHP interface</H2>
 
 
 <p>
@@ -183,7 +199,7 @@
 SWIG doesn't have support for the namespace feature added in PHP 5.3.
 </p>
 
-<H3><a name="Php_nn2_1"></a>33.2.1 Constants</H3>
+<H3><a name="Php_nn2_1"></a>34.2.1 Constants</H3>
 
 
 <p>
@@ -220,9 +236,9 @@
 <p>
 There's one peculiarity of how constants work in PHP which it is useful
 to note (this is not specific to SWIG though) - if you try to use an undeclared
-constant, PHP will issue a warning and then expand the constant to a string
-version of the constant's name.  The warning will often be missed though as
-if you're using PHP in a webserver, it will probably end up in error.log or
+constant, PHP will emit a notice and then expand the constant to a string
+version of the constant's name.  Unfortunately it is easy to miss the notice
+if you're using PHP in a webserver, as it will probably end up in error.log or
 similar.
 </p>
 
@@ -260,7 +276,7 @@
 would be treated as false!
 </p>
 
-<H3><a name="Php_nn2_2"></a>33.2.2 Global Variables</H3>
+<H3><a name="Php_nn2_2"></a>34.2.2 Global Variables</H3>
 
 
 <p>
@@ -309,7 +325,7 @@
 At this time SWIG does not support custom accessor methods.
 </p>
 
-<H3><a name="Php_nn2_3"></a>33.2.3 Functions</H3>
+<H3><a name="Php_nn2_3"></a>34.2.3 Functions</H3>
 
 
 <p>
@@ -362,7 +378,7 @@
 -->
 
 
-<H3><a name="Php_nn2_4"></a>33.2.4 Overloading</H3>
+<H3><a name="Php_nn2_4"></a>34.2.4 Overloading</H3>
 
 
 <p>
@@ -418,7 +434,7 @@
 </p>
 -->
 
-<H3><a name="Php_nn2_5"></a>33.2.5 Pointers and References</H3>
+<H3><a name="Php_nn2_5"></a>34.2.5 Pointers and References</H3>
 
 
 <p>
@@ -563,7 +579,7 @@
 variable, or assigning <tt>NULL</tt> to a variable.
 </p>
 
-<H3><a name="Php_nn2_6"></a>33.2.6 Structures and C++ classes</H3>
+<H3><a name="Php_nn2_6"></a>34.2.6 Structures and C++ classes</H3>
 
 
 <p>
@@ -624,7 +640,7 @@
 Member variables and methods are accessed using the <tt>-&gt;</tt> operator.
 </p>
 
-<H4><a name="Php_nn2_6_1"></a>33.2.6.1 Using <tt>-noproxy</tt></H4>
+<H4><a name="Php_nn2_6_1"></a>34.2.6.1 Using <tt>-noproxy</tt></H4>
 
 
 <p>
@@ -650,7 +666,7 @@
 Complex_im_get($obj);
 </pre></div>
 
-<H4><a name="Php_nn2_6_2"></a>33.2.6.2 Constructors and Destructors</H4>
+<H4><a name="Php_nn2_6_2"></a>34.2.6.2 Constructors and Destructors</H4>
 
 
 <p>
@@ -691,7 +707,7 @@
 <tt>unset($v)</tt>
 </p>
 
-<H4><a name="Php_nn2_6_3"></a>33.2.6.3 Static Member Variables</H4>
+<H4><a name="Php_nn2_6_3"></a>34.2.6.3 Static Member Variables</H4>
 
 
 <p>
@@ -734,7 +750,7 @@
 echo "There have now been " . Ko::threats() . " threats\n";
 
 </pre></div>
-<H4><a name="Php_nn2_6_4"></a>33.2.6.4 Static Member Functions</H4>
+<H4><a name="Php_nn2_6_4"></a>34.2.6.4 Static Member Functions</H4>
 
 
 <p>
@@ -756,7 +772,25 @@
 </pre></div>
 
 
-<H3><a name="Php_nn2_7"></a>33.2.7 PHP Pragmas, Startup and Shutdown code</H3>
+<H4><a name="Php_nn2_6_5"></a>34.2.6.5 Specifying Implemented Interfaces</H4>
+
+
+<p>
+PHP supports the concept of abstract interfaces which a class can implement.
+Since SWIG 3.0.3, you can tell SWIG that a wrapped class (for example
+<code>MyIterator</code>) implements the <code>Iterator</code> interface like
+so:
+</p>
+
+<div class="code"><pre>
+%typemap("phpinterfaces") MyIterator "Iterator";
+</pre></div>
+
+<p>
+If there are multiple interfaces, just list them separated by commas.
+</p>
+
+<H3><a name="Php_nn2_7"></a>34.2.7 PHP Pragmas, Startup and Shutdown code</H3>
 
 
 <p>
@@ -844,7 +878,7 @@
 into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.
 </p>
 
-<H2><a name="Php_nn3"></a>33.3 Cross language polymorphism</H2>
+<H2><a name="Php_nn3"></a>34.3 Cross language polymorphism</H2>
 
 
 <p>
@@ -879,7 +913,7 @@
 transparently.
 </p>
 
-<H3><a name="Php_nn3_1"></a>33.3.1 Enabling directors</H3>
+<H3><a name="Php_nn3_1"></a>34.3.1 Enabling directors</H3>
 
 
 <p>
@@ -968,7 +1002,7 @@
 </div>
 
 
-<H3><a name="Php_nn3_2"></a>33.3.2 Director classes</H3>
+<H3><a name="Php_nn3_2"></a>34.3.2 Director classes</H3>
 
 
  
@@ -1048,7 +1082,7 @@
 calls through PHP.
 </p>
 
-<H3><a name="Php_nn3_3"></a>33.3.3 Ownership and object destruction</H3>
+<H3><a name="Php_nn3_3"></a>34.3.3 Ownership and object destruction</H3>
 
 
 <p>
@@ -1104,7 +1138,7 @@
 deleting all the Foo pointers it contains at some point.
 </p>
 
-<H3><a name="Php_nn3_4"></a>33.3.4 Exception unrolling</H3>
+<H3><a name="Php_nn3_4"></a>34.3.4 Exception unrolling</H3>
 
 
 <p>
@@ -1163,7 +1197,7 @@
 as soon as the C wrapper function returns.
 </p>
 
-<H3><a name="Php_nn3_5"></a>33.3.5 Overhead and code bloat</H3>
+<H3><a name="Php_nn3_5"></a>34.3.5 Overhead and code bloat</H3>
 
 
 <p>
@@ -1196,7 +1230,7 @@
 directive) for only those methods that are likely to be extended in PHP.
 </p>
 
-<H3><a name="Php_nn3_6"></a>33.3.6 Typemaps</H3>
+<H3><a name="Php_nn3_6"></a>34.3.6 Typemaps</H3>
 
 
 <p>
@@ -1210,7 +1244,7 @@
 </p>
 
 
-<H3><a name="Php_nn3_7"></a>33.3.7 Miscellaneous</H3>
+<H3><a name="Php_nn3_7"></a>34.3.7 Miscellaneous</H3>
 
 
 <p> Director typemaps for STL classes are mostly in place, and hence you
diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html
index 3ede1a9..44c6930 100644
--- a/Doc/Manual/Pike.html
+++ b/Doc/Manual/Pike.html
@@ -6,7 +6,7 @@
 </head>
 
 <body bgcolor="#ffffff">
-<H1><a name="Pike"></a>34 SWIG and Pike</H1>
+<H1><a name="Pike"></a>35 SWIG and Pike</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -46,10 +46,10 @@
 chapter.<br>
 </p>
 
-<H2><a name="Pike_nn2"></a>34.1 Preliminaries</H2>
+<H2><a name="Pike_nn2"></a>35.1 Preliminaries</H2>
 
 
-<H3><a name="Pike_nn3"></a>34.1.1 Running SWIG</H3>
+<H3><a name="Pike_nn3"></a>35.1.1 Running SWIG</H3>
 
 
 <p>
@@ -94,7 +94,7 @@
 <div class="code">
   <pre>$ <b>swig -pike -o pseudonym.c example.i</b><br></pre>
 </div>
-<H3><a name="Pike_nn4"></a>34.1.2 Getting the right header files</H3>
+<H3><a name="Pike_nn4"></a>35.1.2 Getting the right header files</H3>
 
 
 <p>
@@ -114,7 +114,7 @@
 and so on.
 </p>
 
-<H3><a name="Pike_nn5"></a>34.1.3 Using your module</H3>
+<H3><a name="Pike_nn5"></a>35.1.3 Using your module</H3>
 
 
 <p>
@@ -129,10 +129,10 @@
 (1) Result: 24
 </pre></div>
 
-<H2><a name="Pike_nn6"></a>34.2 Basic C/C++ Mapping</H2>
+<H2><a name="Pike_nn6"></a>35.2 Basic C/C++ Mapping</H2>
 
 
-<H3><a name="Pike_nn7"></a>34.2.1 Modules</H3>
+<H3><a name="Pike_nn7"></a>35.2.1 Modules</H3>
 
 
 <p>
@@ -143,7 +143,7 @@
 significance.
 </p>
 
-<H3><a name="Pike_nn8"></a>34.2.2 Functions</H3>
+<H3><a name="Pike_nn8"></a>35.2.2 Functions</H3>
 
 
 <p>
@@ -168,7 +168,7 @@
 (1) Result: 24
 </pre></div>
 
-<H3><a name="Pike_nn9"></a>34.2.3 Global variables</H3>
+<H3><a name="Pike_nn9"></a>35.2.3 Global variables</H3>
 
 
 <p>
@@ -197,7 +197,7 @@
 (3) Result: 3.141590
 </pre></div>
 
-<H3><a name="Pike_nn10"></a>34.2.4 Constants and enumerated types</H3>
+<H3><a name="Pike_nn10"></a>35.2.4 Constants and enumerated types</H3>
 
 
 <p>
@@ -205,7 +205,7 @@
 not as Pike enums.
 </p>
 
-<H3><a name="Pike_nn11"></a>34.2.5 Constructors and Destructors</H3>
+<H3><a name="Pike_nn11"></a>35.2.5 Constructors and Destructors</H3>
 
 
 <p>
@@ -213,7 +213,7 @@
 wrapped as <tt>destroy()</tt> methods, for Pike classes.
 </p>
 
-<H3><a name="Pike_nn12"></a>34.2.6 Static Members</H3>
+<H3><a name="Pike_nn12"></a>35.2.6 Static Members</H3>
 
 
 <p>
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index dcfd742..eb102aa 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -6,7 +6,7 @@
 </head>
 
 <body bgcolor="#ffffff">
-<H1><a name="Python"></a>35 SWIG and Python</H1>
+<H1><a name="Python"></a>36 SWIG and Python</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -116,6 +116,7 @@
 <li><a href="#Python_nn74">Function annotation</a>
 <li><a href="#Python_nn75">Buffer interface</a>
 <li><a href="#Python_nn76">Abstract base classes</a>
+<li><a href="#Python_nn77">Byte string output conversion</a>
 </ul>
 </ul>
 </div>
@@ -141,7 +142,7 @@
 Basics</a>" chapter.
 </p>
 
-<H2><a name="Python_nn2"></a>35.1 Overview</H2>
+<H2><a name="Python_nn2"></a>36.1 Overview</H2>
 
 
 <p>
@@ -168,10 +169,10 @@
 details.
 </p>
 
-<H2><a name="Python_nn3"></a>35.2 Preliminaries</H2>
+<H2><a name="Python_nn3"></a>36.2 Preliminaries</H2>
 
 
-<H3><a name="Python_nn4"></a>35.2.1 Running SWIG</H3>
+<H3><a name="Python_nn4"></a>36.2.1 Running SWIG</H3>
 
 
 <p>
@@ -193,7 +194,7 @@
 </div>
 
 <p>
-The <tt> #define SWIG_FILE_WITH_INIT </tt> line inserts a macro that specifies that the
+The <tt>#define SWIG_FILE_WITH_INIT</tt> line inserts a macro that specifies that the
 resulting C file should be built as a python extension, inserting the module
 <tt>init</tt> code. This <tt>.i</tt> file wraps the following simple C file:
 </p>
@@ -269,7 +270,7 @@
 how you might go about compiling and using the generated files.
 </p>
 
-<H3><a name="Python_nn6"></a>35.2.2 Using distutils</H3>
+<H3><a name="Python_nn6"></a>36.2.2 Using distutils</H3>
 
 
 <p>
@@ -361,7 +362,7 @@
 can even build extensions to the standard Windows Python using MingGW)
 </p>
 
-<H3><a name="Python_nn7"></a>35.2.3 Hand compiling a dynamic module</H3>
+<H3><a name="Python_nn7"></a>36.2.3 Hand compiling a dynamic module</H3>
 
 
 <p>
@@ -394,7 +395,7 @@
 name of the corresponding object file should be
 "<tt>_example.so</tt>" or "<tt>_examplemodule.so</tt>".
 The name of the module is specified using the <tt>%module</tt> directive or the 
-<tt> -module</tt> command line option.
+<tt>-module</tt> command line option.
 </p>
 
 <p>
@@ -409,7 +410,7 @@
 </p>
 
 
-<H3><a name="Python_nn8"></a>35.2.4 Static linking</H3>
+<H3><a name="Python_nn8"></a>36.2.4 Static linking</H3>
 
 
 <p>
@@ -488,7 +489,7 @@
 (perhaps using distutils).
 </p>
 
-<H3><a name="Python_nn9"></a>35.2.5 Using your module</H3>
+<H3><a name="Python_nn9"></a>36.2.5 Using your module</H3>
 
 
 <p>
@@ -645,7 +646,7 @@
 read the man pages).
 </p>
 
-<H3><a name="Python_nn10"></a>35.2.6 Compilation of C++ extensions</H3>
+<H3><a name="Python_nn10"></a>36.2.6 Compilation of C++ extensions</H3>
 
 
 <p>
@@ -737,7 +738,7 @@
 might want to investigate using a more formal standard such as COM.
 </p>
 
-<H3><a name="Python_nn11"></a>35.2.7 Compiling for 64-bit platforms</H3>
+<H3><a name="Python_nn11"></a>36.2.7 Compiling for 64-bit platforms</H3>
 
 
 <p>
@@ -774,7 +775,7 @@
 extension.
 </p>
 
-<H3><a name="Python_nn12"></a>35.2.8 Building Python Extensions under Windows</H3>
+<H3><a name="Python_nn12"></a>36.2.8 Building Python Extensions under Windows</H3>
 
 
 <p>
@@ -782,8 +783,8 @@
 the process used with Unix. Using the distutils, it is essentially
 identical. If you have the same version of the MS compiler that Python
 was built with (the python2.4 and python2.5 distributed by python.org
-are built with Visual Studio 2003), the standard <tt> python setup.py
-build </tt> should just work.
+are built with Visual Studio 2003), the standard <tt>python setup.py
+build</tt> should just work.
 </p>
 
 <p>
@@ -903,7 +904,7 @@
 </p>
 
 
-<H2><a name="Python_nn13"></a>35.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Python_nn13"></a>36.3 A tour of basic C/C++ wrapping</H2>
 
 
 <p>
@@ -912,7 +913,7 @@
 This section briefly covers the essential aspects of this wrapping.
 </p>
 
-<H3><a name="Python_nn14"></a>35.3.1 Modules</H3>
+<H3><a name="Python_nn14"></a>36.3.1 Modules</H3>
 
 
 <p>
@@ -925,7 +926,7 @@
 Python command or standard module name.  
 </p>
 
-<H3><a name="Python_nn15"></a>35.3.2 Functions</H3>
+<H3><a name="Python_nn15"></a>36.3.2 Functions</H3>
 
 
 <p>
@@ -949,7 +950,7 @@
 &gt;&gt;&gt;
 </pre></div>
 
-<H3><a name="Python_nn16"></a>35.3.3 Global variables</H3>
+<H3><a name="Python_nn16"></a>36.3.3 Global variables</H3>
 
 
 <p>
@@ -1087,7 +1088,7 @@
 if there are no global variables in a module.
 </p>
 
-<H3><a name="Python_nn17"></a>35.3.4 Constants and enums</H3>
+<H3><a name="Python_nn17"></a>36.3.4 Constants and enums</H3>
 
 
 <p>
@@ -1127,7 +1128,7 @@
 generate code that prevents this.  You will just have to be careful.
 </p>
 
-<H3><a name="Python_nn18"></a>35.3.5 Pointers</H3>
+<H3><a name="Python_nn18"></a>36.3.5 Pointers</H3>
 
 
 <p>
@@ -1268,7 +1269,7 @@
 <tt>None</tt> if the conversion can't be performed.
 </p>
 
-<H3><a name="Python_nn19"></a>35.3.6 Structures</H3>
+<H3><a name="Python_nn19"></a>36.3.6 Structures</H3>
 
 
 <p>
@@ -1457,7 +1458,7 @@
 </pre>
 </div>
 
-<H3><a name="Python_nn20"></a>35.3.7 C++ classes</H3>
+<H3><a name="Python_nn20"></a>36.3.7 C++ classes</H3>
 
 
 <p>
@@ -1546,7 +1547,7 @@
 </pre>
 </div>
 
-<H3><a name="Python_nn21"></a>35.3.8 C++ inheritance</H3>
+<H3><a name="Python_nn21"></a>36.3.8 C++ inheritance</H3>
 
 
 <p>
@@ -1601,7 +1602,7 @@
 It is safe to use multiple inheritance with SWIG.
 </p>
 
-<H3><a name="Python_nn22"></a>35.3.9 Pointers, references, values, and arrays</H3>
+<H3><a name="Python_nn22"></a>36.3.9 Pointers, references, values, and arrays</H3>
 
 
 <p>
@@ -1662,7 +1663,7 @@
 allocation/deallocation process.
 </p>
 
-<H3><a name="Python_nn23"></a>35.3.10 C++ overloaded functions</H3>
+<H3><a name="Python_nn23"></a>36.3.10 C++ overloaded functions</H3>
 
 
 <p>
@@ -1785,7 +1786,7 @@
 Please refer to the "SWIG and C++" chapter for more information about overloading. 
 </p>
 
-<H3><a name="Python_nn24"></a>35.3.11 C++ operators</H3>
+<H3><a name="Python_nn24"></a>36.3.11 C++ operators</H3>
 
 
 <p>
@@ -1874,7 +1875,7 @@
 overloaded assignment operators don't map to Python semantics and will be ignored.
 </p>
 
-<H3><a name="Python_nn25"></a>35.3.12 C++ namespaces</H3>
+<H3><a name="Python_nn25"></a>36.3.12 C++ namespaces</H3>
 
 
 <p>
@@ -1941,7 +1942,7 @@
 identical symbol names, well, then you get what you deserve.
 </p>
 
-<H3><a name="Python_nn26"></a>35.3.13 C++ templates</H3>
+<H3><a name="Python_nn26"></a>36.3.13 C++ templates</H3>
 
 
 <p>
@@ -1995,7 +1996,7 @@
 examples will appear later.
 </p>
 
-<H3><a name="Python_nn27"></a>35.3.14 C++ Smart Pointers</H3>
+<H3><a name="Python_nn27"></a>36.3.14 C++ Smart Pointers</H3>
 
 
 <p>
@@ -2079,7 +2080,7 @@
 </pre>
 </div>
 
-<H3><a name="Python_nn27a"></a>35.3.15 C++ reference counted objects</H3>
+<H3><a name="Python_nn27a"></a>36.3.15 C++ reference counted objects</H3>
 
 
 <p>
@@ -2088,7 +2089,7 @@
 </p>
 
 
-<H2><a name="Python_nn28"></a>35.4 Further details on the Python class interface</H2>
+<H2><a name="Python_nn28"></a>36.4 Further details on the Python class interface</H2>
 
 
 <p>
@@ -2111,7 +2112,7 @@
 section.
 </p>
 
-<H3><a name="Python_nn29"></a>35.4.1 Proxy classes</H3>
+<H3><a name="Python_nn29"></a>36.4.1 Proxy classes</H3>
 
 
 <p>
@@ -2200,7 +2201,7 @@
 by Python built-in types until Python 2.2).
 </p>
 
-<H3><a name="Python_builtin_types"></a>35.4.2 Built-in Types</H3>
+<H3><a name="Python_builtin_types"></a>36.4.2 Built-in Types</H3>
 
 
 <p>
@@ -2244,7 +2245,7 @@
 
 <p><a href="http://docs.python.org/extending/newtypes.html">http://docs.python.org/extending/newtypes.html</a></p>
 
-<H4><a name="Python_builtin_limitations"></a>35.4.2.1 Limitations</H4>
+<H4><a name="Python_builtin_limitations"></a>36.4.2.1 Limitations</H4>
 
 
 <p>Use of the <tt>-builtin</tt> option implies a couple of limitations:
@@ -2412,7 +2413,7 @@
 </li>
 </ul>
 
-<H4><a name="Python_builtin_overloads"></a>35.4.2.2 Operator overloads -- use them!</H4>
+<H4><a name="Python_builtin_overloads"></a>36.4.2.2 Operator overloads -- use them!</H4>
 
 
 <p>The entire justification for the <tt>-builtin</tt> option is improved
@@ -2513,7 +2514,7 @@
 </p>
 
 
-<H3><a name="Python_nn30"></a>35.4.3 Memory management</H3>
+<H3><a name="Python_nn30"></a>36.4.3 Memory management</H3>
 
 
 <p>NOTE: Although this section refers to proxy objects, everything here also applies
@@ -2708,7 +2709,7 @@
 typemaps--an advanced topic discussed later.
 </p>
 
-<H3><a name="Python_nn31"></a>35.4.4 Python 2.2 and classic classes</H3>
+<H3><a name="Python_nn31"></a>36.4.4 Python 2.2 and classic classes</H3>
 
 
 <p>
@@ -2745,7 +2746,7 @@
 function or through an instance (see the earlier section).
 </p>
 
-<H2><a name="Python_directors"></a>35.5 Cross language polymorphism</H2>
+<H2><a name="Python_directors"></a>36.5 Cross language polymorphism</H2>
 
 
 <p>
@@ -2779,7 +2780,7 @@
 all the cross-language method routing transparently.
 </p>
 
-<H3><a name="Python_nn33"></a>35.5.1 Enabling directors</H3>
+<H3><a name="Python_nn33"></a>36.5.1 Enabling directors</H3>
 
 
 <p>
@@ -2869,7 +2870,7 @@
 </div>
 
 
-<H3><a name="Python_nn34"></a>35.5.2 Director classes</H3>
+<H3><a name="Python_nn34"></a>36.5.2 Director classes</H3>
 
 
  
@@ -2951,7 +2952,7 @@
 calls through Python.
 </p>
 
-<H3><a name="Python_nn35"></a>35.5.3 Ownership and object destruction</H3>
+<H3><a name="Python_nn35"></a>36.5.3 Ownership and object destruction</H3>
 
 
 <p>
@@ -3018,7 +3019,7 @@
 references to the Foo objects remain in Python.
 </p>
 
-<H3><a name="Python_nn36"></a>35.5.4 Exception unrolling</H3>
+<H3><a name="Python_nn36"></a>36.5.4 Exception unrolling</H3>
 
 
 <p>
@@ -3077,7 +3078,7 @@
 exception as soon as the C wrapper function returns.
 </p>
 
-<H3><a name="Python_nn37"></a>35.5.5 Overhead and code bloat</H3>
+<H3><a name="Python_nn37"></a>36.5.5 Overhead and code bloat</H3>
 
 
 <p>
@@ -3111,7 +3112,7 @@
 Python.
 </p>
 
-<H3><a name="Python_nn38"></a>35.5.6 Typemaps</H3>
+<H3><a name="Python_nn38"></a>36.5.6 Typemaps</H3>
 
 
 <p>
@@ -3125,7 +3126,7 @@
 </p>
 
 
-<H3><a name="Python_nn39"></a>35.5.7 Miscellaneous</H3>
+<H3><a name="Python_nn39"></a>36.5.7 Miscellaneous</H3>
 
 
 <p>
@@ -3172,7 +3173,7 @@
 </p>
 
 
-<H2><a name="Python_nn40"></a>35.6 Common customization features</H2>
+<H2><a name="Python_nn40"></a>36.6 Common customization features</H2>
 
 
 <p>
@@ -3185,7 +3186,7 @@
 improve your the interface to an extension module.
 </p>
 
-<H3><a name="Python_nn41"></a>35.6.1 C/C++ helper functions</H3>
+<H3><a name="Python_nn41"></a>36.6.1 C/C++ helper functions</H3>
 
 
 <p>
@@ -3266,7 +3267,7 @@
 customization features as covered in later sections.
 </p>
 
-<H3><a name="Python_nn42"></a>35.6.2 Adding additional Python code</H3>
+<H3><a name="Python_nn42"></a>36.6.2 Adding additional Python code</H3>
 
 
 <p>
@@ -3367,6 +3368,18 @@
 </pre>
 </div>
 
+<p>When using <tt>%pythoncode</tt> and <tt>%pythonbegin</tt> you generally
+want to make sure that the block is delimited by <tt>%{</tt> and <tt>%}</tt>.
+If you delimit it with <tt>{</tt> and <tt>}</tt> then any lines with a
+leading <tt>#</tt> will be handled by SWIG as preprocessor directives, when
+you probably meant them as Python comments.  Prior to SWIG 3.0.3, invalid
+preprocessor directives were silently ignored, so generally using the wrong
+delimiters resulted in such comments not appearing in the generated output
+(though a comment starting with a valid preprocessor directive could cause
+problems, for example: <tt># error handling</tt>).  SWIG 3.0.3 and later report
+an error for invalid preprocessor directives, so you may have to update
+existing interface files to delimit blocks of Python code correctly.</p>
+
 <p>Sometimes you may want to replace or modify the wrapper function
 that SWIG creates in the proxy <tt>.py</tt> file.  The Python module
 in SWIG provides some features that enable you to do this.  First, to
@@ -3494,7 +3507,7 @@
 </p>
 
 
-<H3><a name="Python_nn43"></a>35.6.3 Class extension with %extend</H3>
+<H3><a name="Python_nn43"></a>36.6.3 Class extension with %extend</H3>
 
 
 <p>
@@ -3583,7 +3596,7 @@
 in any way---the extensions only show up in the Python interface.
 </p>
 
-<H3><a name="Python_nn44"></a>35.6.4 Exception handling with %exception</H3>
+<H3><a name="Python_nn44"></a>36.6.4 Exception handling with %exception</H3>
 
 
 <p>
@@ -3709,7 +3722,7 @@
 to raise exceptions.  See the <a href="Library.html#Library">SWIG Library</a> chapter.
 </p>
 
-<H2><a name="Python_nn45"></a>35.7 Tips and techniques</H2>
+<H2><a name="Python_nn45"></a>36.7 Tips and techniques</H2>
 
 
 <p>
@@ -3719,7 +3732,7 @@
 solving these problems.
 </p>
 
-<H3><a name="Python_nn46"></a>35.7.1 Input and output parameters</H3>
+<H3><a name="Python_nn46"></a>36.7.1 Input and output parameters</H3>
 
 
 <p>
@@ -3932,7 +3945,7 @@
 may not have the intended effect since <tt>typemaps.i</tt> does not define an OUTPUT rule for <tt>Bar</tt>.
 </p>
 
-<H3><a name="Python_nn47"></a>35.7.2 Simple pointers</H3>
+<H3><a name="Python_nn47"></a>36.7.2 Simple pointers</H3>
 
 
 <p>
@@ -4001,7 +4014,7 @@
 See the <a href="Library.html#Library">SWIG Library</a> chapter for further details.
 </p>
 
-<H3><a name="Python_nn48"></a>35.7.3 Unbounded C Arrays</H3>
+<H3><a name="Python_nn48"></a>36.7.3 Unbounded C Arrays</H3>
 
 
 <p>
@@ -4063,7 +4076,7 @@
 package binary data, etc.
 </p>
 
-<H3><a name="Python_nn49"></a>35.7.4 String handling</H3>
+<H3><a name="Python_nn49"></a>36.7.4 String handling</H3>
 
 
 <p>
@@ -4132,7 +4145,7 @@
 also be used to extra binary data from arbitrary pointers.
 </p>
 
-<H2><a name="Python_nn53"></a>35.8 Typemaps</H2>
+<H2><a name="Python_nn53"></a>36.8 Typemaps</H2>
 
 
 <p>
@@ -4149,7 +4162,7 @@
 C-Python interface or if you want to elevate your guru status.
 </p>
 
-<H3><a name="Python_nn54"></a>35.8.1 What is a typemap?</H3>
+<H3><a name="Python_nn54"></a>36.8.1 What is a typemap?</H3>
 
 
 <p>
@@ -4265,7 +4278,7 @@
 </pre>
 </div>
 
-<H3><a name="Python_nn55"></a>35.8.2 Python typemaps</H3>
+<H3><a name="Python_nn55"></a>36.8.2 Python typemaps</H3>
 
 
 <p>
@@ -4306,7 +4319,7 @@
 </p>
 
 
-<H3><a name="Python_nn56"></a>35.8.3 Typemap variables</H3>
+<H3><a name="Python_nn56"></a>36.8.3 Typemap variables</H3>
 
 
 <p>
@@ -4377,7 +4390,7 @@
 The Python name of the wrapper function being created.
 </div>
 
-<H3><a name="Python_nn57"></a>35.8.4 Useful Python Functions</H3>
+<H3><a name="Python_nn57"></a>36.8.4 Useful Python Functions</H3>
 
 
 <p>
@@ -4505,7 +4518,7 @@
 </pre>
 </div>
 
-<H2><a name="Python_nn58"></a>35.9 Typemap Examples</H2>
+<H2><a name="Python_nn58"></a>36.9 Typemap Examples</H2>
 
 
 <p>
@@ -4514,7 +4527,7 @@
 the SWIG library.
 </p>
 
-<H3><a name="Python_nn59"></a>35.9.1 Converting  Python list to a char ** </H3>
+<H3><a name="Python_nn59"></a>36.9.1 Converting  Python list to a char ** </H3>
 
 
 <p>
@@ -4594,7 +4607,7 @@
 the C function. 
 </p>
 
-<H3><a name="Python_nn60"></a>35.9.2 Expanding a Python object into multiple arguments</H3>
+<H3><a name="Python_nn60"></a>36.9.2 Expanding a Python object into multiple arguments</H3>
 
 
 <p>
@@ -4673,7 +4686,7 @@
 </pre>
 </div>
 
-<H3><a name="Python_nn61"></a>35.9.3 Using typemaps to return arguments</H3>
+<H3><a name="Python_nn61"></a>36.9.3 Using typemaps to return arguments</H3>
 
 
 <p>
@@ -4761,7 +4774,7 @@
 &gt;&gt;&gt;
 </pre></div>
 
-<H3><a name="Python_nn62"></a>35.9.4 Mapping Python tuples into small arrays</H3>
+<H3><a name="Python_nn62"></a>36.9.4 Mapping Python tuples into small arrays</H3>
 
 
 <p>
@@ -4810,7 +4823,7 @@
 for small structures, this approach works fine.
 </p>
 
-<H3><a name="Python_nn63"></a>35.9.5 Mapping sequences to C arrays</H3>
+<H3><a name="Python_nn63"></a>36.9.5 Mapping sequences to C arrays</H3>
 
 
 <p>
@@ -4899,7 +4912,7 @@
 </pre>
 </div>
 
-<H3><a name="Python_nn64"></a>35.9.6 Pointer handling</H3>
+<H3><a name="Python_nn64"></a>36.9.6 Pointer handling</H3>
 
 
 <p>
@@ -4996,7 +5009,7 @@
 
 
 
-<H2><a name="Python_nn65"></a>35.10 Docstring Features</H2>
+<H2><a name="Python_nn65"></a>36.10 Docstring Features</H2>
 
 
 <p>
@@ -5024,7 +5037,7 @@
 </p>
 
 
-<H3><a name="Python_nn66"></a>35.10.1 Module docstring</H3>
+<H3><a name="Python_nn66"></a>36.10.1 Module docstring</H3>
 
 
 <p>
@@ -5058,7 +5071,7 @@
 </div>
 
 
-<H3><a name="Python_nn67"></a>35.10.2 %feature("autodoc")</H3>
+<H3><a name="Python_nn67"></a>36.10.2 %feature("autodoc")</H3>
 
 
 <p>
@@ -5086,7 +5099,7 @@
 feature, <tt>%feature("autodoc", "<i>level</i>")</tt>.
 The four values for <i>level</i> are covered in the following sub-sections.
 
-<H4><a name="Python_nn68"></a>35.10.2.1 %feature("autodoc", "0")</H4>
+<H4><a name="Python_nn68"></a>36.10.2.1 %feature("autodoc", "0")</H4>
 
 
 <p>
@@ -5115,7 +5128,7 @@
 </div>
 
 
-<H4><a name="Python_nn69"></a>35.10.2.2 %feature("autodoc", "1")</H4>
+<H4><a name="Python_nn69"></a>36.10.2.2 %feature("autodoc", "1")</H4>
 
 
 <p>
@@ -5140,7 +5153,7 @@
 </div>
 
 
-<H4><a name="Python_autodoc2"></a>35.10.2.3 %feature("autodoc", "2")</H4>
+<H4><a name="Python_autodoc2"></a>36.10.2.3 %feature("autodoc", "2")</H4>
 
 
 <p>
@@ -5200,7 +5213,7 @@
 </pre>
 </div>
 
-<H4><a name="Python_autodoc3"></a>35.10.2.4 %feature("autodoc", "3")</H4>
+<H4><a name="Python_autodoc3"></a>36.10.2.4 %feature("autodoc", "3")</H4>
 
 
 <p>
@@ -5225,7 +5238,7 @@
 </div>
 
 
-<H4><a name="Python_nn70"></a>35.10.2.5 %feature("autodoc", "docstring")</H4>
+<H4><a name="Python_nn70"></a>36.10.2.5 %feature("autodoc", "docstring")</H4>
 
 
 <p>
@@ -5244,7 +5257,7 @@
 </div>
 
 
-<H3><a name="Python_nn71"></a>35.10.3 %feature("docstring")</H3>
+<H3><a name="Python_nn71"></a>36.10.3 %feature("docstring")</H3>
 
 
 <p>
@@ -5276,7 +5289,7 @@
 </pre>
 </div>
 
-<H2><a name="Python_nn72"></a>35.11 Python Packages</H2>
+<H2><a name="Python_nn72"></a>36.11 Python Packages</H2>
 
 
 <p>Python has concepts of modules and packages. Modules are separate units of
@@ -5334,7 +5347,7 @@
 <tt>%module</tt> directive or import related command line options. These are
 explained in the following sections.</p>
 
-<H3><a name="Python_modulepackage"></a>35.11.1 Setting the Python package</H3>
+<H3><a name="Python_modulepackage"></a>36.11.1 Setting the Python package</H3>
 
 
 <p>
@@ -5388,7 +5401,7 @@
 </pre>
 </div>
 
-<H3><a name="Python_absrelimports"></a>35.11.2 Absolute and relative imports</H3>
+<H3><a name="Python_absrelimports"></a>36.11.2 Absolute and relative imports</H3>
 
 
 <p>Suppose, we have the following hierarchy of files:</p>
@@ -5412,7 +5425,7 @@
 
 <p>
 We edit <tt>pkg1/mod2.py</tt> and want to import module
-<tt>pkg1/pkg2/pkg3.py</tt> in order to derive from class <tt>M3</tt>. We can
+<tt>pkg1/pkg2/mod3.py</tt> in order to derive from class <tt>M3</tt>. We can
 write appropriate Python code in several ways, for example:
 </p>
 
@@ -5527,7 +5540,7 @@
 <tt>__init__.py</tt> to import symbols from submodules or subpackages and the
 submodule depends on other submodules (discussed later).</p>
 
-<H3><a name="Python_absimport"></a>35.11.3 Enforcing absolute import semantics</H3>
+<H3><a name="Python_absimport"></a>36.11.3 Enforcing absolute import semantics</H3>
 
 
 <p>As you may know, there is an incompatibility in import semantics (for the
@@ -5564,14 +5577,14 @@
 </pre>
 </div>
 
-<H3><a name="Python_importfrominit"></a>35.11.4 Importing from __init__.py</H3>
+<H3><a name="Python_importfrominit"></a>36.11.4 Importing from __init__.py</H3>
 
 
 <p>Imports in <tt>__init__.py</tt> are handy when you want to populate a
 package's namespace with names imported from other modules. In SWIG based
 projects this approach may also be used to split large pieces of code into
-smaller modules, compile them in parallel and then re-assemble everything at another
-level by importing submodules' contents in <tt>__init__.py</tt>, for
+smaller modules, compile them in parallel and then re-assemble everything at
+runtime by importing submodules' contents in <tt>__init__.py</tt>, for
 example.</p>
 
 <p>Unfortunately import directives in <tt>__init__.py</tt> may cause problems,
@@ -5675,7 +5688,7 @@
 workaround).</p>
 
 
-<H2><a name="Python_python3support"></a>35.12 Python 3 Support</H2>
+<H2><a name="Python_python3support"></a>36.12 Python 3 Support</H2>
 
 
 <p>
@@ -5702,7 +5715,7 @@
 SWIG.
 </p>
 
-<H3><a name="Python_nn74"></a>35.12.1 Function annotation</H3>
+<H3><a name="Python_nn74"></a>36.12.1 Function annotation</H3>
 
 
 <p>
@@ -5735,7 +5748,7 @@
 <a href="http://www.python.org/dev/peps/pep-3107/">PEP 3107</a>.
 </p>
 
-<H3><a name="Python_nn75"></a>35.12.2 Buffer interface</H3>
+<H3><a name="Python_nn75"></a>36.12.2 Buffer interface</H3>
 
 
 <p>
@@ -5887,7 +5900,7 @@
 </div>
 
 
-<H3><a name="Python_nn76"></a>35.12.3 Abstract base classes</H3>
+<H3><a name="Python_nn76"></a>36.12.3 Abstract base classes</H3>
 
 
 <p>
@@ -5928,6 +5941,92 @@
 <a href="http://www.python.org/dev/peps/pep-3119/">PEP 3119</a>.
 </p>
 
+<H3><a name="Python_nn77"></a>36.12.4 Byte string output conversion</H3>
+
+
+<p>
+By default, any byte string (<tt>char*</tt> or <tt>std::string</tt>) returned
+from C or C++ code is decoded to text as UTF-8. This decoding uses the
+<tt>surrogateescape</tt> error handler under Python 3.1 or higher -- this
+error handler decodes invalid byte sequences to high surrogate characters
+in the range U+DC80 to U+DCFF.
+
+As an example, consider the following SWIG interface, which exposes a byte
+string that cannot be completely decoded as UTF-8:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%include &lt;std_string.i&gt;
+
+%inline %{
+
+const char* non_utf8_c_str(void) {
+        return "h\xe9llo w\xc3\xb6rld";
+}
+
+%}
+</pre></div>
+
+<p>
+When this method is called from Python 3, the return value is the following
+text string:
+</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; s = example.non_utf8_c_str()
+&gt;&gt;&gt; s
+'h\udce9llo w&#246;rld'
+</pre></div>
+
+<p>
+Since the C string contains bytes that cannot be decoded as UTF-8, those raw
+bytes are represented as high surrogate characters that can be used to obtain
+the original byte sequence:
+</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; b = s.encode('utf-8', errors='surrogateescape')
+&gt;&gt;&gt; b
+b'h\xe9llo w\xc3\xb6rld'
+</pre></div>
+
+<p>
+One can then attempt a different encoding, if desired (or simply leave the
+byte string as a raw sequence of bytes for use in binary protocols):
+</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; b.decode('latin-1')
+'h&#233;llo w&#195;&#182;rld'
+</pre></div>
+
+<p>
+Note, however, that text strings containing surrogate characters are rejected
+with the default <tt>strict</tt> codec error handler. For example:
+</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; with open('test', 'w') as f:
+...     print(s, file=f)
+...
+Traceback (most recent call last):
+  File "&lt;stdin&gt;", line 2, in &lt;module&gt;
+UnicodeEncodeError: 'utf-8' codec can't encode character '\udce9' in position 1: surrogates not allowed
+</pre></div>
+
+<p>
+This requires the user to check most strings returned by SWIG bindings, but
+the alternative is for a non-UTF8 byte string to be completely inaccessible
+in Python 3 code.
+</p>
+
+<p>
+For more details about the <tt>surrogateescape</tt> error handler, please see
+<a href="http://www.python.org/dev/peps/pep-0383/">PEP 383</a>.
+</p>
+
 </body>
 </html>
 
diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html
index ce9523c..5de390e 100644
--- a/Doc/Manual/R.html
+++ b/Doc/Manual/R.html
@@ -6,7 +6,7 @@
 </head>
 
 <body bgcolor="#ffffff">
-<H1><a name="R"></a>36 SWIG and R</H1>
+<H1><a name="R"></a>37 SWIG and R</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -33,7 +33,7 @@
 with gcc. The R bindings also work on Microsoft Windows using Visual C++.
 </p>
 
-<H2><a name="R_nn2"></a>36.1 Bugs</H2>
+<H2><a name="R_nn2"></a>37.1 Bugs</H2>
 
 
 <p>
@@ -45,7 +45,7 @@
 <li>C Array wrappings
 </ul>
 
-<H2><a name="R_nn3"></a>36.2 Using R and SWIG</H2>
+<H2><a name="R_nn3"></a>37.2 Using R and SWIG</H2>
 
 
 <p>
@@ -119,7 +119,7 @@
 These two files can be loaded in any order
 </p>
 
-<H2><a name="R_nn4"></a>36.3 Precompiling large R files</H2>
+<H2><a name="R_nn4"></a>37.3 Precompiling large R files</H2>
 
 
 In cases where the R file is large, one make save a lot of loading
@@ -137,7 +137,7 @@
 
 
 
-<H2><a name="R_nn5"></a>36.4 General policy</H2>
+<H2><a name="R_nn5"></a>37.4 General policy</H2>
 
 
 <p>
@@ -146,7 +146,7 @@
 to provide R syntax.
 </p>
 
-<H2><a name="R_language_conventions"></a>36.5 Language conventions</H2>
+<H2><a name="R_language_conventions"></a>37.5 Language conventions</H2>
 
 
 <p>
@@ -155,7 +155,7 @@
 slices)
 </p>
 
-<H2><a name="R_nn6"></a>36.6 C++ classes</H2>
+<H2><a name="R_nn6"></a>37.6 C++ classes</H2>
 
 
 <p>
@@ -167,7 +167,7 @@
 of the proxy class baggage you see in other languages.
 </p>
 
-<H2><a name="R_nn7"></a>36.7 Enumerations</H2>
+<H2><a name="R_nn7"></a>37.7 Enumerations</H2>
 
 
 <p>
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html
index 9719239..e78447b 100644
--- a/Doc/Manual/Ruby.html
+++ b/Doc/Manual/Ruby.html
@@ -7,7 +7,7 @@
 
 <body bgcolor="#ffffff">
 
-<H1><a name="Ruby"></a>37 SWIG and Ruby</H1>
+<H1><a name="Ruby"></a>38 SWIG and Ruby</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -144,10 +144,10 @@
 
 <p>This chapter describes SWIG's support of Ruby.</p>
 
-<H2><a name="Ruby_nn2"></a>37.1 Preliminaries</H2>
+<H2><a name="Ruby_nn2"></a>38.1 Preliminaries</H2>
 
 
-<p> SWIG 1.3 is known to work with Ruby versions 1.6 and later.
+<p> SWIG 3.0 is known to work with Ruby versions 1.8 and later.
 Given the choice, you should use the latest stable version of Ruby. You
 should also determine if your system supports shared libraries and
 dynamic loading. SWIG will work with or without dynamic loading, but
@@ -159,7 +159,7 @@
 chapter. It is also assumed that the reader has a basic understanding
 of Ruby. </p>
 
-<H3><a name="Ruby_nn3"></a>37.1.1 Running SWIG</H3>
+<H3><a name="Ruby_nn3"></a>38.1.1 Running SWIG</H3>
 
 
 <p> To build a Ruby module, run SWIG using the <tt>-ruby</tt>
@@ -183,7 +183,7 @@
 build a Ruby extension module. To finish building the module, you need
 to compile this file and link it with the rest of your program. </p>
 
-<H3><a name="Ruby_nn4"></a>37.1.2 Getting the right header files</H3>
+<H3><a name="Ruby_nn4"></a>38.1.2 Getting the right header files</H3>
 
 
 <p> In order to compile the wrapper code, the compiler needs the <tt>ruby.h</tt>
@@ -191,7 +191,7 @@
 
 <div class="code shell diagram">
 <pre>/usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h
-/usr/local/lib/ruby/1.6/i686-linux/ruby.h
+/usr/include/ruby-2.1.0/ruby.h
 </pre>
 </div>
 
@@ -201,12 +201,18 @@
 
 <div class="code shell">
 <pre>$ ruby -e 'puts $:.join("\n")'
-/usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
-/usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .
+/usr/local/lib/site_ruby/2.1.0
+/usr/local/lib/x86_64-linux-gnu/site_ruby
+/usr/local/lib/site_ruby
+/usr/lib/ruby/vendor_ruby/2.1.0
+/usr/lib/x86_64-linux-gnu/ruby/vendor_ruby/2.1.0
+/usr/lib/ruby/vendor_ruby
+/usr/lib/ruby/2.1.0
+/usr/lib/x86_64-linux-gnu/ruby/2.1.0
 </pre>
 </div>
 
-<H3><a name="Ruby_nn5"></a>37.1.3 Compiling a dynamic module</H3>
+<H3><a name="Ruby_nn5"></a>38.1.3 Compiling a dynamic module</H3>
 
 
 <p> Ruby extension modules are typically compiled into shared
@@ -260,7 +266,7 @@
 <div class="code shell">
 <pre>$ swig -ruby example.i
 $ gcc -O2 -fPIC -c example.c
-$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
+$ gcc -O2 -fPIC -c example_wrap.c -I/usr/include/ruby-2.1.0
 $ gcc -shared example.o example_wrap.o -o example.so
 </pre>
 </div>
@@ -279,7 +285,7 @@
 of options. You might also check the <a href="http://www.dabeaz.com/cgi-bin/wiki.pl">SWIG Wiki</a>
 for additional information. </p>
 
-<H3><a name="Ruby_nn6"></a>37.1.4 Using your module</H3>
+<H3><a name="Ruby_nn6"></a>38.1.4 Using your module</H3>
 
 
 <p> Ruby <i>module</i> names must be capitalized,
@@ -309,7 +315,7 @@
 <p> will result in an extension module using the feature name
 "example" and Ruby module name "Example". </p>
 
-<H3><a name="Ruby_nn7"></a>37.1.5 Static linking</H3>
+<H3><a name="Ruby_nn7"></a>38.1.5 Static linking</H3>
 
 
 <p> An alternative approach to dynamic linking is to rebuild the
@@ -324,7 +330,7 @@
 file, adding your directory to the list of extensions in the file, and
 finally rebuilding Ruby. </p>
 
-<H3><a name="Ruby_nn8"></a>37.1.6 Compilation of C++ extensions</H3>
+<H3><a name="Ruby_nn8"></a>38.1.6 Compilation of C++ extensions</H3>
 
 
 <p> On most machines, C++ extension modules should be linked
@@ -334,7 +340,7 @@
 <pre>
 $ swig -c++ -ruby example.i
 $ g++ -fPIC -c example.cxx
-$ g++ -fPIC -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
+$ g++ -fPIC -c example_wrap.cxx -I/usr/include/ruby-2.1.0
 $ g++ -shared example.o example_wrap.o -o example.so
 </pre>
 </div>
@@ -356,7 +362,7 @@
 create_makefile('example')</pre>
 </div>
 
-<H2><a name="Ruby_nn9"></a>37.2 Building Ruby Extensions under Windows 95/NT</H2>
+<H2><a name="Ruby_nn9"></a>38.2 Building Ruby Extensions under Windows 95/NT</H2>
 
 
 <p> Building a SWIG extension to Ruby under Windows 95/NT is
@@ -381,7 +387,7 @@
 distribution to the Ruby package, as you will need the Ruby header
 files. </p>
 
-<H3><a name="Ruby_nn10"></a>37.2.1 Running SWIG from Developer Studio</H3>
+<H3><a name="Ruby_nn10"></a>38.2.1 Running SWIG from Developer Studio</H3>
 
 
 <p> If you are developing your application within Microsoft
@@ -445,13 +451,13 @@
 </pre>
 </div>
 
-<H2><a name="Ruby_nn11"></a>37.3 The Ruby-to-C/C++ Mapping</H2>
+<H2><a name="Ruby_nn11"></a>38.3 The Ruby-to-C/C++ Mapping</H2>
 
 
 <p> This section describes the basics of how SWIG maps C or C++
 declarations in your SWIG interface files to Ruby constructs. </p>
 
-<H3><a name="Ruby_nn12"></a>37.3.1 Modules</H3>
+<H3><a name="Ruby_nn12"></a>38.3.1 Modules</H3>
 
 
 <p> The SWIG <tt>%module</tt> directive specifies
@@ -523,7 +529,7 @@
 names of your constants, classes and methods don't conflict with any of
 Ruby's built-in names. </p>
 
-<H3><a name="Ruby_nn13"></a>37.3.2 Functions</H3>
+<H3><a name="Ruby_nn13"></a>38.3.2 Functions</H3>
 
 
 <p> Global functions are wrapped as Ruby module methods. For
@@ -557,7 +563,7 @@
 24</pre>
 </div>
 
-<H3><a name="Ruby_nn14"></a>37.3.3 Variable Linking</H3>
+<H3><a name="Ruby_nn14"></a>38.3.3 Variable Linking</H3>
 
 
 <p> C/C++ global variables are wrapped as a pair of singleton
@@ -619,7 +625,7 @@
 effect until it is explicitly disabled using <tt>%mutable</tt>.
 </p>
 
-<H3><a name="Ruby_nn15"></a>37.3.4 Constants</H3>
+<H3><a name="Ruby_nn15"></a>38.3.4 Constants</H3>
 
 
 <p> C/C++ constants are wrapped as module constants initialized
@@ -647,7 +653,7 @@
 3.14159</pre>
 </div>
 
-<H3><a name="Ruby_nn16"></a>37.3.5 Pointers</H3>
+<H3><a name="Ruby_nn16"></a>38.3.5 Pointers</H3>
 
 
 <p> "Opaque" pointers to arbitrary C/C++ types (i.e. types that
@@ -671,7 +677,7 @@
 <p> A <tt>NULL</tt> pointer is always represented by
 the Ruby <tt>nil</tt> object. </p>
 
-<H3><a name="Ruby_nn17"></a>37.3.6 Structures</H3>
+<H3><a name="Ruby_nn17"></a>38.3.6 Structures</H3>
 
 
 <p> C/C++ structs are wrapped as Ruby classes, with accessor
@@ -685,7 +691,7 @@
 </div>
 
 <p> gets wrapped as a <tt>Vector</tt> class, with
-Ruby instance methods <tt>x</tt>, <tt> x=</tt>,
+Ruby instance methods <tt>x</tt>, <tt>x=</tt>,
 <tt>y</tt> and <tt>y=</tt>. These methods can
 be used to access structure data from Ruby as follows: </p>
 
@@ -776,7 +782,7 @@
 }</pre>
 </div>
 
-<H3><a name="Ruby_nn18"></a>37.3.7 C++ classes</H3>
+<H3><a name="Ruby_nn18"></a>38.3.7 C++ classes</H3>
 
 
 <p> Like structs, C++ classes are wrapped by creating a new Ruby
@@ -831,7 +837,7 @@
 3</pre>
 </div>
 
-<H3><a name="Ruby_nn19"></a>37.3.8 C++ Inheritance</H3>
+<H3><a name="Ruby_nn19"></a>38.3.8 C++ Inheritance</H3>
 
 
 <p> The SWIG type-checker is fully aware of C++ inheritance.
@@ -984,7 +990,7 @@
 (i.e. they exhibit <a href="http://c2.com/cgi/wiki?DuckTyping">"Duck
 Typing"</a>). </p>
 
-<H3><a name="Ruby_nn20"></a>37.3.9 C++ Overloaded Functions</H3>
+<H3><a name="Ruby_nn20"></a>38.3.9 C++ Overloaded Functions</H3>
 
 
 <p> C++ overloaded functions, methods, and constructors are
@@ -1074,7 +1080,7 @@
 <p>Please refer to the <a href="SWIGPlus.html#SWIGPlus">"SWIG
 and C++"</a> chapter for more information about overloading. </p>
 
-<H3><a name="Ruby_nn21"></a>37.3.10 C++ Operators</H3>
+<H3><a name="Ruby_nn21"></a>38.3.10 C++ Operators</H3>
 
 
 <p> For the most part, overloaded operators are handled
@@ -1116,7 +1122,7 @@
 is discussed in the <a href="#Ruby_operator_overloading">section
 on operator overloading</a>. </p>
 
-<H3><a name="Ruby_nn22"></a>37.3.11 C++ namespaces</H3>
+<H3><a name="Ruby_nn22"></a>38.3.11 C++ namespaces</H3>
 
 
 <p> SWIG is aware of C++ namespaces, but namespace names do not
@@ -1173,7 +1179,7 @@
 program utilizes thousands of small deeply nested namespaces each with
 identical symbol names, well, then you get what you deserve. </p>
 
-<H3><a name="Ruby_nn23"></a>37.3.12 C++ templates</H3>
+<H3><a name="Ruby_nn23"></a>38.3.12 C++ templates</H3>
 
 
 <p> C++ templates don't present a huge problem for SWIG. However,
@@ -1215,7 +1221,7 @@
 4</pre>
 </div>
 
-<H3><a name="Ruby_nn23_1"></a>37.3.13 C++ Standard Template Library (STL)</H3>
+<H3><a name="Ruby_nn23_1"></a>38.3.13 C++ Standard Template Library (STL)</H3>
 
 
 <p> On a related note, the standard SWIG library contains a
@@ -1308,12 +1314,12 @@
 shown in these examples. More details can be found in the <a href="SWIGPlus.html#SWIGPlus">SWIG and C++</a>
 chapter.</p>
 
-<H3><a name="Ruby_C_STL_Functors"></a>37.3.14 C++ STL Functors</H3>
+<H3><a name="Ruby_C_STL_Functors"></a>38.3.14 C++ STL Functors</H3>
 
 
 <p>Some containers in the STL allow you to modify their default
 behavior by using so called functors or function objects.
-Functors are often just a very simple struct with<tt> operator()</tt>
+Functors are often just a very simple struct with <tt>operator()</tt>
 redefined or an actual C/C++ function. This allows you, for
 example, to always keep the sort order of a STL container to your
 liking.</p>
@@ -1327,7 +1333,7 @@
 <tt>std::multiset</tt>
 and <tt>std::multimap</tt>.</p>
 
-<p>The functors in swig are called<tt> swig::UnaryFunction</tt>
+<p>The functors in swig are called <tt>swig::UnaryFunction</tt>
 and <tt>swig::BinaryFunction</tt>.
 
 For C++ predicates (ie. functors that must return bool as a result) <tt>swig::UnaryPredicate</tt>
@@ -1369,7 +1375,7 @@
 </pre>
 </div>
 
-<H3><a name="Ruby_C_Iterators"></a>37.3.15 C++ STL Iterators</H3>
+<H3><a name="Ruby_C_Iterators"></a>38.3.15 C++ STL Iterators</H3>
 
 
 <p>The STL is well known for the use of iterators. There
@@ -1380,8 +1386,8 @@
 modify the values.</p>
 
 <p>The Ruby STL wrappings support both type of iterators by using
-a proxy class in-between. This proxy class is <tt>swig::Iterator or
-swig::ConstIterator. </tt> Derived from them are template
+a proxy class in-between. This proxy class is <tt>swig::Iterator</tt> or
+<tt>swig::ConstIterator</tt>. Derived from them are template
 classes that need to be initialized with the actual iterator for the
 container you are wrapping and often times with the beginning and
 ending points of the iteration range.</p>
@@ -1450,9 +1456,9 @@
 </pre>
 </div>
 
-<p>If you'd rather have STL classes without any iterators, you should define<tt> -DSWIG_NO_EXPORT_ITERATOR_METHODS </tt>when running swig.</p>
+<p>If you'd rather have STL classes without any iterators, you should define <tt>-DSWIG_NO_EXPORT_ITERATOR_METHODS</tt> when running swig.</p>
 
-<H3><a name="Ruby_nn24"></a>37.3.16 C++ Smart Pointers</H3>
+<H3><a name="Ruby_nn24"></a>38.3.16 C++ Smart Pointers</H3>
 
 
 <p> In certain C++ programs, it is common to use classes that
@@ -1517,7 +1523,7 @@
 <pre>irb(main):004:0&gt; <b>f = p.__deref__()</b> # Returns underlying Foo *</pre>
 </div>
 
-<H3><a name="Ruby_nn25"></a>37.3.17 Cross-Language Polymorphism</H3>
+<H3><a name="Ruby_nn25"></a>38.3.17 Cross-Language Polymorphism</H3>
 
 
 <p> SWIG's Ruby module supports cross-language polymorphism
@@ -1526,7 +1532,7 @@
 section just notes the differences that you need to be aware of when
 using this feature with Ruby. </p>
 
-<H4><a name="Ruby_nn26"></a>37.3.17.1 Exception Unrolling</H4>
+<H4><a name="Ruby_nn26"></a>38.3.17.1 Exception Unrolling</H4>
 
 
 <p> Whenever a C++ director class routes one of its virtual
@@ -1549,7 +1555,7 @@
 function from Ruby's C API. If any Ruby exception is raised, it will be
 caught here and a C++ exception is raised in its place. </p>
 
-<H2><a name="Ruby_nn27"></a>37.4 Naming</H2>
+<H2><a name="Ruby_nn27"></a>38.4 Naming</H2>
 
 
 <p>Ruby has several common naming conventions. Constants are
@@ -1587,7 +1593,7 @@
 by SWIG, it is turned off by default in SWIG 1.3.28. However, it is
 planned to become the default option in future releases.</p>
 
-<H3><a name="Ruby_nn28"></a>37.4.1 Defining Aliases</H3>
+<H3><a name="Ruby_nn28"></a>38.4.1 Defining Aliases</H3>
 
 
 <p> It's a fairly common practice in the Ruby built-ins and
@@ -1657,7 +1663,7 @@
 on <a href="Customization.html#Customization">"Customization
 Features"</a>) for more details).</p>
 
-<H3><a name="Ruby_nn29"></a>37.4.2 Predicate Methods</H3>
+<H3><a name="Ruby_nn29"></a>38.4.2 Predicate Methods</H3>
 
 
 <p> Ruby methods that return a boolean value and end in a
@@ -1706,7 +1712,7 @@
 used for other kinds of features apply (see the chapter on <a href="Customization.html#Customization">"Customization
 Features"</a>) for more details). </p>
 
-<H3><a name="Ruby_nn30"></a>37.4.3 Bang Methods</H3>
+<H3><a name="Ruby_nn30"></a>38.4.3 Bang Methods</H3>
 
 
 <p> Ruby methods that modify an object in-place and end in an
@@ -1738,7 +1744,7 @@
 used for other kinds of features apply (see the chapter on <a href="Customization.html#Customization">"Customization
 Features"</a>) for more details). </p>
 
-<H3><a name="Ruby_nn31"></a>37.4.4 Getters and Setters</H3>
+<H3><a name="Ruby_nn31"></a>38.4.4 Getters and Setters</H3>
 
 
 <p> Often times a C++ library will expose properties through
@@ -1773,7 +1779,7 @@
 %rename("value=") Foo::setValue(int value);</pre>
 </div>
 
-<H2><a name="Ruby_nn32"></a>37.5 Input and output parameters</H2>
+<H2><a name="Ruby_nn32"></a>38.5 Input and output parameters</H2>
 
 
 <p> A common problem in some C programs is handling parameters
@@ -1912,10 +1918,10 @@
 <pre>r, c = Example.get_dimensions(m)</pre>
 </div>
 
-<H2><a name="Ruby_nn33"></a>37.6 Exception handling </H2>
+<H2><a name="Ruby_nn33"></a>38.6 Exception handling </H2>
 
 
-<H3><a name="Ruby_nn34"></a>37.6.1 Using the %exception directive </H3>
+<H3><a name="Ruby_nn34"></a>38.6.1 Using the %exception directive </H3>
 
 
 <p>The SWIG <tt>%exception</tt> directive can be
@@ -2024,7 +2030,7 @@
 limited to C++ exception handling. See the chapter on <a href="Customization.html#Customization">Customization
 Features</a> for more examples.</p>
 
-<H3><a name="Ruby_nn34_2"></a>37.6.2 Handling Ruby Blocks </H3>
+<H3><a name="Ruby_nn34_2"></a>38.6.2 Handling Ruby Blocks </H3>
 
 
 <p>One of the highlights of Ruby and most of its standard library
@@ -2091,7 +2097,7 @@
 
 <p>For more information on typemaps, see <a href="#Ruby_nn37">Typemaps</a>.</p>
 
-<H3><a name="Ruby_nn35"></a>37.6.3 Raising exceptions </H3>
+<H3><a name="Ruby_nn35"></a>38.6.3 Raising exceptions </H3>
 
 
 <p>There are three ways to raise exceptions from C++ code to
@@ -2248,7 +2254,7 @@
 is the exception type. You can raise a custom exception type or one of
 the built-in Ruby exception types.</p>
 
-<H3><a name="Ruby_nn36"></a>37.6.4 Exception classes </H3>
+<H3><a name="Ruby_nn36"></a>38.6.4 Exception classes </H3>
 
 
 <p>Starting with SWIG 1.3.28, the Ruby module supports the <tt>%exceptionclass</tt>
@@ -2285,7 +2291,7 @@
 <p>For another example look at swig/Examples/ruby/exception_class.
 </p>
 
-<H2><a name="Ruby_nn37"></a>37.7 Typemaps</H2>
+<H2><a name="Ruby_nn37"></a>38.7 Typemaps</H2>
 
 
 <p> This section describes how you can modify SWIG's default
@@ -2300,7 +2306,7 @@
 in most cases. Typemaps are only used if you want to change some aspect
 of the primitive C-Ruby interface.</p>
 
-<H3><a name="Ruby_nn38"></a>37.7.1 What is a typemap?</H3>
+<H3><a name="Ruby_nn38"></a>38.7.1 What is a typemap?</H3>
 
 
 <p> A typemap is nothing more than a code generation rule that is
@@ -2457,7 +2463,7 @@
 2</pre>
 </div>
 
-<H3><a name="Ruby_Typemap_scope"></a>37.7.2 Typemap scope</H3>
+<H3><a name="Ruby_Typemap_scope"></a>38.7.2 Typemap scope</H3>
 
 
 <p> Once defined, a typemap remains in effect for all of the
@@ -2503,7 +2509,7 @@
 };</pre>
 </div>
 
-<H3><a name="Ruby_Copying_a_typemap"></a>37.7.3 Copying a typemap</H3>
+<H3><a name="Ruby_Copying_a_typemap"></a>38.7.3 Copying a typemap</H3>
 
 
 <p> A typemap is copied by using assignment. For example:</p>
@@ -2545,7 +2551,7 @@
 %apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments</pre>
 </div>
 
-<H3><a name="Ruby_Deleting_a_typemap"></a>37.7.4 Deleting a typemap</H3>
+<H3><a name="Ruby_Deleting_a_typemap"></a>38.7.4 Deleting a typemap</H3>
 
 
 <p> A typemap can be deleted by simply defining no code. For
@@ -2570,7 +2576,7 @@
 will make that type unusable unless you also define a new set of
 typemaps immediately after the clear operation.</p>
 
-<H3><a name="Ruby_Placement_of_typemaps"></a>37.7.5 Placement of typemaps</H3>
+<H3><a name="Ruby_Placement_of_typemaps"></a>38.7.5 Placement of typemaps</H3>
 
 
 <p> Typemap declarations can be declared in the global scope,
@@ -2641,13 +2647,13 @@
 string</tt>
 .</p>
 
-<H3><a name="Ruby_nn39"></a>37.7.6 Ruby typemaps</H3>
+<H3><a name="Ruby_nn39"></a>38.7.6 Ruby typemaps</H3>
 
 
 <p>The following list details all of the typemap methods that
 can be used by the Ruby module: </p>
 
-<H4><a name="Ruby_in_typemap"></a>37.7.6.1 "in" typemap</H4>
+<H4><a name="Ruby_in_typemap"></a>38.7.6.1 "in" typemap</H4>
 
 
 <p>Converts Ruby objects to input
@@ -2714,7 +2720,7 @@
 
 <p> At this time, only zero or one arguments may be converted.</p>
 
-<H4><a name="Ruby_typecheck_typemap"></a>37.7.6.2 "typecheck" typemap</H4>
+<H4><a name="Ruby_typecheck_typemap"></a>38.7.6.2 "typecheck" typemap</H4>
 
 
 <p> The "typecheck" typemap is used to support overloaded
@@ -2736,7 +2742,7 @@
 "typecheck" typemaps. More details about this follow in a later section
 on "Typemaps and Overloading."</p>
 
-<H4><a name="Ruby_out_typemap"></a>37.7.6.3 "out" typemap</H4>
+<H4><a name="Ruby_out_typemap"></a>38.7.6.3 "out" typemap</H4>
 
 
 <p>Converts return value of a C function
@@ -2787,7 +2793,7 @@
 </table>
 </div>
 
-<H4><a name="Ruby_arginit_typemap"></a>37.7.6.4 "arginit" typemap</H4>
+<H4><a name="Ruby_arginit_typemap"></a>38.7.6.4 "arginit" typemap</H4>
 
 
 <p> The "arginit" typemap is used to set the initial value of a
@@ -2802,7 +2808,7 @@
 }</pre>
 </div>
 
-<H4><a name="Ruby_default_typemap"></a>37.7.6.5 "default" typemap</H4>
+<H4><a name="Ruby_default_typemap"></a>38.7.6.5 "default" typemap</H4>
 
 
 <p> The "default" typemap is used to turn an argument into a
@@ -2823,11 +2829,11 @@
 the value specified by this typemap as all arguments must be given.</p>
 
 <p> Once a default typemap has been applied to an argument, all
-arguments that follow must have default values. See the <a href="http://www.swig.org/Doc1.3/SWIGDocumentation.html#SWIG_default_args">
+arguments that follow must have default values. See the <a href="SWIG.html#SWIG_default_args">
 Default/optional arguments</a> section for further information on
 default argument wrapping.</p>
 
-<H4><a name="Ruby_check_typemap"></a>37.7.6.6 "check" typemap</H4>
+<H4><a name="Ruby_check_typemap"></a>38.7.6.6 "check" typemap</H4>
 
 
 <p> The "check" typemap is used to supply value checking code
@@ -2842,7 +2848,7 @@
 }</pre>
 </div>
 
-<H4><a name="Ruby_argout_typemap_"></a>37.7.6.7 "argout" typemap</H4>
+<H4><a name="Ruby_argout_typemap_"></a>38.7.6.7 "argout" typemap</H4>
 
 
 <p> The "argout" typemap is used to return values from arguments.
@@ -2896,7 +2902,7 @@
 
 <p> See the <tt>typemaps.i</tt> library for examples.</p>
 
-<H4><a name="Ruby_freearg_typemap_"></a>37.7.6.8 "freearg" typemap</H4>
+<H4><a name="Ruby_freearg_typemap_"></a>38.7.6.8 "freearg" typemap</H4>
 
 
 <p> The "freearg" typemap is used to cleanup argument data. It is
@@ -2923,7 +2929,7 @@
 that may be used in other typemaps whenever a wrapper function needs to
 abort prematurely.</p>
 
-<H4><a name="Ruby_newfree_typemap"></a>37.7.6.9 "newfree" typemap</H4>
+<H4><a name="Ruby_newfree_typemap"></a>38.7.6.9 "newfree" typemap</H4>
 
 
 <p> The "newfree" typemap is used in conjunction with the <tt>%newobject</tt>
@@ -2947,7 +2953,7 @@
 <p> See <a href="Customization.html#Customization_ownership">Object
 ownership and %newobject</a> for further details.</p>
 
-<H4><a name="Ruby_memberin_typemap"></a>37.7.6.10 "memberin" typemap</H4>
+<H4><a name="Ruby_memberin_typemap"></a>38.7.6.10 "memberin" typemap</H4>
 
 
 <p> The "memberin" typemap is used to copy data from<em> an
@@ -2965,21 +2971,21 @@
 already provides a default implementation for arrays, strings, and
 other objects.</p>
 
-<H4><a name="Ruby_varin_typemap"></a>37.7.6.11 "varin" typemap</H4>
+<H4><a name="Ruby_varin_typemap"></a>38.7.6.11 "varin" typemap</H4>
 
 
 <p> The "varin" typemap is used to convert objects in the target
 language to C for the purposes of assigning to a C/C++ global variable.
 This is implementation specific.</p>
 
-<H4><a name="Ruby_varout_typemap_"></a>37.7.6.12 "varout" typemap</H4>
+<H4><a name="Ruby_varout_typemap_"></a>38.7.6.12 "varout" typemap</H4>
 
 
 <p> The "varout" typemap is used to convert a C/C++ object to an
 object in the target language when reading a C/C++ global variable.
 This is implementation specific.</p>
 
-<H4><a name="Ruby_throws_typemap"></a>37.7.6.13 "throws" typemap</H4>
+<H4><a name="Ruby_throws_typemap"></a>38.7.6.13 "throws" typemap</H4>
 
 
 <p> The "throws" typemap is only used when SWIG parses a C++
@@ -3017,10 +3023,10 @@
 
 <p> Note that if your methods do not have an exception
 specification yet they do throw exceptions, SWIG cannot know how to
-deal with them. For a neat way to handle these, see the <a href="http://www.swig.org/Doc1.3/SWIGDocumentation.html#exception">Exception
+deal with them. For a neat way to handle these, see the <a href="Customization.html#Customization_exception">Exception
 handling with %exception</a> section.</p>
 
-<H4><a name="Ruby_directorin_typemap"></a>37.7.6.14 directorin typemap</H4>
+<H4><a name="Ruby_directorin_typemap"></a>38.7.6.14 directorin typemap</H4>
 
 
 <p>Converts C++ objects in director
@@ -3079,7 +3085,7 @@
 </table>
 </div>
 
-<H4><a name="Ruby_directorout_typemap"></a>37.7.6.15 directorout typemap</H4>
+<H4><a name="Ruby_directorout_typemap"></a>38.7.6.15 directorout typemap</H4>
 
 
 <p>Converts Ruby objects in director
@@ -3152,7 +3158,7 @@
 
 </p>
 
-<H4><a name="Ruby_directorargout_typemap"></a>37.7.6.16 directorargout typemap</H4>
+<H4><a name="Ruby_directorargout_typemap"></a>38.7.6.16 directorargout typemap</H4>
 
 
 <p>Output argument processing in director
@@ -3210,19 +3216,19 @@
 </table>
 </div>
 
-<H4><a name="Ruby_ret_typemap"></a>37.7.6.17 ret typemap</H4>
+<H4><a name="Ruby_ret_typemap"></a>38.7.6.17 ret typemap</H4>
 
 
 <p>Cleanup of function return values
 </p>
 
-<H4><a name="Ruby_globalin_typemap"></a>37.7.6.18 globalin typemap</H4>
+<H4><a name="Ruby_globalin_typemap"></a>38.7.6.18 globalin typemap</H4>
 
 
 <p>Setting of C global variables
 </p>
 
-<H3><a name="Ruby_nn40"></a>37.7.7 Typemap variables</H3>
+<H3><a name="Ruby_nn40"></a>38.7.7 Typemap variables</H3>
 
 
 <p>
@@ -3272,7 +3278,7 @@
 <div class="indent">The Ruby name of the wrapper function
 being created. </div>
 
-<H3><a name="Ruby_nn41"></a>37.7.8 Useful Functions</H3>
+<H3><a name="Ruby_nn41"></a>38.7.8 Useful Functions</H3>
 
 
 <p> When you write a typemap, you usually have to work directly
@@ -3287,7 +3293,7 @@
 That should help you avoid having to rewrite a lot of typemaps
 across multiple languages.</p>
 
-<H4><a name="Ruby_nn42"></a>37.7.8.1 C Datatypes to Ruby Objects</H4>
+<H4><a name="Ruby_nn42"></a>38.7.8.1 C Datatypes to Ruby Objects</H4>
 
 
 <div class="diagram">
@@ -3329,7 +3335,7 @@
 </table>
 </div>
 
-<H4><a name="Ruby_nn43"></a>37.7.8.2 Ruby Objects to C Datatypes</H4>
+<H4><a name="Ruby_nn43"></a>38.7.8.2 Ruby Objects to C Datatypes</H4>
 
 
 <p>Here, while the Ruby versions return the value directly, the SWIG
@@ -3397,7 +3403,7 @@
 </table>
 </div>
 
-<H4><a name="Ruby_nn44"></a>37.7.8.3 Macros for VALUE</H4>
+<H4><a name="Ruby_nn44"></a>38.7.8.3 Macros for VALUE</H4>
 
 
 <p> <tt>RSTRING_LEN(str)</tt> </p>
@@ -3420,7 +3426,7 @@
 
 <div class="indent">pointer to array storage</div>
 
-<H4><a name="Ruby_nn45"></a>37.7.8.4 Exceptions</H4>
+<H4><a name="Ruby_nn45"></a>38.7.8.4 Exceptions</H4>
 
 
 <p> <tt>void rb_raise(VALUE exception, const char *fmt,
@@ -3499,7 +3505,7 @@
 flag. The given format string <i>fmt</i> and remaining
 arguments are interpreted as with <tt>printf()</tt>. </div>
 
-<H4><a name="Ruby_nn46"></a>37.7.8.5 Iterators</H4>
+<H4><a name="Ruby_nn46"></a>38.7.8.5 Iterators</H4>
 
 
 <p> <tt>void rb_iter_break()</tt> </p>
@@ -3545,14 +3551,14 @@
 <div class="indent"> Equivalent to Ruby's <tt>throw</tt>.
 </div>
 
-<H3><a name="Ruby_nn47"></a>37.7.9 Typemap Examples</H3>
+<H3><a name="Ruby_nn47"></a>38.7.9 Typemap Examples</H3>
 
 
 <p> This section includes a few examples of typemaps. For more
 examples, you might look at the examples in the <tt>Example/ruby</tt>
 directory. </p>
 
-<H3><a name="Ruby_nn48"></a>37.7.10 Converting a Ruby array to a char **</H3>
+<H3><a name="Ruby_nn48"></a>38.7.10 Converting a Ruby array to a char **</H3>
 
 
 <p> A common problem in many C programs is the processing of
@@ -3617,7 +3623,7 @@
 the array, the "freearg" typemap is used to later release this memory
 after the execution of the C function. </p>
 
-<H3><a name="Ruby_nn49"></a>37.7.11 Collecting arguments in a hash</H3>
+<H3><a name="Ruby_nn49"></a>38.7.11 Collecting arguments in a hash</H3>
 
 
 <p> Ruby's solution to the "keyword arguments" capability of some
@@ -3831,7 +3837,7 @@
 program that uses the extension, can be found in the <tt>Examples/ruby/hashargs</tt>
 directory of the SWIG distribution. </p>
 
-<H3><a name="Ruby_nn50"></a>37.7.12 Pointer handling</H3>
+<H3><a name="Ruby_nn50"></a>38.7.12 Pointer handling</H3>
 
 
 <p> Occasionally, it might be necessary to convert pointer values
@@ -3890,7 +3896,7 @@
 }</pre>
 </div>
 
-<H4><a name="Ruby_nn51"></a>37.7.12.1 Ruby Datatype Wrapping</H4>
+<H4><a name="Ruby_nn51"></a>38.7.12.1 Ruby Datatype Wrapping</H4>
 
 
 <p> <tt>VALUE Data_Wrap_Struct(VALUE class, void
@@ -3917,7 +3923,7 @@
 type <i>c-type</i> from the data object <i>obj</i>
 and assigns that pointer to <i>ptr</i>. </div>
 
-<H3><a name="Ruby_nn52"></a>37.7.13 Example: STL Vector to Ruby Array</H3>
+<H3><a name="Ruby_nn52"></a>38.7.13 Example: STL Vector to Ruby Array</H3>
 
 
 <p>Another use for macros and type maps is to create a Ruby array
@@ -4009,7 +4015,7 @@
 which does much more than this. Refer to the section called
 the<a href="#Ruby_nn23_1"> C++ Standard Template Library</a>.
 
-<H2><a name="Ruby_nn65"></a>37.8 Docstring Features</H2>
+<H2><a name="Ruby_nn65"></a>38.8 Docstring Features</H2>
 
 
 <p>
@@ -4043,7 +4049,7 @@
 $ rdoc -r file_wrap.c
 </pre></div>
 
-<H3><a name="Ruby_nn66"></a>37.8.1 Module docstring</H3>
+<H3><a name="Ruby_nn66"></a>38.8.1 Module docstring</H3>
 
 
 <p>
@@ -4073,7 +4079,7 @@
 %module(docstring=DOCSTRING) xrc</pre>
 </div>
 
-<H3><a name="Ruby_nn67"></a>37.8.2 %feature("autodoc")</H3>
+<H3><a name="Ruby_nn67"></a>38.8.2 %feature("autodoc")</H3>
 
 
 <p>Since SWIG does know everything about the function it wraps,
@@ -4094,7 +4100,7 @@
 feature, described below.
 </p>
 
-<H4><a name="Ruby_nn68"></a>37.8.2.1 %feature("autodoc", "0")</H4>
+<H4><a name="Ruby_nn68"></a>38.8.2.1 %feature("autodoc", "0")</H4>
 
 
 <p>
@@ -4118,7 +4124,7 @@
   ...</pre>
 </div>
 
-<H4><a name="Ruby_autodoc1"></a>37.8.2.2 %feature("autodoc", "1")</H4>
+<H4><a name="Ruby_autodoc1"></a>38.8.2.2 %feature("autodoc", "1")</H4>
 
 
 <p>
@@ -4138,7 +4144,7 @@
   ...</pre>
 </div>
 
-<H4><a name="Ruby_autodoc2"></a>37.8.2.3 %feature("autodoc", "2")</H4>
+<H4><a name="Ruby_autodoc2"></a>38.8.2.3 %feature("autodoc", "2")</H4>
 
 
 <p>
@@ -4150,7 +4156,7 @@
 this:
 </p>
 
-<H4><a name="Ruby_feature_autodoc3"></a>37.8.2.4 %feature("autodoc", "3")</H4>
+<H4><a name="Ruby_feature_autodoc3"></a>38.8.2.4 %feature("autodoc", "3")</H4>
 
 
 <p>
@@ -4171,7 +4177,7 @@
 	bar - Bar</pre>
 </div>
 
-<H4><a name="Ruby_nn70"></a>37.8.2.5 %feature("autodoc", "docstring")</H4>
+<H4><a name="Ruby_nn70"></a>38.8.2.5 %feature("autodoc", "docstring")</H4>
 
 
 <p>
@@ -4187,7 +4193,7 @@
 void GetPosition(int* OUTPUT, int* OUTPUT);</pre>
 </div>
 
-<H3><a name="Ruby_nn71"></a>37.8.3 %feature("docstring")</H3>
+<H3><a name="Ruby_nn71"></a>38.8.3 %feature("docstring")</H3>
 
 
 <p>
@@ -4198,10 +4204,10 @@
 If an item already has an autodoc string then it is combined with the
 docstring and they are output together. </p>
 
-<H2><a name="Ruby_nn53"></a>37.9 Advanced Topics</H2>
+<H2><a name="Ruby_nn53"></a>38.9 Advanced Topics</H2>
 
 
-<H3><a name="Ruby_operator_overloading"></a>37.9.1 Operator overloading</H3>
+<H3><a name="Ruby_operator_overloading"></a>38.9.1 Operator overloading</H3>
 
 
 <p> SWIG allows operator overloading with, by using the <tt>%extend</tt>
@@ -4382,7 +4388,7 @@
 parses the expression <i>a != b</i> as <i>!(a == b)</i>.
 </p>
 
-<H3><a name="Ruby_nn55"></a>37.9.2 Creating Multi-Module Packages</H3>
+<H3><a name="Ruby_nn55"></a>38.9.2 Creating Multi-Module Packages</H3>
 
 
 <p> The chapter on <a href="Modules.html#Modules">Working
@@ -4466,7 +4472,7 @@
 <pre>$ <b>ruby extconf.rb</b>
 creating Makefile
 $ <b>make</b>
-g++ -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.7/i686-linux \
+g++ -fPIC -g -O2 -I. -I/usr/include/ruby-2.1.0 \
 -I. -c shape_wrap.cxx
 gcc -shared -L/usr/local/lib -o shape.so shape_wrap.o -L. \
 -lruby -lruby -lc</pre>
@@ -4508,7 +4514,7 @@
 5.0</pre>
 </div>
 
-<H3><a name="Ruby_nn56"></a>37.9.3 Specifying Mixin Modules</H3>
+<H3><a name="Ruby_nn56"></a>38.9.3 Specifying Mixin Modules</H3>
 
 
 <p> The Ruby language doesn't support multiple inheritance, but
@@ -4575,7 +4581,7 @@
 on <a href="Customization.html#Customization">"Customization
 Features"</a>) for more details). </p>
 
-<H2><a name="Ruby_nn57"></a>37.10 Memory Management</H2>
+<H2><a name="Ruby_nn57"></a>38.10 Memory Management</H2>
 
 
 <p>One of the most common issues in generating SWIG bindings for
@@ -4598,7 +4604,7 @@
 invoked. Clearly, developing a SWIG wrapper requires a thorough
 understanding of how the underlying library manages memory.</p>
 
-<H3><a name="Ruby_nn58"></a>37.10.1 Mark and Sweep Garbage Collector </H3>
+<H3><a name="Ruby_nn58"></a>38.10.1 Mark and Sweep Garbage Collector </H3>
 
 
 <p>Ruby uses a mark and sweep garbage collector. When the garbage
@@ -4630,7 +4636,7 @@
 C++ struct, then a "free" function must be defined that deallocates
 this memory. </p>
 
-<H3><a name="Ruby_nn59"></a>37.10.2 Object Ownership</H3>
+<H3><a name="Ruby_nn59"></a>38.10.2 Object Ownership</H3>
 
 
 <p>As described above, memory management depends on clearly
@@ -4775,7 +4781,7 @@
 
 <p> This code can be seen in swig/examples/ruby/tracking.</p>
 
-<H3><a name="Ruby_nn60"></a>37.10.3 Object Tracking</H3>
+<H3><a name="Ruby_nn60"></a>38.10.3 Object Tracking</H3>
 
 
 <p>The remaining parts of this section will use the class library
@@ -4997,10 +5003,10 @@
 <p>In general, you will only need to use the <tt>SWIG_RubyInstanceFor</tt>,
 which is required for implementing mark functions as shown below.
 However, if you implement your own free functions (see below) you may
-also have to call the<tt> SWIG_RubyRemoveTracking</tt> and <tt>RubyUnlinkObjects</tt>
+also have to call the <tt>SWIG_RubyRemoveTracking</tt> and <tt>RubyUnlinkObjects</tt>
 methods.</p>
 
-<H3><a name="Ruby_nn61"></a>37.10.4 Mark Functions</H3>
+<H3><a name="Ruby_nn61"></a>38.10.4 Mark Functions</H3>
 
 
 <p>With a bit more testing, we see that our class library still
@@ -5129,7 +5135,7 @@
 
 <p>This code can be seen in swig/examples/ruby/mark_function.</p>
 
-<H3><a name="Ruby_nn62"></a>37.10.5 Free Functions</H3>
+<H3><a name="Ruby_nn62"></a>38.10.5 Free Functions</H3>
 
 
 <p>By default, SWIG creates a "free" function that is called when
@@ -5296,7 +5302,7 @@
 
 <p>This code can be seen in swig/examples/ruby/free_function.</p>
 
-<H3><a name="Ruby_nn63"></a>37.10.6 Embedded Ruby and the C++ Stack</H3>
+<H3><a name="Ruby_nn63"></a>38.10.6 Embedded Ruby and the C++ Stack</H3>
 
 
 <p>As has been said, the Ruby GC runs and marks objects before
@@ -5351,7 +5357,7 @@
 <p>To solve the problem, SWIG can now generate code with director
 functions containing the optional macros SWIG_INIT_STACK and
 SWIG_RELEASE_STACK. These macros will try to force Ruby to
-reinitiliaze the beginning of the stack the first time a
+reinitialize the beginning of the stack the first time a
 director
 function is called. This will lead Ruby to measure and not
 collect any VALUE objects defined from that point on. </p>
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index bd929f7..4c33aea 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -138,6 +138,7 @@
 -xml                  Generate XML wrappers
 
 -c++                  Enable C++ parsing
+-cppext <em>ext</em>           Change file extension of C++ generated files to <em>ext</em> (default is cxx, except for PHP which uses cpp)
 -D<em>symbol</em>              Define a preprocessor symbol
 -Fstandard            Display error/warning messages in commonly used format
 -Fmicrosoft           Display error/warning messages in Microsoft format
@@ -146,7 +147,7 @@
 -l<em>file</em>                Include a SWIG library file.
 -module <em>name</em>          Set the name of the SWIG module
 -o <em>outfile</em>            Name of output file
--outcurrentdir	      Set default output dir to current dir instead of input file's path
+-outcurrentdir        Set default output dir to current dir instead of input file's path
 -outdir <em>dir</em>           Set language specific files output directory
 -pcreversion          Display PCRE version information
 -swiglib              Show location of SWIG library
@@ -1046,7 +1047,7 @@
 </pre></div>
 
 <p>
-In this case <tt>f1</tt>,<tt> f2</tt>, and <tt>buffer</tt> are all
+In this case <tt>f1</tt>, <tt>f2</tt>, and <tt>buffer</tt> are all
 opaque objects containing C pointers. It doesn't matter what value
 they contain--our program works just fine without this knowledge.</p>
 
@@ -1711,7 +1712,7 @@
 </pre></div>
 
 <p>
-<tt>%rename </tt>applies a renaming operation to all future
+<tt>%rename</tt> applies a renaming operation to all future
 occurrences of a name. The renaming applies to functions, variables,
 class and structure names, member functions, and member data. For
 example, if you had two-dozen C++ classes, all with a member function
@@ -3316,7 +3317,7 @@
 if the full type information is not available if it is needed, whereas
 SWIG will usually not warn or error out as it is designed to work without
 full type information. However, if type information is not specified
-correctly, the wrappers can be sub-optimal and even result in uncompileable C/C++ code.
+correctly, the wrappers can be sub-optimal and even result in uncompilable C/C++ code.
 
 <li>If your program has a main() function, you may need to rename it
 (read on).
diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
index f955899..62c0e8d 100644
--- a/Doc/Manual/SWIGPlus.html
+++ b/Doc/Manual/SWIGPlus.html
@@ -1184,15 +1184,17 @@
 </div>
 
 <p>
-This produces uncompileable wrapper code because default values in C++ are
+This produces uncompilable wrapper code because default values in C++ are
 evaluated in the same scope as the member function whereas SWIG
 evaluates them in the scope of a wrapper function (meaning that the
 values have to be public). 
 </p>
 
 <p>
-This feature is automatically turned on when wrapping <a href="SWIG.html#SWIG_default_args">C code with default arguments</a>
-and whenever keyword arguments (kwargs) are specified for either C or C++ code.
+The <tt>compactdefaultargs</tt> feature is automatically turned on when wrapping <a href="SWIG.html#SWIG_default_args">C code with default arguments</a>.
+Some target languages will also automatically turn on this feature
+if the keyword arguments feature (kwargs) is specified for either C or C++ functions, and the target language supports kwargs,
+the <tt>compactdefaultargs</tt> feature is also automatically turned on.
 Keyword arguments are a language feature of some scripting languages, for example Ruby and Python.
 SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used.
 </p>
@@ -1203,7 +1205,7 @@
 <p>
  SWIG wraps class members that are public following the C++
  conventions, i.e., by explicit public declaration or by the use of
- the <tt> using</tt> directive. In general, anything specified in a
+ the <tt>using</tt> directive. In general, anything specified in a
  private or protected section will be ignored, although the internal
  code generator sometimes looks at the contents of the private and
  protected sections so that it can properly generate code for default
@@ -2798,7 +2800,7 @@
 </pre></div>
 
 <p>
-This code adds a<tt> __str__</tt> method to our class for producing a
+This code adds a <tt>__str__</tt> method to our class for producing a
 string representation of the object. In Python, such a method would
 allow us to print the value of an object using the <tt>print</tt>
 command.
@@ -2847,12 +2849,12 @@
 
 <p>
 The following special variables are expanded if used within a %extend block: 
-$name, $symname, $overname, $decl, $fulldecl, $parentname and $parentsymname.
+$name, $symname, $overname, $decl, $fulldecl, $parentclassname and $parentclasssymname.
 The <a href="Customization.html#Customization_exception_special_variables">Special variables</a> section provides more information each of these special variables.
 </p>
 
 <p>
-The<tt> %extend</tt> directive follows all of the same conventions
+The <tt>%extend</tt> directive follows all of the same conventions
 as its use with C structures. Please refer to the <a href="SWIG.html#SWIG_adding_member_functions">Adding member functions to C structures</a>
 section for further details.
 </p>
@@ -3565,7 +3567,7 @@
 template&lt;class T&gt; class List {
     ...
     public:
-    List() { };
+    List() { }
     T get(int index);
     ...
 };
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 99d1dfe..897d274 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
 <body bgcolor="#ffffff">
 <H1><a name="Sections"></a>SWIG-3.0 Documentation</H1>
 
-Last update : SWIG-3.0.1 (in progress)
+Last update : SWIG-3.0.4 (14 Jan 2015)
 
 <H2>Sections</H2>
 
@@ -42,7 +42,7 @@
 <li><a href="Go.html#Go">Go support</a></li>
 <li><a href="Guile.html#Guile">Guile support</a></li>
 <li><a href="Java.html#Java">Java support</a></li>
-<li><a href="Javascript.html#Java">Javascript support</a></li>
+<li><a href="Javascript.html#Javascript">Javascript support</a></li>
 <li><a href="Lisp.html#Lisp">Common Lisp support</a></li>
 <li><a href="Lua.html#Lua">Lua support</a></li>
 <li><a href="Modula3.html#Modula3">Modula3 support</a></li>
diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html
index 45eebbf..45218f3 100644
--- a/Doc/Manual/Tcl.html
+++ b/Doc/Manual/Tcl.html
@@ -6,7 +6,7 @@
 </head>
 
 <body bgcolor="#ffffff">
-<H1><a name="Tcl"></a>38 SWIG and Tcl</H1>
+<H1><a name="Tcl"></a>39 SWIG and Tcl</H1>
 <!-- INDEX -->
 <div class="sectiontoc">
 <ul>
@@ -83,7 +83,7 @@
 this is no longer supported.
 </p>
 
-<H2><a name="Tcl_nn2"></a>38.1 Preliminaries</H2>
+<H2><a name="Tcl_nn2"></a>39.1 Preliminaries</H2>
 
 
 <p>
@@ -109,7 +109,7 @@
 need to compile this file and link it with the rest of your program.
 </p>
 
-<H3><a name="Tcl_nn3"></a>38.1.1 Getting the right header files</H3>
+<H3><a name="Tcl_nn3"></a>39.1.1 Getting the right header files</H3>
 
 
 <p>
@@ -127,7 +127,7 @@
 header file.
 </p>
 
-<H3><a name="Tcl_nn4"></a>38.1.2 Compiling a dynamic module</H3>
+<H3><a name="Tcl_nn4"></a>39.1.2 Compiling a dynamic module</H3>
 
 
 <p>
@@ -160,10 +160,10 @@
 name of the corresponding object file should be
 "<tt>example.so</tt>".
 The name of the module is specified using the <tt>%module</tt> directive or the 
-<tt> -module</tt> command line option.
+ <tt>-module</tt> command line option.
 </p>
 
-<H3><a name="Tcl_nn5"></a>38.1.3 Static linking</H3>
+<H3><a name="Tcl_nn5"></a>39.1.3 Static linking</H3>
 
 
 <p>
@@ -229,7 +229,7 @@
 hassle in the opinion of this author). 
 </p>
 
-<H3><a name="Tcl_nn6"></a>38.1.4 Using your module</H3>
+<H3><a name="Tcl_nn6"></a>39.1.4 Using your module</H3>
 
 
 <p>
@@ -357,7 +357,7 @@
 the man pages). 
 </p>
 
-<H3><a name="Tcl_nn7"></a>38.1.5 Compilation of C++ extensions</H3>
+<H3><a name="Tcl_nn7"></a>39.1.5 Compilation of C++ extensions</H3>
 
 
 <p>
@@ -440,7 +440,7 @@
 might want to investigate using a more formal standard such as COM.
 </p>
 
-<H3><a name="Tcl_nn8"></a>38.1.6 Compiling for 64-bit platforms</H3>
+<H3><a name="Tcl_nn8"></a>39.1.6 Compiling for 64-bit platforms</H3>
 
 
 <p>
@@ -467,7 +467,7 @@
 linking standard (e.g., -o32 and -n32 on Irix).
 </p>
 
-<H3><a name="Tcl_nn9"></a>38.1.7 Setting a package prefix</H3>
+<H3><a name="Tcl_nn9"></a>39.1.7 Setting a package prefix</H3>
 
 
 <p>
@@ -486,7 +486,7 @@
 call it "<tt>Foo_bar</tt>".
 </p>
 
-<H3><a name="Tcl_nn10"></a>38.1.8 Using namespaces</H3>
+<H3><a name="Tcl_nn10"></a>39.1.8 Using namespaces</H3>
 
 
 <p>
@@ -504,11 +504,11 @@
 </p>
 
 <p>
-When the<tt> -namespace</tt> option is used, objects in the module
+When the <tt>-namespace</tt> option is used, objects in the module
 are always accessed with the namespace name such as <tt>Foo::bar</tt>.
 </p>
 
-<H2><a name="Tcl_nn11"></a>38.2 Building Tcl/Tk Extensions under Windows 95/NT</H2>
+<H2><a name="Tcl_nn11"></a>39.2 Building Tcl/Tk Extensions under Windows 95/NT</H2>
 
 
 <p>
@@ -519,7 +519,7 @@
 although the procedure may be similar with other compilers.
 </p>
 
-<H3><a name="Tcl_nn12"></a>38.2.1 Running SWIG from Developer Studio</H3>
+<H3><a name="Tcl_nn12"></a>39.2.1 Running SWIG from Developer Studio</H3>
 
 
 <p>
@@ -577,7 +577,7 @@
 %
 </pre></div>
 
-<H3><a name="Tcl_nn13"></a>38.2.2 Using NMAKE</H3>
+<H3><a name="Tcl_nn13"></a>39.2.2 Using NMAKE</H3>
 
 
 <p>
@@ -640,7 +640,7 @@
 Tcl extensions.
 </p>
 
-<H2><a name="Tcl_nn14"></a>38.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Tcl_nn14"></a>39.3 A tour of basic C/C++ wrapping</H2>
 
 
 <p>
@@ -651,7 +651,7 @@
 wrapping.
 </p>
 
-<H3><a name="Tcl_nn15"></a>38.3.1 Modules</H3>
+<H3><a name="Tcl_nn15"></a>39.3.1 Modules</H3>
 
 
 <p>
@@ -685,7 +685,7 @@
 </pre>
 </div>
 
-<H3><a name="Tcl_nn16"></a>38.3.2 Functions</H3>
+<H3><a name="Tcl_nn16"></a>39.3.2 Functions</H3>
 
 
 <p>
@@ -710,7 +710,7 @@
 %
 </pre></div>
 
-<H3><a name="Tcl_nn17"></a>38.3.3 Global variables</H3>
+<H3><a name="Tcl_nn17"></a>39.3.3 Global variables</H3>
 
 
 <p>
@@ -790,7 +790,7 @@
 </pre>
 </div>
 
-<H3><a name="Tcl_nn18"></a>38.3.4 Constants and enums</H3>
+<H3><a name="Tcl_nn18"></a>39.3.4 Constants and enums</H3>
 
 
 <p>
@@ -874,7 +874,7 @@
 conversion.  This allows the <tt>global</tt> statement to be omitted.
 </p>
 
-<H3><a name="Tcl_nn19"></a>38.3.5 Pointers</H3>
+<H3><a name="Tcl_nn19"></a>39.3.5 Pointers</H3>
 
 
 <p>
@@ -970,7 +970,7 @@
 <tt>None</tt> if the conversion can't be performed.
 </p>
 
-<H3><a name="Tcl_nn20"></a>38.3.6 Structures</H3>
+<H3><a name="Tcl_nn20"></a>39.3.6 Structures</H3>
 
 
 <p>
@@ -1252,7 +1252,7 @@
 memory management section that appears shortly.
 </p>
 
-<H3><a name="Tcl_nn21"></a>38.3.7 C++ classes</H3>
+<H3><a name="Tcl_nn21"></a>39.3.7 C++ classes</H3>
 
 
 <p>
@@ -1283,7 +1283,7 @@
 % x insert Lager
 % x get 1
 Stout
-% puts [l cget -length]
+% puts [x cget -length]
 3
 %
 </pre></div>
@@ -1319,7 +1319,7 @@
 </pre>
 </div>
 
-<H3><a name="Tcl_nn22"></a>38.3.8 C++ inheritance</H3>
+<H3><a name="Tcl_nn22"></a>39.3.8 C++ inheritance</H3>
 
 
 <p>
@@ -1368,7 +1368,7 @@
 It is safe to use multiple inheritance with SWIG.
 </p>
 
-<H3><a name="Tcl_nn23"></a>38.3.9 Pointers, references, values, and arrays</H3>
+<H3><a name="Tcl_nn23"></a>39.3.9 Pointers, references, values, and arrays</H3>
 
 
 <p>
@@ -1422,7 +1422,7 @@
 when the return value is garbage collected).
 </p>
 
-<H3><a name="Tcl_nn24"></a>38.3.10 C++ overloaded functions</H3>
+<H3><a name="Tcl_nn24"></a>39.3.10 C++ overloaded functions</H3>
 
 
 <p>
@@ -1545,7 +1545,7 @@
 Please refer to the "SWIG and C++" chapter for more information about overloading. 
 </p>
 
-<H3><a name="Tcl_nn25"></a>38.3.11 C++ operators</H3>
+<H3><a name="Tcl_nn25"></a>39.3.11 C++ operators</H3>
 
 
 <p>
@@ -1647,7 +1647,7 @@
 Keep reading.
 </p>
 
-<H3><a name="Tcl_nn26"></a>38.3.12 C++ namespaces</H3>
+<H3><a name="Tcl_nn26"></a>39.3.12 C++ namespaces</H3>
 
 
 <p>
@@ -1711,7 +1711,7 @@
 identical symbol names, well, then you get what you deserve.
 </p>
 
-<H3><a name="Tcl_nn27"></a>38.3.13 C++ templates</H3>
+<H3><a name="Tcl_nn27"></a>39.3.13 C++ templates</H3>
 
 
 <p>
@@ -1763,7 +1763,7 @@
 examples will appear later.
 </p>
 
-<H3><a name="Tcl_nn28"></a>38.3.14 C++ Smart Pointers</H3>
+<H3><a name="Tcl_nn28"></a>39.3.14 C++ Smart Pointers</H3>
 
 
 <p>
@@ -1847,7 +1847,7 @@
 </pre>
 </div>
 
-<H2><a name="Tcl_nn29"></a>38.4 Further details on the Tcl class interface</H2>
+<H2><a name="Tcl_nn29"></a>39.4 Further details on the Tcl class interface</H2>
 
 
 <p>
@@ -1860,7 +1860,7 @@
 of how the proxy classes work.
 </p>
 
-<H3><a name="Tcl_nn30"></a>38.4.1 Proxy classes</H3>
+<H3><a name="Tcl_nn30"></a>39.4.1 Proxy classes</H3>
 
 
 <p>
@@ -1925,7 +1925,7 @@
 as shown in the last section.
 </p>
 
-<H3><a name="Tcl_nn31"></a>38.4.2 Memory management</H3>
+<H3><a name="Tcl_nn31"></a>39.4.2 Memory management</H3>
 
 
 <p>
@@ -2113,7 +2113,7 @@
 </p>
 
 
-<H2><a name="Tcl_nn32"></a>38.5 Input and output parameters</H2>
+<H2><a name="Tcl_nn32"></a>39.5 Input and output parameters</H2>
 
 
 <p>
@@ -2301,7 +2301,7 @@
 </pre>
 </div>
 
-<H2><a name="Tcl_nn33"></a>38.6 Exception handling </H2>
+<H2><a name="Tcl_nn33"></a>39.6 Exception handling </H2>
 
 
 <p>
@@ -2365,7 +2365,7 @@
     $action                // Gets substituted by actual function call
   }
   catch (RangeError) {
-    Tcl_SetStringObj(tcl_result,"Array index out-of-bounds");
+    Tcl_SetResult(interp, (char *)"Array index out-of-bounds", TCL_STATIC);
     return TCL_ERROR;
   }
 }
@@ -2384,7 +2384,7 @@
     $action
   }
   catch (RangeError) {
-    Tcl_SetStringObj(tcl_result,"Array index out-of-bounds");
+    Tcl_SetResult(interp, (char *)"Array index out-of-bounds", TCL_STATIC);
     return TCL_ERROR;
   }
 }
@@ -2394,7 +2394,7 @@
     $action
   }
   catch (RangeError) {
-    Tcl_SetStringObj(tcl_result,"Array index out-of-bounds");
+    Tcl_SetResult(interp, (char *)"Array index out-of-bounds", TCL_STATIC);
     return TCL_ERROR;
   }
 }
@@ -2419,7 +2419,7 @@
     $action
   }
   catch (RangeError) {
-    Tcl_SetStringObj(tcl_result,"Array index out-of-bounds");
+    Tcl_SetResult(interp, (char *)"Array index out-of-bounds", TCL_STATIC);
     return TCL_ERROR;
   }
 }
@@ -2435,7 +2435,7 @@
 See the chapter on "<a href="Customization.html#Customization">Customization Features</a>" for more examples.
 </p>
 
-<H2><a name="Tcl_nn34"></a>38.7 Typemaps</H2>
+<H2><a name="Tcl_nn34"></a>39.7 Typemaps</H2>
 
 
 <p>
@@ -2452,7 +2452,7 @@
 C-Tcl interface.
 </p>
 
-<H3><a name="Tcl_nn35"></a>38.7.1 What is a typemap?</H3>
+<H3><a name="Tcl_nn35"></a>39.7.1 What is a typemap?</H3>
 
 
 <p>
@@ -2569,7 +2569,7 @@
 </pre>
 </div>
 
-<H3><a name="Tcl_nn36"></a>38.7.2 Tcl typemaps</H3>
+<H3><a name="Tcl_nn36"></a>39.7.2 Tcl typemaps</H3>
 
 
 <p>
@@ -2707,7 +2707,7 @@
 Examples of these methods will appear shortly.
 </p>
 
-<H3><a name="Tcl_nn37"></a>38.7.3 Typemap variables</H3>
+<H3><a name="Tcl_nn37"></a>39.7.3 Typemap variables</H3>
 
 
 <p>
@@ -2778,7 +2778,7 @@
 The Tcl name of the wrapper function being created.
 </div>
 
-<H3><a name="Tcl_nn38"></a>38.7.4 Converting  a Tcl list to a char ** </H3>
+<H3><a name="Tcl_nn38"></a>39.7.4 Converting  a Tcl list to a char ** </H3>
 
 
 <p>
@@ -2840,7 +2840,7 @@
 3
 </pre></div>
 
-<H3><a name="Tcl_nn39"></a>38.7.5 Returning values in arguments</H3>
+<H3><a name="Tcl_nn39"></a>39.7.5 Returning values in arguments</H3>
 
 
 <p>
@@ -2882,7 +2882,7 @@
 %
 </pre></div>
 
-<H3><a name="Tcl_nn40"></a>38.7.6 Useful functions</H3>
+<H3><a name="Tcl_nn40"></a>39.7.6 Useful functions</H3>
 
 
 <p>
@@ -2921,7 +2921,6 @@
 <div class="code">
 <pre>
 Tcl_Obj  *Tcl_NewStringObj(char *str, int len);
-void      Tcl_SetStringObj(Tcl_Obj *obj, char *str, int len);
 char     *Tcl_GetStringFromObj(Tcl_Obj *obj, int *len);
 void      Tcl_AppendToObj(Tcl_Obj *obj, char *str, int len);
 </pre>
@@ -2959,7 +2958,7 @@
 </pre>
 </div>
 
-<H3><a name="Tcl_nn41"></a>38.7.7 Standard  typemaps</H3>
+<H3><a name="Tcl_nn41"></a>39.7.7 Standard  typemaps</H3>
 
 
 <p>
@@ -3037,13 +3036,14 @@
 
 <div class="code">
 <pre>
-%typemap(out) char * {
-   Tcl_SetStringObj($result,$1);
+%typemap(out,noblock=1,fragment="SWIG_FromCharPtr") char *, const char * {
+  Tcl_SetObjResult(interp,SWIG_FromCharPtr((const char *)$1));
 }
+
 </pre>
 </div>
 
-<H3><a name="Tcl_nn42"></a>38.7.8 Pointer handling</H3>
+<H3><a name="Tcl_nn42"></a>39.7.8 Pointer handling</H3>
 
 
 <p>
@@ -3119,7 +3119,7 @@
 </pre>
 </div>
 
-<H2><a name="Tcl_nn43"></a>38.8 Turning a SWIG module into a Tcl Package.</H2>
+<H2><a name="Tcl_nn43"></a>39.8 Turning a SWIG module into a Tcl Package.</H2>
 
 
 <p>
@@ -3191,7 +3191,7 @@
 to use the <tt>load</tt> command instead.
 </p>
 
-<H2><a name="Tcl_nn44"></a>38.9 Building new kinds of Tcl interfaces (in Tcl)</H2>
+<H2><a name="Tcl_nn44"></a>39.9 Building new kinds of Tcl interfaces (in Tcl)</H2>
 
 
 <p>
@@ -3290,7 +3290,7 @@
 with an out of bounds array access).
 </p>
 
-<H3><a name="Tcl_nn45"></a>38.9.1 Proxy classes</H3>
+<H3><a name="Tcl_nn45"></a>39.9.1 Proxy classes</H3>
 
 
 <p>
@@ -3411,7 +3411,7 @@
 interesting things.
 </p>
 
-<H2><a name="Tcl_nn46"></a>38.10 Tcl/Tk Stubs</H2>
+<H2><a name="Tcl_nn46"></a>39.10 Tcl/Tk Stubs</H2>
 
 
 <p>
diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
index cba5241..040244d 100644
--- a/Doc/Manual/Typemaps.html
+++ b/Doc/Manual/Typemaps.html
@@ -2050,6 +2050,22 @@
 </pre>
 </div>
 
+<p>There is an exception: if the variable name starts with the <tt>_global_</tt> prefix,
+the argument number is not appended. Such variables can be used throughout the generated
+wrapper function. For example, the above typemap could be rewritten to use <tt>_global_temp</tt>
+instead of <tt>temp</tt> and the generated code would then contain a single <tt>_global_temp</tt> variable
+instead of <tt>temp1</tt>, <tt>temp2</tt> and <tt>temp3</tt>:
+</p>
+
+<div class="code">
+<pre>
+%typemap(in) std::string * <b>(std::string _global_temp)</b> {
+ ... as above ...
+}
+</pre>
+</div>
+
+
 <p>
 Some typemaps do not recognize local variables (or they may simply not
 apply). At this time, only typemaps that apply to argument conversion support this (input typemaps such as the "in" typemap).
@@ -3360,7 +3376,7 @@
 </div>
 
 <p>
-To do this, you not only need to map a list of strings to <tt> char *argv[]</tt>, but the
+To do this, you not only need to map a list of strings to <tt>char *argv[]</tt>, but the
 value of <tt>int argc</tt> is implicitly determined by the length of the list.   Using only simple
 typemaps, this type of conversion is possible, but extremely painful.
 Multi-argument typemaps help in this situation.
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 01febf5..cdc33d0 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -14,18 +14,41 @@
 #
 # 2.   To use this makefile, set required variables, eg SRCS, INTERFACE,
 #      INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a
-#           $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \
+#           $(MAKE) -f Makefile.template.in SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
 #           INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \
 #           INTERFACEDIR='$(INTERFACEDIR)' TARGET='$(TARGET)' method
 #
 #      'method' describes what is being built.
 #---------------------------------------------------------------
 
+# Regenerate Makefile if Makefile.in or config.status have changed.
+Makefile: @srcdir@/Makefile.in ../config.status
+	cd .. && $(SHELL) ./config.status Examples/Makefile
+
+# SRCDIR is the relative path to the current source directory
+# - For in-source-tree builds, SRCDIR with be either '' or './', but
+#   '../' for the test suites that build in a subdir (e.g. C#, Java)
+# - For out-of-source-tree builds, SRCDIR will be a relative
+#   path ending with a '/'
+
+# SRCDIR_SRCS, etc. are $(SRCS), etc. with $(SRCDIR) prepended
+SRCDIR_SRCS    = $(addprefix $(SRCDIR),$(SRCS))
+SRCDIR_CSRCS   = $(addprefix $(SRCDIR),$(CSRCS))
+SRCDIR_CXXSRCS = $(addprefix $(SRCDIR),$(CXXSRCS))
+
+ifeq (,$(SRCDIR))
+SRCDIR_INCLUDE = -I.
+else
+SRCDIR_INCLUDE = -I. -I$(SRCDIR)
+endif
+
 TARGET     =
 CC         = @CC@
 CXX        = @CXX@
+CPPFLAGS   = $(SRCDIR_INCLUDE)
 CFLAGS     = @PLATCFLAGS@
 CXXFLAGS   = @BOOST_CPPFLAGS@ @PLATCXXFLAGS@
+LDFLAGS    =
 prefix     = @prefix@
 exec_prefix= @exec_prefix@
 SRCS       =
@@ -33,7 +56,7 @@
 LIBS       =
 INTERFACE  =
 INTERFACEDIR  =
-INTERFACEPATH = $(INTERFACEDIR)$(INTERFACE)
+INTERFACEPATH = $(SRCDIR)$(INTERFACEDIR)$(INTERFACE)
 SWIGOPT    =
 SWIG       = swig
 
@@ -88,7 +111,7 @@
 ##################################################################
 
 CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-             -L/usr/local/lib -lg++ -lstdc++ -lgcc
+	     -L/usr/local/lib -lg++ -lstdc++ -lgcc
 
 # Solaris workshop 5.0
 # CPP_DLLIBS = -L/opt/SUNWspro/lib -lCrun
@@ -107,6 +130,7 @@
 
 distclean:
 	rm -f Makefile
+	rm -f d/example.mk
 	rm -f xml/Makefile
 
 ##################################################################
@@ -126,39 +150,39 @@
 TCL_SO     = @TCL_SO@
 TCLLDSHARED = @TCLLDSHARED@
 TCLCXXSHARED = @TCLCXXSHARED@
-TCL_SCRIPT = $(RUNME).tcl
+TCL_SCRIPT = $(SRCDIR)$(RUNME).tcl
 
 # -----------------------------------------------------------
 # Build a new version of the tclsh shell
 # -----------------------------------------------------------
 
-tclsh: $(SRCS)
-	$(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH)
-	$(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \
+tclsh: $(SRCDIR_SRCS)
+	$(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \
 	$(TCL_LIB)  $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET)
 
-tclsh_cpp: $(SRCS)
-	$(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH)
-	$(CXX) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \
+tclsh_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \
 	$(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET)
 
 # -----------------------------------------------------------
 # Build a Tcl dynamic loadable module (you might need to tweak this)
 # -----------------------------------------------------------
 
-tcl:  $(SRCS)
-	$(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE)
-	$(TCLLDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
+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)
 
 # -----------------------------------------------------------
 # Build a Tcl7.5 dynamic loadable module for C++
 # -----------------------------------------------------------
 
-tcl_cpp: $(SRCS)
-	$(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE)
-	$(TCLCXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
+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)
 
 # -----------------------------------------------------------------
 # Run Tcl example
@@ -181,7 +205,7 @@
 tcl_clean:
 	rm -f *_wrap* *~ .~* mytclsh@EXEEXT@
 	rm -f core @EXTRA_CLEAN@
-	rm -f *.@OBJEXT@ *@SO@
+	rm -f *.@OBJEXT@ *$(TCL_SO)
 
 ##################################################################
 #####                       PERL 5                          ######
@@ -201,44 +225,44 @@
 PERL5_LDFLAGS = @PERL5LDFLAGS@
 PERL = @PERL@
 PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS)
-PERL5_SCRIPT = $(RUNME).pl
+PERL5_SCRIPT = $(SRCDIR)$(RUNME).pl
 
 # ----------------------------------------------------------------
 # Build a Perl5 dynamically loadable module (C)
 # ----------------------------------------------------------------
 
-perl5: $(SRCS)
-	$(SWIG) -perl5 $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE)
-	$(LDSHARED) $(CFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+perl5: $(SRCDIR_SRCS)
+	$(SWIG) -perl5 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c -Dbool=char $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
 # ----------------------------------------------------------------
 # Build a Perl5 dynamically loadable module (C++)
 # ----------------------------------------------------------------
 
-perl5_cpp: $(SRCS)
-	$(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE)
-	$(CXXSHARED) $(CXXFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+perl5_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -perl5 -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
 # ----------------------------------------------------------------
 # Build a module from existing XS C source code.   (ie. from xsubpp).
 # ----------------------------------------------------------------
-perl5_xs: $(SRCS)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) -I$(PERL5_INCLUDE)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(LIBS) -o $(TARGET)$(SO)
+perl5_xs: $(SRCDIR_SRCS)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(INCLUDES) -I$(PERL5_INCLUDE)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $(TARGET)$(SO)
 
 # ----------------------------------------------------------------
 # Build a statically linked Perl5 executable
 # ----------------------------------------------------------------
 
-perl5_static: $(SRCS)
-	$(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
+perl5_static: $(SRCDIR_SRCS)
+	$(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Dbool=char $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
 
-perl5_static_cpp: $(SRCS)
-	$(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
+perl5_static_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
 
 # -----------------------------------------------------------------
 # Running a Perl5 example
@@ -267,15 +291,17 @@
 #####                       PYTHON                          ######
 ##################################################################
 
+PYTHON_FLAGS =
+
 # Make sure these locate your Python installation
 ifeq (,$(PY3))
   PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@
   PYTHON_LIB    = @PYLIB@
-  PYTHON        = @PYTHON@
+  PYTHON        = @PYTHON@ $(PYTHON_FLAGS)
 else
   PYTHON_INCLUDE= $(DEFS) @PY3INCLUDE@
   PYTHON_LIB    = @PY3LIB@
-  PYTHON        = @PYTHON3@
+  PYTHON        = @PYTHON3@ $(PYTHON_FLAGS)
 endif
 
 # Extra Python specific linking options
@@ -299,19 +325,19 @@
 # Build a C dynamically loadable module
 # ----------------------------------------------------------------
 
-python: $(SRCS)
-	$(SWIGPYTHON) $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
+python: $(SRCDIR_SRCS)
+	$(SWIGPYTHON) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(PYTHON_INCLUDE)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
 
 # -----------------------------------------------------------------
 # Build a C++ dynamically loadable module
 # -----------------------------------------------------------------
 
-python_cpp: $(SRCS)
-	$(SWIGPYTHON) -c++ $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
-	$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
+python_cpp: $(SRCDIR_SRCS)
+	$(SWIGPYTHON) -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
 
 # -----------------------------------------------------------------
 # Build statically linked Python interpreter
@@ -324,14 +350,14 @@
 TKINTER =
 PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS)
 
-python_static: $(SRCS)
-	$(SWIGPYTHON) -lembed.i $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
+python_static: $(SRCDIR_SRCS)
+	$(SWIGPYTHON) -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \
 	$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
 
-python_static_cpp: $(SRCS)
-	$(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+python_static_cpp: $(SRCDIR_SRCS)
+	$(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \
 	$(PYTHON_INCLUDE) $(LIBS)  -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
 
 # -----------------------------------------------------------------
@@ -347,9 +373,15 @@
 PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
 
 python_run: $(PYSCRIPT)
+	export PYTHONPATH=".:$$PYTHONPATH"; \
 	$(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
 
-$(RUNME)3.py: $(RUNME).py
+ifneq (,$(SRCDIR))
+$(RUNME).py: $(SRCDIR)$(RUNME).py
+	cp $< $@
+endif
+
+$(RUNME)3.py: $(SRCDIR)$(RUNME).py
 	cp $< $@
 	$(PY2TO3) -w $@ >/dev/null 2>&1
 
@@ -368,9 +400,10 @@
 	rm -rf __pycache__
 	rm -f *_wrap* *~ .~* mypython@EXEEXT@ *.pyc
 	rm -f core @EXTRA_CLEAN@
-	rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@
+	rm -f *.@OBJEXT@ *@SO@ *$(PYTHON_SO)
 	rm -f $(TARGET).py
-	if [ -f $(RUNME).py ]; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi
+	if test -f $(SRCDIR)$(RUNME).py; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi
+	case "x$(SRCDIR)" in x|x./);; *) rm -f $(RUNME).py;; esac
 
 
 ##################################################################
@@ -385,27 +418,27 @@
 OCTAVE_DLNK   = @OCTAVE_LDFLAGS@
 OCTAVE_SO     = @OCTAVE_SO@
 
-OCTAVE_SCRIPT = $(RUNME).m
+OCTAVE_SCRIPT = $(SRCDIR)$(RUNME).m
 
 # ----------------------------------------------------------------
 # Build a C dynamically loadable module
 # Note: Octave requires C++ compiler when compiling C wrappers
 # ----------------------------------------------------------------
 
-octave: $(SRCS)
-	$(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -g -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
-	$(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CSRCS) $(INCLUDES)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
+octave: $(SRCDIR_SRCS)
+	$(SWIG) -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
+	$(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS) $(INCLUDES)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
 
 # -----------------------------------------------------------------
 # Build a C++ dynamically loadable module
 # -----------------------------------------------------------------
 
-octave_cpp: $(SRCS)
-	$(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -g -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
-	$(CXXSHARED) -g $(CXXFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
+octave_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(OCTAVE_CXX)
+	$(CXXSHARED) -g $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
 
 # -----------------------------------------------------------------
 # Running an Octave example
@@ -429,7 +462,7 @@
 	rm -rf __pycache__
 	rm -f *_wrap* *~ .~* myoctave@EXEEXT@ *.pyc
 	rm -f core @EXTRA_CLEAN@
-	rm -f *.@OBJEXT@ *@SO@ *@OCTAVE_SO@
+	rm -f *.@OBJEXT@ *@SO@ *$(OCTAVE_SO)
 
 ##################################################################
 #####                       GUILE                           ######
@@ -442,21 +475,21 @@
 GUILE_LIBS    = @GUILE_LIBS@
 GUILE_LIBOPTS = @LIBS@ $(SYSLIBS)
 GUILE_LIBPREFIX = lib
-GUILE_SCRIPT  = $(RUNME).scm
+GUILE_SCRIPT  = $(SRCDIR)$(RUNME).scm
 
 #------------------------------------------------------------------
 # Build a dynamically loaded module with passive linkage
 #------------------------------------------------------------------
-guile: $(SRCS)
-	$(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
+guile: $(SRCDIR_SRCS)
+	$(SWIG) -guile -Linkage passive $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCDIR_SRCS)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
 
 guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
-$(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCS)
-	$(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
-	$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@
+$(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCDIR_SRCS)
+	$(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@
 
 guile_externalhdr:
 	$(SWIG) -guile -external-runtime $(TARGET)
@@ -465,34 +498,34 @@
 # Build Guile interpreter augmented with extra functions
 # -----------------------------------------------------------------
 
-guile_augmented:
-	$(SWIG) -guile $(SWIGOPT) $(INTERFACE)
-	$(CC) $(CXXFLAGS) $(SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET)
+guile_augmented: $(SRCDIR_SRCS)
+	$(SWIG) -guile $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET)
 
 # -----------------------------------------------------------------
 # Build statically linked Guile interpreter
 # -----------------------------------------------------------------
 
-guile_static: $(SRCS)
-	$(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \
+guile_static: $(SRCDIR_SRCS)
+	$(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \
 	  -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \
 	  $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile
 
-guile_static_cpp: $(SRCS)
-	$(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+guile_static_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \
 	  -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \
 	  $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile
 
-guile_simple: $(SRCS)
-	$(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \
+guile_simple: $(SRCDIR_SRCS)
+	$(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \
 	  $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile
 
-guile_simple_cpp: $(SRCS)
-	$(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+guile_simple_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \
 	  $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile
 
 # -----------------------------------------------------------------
@@ -519,7 +552,7 @@
 guile_clean:
 	rm -f *_wrap* *~ .~* my-guile@EXEEXT@ $(TARGET)@EXEEXT@
 	rm -f core @EXTRA_CLEAN@
-	rm -f *.@OBJEXT@ *@GUILE_SO@
+	rm -f *.@OBJEXT@ *$(GUILE_SO)
 
 ##################################################################
 #####                       JAVA                            ######
@@ -538,39 +571,39 @@
 JAVACXXSHARED = @JAVACXXSHARED@
 JAVACFLAGS = @JAVACFLAGS@
 JAVA = @JAVA@
-JAVAC = @JAVAC@
+JAVAC = @JAVAC@ -d .
 
 # ----------------------------------------------------------------
 # Build a java dynamically loadable module (C)
 # ----------------------------------------------------------------
 
-java: $(SRCS)
-	$(SWIG) -java $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE)
-	$(JAVALDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
+java: $(SRCDIR_SRCS)
+	$(SWIG) -java $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(JAVACFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE)
+	$(JAVALDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
 
 # ----------------------------------------------------------------
 # Build a java dynamically loadable module (C++)
 # ----------------------------------------------------------------
 
-java_cpp: $(SRCS)
-	$(SWIG) -java -c++ $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE)
-	$(JAVACXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
+java_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -java -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(JAVACFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE)
+	$(JAVACXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
 
 # ----------------------------------------------------------------
 # Compile java files
 # ----------------------------------------------------------------
 
-java_compile: $(SRCS)
-	$(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(JAVASRCS)
+java_compile: $(SRCDIR_SRCS)
+	$(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(addprefix $(SRCDIR),$(JAVASRCS))
 
 # -----------------------------------------------------------------
 # Run java example
 # -----------------------------------------------------------------
 
 java_run:
-	env LD_LIBRARY_PATH=. $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE)
+	env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE)
 
 # -----------------------------------------------------------------
 # Version display
@@ -600,9 +633,6 @@
 ROOT_DIR = @ROOT_DIR@
 JSINCLUDES = @JSCOREINC@ @JSV8INC@
 JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
-JSSO =@JSSO@
-JSLDSHARED = @JSLDSHARED@
-JSCXXSHARED = @JSCXXSHARED@
 NODEJS = @NODEJS@
 NODEGYP = @NODEGYP@
 
@@ -613,38 +643,39 @@
 javascript_wrapper:
 	$(SWIG) -javascript $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH)
 
-javascript_wrapper_cpp: $(SRCS)
+javascript_wrapper_cpp: $(SRCDIR_SRCS)
 	$(SWIG) -javascript -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cxx $(INTERFACEPATH)
 
-javascript_build: $(SRCS)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(JSINCLUDES)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+javascript_build: $(SRCDIR_SRCS)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(JSINCLUDES)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
-javascript_build_cpp: $(SRCS)
+javascript_build_cpp: $(SRCDIR_SRCS)
 ifeq (node,$(JSENGINE))
+	sed -e 's|$$srcdir|./$(SRCDIR)|g' $(SRCDIR)binding.gyp.in > binding.gyp
 	$(NODEGYP) --loglevel=silent configure build 1>>/dev/null
 else
-	$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(JSINCLUDES)
-	$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
 endif
 
 # These targets are used by the test-suite:
 
-javascript: $(SRCS) javascript_custom_interpreter
+javascript: $(SRCDIR_SRCS) javascript_custom_interpreter
 	$(SWIG) -javascript $(SWIGOPT) $(INTERFACEPATH)
 ifeq (jsc, $(ENGINE))
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(JSINCLUDES)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(JSINCLUDES)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 else # (v8 | node) # v8 and node must be compiled as c++
-	$(CXX) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(JSINCLUDES)
-	$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 endif
 
-javascript_cpp: $(SRCS) javascript_custom_interpreter
+javascript_cpp: $(SRCDIR_SRCS) javascript_custom_interpreter
 	$(SWIG) -javascript -c++ $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(JSINCLUDES)
-	$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
 # -----------------------------------------------------------------
 # Running a Javascript example
@@ -655,10 +686,10 @@
 
 ifeq (node,$(JSENGINE))
 javascript_run:
-	$(RUNTOOL) $(NODEJS) $(RUNME).js $(RUNPIPE)
+	env NODE_PATH=$$PWD:$(SRCDIR) $(RUNTOOL) $(NODEJS) $(SRCDIR)$(RUNME).js $(RUNPIPE)
 else
 javascript_run: javascript_custom_interpreter
-	$(RUNTOOL) $(ROOT_DIR)/Tools/javascript/javascript -$(JSENGINE) -L $(TARGET) $(RUNME).js $(RUNPIPE)
+	$(RUNTOOL) $(ROOT_DIR)/Tools/javascript/javascript -$(JSENGINE) -L $(TARGET) $(SRCDIR)$(RUNME).js $(RUNPIPE)
 endif
 
 # -----------------------------------------------------------------
@@ -697,24 +728,25 @@
 	rm -rf build
 	rm -f *_wrap* $(RUNME)
 	rm -f core @EXTRA_CLEAN@
-	rm -f *.@OBJEXT@ *@JSSO@ *.$(SO)
-	(cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean)
+	rm -f *.@OBJEXT@ *@SO@
+	rm -f binding.gyp example-gypcopy.cxx
+	cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean
 
 ##################################################################
 #####                       ANDROID                         ######
 ##################################################################
 
-ANDROID = android
-ANDROID_NDK_BUILD = ndk-build
-ANDROID_ADB = adb
-ANT = ant
+ANDROID = @ANDROID@
+ANDROID_NDK_BUILD = @NDKBUILD@
+ANDROID_ADB = @ADB@
+ANT = @ANT@
 TARGETID = 1
 
 # ----------------------------------------------------------------
 # Build an Android dynamically loadable module (C)
 # ----------------------------------------------------------------
 
-android: $(SRCS)
+android: $(SRCDIR_SRCS)
 	$(ANDROID) $(SILENT_OPTION) update project --target $(TARGETID) --name $(PROJECTNAME) --path .
 	$(SWIG) -java $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH)
 	+$(ANDROID_NDK_BUILD) $(SILENT_PIPE)
@@ -724,7 +756,7 @@
 # Build an Android dynamically loadable module (C++)
 # ----------------------------------------------------------------
 
-android_cpp: $(SRCS)
+android_cpp: $(SRCDIR_SRCS)
 	$(ANDROID) $(SILENT_OPTION) update project --target $(TARGETID) --name $(PROJECTNAME) --path .
 	$(SWIG) -java -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cpp $(INTERFACEPATH)
 	+$(ANDROID_NDK_BUILD) $(SILENT_PIPE)
@@ -750,7 +782,7 @@
 # -----------------------------------------------------------------
 
 android_clean:
-	ant -q -logfile /dev/null clean
+	test -n "$(SRCDIR)" && cd $(SRCDIR) ; $(ANT) -q -logfile /dev/null clean
 	rm -f $(INTERFACEDIR)$(TARGET)_wrap.*
 	rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java`
 	rm -rf obj
@@ -765,13 +797,11 @@
 # Build a modula3 dynamically loadable module (C)
 # ----------------------------------------------------------------
 
-modula3: $(SRCS)
-	$(SWIG) -modula3 $(SWIGOPT) $(INTERFACEPATH)
-#	$(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) \
-#       $(OBJS) $(IOBJS) $(LIBS)
+modula3: $(SRCDIR_SRCS)
+	$(SWIG) -modula3 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
 
-modula3_cpp: $(SRCS)
-	$(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACEPATH)
+modula3_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -modula3 -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
 
 # -----------------------------------------------------------------
 # Run modula3 example
@@ -810,22 +840,22 @@
 # Build a C/C++ dynamically loadable module
 # ----------------------------------------------------------------
 
-mzscheme: $(SRCS)
-	$(SWIG) -mzscheme $(SWIGOPT) $(INTERFACEPATH)
-	$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS)
+mzscheme: $(SRCDIR_SRCS)
+	$(SWIG) -mzscheme $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCDIR_SRCS)
 	$(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS)
 
-mzscheme_cpp: $(SRCS)
-	$(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH)
-	$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
-	$(CXXSHARED) $(CXXFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
+mzscheme_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -mzscheme -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
+	$(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
 
 # -----------------------------------------------------------------
 # Run mzscheme example
 # -----------------------------------------------------------------
 
 mzscheme_run:
-	env LD_LIBRARY_PATH=. $(RUNTOOL) $(MZSCHEME) -r $(MZSCHEME_SCRIPT) $(RUNPIPE)
+	env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(MZSCHEME) -r $(MZSCHEME_SCRIPT) $(RUNPIPE)
 
 # -----------------------------------------------------------------
 # Version display
@@ -842,7 +872,7 @@
 mzscheme_clean:
 	rm -f *_wrap* *~ .~*
 	rm -f core @EXTRA_CLEAN@
-	rm -f *.@OBJEXT@ *@SO@
+	rm -f *.@OBJEXT@ *$(MZSCHEME_SO)
 
 ##################################################################
 #####                          Ocaml                         #####
@@ -865,10 +895,10 @@
 	$(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" \
 		-c swigp4.ml
 
-ocaml_static: $(SRCS)
+ocaml_static: $(SRCDIR_SRCS)
 	$(OCAMLCORE)
-	$(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH)
-	$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
+	$(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS)
 	$(OCC) -g -c $(INTERFACE:%.i=%.mli)
 	$(OCC) -g -c $(INTERFACE:%.i=%.ml)
 	test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
@@ -879,11 +909,11 @@
 		$(PROGFILE:%.ml=%.cmo) \
 		$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
 
-ocaml_dynamic: $(SRCS)
+ocaml_dynamic: $(SRCDIR_SRCS)
 	$(OCAMLCORE)
-	$(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH)
-	$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
-	$(CXXSHARED) $(CXXFLAGS) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
+	$(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS)
+	$(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(CCSHARED) -o $(INTERFACE:%.i=%@SO@) \
 		$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS)
 	$(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > \
 		$(INTERFACE:%.i=%_dynamic.ml)
@@ -898,10 +928,10 @@
 		-package dl -linkpkg \
 		$(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo)
 
-ocaml_static_toplevel: $(SRCS)
+ocaml_static_toplevel: $(SRCDIR_SRCS)
 	$(OCAMLCORE)
-	$(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH)
-	$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
+	$(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS)
 	$(OCC) -g -c $(INTERFACE:%.i=%.mli)
 	$(OCC) -g -c $(INTERFACE:%.i=%.ml)
 	test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
@@ -913,12 +943,12 @@
 		$(INTERFACE:%.i=%.cmo) \
 		$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
 
-ocaml_static_cpp: $(SRCS)
+ocaml_static_cpp: $(SRCDIR_SRCS)
 	$(OCAMLCORE)
-	$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
+	$(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
 	cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
 	$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
-		$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
+		$(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
 	$(OCC) -g -c $(INTERFACE:%.i=%.mli)
 	$(OCC) -g -c $(INTERFACE:%.i=%.ml)
 	test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
@@ -930,12 +960,12 @@
 		$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
 		-cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
 
-ocaml_static_cpp_toplevel: $(SRCS)
+ocaml_static_cpp_toplevel: $(SRCDIR_SRCS)
 	$(OCAMLCORE)
-	$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
+	$(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
 	cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
 	$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
-		$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
+		$(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
 	$(OCC) -g -c $(INTERFACE:%.i=%.mli)
 	$(OCC) -g -c $(INTERFACE:%.i=%.ml)
 	test -z "$(PROGFILE)" || test -f "$(PROGFILE)" && \
@@ -948,13 +978,13 @@
 		$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
 		-cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
 
-ocaml_dynamic_cpp: $(SRCS)
+ocaml_dynamic_cpp: $(SRCDIR_SRCS)
 	$(OCAMLCORE)
-	$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
+	$(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
 	cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
 	$(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
-		$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC
-	$(CXXSHARED) $(CXXFLAGS) -o $(INTERFACE:%.i=%@SO@) \
+		$(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) -ccopt -fPIC
+	$(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(INTERFACE:%.i=%@SO@) \
 		$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
 		$(CPP_DLLIBS) $(LIBS)
 	$(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > \
@@ -1006,26 +1036,26 @@
 RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS)
 RUBY_SO = @RUBYSO@
 RUBY = @RUBY@
-RUBY_SCRIPT = $(RUNME).rb
+RUBY_SCRIPT = $(SRCDIR)$(RUNME).rb
 
 
 # ----------------------------------------------------------------
 # Build a C dynamically loadable module
 # ----------------------------------------------------------------
 
-ruby: $(SRCS)
-	$(SWIG) -ruby $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO)
+ruby: $(SRCDIR_SRCS)
+	$(SWIG) -ruby $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(RUBY_INCLUDE)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO)
 
 # -----------------------------------------------------------------
 # Build a C++ dynamically loadable module
 # -----------------------------------------------------------------
 
-ruby_cpp: $(SRCS)
-	$(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE)
-	$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO)
+ruby_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -ruby $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(RUBY_SO)
 
 # -----------------------------------------------------------------
 # Build statically linked Ruby interpreter
@@ -1034,14 +1064,14 @@
 # library file
 # -----------------------------------------------------------------
 
-ruby_static: $(SRCS)
-	$(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
+ruby_static: $(SRCDIR_SRCS)
+	$(SWIG) -ruby -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \
 	$(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET)
 
-ruby_cpp_static: $(SRCS)
-	$(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) $(CXXFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+ruby_cpp_static: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \
 	$(RUBY_INCLUDE) $(LIBS)  -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET)
 
 # -----------------------------------------------------------------
@@ -1063,9 +1093,9 @@
 # -----------------------------------------------------------------
 
 ruby_clean:
-	rm -f *_wrap* *~ .~* myruby@EXEEXT@ *.pm
+	rm -f *_wrap* *~ .~* myruby@EXEEXT@
 	rm -f core @EXTRA_CLEAN@
-	rm -f *.@OBJEXT@ *@SO@
+	rm -f *.@OBJEXT@ *$(RUBY_SO)
 
 ##################################################################
 #####                       PHP                             ######
@@ -1074,25 +1104,25 @@
 PHP         = @PHP@
 PHP_INCLUDE = @PHPINC@
 PHP_SO      = @PHP_SO@
-PHP_SCRIPT  = $(RUNME).php
+PHP_SCRIPT  = $(SRCDIR)$(RUNME).php
 
 # -------------------------------------------------------------------
 # Build a PHP dynamically loadable module (C)
 # -------------------------------------------------------------------
 
-php: $(SRCS)
-	$(SWIG) -php $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
+php: $(SRCDIR_SRCS)
+	$(SWIG) -php $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
 
 # --------------------------------------------------------------------
 # Build a PHP dynamically loadable module (C++)
 # --------------------------------------------------------------------
 
-php_cpp: $(SRCS)
-	$(SWIG) -php -cppext cxx -c++ $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE)
-	$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
+php_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -php -cppext cxx -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
 
 # -----------------------------------------------------------------
 # Running a PHP example
@@ -1115,7 +1145,7 @@
 php_clean:
 	rm -f *_wrap* *~ .~* example.php php_example.h
 	rm -f core @EXTRA_CLEAN@
-	rm -f *.@OBJEXT@ *@SO@
+	rm -f *.@OBJEXT@ *$(PHP_SO)
 
 ##################################################################
 #####                       Pike                            ######
@@ -1134,19 +1164,19 @@
 # Build a C dynamically loadable module
 # ----------------------------------------------------------------
 
-pike: $(SRCS)
-	$(SWIG) -pike $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PIKE_INCLUDE)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+pike: $(SRCDIR_SRCS)
+	$(SWIG) -pike $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(PIKE_INCLUDE)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
 # -----------------------------------------------------------------
 # Build a C++ dynamically loadable module
 # -----------------------------------------------------------------
 
-pike_cpp: $(SRCS)
-	$(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE)
-	$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+pike_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -pike $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
 # -----------------------------------------------------------------
 # Build statically linked Pike interpreter
@@ -1155,14 +1185,14 @@
 # library file
 # -----------------------------------------------------------------
 
-pike_static: $(SRCS)
-	$(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) $(CFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
+pike_static: $(SRCDIR_SRCS)
+	$(SWIG) -pike -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \
 	$(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET)
 
-pike_cpp_static: $(SRCS)
-	$(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) $(CXXFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
+pike_cpp_static: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -pike -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \
 	$(PIKE_INCLUDE) $(LIBS)  -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET)
 
 # -----------------------------------------------------------------
@@ -1218,24 +1248,24 @@
 # -----------------------------------------------------------------
 
 # This is the old way to build chicken, but it does not work correctly with exceptions
-chicken_direct: $(SRCS)
+chicken_direct: $(SRCDIR_SRCS)
 	$(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
 	$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
 		-dynamic -feature chicken-compile-shared \
 		-output-file $(CHICKEN_COMPILED_SCHEME)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(CHICKEN_CFLAGS) \
-		$(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCS) $(CHICKEN_COMPILED_SCHEME)
-	$(LDSHARED) $(CFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(CHICKEN_CFLAGS) \
+		$(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCDIR_SRCS) $(CHICKEN_COMPILED_SCHEME)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
 		$(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
-chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS)
+chicken_direct_cpp: $(SRCDIR_CXXSRCS) $(CHICKSRCS)
 	$(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
 	$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
 		-dynamic -feature chicken-compile-shared \
 		-output-file $(CHICKEN_COMPILED_SCHEME)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(CHICKEN_CFLAGS) \
-		$(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CHICKEN_COMPILED_SCHEME)
-	$(CXXSHARED) $(CXXFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(CHICKEN_CFLAGS) \
+		$(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(CHICKEN_COMPILED_SCHEME)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \
 		$(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
 # -----------------------------------------------------------------
@@ -1243,28 +1273,28 @@
 # -----------------------------------------------------------------
 
 # The following two targets are also used by the test suite
-chicken_static: $(SRCS) $(CHICKSRCS)
+chicken_static: $(SRCDIR_SRCS) $(CHICKSRCS)
 	$(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
 	$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
 		-output-file $(CHICKEN_COMPILED_SCHEME)
 	$(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \
 		-output-file $(CHICKEN_MAIN:.scm=_chicken.c)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(CHICKEN_CFLAGS) \
-		$(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCS) \
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(CHICKEN_CFLAGS) \
+		$(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCDIR_SRCS) \
 		$(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN)
-	$(CC) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \
+	$(CC) $(CFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \
 		$(OBJS) $(IOBJS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET)
 
-chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS)
+chicken_static_cpp: $(SRCDIR_CXXSRCS) $(CHICKSRCS)
 	$(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
 	$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
 		-output-file $(CHICKEN_COMPILED_SCHEME)
 	$(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \
 		-output-file $(CHICKEN_MAIN:.scm=_chicken.c)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(CHICKEN_CFLAGS) \
-		$(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) \
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(CHICKEN_CFLAGS) \
+		$(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) \
 		$(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN)
-	$(CXX) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \
+	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \
 		$(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET)
 
 # ----------------------------------------------------------------
@@ -1273,11 +1303,11 @@
 
 chicken:
 	$(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
-	$(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO)
+	$(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCDIR_SRCS) $(ISRCS) -o $(TARGET)$(SO)
 
 chicken_cpp:
 	$(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
-	$(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO)
+	$(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCDIR_SRCS) $(ICXXSRCS) $(SRCDIR_CXXSRCS) -o $(TARGET)$(SO)
 
 chicken_externalhdr:
 	$(SWIG) -chicken -external-runtime $(TARGET)
@@ -1287,7 +1317,7 @@
 # -----------------------------------------------------------------
 
 chicken_run:
-	env LD_LIBRARY_PATH=. $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE)
+	env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE)
 
 # -----------------------------------------------------------------
 # Version display
@@ -1323,33 +1353,39 @@
 # Build a CSharp dynamically loadable module (C)
 # ----------------------------------------------------------------
 
-csharp: $(SRCS)
-	$(SWIG) -csharp $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(ISRCS) $(INCLUDES)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO)
+csharp: $(SRCDIR_SRCS)
+	$(SWIG) -csharp $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(CSHARPCFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO)
 
 # ----------------------------------------------------------------
 # Build a CSharp dynamically loadable module (C++)
 # ----------------------------------------------------------------
 
-csharp_cpp: $(SRCS)
-	$(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(CSHARPCFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
-	$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO)
+csharp_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -csharp -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(CSHARPCFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO)
 
 # ----------------------------------------------------------------
 # Compile CSharp files
 # ----------------------------------------------------------------
 
-csharp_compile: $(SRCS)
-	$(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS)
+ifneq (,$(SRCDIR))
+SRCDIR_CSHARPSRCS = $(addprefix $(SRCDIR),$(CSHARPSRCS))
+else
+SRCDIR_CSHARPSRCS =
+endif
+
+csharp_compile: $(SRCDIR_SRCS)
+	$(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS) $(SRCDIR_CSHARPSRCS)
 
 # -----------------------------------------------------------------
 # Run CSharp example
 # -----------------------------------------------------------------
 
 csharp_run:
-	env LD_LIBRARY_PATH=. $(RUNTOOL) $(CSHARP_RUNME) $(RUNPIPE)
+	env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(CSHARP_RUNME) $(RUNPIPE)
 
 # -----------------------------------------------------------------
 # Version display
@@ -1358,6 +1394,7 @@
 # Version check below also works with MS csc.exe which does not understand --version
 csharp_version:
 	$(CSHARPCOMPILER) --version | head -n 1
+	if test -n "$(CSHARPCILINTERPRETER)" ; then "$(CSHARPCILINTERPRETER)" --version ; fi
 
 # -----------------------------------------------------------------
 # Cleaning the CSharp examples
@@ -1381,7 +1418,7 @@
 LUA_SO     = @LUA_SO@
 
 LUA        = @LUABIN@
-LUA_SCRIPT = $(RUNME).lua
+LUA_SCRIPT = $(SRCDIR)$(RUNME).lua
 
 # Extra code for lua static link
 LUA_INTERP = ../lua.c
@@ -1390,32 +1427,32 @@
 # Build a C dynamically loadable module
 # ----------------------------------------------------------------
 
-lua: $(SRCS)
-	$(SWIG) -lua $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(LUA_INCLUDE)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
+lua: $(SRCDIR_SRCS)
+	$(SWIG) -lua $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(LUA_INCLUDE)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
 
 # -----------------------------------------------------------------
 # Build a C++ dynamically loadable module
 # -----------------------------------------------------------------
 
-lua_cpp: $(SRCS)
-	$(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(LUA_INCLUDE)
-	$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
+lua_cpp: $(SRCDIR_SRCS) $(GENCXXSRCS)
+	$(SWIG) -c++ -lua $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(GENCXXSRCS) $(INCLUDES) $(LUA_INCLUDE)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
 
 # -----------------------------------------------------------------
 # Build statically linked Lua interpreter
 # -----------------------------------------------------------------
 
-lua_static: $(SRCS)
-	$(SWIG) -lua -module example $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) $(CFLAGS)  $(ISRCS) $(SRCS) $(LUA_INTERP) $(INCLUDES) \
+lua_static: $(SRCDIR_SRCS)
+	$(SWIG) -lua -module example $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)  $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR)$(LUA_INTERP) $(INCLUDES) \
 	$(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET)
 
-lua_static_cpp: $(SRCS)
-	$(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \
+lua_static_cpp: $(SRCDIR_SRCS) $(GENCXXSRCS)
+	$(SWIG) -c++ -lua -module example $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(GENCXXSRCS) $(SRCDIR)$(LUA_INTERP) $(INCLUDES) \
 	$(LUA_INCLUDE) $(LIBS)  $(LUA_LIB) -o $(TARGET)
 
 # -----------------------------------------------------------------
@@ -1426,7 +1463,7 @@
 	$(RUNTOOL) $(LUA) $(LUA_SCRIPT) $(RUNPIPE)
 
 lua_embed_run:
-	$(RUNTOOL) ./$(TARGET) $(RUNPIPE)
+	$(RUNTOOL) ./$(TARGET) $(LUA_SCRIPT) $(RUNPIPE)
 
 # -----------------------------------------------------------------
 # Version display
@@ -1442,7 +1479,7 @@
 lua_clean:
 	rm -f *_wrap* *~ .~* mylua@EXEEXT@
 	rm -f core @EXTRA_CLEAN@
-	rm -f *.@OBJEXT@ *@SO@
+	rm -f *.@OBJEXT@ *$(LUA_SO)
 
 ##################################################################
 #####                   ALLEGRO CL                          ######
@@ -1451,15 +1488,15 @@
 ALLEGROCL    = @ALLEGROCLBIN@
 ALLEGROCL_SCRIPT=$(RUNME).lisp
 
-allegrocl: $(SRCS)
-	$(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
-	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+allegrocl: $(SRCDIR_SRCS)
+	$(SWIG) -allegrocl -cwrap $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCDIR_SRCS)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
-allegrocl_cpp: $(SRCS)
-	$(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
-	$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+allegrocl_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -allegrocl $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
 # -----------------------------------------------------------------
 # Run ALLEGRO CL example
@@ -1491,11 +1528,11 @@
 CLISP = @CLISPBIN@
 CLISP_SCRIPT=$(RUNME).lisp
 
-clisp: $(SRCS)
-	$(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH)
+clisp: $(SRCDIR_SRCS)
+	$(SWIG) -clisp $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
 
-clisp_cpp: $(SRCS)
-	$(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH)
+clisp_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -clisp $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
 
 # -----------------------------------------------------------------
 # Run CLISP example
@@ -1527,15 +1564,15 @@
 CFFI = @CFFIBIN@
 CFFI_SCRIPT=$(RUNME).lisp
 
-cffi: $(SRCS)
-	$(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH)
-#	$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
-#	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+cffi: $(SRCDIR_SRCS)
+	$(SWIG) -cffi $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+#	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCDIR_SRCS)
+#	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
-cffi_cpp: $(SRCS)
-	$(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
-	$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+cffi_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -cffi $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
 # -----------------------------------------------------------------
 # Run CFFI example
@@ -1567,15 +1604,15 @@
 UFFI = @UFFIBIN@
 UFFI_SCRIPT=$(RUNME).lisp
 
-uffi: $(SRCS)
-	$(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH)
-#	$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
-#	$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+uffi: $(SRCDIR_SRCS)
+	$(SWIG) -uffi $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+#	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCDIR_SRCS)
+#	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
-uffi_cpp: $(SRCS)
-	$(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH)
-#	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
-#	$(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
+uffi_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -c++ -uffi $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+#	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES)
+#	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
 
 # -----------------------------------------------------------------
 # Run UFFI example
@@ -1618,23 +1655,23 @@
 # Build a R dynamically loadable module (C)
 # ----------------------------------------------------------------
 
-r: $(SRCS)
-	$(SWIG) -r $(SWIGOPT) $(INTERFACEPATH)
-ifneq ($(SRCS),)
-	$(CC) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES) 
+r: $(SRCDIR_SRCS)
+	$(SWIG) -r $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+ifneq ($(SRCDIR_SRCS),)
+	$(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(R_CFLAGS) $(SRCDIR_SRCS) $(INCLUDES)
 endif
-	+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null )
+	+( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null )
 
 # ----------------------------------------------------------------
 # Build a R dynamically loadable module (C++)
 # ----------------------------------------------------------------
 
-r_cpp: $(CXXSRCS)
+r_cpp: $(SRCDIR_CXXSRCS)
 	$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
-ifneq ($(CXXSRCS),)
-	$(CXX) -g -c $(CXXFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES) 
+ifneq ($(SRCDIR_CXXSRCS),)
+	$(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(R_CFLAGS) $(SRCDIR_CXXSRCS) $(INCLUDES)
 endif
-	+( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null )
+	+( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null )
 
 # -----------------------------------------------------------------
 # Run R example
@@ -1693,13 +1730,13 @@
 # Build a Go module (C)
 # ----------------------------------------------------------------
 
-go: $(SRCS)
-	$(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH)
+go: $(SRCDIR_SRCS)
+	$(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
 	if $(GO12) || $(GO13) || $(GOGCC); then \
-	  $(CC) -g -c $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES); \
+	  $(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
 	else \
-	  $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES); \
-	  $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
+	  $(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \
+	  $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
 	fi
 	$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS)
 	if ! $(GOGCC) ; then \
@@ -1714,12 +1751,12 @@
 	    $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
 	  fi; \
 	fi
-	if test -f $(RUNME).go; then \
-	  $(GO) $(GOCOMPILEARG) $(RUNME).go; \
+	if test -f $(SRCDIR)$(RUNME).go; then \
+	  $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
 	  if $(GOGCC) ; then \
 	    $(COMPILETOOL) $(GO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS); \
 	  elif $(GO12) || $(GO13); then \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CC) -extldflags "$(CFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
+	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
 	  else \
 	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
 	  fi; \
@@ -1729,13 +1766,13 @@
 # Build a Go module (C++)
 # ----------------------------------------------------------------
 
-go_cpp: $(SRCS)
-	$(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH)
+go_cpp: $(SRCDIR_SRCS)
+	$(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
 	if $(GO12) || $(GO13) || $(GOGCC); then \
-	  $(CXX) -g -c $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
+	  $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
 	else \
-	  $(CXX) -g -c $(CCSHARED) $(CXXFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
-	  $(CXXSHARED) $(CXXFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
+	  $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES); \
+	  $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \
 	fi
 	$(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS)
 	if ! $(GOGCC) ; then \
@@ -1750,12 +1787,12 @@
 	    $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \
 	  fi; \
 	fi
-	if test -f $(RUNME).go; then \
-	  $(GO) $(GOCOMPILEARG) $(RUNME).go; \
+	if test -f $(SRCDIR)$(RUNME).go; then \
+	  $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \
 	  if $(GOGCC) ; then \
 	    $(COMPILETOOL) $(GO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS) -lstdc++; \
 	  elif $(GO12) || $(GO13); then \
-	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
+	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \
 	  else \
 	    $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \
 	  fi; \
@@ -1766,7 +1803,7 @@
 # -----------------------------------------------------------------
 
 go_run:
-	env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$(RUNME) $(RUNPIPE)
+	env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) ./$(RUNME) $(RUNPIPE)
 
 # -----------------------------------------------------------------
 # Version display
@@ -1808,19 +1845,19 @@
 # Build a dynamically loadable D wrapper for a C module
 # ----------------------------------------------------------------
 
-d: $(SRCS)
-	$(SWIGD) $(SWIGOPT) $(INTERFACEPATH)
-	$(CC) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES)
-	$(LDSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
+d: $(SRCDIR_SRCS)
+	$(SWIGD) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+	$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES)
+	$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
 
 # ----------------------------------------------------------------
 # Build a dynamically loadable D wrapper for a C++ module
 # ----------------------------------------------------------------
 
-d_cpp: $(SRCS)
-	$(SWIGD) -c++ $(SWIGOPT) $(INTERFACEPATH)
-	$(CXX) -c $(CCSHARED) $(CXXFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
-	$(CXXSHARED) $(CXXFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
+d_cpp: $(SRCDIR_SRCS)
+	$(SWIGD) -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+	$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES)
+	$(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
 
 # ----------------------------------------------------------------
 # Compile D files
@@ -1828,7 +1865,7 @@
 
 # Clear the DFLAGS environment variable for the compiler call itself
 # to work around a discrepancy in argument handling between DMD and LDC.
-d_compile: $(SRCS)
+d_compile: $(SRCDIR_SRCS)
 	DFLAGS="" $(COMPILETOOL) $(DCOMPILER) $(DFLAGS) $(DSRCS)
 
 # -----------------------------------------------------------------
@@ -1836,7 +1873,7 @@
 # -----------------------------------------------------------------
 
 d_run:
-	$(RUNTOOL) $(D_RUNME) $(RUNPIPE)
+	env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(D_RUNME) $(RUNPIPE)
 
 # -----------------------------------------------------------------
 # Version display
diff --git a/Examples/android/class/Makefile b/Examples/android/class/Makefile
index cef405e..5745666 100644
--- a/Examples/android/class/Makefile
+++ b/Examples/android/class/Makefile
@@ -3,7 +3,7 @@
 TARGET     = example
 INTERFACE  = example.i
 INTERFACEDIR = jni/
-PACKAGEDIR = src/org/swig
+PACKAGEDIR = $(SRCDIR)src/org/swig
 PACKAGENAME= org.swig.classexample
 SWIGOPT    = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/classexample
 PROJECTNAME= SwigClass
@@ -13,14 +13,14 @@
 check: build
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \
 	PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp
 
 install:
-	$(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \
 	PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \
 	PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean
diff --git a/Examples/android/extend/Makefile b/Examples/android/extend/Makefile
index 9b79649..fb974d2 100644
--- a/Examples/android/extend/Makefile
+++ b/Examples/android/extend/Makefile
@@ -3,7 +3,7 @@
 TARGET     = example
 INTERFACE  = example.i
 INTERFACEDIR = jni/
-PACKAGEDIR = src/org/swig
+PACKAGEDIR = $(SRCDIR)src/org/swig
 PACKAGENAME= org.swig.extendexample
 SWIGOPT    = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/extendexample
 PROJECTNAME= SwigExtend
@@ -13,14 +13,14 @@
 check: build
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \
 	PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp
 
 install:
-	$(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \
 	PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \
 	PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean
diff --git a/Examples/android/simple/Makefile b/Examples/android/simple/Makefile
index 7e7ff40..2bf4196 100644
--- a/Examples/android/simple/Makefile
+++ b/Examples/android/simple/Makefile
@@ -3,7 +3,7 @@
 TARGET     = example
 INTERFACE  = example.i
 INTERFACEDIR = jni/
-PACKAGEDIR = src/org/swig
+PACKAGEDIR = $(SRCDIR)src/org/swig
 PACKAGENAME= org.swig.simple
 SWIGOPT    = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/simple
 PROJECTNAME= SwigSimple
@@ -13,14 +13,14 @@
 check: build
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \
 	PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android
 
 install:
-	$(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \
 	PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \
 	PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean
diff --git a/Examples/chicken/class/Makefile b/Examples/chicken/class/Makefile
index cd445c8..a37ea4a 100644
--- a/Examples/chicken/class/Makefile
+++ b/Examples/chicken/class/Makefile
@@ -6,7 +6,6 @@
 TARGET      = class
 INCLUDE     =
 SWIGOPT     =
-CFLAGS      =
 VARIANT     =
 
 # uncomment the following lines to build a static exe (only pick one of the CHICKEN_MAIN lines)
@@ -15,24 +14,24 @@
 #VARIANT      = _static
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile CHICKEN_SCRIPT='runme-lowlevel.scm' chicken_run
-	$(MAKE) -f $(TOP)/Makefile CHICKEN_SCRIPT='runme-tinyclos.scm' chicken_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CHICKEN_SCRIPT='runme-lowlevel.scm' chicken_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CHICKEN_SCRIPT='runme-tinyclos.scm' chicken_run
 
 build: $(TARGET) $(TARGET)_proxy
 
 $(TARGET): $(INTERFACE) $(SRCS)
-	$(MAKE) -f $(TOP)/Makefile \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
 	SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
 	INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
 	SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
 
 $(TARGET)_proxy: $(INTERFACE) $(SRCS)
-	$(MAKE) -f $(TOP)/Makefile \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
 	SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
 	INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT) -proxy' TARGET='$(TARGET)_proxy' \
 	SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile chicken_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
 	rm -f example.scm
 	rm -f $(TARGET)
diff --git a/Examples/chicken/class/example.cxx b/Examples/chicken/class/example.cxx
index 1e8e203..0463045 100644
--- a/Examples/chicken/class/example.cxx
+++ b/Examples/chicken/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
 
 #include "example.h"
 #define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
+double Circle::area() {
   return M_PI*radius*radius;
 }
 
-double Circle::perimeter(void) {
+double Circle::perimeter() {
   return 2*M_PI*radius;
 }
 
-double Square::area(void) {
+double Square::area() {
   return width*width;
 }
 
-double Square::perimeter(void) {
+double Square::perimeter() {
   return 4*width;
 }
diff --git a/Examples/chicken/constants/Makefile b/Examples/chicken/constants/Makefile
index fe39673..7167e86 100644
--- a/Examples/chicken/constants/Makefile
+++ b/Examples/chicken/constants/Makefile
@@ -6,7 +6,6 @@
 TARGET      = constants
 INCLUDE     =
 SWIGOPT     =
-CFLAGS      =
 VARIANT     =
 
 # uncomment the following two lines to build a static exe
@@ -14,17 +13,17 @@
 #VARIANT      = _static
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile chicken_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
 
 build: $(TARGET)
 
 $(TARGET): $(INTERFACE) $(SRCS)
-	$(MAKE) -f $(TOP)/Makefile \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
 	SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
 	INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
 	SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile chicken_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
 	rm -f example.scm
 	rm -f $(TARGET)
diff --git a/Examples/chicken/multimap/Makefile b/Examples/chicken/multimap/Makefile
index d92cfed..e8192e9 100644
--- a/Examples/chicken/multimap/Makefile
+++ b/Examples/chicken/multimap/Makefile
@@ -6,7 +6,6 @@
 TARGET      = multimap
 INCLUDE     =
 SWIGOPT     =
-CFLAGS      =
 VARIANT     =
 
 # uncomment the following two lines to build a static exe
@@ -14,17 +13,17 @@
 #VARIANT      = _static
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile chicken_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
 
 build: $(TARGET)
 
 $(TARGET): $(INTERFACE) $(SRCS)
-	$(MAKE) -f $(TOP)/Makefile \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
 	SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
 	INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
 	SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile chicken_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
 	rm -f example.scm
 	rm -f $(TARGET)
diff --git a/Examples/chicken/overload/Makefile b/Examples/chicken/overload/Makefile
index fb190e8..a9647d9 100644
--- a/Examples/chicken/overload/Makefile
+++ b/Examples/chicken/overload/Makefile
@@ -6,7 +6,6 @@
 TARGET      = overload
 INCLUDE     =
 SWIGOPT     = -proxy -unhideprimitive
-CFLAGS      =
 VARIANT     =
 
 # uncomment the following lines to build a static exe
@@ -14,17 +13,17 @@
 #VARIANT      = _static
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile chicken_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
 
 build: $(TARGET)
 
 $(TARGET): $(INTERFACE) $(SRCS)
-	$(MAKE) -f $(TOP)/Makefile \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
 	SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
 	INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
 	SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile chicken_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
 	rm -f example.scm
 	rm -f $(TARGET)
diff --git a/Examples/chicken/simple/Makefile b/Examples/chicken/simple/Makefile
index d0d7374..c07075e 100644
--- a/Examples/chicken/simple/Makefile
+++ b/Examples/chicken/simple/Makefile
@@ -6,7 +6,6 @@
 TARGET      = simple
 INCLUDE     =
 SWIGOPT     =
-CFLAGS      =
 VARIANT     =
 
 # uncomment the following two lines to build a static exe
@@ -14,17 +13,17 @@
 #VARIANT      = _static
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile chicken_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_run
 
 build: $(TARGET)
 
 $(TARGET): $(INTERFACE) $(SRCS)
-	$(MAKE) -f $(TOP)/Makefile \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
 	SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \
 	INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' \
 	SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile chicken_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' chicken_clean
 	rm -f example.scm example-generic.scm example-clos.scm
 	rm -f $(TARGET)
diff --git a/Examples/contract/simple_cxx/example.h b/Examples/contract/simple_cxx/example.h
index 64b7684..de708bb7 100644
--- a/Examples/contract/simple_cxx/example.h
+++ b/Examples/contract/simple_cxx/example.h
@@ -7,7 +7,7 @@
   }
   virtual ~Shape() {
     nshapes--;
-  };
+  }
   double  x, y;   
   void    move(double dx, double dy);
   virtual double area(void) = 0;
@@ -19,7 +19,7 @@
 private:
   double radius;
 public:
-  Circle(double r) : radius(r) { };
+  Circle(double r) : radius(r) { }
   virtual double area(void);
   virtual double perimeter(void);
 };
@@ -28,7 +28,7 @@
 private:
   double width;
 public:
-  Square(double w) : width(w) { };
+  Square(double w) : width(w) { }
   virtual double area(void);
   virtual double perimeter(void);
 };
diff --git a/Examples/csharp/arrays/Makefile b/Examples/csharp/arrays/Makefile
index 4be092d..e5d733d 100644
--- a/Examples/csharp/arrays/Makefile
+++ b/Examples/csharp/arrays/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -unsafe -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/callback/Makefile b/Examples/csharp/callback/Makefile
index 6c58abd..4f4c84b 100644
--- a/Examples/csharp/callback/Makefile
+++ b/Examples/csharp/callback/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/class/Makefile b/Examples/csharp/class/Makefile
index 6c58abd..4f4c84b 100644
--- a/Examples/csharp/class/Makefile
+++ b/Examples/csharp/class/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/class/example.cxx b/Examples/csharp/class/example.cxx
index 1e8e203..0463045 100644
--- a/Examples/csharp/class/example.cxx
+++ b/Examples/csharp/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
 
 #include "example.h"
 #define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
+double Circle::area() {
   return M_PI*radius*radius;
 }
 
-double Circle::perimeter(void) {
+double Circle::perimeter() {
   return 2*M_PI*radius;
 }
 
-double Square::area(void) {
+double Square::area() {
   return width*width;
 }
 
-double Square::perimeter(void) {
+double Square::perimeter() {
   return 4*width;
 }
diff --git a/Examples/csharp/enum/Makefile b/Examples/csharp/enum/Makefile
index 6c58abd..4f4c84b 100644
--- a/Examples/csharp/enum/Makefile
+++ b/Examples/csharp/enum/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/extend/Makefile b/Examples/csharp/extend/Makefile
index 6c58abd..4f4c84b 100644
--- a/Examples/csharp/extend/Makefile
+++ b/Examples/csharp/extend/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/extend/example.h b/Examples/csharp/extend/example.h
index b27ab97..ca1aed2 100644
--- a/Examples/csharp/extend/example.h
+++ b/Examples/csharp/extend/example.h
@@ -14,7 +14,7 @@
 	virtual std::string getTitle() { return getPosition() + " " + getName(); }
 	virtual std::string getName() { return name; }
 	virtual std::string getPosition() const { return "Employee"; }
-	virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+	virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
 };
 
 
diff --git a/Examples/csharp/funcptr/Makefile b/Examples/csharp/funcptr/Makefile
index ed15cb2..99cdfa3 100644
--- a/Examples/csharp/funcptr/Makefile
+++ b/Examples/csharp/funcptr/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/nested/Makefile b/Examples/csharp/nested/Makefile
index 6c58abd..4f4c84b 100644
--- a/Examples/csharp/nested/Makefile
+++ b/Examples/csharp/nested/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/reference/Makefile b/Examples/csharp/reference/Makefile
index 6c58abd..4f4c84b 100644
--- a/Examples/csharp/reference/Makefile
+++ b/Examples/csharp/reference/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/reference/example.cxx b/Examples/csharp/reference/example.cxx
index 8a513bf..9dbaed2 100644
--- a/Examples/csharp/reference/example.cxx
+++ b/Examples/csharp/reference/example.cxx
@@ -19,7 +19,7 @@
 
 char *Vector::print() {
   static char temp[512];
-  sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
diff --git a/Examples/csharp/reference/example.h b/Examples/csharp/reference/example.h
index 4915adb..bcfcfb7 100644
--- a/Examples/csharp/reference/example.h
+++ b/Examples/csharp/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   friend Vector operator+(const Vector &a, const Vector &b);
   char *print();
 };
@@ -20,7 +20,3 @@
   Vector &operator[](int);
   int size();
 };
-
-
-
-  
diff --git a/Examples/csharp/reference/example.i b/Examples/csharp/reference/example.i
index 6daa3b1..173143d 100644
--- a/Examples/csharp/reference/example.i
+++ b/Examples/csharp/reference/example.i
@@ -29,7 +29,7 @@
   VectorArray(int maxsize);
   ~VectorArray();
   int size();
-  
+
   /* This wrapper provides an alternative to the [] operator */
   %extend {
     Vector &get(int index) {
@@ -40,7 +40,3 @@
     }
   }
 };
-
-
-
-
diff --git a/Examples/csharp/simple/Makefile b/Examples/csharp/simple/Makefile
index ed15cb2..99cdfa3 100644
--- a/Examples/csharp/simple/Makefile
+++ b/Examples/csharp/simple/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/template/Makefile b/Examples/csharp/template/Makefile
index 23fe2ee..2d0e070 100644
--- a/Examples/csharp/template/Makefile
+++ b/Examples/csharp/template/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp_cpp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/variables/Makefile b/Examples/csharp/variables/Makefile
index ed15cb2..99cdfa3 100644
--- a/Examples/csharp/variables/Makefile
+++ b/Examples/csharp/variables/Makefile
@@ -8,12 +8,12 @@
 CSHARPFLAGS= -nologo -debug+ -out:runme.exe
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile csharp_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
-	$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile csharp_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' csharp_clean
diff --git a/Examples/csharp/variables/example.c b/Examples/csharp/variables/example.c
index 05e17c8..85685fe 100644
--- a/Examples/csharp/variables/example.c
+++ b/Examples/csharp/variables/example.c
@@ -52,9 +52,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %s\n", name);
-  printf("ptptr     = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+  printf("ptptr     = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/d/callback/Makefile b/Examples/d/callback/Makefile
index eda18f1..ad84231 100644
--- a/Examples/d/callback/Makefile
+++ b/Examples/d/callback/Makefile
@@ -1,27 +1 @@
-ifeq (2,$(D_VERSION))
-  WORKING_DIR = d2/
-else
-  WORKING_DIR = d1/
-endif
-
-TOP           = ../../..
-SWIG          = $(TOP)/../preinst-swig
-EXTRA_CFLAGS  = -I../ ../example.cxx example_wrap.cxx
-EXTRA_LDFLAGS = example.o example_wrap.o
-TARGET        = example_wrap
-SWIGOPT       =
-DSRCS         = *.d
-DFLAGS        = -ofrunme
-
-check: build
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_run
-
-build:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
-	$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
-
-clean:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_clean
+include ../example.mk
diff --git a/Examples/d/class/Makefile b/Examples/d/class/Makefile
index eda18f1..ad84231 100644
--- a/Examples/d/class/Makefile
+++ b/Examples/d/class/Makefile
@@ -1,27 +1 @@
-ifeq (2,$(D_VERSION))
-  WORKING_DIR = d2/
-else
-  WORKING_DIR = d1/
-endif
-
-TOP           = ../../..
-SWIG          = $(TOP)/../preinst-swig
-EXTRA_CFLAGS  = -I../ ../example.cxx example_wrap.cxx
-EXTRA_LDFLAGS = example.o example_wrap.o
-TARGET        = example_wrap
-SWIGOPT       =
-DSRCS         = *.d
-DFLAGS        = -ofrunme
-
-check: build
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_run
-
-build:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
-	$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
-
-clean:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_clean
+include ../example.mk
diff --git a/Examples/d/class/example.cxx b/Examples/d/class/example.cxx
index 1e8e203..0463045 100644
--- a/Examples/d/class/example.cxx
+++ b/Examples/d/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
 
 #include "example.h"
 #define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
+double Circle::area() {
   return M_PI*radius*radius;
 }
 
-double Circle::perimeter(void) {
+double Circle::perimeter() {
   return 2*M_PI*radius;
 }
 
-double Square::area(void) {
+double Square::area() {
   return width*width;
 }
 
-double Square::perimeter(void) {
+double Square::perimeter() {
   return 4*width;
 }
diff --git a/Examples/d/constants/Makefile b/Examples/d/constants/Makefile
index d537ce2..ad84231 100644
--- a/Examples/d/constants/Makefile
+++ b/Examples/d/constants/Makefile
@@ -1,27 +1 @@
-ifeq (2,$(D_VERSION))
-  WORKING_DIR = d2/
-else
-  WORKING_DIR = d1/
-endif
-
-TOP           = ../../..
-SWIG          = $(TOP)/../preinst-swig
-EXTRA_CFLAGS  = -I../ example_wrap.c
-EXTRA_LDFLAGS = example_wrap.o
-TARGET        = example_wrap
-SWIGOPT       =
-DSRCS         = *.d
-DFLAGS        = -ofrunme
-
-check: build
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_run
-
-build:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
-	$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
-
-clean:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_clean
+include ../example.mk
diff --git a/Examples/d/constants/example.d b/Examples/d/constants/example.d
deleted file mode 100644
index 7448d0a..0000000
--- a/Examples/d/constants/example.d
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.41
- *
- * Do not make changes to this file unless you know what you are doing--modify
- * the SWIG interface file instead.
- * ----------------------------------------------------------------------------- */
-
-module example;
-
-static import example_wrap;
-
-static import tango.stdc.stringz;
-
-public const int ICONST = 42;
-public const double FCONST = 2.1828;
-public const char CCONST = 'x';
-public const char CCONST2 = '\n';
-public const char[] SCONST = "Hello World";
-public const char[] SCONST2 = "\"Hello World\"";
-public const double EXPR = 42+3*(2.1828);
-public const int iconst = 37;
-public const double fconst = 3.14;
diff --git a/Examples/d/enum/Makefile b/Examples/d/enum/Makefile
index eda18f1..ad84231 100644
--- a/Examples/d/enum/Makefile
+++ b/Examples/d/enum/Makefile
@@ -1,27 +1 @@
-ifeq (2,$(D_VERSION))
-  WORKING_DIR = d2/
-else
-  WORKING_DIR = d1/
-endif
-
-TOP           = ../../..
-SWIG          = $(TOP)/../preinst-swig
-EXTRA_CFLAGS  = -I../ ../example.cxx example_wrap.cxx
-EXTRA_LDFLAGS = example.o example_wrap.o
-TARGET        = example_wrap
-SWIGOPT       =
-DSRCS         = *.d
-DFLAGS        = -ofrunme
-
-check: build
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_run
-
-build:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
-	$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
-
-clean:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_clean
+include ../example.mk
diff --git a/Examples/d/example.mk.in b/Examples/d/example.mk.in
new file mode 100644
index 0000000..a1d9a85
--- /dev/null
+++ b/Examples/d/example.mk.in
@@ -0,0 +1,59 @@
+#
+# Common Makefile code for building D examples.
+#
+# We actually need to configure this to gain access to the default D version to
+# use when D_VERSION is not set. Using Examples/Makefile.in is not enough, as
+# the location of the source files (d1/ or d2/) depends on it. The alternative
+# would be to add the functionality specific to Examples/d (as opposed to the
+# test suite) directly to Examples/Makefile.in.
+#
+# This file is supposed to be included from a Makefile in the subdirectory
+# corresponding to a specific example.
+#
+
+ifeq (,$(D_VERSION))
+	D_VERSION = @DDEFAULTVERSION@
+endif
+
+ifeq (1,$(D_VERSION))
+	VERSION_DIR = d1/
+else
+	VERSION_DIR = d2/
+endif
+
+EXAMPLES_TOP   = ../../..
+SWIG_TOP       = ../../../..
+SWIG           = $(SWIG_TOP)/preinst-swig
+EXTRA_CFLAGS   =
+EXTRA_CXXFLAGS =
+EXTRA_LDFLAGS  =
+TARGET         = example_wrap
+SWIGOPT        = -outcurrentdir
+DFLAGS         = -ofrunme
+
+ifeq (,$(SRCDIR))
+DSRCS          = *.d
+else
+DSRCS          = *.d $(addprefix ../$(SRCDIR)$(VERSION_DIR),runme.d)
+endif
+
+
+check: build
+	$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_run
+
+build:
+	mkdir -p $(VERSION_DIR)
+	if [ -f $(SRCDIR)example.cxx ]; then \
+		$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CXXFLAGS='$(EXTRA_CXXFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' CXXSRCS='example.cxx' d_cpp; \
+	elif [ -f $(SRCDIR)example.c ]; then \
+		$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='example.c' d; \
+	else \
+		$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='' d; \
+	fi
+	$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean:
+	if [ -d $(VERSION_DIR) ]; then \
+		$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_clean; \
+	fi
+	test -f $(VERSION_DIR)runme.d || rm -rf $(VERSION_DIR) # Only delete dir if out of source
diff --git a/Examples/d/extend/Makefile b/Examples/d/extend/Makefile
index eda18f1..ad84231 100644
--- a/Examples/d/extend/Makefile
+++ b/Examples/d/extend/Makefile
@@ -1,27 +1 @@
-ifeq (2,$(D_VERSION))
-  WORKING_DIR = d2/
-else
-  WORKING_DIR = d1/
-endif
-
-TOP           = ../../..
-SWIG          = $(TOP)/../preinst-swig
-EXTRA_CFLAGS  = -I../ ../example.cxx example_wrap.cxx
-EXTRA_LDFLAGS = example.o example_wrap.o
-TARGET        = example_wrap
-SWIGOPT       =
-DSRCS         = *.d
-DFLAGS        = -ofrunme
-
-check: build
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_run
-
-build:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
-	$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
-
-clean:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_clean
+include ../example.mk
diff --git a/Examples/d/extend/example.h b/Examples/d/extend/example.h
index 7ad93fb..7a8c04c 100644
--- a/Examples/d/extend/example.h
+++ b/Examples/d/extend/example.h
@@ -14,7 +14,7 @@
 	virtual std::string getTitle() { return getPosition() + " " + getName(); }
 	virtual std::string getName() { return name; }
 	virtual std::string getPosition() const { return "Employee"; }
-	virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+	virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
 };
 
 
diff --git a/Examples/d/funcptr/Makefile b/Examples/d/funcptr/Makefile
index 2ba893c..ad84231 100644
--- a/Examples/d/funcptr/Makefile
+++ b/Examples/d/funcptr/Makefile
@@ -1,27 +1 @@
-ifeq (2,$(D_VERSION))
-  WORKING_DIR = d2/
-else
-  WORKING_DIR = d1/
-endif
-
-TOP           = ../../..
-SWIG          = $(TOP)/../preinst-swig
-EXTRA_CFLAGS  = -I../ ../example.c example_wrap.c
-EXTRA_LDFLAGS = example.o example_wrap.o
-TARGET        = example_wrap
-SWIGOPT       =
-DSRCS         = *.d
-DFLAGS        = -ofrunme
-
-check: build
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_run
-
-build:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
-	$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
-
-clean:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_clean
+include ../example.mk
diff --git a/Examples/d/simple/Makefile b/Examples/d/simple/Makefile
index a8808c9..ad84231 100644
--- a/Examples/d/simple/Makefile
+++ b/Examples/d/simple/Makefile
@@ -1,27 +1 @@
-ifeq (2,$(D_VERSION))
-  WORKING_DIR = d2/
-else
-  WORKING_DIR = d1/
-endif
-
-TOP           = ../../..
-SWIG          = $(TOP)/../preinst-swig
-EXTRA_CFLAGS  = -I../ ../example.c example_wrap.c
-EXTRA_LDFLAGS = example.o example_wrap.o
-TARGET        = example_wrap
-SWIGOPT       =
-DSRCS         = *.d
-DFLAGS        = -ofrunme
-
-check: build
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_run
-
-build:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
-	$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
-
-clean:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_clean
+include ../example.mk
diff --git a/Examples/d/variables/Makefile b/Examples/d/variables/Makefile
index a8808c9..ad84231 100644
--- a/Examples/d/variables/Makefile
+++ b/Examples/d/variables/Makefile
@@ -1,27 +1 @@
-ifeq (2,$(D_VERSION))
-  WORKING_DIR = d2/
-else
-  WORKING_DIR = d1/
-endif
-
-TOP           = ../../..
-SWIG          = $(TOP)/../preinst-swig
-EXTRA_CFLAGS  = -I../ ../example.c example_wrap.c
-EXTRA_LDFLAGS = example.o example_wrap.o
-TARGET        = example_wrap
-SWIGOPT       =
-DSRCS         = *.d
-DFLAGS        = -ofrunme
-
-check: build
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_run
-
-build:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
-	$(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
-
-clean:
-	cd $(WORKING_DIR); \
-	$(MAKE) -f $(TOP)/Makefile d_clean
+include ../example.mk
diff --git a/Examples/d/variables/example.c b/Examples/d/variables/example.c
index 3b4e9f3..f5356c7 100644
--- a/Examples/d/variables/example.c
+++ b/Examples/d/variables/example.c
@@ -52,9 +52,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %s\n", name);
-  printf("ptptr     = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+  printf("ptptr     = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/go/callback/Makefile b/Examples/go/callback/Makefile
index 46a14b4..bf5275f 100644
--- a/Examples/go/callback/Makefile
+++ b/Examples/go/callback/Makefile
@@ -6,11 +6,11 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/class/Makefile b/Examples/go/class/Makefile
index 72605ca..de067cd 100644
--- a/Examples/go/class/Makefile
+++ b/Examples/go/class/Makefile
@@ -6,11 +6,11 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/class/class.cxx b/Examples/go/class/class.cxx
index 1e8e203..f87c7ec 100644
--- a/Examples/go/class/class.cxx
+++ b/Examples/go/class/class.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : class.cxx */
 
 #include "example.h"
 #define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
+double Circle::area() {
   return M_PI*radius*radius;
 }
 
-double Circle::perimeter(void) {
+double Circle::perimeter() {
   return 2*M_PI*radius;
 }
 
-double Square::area(void) {
+double Square::area() {
   return width*width;
 }
 
-double Square::perimeter(void) {
+double Square::perimeter() {
   return 4*width;
 }
diff --git a/Examples/go/class/index.html b/Examples/go/class/index.html
index b39119d..df93b56 100644
--- a/Examples/go/class/index.html
+++ b/Examples/go/class/index.html
@@ -33,8 +33,8 @@
   }
   virtual ~Shape() {
     nshapes--;
-  };
-  double  x, y;   
+  }
+  double  x, y;
   void    move(double dx, double dy);
   virtual double area() = 0;
   virtual double perimeter() = 0;
@@ -45,7 +45,7 @@
 private:
   double radius;
 public:
-  Circle(double r) : radius(r) { };
+  Circle(double r) : radius(r) { }
   virtual double area();
   virtual double perimeter();
 };
@@ -54,7 +54,7 @@
 private:
   double width;
 public:
-  Square(double w) : width(w) { };
+  Square(double w) : width(w) { }
   virtual double area();
   virtual double perimeter();
 };
diff --git a/Examples/go/constants/Makefile b/Examples/go/constants/Makefile
index 9fa9673..8fb07fd 100644
--- a/Examples/go/constants/Makefile
+++ b/Examples/go/constants/Makefile
@@ -6,11 +6,11 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/enum/Makefile b/Examples/go/enum/Makefile
index 1ceecc1..2e2f1b2 100644
--- a/Examples/go/enum/Makefile
+++ b/Examples/go/enum/Makefile
@@ -6,11 +6,11 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/extend/Makefile b/Examples/go/extend/Makefile
index 67da892..2906942 100644
--- a/Examples/go/extend/Makefile
+++ b/Examples/go/extend/Makefile
@@ -6,11 +6,11 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/extend/example.h b/Examples/go/extend/example.h
index b27ab97..ca1aed2 100644
--- a/Examples/go/extend/example.h
+++ b/Examples/go/extend/example.h
@@ -14,7 +14,7 @@
 	virtual std::string getTitle() { return getPosition() + " " + getName(); }
 	virtual std::string getName() { return name; }
 	virtual std::string getPosition() const { return "Employee"; }
-	virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+	virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
 };
 
 
diff --git a/Examples/go/funcptr/Makefile b/Examples/go/funcptr/Makefile
index 2c32c45..82031c9 100644
--- a/Examples/go/funcptr/Makefile
+++ b/Examples/go/funcptr/Makefile
@@ -6,11 +6,11 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/multimap/Makefile b/Examples/go/multimap/Makefile
index 0c5ec39..4d73916 100644
--- a/Examples/go/multimap/Makefile
+++ b/Examples/go/multimap/Makefile
@@ -6,11 +6,11 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/pointer/Makefile b/Examples/go/pointer/Makefile
index 12e94f9..9f1f3fd 100644
--- a/Examples/go/pointer/Makefile
+++ b/Examples/go/pointer/Makefile
@@ -6,11 +6,11 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/reference/Makefile b/Examples/go/reference/Makefile
index 41a9442..e136f6f 100644
--- a/Examples/go/reference/Makefile
+++ b/Examples/go/reference/Makefile
@@ -6,11 +6,11 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/reference/example.h b/Examples/go/reference/example.h
index 4915adb..bcfcfb7 100644
--- a/Examples/go/reference/example.h
+++ b/Examples/go/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   friend Vector operator+(const Vector &a, const Vector &b);
   char *print();
 };
@@ -20,7 +20,3 @@
   Vector &operator[](int);
   int size();
 };
-
-
-
-  
diff --git a/Examples/go/reference/example.i b/Examples/go/reference/example.i
index 1cf19c8..173143d 100644
--- a/Examples/go/reference/example.i
+++ b/Examples/go/reference/example.i
@@ -29,7 +29,7 @@
   VectorArray(int maxsize);
   ~VectorArray();
   int size();
-  
+
   /* This wrapper provides an alternative to the [] operator */
   %extend {
     Vector &get(int index) {
diff --git a/Examples/go/reference/reference.cxx b/Examples/go/reference/reference.cxx
index 8a513bf..9dbaed2 100644
--- a/Examples/go/reference/reference.cxx
+++ b/Examples/go/reference/reference.cxx
@@ -19,7 +19,7 @@
 
 char *Vector::print() {
   static char temp[512];
-  sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
diff --git a/Examples/go/simple/Makefile b/Examples/go/simple/Makefile
index 907da88..5bc1654 100644
--- a/Examples/go/simple/Makefile
+++ b/Examples/go/simple/Makefile
@@ -5,11 +5,11 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/template/Makefile b/Examples/go/template/Makefile
index 51cd97a..a1d6748 100644
--- a/Examples/go/template/Makefile
+++ b/Examples/go/template/Makefile
@@ -6,11 +6,11 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/go/variables/Makefile b/Examples/go/variables/Makefile
index 1f14492..d0da605 100644
--- a/Examples/go/variables/Makefile
+++ b/Examples/go/variables/Makefile
@@ -6,11 +6,11 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' go
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' go_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' go_clean
diff --git a/Examples/guile/class/Makefile b/Examples/guile/class/Makefile
index 8de4f29..48426a8 100644
--- a/Examples/guile/class/Makefile
+++ b/Examples/guile/class/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile guile_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean
diff --git a/Examples/guile/class/example.cxx b/Examples/guile/class/example.cxx
index 1e8e203..0463045 100644
--- a/Examples/guile/class/example.cxx
+++ b/Examples/guile/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
 
 #include "example.h"
 #define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
+double Circle::area() {
   return M_PI*radius*radius;
 }
 
-double Circle::perimeter(void) {
+double Circle::perimeter() {
   return 2*M_PI*radius;
 }
 
-double Square::area(void) {
+double Square::area() {
   return width*width;
 }
 
-double Square::perimeter(void) {
+double Square::perimeter() {
   return 4*width;
 }
diff --git a/Examples/guile/constants/Makefile b/Examples/guile/constants/Makefile
index 2b6965e..d3f58eb 100644
--- a/Examples/guile/constants/Makefile
+++ b/Examples/guile/constants/Makefile
@@ -5,11 +5,11 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean
diff --git a/Examples/guile/matrix/Makefile b/Examples/guile/matrix/Makefile
index a32210e..53638c8 100644
--- a/Examples/guile/matrix/Makefile
+++ b/Examples/guile/matrix/Makefile
@@ -5,11 +5,11 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' GUILE_RUNOPTIONS='-e do-test' guile_augmented_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' GUILE_RUNOPTIONS='-e do-test' guile_augmented_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-lm' guile_augmented
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean
diff --git a/Examples/guile/matrix/runme.scm b/Examples/guile/matrix/runme.scm
old mode 100755
new mode 100644
diff --git a/Examples/guile/multimap/Makefile b/Examples/guile/multimap/Makefile
index 4ca82a3..b8f5e9b 100644
--- a/Examples/guile/multimap/Makefile
+++ b/Examples/guile/multimap/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile guile_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean
diff --git a/Examples/guile/multivalue/Makefile b/Examples/guile/multivalue/Makefile
index 4ca82a3..b8f5e9b 100644
--- a/Examples/guile/multivalue/Makefile
+++ b/Examples/guile/multivalue/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile guile_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean
diff --git a/Examples/guile/port/Makefile b/Examples/guile/port/Makefile
index d6ec0ac..95a3a47 100644
--- a/Examples/guile/port/Makefile
+++ b/Examples/guile/port/Makefile
@@ -5,12 +5,12 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean
 	rm -f test.out
diff --git a/Examples/guile/simple/Makefile b/Examples/guile/simple/Makefile
index da4eb90..517e41c 100644
--- a/Examples/guile/simple/Makefile
+++ b/Examples/guile/simple/Makefile
@@ -5,11 +5,11 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_augmented_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean
diff --git a/Examples/guile/std_vector/Makefile b/Examples/guile/std_vector/Makefile
index fd7a843..d7f5de2 100644
--- a/Examples/guile/std_vector/Makefile
+++ b/Examples/guile/std_vector/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile guile_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' guile_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='my-guile' INTERFACE='$(INTERFACE)' guile_static_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' guile_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean
diff --git a/Examples/java/callback/Makefile b/Examples/java/callback/Makefile
index 8f274e7..13cfd17 100644
--- a/Examples/java/callback/Makefile
+++ b/Examples/java/callback/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/class/Makefile b/Examples/java/class/Makefile
index 8f274e7..13cfd17 100644
--- a/Examples/java/class/Makefile
+++ b/Examples/java/class/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/constants/Makefile b/Examples/java/constants/Makefile
index 4e21fc4..637ce0e 100644
--- a/Examples/java/constants/Makefile
+++ b/Examples/java/constants/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/enum/Makefile b/Examples/java/enum/Makefile
index 8f274e7..13cfd17 100644
--- a/Examples/java/enum/Makefile
+++ b/Examples/java/enum/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/extend/Makefile b/Examples/java/extend/Makefile
index 8f274e7..13cfd17 100644
--- a/Examples/java/extend/Makefile
+++ b/Examples/java/extend/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/extend/example.h b/Examples/java/extend/example.h
index b27ab97..ca1aed2 100644
--- a/Examples/java/extend/example.h
+++ b/Examples/java/extend/example.h
@@ -14,7 +14,7 @@
 	virtual std::string getTitle() { return getPosition() + " " + getName(); }
 	virtual std::string getName() { return name; }
 	virtual std::string getPosition() const { return "Employee"; }
-	virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+	virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
 };
 
 
diff --git a/Examples/java/funcptr/Makefile b/Examples/java/funcptr/Makefile
index e9e29f3..c0b1927 100644
--- a/Examples/java/funcptr/Makefile
+++ b/Examples/java/funcptr/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/multimap/Makefile b/Examples/java/multimap/Makefile
index e9e29f3..c0b1927 100644
--- a/Examples/java/multimap/Makefile
+++ b/Examples/java/multimap/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/native/Makefile b/Examples/java/native/Makefile
index e858cbe..fa67e48 100644
--- a/Examples/java/native/Makefile
+++ b/Examples/java/native/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/nested/Makefile b/Examples/java/nested/Makefile
index 8f274e7..13cfd17 100644
--- a/Examples/java/nested/Makefile
+++ b/Examples/java/nested/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/pointer/Makefile b/Examples/java/pointer/Makefile
index e9e29f3..c0b1927 100644
--- a/Examples/java/pointer/Makefile
+++ b/Examples/java/pointer/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/reference/Makefile b/Examples/java/reference/Makefile
index 8f274e7..13cfd17 100644
--- a/Examples/java/reference/Makefile
+++ b/Examples/java/reference/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/reference/example.cxx b/Examples/java/reference/example.cxx
index 8a513bf..9dbaed2 100644
--- a/Examples/java/reference/example.cxx
+++ b/Examples/java/reference/example.cxx
@@ -19,7 +19,7 @@
 
 char *Vector::print() {
   static char temp[512];
-  sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
diff --git a/Examples/java/reference/example.h b/Examples/java/reference/example.h
index 4915adb..bcfcfb7 100644
--- a/Examples/java/reference/example.h
+++ b/Examples/java/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   friend Vector operator+(const Vector &a, const Vector &b);
   char *print();
 };
@@ -20,7 +20,3 @@
   Vector &operator[](int);
   int size();
 };
-
-
-
-  
diff --git a/Examples/java/reference/example.i b/Examples/java/reference/example.i
index 6daa3b1..173143d 100644
--- a/Examples/java/reference/example.i
+++ b/Examples/java/reference/example.i
@@ -29,7 +29,7 @@
   VectorArray(int maxsize);
   ~VectorArray();
   int size();
-  
+
   /* This wrapper provides an alternative to the [] operator */
   %extend {
     Vector &get(int index) {
@@ -40,7 +40,3 @@
     }
   }
 };
-
-
-
-
diff --git a/Examples/java/simple/Makefile b/Examples/java/simple/Makefile
index e9e29f3..c0b1927 100644
--- a/Examples/java/simple/Makefile
+++ b/Examples/java/simple/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/template/Makefile b/Examples/java/template/Makefile
index 4e21fc4..637ce0e 100644
--- a/Examples/java/template/Makefile
+++ b/Examples/java/template/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/typemap/Makefile b/Examples/java/typemap/Makefile
index e858cbe..fa67e48 100644
--- a/Examples/java/typemap/Makefile
+++ b/Examples/java/typemap/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/variables/Makefile b/Examples/java/variables/Makefile
index e9e29f3..c0b1927 100644
--- a/Examples/java/variables/Makefile
+++ b/Examples/java/variables/Makefile
@@ -7,12 +7,12 @@
 JAVASRCS   = *.java
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile java_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
-	$(MAKE) -f $(TOP)/Makefile JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile java_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean
diff --git a/Examples/java/variables/example.c b/Examples/java/variables/example.c
index 05e17c8..85685fe 100644
--- a/Examples/java/variables/example.c
+++ b/Examples/java/variables/example.c
@@ -52,9 +52,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %s\n", name);
-  printf("ptptr     = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+  printf("ptptr     = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/javascript/class/Makefile b/Examples/javascript/class/Makefile
old mode 100755
new mode 100644
index 31846fa..54a8f7b
--- a/Examples/javascript/class/Makefile
+++ b/Examples/javascript/class/Makefile
@@ -1,3 +1,3 @@
 SRCS = example.cxx
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/class/binding.gyp b/Examples/javascript/class/binding.gyp
deleted file mode 100644
index 54eebfa..0000000
--- a/Examples/javascript/class/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example.cxx", "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/class/binding.gyp.in b/Examples/javascript/class/binding.gyp.in
new file mode 100644
index 0000000..cb2b45e
--- /dev/null
+++ b/Examples/javascript/class/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/class/example.cxx b/Examples/javascript/class/example.cxx
old mode 100755
new mode 100644
index e23fa6f..0463045
--- a/Examples/javascript/class/example.cxx
+++ b/Examples/javascript/class/example.cxx
@@ -1,5 +1,5 @@
-/* File : example.c */
-#include <iostream>
+/* File : example.cxx */
+
 #include "example.h"
 #define M_PI 3.14159265358979323846
 
@@ -11,18 +11,18 @@
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
+double Circle::area() {
   return M_PI*radius*radius;
 }
 
-double Circle::perimeter(void) {
+double Circle::perimeter() {
   return 2*M_PI*radius;
 }
 
-double Square::area(void) {
+double Square::area() {
   return width*width;
 }
 
-double Square::perimeter(void) {
+double Square::perimeter() {
   return 4*width;
 }
diff --git a/Examples/javascript/class/example.h b/Examples/javascript/class/example.h
old mode 100755
new mode 100644
index 64b7684..642130c
--- a/Examples/javascript/class/example.h
+++ b/Examples/javascript/class/example.h
@@ -7,11 +7,11 @@
   }
   virtual ~Shape() {
     nshapes--;
-  };
+  }
   double  x, y;   
   void    move(double dx, double dy);
-  virtual double area(void) = 0;
-  virtual double perimeter(void) = 0;
+  virtual double area() = 0;
+  virtual double perimeter() = 0;
   static  int nshapes;
 };
 
@@ -19,16 +19,16 @@
 private:
   double radius;
 public:
-  Circle(double r) : radius(r) { };
-  virtual double area(void);
-  virtual double perimeter(void);
+  Circle(double r) : radius(r) { }
+  virtual double area();
+  virtual double perimeter();
 };
 
 class Square : public Shape {
 private:
   double width;
 public:
-  Square(double w) : width(w) { };
-  virtual double area(void);
-  virtual double perimeter(void);
+  Square(double w) : width(w) { }
+  virtual double area();
+  virtual double perimeter();
 };
diff --git a/Examples/javascript/class/example.i b/Examples/javascript/class/example.i
old mode 100755
new mode 100644
index 75700b3..fbdf724
--- a/Examples/javascript/class/example.i
+++ b/Examples/javascript/class/example.i
@@ -7,4 +7,3 @@
 
 /* Let's just grab the original header file here */
 %include "example.h"
-
diff --git a/Examples/javascript/class/example.js b/Examples/javascript/class/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/class/example.js
+++ b/Examples/javascript/class/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/class/runme.js b/Examples/javascript/class/runme.js
old mode 100755
new mode 100644
index e1d5d97..6a77b8d
--- a/Examples/javascript/class/runme.js
+++ b/Examples/javascript/class/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 // ----- Object creation -----
 
diff --git a/Examples/javascript/constant/Makefile b/Examples/javascript/constant/Makefile
old mode 100755
new mode 100644
index ea04c7d..0402f8d
--- a/Examples/javascript/constant/Makefile
+++ b/Examples/javascript/constant/Makefile
@@ -1,3 +1,3 @@
 SRCS =
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/constant/binding.gyp b/Examples/javascript/constant/binding.gyp
deleted file mode 100644
index 69af46b..0000000
--- a/Examples/javascript/constant/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/constant/binding.gyp.in b/Examples/javascript/constant/binding.gyp.in
new file mode 100644
index 0000000..59779ae
--- /dev/null
+++ b/Examples/javascript/constant/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/constant/example.i b/Examples/javascript/constant/example.i
old mode 100755
new mode 100644
diff --git a/Examples/javascript/constant/example.js b/Examples/javascript/constant/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/constant/example.js
+++ b/Examples/javascript/constant/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/constant/runme.js b/Examples/javascript/constant/runme.js
old mode 100755
new mode 100644
index f4b5588..f29d1a8
--- a/Examples/javascript/constant/runme.js
+++ b/Examples/javascript/constant/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 console.log("ICONST  = " + example.ICONST  + " (should be 42)");
 console.log("FCONST  = " + example.FCONST  + " (should be 2.1828)");
diff --git a/Examples/javascript/enum/Makefile b/Examples/javascript/enum/Makefile
old mode 100755
new mode 100644
index 31846fa..54a8f7b
--- a/Examples/javascript/enum/Makefile
+++ b/Examples/javascript/enum/Makefile
@@ -1,3 +1,3 @@
 SRCS = example.cxx
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/enum/binding.gyp b/Examples/javascript/enum/binding.gyp
deleted file mode 100644
index 54eebfa..0000000
--- a/Examples/javascript/enum/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example.cxx", "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/enum/binding.gyp.in b/Examples/javascript/enum/binding.gyp.in
new file mode 100644
index 0000000..cb2b45e
--- /dev/null
+++ b/Examples/javascript/enum/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/enum/example.cxx b/Examples/javascript/enum/example.cxx
old mode 100755
new mode 100644
diff --git a/Examples/javascript/enum/example.h b/Examples/javascript/enum/example.h
old mode 100755
new mode 100644
diff --git a/Examples/javascript/enum/example.i b/Examples/javascript/enum/example.i
old mode 100755
new mode 100644
diff --git a/Examples/javascript/enum/example.js b/Examples/javascript/enum/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/enum/example.js
+++ b/Examples/javascript/enum/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/enum/runme.js b/Examples/javascript/enum/runme.js
old mode 100755
new mode 100644
index d4e89e8..851d43c
--- a/Examples/javascript/enum/runme.js
+++ b/Examples/javascript/enum/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 // ----- Object creation -----
 
diff --git a/Examples/javascript/example.mk b/Examples/javascript/example.mk
index 274eff1..cb8a33e 100644
--- a/Examples/javascript/example.mk
+++ b/Examples/javascript/example.mk
@@ -7,21 +7,27 @@
 	JSENGINE=node
 endif
 
+ifneq (, $(V8_VERSION))
+	JSV8_VERSION=$(V8_VERSION)
+else
+	JSV8_VERSION=0x031110
+endif
+
 EXAMPLES_TOP=../..
 SWIG_TOP=../../..
 SWIG = $(SWIG_TOP)/preinst-swig
 TARGET = example
 INTERFACE = example.i
-SWIGOPT=-$(JSENGINE)
+SWIGOPT=-$(JSENGINE) -DV8_VERSION=$(JSV8_VERSION)
 
 check: build
-	$(MAKE) -f $(EXAMPLES_TOP)/Makefile JSENGINE='$(JSENGINE)' TARGET='$(TARGET)' javascript_run
+	$(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' JSENGINE='$(JSENGINE)' TARGET='$(TARGET)' javascript_run
 
 build:
-	$(MAKE) -f $(EXAMPLES_TOP)/Makefile CXXSRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_wrapper_cpp
-	$(MAKE) -f $(EXAMPLES_TOP)/Makefile CXXSRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' JSENGINE='$(JSENGINE)' javascript_build_cpp
 
 clean:
-	$(MAKE) -f $(EXAMPLES_TOP)/Makefile javascript_clean
+	$(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' javascript_clean
diff --git a/Examples/javascript/exception/Makefile b/Examples/javascript/exception/Makefile
old mode 100755
new mode 100644
index 31846fa..54a8f7b
--- a/Examples/javascript/exception/Makefile
+++ b/Examples/javascript/exception/Makefile
@@ -1,3 +1,3 @@
 SRCS = example.cxx
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/exception/binding.gyp b/Examples/javascript/exception/binding.gyp.in
similarity index 83%
rename from Examples/javascript/exception/binding.gyp
rename to Examples/javascript/exception/binding.gyp.in
index 2be0a17..2e97d97 100644
--- a/Examples/javascript/exception/binding.gyp
+++ b/Examples/javascript/exception/binding.gyp.in
@@ -2,7 +2,8 @@
   "targets": [
     {
       "target_name": "example",
-      "sources": [ "example.cxx", "example_wrap.cxx" ],
+      "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"],
       'defines': [
         'BUILDING_NODE_EXTENSION=1',
       ],
diff --git a/Examples/javascript/exception/example.js b/Examples/javascript/exception/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/exception/example.js
+++ b/Examples/javascript/exception/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/exception/runme.js b/Examples/javascript/exception/runme.js
index 977f51e..43ce66d 100644
--- a/Examples/javascript/exception/runme.js
+++ b/Examples/javascript/exception/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 console.log("Trying to catch some exceptions.");
 t = new example.Test();
diff --git a/Examples/javascript/functor/Makefile b/Examples/javascript/functor/Makefile
old mode 100755
new mode 100644
index 31846fa..0402f8d
--- a/Examples/javascript/functor/Makefile
+++ b/Examples/javascript/functor/Makefile
@@ -1,3 +1,3 @@
-SRCS = example.cxx
+SRCS =
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/functor/binding.gyp b/Examples/javascript/functor/binding.gyp
deleted file mode 100644
index 54eebfa..0000000
--- a/Examples/javascript/functor/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example.cxx", "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/functor/binding.gyp.in b/Examples/javascript/functor/binding.gyp.in
new file mode 100644
index 0000000..59779ae
--- /dev/null
+++ b/Examples/javascript/functor/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/functor/example.js b/Examples/javascript/functor/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/functor/example.js
+++ b/Examples/javascript/functor/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/functor/runme.js b/Examples/javascript/functor/runme.js
index dc12470..28dc643 100644
--- a/Examples/javascript/functor/runme.js
+++ b/Examples/javascript/functor/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 a = new example.intSum(0);
 b = new example.doubleSum(100.0);
diff --git a/Examples/javascript/nspace/Makefile b/Examples/javascript/nspace/Makefile
old mode 100755
new mode 100644
index ea04c7d..0402f8d
--- a/Examples/javascript/nspace/Makefile
+++ b/Examples/javascript/nspace/Makefile
@@ -1,3 +1,3 @@
 SRCS =
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/nspace/binding.gyp b/Examples/javascript/nspace/binding.gyp
deleted file mode 100644
index 69af46b..0000000
--- a/Examples/javascript/nspace/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/nspace/binding.gyp.in b/Examples/javascript/nspace/binding.gyp.in
new file mode 100644
index 0000000..59779ae
--- /dev/null
+++ b/Examples/javascript/nspace/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/nspace/example.js b/Examples/javascript/nspace/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/nspace/example.js
+++ b/Examples/javascript/nspace/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/nspace/runme.js b/Examples/javascript/nspace/runme.js
index d6a49d8..fad7347 100644
--- a/Examples/javascript/nspace/runme.js
+++ b/Examples/javascript/nspace/runme.js
@@ -3,7 +3,7 @@
 // This file illustrates class C++ interface generated
 // by SWIG.
 
-var example = require("./example");
+var example = require("example");
 
 // Calling a module function ( aka global function )
 if (example.module_function() !== 7) {
diff --git a/Examples/javascript/operator/Makefile b/Examples/javascript/operator/Makefile
old mode 100755
new mode 100644
index ea04c7d..0402f8d
--- a/Examples/javascript/operator/Makefile
+++ b/Examples/javascript/operator/Makefile
@@ -1,3 +1,3 @@
 SRCS =
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/operator/binding.gyp b/Examples/javascript/operator/binding.gyp
deleted file mode 100644
index 69af46b..0000000
--- a/Examples/javascript/operator/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/operator/binding.gyp.in b/Examples/javascript/operator/binding.gyp.in
new file mode 100644
index 0000000..59779ae
--- /dev/null
+++ b/Examples/javascript/operator/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/operator/example.js b/Examples/javascript/operator/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/operator/example.js
+++ b/Examples/javascript/operator/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/operator/runme.js b/Examples/javascript/operator/runme.js
index a700918..f72ca1c 100644
--- a/Examples/javascript/operator/runme.js
+++ b/Examples/javascript/operator/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 a = new example.Complex(2,3);
 b = new example.Complex(-5,10);
diff --git a/Examples/javascript/overload/Makefile b/Examples/javascript/overload/Makefile
old mode 100755
new mode 100644
index ea04c7d..0402f8d
--- a/Examples/javascript/overload/Makefile
+++ b/Examples/javascript/overload/Makefile
@@ -1,3 +1,3 @@
 SRCS =
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/overload/binding.gyp b/Examples/javascript/overload/binding.gyp
deleted file mode 100644
index 69af46b..0000000
--- a/Examples/javascript/overload/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/overload/binding.gyp.in b/Examples/javascript/overload/binding.gyp.in
new file mode 100644
index 0000000..59779ae
--- /dev/null
+++ b/Examples/javascript/overload/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/overload/example.js b/Examples/javascript/overload/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/overload/example.js
+++ b/Examples/javascript/overload/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/overload/runme.js b/Examples/javascript/overload/runme.js
index 1e6c861..1c23e3b 100644
--- a/Examples/javascript/overload/runme.js
+++ b/Examples/javascript/overload/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 example.f();
 example.f(1);
diff --git a/Examples/javascript/pointer/Makefile b/Examples/javascript/pointer/Makefile
old mode 100755
new mode 100644
index 31846fa..54a8f7b
--- a/Examples/javascript/pointer/Makefile
+++ b/Examples/javascript/pointer/Makefile
@@ -1,3 +1,3 @@
 SRCS = example.cxx
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/pointer/binding.gyp b/Examples/javascript/pointer/binding.gyp
deleted file mode 100644
index 54eebfa..0000000
--- a/Examples/javascript/pointer/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example.cxx", "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/pointer/binding.gyp.in b/Examples/javascript/pointer/binding.gyp.in
new file mode 100644
index 0000000..cb2b45e
--- /dev/null
+++ b/Examples/javascript/pointer/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/pointer/example.cxx b/Examples/javascript/pointer/example.cxx
old mode 100755
new mode 100644
diff --git a/Examples/javascript/pointer/example.i b/Examples/javascript/pointer/example.i
old mode 100755
new mode 100644
diff --git a/Examples/javascript/pointer/example.js b/Examples/javascript/pointer/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/pointer/example.js
+++ b/Examples/javascript/pointer/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/pointer/runme.js b/Examples/javascript/pointer/runme.js
old mode 100755
new mode 100644
index fb8cf0c..e9fa9a0
--- a/Examples/javascript/pointer/runme.js
+++ b/Examples/javascript/pointer/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 // First create some objects using the pointer library.
 console.log("Testing the pointer library");
diff --git a/Examples/javascript/pointer/typemaps.i b/Examples/javascript/pointer/typemaps.i
deleted file mode 100644
index e69de29..0000000
--- a/Examples/javascript/pointer/typemaps.i
+++ /dev/null
diff --git a/Examples/javascript/reference/Makefile b/Examples/javascript/reference/Makefile
old mode 100755
new mode 100644
index 31846fa..54a8f7b
--- a/Examples/javascript/reference/Makefile
+++ b/Examples/javascript/reference/Makefile
@@ -1,3 +1,3 @@
 SRCS = example.cxx
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/reference/binding.gyp b/Examples/javascript/reference/binding.gyp
deleted file mode 100644
index 54eebfa..0000000
--- a/Examples/javascript/reference/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example.cxx", "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/reference/binding.gyp.in b/Examples/javascript/reference/binding.gyp.in
new file mode 100644
index 0000000..cb2b45e
--- /dev/null
+++ b/Examples/javascript/reference/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/reference/example.cxx b/Examples/javascript/reference/example.cxx
old mode 100755
new mode 100644
index 8a513bf..9dbaed2
--- a/Examples/javascript/reference/example.cxx
+++ b/Examples/javascript/reference/example.cxx
@@ -19,7 +19,7 @@
 
 char *Vector::print() {
   static char temp[512];
-  sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
diff --git a/Examples/javascript/reference/example.h b/Examples/javascript/reference/example.h
old mode 100755
new mode 100644
index 4915adb..bcfcfb7
--- a/Examples/javascript/reference/example.h
+++ b/Examples/javascript/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   friend Vector operator+(const Vector &a, const Vector &b);
   char *print();
 };
@@ -20,7 +20,3 @@
   Vector &operator[](int);
   int size();
 };
-
-
-
-  
diff --git a/Examples/javascript/reference/example.i b/Examples/javascript/reference/example.i
old mode 100755
new mode 100644
index 1cf19c8..173143d
--- a/Examples/javascript/reference/example.i
+++ b/Examples/javascript/reference/example.i
@@ -29,7 +29,7 @@
   VectorArray(int maxsize);
   ~VectorArray();
   int size();
-  
+
   /* This wrapper provides an alternative to the [] operator */
   %extend {
     Vector &get(int index) {
diff --git a/Examples/javascript/reference/example.js b/Examples/javascript/reference/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/reference/example.js
+++ b/Examples/javascript/reference/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/reference/runme.js b/Examples/javascript/reference/runme.js
old mode 100755
new mode 100644
index 88c1083..04f7325
--- a/Examples/javascript/reference/runme.js
+++ b/Examples/javascript/reference/runme.js
@@ -1,5 +1,5 @@
 // This file illustrates the manipulation of C++ references in Javascript.
-var example = require("./example");
+var example = require("example");
 
 // ----- Object creation -----
 
diff --git a/Examples/javascript/simple/Makefile b/Examples/javascript/simple/Makefile
old mode 100755
new mode 100644
index 31846fa..54a8f7b
--- a/Examples/javascript/simple/Makefile
+++ b/Examples/javascript/simple/Makefile
@@ -1,3 +1,3 @@
 SRCS = example.cxx
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/simple/binding.gyp b/Examples/javascript/simple/binding.gyp
deleted file mode 100644
index 54eebfa..0000000
--- a/Examples/javascript/simple/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example.cxx", "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/simple/binding.gyp.in b/Examples/javascript/simple/binding.gyp.in
new file mode 100644
index 0000000..cb2b45e
--- /dev/null
+++ b/Examples/javascript/simple/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/simple/example.js b/Examples/javascript/simple/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/simple/example.js
+++ b/Examples/javascript/simple/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/simple/runme.js b/Examples/javascript/simple/runme.js
old mode 100755
new mode 100644
index be2c186..4abff0e
--- a/Examples/javascript/simple/runme.js
+++ b/Examples/javascript/simple/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 /* Call our gcd() function */
 
diff --git a/Examples/javascript/template/Makefile b/Examples/javascript/template/Makefile
old mode 100755
new mode 100644
index ea04c7d..0402f8d
--- a/Examples/javascript/template/Makefile
+++ b/Examples/javascript/template/Makefile
@@ -1,3 +1,3 @@
 SRCS =
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/template/binding.gyp b/Examples/javascript/template/binding.gyp
deleted file mode 100644
index 69af46b..0000000
--- a/Examples/javascript/template/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/template/binding.gyp.in b/Examples/javascript/template/binding.gyp.in
new file mode 100644
index 0000000..59779ae
--- /dev/null
+++ b/Examples/javascript/template/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/template/example.js b/Examples/javascript/template/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/template/example.js
+++ b/Examples/javascript/template/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/template/runme.js b/Examples/javascript/template/runme.js
index 55894df..6a29fa7 100644
--- a/Examples/javascript/template/runme.js
+++ b/Examples/javascript/template/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 //Call some templated functions
 console.log(example.maxint(3,7));
@@ -9,20 +9,20 @@
 iv = new example.vecint(100);
 dv = new example.vecdouble(1000);
 
-for(i=0;i<=100;i++)
+for(i=0;i<100;i++)
       iv.setitem(i,2*i);
 
-for(i=0;i<=1000;i++)
+for(i=0;i<1000;i++)
       dv.setitem(i, 1.0/(i+1));
 
 sum = 0;
-for(i=0;i<=100;i++)
+for(i=0;i<100;i++)
       sum = sum + iv.getitem(i);
 
 console.log(sum);
 
 sum = 0.0;
-for(i=0;i<=1000;i++)
+for(i=0;i<1000;i++)
       sum = sum + dv.getitem(i);
 console.log(sum);
 
diff --git a/Examples/javascript/variables/Makefile b/Examples/javascript/variables/Makefile
old mode 100755
new mode 100644
index 31846fa..54a8f7b
--- a/Examples/javascript/variables/Makefile
+++ b/Examples/javascript/variables/Makefile
@@ -1,3 +1,3 @@
 SRCS = example.cxx
 
-include ../example.mk
+include $(SRCDIR)../example.mk
diff --git a/Examples/javascript/variables/binding.gyp b/Examples/javascript/variables/binding.gyp
deleted file mode 100644
index 54eebfa..0000000
--- a/Examples/javascript/variables/binding.gyp
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "targets": [
-    {
-      "target_name": "example",
-      "sources": [ "example.cxx", "example_wrap.cxx" ]
-    }
-  ]
-}
diff --git a/Examples/javascript/variables/binding.gyp.in b/Examples/javascript/variables/binding.gyp.in
new file mode 100644
index 0000000..cb2b45e
--- /dev/null
+++ b/Examples/javascript/variables/binding.gyp.in
@@ -0,0 +1,9 @@
+{
+  "targets": [
+    {
+      "target_name": "example",
+      "sources": [ "<!(cp $srcdir/example.cxx example-gypcopy.cxx && echo example-gypcopy.cxx)", "example_wrap.cxx" ],
+      "include_dirs": ["$srcdir"]
+    }
+  ]
+}
diff --git a/Examples/javascript/variables/example.cxx b/Examples/javascript/variables/example.cxx
old mode 100755
new mode 100644
index f10390a..15314b3
--- a/Examples/javascript/variables/example.cxx
+++ b/Examples/javascript/variables/example.cxx
@@ -57,9 +57,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %s\n", name);
-  printf("ptptr     = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+  printf("ptptr     = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/javascript/variables/example.h b/Examples/javascript/variables/example.h
old mode 100755
new mode 100644
diff --git a/Examples/javascript/variables/example.i b/Examples/javascript/variables/example.i
old mode 100755
new mode 100644
diff --git a/Examples/javascript/variables/example.js b/Examples/javascript/variables/example.js
index 79cd391..2e7f83a 100644
--- a/Examples/javascript/variables/example.js
+++ b/Examples/javascript/variables/example.js
@@ -1 +1 @@
-module.exports = require("./build/Release/example");
+module.exports = require("build/Release/example");
diff --git a/Examples/javascript/variables/runme.js b/Examples/javascript/variables/runme.js
old mode 100755
new mode 100644
index 537e172..a2b5f79
--- a/Examples/javascript/variables/runme.js
+++ b/Examples/javascript/variables/runme.js
@@ -1,4 +1,4 @@
-var example = require("./example");
+var example = require("example");
 
 // Try to set the values of some global variables
 example.ivar   =  42;
diff --git a/Examples/lua/arrays/Makefile b/Examples/lua/arrays/Makefile
index d398dff..4191f7e 100644
--- a/Examples/lua/arrays/Makefile
+++ b/Examples/lua/arrays/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/arrays/example.c b/Examples/lua/arrays/example.c
index ed23738..da1bd75 100644
--- a/Examples/lua/arrays/example.c
+++ b/Examples/lua/arrays/example.c
@@ -13,7 +13,7 @@
   qsort(arr, len, sizeof(int), compare_int);
 }
 
-// ditto doubles
+/* ditto doubles */
 int compare_double(const void * a, const void * b)
 {
   return (int)( *(double*)a - *(double*)b );
diff --git a/Examples/lua/class/Makefile b/Examples/lua/class/Makefile
index c39e8ac..96308f0 100644
--- a/Examples/lua/class/Makefile
+++ b/Examples/lua/class/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/class/example.cxx b/Examples/lua/class/example.cxx
index 1e8e203..0463045 100644
--- a/Examples/lua/class/example.cxx
+++ b/Examples/lua/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
 
 #include "example.h"
 #define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
+double Circle::area() {
   return M_PI*radius*radius;
 }
 
-double Circle::perimeter(void) {
+double Circle::perimeter() {
   return 2*M_PI*radius;
 }
 
-double Square::area(void) {
+double Square::area() {
   return width*width;
 }
 
-double Square::perimeter(void) {
+double Square::perimeter() {
   return 4*width;
 }
diff --git a/Examples/lua/class/runme.lua b/Examples/lua/class/runme.lua
index 2c3ad8c..5d140de 100644
--- a/Examples/lua/class/runme.lua
+++ b/Examples/lua/class/runme.lua
@@ -53,7 +53,6 @@
 -- Note: this invokes the virtual destructor
 c=nil
 s=nil
-s = 3
 
 -- call gc to make sure they are collected
 collectgarbage()
diff --git a/Examples/lua/constants/Makefile b/Examples/lua/constants/Makefile
index 7e36e15..ae33cb1 100644
--- a/Examples/lua/constants/Makefile
+++ b/Examples/lua/constants/Makefile
@@ -6,15 +6,15 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/dual/Makefile b/Examples/lua/dual/Makefile
index 12ee00a..c86152a 100644
--- a/Examples/lua/dual/Makefile
+++ b/Examples/lua/dual/Makefile
@@ -1,21 +1,21 @@
 TOP        = ../..
 SWIG       = $(TOP)/../preinst-swig
 TARGET     = dual
-CXXSRCS    = example2_wrap.cxx
+GENCXXSRCS = example2_wrap.cxx
 INTERFACE  = dual.i
 LUA_INTERP = dual.cpp
 
 # This is a little different to normal as we need to static link two modules and a custom interpreter
 # We need the external runtime, then swig examples2, and build the module as normal
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run
 
 build:
 	$(SWIG) -lua -external-runtime
-	$(SWIG) -c++ -lua $(SWIGOPT) example2.i
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(SWIG) -c++ -lua $(SWIGOPT) -o $(GENCXXSRCS) $(SRCDIR)example2.i
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) GENCXXSRCS='$(GENCXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
 	rm -f swigluarun.h $(TARGET)
diff --git a/Examples/lua/dual/dual.cpp b/Examples/lua/dual/dual.cpp
index b54e44d..2108a72 100644
--- a/Examples/lua/dual/dual.cpp
+++ b/Examples/lua/dual/dual.cpp
@@ -45,14 +45,14 @@
   swig_type_info *pTypeInfo=0,*pTypeInfo2=0;
   swig_module_info *pModule=0;
   pModule=SWIG_GetModule(L);
-  DEBUG2("  SWIG_GetModule() returns %p\n",pModule)
+  DEBUG2("  SWIG_GetModule() returns %p\n", (void *)pModule)
   if(pModule==0) return;
   pTypeInfo = SWIG_TypeQuery(L,"Foo *");
   DEBUG2("  Type (Foo*) is %s\n",pTypeInfo==0?"unknown":"known");
-  DEBUG3("    Module %p typeinfo(Foo*) %p\n",pModule,pTypeInfo);
+  DEBUG3("    Module %p typeinfo(Foo*) %p\n", (void *)pModule, (void *)pTypeInfo);
   pTypeInfo2 = SWIG_TypeQuery(L,"Bar *");
   DEBUG2("  Type (Bar*) is %s\n",pTypeInfo2==0?"unknown":"known");
-  DEBUG3("    Module %p typeinfo(Bar*) %p\n",pModule,pTypeInfo2);
+  DEBUG3("    Module %p typeinfo(Bar*) %p\n", (void *)pModule, (void *)pTypeInfo2);
 }
 
 int main(int argc,char* argv[])
diff --git a/Examples/lua/embed/Makefile b/Examples/lua/embed/Makefile
index 57979c0..5e3a918 100644
--- a/Examples/lua/embed/Makefile
+++ b/Examples/lua/embed/Makefile
@@ -9,12 +9,12 @@
 # this is a little different to normal as we have our own special interpreter
 # which we want to static link
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
 	rm -f $(TARGET)
diff --git a/Examples/lua/embed/embed.c b/Examples/lua/embed/embed.c
index 5075674..1f10cc8 100644
--- a/Examples/lua/embed/embed.c
+++ b/Examples/lua/embed/embed.c
@@ -13,6 +13,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <lua.h>
 #include <lauxlib.h>
@@ -62,9 +63,13 @@
   luaopen_example(L);
   printf("[C] all looks ok\n");
   printf("\n");
-  printf("[C] let's load the file 'runme.lua'\n");
+  if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) {
+    printf("[C] ERROR: no lua file given on command line\n");
+    exit(3);
+  }
+  printf("[C] let's load the file '%s'\n", argv[1]);
   printf("[C] any lua code in this file will be executed\n");
-  if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
+  if (luaL_loadfile(L, argv[1]) || lua_pcall(L, 0, 0, 0)) {
     printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
     exit(3);
   }
diff --git a/Examples/lua/embed2/Makefile b/Examples/lua/embed2/Makefile
index ec22bdc..d30ba09 100644
--- a/Examples/lua/embed2/Makefile
+++ b/Examples/lua/embed2/Makefile
@@ -9,12 +9,12 @@
 # this is a little different to normal as we have our own special interpreter
 # which we want to static link
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' LIBS='$(LIBS)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
 	rm -f $(TARGET)
diff --git a/Examples/lua/embed2/embed2.c b/Examples/lua/embed2/embed2.c
index 100a1fb..0ce9f8f 100644
--- a/Examples/lua/embed2/embed2.c
+++ b/Examples/lua/embed2/embed2.c
@@ -24,6 +24,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <lua.h>
 #include <lauxlib.h>
@@ -52,7 +53,7 @@
   lua_getglobal(L, "add");               /* function to be called */
   if (!lua_isfunction(L,-1)) {
     printf("[C] error: cannot find function 'add'\n");
-    lua_settop(L,top);  // reset
+    lua_settop(L,top);
     return 0;
   }
   lua_pushnumber(L,a);
@@ -60,18 +61,18 @@
   if (lua_pcall(L, 2, 1, 0) != 0)  /* call function with 2 arguments and 1 result */
   {
     printf("[C] error running function `add': %s\n",lua_tostring(L, -1));
-    lua_settop(L,top);  // reset
+    lua_settop(L,top);
     return 0;
   }
-  // check results
+  /* check results */
   if (!lua_isnumber(L,-1)) {
     printf("[C] error: returned value is not a number\n");
-    lua_settop(L,top);  // reset
+    lua_settop(L,top);
     return 0;
   }
   *res=(int)lua_tonumber(L,-1);
   lua_settop(L,top);  /* reset stack */
-  return 1;   // ok
+  return 1;
 }
 
 /* This is a variargs call function for calling from C into Lua.
@@ -189,9 +190,13 @@
   luaopen_example(L);
   printf("[C] all looks ok\n");
   printf("\n");
-  printf("[C] let's load the file 'runme.lua'\n");
+  if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) {
+    printf("[C] ERROR: no lua file given on command line\n");
+    exit(3);
+  }
+  printf("[C] let's load the file '%s'\n", argv[1]);
   printf("[C] any lua code in this file will be executed\n");
-  if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
+  if (luaL_loadfile(L, argv[1]) || lua_pcall(L, 0, 0, 0)) {
     printf("[C] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
     exit(3);
   }
diff --git a/Examples/lua/embed2/runme.lua b/Examples/lua/embed2/runme.lua
index 9e7ab61..6e93164 100644
--- a/Examples/lua/embed2/runme.lua
+++ b/Examples/lua/embed2/runme.lua
@@ -3,25 +3,25 @@
 -- we do not need to load the library, as it was already in the interpreter
 -- but let's check anyway
 assert(type(example)=='table',"Don't appear to have loaded the example module")
-

--- note: we will copy the functions from example table into global

--- this will help us later

-for k,v in pairs(example) do _G[k]=v end

 
--- our add function

+-- note: we will copy the functions from example table into global
+-- this will help us later
+for k,v in pairs(example) do _G[k]=v end
+
+-- our add function
 -- we will be calling this from C
-function add(a,b)

-    print("[lua] this is function add(",a,b,")")

-    c=a+b

-    print("[lua] returning",c)

-    return c

+function add(a,b)
+    print("[lua] this is function add(",a,b,")")
+    c=a+b
+    print("[lua] returning",c)
+    return c
 end
 
-function append(a,b)

-    print("[lua] this is function append(",a,b,")")

-    c=a..b

-    print("[lua] returning",c)

-    return c

+function append(a,b)
+    print("[lua] this is function append(",a,b,")")
+    c=a..b
+    print("[lua] returning",c)
+    return c
 end
 
 
diff --git a/Examples/lua/embed3/Makefile b/Examples/lua/embed3/Makefile
index 8cfa974..fc00261 100644
--- a/Examples/lua/embed3/Makefile
+++ b/Examples/lua/embed3/Makefile
@@ -9,13 +9,13 @@
 # which we want to static link
 # we also need the external runtime, so we can get access to certain internals of SWIG
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' lua_embed_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' lua_embed_run
 
 build:
 	$(SWIG) -c++ -lua $(SWIGOPT) -external-runtime swigluarun.h
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' LUA_INTERP='$(LUA_INTERP)' lua_static_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
 	rm -f swigluarun.h $(TARGET)
diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp
index d559167..9be49ad 100644
--- a/Examples/lua/embed3/embed3.cpp
+++ b/Examples/lua/embed3/embed3.cpp
@@ -113,10 +113,14 @@
   push_pointer(L,&engine,"Engine *",0);
   lua_setglobal(L, "pEngine");  // set as global variable
 
-  printf("[C++] now let's load the file 'runme.lua'\n");
+  if (argc != 2 || argv[1] == NULL || strlen(argv[1]) == 0) {
+    printf("[C++] ERROR: no lua file given on command line\n");
+    exit(3);
+  }
+  printf("[C++] now let's load the file '%s'\n", argv[1]);
   printf("[C++] any lua code in this file will be executed\n");
-  if (luaL_loadfile(L, "runme.lua") || lua_pcall(L, 0, 0, 0)) {
-    printf("[C++] ERROR: cannot run lua file: %s", lua_tostring(L, -1));
+  if (luaL_loadfile(L, argv[1]) || lua_pcall(L, 0, 0, 0)) {
+    printf("[C++] ERROR: cannot run lua file: %s",lua_tostring(L, -1));
     exit(3);
   }
   printf("[C++] We are now back in C++, all looks ok\n");
diff --git a/Examples/lua/exception/Makefile b/Examples/lua/exception/Makefile
index 3dbebb4..ac9c28b 100644
--- a/Examples/lua/exception/Makefile
+++ b/Examples/lua/exception/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/funcptr3/Makefile b/Examples/lua/funcptr3/Makefile
index 8b51e73..aeeaad4 100644
--- a/Examples/lua/funcptr3/Makefile
+++ b/Examples/lua/funcptr3/Makefile
@@ -6,15 +6,15 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/functest/Makefile b/Examples/lua/functest/Makefile
index 8b51e73..aeeaad4 100644
--- a/Examples/lua/functest/Makefile
+++ b/Examples/lua/functest/Makefile
@@ -6,15 +6,15 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/functest/example.i b/Examples/lua/functest/example.i
index 631e060..9bb64cb 100644
--- a/Examples/lua/functest/example.i
+++ b/Examples/lua/functest/example.i
@@ -1,13 +1,12 @@
 /* File : example.i */
 %module example
 
-%include "typemaps.i" // you must have this for the typemaps for ptrs
-// basic function testing
-//
+%include "typemaps.i"
+
 %inline %{
-extern int add1(int x, int y);              // return x+y -- basic function test
-extern void add2(int x, int *INPUT, int *OUTPUT); // *z = x+*y  -- argin and argout test
-extern int add3(int x, int y, int *OUTPUT);    // return x+y, *z=x-y -- returning 2 values
-extern void add4(int x, int *INOUT);        // *y += x    -- INOUT dual purpose variable
+extern int add1(int x, int y);              /* return x+y -- basic function test */
+extern void add2(int x, int *INPUT, int *OUTPUT); /* *z = x+*y  -- argin and argout test */
+extern int add3(int x, int y, int *OUTPUT);    /* return x+y, *z=x-y -- returning 2 values */
+extern void add4(int x, int *INOUT);        /* *y += x    -- INOUT dual purpose variable */
 %}
 
diff --git a/Examples/lua/functor/Makefile b/Examples/lua/functor/Makefile
index 4e4edbf..e647fb2 100644
--- a/Examples/lua/functor/Makefile
+++ b/Examples/lua/functor/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/import/Makefile b/Examples/lua/import/Makefile
index 0a9aebd..8d64a21 100644
--- a/Examples/lua/import/Makefile
+++ b/Examples/lua/import/Makefile
@@ -4,17 +4,17 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' lua_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' lua_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' lua_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' lua_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/import/base.h b/Examples/lua/import/base.h
index fec0f32..ff6fecd 100644
--- a/Examples/lua/import/base.h
+++ b/Examples/lua/import/base.h
@@ -1,7 +1,7 @@
 class Base {
  public:
-     Base() { };
-     virtual ~Base() { };
+     Base() { }
+     virtual ~Base() { }
      virtual const char * A() const {
          return "Base::A";
      }
diff --git a/Examples/lua/nspace/Makefile b/Examples/lua/nspace/Makefile
index 57875ec..17757c2 100644
--- a/Examples/lua/nspace/Makefile
+++ b/Examples/lua/nspace/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/owner/Makefile b/Examples/lua/owner/Makefile
index c39e8ac..96308f0 100644
--- a/Examples/lua/owner/Makefile
+++ b/Examples/lua/owner/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/owner/example.cxx b/Examples/lua/owner/example.cxx
index bce484a..c2c073d 100644
--- a/Examples/lua/owner/example.cxx
+++ b/Examples/lua/owner/example.cxx
@@ -39,12 +39,15 @@
     return new Square(w);
 }
 
-ShapeOwner::ShapeOwner() {printf("  ShapeOwner(%p)\n",this);}
+ShapeOwner::ShapeOwner() {
+  printf("  ShapeOwner(%p)\n", (void *)this);
+}
+
 ShapeOwner::~ShapeOwner()
 {
-    printf("  ~ShapeOwner(%p)\n",this);
-    for(unsigned i=0;i<shapes.size();i++)
-        delete shapes[i];
+  printf("  ~ShapeOwner(%p)\n", (void *)this);
+  for(unsigned i=0;i<shapes.size();i++)
+    delete shapes[i];
 }
 
 void ShapeOwner::add(Shape* ptr) // this method takes ownership of the object
diff --git a/Examples/lua/owner/example.h b/Examples/lua/owner/example.h
index 320bb25..9101c63 100644
--- a/Examples/lua/owner/example.h
+++ b/Examples/lua/owner/example.h
@@ -8,7 +8,7 @@
   }
   virtual ~Shape() {
     nshapes--;
-  };
+  }
   double  x, y;   
   void    move(double dx, double dy);
   virtual double area(void) = 0;
@@ -20,7 +20,7 @@
 private:
   double radius;
 public:
-  Circle(double r) : radius(r) { };
+  Circle(double r) : radius(r) { }
   virtual double area(void);
   virtual double perimeter(void);
 };
@@ -29,7 +29,7 @@
 private:
   double width;
 public:
-  Square(double w) : width(w) { };
+  Square(double w) : width(w) { }
   virtual double area(void);
   virtual double perimeter(void);
 };
diff --git a/Examples/lua/pointer/Makefile b/Examples/lua/pointer/Makefile
index 8b51e73..aeeaad4 100644
--- a/Examples/lua/pointer/Makefile
+++ b/Examples/lua/pointer/Makefile
@@ -6,15 +6,15 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/simple/Makefile b/Examples/lua/simple/Makefile
index d398dff..4191f7e 100644
--- a/Examples/lua/simple/Makefile
+++ b/Examples/lua/simple/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/variables/Makefile b/Examples/lua/variables/Makefile
index d398dff..4191f7e 100644
--- a/Examples/lua/variables/Makefile
+++ b/Examples/lua/variables/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile lua_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' lua
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mylua' INTERFACE='$(INTERFACE)' lua_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile lua_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' lua_clean
diff --git a/Examples/lua/variables/example.c b/Examples/lua/variables/example.c
index 05e17c8..85685fe 100644
--- a/Examples/lua/variables/example.c
+++ b/Examples/lua/variables/example.c
@@ -52,9 +52,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %s\n", name);
-  printf("ptptr     = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+  printf("ptptr     = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/modula3/class/Makefile b/Examples/modula3/class/Makefile
index af8e099..2e2f375 100644
--- a/Examples/modula3/class/Makefile
+++ b/Examples/modula3/class/Makefile
@@ -8,10 +8,10 @@
 MODULA3SRCS = *.[im]3
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile modula3_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
 	m3ppinplace $(MODULA3SRCS)
 # compilation of example_wrap.cxx is started by cm3
@@ -21,4 +21,4 @@
 	cm3
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile modula3_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
diff --git a/Examples/modula3/class/example.cxx b/Examples/modula3/class/example.cxx
index 1e8e203..0463045 100644
--- a/Examples/modula3/class/example.cxx
+++ b/Examples/modula3/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
 
 #include "example.h"
 #define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
+double Circle::area() {
   return M_PI*radius*radius;
 }
 
-double Circle::perimeter(void) {
+double Circle::perimeter() {
   return 2*M_PI*radius;
 }
 
-double Square::area(void) {
+double Square::area() {
   return width*width;
 }
 
-double Square::perimeter(void) {
+double Square::perimeter() {
   return 4*width;
 }
diff --git a/Examples/modula3/enum/Makefile b/Examples/modula3/enum/Makefile
index a351cb1..3915e54 100644
--- a/Examples/modula3/enum/Makefile
+++ b/Examples/modula3/enum/Makefile
@@ -8,18 +8,18 @@
 MODULA3SRCS  = *.[im]3
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile modula3_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
 
 build:
 	$(SWIG) -modula3 $(SWIGOPT) -module Example -generateconst $(CONSTNUMERIC) $(TARGET).h
 	$(CXX) -Wall $(CONSTNUMERIC).c -o $(CONSTNUMERIC)
 	$(CONSTNUMERIC) >$(CONSTNUMERIC).i
 
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
 	m3ppinplace $(MODULA3SRCS)
 	mv m3makefile $(MODULA3SRCS) src/
 	cm3
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile modula3_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
diff --git a/Examples/modula3/exception/Makefile b/Examples/modula3/exception/Makefile
index 8d45255..1dbf1a1 100644
--- a/Examples/modula3/exception/Makefile
+++ b/Examples/modula3/exception/Makefile
@@ -8,15 +8,15 @@
 MODULA3FLAGS= -o runme
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile modula3_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3_cpp
-#	$(MAKE) -f $(TOP)/Makefile MODULA3SRCS='$(MODULA3SRCS)' MODULA3FLAGS='$(MODULA3FLAGS)' modula3_compile
+#	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MODULA3SRCS='$(MODULA3SRCS)' MODULA3FLAGS='$(MODULA3FLAGS)' modula3_compile
 	m3ppinplace $(MODULA3SRCS)
 	mv m3makefile $(MODULA3SRCS) src/
 	cm3
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile modula3_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
diff --git a/Examples/modula3/reference/Makefile b/Examples/modula3/reference/Makefile
index 1a5fdeb..3b68fe8 100644
--- a/Examples/modula3/reference/Makefile
+++ b/Examples/modula3/reference/Makefile
@@ -7,14 +7,14 @@
 MODULA3SRCS = *.[im]3
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile modula3_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
 	m3ppinplace $(MODULA3SRCS)
 	mv m3makefile $(MODULA3SRCS) src/
 	cm3
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile modula3_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
diff --git a/Examples/modula3/reference/example.cxx b/Examples/modula3/reference/example.cxx
index 649b016..9dbaed2 100644
--- a/Examples/modula3/reference/example.cxx
+++ b/Examples/modula3/reference/example.cxx
@@ -19,7 +19,7 @@
 
 char *Vector::print() {
   static char temp[512];
-  sprintf(temp,"Vector %x (%g,%g,%g)", (int)this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
diff --git a/Examples/modula3/reference/example.h b/Examples/modula3/reference/example.h
index 0a9cd44..7b4ba8f 100644
--- a/Examples/modula3/reference/example.h
+++ b/Examples/modula3/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   Vector operator+(const Vector &b) const;
   char *print();
 };
diff --git a/Examples/modula3/simple/Makefile b/Examples/modula3/simple/Makefile
index 6287dac..2796b25 100644
--- a/Examples/modula3/simple/Makefile
+++ b/Examples/modula3/simple/Makefile
@@ -7,14 +7,14 @@
 MODULA3SRCS = *.[im]3
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile modula3_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
 	m3ppinplace $(MODULA3SRCS)
 	mv m3makefile $(MODULA3SRCS) src/
 	cm3
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile modula3_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
diff --git a/Examples/modula3/typemap/Makefile b/Examples/modula3/typemap/Makefile
index 6287dac..2796b25 100644
--- a/Examples/modula3/typemap/Makefile
+++ b/Examples/modula3/typemap/Makefile
@@ -7,14 +7,14 @@
 MODULA3SRCS = *.[im]3
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile modula3_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' modula3
 	m3ppinplace $(MODULA3SRCS)
 	mv m3makefile $(MODULA3SRCS) src/
 	cm3
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile modula3_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' modula3_clean
diff --git a/Examples/mzscheme/multimap/Makefile b/Examples/mzscheme/multimap/Makefile
index f8eeb72..ecf83fb 100644
--- a/Examples/mzscheme/multimap/Makefile
+++ b/Examples/mzscheme/multimap/Makefile
@@ -6,10 +6,10 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile mzscheme_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
 clean:
-	$(MAKE) -f $(TOP)/Makefile mzscheme_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
diff --git a/Examples/mzscheme/simple/Makefile b/Examples/mzscheme/simple/Makefile
index f8eeb72..ecf83fb 100644
--- a/Examples/mzscheme/simple/Makefile
+++ b/Examples/mzscheme/simple/Makefile
@@ -6,10 +6,10 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile mzscheme_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
 clean:
-	$(MAKE) -f $(TOP)/Makefile mzscheme_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
diff --git a/Examples/mzscheme/std_vector/Makefile b/Examples/mzscheme/std_vector/Makefile
index d2bf0a0..75918a6 100644
--- a/Examples/mzscheme/std_vector/Makefile
+++ b/Examples/mzscheme/std_vector/Makefile
@@ -9,7 +9,7 @@
 MZC        = test -n "/usr/bin/mzc" && /usr/bin/mzc
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile mzscheme_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
 
 build:
 	$(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
@@ -17,4 +17,4 @@
 	$(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile mzscheme_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
diff --git a/Examples/ocaml/argout_ref/Makefile b/Examples/ocaml/argout_ref/Makefile
index 4e12e37..09893af 100644
--- a/Examples/ocaml/argout_ref/Makefile
+++ b/Examples/ocaml/argout_ref/Makefile
@@ -8,21 +8,21 @@
 OBJS       = example.o
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
 
 build: static
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static_cpp
 
 dynamic:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_dynamic_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
diff --git a/Examples/ocaml/contract/Makefile b/Examples/ocaml/contract/Makefile
index 1db93e3..df5d6a6 100644
--- a/Examples/ocaml/contract/Makefile
+++ b/Examples/ocaml/contract/Makefile
@@ -8,27 +8,27 @@
 OBJS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
 
 build: static
 
 dynamic:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_dynamic
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static
 
 toplevel:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static_toplevel
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
diff --git a/Examples/ocaml/scoped_enum/Makefile b/Examples/ocaml/scoped_enum/Makefile
index e5de57a..7947339 100644
--- a/Examples/ocaml/scoped_enum/Makefile
+++ b/Examples/ocaml/scoped_enum/Makefile
@@ -8,27 +8,27 @@
 OBJS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
 
 build: static
 
 dynamic:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_dynamic_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static_cpp
 
 toplevel:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static_cpp_toplevel
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile
index c1ab650..69102f3 100644
--- a/Examples/ocaml/shapes/Makefile
+++ b/Examples/ocaml/shapes/Makefile
@@ -9,27 +9,27 @@
 OBJS       = example.o
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
 
 build: static static_top
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static_cpp
 
 static_top:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static_cpp_toplevel
 
 dynamic:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)'
 	MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_dynamic_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
diff --git a/Examples/ocaml/simple/Makefile b/Examples/ocaml/simple/Makefile
index 64c7256..49bf81c 100644
--- a/Examples/ocaml/simple/Makefile
+++ b/Examples/ocaml/simple/Makefile
@@ -8,27 +8,27 @@
 OBJS       = example.o
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
 
 build: static
 
 dynamic:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_dynamic
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static
 
 toplevel:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
 	PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static_toplevel
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
diff --git a/Examples/ocaml/std_string/Makefile b/Examples/ocaml/std_string/Makefile
index 89f9970..8f8b2f6 100644
--- a/Examples/ocaml/std_string/Makefile
+++ b/Examples/ocaml/std_string/Makefile
@@ -6,19 +6,19 @@
 PROGFILE   = runme.ml
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
 
 build: static
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_static_cpp
 
 dynamic:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_dynamic_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/ocaml/std_vector/Makefile b/Examples/ocaml/std_vector/Makefile
index 89f9970..8f8b2f6 100644
--- a/Examples/ocaml/std_vector/Makefile
+++ b/Examples/ocaml/std_vector/Makefile
@@ -6,19 +6,19 @@
 PROGFILE   = runme.ml
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
 
 build: static
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_static_cpp
 
 dynamic:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_dynamic_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/ocaml/stl/Makefile b/Examples/ocaml/stl/Makefile
index a913611..e4cce48 100644
--- a/Examples/ocaml/stl/Makefile
+++ b/Examples/ocaml/stl/Makefile
@@ -6,29 +6,29 @@
 PROGFILE   = runme.ml
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
 
 build: static
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_static_cpp
 
 director:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_static_cpp_director
 
 dynamic:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_static_cpp
 
 toplevel:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_static_cpp_toplevel
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile
index 6d34485..294bdec 100644
--- a/Examples/ocaml/string_from_ptr/Makefile
+++ b/Examples/ocaml/string_from_ptr/Makefile
@@ -9,27 +9,27 @@
 OBJS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
 
 build: static static_top
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static_cpp
 
 static_top:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_static_cpp_toplevel
 
 dynamic:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)'
 	MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
 	ocaml_dynamic_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean
diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile
index 49cc544..b6b8666 100644
--- a/Examples/ocaml/strings_test/Makefile
+++ b/Examples/ocaml/strings_test/Makefile
@@ -6,24 +6,24 @@
 PROGFILE   = runme.ml
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
 
 build: static top
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_static_cpp
 
 dynamic:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_static_cpp
 
 top:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	ocaml_static_cpp_toplevel
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
diff --git a/Examples/octave/callback/Makefile b/Examples/octave/callback/Makefile
index d38d7f8..3b746de 100644
--- a/Examples/octave/callback/Makefile
+++ b/Examples/octave/callback/Makefile
@@ -1,17 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-CXXSRCS    = example.cxx
-TARGET     = swigexample
-INTERFACE  = example.i
-LIBS       = -lm
-SWIGOPT    =
+CXXSRCS = example.cxx
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/callback/example.i b/Examples/octave/callback/example.i
index 3192904..50ef509 100644
--- a/Examples/octave/callback/example.i
+++ b/Examples/octave/callback/example.i
@@ -1,5 +1,8 @@
 /* File : example.i */
 %module(directors="1") swigexample
+
+%feature("autodoc", 1);
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/octave/class/Makefile b/Examples/octave/class/Makefile
index d38d7f8..3b746de 100644
--- a/Examples/octave/class/Makefile
+++ b/Examples/octave/class/Makefile
@@ -1,17 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-CXXSRCS    = example.cxx
-TARGET     = swigexample
-INTERFACE  = example.i
-LIBS       = -lm
-SWIGOPT    =
+CXXSRCS = example.cxx
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/class/example.cxx b/Examples/octave/class/example.cxx
index 1e8e203..0463045 100644
--- a/Examples/octave/class/example.cxx
+++ b/Examples/octave/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
 
 #include "example.h"
 #define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
+double Circle::area() {
   return M_PI*radius*radius;
 }
 
-double Circle::perimeter(void) {
+double Circle::perimeter() {
   return 2*M_PI*radius;
 }
 
-double Square::area(void) {
+double Square::area() {
   return width*width;
 }
 
-double Square::perimeter(void) {
+double Square::perimeter() {
   return 4*width;
 }
diff --git a/Examples/octave/class/example.i b/Examples/octave/class/example.i
index b109bcb..52e9fd3 100644
--- a/Examples/octave/class/example.i
+++ b/Examples/octave/class/example.i
@@ -1,6 +1,8 @@
 /* File : example.i */
 %module swigexample
 
+%feature("autodoc", 1);
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/octave/constants/Makefile b/Examples/octave/constants/Makefile
index 03501bd..acf4d05 100644
--- a/Examples/octave/constants/Makefile
+++ b/Examples/octave/constants/Makefile
@@ -1,17 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-CXXSRCS    =
-TARGET     = swigexample
-INTERFACE  = example.i
-LIBS       = -lm
-SWIGOPT    =
+CXXSRCS =
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/constants/example.i b/Examples/octave/constants/example.i
index 405974b..ab42a6b 100644
--- a/Examples/octave/constants/example.i
+++ b/Examples/octave/constants/example.i
@@ -1,6 +1,8 @@
 /* File : example.i */
 %module swigexample
 
+%feature("autodoc", 1);
+
 /* A few preprocessor macros */
 
 #define    ICONST      42
diff --git a/Examples/octave/contract/Makefile b/Examples/octave/contract/Makefile
index 73e3962..413b64b 100644
--- a/Examples/octave/contract/Makefile
+++ b/Examples/octave/contract/Makefile
@@ -1,15 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-SRCS       = example.c
-TARGET     = swigexample
-INTERFACE  = example.i
+SRCS = example.c
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/contract/example.i b/Examples/octave/contract/example.i
index 78c459e..8976607 100644
--- a/Examples/octave/contract/example.i
+++ b/Examples/octave/contract/example.i
@@ -1,6 +1,8 @@
 /* File : example.i */
 %module swigexample
 
+%feature("autodoc", 1);
+
 %contract gcd(int x, int y) {
 require:
 	x >= 0;
diff --git a/Examples/octave/enum/Makefile b/Examples/octave/enum/Makefile
index d38d7f8..3b746de 100644
--- a/Examples/octave/enum/Makefile
+++ b/Examples/octave/enum/Makefile
@@ -1,17 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-CXXSRCS    = example.cxx
-TARGET     = swigexample
-INTERFACE  = example.i
-LIBS       = -lm
-SWIGOPT    =
+CXXSRCS = example.cxx
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/enum/example.i b/Examples/octave/enum/example.i
index cee9af4..084bab0 100644
--- a/Examples/octave/enum/example.i
+++ b/Examples/octave/enum/example.i
@@ -1,6 +1,8 @@
 /* File : example.i */
 %module swigexample
 
+%feature("autodoc", 1);
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/octave/example.mk b/Examples/octave/example.mk
new file mode 100644
index 0000000..e0b1e4e
--- /dev/null
+++ b/Examples/octave/example.mk
@@ -0,0 +1,32 @@
+# Note: as a convention an example must be in a child directory of this.
+# These paths are relative to such an example directory
+
+TOP        = ../..
+SWIG       = $(TOP)/../preinst-swig
+TARGET     = swigexample
+INTERFACE  = example.i
+
+check: build
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run
+
+build:
+ifneq (,$(SRCS))
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
+else
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
+endif
+ifneq (,$(TARGET2)$(SWIGOPT2))
+ifneq (,$(SRCS))
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave
+else
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave_cpp
+endif
+endif
+
+
+clean:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean
diff --git a/Examples/octave/extend/Makefile b/Examples/octave/extend/Makefile
index d38d7f8..3b746de 100644
--- a/Examples/octave/extend/Makefile
+++ b/Examples/octave/extend/Makefile
@@ -1,17 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-CXXSRCS    = example.cxx
-TARGET     = swigexample
-INTERFACE  = example.i
-LIBS       = -lm
-SWIGOPT    =
+CXXSRCS = example.cxx
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/extend/example.h b/Examples/octave/extend/example.h
index 9e15cf8..77a26ec 100644
--- a/Examples/octave/extend/example.h
+++ b/Examples/octave/extend/example.h
@@ -14,7 +14,7 @@
 	virtual std::string getTitle() { return getPosition() + " " + getName(); }
 	virtual std::string getName() { return name; }
 	virtual std::string getPosition() const { return "Employee"; }
-	virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+	virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
 };
 
 
diff --git a/Examples/octave/extend/example.i b/Examples/octave/extend/example.i
index 953c2f3..3b9ac53 100644
--- a/Examples/octave/extend/example.i
+++ b/Examples/octave/extend/example.i
@@ -1,5 +1,8 @@
 /* File : example.i */
 %module(directors="1") swigexample
+
+%feature("autodoc", 1);
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/octave/funcptr/Makefile b/Examples/octave/funcptr/Makefile
index 73e3962..413b64b 100644
--- a/Examples/octave/funcptr/Makefile
+++ b/Examples/octave/funcptr/Makefile
@@ -1,15 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-SRCS       = example.c
-TARGET     = swigexample
-INTERFACE  = example.i
+SRCS = example.c
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/funcptr/example.i b/Examples/octave/funcptr/example.i
index 163a199..c6fcfe7 100644
--- a/Examples/octave/funcptr/example.i
+++ b/Examples/octave/funcptr/example.i
@@ -1,5 +1,8 @@
 /* File : example.i */
 %module swigexample
+
+%feature("autodoc", 1);
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/octave/funcptr2/Makefile b/Examples/octave/funcptr2/Makefile
index 73e3962..413b64b 100644
--- a/Examples/octave/funcptr2/Makefile
+++ b/Examples/octave/funcptr2/Makefile
@@ -1,15 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-SRCS       = example.c
-TARGET     = swigexample
-INTERFACE  = example.i
+SRCS = example.c
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/funcptr2/example.i b/Examples/octave/funcptr2/example.i
index 33378a1..bbe50fb 100644
--- a/Examples/octave/funcptr2/example.i
+++ b/Examples/octave/funcptr2/example.i
@@ -1,5 +1,8 @@
 /* File : example.i */
 %module swigexample
+
+%feature("autodoc", 1);
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/octave/functor/Makefile b/Examples/octave/functor/Makefile
index 94fb963..acf4d05 100644
--- a/Examples/octave/functor/Makefile
+++ b/Examples/octave/functor/Makefile
@@ -1,17 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-CXXSRCS    =
-TARGET     = swigexample
-INTERFACE  = example.i
-LIBS       = -lm
-SWIGOPT    =
+CXXSRCS =
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/functor/example.i b/Examples/octave/functor/example.i
index ade20c5..0c21a8e 100644
--- a/Examples/octave/functor/example.i
+++ b/Examples/octave/functor/example.i
@@ -1,6 +1,7 @@
 /* File : example.i */
 %module swigexample
 
+%feature("autodoc", 1);
 
 %inline %{
 // From B. Strousjoup, "The C++ Programming Language, Third Edition", p. 514
diff --git a/Examples/octave/module_load/Makefile b/Examples/octave/module_load/Makefile
index e388763..d2cd66e 100644
--- a/Examples/octave/module_load/Makefile
+++ b/Examples/octave/module_load/Makefile
@@ -1,18 +1,7 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-SRCS       = example.c
-TARGET     = swigexample
-INTERFACE  = example.i
+SRCS     = example.c
+TARGET   = swigexample
+SWIGOPT  = -module swigexample
+TARGET2  = swigexample2
+SWIGOPT2 = -module swigexample2 -globals .
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' SWIGOPT='-module $$(TARGET)' INTERFACE='$(INTERFACE)' octave
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)2' SWIGOPT='-module $$(TARGET) -globals .' INTERFACE='$(INTERFACE)' octave
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
-	rm -f $(TARGET).m
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/module_load/example.i b/Examples/octave/module_load/example.i
index fd074d4..bd0e399 100644
--- a/Examples/octave/module_load/example.i
+++ b/Examples/octave/module_load/example.i
@@ -1,5 +1,8 @@
 /* File : example.i */
 /* module name given on cmdline */
+
+%feature("autodoc", 1);
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/octave/operator/Makefile b/Examples/octave/operator/Makefile
index 94fb963..acf4d05 100644
--- a/Examples/octave/operator/Makefile
+++ b/Examples/octave/operator/Makefile
@@ -1,17 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-CXXSRCS    =
-TARGET     = swigexample
-INTERFACE  = example.i
-LIBS       = -lm
-SWIGOPT    =
+CXXSRCS =
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/operator/example.i b/Examples/octave/operator/example.i
index a2d9773..7fad8e6 100644
--- a/Examples/octave/operator/example.i
+++ b/Examples/octave/operator/example.i
@@ -1,6 +1,10 @@
 /* File : example.i */
 %module swigexample
+
+%feature("autodoc", 1);
+
 #pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/octave/pointer/Makefile b/Examples/octave/pointer/Makefile
index 73e3962..413b64b 100644
--- a/Examples/octave/pointer/Makefile
+++ b/Examples/octave/pointer/Makefile
@@ -1,15 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-SRCS       = example.c
-TARGET     = swigexample
-INTERFACE  = example.i
+SRCS = example.c
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/pointer/example.i b/Examples/octave/pointer/example.i
index 545e3ad..8b9e0f1 100644
--- a/Examples/octave/pointer/example.i
+++ b/Examples/octave/pointer/example.i
@@ -1,6 +1,8 @@
 /* File : example.i */
 %module swigexample
 
+%feature("autodoc", 1);
+
 %{
 extern void add(int *, int *, int *);
 extern void sub(int *, int *, int *);
diff --git a/Examples/octave/reference/Makefile b/Examples/octave/reference/Makefile
index d38d7f8..3b746de 100644
--- a/Examples/octave/reference/Makefile
+++ b/Examples/octave/reference/Makefile
@@ -1,17 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-CXXSRCS    = example.cxx
-TARGET     = swigexample
-INTERFACE  = example.i
-LIBS       = -lm
-SWIGOPT    =
+CXXSRCS = example.cxx
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/reference/example.cxx b/Examples/octave/reference/example.cxx
index 9b72ca6..632a03a 100644
--- a/Examples/octave/reference/example.cxx
+++ b/Examples/octave/reference/example.cxx
@@ -19,7 +19,7 @@
 
 char *Vector::print() {
   static char temp[512];
-  sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
diff --git a/Examples/octave/reference/example.h b/Examples/octave/reference/example.h
index 697afaf..bcfcfb7 100644
--- a/Examples/octave/reference/example.h
+++ b/Examples/octave/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   friend Vector operator+(const Vector &a, const Vector &b);
   char *print();
 };
diff --git a/Examples/octave/reference/example.i b/Examples/octave/reference/example.i
index da09800..0aa7334 100644
--- a/Examples/octave/reference/example.i
+++ b/Examples/octave/reference/example.i
@@ -4,6 +4,8 @@
 
 %module swigexample
 
+%feature("autodoc", 1);
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/octave/simple/Makefile b/Examples/octave/simple/Makefile
index 73e3962..413b64b 100644
--- a/Examples/octave/simple/Makefile
+++ b/Examples/octave/simple/Makefile
@@ -1,15 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-SRCS       = example.c
-TARGET     = swigexample
-INTERFACE  = example.i
+SRCS = example.c
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/simple/example.i b/Examples/octave/simple/example.i
index 127bfcd..a3006f2 100644
--- a/Examples/octave/simple/example.i
+++ b/Examples/octave/simple/example.i
@@ -1,6 +1,8 @@
 /* File : example.i */
 %module swigexample
 
+%feature("autodoc", 1);
+
 %inline %{
 extern int    gcd(int x, int y);
 extern double Foo;
diff --git a/Examples/octave/template/Makefile b/Examples/octave/template/Makefile
index 94fb963..acf4d05 100644
--- a/Examples/octave/template/Makefile
+++ b/Examples/octave/template/Makefile
@@ -1,17 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-CXXSRCS    =
-TARGET     = swigexample
-INTERFACE  = example.i
-LIBS       = -lm
-SWIGOPT    =
+CXXSRCS =
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/template/example.i b/Examples/octave/template/example.i
index cfff18d..3c57f38 100644
--- a/Examples/octave/template/example.i
+++ b/Examples/octave/template/example.i
@@ -1,6 +1,8 @@
 /* File : example.i */
 %module swigexample
 
+%feature("autodoc", 1);
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/octave/variables/Makefile b/Examples/octave/variables/Makefile
index 73e3962..413b64b 100644
--- a/Examples/octave/variables/Makefile
+++ b/Examples/octave/variables/Makefile
@@ -1,15 +1,3 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-SRCS       = example.c
-TARGET     = swigexample
-INTERFACE  = example.i
+SRCS = example.c
 
-check: build
-	$(MAKE) -f $(TOP)/Makefile octave_run
-
-build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile octave_clean
+include $(SRCDIR)../example.mk
diff --git a/Examples/octave/variables/example.c b/Examples/octave/variables/example.c
index e2b72e0..a9102a9 100644
--- a/Examples/octave/variables/example.c
+++ b/Examples/octave/variables/example.c
@@ -52,9 +52,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %s\n", name);
-  printf("ptptr     = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+  printf("ptptr     = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/octave/variables/example.i b/Examples/octave/variables/example.i
index 3e11495..9d8b03e 100644
--- a/Examples/octave/variables/example.i
+++ b/Examples/octave/variables/example.i
@@ -1,5 +1,8 @@
 /* File : example.i */
 %module swigexample
+
+%feature("autodoc", 1);
+
 %{
 #include "example.h"
 %}
diff --git a/Examples/perl5/callback/Makefile b/Examples/perl5/callback/Makefile
index 544d136..0d1cc57 100644
--- a/Examples/perl5/callback/Makefile
+++ b/Examples/perl5/callback/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/check.list b/Examples/perl5/check.list
index 78d45fc..dda8493 100644
--- a/Examples/perl5/check.list
+++ b/Examples/perl5/check.list
@@ -6,6 +6,7 @@
 extend
 funcptr
 import
+java
 multimap
 multiple_inheritance
 pointer
diff --git a/Examples/perl5/class/Makefile b/Examples/perl5/class/Makefile
index 544d136..0d1cc57 100644
--- a/Examples/perl5/class/Makefile
+++ b/Examples/perl5/class/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/constants/Makefile b/Examples/perl5/constants/Makefile
index 8992829..b7b4115 100644
--- a/Examples/perl5/constants/Makefile
+++ b/Examples/perl5/constants/Makefile
@@ -6,15 +6,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/constants2/Makefile b/Examples/perl5/constants2/Makefile
index 2ed10d7..85dd137 100644
--- a/Examples/perl5/constants2/Makefile
+++ b/Examples/perl5/constants2/Makefile
@@ -6,15 +6,15 @@
 SWIGOPT    = -const
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/extend/Makefile b/Examples/perl5/extend/Makefile
index 544d136..0d1cc57 100644
--- a/Examples/perl5/extend/Makefile
+++ b/Examples/perl5/extend/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/extend/example.h b/Examples/perl5/extend/example.h
index b27ab97..ca1aed2 100644
--- a/Examples/perl5/extend/example.h
+++ b/Examples/perl5/extend/example.h
@@ -14,7 +14,7 @@
 	virtual std::string getTitle() { return getPosition() + " " + getName(); }
 	virtual std::string getName() { return name; }
 	virtual std::string getPosition() const { return "Employee"; }
-	virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+	virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
 };
 
 
diff --git a/Examples/perl5/funcptr/Makefile b/Examples/perl5/funcptr/Makefile
index 366b589..3e1de1f 100644
--- a/Examples/perl5/funcptr/Makefile
+++ b/Examples/perl5/funcptr/Makefile
@@ -6,15 +6,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/import/Makefile b/Examples/perl5/import/Makefile
index baa8277..b31ab79 100644
--- a/Examples/perl5/import/Makefile
+++ b/Examples/perl5/import/Makefile
@@ -4,17 +4,17 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='baseclass' INTERFACE='base.i' perl5_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' perl5_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' perl5_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' perl5_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/import/base.h b/Examples/perl5/import/base.h
index 5a266f6..c0b4795 100644
--- a/Examples/perl5/import/base.h
+++ b/Examples/perl5/import/base.h
@@ -2,8 +2,8 @@
 
 class Base {
  public:
-     Base() { };
-     virtual ~Base() { };
+     Base() { }
+     virtual ~Base() { }
      virtual void A() {
          printf("I'm Base::A\n");
      }
diff --git a/Examples/perl5/inline/Makefile b/Examples/perl5/inline/Makefile
index d544a65..5c98748 100644
--- a/Examples/perl5/inline/Makefile
+++ b/Examples/perl5/inline/Makefile
@@ -1,6 +1,6 @@
 run:
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
 	rm -rf _Inline
diff --git a/Examples/perl5/java/Makefile b/Examples/perl5/java/Makefile
index ff3aab0..5eaea32 100644
--- a/Examples/perl5/java/Makefile
+++ b/Examples/perl5/java/Makefile
@@ -6,17 +6,17 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
-build: Example.class
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \
+build: Example.class Example.h
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	CXXSHARED="gcj -fpic -shared Example.class" PERL5_CCFLAGS='' PERL5_EXP='' LIBS="-lstdc++" perl5_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
 	rm -f *.class Example.h
 
-Example.class: Example.java
-	gcj -fPIC -C -c -g Example.java
-	gcjh  Example
+Example.class Example.h: $(SRCDIR)Example.java
+	gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
+	gcjh Example.class
diff --git a/Examples/perl5/multimap/Makefile b/Examples/perl5/multimap/Makefile
index 366b589..3e1de1f 100644
--- a/Examples/perl5/multimap/Makefile
+++ b/Examples/perl5/multimap/Makefile
@@ -6,15 +6,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/multiple_inheritance/Makefile b/Examples/perl5/multiple_inheritance/Makefile
index 62355a8..1fe5a51 100644
--- a/Examples/perl5/multiple_inheritance/Makefile
+++ b/Examples/perl5/multiple_inheritance/Makefile
@@ -6,15 +6,15 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/pointer/Makefile b/Examples/perl5/pointer/Makefile
index 366b589..3e1de1f 100644
--- a/Examples/perl5/pointer/Makefile
+++ b/Examples/perl5/pointer/Makefile
@@ -6,15 +6,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/reference/Makefile b/Examples/perl5/reference/Makefile
index 986fab8..a22f5a6 100644
--- a/Examples/perl5/reference/Makefile
+++ b/Examples/perl5/reference/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    = -noproxy
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myperl' INTERFACE='$(INTERFACE)' SWIGOPT='$(SWIGOPT)' perl5_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/reference/example.cxx b/Examples/perl5/reference/example.cxx
index 8a513bf..9dbaed2 100644
--- a/Examples/perl5/reference/example.cxx
+++ b/Examples/perl5/reference/example.cxx
@@ -19,7 +19,7 @@
 
 char *Vector::print() {
   static char temp[512];
-  sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
diff --git a/Examples/perl5/reference/example.h b/Examples/perl5/reference/example.h
index 4915adb..bcfcfb7 100644
--- a/Examples/perl5/reference/example.h
+++ b/Examples/perl5/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   friend Vector operator+(const Vector &a, const Vector &b);
   char *print();
 };
@@ -20,7 +20,3 @@
   Vector &operator[](int);
   int size();
 };
-
-
-
-  
diff --git a/Examples/perl5/reference/example.i b/Examples/perl5/reference/example.i
index 6daa3b1..173143d 100644
--- a/Examples/perl5/reference/example.i
+++ b/Examples/perl5/reference/example.i
@@ -29,7 +29,7 @@
   VectorArray(int maxsize);
   ~VectorArray();
   int size();
-  
+
   /* This wrapper provides an alternative to the [] operator */
   %extend {
     Vector &get(int index) {
@@ -40,7 +40,3 @@
     }
   }
 };
-
-
-
-
diff --git a/Examples/perl5/simple/Makefile b/Examples/perl5/simple/Makefile
index 366b589..3e1de1f 100644
--- a/Examples/perl5/simple/Makefile
+++ b/Examples/perl5/simple/Makefile
@@ -6,15 +6,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/value/Makefile b/Examples/perl5/value/Makefile
index 366b589..3e1de1f 100644
--- a/Examples/perl5/value/Makefile
+++ b/Examples/perl5/value/Makefile
@@ -6,15 +6,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/value/example.i b/Examples/perl5/value/example.i
index 98fd60e..39663c6 100644
--- a/Examples/perl5/value/example.i
+++ b/Examples/perl5/value/example.i
@@ -26,7 +26,7 @@
 }
 
 void vector_print(Vector *v) {
-  printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+  printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z);
 }
 %}
 
diff --git a/Examples/perl5/variables/Makefile b/Examples/perl5/variables/Makefile
index 366b589..3e1de1f 100644
--- a/Examples/perl5/variables/Makefile
+++ b/Examples/perl5/variables/Makefile
@@ -6,15 +6,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/perl5/variables/example.c b/Examples/perl5/variables/example.c
index 05e17c8..85685fe 100644
--- a/Examples/perl5/variables/example.c
+++ b/Examples/perl5/variables/example.c
@@ -52,9 +52,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %s\n", name);
-  printf("ptptr     = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+  printf("ptptr     = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/perl5/xmlstring/Makefile b/Examples/perl5/xmlstring/Makefile
index df9dabd..4f02d3e 100644
--- a/Examples/perl5/xmlstring/Makefile
+++ b/Examples/perl5/xmlstring/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lxerces-c -lxerces-depdom -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile perl5_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS=$(LIBS) CXX="g++ -g3" perl5_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile perl5_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' perl5_clean
diff --git a/Examples/php/callback/Makefile b/Examples/php/callback/Makefile
index 6f7e4ad..3ad3999 100644
--- a/Examples/php/callback/Makefile
+++ b/Examples/php/callback/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/class/Makefile b/Examples/php/class/Makefile
index cefd81f..8b2b340 100644
--- a/Examples/php/class/Makefile
+++ b/Examples/php/class/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/constants/Makefile b/Examples/php/constants/Makefile
index 3f24a39..e5b4957 100644
--- a/Examples/php/constants/Makefile
+++ b/Examples/php/constants/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/cpointer/Makefile b/Examples/php/cpointer/Makefile
index 57785ac..f2c15c5 100644
--- a/Examples/php/cpointer/Makefile
+++ b/Examples/php/cpointer/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/disown/Makefile b/Examples/php/disown/Makefile
index cefd81f..8b2b340 100644
--- a/Examples/php/disown/Makefile
+++ b/Examples/php/disown/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/disown/example.h b/Examples/php/disown/example.h
index 985bc33..e9f9674 100644
--- a/Examples/php/disown/example.h
+++ b/Examples/php/disown/example.h
@@ -9,7 +9,7 @@
   }
   virtual ~Shape() {
     nshapes--;
-  };
+  }
   double  x, y;   
   void    move(double dx, double dy);
   virtual double area(void) = 0;
@@ -22,8 +22,8 @@
 private:
   double radius;
 public:
-  Circle(double r) : radius(r) { };
-  ~Circle() { };
+  Circle(double r) : radius(r) { }
+  ~Circle() { }
   void set_radius( double r );
   virtual double area(void);
   virtual double perimeter(void);
@@ -33,7 +33,7 @@
 private:
   double width;
 public:
-  Square(double w) : width(w) { };
+  Square(double w) : width(w) { }
   ~Square() { }
   virtual double area(void);
   virtual double perimeter(void);
@@ -44,7 +44,7 @@
   typedef std::vector<Shape*>::iterator iterator;
   std::vector<Shape*> shapes;
 public:
-  ShapeContainer() : shapes() {};
+  ShapeContainer() : shapes() {}
   ~ShapeContainer();
   void addShape( Shape *s );
 };
diff --git a/Examples/php/enum/Makefile b/Examples/php/enum/Makefile
index 22f979d..2028d03 100644
--- a/Examples/php/enum/Makefile
+++ b/Examples/php/enum/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    = -noproxy
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/extend/Makefile b/Examples/php/extend/Makefile
index 6f7e4ad..3ad3999 100644
--- a/Examples/php/extend/Makefile
+++ b/Examples/php/extend/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' php_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/extend/example.h b/Examples/php/extend/example.h
index b27ab97..ca1aed2 100644
--- a/Examples/php/extend/example.h
+++ b/Examples/php/extend/example.h
@@ -14,7 +14,7 @@
 	virtual std::string getTitle() { return getPosition() + " " + getName(); }
 	virtual std::string getName() { return name; }
 	virtual std::string getPosition() const { return "Employee"; }
-	virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+	virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
 };
 
 
diff --git a/Examples/php/funcptr/Makefile b/Examples/php/funcptr/Makefile
index 57785ac..f2c15c5 100644
--- a/Examples/php/funcptr/Makefile
+++ b/Examples/php/funcptr/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/overloading/Makefile b/Examples/php/overloading/Makefile
index cefd81f..8b2b340 100644
--- a/Examples/php/overloading/Makefile
+++ b/Examples/php/overloading/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/pointer/Makefile b/Examples/php/pointer/Makefile
index 57785ac..f2c15c5 100644
--- a/Examples/php/pointer/Makefile
+++ b/Examples/php/pointer/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/pragmas/Makefile b/Examples/php/pragmas/Makefile
index 3f24a39..e5b4957 100644
--- a/Examples/php/pragmas/Makefile
+++ b/Examples/php/pragmas/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/proxy/Makefile b/Examples/php/proxy/Makefile
index cefd81f..8b2b340 100644
--- a/Examples/php/proxy/Makefile
+++ b/Examples/php/proxy/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/proxy/example.h b/Examples/php/proxy/example.h
index 361dff8..0683f07 100644
--- a/Examples/php/proxy/example.h
+++ b/Examples/php/proxy/example.h
@@ -9,7 +9,7 @@
   }
   virtual ~Shape() {
     nshapes--;
-  };
+  }
   double  x, y;   
   void    move(double dx, double dy);
   virtual double area(void) = 0;
@@ -22,8 +22,8 @@
 private:
   double radius;
 public:
-  Circle(double r) : radius(r) { };
-  ~Circle() { };
+  Circle(double r) : radius(r) { }
+  ~Circle() { }
   void set_radius( double r );
   virtual double area(void);
   virtual double perimeter(void);
@@ -33,7 +33,7 @@
 private:
   double width;
 public:
-  Square(double w) : width(w) { };
+  Square(double w) : width(w) { }
   ~Square() { }
   virtual double area(void);
   virtual double perimeter(void);
diff --git a/Examples/php/reference/Makefile b/Examples/php/reference/Makefile
index cefd81f..8b2b340 100644
--- a/Examples/php/reference/Makefile
+++ b/Examples/php/reference/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/reference/example.cxx b/Examples/php/reference/example.cxx
index 13e47ea..7ead7fb 100644
--- a/Examples/php/reference/example.cxx
+++ b/Examples/php/reference/example.cxx
@@ -19,23 +19,23 @@
 
 char *Vector::as_string() {
   static char temp[512];
-  sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
 VectorArray::VectorArray(int size) {
   items = new Vector[size];
   maxsize = size;
-  printf("VectorArray new: self=%p\n",this);
+  printf("VectorArray new: self=%p\n", (void *)this);
 }
 
 VectorArray::~VectorArray() {
-  printf("VectorArray delete: self=%p\n",this);
+  printf("VectorArray delete: self=%p\n", (void *)this);
   delete [] items;
 }
 
 Vector &VectorArray::operator[](int index) {
-  printf("VectorArray: read[%d] self=%p\n",index,this);
+  printf("VectorArray: read[%d] self=%p\n", index, (void *)this);
   if ((index < 0) || (index >= maxsize)) {
     printf("Panic! Array index out of bounds.\n");
     exit(1);
@@ -44,6 +44,6 @@
 }
 
 int VectorArray::size() {
-  printf("VectorArray: size %d self=%p\n",maxsize,this);
+  printf("VectorArray: size %d self=%p\n", maxsize, (void *)this);
   return maxsize;
 }
diff --git a/Examples/php/reference/example.h b/Examples/php/reference/example.h
index 1b88cbf..353b888 100644
--- a/Examples/php/reference/example.h
+++ b/Examples/php/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   friend Vector operator+(const Vector &a, const Vector &b);
   char *as_string();
 };
@@ -20,7 +20,3 @@
   Vector &operator[](int);
   int size();
 };
-
-
-
-  
diff --git a/Examples/php/reference/example.i b/Examples/php/reference/example.i
index d612286..df14599 100644
--- a/Examples/php/reference/example.i
+++ b/Examples/php/reference/example.i
@@ -1,10 +1,6 @@
 /* File : example.i */
 
-/* This example has nothing to do with references but the name is used by all
- * the other languages so it's hard to rename to something more meaningful.
- *
- * Mostly it shows how to use %extend.
- */
+/* This file has a few "typical" uses of C++ references. */
 
 %module example
 
@@ -33,11 +29,11 @@
   VectorArray(int maxsize);
   ~VectorArray();
   int size();
-  
- /*  This wrapper provides an alternative to the [] operator */
+
+  /* This wrapper provides an alternative to the [] operator */
   %extend {
     Vector &get(int index) {
-      printf("VectorArray extended get: %p %d\n",$self,index);
+      printf("VectorArray extended get: %p %d\n", (void *)$self, index);
       return (*$self)[index];
     }
     void set(int index, Vector &a) {
diff --git a/Examples/php/simple/Makefile b/Examples/php/simple/Makefile
index 57785ac..f2c15c5 100644
--- a/Examples/php/simple/Makefile
+++ b/Examples/php/simple/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/sync/Makefile b/Examples/php/sync/Makefile
index cefd81f..8b2b340 100644
--- a/Examples/php/sync/Makefile
+++ b/Examples/php/sync/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/sync/example.cxx b/Examples/php/sync/example.cxx
index 31ed202..0942279 100644
--- a/Examples/php/sync/example.cxx
+++ b/Examples/php/sync/example.cxx
@@ -10,4 +10,4 @@
 	printf("The value of global x is %d\n", x);
 	printf("The value of class s is %s\n", s);
 	printf("The value of class x is %d\n", x);
-};
+}
diff --git a/Examples/php/value/Makefile b/Examples/php/value/Makefile
index 4496867..3db7afe 100644
--- a/Examples/php/value/Makefile
+++ b/Examples/php/value/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    = -noproxy
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/value/example.i b/Examples/php/value/example.i
index 386fa3b..20a4534 100644
--- a/Examples/php/value/example.i
+++ b/Examples/php/value/example.i
@@ -11,7 +11,7 @@
 %inline %{
 
 void vector_print(Vector *v) {
-  printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+  printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z);
 }
 %}
 
diff --git a/Examples/php/variables/Makefile b/Examples/php/variables/Makefile
index 57785ac..f2c15c5 100644
--- a/Examples/php/variables/Makefile
+++ b/Examples/php/variables/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile php_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	php
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
 	php_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile php_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean
diff --git a/Examples/php/variables/example.c b/Examples/php/variables/example.c
index b21dee3..d4c6d02 100644
--- a/Examples/php/variables/example.c
+++ b/Examples/php/variables/example.c
@@ -52,9 +52,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]);
-  printf("ptptr     = %p %s\n", ptptr, Point_print( ptptr ) );
+  printf("ptptr     = %p %s\n", (void *)ptptr, Point_print( ptptr ) );
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile
index aadc471..d8cf4ea 100644
--- a/Examples/pike/class/Makefile
+++ b/Examples/pike/class/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile pike_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile pike_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean
diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile
index c9385ce..736d30f 100644
--- a/Examples/pike/constants/Makefile
+++ b/Examples/pike/constants/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile pike_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile pike_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean
diff --git a/Examples/pike/enum/Makefile b/Examples/pike/enum/Makefile
index aadc471..d8cf4ea 100644
--- a/Examples/pike/enum/Makefile
+++ b/Examples/pike/enum/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile pike_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile pike_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean
diff --git a/Examples/pike/overload/Makefile b/Examples/pike/overload/Makefile
index 8d799ef..f111b11 100644
--- a/Examples/pike/overload/Makefile
+++ b/Examples/pike/overload/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lstdc++ -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile pike_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile pike_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean
diff --git a/Examples/pike/simple/Makefile b/Examples/pike/simple/Makefile
index f58ed4e..d7f6b20 100644
--- a/Examples/pike/simple/Makefile
+++ b/Examples/pike/simple/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile pike_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile pike_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean
diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile
index e4fc945..da115c1 100644
--- a/Examples/pike/template/Makefile
+++ b/Examples/pike/template/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile pike_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile pike_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean
diff --git a/Examples/python/callback/Makefile b/Examples/python/callback/Makefile
index 6849958..a4c4d2a 100644
--- a/Examples/python/callback/Makefile
+++ b/Examples/python/callback/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/check.list b/Examples/python/check.list
index e9e7c83..a43a5fc 100644
--- a/Examples/python/check.list
+++ b/Examples/python/check.list
@@ -24,7 +24,6 @@
 smartptr
 std_vector
 std_map
-swigrun
 template
 varargs
 variables
diff --git a/Examples/python/class/Makefile b/Examples/python/class/Makefile
index e940c1f..41cded2 100644
--- a/Examples/python/class/Makefile
+++ b/Examples/python/class/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile
index 15ffa24..8ec6e9c 100644
--- a/Examples/python/constants/Makefile
+++ b/Examples/python/constants/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/contract/Makefile b/Examples/python/contract/Makefile
index 999521c..fe1d932 100644
--- a/Examples/python/contract/Makefile
+++ b/Examples/python/contract/Makefile
@@ -6,15 +6,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/docstrings/Makefile b/Examples/python/docstrings/Makefile
index 51552f3..f471930 100644
--- a/Examples/python/docstrings/Makefile
+++ b/Examples/python/docstrings/Makefile
@@ -7,17 +7,17 @@
 SWIGOPT    = -O
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/enum/Makefile b/Examples/python/enum/Makefile
index e940c1f..41cded2 100644
--- a/Examples/python/enum/Makefile
+++ b/Examples/python/enum/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile
index fb200fb..ad3d49f 100644
--- a/Examples/python/exception/Makefile
+++ b/Examples/python/exception/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/exception/example.i b/Examples/python/exception/example.i
index 08672c3..817c522 100644
--- a/Examples/python/exception/example.i
+++ b/Examples/python/exception/example.i
@@ -10,3 +10,12 @@
 /* Let's just grab the original header file here */
 %include "example.h"
 
+%inline %{
+// The -builtin SWIG option results in SWIGPYTHON_BUILTIN being defined
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
+
diff --git a/Examples/python/exception/runme.py b/Examples/python/exception/runme.py
index 7187078..9e92411 100644
--- a/Examples/python/exception/runme.py
+++ b/Examples/python/exception/runme.py
@@ -20,10 +20,17 @@
 except RuntimeError,e:
       print e.args[0]
 
-try:
-      t.hosed()
-except example.Exc,e:
-      print e.code, e.msg
+if not example.is_python_builtin():
+  try:
+        t.hosed()
+  except example.Exc,e:
+        print e.code, e.msg
+else:
+  try:
+        t.hosed()
+  except BaseException,e:
+        # Throwing builtin classes as exceptions not supported (-builtin option)
+        print e
 
 for i in range(1,4):
       try:
diff --git a/Examples/python/exceptproxy/Makefile b/Examples/python/exceptproxy/Makefile
index 86a6434..f406dfa 100644
--- a/Examples/python/exceptproxy/Makefile
+++ b/Examples/python/exceptproxy/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/exceptproxy/example.i b/Examples/python/exceptproxy/example.i
index 4a1e0ba..0a46afb 100644
--- a/Examples/python/exceptproxy/example.i
+++ b/Examples/python/exceptproxy/example.i
@@ -109,6 +109,12 @@
 %template(doubleQueue) Queue<double>;
 
 
-
-
+%inline %{
+// The -builtin SWIG option results in SWIGPYTHON_BUILTIN being defined
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
 
diff --git a/Examples/python/exceptproxy/runme.py b/Examples/python/exceptproxy/runme.py
index a2ae555..07e4b0a 100644
--- a/Examples/python/exceptproxy/runme.py
+++ b/Examples/python/exceptproxy/runme.py
@@ -1,10 +1,16 @@
 # file: runme.py
 import example
 
+if example.is_python_builtin():
+  print "Skipping example: -builtin option does not support %exceptionclass"
+  exit(0)
+
 q = example.intQueue(10)
 
 print "Inserting items into intQueue"
 
+print type(example.FullError)
+
 try:
       for i in range(0,100):
             q.enqueue(i)
diff --git a/Examples/python/extend/Makefile b/Examples/python/extend/Makefile
index 6849958..a4c4d2a 100644
--- a/Examples/python/extend/Makefile
+++ b/Examples/python/extend/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/extend/example.h b/Examples/python/extend/example.h
index b27ab97..ca1aed2 100644
--- a/Examples/python/extend/example.h
+++ b/Examples/python/extend/example.h
@@ -14,7 +14,7 @@
 	virtual std::string getTitle() { return getPosition() + " " + getName(); }
 	virtual std::string getName() { return name; }
 	virtual std::string getPosition() const { return "Employee"; }
-	virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+	virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
 };
 
 
diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile
index df3bc86..222916f 100644
--- a/Examples/python/funcptr/Makefile
+++ b/Examples/python/funcptr/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/funcptr2/Makefile b/Examples/python/funcptr2/Makefile
index df3bc86..222916f 100644
--- a/Examples/python/funcptr2/Makefile
+++ b/Examples/python/funcptr2/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/functor/Makefile b/Examples/python/functor/Makefile
index dde0d09..1234c31 100644
--- a/Examples/python/functor/Makefile
+++ b/Examples/python/functor/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile
index f63e122..d83dfea 100644
--- a/Examples/python/import/Makefile
+++ b/Examples/python/import/Makefile
@@ -4,19 +4,19 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp
 
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
 	rm -f foo.py bar.py spam.py base.py
diff --git a/Examples/python/import/base.h b/Examples/python/import/base.h
index 5a266f6..c0b4795 100644
--- a/Examples/python/import/base.h
+++ b/Examples/python/import/base.h
@@ -2,8 +2,8 @@
 
 class Base {
  public:
-     Base() { };
-     virtual ~Base() { };
+     Base() { }
+     virtual ~Base() { }
      virtual void A() {
          printf("I'm Base::A\n");
      }
diff --git a/Examples/python/import_packages/Makefile b/Examples/python/import_packages/Makefile
index fda2380..dfd46d0 100644
--- a/Examples/python/import_packages/Makefile
+++ b/Examples/python/import_packages/Makefile
@@ -5,17 +5,23 @@
 PY3        =
 
 import_packages_subdirs = \
-  same_modnames1 \
+	same_modnames1 \
 	same_modnames2 \
 	from_init1 \
 	from_init2 \
 	from_init3 \
 	relativeimport1 \
-	relativeimport1
+	relativeimport2 \
+	relativeimport3
 
 check: build
+	if test "x$(SRCDIR)" != x; then \
+		for file in `cd $(SRCDIR) && find . -type f -name __init__.py`; do \
+			cp "${SRCDIR}$$file" "$$file" || exit 1; \
+		done; \
+	fi; \
 	for s in $(import_packages_subdirs); do \
-	  (cd $$s && $(MAKE) check); \
+		(cd $$s && $(MAKE) check); \
 	done
 
 build:
@@ -29,7 +35,12 @@
 	done
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
+	if test "x$(SRCDIR)" != x; then \
+		for file in `cd $(SRCDIR) && find . -type f -name __init__.py`; do \
+			rm -f "$$file" || exit 1; \
+		done; \
+	fi; \
 	for s in $(import_packages_subdirs); do \
 		(cd $$s && $(MAKE) clean); \
 	done
diff --git a/Examples/python/import_packages/from_init1/Makefile b/Examples/python/import_packages/from_init1/Makefile
index 8e35c6c..b9d803a 100644
--- a/Examples/python/import_packages/from_init1/Makefile
+++ b/Examples/python/import_packages/from_init1/Makefile
@@ -11,7 +11,7 @@
 endif
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
 	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build
@@ -20,6 +20,6 @@
 	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd py2 && $(MAKE) clean
 	cd py3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init1/py2/Makefile b/Examples/python/import_packages/from_init1/py2/Makefile
index 4c0dfab..9595397 100644
--- a/Examples/python/import_packages/from_init1/py2/Makefile
+++ b/Examples/python/import_packages/from_init1/py2/Makefile
@@ -10,5 +10,5 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init1/py2/pkg2/Makefile b/Examples/python/import_packages/from_init1/py2/pkg2/Makefile
index 0dd1746..1eb810e 100644
--- a/Examples/python/import_packages/from_init1/py2/pkg2/Makefile
+++ b/Examples/python/import_packages/from_init1/py2/pkg2/Makefile
@@ -4,17 +4,17 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp_static
 
 clean::
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
-	$(MAKE) -f $(TOP)/Makefile TARGET='bar' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
diff --git a/Examples/python/import_packages/from_init1/py3/Makefile b/Examples/python/import_packages/from_init1/py3/Makefile
index 4c0dfab..9595397 100644
--- a/Examples/python/import_packages/from_init1/py3/Makefile
+++ b/Examples/python/import_packages/from_init1/py3/Makefile
@@ -10,5 +10,5 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init1/py3/pkg2/Makefile b/Examples/python/import_packages/from_init1/py3/pkg2/Makefile
index 0dd1746..1eb810e 100644
--- a/Examples/python/import_packages/from_init1/py3/pkg2/Makefile
+++ b/Examples/python/import_packages/from_init1/py3/pkg2/Makefile
@@ -4,17 +4,17 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp_static
 
 clean::
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
-	$(MAKE) -f $(TOP)/Makefile TARGET='bar' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
diff --git a/Examples/python/import_packages/from_init1/runme.py b/Examples/python/import_packages/from_init1/runme.py
index c23a085..bbe092b 100644
--- a/Examples/python/import_packages/from_init1/runme.py
+++ b/Examples/python/import_packages/from_init1/runme.py
@@ -1,6 +1,10 @@
-# Test import of modules content from within __init__.py
-print "Testing %module(package=...) + python 'import' in __init__.py"
 import sys
+import os.path
+
+# Test import of modules content from within __init__.py
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+
 if sys.version_info < (3,0):
   import py2.pkg2
   print "  Finished importing py2.pkg2"
diff --git a/Examples/python/import_packages/from_init2/Makefile b/Examples/python/import_packages/from_init2/Makefile
index 8e35c6c..b9d803a 100644
--- a/Examples/python/import_packages/from_init2/Makefile
+++ b/Examples/python/import_packages/from_init2/Makefile
@@ -11,7 +11,7 @@
 endif
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
 	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build
@@ -20,6 +20,6 @@
 	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd py2 && $(MAKE) clean
 	cd py3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init2/py2/Makefile b/Examples/python/import_packages/from_init2/py2/Makefile
index 4c0dfab..9595397 100644
--- a/Examples/python/import_packages/from_init2/py2/Makefile
+++ b/Examples/python/import_packages/from_init2/py2/Makefile
@@ -10,5 +10,5 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init2/py2/pkg2/Makefile b/Examples/python/import_packages/from_init2/py2/pkg2/Makefile
index 3fe5613..36e099b 100644
--- a/Examples/python/import_packages/from_init2/py2/pkg2/Makefile
+++ b/Examples/python/import_packages/from_init2/py2/pkg2/Makefile
@@ -4,15 +4,15 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='bar' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
 	cd pkg3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile
index a417e27..cb20bd2 100644
--- a/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile
+++ b/Examples/python/import_packages/from_init2/py2/pkg2/pkg3/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/from_init2/py3/Makefile b/Examples/python/import_packages/from_init2/py3/Makefile
index 4c0dfab..9595397 100644
--- a/Examples/python/import_packages/from_init2/py3/Makefile
+++ b/Examples/python/import_packages/from_init2/py3/Makefile
@@ -10,5 +10,5 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init2/py3/pkg2/Makefile b/Examples/python/import_packages/from_init2/py3/pkg2/Makefile
index 3fe5613..36e099b 100644
--- a/Examples/python/import_packages/from_init2/py3/pkg2/Makefile
+++ b/Examples/python/import_packages/from_init2/py3/pkg2/Makefile
@@ -4,15 +4,15 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='bar' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
 	cd pkg3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile
index a417e27..cb20bd2 100644
--- a/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile
+++ b/Examples/python/import_packages/from_init2/py3/pkg2/pkg3/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/from_init2/runme.py b/Examples/python/import_packages/from_init2/runme.py
index c23a085..bbe092b 100644
--- a/Examples/python/import_packages/from_init2/runme.py
+++ b/Examples/python/import_packages/from_init2/runme.py
@@ -1,6 +1,10 @@
-# Test import of modules content from within __init__.py
-print "Testing %module(package=...) + python 'import' in __init__.py"
 import sys
+import os.path
+
+# Test import of modules content from within __init__.py
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+
 if sys.version_info < (3,0):
   import py2.pkg2
   print "  Finished importing py2.pkg2"
diff --git a/Examples/python/import_packages/from_init3/Makefile b/Examples/python/import_packages/from_init3/Makefile
index 8e35c6c..b9d803a 100644
--- a/Examples/python/import_packages/from_init3/Makefile
+++ b/Examples/python/import_packages/from_init3/Makefile
@@ -11,7 +11,7 @@
 endif
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
 	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build
@@ -20,6 +20,6 @@
 	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd py2 && $(MAKE) clean
 	cd py3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init3/py2/Makefile b/Examples/python/import_packages/from_init3/py2/Makefile
index 4c0dfab..9595397 100644
--- a/Examples/python/import_packages/from_init3/py2/Makefile
+++ b/Examples/python/import_packages/from_init3/py2/Makefile
@@ -10,5 +10,5 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init3/py2/pkg2/Makefile b/Examples/python/import_packages/from_init3/py2/pkg2/Makefile
index 3fe5613..36e099b 100644
--- a/Examples/python/import_packages/from_init3/py2/pkg2/Makefile
+++ b/Examples/python/import_packages/from_init3/py2/pkg2/Makefile
@@ -4,15 +4,15 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='bar' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
 	cd pkg3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/Makefile
index 470f9d5..d6ae1b2 100644
--- a/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/Makefile
+++ b/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/Makefile
@@ -10,5 +10,5 @@
 	cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg4 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile
index a98d311..286d900 100644
--- a/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile
+++ b/Examples/python/import_packages/from_init3/py2/pkg2/pkg3/pkg4/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/from_init3/py3/Makefile b/Examples/python/import_packages/from_init3/py3/Makefile
index 4c0dfab..9595397 100644
--- a/Examples/python/import_packages/from_init3/py3/Makefile
+++ b/Examples/python/import_packages/from_init3/py3/Makefile
@@ -10,5 +10,5 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init3/py3/pkg2/Makefile b/Examples/python/import_packages/from_init3/py3/pkg2/Makefile
index 3fe5613..36e099b 100644
--- a/Examples/python/import_packages/from_init3/py3/pkg2/Makefile
+++ b/Examples/python/import_packages/from_init3/py3/pkg2/Makefile
@@ -4,15 +4,15 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='bar' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
 	cd pkg3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/Makefile
index 470f9d5..d6ae1b2 100644
--- a/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/Makefile
+++ b/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/Makefile
@@ -10,5 +10,5 @@
 	cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg4 && $(MAKE) clean
diff --git a/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile
index a98d311..286d900 100644
--- a/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile
+++ b/Examples/python/import_packages/from_init3/py3/pkg2/pkg3/pkg4/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/from_init3/runme.py b/Examples/python/import_packages/from_init3/runme.py
index c23a085..bbe092b 100644
--- a/Examples/python/import_packages/from_init3/runme.py
+++ b/Examples/python/import_packages/from_init3/runme.py
@@ -1,6 +1,10 @@
-# Test import of modules content from within __init__.py
-print "Testing %module(package=...) + python 'import' in __init__.py"
 import sys
+import os.path
+
+# Test import of modules content from within __init__.py
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+
 if sys.version_info < (3,0):
   import py2.pkg2
   print "  Finished importing py2.pkg2"
diff --git a/Examples/python/import_packages/relativeimport1/Makefile b/Examples/python/import_packages/relativeimport1/Makefile
index 8e35c6c..b9d803a 100644
--- a/Examples/python/import_packages/relativeimport1/Makefile
+++ b/Examples/python/import_packages/relativeimport1/Makefile
@@ -11,7 +11,7 @@
 endif
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
 	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build
@@ -20,6 +20,6 @@
 	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd py2 && $(MAKE) clean
 	cd py3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport1/py2/Makefile b/Examples/python/import_packages/relativeimport1/py2/Makefile
index 4c0dfab..9595397 100644
--- a/Examples/python/import_packages/relativeimport1/py2/Makefile
+++ b/Examples/python/import_packages/relativeimport1/py2/Makefile
@@ -10,5 +10,5 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile b/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile
index 3fe5613..36e099b 100644
--- a/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile
+++ b/Examples/python/import_packages/relativeimport1/py2/pkg2/Makefile
@@ -4,15 +4,15 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='bar' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
 	cd pkg3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile
index a417e27..cb20bd2 100644
--- a/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile
+++ b/Examples/python/import_packages/relativeimport1/py2/pkg2/pkg3/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/relativeimport1/py3/Makefile b/Examples/python/import_packages/relativeimport1/py3/Makefile
index 4c0dfab..9595397 100644
--- a/Examples/python/import_packages/relativeimport1/py3/Makefile
+++ b/Examples/python/import_packages/relativeimport1/py3/Makefile
@@ -10,5 +10,5 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile b/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile
index 3fe5613..36e099b 100644
--- a/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile
+++ b/Examples/python/import_packages/relativeimport1/py3/pkg2/Makefile
@@ -4,15 +4,15 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='bar' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
 	cd pkg3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile
index a417e27..cb20bd2 100644
--- a/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile
+++ b/Examples/python/import_packages/relativeimport1/py3/pkg2/pkg3/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/relativeimport1/runme.py b/Examples/python/import_packages/relativeimport1/runme.py
index 44ce8d1..99b6e51 100644
--- a/Examples/python/import_packages/relativeimport1/runme.py
+++ b/Examples/python/import_packages/relativeimport1/runme.py
@@ -1,6 +1,10 @@
-# Test import of modules content from within __init__.py
-print "Testing %module(package=...) with -relativeimport"
 import sys
+import os.path
+
+# Test import of modules content from within __init__.py
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - %module(package=...) with -relativeimport"
+
 if sys.version_info < (3,0):
   import py2.pkg2.bar
   print "  Finished importing py2.pkg2.bar"
diff --git a/Examples/python/import_packages/relativeimport2/Makefile b/Examples/python/import_packages/relativeimport2/Makefile
index 8e35c6c..b9d803a 100644
--- a/Examples/python/import_packages/relativeimport2/Makefile
+++ b/Examples/python/import_packages/relativeimport2/Makefile
@@ -11,7 +11,7 @@
 endif
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
 	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build
@@ -20,6 +20,6 @@
 	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd py2 && $(MAKE) clean
 	cd py3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport2/py2/Makefile b/Examples/python/import_packages/relativeimport2/py2/Makefile
index 4c0dfab..9595397 100644
--- a/Examples/python/import_packages/relativeimport2/py2/Makefile
+++ b/Examples/python/import_packages/relativeimport2/py2/Makefile
@@ -10,5 +10,5 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile b/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile
index 3fe5613..36e099b 100644
--- a/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile
+++ b/Examples/python/import_packages/relativeimport2/py2/pkg2/Makefile
@@ -4,15 +4,15 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='bar' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
 	cd pkg3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/Makefile
index 470f9d5..d6ae1b2 100644
--- a/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/Makefile
+++ b/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/Makefile
@@ -10,5 +10,5 @@
 	cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg4 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile
index a98d311..286d900 100644
--- a/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile
+++ b/Examples/python/import_packages/relativeimport2/py2/pkg2/pkg3/pkg4/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/relativeimport2/py3/Makefile b/Examples/python/import_packages/relativeimport2/py3/Makefile
index 4c0dfab..9595397 100644
--- a/Examples/python/import_packages/relativeimport2/py3/Makefile
+++ b/Examples/python/import_packages/relativeimport2/py3/Makefile
@@ -10,5 +10,5 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile b/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile
index 3fe5613..36e099b 100644
--- a/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile
+++ b/Examples/python/import_packages/relativeimport2/py3/pkg2/Makefile
@@ -4,15 +4,15 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
 	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='bar' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
 	cd pkg3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/Makefile
index 470f9d5..d6ae1b2 100644
--- a/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/Makefile
+++ b/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/Makefile
@@ -10,5 +10,5 @@
 	cd pkg4 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg4 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile b/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile
index a98d311..286d900 100644
--- a/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile
+++ b/Examples/python/import_packages/relativeimport2/py3/pkg2/pkg3/pkg4/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/relativeimport2/runme.py b/Examples/python/import_packages/relativeimport2/runme.py
index ac60eb6..f0ab6c4 100644
--- a/Examples/python/import_packages/relativeimport2/runme.py
+++ b/Examples/python/import_packages/relativeimport2/runme.py
@@ -1,6 +1,10 @@
-# Test import of modules content from within __init__.py
-print "Testing %module(package=...) + python 'import' in __init__.py"
 import sys
+import os.path
+
+# Test import of modules content from within __init__.py
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+
 if sys.version_info < (3,0):
   import py2.pkg2.bar
   print "  Finished importing py2.pkg2.bar"
diff --git a/Examples/python/import_packages/relativeimport2/runme3.py b/Examples/python/import_packages/relativeimport2/runme3.py
deleted file mode 100644
index 4b0d112..0000000
--- a/Examples/python/import_packages/relativeimport2/runme3.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# Test import of modules content from within __init__.py
-print("Testing %module(package=...) + python 'import' in __init__.py")
-import sys
-if sys.version_info < (3, 0):
-  import py2.pkg2.bar
-  print("  Finished importing py2.pkg2.bar")
-else:
-  import py3.pkg2.bar
-  print("  Finished importing py3.pkg2.bar")
diff --git a/Examples/python/import_packages/relativeimport3/Makefile b/Examples/python/import_packages/relativeimport3/Makefile
new file mode 100644
index 0000000..b9d803a
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/Makefile
@@ -0,0 +1,25 @@
+TOP        = ../../..
+SWIG       = $(realpath $(TOP)/../preinst-swig)
+SWIGOPT    =
+LIBS       =
+PY3        =
+
+ifeq (,$(PY3))
+  PKG1DIR  = "py2"
+else
+  PKG1DIR  = "py3"
+endif
+
+check: build
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
+
+build:
+	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build
+
+static:
+	cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static
+
+clean:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
+	cd py2 && $(MAKE) clean
+	cd py3 && $(MAKE) clean
diff --git a/Examples/python/import_packages/relativeimport3/README b/Examples/python/import_packages/relativeimport3/README
new file mode 100644
index 0000000..a99ef24
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/README
@@ -0,0 +1,22 @@
+This example tests the %import directive and -relativeimport swig option.
+
+Use 'python runme.py' to run a test.
+
+Overview:
+---------
+
+The example defines 2 different extension modules--each wrapping a separate C++
+class.
+
+     pyX/pkg2/pkg3/foo.i   - Pkg3_Foo class
+     pyX/pkg2/bar.i        - Pkg2_Bar class derived from Pkg3_Foo
+
+The code is processed by swig with -relativeimport flag. The runtime test
+imports pyX.pkg2.bar module.
+
+If everything works well, the module pyX.pkg2.bar shall load properly.
+
+Unix:
+-----
+- Run make
+- Run the test as described above
diff --git a/Examples/python/import_packages/relativeimport3/py2/Makefile b/Examples/python/import_packages/relativeimport3/py2/Makefile
new file mode 100644
index 0000000..9595397
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py2/Makefile
@@ -0,0 +1,14 @@
+TOP        = ../../../..
+SWIG       = $(realpath $(TOP)/../preinst-swig)
+SWIGOPT    =
+LIBS       =
+
+build:
+	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
+
+static:
+	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
+
+clean:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
+	cd pkg2 && $(MAKE) clean
diff --git a/Examples/javascript/functor/example.cxx b/Examples/python/import_packages/relativeimport3/py2/__init__.py
similarity index 100%
rename from Examples/javascript/functor/example.cxx
rename to Examples/python/import_packages/relativeimport3/py2/__init__.py
diff --git a/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile b/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile
new file mode 100644
index 0000000..36e099b
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py2/pkg2/Makefile
@@ -0,0 +1,18 @@
+TOP        = ../../../../..
+SWIG       = $(realpath $(TOP)/../preinst-swig)
+SWIGOPT    =
+LIBS       =
+
+build:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
+	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
+
+static:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
+	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
+
+clean:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
+	cd pkg3 && $(MAKE) clean
diff --git a/Examples/javascript/functor/example.cxx b/Examples/python/import_packages/relativeimport3/py2/pkg2/__init__.py
similarity index 100%
copy from Examples/javascript/functor/example.cxx
copy to Examples/python/import_packages/relativeimport3/py2/pkg2/__init__.py
diff --git a/Examples/python/import_packages/relativeimport3/py2/pkg2/bar.hpp b/Examples/python/import_packages/relativeimport3/py2/pkg2/bar.hpp
new file mode 100644
index 0000000..8f09cd5
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py2/pkg2/bar.hpp
@@ -0,0 +1,5 @@
+#ifndef PY2_PKG2_BAR_HPP
+#define PY2_PKG2_BAR_HPP
+#include "../../py2/pkg2/pkg3/foo.hpp"
+struct Pkg2_Bar : Pkg3_Foo {};
+#endif /* PY2_PKG2_BAR_HPP */
diff --git a/Examples/python/import_packages/relativeimport3/py2/pkg2/bar.i b/Examples/python/import_packages/relativeimport3/py2/pkg2/bar.i
new file mode 100644
index 0000000..6f4690b
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py2/pkg2/bar.i
@@ -0,0 +1,6 @@
+%module(package="py2.pkg2") bar
+%{
+#include "../../py2/pkg2/bar.hpp"
+%}
+%import (module="foo", package="py2.pkg2.pkg3") "../../py2/pkg2/pkg3/foo.hpp"
+%include "../../py2/pkg2/bar.hpp"
diff --git a/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile
new file mode 100644
index 0000000..cb20bd2
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/Makefile
@@ -0,0 +1,15 @@
+TOP        = ../../../../../..
+SWIG       = $(realpath $(TOP)/../preinst-swig)
+SWIGOPT    =
+LIBS       =
+
+build:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
+
+static:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
+
+clean:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/javascript/functor/example.cxx b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/__init__.py
similarity index 100%
copy from Examples/javascript/functor/example.cxx
copy to Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/__init__.py
diff --git a/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/foo.hpp b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/foo.hpp
new file mode 100644
index 0000000..b6c89a4
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/foo.hpp
@@ -0,0 +1,4 @@
+#ifndef PY2_PKG2_PKG3_FOO_HPP
+#define PY2_PKG2_PKG3_FOO_HPP
+struct Pkg3_Foo {};
+#endif /* PY2_PKG2_PKG3_FOO_HPP */
diff --git a/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/foo.i b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/foo.i
new file mode 100644
index 0000000..ba32483
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py2/pkg2/pkg3/foo.i
@@ -0,0 +1,5 @@
+%module(package="py2.pkg2.pkg3") foo
+%{
+#include "../../../py2/pkg2/pkg3/foo.hpp"
+%}
+%include "../../../py2/pkg2/pkg3/foo.hpp"
diff --git a/Examples/python/import_packages/relativeimport3/py3/Makefile b/Examples/python/import_packages/relativeimport3/py3/Makefile
new file mode 100644
index 0000000..9595397
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py3/Makefile
@@ -0,0 +1,14 @@
+TOP        = ../../../..
+SWIG       = $(realpath $(TOP)/../preinst-swig)
+SWIGOPT    =
+LIBS       =
+
+build:
+	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
+
+static:
+	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
+
+clean:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
+	cd pkg2 && $(MAKE) clean
diff --git a/Examples/javascript/functor/example.cxx b/Examples/python/import_packages/relativeimport3/py3/__init__.py
similarity index 100%
copy from Examples/javascript/functor/example.cxx
copy to Examples/python/import_packages/relativeimport3/py3/__init__.py
diff --git a/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile b/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile
new file mode 100644
index 0000000..36e099b
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py3/pkg2/Makefile
@@ -0,0 +1,18 @@
+TOP        = ../../../../..
+SWIG       = $(realpath $(TOP)/../preinst-swig)
+SWIGOPT    =
+LIBS       =
+
+build:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
+	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
+
+static:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
+	cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
+
+clean:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
+	cd pkg3 && $(MAKE) clean
diff --git a/Examples/javascript/functor/example.cxx b/Examples/python/import_packages/relativeimport3/py3/pkg2/__init__.py
similarity index 100%
copy from Examples/javascript/functor/example.cxx
copy to Examples/python/import_packages/relativeimport3/py3/pkg2/__init__.py
diff --git a/Examples/python/import_packages/relativeimport3/py3/pkg2/bar.hpp b/Examples/python/import_packages/relativeimport3/py3/pkg2/bar.hpp
new file mode 100644
index 0000000..408d910
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py3/pkg2/bar.hpp
@@ -0,0 +1,5 @@
+#ifndef PY3_PKG2_BAR_HPP
+#define PY3_PKG2_BAR_HPP
+#include "../../py3/pkg2/pkg3/foo.hpp"
+struct Pkg2_Bar : Pkg3_Foo {};
+#endif /* PY3_PKG2_BAR_HPP */
diff --git a/Examples/python/import_packages/relativeimport3/py3/pkg2/bar.i b/Examples/python/import_packages/relativeimport3/py3/pkg2/bar.i
new file mode 100644
index 0000000..157c62e
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py3/pkg2/bar.i
@@ -0,0 +1,6 @@
+%module(package="py3.pkg2") bar
+%{
+#include "../../py3/pkg2/bar.hpp"
+%}
+%import (module="foo", package="py3.pkg2.pkg3") "../../py3/pkg2/pkg3/foo.hpp"
+%include "../../py3/pkg2/bar.hpp"
diff --git a/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile
new file mode 100644
index 0000000..cb20bd2
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/Makefile
@@ -0,0 +1,15 @@
+TOP        = ../../../../../..
+SWIG       = $(realpath $(TOP)/../preinst-swig)
+SWIGOPT    =
+LIBS       =
+
+build:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
+
+static:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
+
+clean:
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/javascript/functor/example.cxx b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/__init__.py
similarity index 100%
copy from Examples/javascript/functor/example.cxx
copy to Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/__init__.py
diff --git a/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/foo.hpp b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/foo.hpp
new file mode 100644
index 0000000..531721d
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/foo.hpp
@@ -0,0 +1,4 @@
+#ifndef PY3_PKG2_PKG3_FOO_HPP
+#define PY3_PKG2_PKG3_FOO_HPP
+struct Pkg3_Foo {};
+#endif /* PY3_PKG2_PKG3_FOO_HPP */
diff --git a/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/foo.i b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/foo.i
new file mode 100644
index 0000000..c6ba529
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/py3/pkg2/pkg3/foo.i
@@ -0,0 +1,5 @@
+%module(package="py3.pkg2.pkg3") foo
+%{
+#include "../../../py3/pkg2/pkg3/foo.hpp"
+%}
+%include "../../../py3/pkg2/pkg3/foo.hpp"
diff --git a/Examples/python/import_packages/relativeimport3/runme.py b/Examples/python/import_packages/relativeimport3/runme.py
new file mode 100644
index 0000000..99b6e51
--- /dev/null
+++ b/Examples/python/import_packages/relativeimport3/runme.py
@@ -0,0 +1,13 @@
+import sys
+import os.path
+
+# Test import of modules content from within __init__.py
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - %module(package=...) with -relativeimport"
+
+if sys.version_info < (3,0):
+  import py2.pkg2.bar
+  print "  Finished importing py2.pkg2.bar"
+else:
+  import py3.pkg2.bar
+  print "  Finished importing py3.pkg2.bar"
diff --git a/Examples/python/import_packages/same_modnames1/Makefile b/Examples/python/import_packages/same_modnames1/Makefile
index 9dd5971..e05c130 100644
--- a/Examples/python/import_packages/same_modnames1/Makefile
+++ b/Examples/python/import_packages/same_modnames1/Makefile
@@ -4,7 +4,7 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
 	cd pkg1 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
@@ -15,6 +15,6 @@
 	cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg1 && $(MAKE) clean
 	cd pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/same_modnames1/pkg1/Makefile b/Examples/python/import_packages/same_modnames1/pkg1/Makefile
index 9b51a76..df1b303 100644
--- a/Examples/python/import_packages/same_modnames1/pkg1/Makefile
+++ b/Examples/python/import_packages/same_modnames1/pkg1/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/same_modnames1/pkg2/Makefile b/Examples/python/import_packages/same_modnames1/pkg2/Makefile
index 9b51a76..df1b303 100644
--- a/Examples/python/import_packages/same_modnames1/pkg2/Makefile
+++ b/Examples/python/import_packages/same_modnames1/pkg2/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/same_modnames1/runme.py b/Examples/python/import_packages/same_modnames1/runme.py
index 923f0e0..7bec1ec 100644
--- a/Examples/python/import_packages/same_modnames1/runme.py
+++ b/Examples/python/import_packages/same_modnames1/runme.py
@@ -1,5 +1,9 @@
+import os.path
+
 # Test import of same modules from different packages
-print "Testing %module(package=...) + %import + same modules in different packages"
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+
 import pkg2.foo
 print "  Finished importing pkg2.foo"
 
diff --git a/Examples/python/import_packages/same_modnames2/Makefile b/Examples/python/import_packages/same_modnames2/Makefile
index cfc3278..770343a 100644
--- a/Examples/python/import_packages/same_modnames2/Makefile
+++ b/Examples/python/import_packages/same_modnames2/Makefile
@@ -4,7 +4,7 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
 	cd pkg1 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
@@ -15,6 +15,6 @@
 	cd pkg1/pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	cd pkg1 && $(MAKE) clean
 	cd pkg1/pkg2 && $(MAKE) clean
diff --git a/Examples/python/import_packages/same_modnames2/pkg1/Makefile b/Examples/python/import_packages/same_modnames2/pkg1/Makefile
index 9b51a76..df1b303 100644
--- a/Examples/python/import_packages/same_modnames2/pkg1/Makefile
+++ b/Examples/python/import_packages/same_modnames2/pkg1/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile b/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile
index 053b911..11e8573 100644
--- a/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile
+++ b/Examples/python/import_packages/same_modnames2/pkg1/pkg2/Makefile
@@ -4,12 +4,12 @@
 LIBS       =
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='foo' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
diff --git a/Examples/python/import_packages/same_modnames2/runme.py b/Examples/python/import_packages/same_modnames2/runme.py
index af8f781..eec6121 100644
--- a/Examples/python/import_packages/same_modnames2/runme.py
+++ b/Examples/python/import_packages/same_modnames2/runme.py
@@ -1,3 +1,8 @@
+import os.path
+
+testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
+print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
+
 import pkg1.pkg2.foo
 print "  Finished importing pkg1.pkg2.foo"
 
diff --git a/Examples/python/import_template/Makefile b/Examples/python/import_template/Makefile
index f63e122..d83dfea 100644
--- a/Examples/python/import_template/Makefile
+++ b/Examples/python/import_template/Makefile
@@ -4,19 +4,19 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' python_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' python_cpp
 
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
 	rm -f foo.py bar.py spam.py base.py
diff --git a/Examples/python/import_template/base.h b/Examples/python/import_template/base.h
index c755a6f..8faafb3 100644
--- a/Examples/python/import_template/base.h
+++ b/Examples/python/import_template/base.h
@@ -2,8 +2,8 @@
 
 template<class T> class Base {
  public:
-     Base() { };
-     virtual ~Base() { };
+     Base() { }
+     virtual ~Base() { }
      virtual void A() {
          printf("I'm Base::A\n");
      }
diff --git a/Examples/python/java/Makefile b/Examples/python/java/Makefile
index 12a9b51..4befa38 100644
--- a/Examples/python/java/Makefile
+++ b/Examples/python/java/Makefile
@@ -6,17 +6,18 @@
 LIBS       = -lm
 
 check: build
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
-build: Example.class
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj"  \
+build: Example.class Example.h
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	CXXSHARED="gcj -fpic -shared Example.class" DEFS='' LIBS="-lstdc++" python_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
 	rm -f $(TARGET).py
 	rm -f *.class Example.h
 
-Example.class: Example.java
-	gcj -fPIC -C -c -g Example.java
-	gcjh  Example
+Example.class Example.h: $(SRCDIR)Example.java
+	gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
+	gcjh Example.class
diff --git a/Examples/python/java/example.i b/Examples/python/java/example.i
index 13d5b5e..80e0887 100644
--- a/Examples/python/java/example.i
+++ b/Examples/python/java/example.i
@@ -7,3 +7,7 @@
 
 
 %include Example.h
+
+%extend Example {
+  ~Example() {}
+}
diff --git a/Examples/python/libffi/Makefile b/Examples/python/libffi/Makefile
index ae51b0a..db5dfe1 100644
--- a/Examples/python/libffi/Makefile
+++ b/Examples/python/libffi/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' LIBS='-L/usr/local/lib -lffi' python
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/multimap/Makefile b/Examples/python/multimap/Makefile
index df3bc86..222916f 100644
--- a/Examples/python/multimap/Makefile
+++ b/Examples/python/multimap/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/operator/Makefile b/Examples/python/operator/Makefile
index dde0d09..1234c31 100644
--- a/Examples/python/operator/Makefile
+++ b/Examples/python/operator/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/performance/constructor/Makefile b/Examples/python/performance/constructor/Makefile
index 98a50ec..8e65123 100644
--- a/Examples/python/performance/constructor/Makefile
+++ b/Examples/python/performance/constructor/Makefile
@@ -5,17 +5,17 @@
 INTERFACE  = Simple.i
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
 	TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
 	TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
 	TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
 	rm -f $(TARGET)_*.py
diff --git a/Examples/python/performance/func/Makefile b/Examples/python/performance/func/Makefile
index 98a50ec..8e65123 100644
--- a/Examples/python/performance/func/Makefile
+++ b/Examples/python/performance/func/Makefile
@@ -5,17 +5,17 @@
 INTERFACE  = Simple.i
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
 	TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
 	TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
 	TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
 	rm -f $(TARGET)_*.py
diff --git a/Examples/python/performance/hierarchy/Makefile b/Examples/python/performance/hierarchy/Makefile
index 98a50ec..8e65123 100644
--- a/Examples/python/performance/hierarchy/Makefile
+++ b/Examples/python/performance/hierarchy/Makefile
@@ -5,17 +5,17 @@
 INTERFACE  = Simple.i
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
 	TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
 	TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
 	TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
 	rm -f $(TARGET)_*.py
diff --git a/Examples/python/performance/hierarchy_operator/Makefile b/Examples/python/performance/hierarchy_operator/Makefile
index 98a50ec..8e65123 100644
--- a/Examples/python/performance/hierarchy_operator/Makefile
+++ b/Examples/python/performance/hierarchy_operator/Makefile
@@ -5,17 +5,17 @@
 INTERFACE  = Simple.i
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
 	TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
 	TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
 	TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
 	rm -f $(TARGET)_*.py
diff --git a/Examples/python/performance/operator/Makefile b/Examples/python/performance/operator/Makefile
index 98a50ec..8e65123 100644
--- a/Examples/python/performance/operator/Makefile
+++ b/Examples/python/performance/operator/Makefile
@@ -5,17 +5,17 @@
 INTERFACE  = Simple.i
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
 	TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
 	TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
 	TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
 	rm -f $(TARGET)_*.py
diff --git a/Examples/python/pointer/Makefile b/Examples/python/pointer/Makefile
index df3bc86..222916f 100644
--- a/Examples/python/pointer/Makefile
+++ b/Examples/python/pointer/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/reference/Makefile b/Examples/python/reference/Makefile
index e940c1f..41cded2 100644
--- a/Examples/python/reference/Makefile
+++ b/Examples/python/reference/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/reference/example.cxx b/Examples/python/reference/example.cxx
index 8a513bf..9dbaed2 100644
--- a/Examples/python/reference/example.cxx
+++ b/Examples/python/reference/example.cxx
@@ -19,7 +19,7 @@
 
 char *Vector::print() {
   static char temp[512];
-  sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
diff --git a/Examples/python/reference/example.h b/Examples/python/reference/example.h
index 4915adb..bcfcfb7 100644
--- a/Examples/python/reference/example.h
+++ b/Examples/python/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   friend Vector operator+(const Vector &a, const Vector &b);
   char *print();
 };
@@ -20,7 +20,3 @@
   Vector &operator[](int);
   int size();
 };
-
-
-
-  
diff --git a/Examples/python/reference/example.i b/Examples/python/reference/example.i
index 8c95b32..8af8397 100644
--- a/Examples/python/reference/example.i
+++ b/Examples/python/reference/example.i
@@ -31,7 +31,7 @@
   VectorArray(int maxsize);
   ~VectorArray();
   int size();
-  
+
   /* This wrapper provides an alternative to the [] operator */
   %extend {
     Vector &get(int index) {
@@ -42,7 +42,3 @@
     }
   }
 };
-
-
-
-
diff --git a/Examples/python/simple/Makefile b/Examples/python/simple/Makefile
index df3bc86..222916f 100644
--- a/Examples/python/simple/Makefile
+++ b/Examples/python/simple/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile
index aaba9cb..1960935 100644
--- a/Examples/python/smartptr/Makefile
+++ b/Examples/python/smartptr/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/smartptr/example.h b/Examples/python/smartptr/example.h
index c0f9b1d..c18e7ea 100644
--- a/Examples/python/smartptr/example.h
+++ b/Examples/python/smartptr/example.h
@@ -7,7 +7,7 @@
   }
   virtual ~Shape() {
     nshapes--;
-  };
+  }
   double  x, y;   
   void    move(double dx, double dy);
   virtual double area() = 0;
@@ -19,7 +19,7 @@
 private:
   double radius;
 public:
-  Circle(double r) : radius(r) { };
+  Circle(double r) : radius(r) { }
   virtual double area();
   virtual double perimeter();
 };
diff --git a/Examples/python/std_map/Makefile b/Examples/python/std_map/Makefile
index 86a6434..f406dfa 100644
--- a/Examples/python/std_map/Makefile
+++ b/Examples/python/std_map/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile
index 86a6434..f406dfa 100644
--- a/Examples/python/std_vector/Makefile
+++ b/Examples/python/std_vector/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/swigrun/Makefile b/Examples/python/swigrun/Makefile
deleted file mode 100644
index c58f39c..0000000
--- a/Examples/python/swigrun/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-TOP        = ../..
-SWIG       = $(TOP)/../preinst-swig
-CXXSRCS    = example.cxx
-TARGET     = example
-INTERFACE  = example.i
-LIBS       = -lm
-SWIGOPT    =
-
-check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
-
-build:
-	$(SWIG) -python -external-runtime
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
-
-static:
-	$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
-
-clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
-	rm -f swigpyrun.h
diff --git a/Examples/python/swigrun/example.cxx b/Examples/python/swigrun/example.cxx
deleted file mode 100644
index 25906a5..0000000
--- a/Examples/python/swigrun/example.cxx
+++ /dev/null
@@ -1,20 +0,0 @@
-/* File : example.cxx */
-
-#include <Python.h>
-#include "swigpyrun.h"
-#include "example.h"
-
-
-Manager* convert_to_Manager(PyObject *py_obj)
-{
-  Manager* c_ptr;
-  swig_type_info *ty = SWIG_TypeQuery("Manager *");
-  printf("manager ty %p \n", ty);
-  if (SWIG_ConvertPtr(py_obj, (void **) &c_ptr, ty, 0) == -1) {
-    c_ptr = 0;
-  } else {
-    Py_XINCREF(py_obj);
-  }
-  return c_ptr;
-}
-
diff --git a/Examples/python/swigrun/example.h b/Examples/python/swigrun/example.h
deleted file mode 100644
index 69e6fe4..0000000
--- a/Examples/python/swigrun/example.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* File : example.h */
-
-#include <cstdio>
-#include <iostream>
-#include <vector>
-#include <string>
-#include <cmath>
-
-class Employee {
-private:
-	std::string name;
-public:
-	Employee(const char* n): name(n) {}
-	virtual std::string getTitle() { return getPosition() + " " + getName(); }
-	virtual std::string getName() { return name; }
-	virtual std::string getPosition() const { return "Employee"; }
-	virtual ~Employee() { printf("~Employee() @ %p\n", this); }
-};
-
-
-class Manager: public Employee {
-public:
-	Manager(const char* n): Employee(n) {}
-	virtual std::string getPosition() const { return "Manager"; }
-};
-
-
-class EmployeeList {
-	std::vector<Employee*> list;
-public:
-	EmployeeList() {
-		list.push_back(new Employee("Bob"));
-		list.push_back(new Employee("Jane"));
-		list.push_back(new Manager("Ted"));
-	}
-	void addEmployee(Employee *p) {
-		list.push_back(p);
-		std::cout << "New employee added.   Current employees are:" << std::endl;
-		std::vector<Employee*>::iterator i;
-		for (i=list.begin(); i!=list.end(); i++) {
-			std::cout << "  " << (*i)->getTitle() << std::endl;
-		}
-	}
-	const Employee *get_item(int i) {
-		return list[i];
-	}
-	~EmployeeList() { 
-		std::vector<Employee*>::iterator i;
-		std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
-		for (i=list.begin(); i!=list.end(); i++) {
-			delete *i;
-		}
-		std::cout << "~EmployeeList empty." << std::endl;
-	}
-};
-
-Manager* convert_to_Manager(PyObject *obj);
-
diff --git a/Examples/python/swigrun/example.i b/Examples/python/swigrun/example.i
deleted file mode 100644
index c8ec32e..0000000
--- a/Examples/python/swigrun/example.i
+++ /dev/null
@@ -1,15 +0,0 @@
-/* File : example.i */
-%module(directors="1") example
-%{
-#include "example.h"
-%}
-
-%include "std_vector.i"
-%include "std_string.i"
-
-/* turn on director wrapping for Manager */
-%feature("director") Employee;
-%feature("director") Manager;
-
-%include "example.h"
-
diff --git a/Examples/python/swigrun/runme.py b/Examples/python/swigrun/runme.py
deleted file mode 100644
index abcd964..0000000
--- a/Examples/python/swigrun/runme.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# file: runme.py
-
-# This file illustrates the cross language polymorphism using directors.
-
-import example 
-
-
-# CEO class, which overrides Employee::getPosition().
-
-class CEO(example.Manager):
-	def __init__(self, name):
-		example.Manager.__init__(self, name)
-	def getPosition(self):
-		return "CEO"
-	def __del__(self):
-		print "CEO.__del__(),", self.getName()
-		# for proxy class extensions that are not "disowned" and
-		# define a __del__ method, it is very important to call the 
-		# base class __del__.  otherwise the c++ objects will never
-		# be deleted.
-		example.Manager.__del__(self)
-
-
-
-
-e = CEO("Alice")
-m = example.convert_to_Manager(e)
-print m
diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile
index 86a6434..f406dfa 100644
--- a/Examples/python/template/Makefile
+++ b/Examples/python/template/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/varargs/Makefile b/Examples/python/varargs/Makefile
index 15ffa24..8ec6e9c 100644
--- a/Examples/python/varargs/Makefile
+++ b/Examples/python/varargs/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/variables/Makefile b/Examples/python/variables/Makefile
index df3bc86..222916f 100644
--- a/Examples/python/variables/Makefile
+++ b/Examples/python/variables/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile python_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' python_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
diff --git a/Examples/python/variables/example.c b/Examples/python/variables/example.c
index 05e17c8..85685fe 100644
--- a/Examples/python/variables/example.c
+++ b/Examples/python/variables/example.c
@@ -52,9 +52,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %s\n", name);
-  printf("ptptr     = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+  printf("ptptr     = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/r/class/Makefile b/Examples/r/class/Makefile
index 8a64f49..3e5d6a6 100644
--- a/Examples/r/class/Makefile
+++ b/Examples/r/class/Makefile
@@ -5,11 +5,11 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile r_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' r_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' r_clean
diff --git a/Examples/r/class/example.cxx b/Examples/r/class/example.cxx
index 1e8e203..0463045 100644
--- a/Examples/r/class/example.cxx
+++ b/Examples/r/class/example.cxx
@@ -1,4 +1,4 @@
-/* File : example.c */
+/* File : example.cxx */
 
 #include "example.h"
 #define M_PI 3.14159265358979323846
@@ -11,18 +11,18 @@
 
 int Shape::nshapes = 0;
 
-double Circle::area(void) {
+double Circle::area() {
   return M_PI*radius*radius;
 }
 
-double Circle::perimeter(void) {
+double Circle::perimeter() {
   return 2*M_PI*radius;
 }
 
-double Square::area(void) {
+double Square::area() {
   return width*width;
 }
 
-double Square::perimeter(void) {
+double Square::perimeter() {
   return 4*width;
 }
diff --git a/Examples/r/simple/Makefile b/Examples/r/simple/Makefile
index 8a8e0e1..5cc4153 100644
--- a/Examples/r/simple/Makefile
+++ b/Examples/r/simple/Makefile
@@ -5,11 +5,11 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile r_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' r_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' r
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile INTERFACE='$(INTERFACE)' r_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' INTERFACE='$(INTERFACE)' r_clean
diff --git a/Examples/ruby/class/Makefile b/Examples/ruby/class/Makefile
index ef267bc..516f842 100644
--- a/Examples/ruby/class/Makefile
+++ b/Examples/ruby/class/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/constants/Makefile b/Examples/ruby/constants/Makefile
index 7af9ec8..561d5fd 100644
--- a/Examples/ruby/constants/Makefile
+++ b/Examples/ruby/constants/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/enum/Makefile b/Examples/ruby/enum/Makefile
index ef267bc..516f842 100644
--- a/Examples/ruby/enum/Makefile
+++ b/Examples/ruby/enum/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/exception_class/Makefile b/Examples/ruby/exception_class/Makefile
index f0ae7e5..6723a2a 100644
--- a/Examples/ruby/exception_class/Makefile
+++ b/Examples/ruby/exception_class/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/free_function/Makefile b/Examples/ruby/free_function/Makefile
index ef267bc..516f842 100644
--- a/Examples/ruby/free_function/Makefile
+++ b/Examples/ruby/free_function/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/funcptr/Makefile b/Examples/ruby/funcptr/Makefile
index ddbc1ae..15b39cf 100644
--- a/Examples/ruby/funcptr/Makefile
+++ b/Examples/ruby/funcptr/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/funcptr2/Makefile b/Examples/ruby/funcptr2/Makefile
index ddbc1ae..15b39cf 100644
--- a/Examples/ruby/funcptr2/Makefile
+++ b/Examples/ruby/funcptr2/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/functor/Makefile b/Examples/ruby/functor/Makefile
index 662baa1..348bd66 100644
--- a/Examples/ruby/functor/Makefile
+++ b/Examples/ruby/functor/Makefile
@@ -5,15 +5,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/hashargs/Makefile b/Examples/ruby/hashargs/Makefile
index 3933cf2..59a36c0 100644
--- a/Examples/ruby/hashargs/Makefile
+++ b/Examples/ruby/hashargs/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/import/Makefile b/Examples/ruby/import/Makefile
index cd7719b..b5d06bd 100644
--- a/Examples/ruby/import/Makefile
+++ b/Examples/ruby/import/Makefile
@@ -4,17 +4,17 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/import_template/Makefile b/Examples/ruby/import_template/Makefile
index cd7719b..b5d06bd 100644
--- a/Examples/ruby/import_template/Makefile
+++ b/Examples/ruby/import_template/Makefile
@@ -4,17 +4,17 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' ruby_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' ruby_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' ruby_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' ruby_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/java/Makefile b/Examples/ruby/java/Makefile
index 4d24934..7d611ab 100644
--- a/Examples/ruby/java/Makefile
+++ b/Examples/ruby/java/Makefile
@@ -6,17 +6,17 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
-build: Example.class
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj" \
+build: Example.class Example.h
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
 	CXXSHARED="gcj -fpic -shared Example.class" LIBS="-lstdc++" DEFS='' ruby_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
 	rm -f *.class Example.h
 
-Example.class: Example.java
-	gcj -fPIC -C -c -g Example.java
-	gcjh  Example
+Example.class Example.h: $(SRCDIR)Example.java
+	gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
+	gcjh Example.class
diff --git a/Examples/ruby/mark_function/Makefile b/Examples/ruby/mark_function/Makefile
index ef267bc..516f842 100644
--- a/Examples/ruby/mark_function/Makefile
+++ b/Examples/ruby/mark_function/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/multimap/Makefile b/Examples/ruby/multimap/Makefile
index ddbc1ae..15b39cf 100644
--- a/Examples/ruby/multimap/Makefile
+++ b/Examples/ruby/multimap/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/operator/Makefile b/Examples/ruby/operator/Makefile
index 5fd4b07..bdcf526 100644
--- a/Examples/ruby/operator/Makefile
+++ b/Examples/ruby/operator/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/overloading/Makefile b/Examples/ruby/overloading/Makefile
index ef267bc..516f842 100644
--- a/Examples/ruby/overloading/Makefile
+++ b/Examples/ruby/overloading/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/pointer/Makefile b/Examples/ruby/pointer/Makefile
index ddbc1ae..15b39cf 100644
--- a/Examples/ruby/pointer/Makefile
+++ b/Examples/ruby/pointer/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/reference/Makefile b/Examples/ruby/reference/Makefile
index ef267bc..516f842 100644
--- a/Examples/ruby/reference/Makefile
+++ b/Examples/ruby/reference/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/reference/example.cxx b/Examples/ruby/reference/example.cxx
index 8a513bf..9dbaed2 100644
--- a/Examples/ruby/reference/example.cxx
+++ b/Examples/ruby/reference/example.cxx
@@ -19,7 +19,7 @@
 
 char *Vector::print() {
   static char temp[512];
-  sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
diff --git a/Examples/ruby/reference/example.h b/Examples/ruby/reference/example.h
index 4915adb..bcfcfb7 100644
--- a/Examples/ruby/reference/example.h
+++ b/Examples/ruby/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   friend Vector operator+(const Vector &a, const Vector &b);
   char *print();
 };
@@ -20,7 +20,3 @@
   Vector &operator[](int);
   int size();
 };
-
-
-
-  
diff --git a/Examples/ruby/reference/example.i b/Examples/ruby/reference/example.i
index 6daa3b1..173143d 100644
--- a/Examples/ruby/reference/example.i
+++ b/Examples/ruby/reference/example.i
@@ -29,7 +29,7 @@
   VectorArray(int maxsize);
   ~VectorArray();
   int size();
-  
+
   /* This wrapper provides an alternative to the [] operator */
   %extend {
     Vector &get(int index) {
@@ -40,7 +40,3 @@
     }
   }
 };
-
-
-
-
diff --git a/Examples/ruby/simple/Makefile b/Examples/ruby/simple/Makefile
index ddbc1ae..15b39cf 100644
--- a/Examples/ruby/simple/Makefile
+++ b/Examples/ruby/simple/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/std_vector/Makefile b/Examples/ruby/std_vector/Makefile
index 208a644..370bd8f 100644
--- a/Examples/ruby/std_vector/Makefile
+++ b/Examples/ruby/std_vector/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/template/Makefile b/Examples/ruby/template/Makefile
index 208a644..370bd8f 100644
--- a/Examples/ruby/template/Makefile
+++ b/Examples/ruby/template/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	SWIGOPT='$(SWIGOPT)' TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/value/Makefile b/Examples/ruby/value/Makefile
index ddbc1ae..15b39cf 100644
--- a/Examples/ruby/value/Makefile
+++ b/Examples/ruby/value/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/value/example.i b/Examples/ruby/value/example.i
index 98fd60e..39663c6 100644
--- a/Examples/ruby/value/example.i
+++ b/Examples/ruby/value/example.i
@@ -26,7 +26,7 @@
 }
 
 void vector_print(Vector *v) {
-  printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+  printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z);
 }
 %}
 
diff --git a/Examples/ruby/variables/Makefile b/Examples/ruby/variables/Makefile
index ddbc1ae..15b39cf 100644
--- a/Examples/ruby/variables/Makefile
+++ b/Examples/ruby/variables/Makefile
@@ -5,15 +5,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile ruby_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile ruby_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' ruby_clean
diff --git a/Examples/ruby/variables/example.c b/Examples/ruby/variables/example.c
index 05e17c8..85685fe 100644
--- a/Examples/ruby/variables/example.c
+++ b/Examples/ruby/variables/example.c
@@ -52,9 +52,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %s\n", name);
-  printf("ptptr     = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+  printf("ptptr     = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/tcl/class/Makefile b/Examples/tcl/class/Makefile
index db6149c..aacf30e 100644
--- a/Examples/tcl/class/Makefile
+++ b/Examples/tcl/class/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/constants/Makefile b/Examples/tcl/constants/Makefile
index ed4d89f..17c8afa 100644
--- a/Examples/tcl/constants/Makefile
+++ b/Examples/tcl/constants/Makefile
@@ -6,15 +6,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/contract/Makefile b/Examples/tcl/contract/Makefile
index ca6134e..01fdc37 100644
--- a/Examples/tcl/contract/Makefile
+++ b/Examples/tcl/contract/Makefile
@@ -7,15 +7,15 @@
 SWIGOPT    =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/enum/Makefile b/Examples/tcl/enum/Makefile
index db6149c..aacf30e 100644
--- a/Examples/tcl/enum/Makefile
+++ b/Examples/tcl/enum/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/funcptr/Makefile b/Examples/tcl/funcptr/Makefile
index 9190779..7155bf3 100644
--- a/Examples/tcl/funcptr/Makefile
+++ b/Examples/tcl/funcptr/Makefile
@@ -6,15 +6,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/import/Makefile b/Examples/tcl/import/Makefile
index 81cd7c4..6aa48e7 100644
--- a/Examples/tcl/import/Makefile
+++ b/Examples/tcl/import/Makefile
@@ -4,18 +4,18 @@
 LIBS       =
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='base' INTERFACE='base.i' tcl_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' tcl_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' tcl_cpp
-	$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
 	LIBS='$(LIBS)' TARGET='spam' INTERFACE='spam.i' tcl_cpp
 
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/java/Makefile b/Examples/tcl/java/Makefile
index 3a92123..4be3764 100644
--- a/Examples/tcl/java/Makefile
+++ b/Examples/tcl/java/Makefile
@@ -6,20 +6,17 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
-build: Example.class
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
-	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' CXX="gcj"  \
-	TCL_CXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp
+build: Example.class Example.h
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+	TCLCXXSHARED="gcj -fpic -shared Example.class " LIBS="-lstdc++" DEFS='' tcl_cpp
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
 	rm -f *.class Example.h
 
-run:
-	tclsh runme.tcl
-
-Example.class: Example.java
-	gcj -fPIC -C -c -g Example.java
-	gcjh  Example
+Example.class Example.h: $(SRCDIR)Example.java
+	gcj -d . -fPIC -C -c -g $(SRCDIR)Example.java
+	gcjh Example.class
diff --git a/Examples/tcl/multimap/Makefile b/Examples/tcl/multimap/Makefile
index 9190779..7155bf3 100644
--- a/Examples/tcl/multimap/Makefile
+++ b/Examples/tcl/multimap/Makefile
@@ -6,15 +6,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/operator/Makefile b/Examples/tcl/operator/Makefile
index 6c91c3d..1c6e1be 100644
--- a/Examples/tcl/operator/Makefile
+++ b/Examples/tcl/operator/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/pointer/Makefile b/Examples/tcl/pointer/Makefile
index 9190779..7155bf3 100644
--- a/Examples/tcl/pointer/Makefile
+++ b/Examples/tcl/pointer/Makefile
@@ -6,15 +6,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/reference/Makefile b/Examples/tcl/reference/Makefile
index db6149c..aacf30e 100644
--- a/Examples/tcl/reference/Makefile
+++ b/Examples/tcl/reference/Makefile
@@ -6,15 +6,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/reference/example.cxx b/Examples/tcl/reference/example.cxx
index 8a513bf..9dbaed2 100644
--- a/Examples/tcl/reference/example.cxx
+++ b/Examples/tcl/reference/example.cxx
@@ -19,7 +19,7 @@
 
 char *Vector::print() {
   static char temp[512];
-  sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z);
+  sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z);
   return temp;
 }
 
diff --git a/Examples/tcl/reference/example.h b/Examples/tcl/reference/example.h
index 4915adb..bcfcfb7 100644
--- a/Examples/tcl/reference/example.h
+++ b/Examples/tcl/reference/example.h
@@ -4,8 +4,8 @@
 private:
   double x,y,z;
 public:
-  Vector() : x(0), y(0), z(0) { };
-  Vector(double x, double y, double z) : x(x), y(y), z(z) { };
+  Vector() : x(0), y(0), z(0) { }
+  Vector(double x, double y, double z) : x(x), y(y), z(z) { }
   friend Vector operator+(const Vector &a, const Vector &b);
   char *print();
 };
@@ -20,7 +20,3 @@
   Vector &operator[](int);
   int size();
 };
-
-
-
-  
diff --git a/Examples/tcl/reference/example.i b/Examples/tcl/reference/example.i
index 6daa3b1..173143d 100644
--- a/Examples/tcl/reference/example.i
+++ b/Examples/tcl/reference/example.i
@@ -29,7 +29,7 @@
   VectorArray(int maxsize);
   ~VectorArray();
   int size();
-  
+
   /* This wrapper provides an alternative to the [] operator */
   %extend {
     Vector &get(int index) {
@@ -40,7 +40,3 @@
     }
   }
 };
-
-
-
-
diff --git a/Examples/tcl/simple/Makefile b/Examples/tcl/simple/Makefile
index 9190779..7155bf3 100644
--- a/Examples/tcl/simple/Makefile
+++ b/Examples/tcl/simple/Makefile
@@ -6,15 +6,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/std_vector/Makefile b/Examples/tcl/std_vector/Makefile
index a150fc9..f29f933 100644
--- a/Examples/tcl/std_vector/Makefile
+++ b/Examples/tcl/std_vector/Makefile
@@ -7,15 +7,15 @@
 LIBS       = -lm
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl_cpp
 
 static:
-	$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh_cpp_static
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/value/Makefile b/Examples/tcl/value/Makefile
index 9190779..7155bf3 100644
--- a/Examples/tcl/value/Makefile
+++ b/Examples/tcl/value/Makefile
@@ -6,15 +6,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/value/example.i b/Examples/tcl/value/example.i
index 98fd60e..39663c6 100644
--- a/Examples/tcl/value/example.i
+++ b/Examples/tcl/value/example.i
@@ -26,7 +26,7 @@
 }
 
 void vector_print(Vector *v) {
-  printf("Vector %p = (%g, %g, %g)\n", v, v->x, v->y, v->z);
+  printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z);
 }
 %}
 
diff --git a/Examples/tcl/variables/Makefile b/Examples/tcl/variables/Makefile
index 9190779..7155bf3 100644
--- a/Examples/tcl/variables/Makefile
+++ b/Examples/tcl/variables/Makefile
@@ -6,15 +6,15 @@
 INTERFACE  = example.i
 
 check: build
-	$(MAKE) -f $(TOP)/Makefile tcl_run
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_run
 
 build:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(DLTARGET)' INTERFACE='$(INTERFACE)' tcl
 
 static:
-	$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
 	TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tclsh
 
 clean:
-	$(MAKE) -f $(TOP)/Makefile tcl_clean
+	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' tcl_clean
diff --git a/Examples/tcl/variables/example.c b/Examples/tcl/variables/example.c
index 05e17c8..85685fe 100644
--- a/Examples/tcl/variables/example.c
+++ b/Examples/tcl/variables/example.c
@@ -52,9 +52,9 @@
   printf("cvar      = %c\n", cvar);
   printf("strvar    = %s\n", strvar ? strvar : "(null)");
   printf("cstrvar   = %s\n", cstrvar);
-  printf("iptrvar   = %p\n", iptrvar);
+  printf("iptrvar   = %p\n", (void *)iptrvar);
   printf("name      = %s\n", name);
-  printf("ptptr     = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+  printf("ptptr     = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
   printf("pt        = (%d, %d)\n", pt.x, pt.y);
   printf("status    = %d\n", status);
 }
diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in
index 5f75bfc..02ef8e3 100644
--- a/Examples/test-suite/allegrocl/Makefile.in
+++ b/Examples/test-suite/allegrocl/Makefile.in
@@ -5,6 +5,7 @@
 LANGUAGE     = allegrocl
 ALLEGROCL    = @ALLEGROCLBIN@
 SCRIPTSUFFIX = _runme.lisp
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -12,7 +13,7 @@
 
 # these cpp tests generate warnings/errors when compiling
 # the wrapper .cxx file.
-CPP_TEST_BROKEN_CXX = 
+CPP_TEST_BROKEN_CXX =
 # the error is wrap:action code generated by swig. \
 # error: can't convert [std::string] 'b' to 'bool' \
 # might just need a bool overload op for std::string. \
@@ -71,7 +72,7 @@
 	extern_throws \
 	throw_exception \
 	using_pointers \
-		
+
 C_TEST_CASES_ACL_BROKEN = \
 # 'cdate.i' module support \
 	li_cdata \
@@ -96,7 +97,7 @@
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -106,7 +107,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -114,13 +115,12 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.lisp appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 %.clean:
 	@rm -f $*.cl
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean
-
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" allegrocl_clean
diff --git a/Examples/test-suite/allowexcept.i b/Examples/test-suite/allowexcept.i
index 37b01cd..c901295 100644
--- a/Examples/test-suite/allowexcept.i
+++ b/Examples/test-suite/allowexcept.i
@@ -21,7 +21,7 @@
 %}
 
 
-// Now test the allowexcept feature by making the usual $action uncompileable and ensuring the %exception is picked up
+// Now test the allowexcept feature by making the usual $action uncompilable and ensuring the %exception is picked up
 
 struct XYZ {
 };
diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i
index 599a3f1..d858997 100644
--- a/Examples/test-suite/autodoc.i
+++ b/Examples/test-suite/autodoc.i
@@ -133,3 +133,11 @@
 void banana(S *a, const struct tagS *b, int c, Integer d) {}
 %}
 
+%inline %{
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
+  
diff --git a/Examples/test-suite/cffi/Makefile.in b/Examples/test-suite/cffi/Makefile.in
index aa8b40a..ee7e3f6 100644
--- a/Examples/test-suite/cffi/Makefile.in
+++ b/Examples/test-suite/cffi/Makefile.in
@@ -5,6 +5,7 @@
 LANGUAGE     = cffi
 CFFI         = @CFFIBIN@
 SCRIPTSUFFIX = _runme.lisp
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -14,13 +15,13 @@
 # Overridden variables here
 # no C++ tests for now
 CPP_TEST_CASES =
-#C_TEST_CASES += 
+#C_TEST_CASES +=
 
 # Custom tests - tests with additional commandline options
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -30,7 +31,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -38,14 +39,13 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.lisp appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFI) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean: (does nothing, we dont generate extra cffi code)
 %.clean:
-	
+	@exit 0
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile cffi_clean
-
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" cffi_clean
diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in
index 3c2f3de..31ab311 100644
--- a/Examples/test-suite/chicken/Makefile.in
+++ b/Examples/test-suite/chicken/Makefile.in
@@ -3,12 +3,14 @@
 #######################################################################
 
 LANGUAGE     = chicken
-VARIANT      = 
+VARIANT      =
 SCRIPTSUFFIX = _runme.ss
 PROXYSUFFIX  = _runme_proxy.ss
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
+
 CHICKEN_CSI  = @CHICKEN_CSI@ -quiet -batch -no-init
 SO           = @SO@
 
@@ -17,7 +19,7 @@
 # Skip the STD cases for now, except for li_std_string.i
 SKIP_CPP_STD_CASES = Yes
 
-CPP_TEST_CASES += li_std_string 
+CPP_TEST_CASES += li_std_string
 
 EXTRA_TEST_CASES += chicken_ext_test.externaltest
 
@@ -39,11 +41,11 @@
 %.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX)
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
 	  $(MAKE) $*.cppproxy; \
 	fi
 
@@ -51,15 +53,15 @@
 	$(setup)
 	+$(swig_and_compile_c)
 	$(run_testcase)
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
 	  $(MAKE) $*.cproxy; \
 	fi
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \
 	  $(MAKE) $*.multiproxy; \
 	fi
 
@@ -86,14 +88,14 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.scm appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean
 %.clean:
-	
+	@exit 0
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile chicken_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" chicken_clean
 	rm -f *.scm
diff --git a/Examples/test-suite/clisp/Makefile.in b/Examples/test-suite/clisp/Makefile.in
index 24655a6..6837ed6 100644
--- a/Examples/test-suite/clisp/Makefile.in
+++ b/Examples/test-suite/clisp/Makefile.in
@@ -5,6 +5,7 @@
 LANGUAGE     = clisp
 CLISP        = @CLISPBIN@
 SCRIPTSUFFIX = _runme.lisp
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -14,13 +15,13 @@
 # Overridden variables here
 # no C++ tests for now
 CPP_TEST_CASES =
-#C_TEST_CASES += 
+#C_TEST_CASES +=
 
 # Custom tests - tests with additional commandline options
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -30,7 +31,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -38,14 +39,13 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.lisp appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISP) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean: (does nothing, we dont generate extra clisp code)
 %.clean:
-	
+	@exit 0
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile clisp_clean
-
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" clisp_clean
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 2a45915..ac2dfd4 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -69,7 +69,13 @@
 LIBS       = -L.
 LIBPREFIX  = lib
 ACTION     = check
-INTERFACEDIR = $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/
+INTERFACEDIR = ../
+SRCDIR     = $(srcdir)/
+SCRIPTDIR  = $(srcdir)
+
+# Regenerate Makefile if Makefile.in or config.status have changed.
+Makefile: $(srcdir)/Makefile.in ../../../config.status
+	cd ../../../ && $(SHELL) ./config.status $(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE)/Makefile
 
 #
 # Please keep test cases in alphabetical order.
@@ -80,6 +86,7 @@
 CPP_TEST_BROKEN += \
 	constants \
 	cpp_broken \
+	director_nested_class \
 	exception_partial_info \
 	extend_variable \
 	li_std_vector_ptr \
@@ -136,6 +143,7 @@
 	class_scope_weird \
 	compactdefaultargs \
 	const_const_2 \
+	constant_directive \
 	constant_pointers \
 	constover \
 	constructor_copy \
@@ -166,6 +174,7 @@
 	director_abstract \
 	director_alternating \
 	director_basic \
+	director_property \
 	director_binary_string \
 	director_classes \
 	director_classic \
@@ -204,6 +213,7 @@
 	enum_template \
 	enum_thorough \
 	enum_var \
+	equality \
 	evil_diamond \
 	evil_diamond_ns \
 	evil_diamond_prop \
@@ -241,6 +251,7 @@
 	insert_directive \
 	keyword_rename \
 	kind \
+	kwargs_feature \
 	langobj \
 	li_attribute \
 	li_attribute_template \
@@ -288,6 +299,7 @@
 	nested_directors \
 	nested_comment \
 	nested_scope \
+	nested_template_base \
 	nested_workaround \
 	newobject1 \
 	null_pointer \
@@ -301,6 +313,7 @@
 	overload_extend \
 	overload_method \
 	overload_numeric \
+	overload_polymorphic \
 	overload_rename \
 	overload_return_type \
 	overload_simple \
@@ -371,6 +384,7 @@
 	template_classes \
 	template_const_ref \
 	template_construct \
+	template_templated_constructors \
 	template_default \
 	template_default2 \
 	template_default_arg \
@@ -409,7 +423,6 @@
 	template_partial_specialization \
 	template_partial_specialization_typedef \
 	template_qualifier \
-	template_qualifier \
 	template_ref_type \
 	template_rename \
 	template_retvalue \
@@ -468,6 +481,7 @@
 	typemap_various \
 	typename \
 	types_directive \
+	unicode_strings \
 	union_scope \
 	using1 \
 	using2 \
@@ -518,6 +532,7 @@
 	cpp11_rvalue_reference3 \
 	cpp11_sizeof_object \
 	cpp11_static_assert \
+	cpp11_strongly_typed_enumerations \
 	cpp11_thread_local \
 	cpp11_template_double_brackets \
 	cpp11_template_explicit \
@@ -530,7 +545,6 @@
 # Broken C++11 test cases.
 CPP11_TEST_BROKEN = \
 #	cpp11_hash_tables \           # not fully implemented yet
-#	cpp11_strongly_typed_enumerations \ # SWIG not quite getting this right yet in all langs
 #	cpp11_variadic_templates \    # Broken for some languages (such as Java)
 #	cpp11_reference_wrapper \     # No typemaps
 
@@ -602,6 +616,7 @@
 	memberin_extend_c \
 	name \
 	nested \
+	nested_extend_c \
 	nested_structs \
 	newobject2 \
 	overload_extend \
@@ -682,14 +697,14 @@
 	$(MAKE) check CC=true CXX=true LDSHARED=true CXXSHARED=true RUNTOOL=true COMPILETOOL=true
 
 swig_and_compile_cpp =  \
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
 	SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
 	INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
 	TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
 	$(LANGUAGE)$(VARIANT)_cpp
 
 swig_and_compile_c =  \
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CSRCS="$(CSRCS)" \
 	SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
 	INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
 	TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
@@ -697,7 +712,7 @@
 
 swig_and_compile_multi_cpp = \
 	for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
-	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
+	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
 	  SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
 	  INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
 	  TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
@@ -705,11 +720,11 @@
 	done
 
 swig_and_compile_external =  \
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" \
 	SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
 	TARGET="$*_wrap_hdr.h" \
 	$(LANGUAGE)$(VARIANT)_externalhdr; \
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS) $*_external.cxx" \
 	SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
 	INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
 	TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
@@ -718,7 +733,7 @@
 swig_and_compile_runtime = \
 
 setup = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then	  \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then	  \
 	  echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
 	else								  \
 	  echo "$(ACTION)ing $(LANGUAGE) testcase $*" ;		  \
diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i
new file mode 100644
index 0000000..8204720
--- /dev/null
+++ b/Examples/test-suite/constant_directive.i
@@ -0,0 +1,28 @@
+%module constant_directive
+
+// %constant and struct
+%{
+  struct Type1 {
+    Type1(int val = 0) : val(val) {} 
+    int val;
+  };
+  static Type1 TYPE1_CONSTANT1(1);
+  static Type1 TYPE1_CONST2(2);
+  static Type1 TYPE1_CONST3(3);
+%}
+
+struct Type1 {
+  Type1(int val = 0) : val(val) {} 
+  int val;
+};
+
+%inline %{
+Type1 getType1Instance() { return Type1(111); }
+%}
+
+%constant Type1 TYPE1_CONSTANT1;
+%constant Type1 TYPE1_CONSTANT2 = TYPE1_CONST2;
+%constant Type1 *TYPE1_CONSTANT3 = &TYPE1_CONST3;
+
+%constant int TYPE_INT = 0;
+
diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i
index 412b813..d91107c 100644
--- a/Examples/test-suite/cpp11_constexpr.i
+++ b/Examples/test-suite/cpp11_constexpr.i
@@ -18,6 +18,12 @@
   static const int LLL = 300;
   constexpr int MMM() { return 400; }
   constexpr const int NNN() { return 500; }
+  // Regression tests for support added in SWIG 3.0.4:
+  static constexpr const int JJJ1 = 101;
+  constexpr static int KKK1 = 201;
+  // Regression tests for https://github.com/swig/swig/issues/284 :
+  explicit constexpr ConstExpressions(int) { }
+  constexpr explicit ConstExpressions(double) { }
 };
 %}
 
diff --git a/Examples/test-suite/cpp11_function_objects.i b/Examples/test-suite/cpp11_function_objects.i
index fb75ede..e80f60a 100644
--- a/Examples/test-suite/cpp11_function_objects.i
+++ b/Examples/test-suite/cpp11_function_objects.i
@@ -3,25 +3,31 @@
    Function objects are objects which overload the operator() function.
    The std::function does not provide any seamless support in the target languages yet.
 */
-%module cpp11_function_objects
+%module(directors="1") cpp11_function_objects
 
 %rename(__call__) Test::operator();
 
+%feature("director") Test;
+
 %inline %{
-struct Test {
+class Test {
+public:
   int value;
   
-  void operator()(int x, int y) {
+  virtual void operator()(int x, int y) {
     value=x+y;
   }
   Test() : value(0) {}
-} test;
+  virtual ~Test() {}
+};
+
+Test test;
 
 #include <functional>
 std::function<void ( int, int )> pF = test;
 
-int testit1(Test new_test, int a, int b) {
-  pF = new_test;
+int testit1(Test &new_test, int a, int b) {
+  pF = std::ref(new_test);
   pF(a, b);
   return new_test.value;
 }
diff --git a/Examples/test-suite/cpp11_strongly_typed_enumerations.i b/Examples/test-suite/cpp11_strongly_typed_enumerations.i
index ed46636..3a4ee10 100644
--- a/Examples/test-suite/cpp11_strongly_typed_enumerations.i
+++ b/Examples/test-suite/cpp11_strongly_typed_enumerations.i
@@ -1,11 +1,9 @@
-/* This testcase checks whether SWIG produces the correct wrapper for the
-   strongly typed enums. Enums with the same type are comparable. Enum classes
-   require support for nested classes. */
+// This testcase checks whether SWIG produces the correct wrappers for strongly typed enums.
+
 %module cpp11_strongly_typed_enumerations
-%warnfilter(302) Val1;
-%warnfilter(302) Val2;
-%warnfilter(302) Val3;
-%warnfilter(302) Val4;
+
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Class1::Struct1;
+%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Class2::Struct1;
 
 /* Forward declarations (illegally accepted by SWIG - oh well!) */
 enum Enum1 : short;
@@ -17,15 +15,19 @@
 enum class Enum1 {
   Val1,
   Val2,
-  Val3 = 100,
-  Val4 /* = 101 */
+  Val3 = 13,
+  Val4,
+  Val5a = 13,
+  Val6a
 };
 
 enum class Enum2 : short {
   Val1,
   Val2,
-  Val3 = 100,
-  Val4
+  Val3 = 23,
+  Val4,
+  Val5b = 23,
+  Val6b
 };
 %}
 
@@ -39,24 +41,24 @@
 enum class Enum6 : unsigned int; // Legal C++11.
 
 enum Enum4 : unsigned int {
-  Val1, Val2, Val3 = 100, Val4
+  Val1, Val2, Val3 = 43, Val4
 };
 
 enum class Enum5 {
-  Val1, Val2, Val3 = 100, Val4
+  Val1, Val2, Val3 = 53, Val4
 };
 
 enum class Enum6 : unsigned int {
-  Val1, Val2, Val3 = 300, Val4
+  Val1, Val2, Val3 = 63, Val4
 };
 
 typedef enum class Enum7 : unsigned int {
-  Val1, Val2, Val3 = 300, Val4
+  Val1, Val2, Val3 = 73, Val4
 } Enum7td;
 
 // enum inherits from non-primitive type
 enum class Enum8 : size_t {
-  Val1, Val2, Val3 = 300, Val4
+  Val1, Val2, Val3 = 83, Val4
 };
 
 template <typename T> struct TType {
@@ -64,7 +66,7 @@
 };
 
 enum class Enum10 : TType<int>::type_name {
-  Val1, Val2, Val3 = 300, Val4
+  Val1, Val2, Val3 = 103, Val4
 };
 
 // forward declaration, no definition of enum
@@ -73,15 +75,144 @@
     Enum11 myenum11;
 };
 
-/*
-TODO
-enum class MyClass {AAA, BBB, CCC};
-namespace Space {
-enum MyEnum {XXX, YYY, ZZZ};
-}
-struct SSS {
-  MyClass m;
+class Class1
+{
+public:
+  enum class Enum12
+  {
+    Val1 = 1121,
+    Val2 = 1122,
+    Val3,
+    Val4,
+    Val5c = 1121,
+    Val6c
+  };
+
+  enum Enum13
+  {
+    Val1 = 1131,
+    Val2 = 1132,
+    Val3,
+    Val4,
+    Val5d = 1131,
+    Val6d
+  };
+
+  enum class Enum14
+  {
+    Val1 = 1141,
+    Val2 = 1142,
+    Val3,
+    Val4,
+    Val5e = 1141,
+    Val6e
+  };
+
+  struct Struct1
+  {
+    enum class Enum12
+    {
+      Val1 = 3121,
+      Val2 = 3122,
+      Val3,
+      Val4,
+      Val5f = 3121,
+      Val6f
+    };
+
+    enum Enum13
+    {
+      Val1 = 3131,
+      Val2 = 3132,
+      Val3,
+      Val4,
+    };
+
+    enum class Enum14
+    {
+      Val1 = 3141,
+      Val2 = 3142,
+      Val3,
+      Val4,
+      Val5g = 3141,
+      Val6g
+    };
+  };
+  Enum1 class1Test1(Enum1 e) { return e; }
+  Enum12 class1Test2(Enum12 e) { return e; }
+  Struct1::Enum12 class1Test3(Struct1::Enum12 e) { return e; }
 };
-*/
+
+class Class2
+{
+public:
+  enum class Enum12
+  {
+    Val1 = 2121,
+    Val2 = 2122,
+    Val3,
+    Val4,
+    Val5h = 2121,
+    Val6h
+  };
+
+  enum Enum13
+  {
+    Val1 = 2131,
+    Val2 = 2132,
+    Val3,
+    Val4,
+    Val5i = 2131,
+    Val6i
+  };
+
+  enum class Enum14
+  {
+    Val1 = 2141,
+    Val2 = 2142,
+    Val3,
+    Val4,
+    Val5j = 2141,
+    Val6j
+  };
+
+  struct Struct1
+  {
+    enum class Enum12
+    {
+      Val1 = 4121,
+      Val2 = 4122,
+      Val3,
+      Val4,
+      Val5k = 4121,
+      Val6k
+    };
+
+    enum Enum13
+    {
+      Val1 = 4131,
+      Val2 = 4132,
+      Val3,
+      Val4,
+      Val5l = 4131,
+      Val6l
+    };
+
+    enum class Enum14
+    {
+      Val1 = 4141,
+      Val2 = 4142,
+      Val3,
+      Val4,
+      Val5m = 4141,
+      Val6m
+    };
+  };
+};
+
+Enum1 globalTest1(Enum1 e) { return e; }
+Class1::Enum12 globalTest2(Class1::Enum12 e) { return e; }
+Class1::Struct1::Enum12 globalTest3(Class1::Struct1::Enum12 e) { return e; }
+
 %}
 
diff --git a/Examples/test-suite/cpp11_strongly_typed_enumerations_simple.i b/Examples/test-suite/cpp11_strongly_typed_enumerations_simple.i
new file mode 100644
index 0000000..3848d29
--- /dev/null
+++ b/Examples/test-suite/cpp11_strongly_typed_enumerations_simple.i
@@ -0,0 +1,5 @@
+%module cpp11_strongly_typed_enumerations_simple
+
+%include <enumsimple.swg>
+
+%include "cpp11_strongly_typed_enumerations.i"
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index 993699b..292c751 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -8,6 +8,7 @@
 CSHARPCILINTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
 CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
 CSHARPCYGPATH_W     = @CSHARPCYGPATH_W@
+
 srcdir       = @srcdir@
 top_srcdir   = ../@top_srcdir@
 top_builddir = ../@top_builddir@
@@ -27,9 +28,13 @@
 	intermediary_classname \
 	li_boost_intrusive_ptr
 
+CPP11_TEST_CASES = \
+	cpp11_strongly_typed_enumerations_simple \
+
 include $(srcdir)/../common.mk
 
 # Overridden variables here
+SRCDIR       = ../$(srcdir)/
 SWIGOPT += -namespace $*Namespace
 
 CSHARPFLAGSSPECIAL =
@@ -40,7 +45,7 @@
 csharp_swig2_compatibility.cpptest: SWIGOPT += -DSWIG2_CSHARP
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+(cd $* && $(swig_and_compile_cpp))
 	+$(run_testcase)
@@ -50,14 +55,14 @@
 	+(cd $* && $(swig_and_compile_c))
 	+$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+(cd $* && $(swig_and_compile_multi_cpp))
 	+$(run_testcase)
 
 # Makes a directory for the testcase if it does not exist
 setup = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then	  \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then	  \
 	  echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
 	else								  \
 	  echo "$(ACTION)ing $(LANGUAGE) testcase $*" ;		  \
@@ -71,10 +76,10 @@
 # Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
 # DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
 	  $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
 	  CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
-	  CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
+	  CSHARPSRCS='`$(CSHARPCYGPATH_W) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
 	  env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$*_runme.exe; \
 	else \
 	  cd $* && \
diff --git a/Examples/test-suite/csharp/cpp11_strongly_typed_enumerations_runme.cs b/Examples/test-suite/csharp/cpp11_strongly_typed_enumerations_runme.cs
new file mode 100644
index 0000000..f2c25e7
--- /dev/null
+++ b/Examples/test-suite/csharp/cpp11_strongly_typed_enumerations_runme.cs
@@ -0,0 +1,169 @@
+using System;
+using cpp11_strongly_typed_enumerationsNamespace;
+
+public class cpp11_strongly_typed_enumerations_runme {
+
+  public static int enumCheck(int actual, int expected) {
+    if (actual != expected)
+      throw new ApplicationException("Enum value mismatch. Expected " + expected + " Actual: " + actual);
+    return expected + 1;
+  }
+
+  public static void Main() {
+    int val = 0;
+    val = enumCheck((int)Enum1.Val1, val);
+    val = enumCheck((int)Enum1.Val2, val);
+    val = enumCheck((int)Enum1.Val3, 13);
+    val = enumCheck((int)Enum1.Val4, val);
+    val = enumCheck((int)Enum1.Val5a, 13);
+    val = enumCheck((int)Enum1.Val6a, val);
+
+    val = 0;
+    val = enumCheck((int)Enum2.Val1, val);
+    val = enumCheck((int)Enum2.Val2, val);
+    val = enumCheck((int)Enum2.Val3, 23);
+    val = enumCheck((int)Enum2.Val4, val);
+    val = enumCheck((int)Enum2.Val5b, 23);
+    val = enumCheck((int)Enum2.Val6b, val);
+
+    val = 0;
+    val = enumCheck((int)Enum4.Val1, val);
+    val = enumCheck((int)Enum4.Val2, val);
+    val = enumCheck((int)Enum4.Val3, 43);
+    val = enumCheck((int)Enum4.Val4, val);
+
+    val = 0;
+    val = enumCheck((int)Enum5.Val1, val);
+    val = enumCheck((int)Enum5.Val2, val);
+    val = enumCheck((int)Enum5.Val3, 53);
+    val = enumCheck((int)Enum5.Val4, val);
+
+    val = 0;
+    val = enumCheck((int)Enum6.Val1, val);
+    val = enumCheck((int)Enum6.Val2, val);
+    val = enumCheck((int)Enum6.Val3, 63);
+    val = enumCheck((int)Enum6.Val4, val);
+
+    val = 0;
+    val = enumCheck((int)Enum7td.Val1, val);
+    val = enumCheck((int)Enum7td.Val2, val);
+    val = enumCheck((int)Enum7td.Val3, 73);
+    val = enumCheck((int)Enum7td.Val4, val);
+
+    val = 0;
+    val = enumCheck((int)Enum8.Val1, val);
+    val = enumCheck((int)Enum8.Val2, val);
+    val = enumCheck((int)Enum8.Val3, 83);
+    val = enumCheck((int)Enum8.Val4, val);
+
+    val = 0;
+    val = enumCheck((int)Enum10.Val1, val);
+    val = enumCheck((int)Enum10.Val2, val);
+    val = enumCheck((int)Enum10.Val3, 103);
+    val = enumCheck((int)Enum10.Val4, val);
+
+    val = 0;
+    val = enumCheck((int)Class1.Enum12.Val1, 1121);
+    val = enumCheck((int)Class1.Enum12.Val2, 1122);
+    val = enumCheck((int)Class1.Enum12.Val3, val);
+    val = enumCheck((int)Class1.Enum12.Val4, val);
+    val = enumCheck((int)Class1.Enum12.Val5c, 1121);
+    val = enumCheck((int)Class1.Enum12.Val6c, val);
+
+    val = 0;
+    val = enumCheck((int)Class1.Enum13.Val1, 1131);
+    val = enumCheck((int)Class1.Enum13.Val2, 1132);
+    val = enumCheck((int)Class1.Enum13.Val3, val);
+    val = enumCheck((int)Class1.Enum13.Val4, val);
+    val = enumCheck((int)Class1.Enum13.Val5d, 1131);
+    val = enumCheck((int)Class1.Enum13.Val6d, val);
+
+    val = 0;
+    val = enumCheck((int)Class1.Enum14.Val1, 1141);
+    val = enumCheck((int)Class1.Enum14.Val2, 1142);
+    val = enumCheck((int)Class1.Enum14.Val3, val);
+    val = enumCheck((int)Class1.Enum14.Val4, val);
+    val = enumCheck((int)Class1.Enum14.Val5e, 1141);
+    val = enumCheck((int)Class1.Enum14.Val6e, val);
+
+    val = 0;
+    val = enumCheck((int)Class1.Struct1.Enum12.Val1, 3121);
+    val = enumCheck((int)Class1.Struct1.Enum12.Val2, 3122);
+    val = enumCheck((int)Class1.Struct1.Enum12.Val3, val);
+    val = enumCheck((int)Class1.Struct1.Enum12.Val4, val);
+    val = enumCheck((int)Class1.Struct1.Enum12.Val5f, 3121);
+    val = enumCheck((int)Class1.Struct1.Enum12.Val6f, val);
+
+    val = 0;
+    val = enumCheck((int)Class1.Struct1.Enum13.Val1, 3131);
+    val = enumCheck((int)Class1.Struct1.Enum13.Val2, 3132);
+    val = enumCheck((int)Class1.Struct1.Enum13.Val3, val);
+    val = enumCheck((int)Class1.Struct1.Enum13.Val4, val);
+
+    val = 0;
+    val = enumCheck((int)Class1.Struct1.Enum14.Val1, 3141);
+    val = enumCheck((int)Class1.Struct1.Enum14.Val2, 3142);
+    val = enumCheck((int)Class1.Struct1.Enum14.Val3, val);
+    val = enumCheck((int)Class1.Struct1.Enum14.Val4, val);
+    val = enumCheck((int)Class1.Struct1.Enum14.Val5g, 3141);
+    val = enumCheck((int)Class1.Struct1.Enum14.Val6g, val);
+
+    val = 0;
+    val = enumCheck((int)Class2.Enum12.Val1, 2121);
+    val = enumCheck((int)Class2.Enum12.Val2, 2122);
+    val = enumCheck((int)Class2.Enum12.Val3, val);
+    val = enumCheck((int)Class2.Enum12.Val4, val);
+    val = enumCheck((int)Class2.Enum12.Val5h, 2121);
+    val = enumCheck((int)Class2.Enum12.Val6h, val);
+
+    val = 0;
+    val = enumCheck((int)Class2.Enum13.Val1, 2131);
+    val = enumCheck((int)Class2.Enum13.Val2, 2132);
+    val = enumCheck((int)Class2.Enum13.Val3, val);
+    val = enumCheck((int)Class2.Enum13.Val4, val);
+    val = enumCheck((int)Class2.Enum13.Val5i, 2131);
+    val = enumCheck((int)Class2.Enum13.Val6i, val);
+
+    val = 0;
+    val = enumCheck((int)Class2.Enum14.Val1, 2141);
+    val = enumCheck((int)Class2.Enum14.Val2, 2142);
+    val = enumCheck((int)Class2.Enum14.Val3, val);
+    val = enumCheck((int)Class2.Enum14.Val4, val);
+    val = enumCheck((int)Class2.Enum14.Val5j, 2141);
+    val = enumCheck((int)Class2.Enum14.Val6j, val);
+
+    val = 0;
+    val = enumCheck((int)Class2.Struct1.Enum12.Val1, 4121);
+    val = enumCheck((int)Class2.Struct1.Enum12.Val2, 4122);
+    val = enumCheck((int)Class2.Struct1.Enum12.Val3, val);
+    val = enumCheck((int)Class2.Struct1.Enum12.Val4, val);
+    val = enumCheck((int)Class2.Struct1.Enum12.Val5k, 4121);
+    val = enumCheck((int)Class2.Struct1.Enum12.Val6k, val);
+
+    val = 0;
+    val = enumCheck((int)Class2.Struct1.Enum13.Val1, 4131);
+    val = enumCheck((int)Class2.Struct1.Enum13.Val2, 4132);
+    val = enumCheck((int)Class2.Struct1.Enum13.Val3, val);
+    val = enumCheck((int)Class2.Struct1.Enum13.Val4, val);
+    val = enumCheck((int)Class2.Struct1.Enum13.Val5l, 4131);
+    val = enumCheck((int)Class2.Struct1.Enum13.Val6l, val);
+
+    val = 0;
+    val = enumCheck((int)Class2.Struct1.Enum14.Val1, 4141);
+    val = enumCheck((int)Class2.Struct1.Enum14.Val2, 4142);
+    val = enumCheck((int)Class2.Struct1.Enum14.Val3, val);
+    val = enumCheck((int)Class2.Struct1.Enum14.Val4, val);
+    val = enumCheck((int)Class2.Struct1.Enum14.Val5m, 4141);
+    val = enumCheck((int)Class2.Struct1.Enum14.Val6m, val);
+
+    Class1 class1 = new Class1();
+    enumCheck((int)class1.class1Test1(Enum1.Val5a), 13);
+    enumCheck((int)class1.class1Test2(Class1.Enum12.Val5c), 1121);
+    enumCheck((int)class1.class1Test3(Class1.Struct1.Enum12.Val5f), 3121);
+
+    enumCheck((int)cpp11_strongly_typed_enumerations.globalTest1(Enum1.Val5a), 13);
+    enumCheck((int)cpp11_strongly_typed_enumerations.globalTest2(Class1.Enum12.Val5c), 1121);
+    enumCheck((int)cpp11_strongly_typed_enumerations.globalTest3(Class1.Struct1.Enum12.Val5f), 3121);
+  }
+}
+
diff --git a/Examples/test-suite/csharp/csharp_exceptions_runme.cs b/Examples/test-suite/csharp/csharp_exceptions_runme.cs
index 43585b1..51805ce 100644
--- a/Examples/test-suite/csharp/csharp_exceptions_runme.cs
+++ b/Examples/test-suite/csharp/csharp_exceptions_runme.cs
@@ -323,7 +323,9 @@
          } catch (ArgumentOutOfRangeException e) {
            String expectedMessage = "caught:" + i + "\n" + "Parameter name: input";
            if (e.Message.Replace(runme.CRLF,"\n") != expectedMessage)
-             throw new Exception("Exception message incorrect. Expected:\n[" + expectedMessage + "]\n" + "Received:\n[" + e.Message + "]");
+             throw new Exception("Exception message incorrect. Expected:\n[" + 
+                 expectedMessage + "]\n" + "Received:\n[" + 
+                 e.Message + "]");
            if (e.ParamName != "input")
              throw new Exception("Exception ParamName incorrect. Expected:\n[input]\n" + "Received:\n[" + e.ParamName + "]");
            if (e.InnerException != null)
@@ -333,7 +335,7 @@
            throw new Exception("throwsException.dub = " + throwsClass.dub + " expected: 1234.5678");
        }
      } catch (Exception e) {
-       Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message);
+       Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message + "\n  TestThread Inner stack trace: " + e.StackTrace);
        Failed = true;
      }
    }
diff --git a/Examples/test-suite/d/Makefile.in b/Examples/test-suite/d/Makefile.in
index 61c2749..3333df1 100644
--- a/Examples/test-suite/d/Makefile.in
+++ b/Examples/test-suite/d/Makefile.in
@@ -3,17 +3,22 @@
 #######################################################################
 
 LANGUAGE     = d
+
 srcdir       = @srcdir@
 top_srcdir   = ../@top_srcdir@
 top_builddir = ../@top_builddir@
 
+ifeq (,$(D_VERSION))
+  D_VERSION = @DDEFAULTVERSION@
+endif
+
 ifeq (2,$(D_VERSION))
   VERSIONSUFFIX = .2
 else
   VERSIONSUFFIX = .1
 endif
 
-TESTSUFFIX = _runme$(VERSIONSUFFIX).d
+SCRIPTSUFFIX = _runme$(VERSIONSUFFIX).d
 
 CPP_TEST_CASES = \
 	d_nativepointers \
@@ -21,10 +26,9 @@
 
 include $(srcdir)/../common.mk
 
-# Override some variables from common.mk:
-
+# Overridden variables here
+SRCDIR       = ../$(srcdir)/
 TARGETSUFFIX = _wrap
-
 SWIGOPT+=-splitproxy -package $*
 
 # Rules for the different types of tests
@@ -45,7 +49,7 @@
 
 # Makes a directory for the testcase if it does not exist
 setup = \
-	if [ -f $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then			\
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then			\
 	  echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ;	\
 	else									\
 	  echo "$(ACTION)ing $(LANGUAGE) testcase $*" ;			\
@@ -60,11 +64,11 @@
 # Compiles D files then runs the testcase. A testcase is only run if
 # a file is found which has _runme.d appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
 	  cd $*$(VERSIONSUFFIX) && \
 	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
 	  DFLAGS='-of$*_runme' \
-	  DSRCS='../$(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) `find $* -name *.d`' d_compile && \
+	  DSRCS='../$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) `find $* -name *.d`' d_compile && \
 	  env LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" $(RUNTOOL) ./$*_runme; \
 	else \
 	  cd $*$(VERSIONSUFFIX) && \
diff --git a/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d b/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d
index 0027aad..0289295 100644
--- a/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d
+++ b/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d
@@ -2,6 +2,7 @@
 
 import core.memory;
 import core.thread;
+import core.time;
 import std.conv;
 import std.exception;
 import std.stdio;
@@ -31,15 +32,6 @@
   if (TRACE)
     writeln("---> NEARLY FINISHED <---");
 
-  // Try to get the GC to collect everything not referenced anymore.
-  int countdown = 100;
-  while (--countdown) {
-    GC.collect();
-    if (Klass.getTotal_count() == 1)
-      break;
-    Thread.sleep(100);
-  }
-
   // A single remaining instance expected: the global variable (GlobalValue).
   if (Klass.getTotal_count() != 1)
     throw new Exception("Klass.total_count=" ~ to!string(Klass.getTotal_count()));
@@ -55,9 +47,15 @@
 }
 
 void runTest() {
+  // We want to check whether all the C++ Klass instances have been properly
+  // destructed after the tests have run. However, as it is legal for the GC
+  // to leave an object around even if it is unreachable, use deterministic
+  // memory management here.
+  import std.typecons : scoped;
+
   // simple shared_ptr usage - created in C++
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     string val = k.getValue();
     verifyValue("me oh my", val);
     verifyCount(1, k);
@@ -73,7 +71,7 @@
 
   // pass by shared_ptr
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = smartpointertest(k);
     string val = kret.getValue();
     verifyValue("me oh my smartpointertest", val);
@@ -83,7 +81,7 @@
 
   // pass by shared_ptr pointer
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = smartpointerpointertest(k);
     string val = kret.getValue();
     verifyValue("me oh my smartpointerpointertest", val);
@@ -93,7 +91,7 @@
 
   // pass by shared_ptr reference
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = smartpointerreftest(k);
     string val = kret.getValue();
     verifyValue("me oh my smartpointerreftest", val);
@@ -103,7 +101,7 @@
 
   // pass by shared_ptr pointer reference
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = smartpointerpointerreftest(k);
     string val = kret.getValue();
     verifyValue("me oh my smartpointerpointerreftest", val);
@@ -113,7 +111,7 @@
 
   // const pass by shared_ptr
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = constsmartpointertest(k);
     string val = kret.getValue();
     verifyValue("me oh my", val);
@@ -123,7 +121,7 @@
 
   // const pass by shared_ptr pointer
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = constsmartpointerpointertest(k);
     string val = kret.getValue();
     verifyValue("me oh my", val);
@@ -133,7 +131,7 @@
 
   // const pass by shared_ptr reference
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = constsmartpointerreftest(k);
     string val = kret.getValue();
     verifyValue("me oh my", val);
@@ -143,7 +141,7 @@
 
   // pass by value
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = valuetest(k);
     string val = kret.getValue();
     verifyValue("me oh my valuetest", val);
@@ -153,7 +151,7 @@
 
   // pass by pointer
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = pointertest(k);
     string val = kret.getValue();
     verifyValue("me oh my pointertest", val);
@@ -163,7 +161,7 @@
 
   // pass by reference
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = reftest(k);
     string val = kret.getValue();
     verifyValue("me oh my reftest", val);
@@ -173,7 +171,7 @@
 
   // pass by pointer reference
   {
-    auto k = new Klass("me oh my");
+    auto k = scoped!Klass("me oh my");
     auto kret = pointerreftest(k);
     string val = kret.getValue();
     verifyValue("me oh my pointerreftest", val);
@@ -215,7 +213,7 @@
   ////////////////////////////////// Derived classes ////////////////////////////////////////
   // derived pass by shared_ptr
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = derivedsmartptrtest(k);
     string val = kret.getValue();
     verifyValue("me oh my derivedsmartptrtest-Derived", val);
@@ -224,7 +222,7 @@
   }
   // derived pass by shared_ptr pointer
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = derivedsmartptrpointertest(k);
     string val = kret.getValue();
     verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
@@ -233,7 +231,7 @@
   }
   // derived pass by shared_ptr ref
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = derivedsmartptrreftest(k);
     string val = kret.getValue();
     verifyValue("me oh my derivedsmartptrreftest-Derived", val);
@@ -242,7 +240,7 @@
   }
   // derived pass by shared_ptr pointer ref
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = derivedsmartptrpointerreftest(k);
     string val = kret.getValue();
     verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
@@ -251,7 +249,7 @@
   }
   // derived pass by pointer
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = derivedpointertest(k);
     string val = kret.getValue();
     verifyValue("me oh my derivedpointertest-Derived", val);
@@ -260,7 +258,7 @@
   }
   // derived pass by ref
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = derivedreftest(k);
     string val = kret.getValue();
     verifyValue("me oh my derivedreftest-Derived", val);
@@ -271,7 +269,7 @@
   ////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
   // pass by shared_ptr (mixed)
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = smartpointertest(k);
     string val = kret.getValue();
     verifyValue("me oh my smartpointertest-Derived", val);
@@ -281,7 +279,7 @@
 
   // pass by shared_ptr pointer (mixed)
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = smartpointerpointertest(k);
     string val = kret.getValue();
     verifyValue("me oh my smartpointerpointertest-Derived", val);
@@ -291,7 +289,7 @@
 
   // pass by shared_ptr reference (mixed)
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = smartpointerreftest(k);
     string val = kret.getValue();
     verifyValue("me oh my smartpointerreftest-Derived", val);
@@ -301,7 +299,7 @@
 
   // pass by shared_ptr pointer reference (mixed)
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = smartpointerpointerreftest(k);
     string val = kret.getValue();
     verifyValue("me oh my smartpointerpointerreftest-Derived", val);
@@ -311,7 +309,7 @@
 
   // pass by value (mixed)
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = valuetest(k);
     string val = kret.getValue();
     verifyValue("me oh my valuetest", val); // note slicing
@@ -321,7 +319,7 @@
 
   // pass by pointer (mixed)
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = pointertest(k);
     string val = kret.getValue();
     verifyValue("me oh my pointertest-Derived", val);
@@ -331,7 +329,7 @@
 
   // pass by ref (mixed)
   {
-    auto k = new KlassDerived("me oh my");
+    auto k = scoped!KlassDerived("me oh my");
     auto kret = reftest(k);
     string val = kret.getValue();
     verifyValue("me oh my reftest-Derived", val);
@@ -341,7 +339,7 @@
 
   // 3rd derived class
   {
-    auto k = new Klass3rdDerived("me oh my");
+    auto k = scoped!Klass3rdDerived("me oh my");
     string val = k.getValue();
     verifyValue("me oh my-3rdDerived", val);
     verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
@@ -353,128 +351,140 @@
   ////////////////////////////////// Member variables ////////////////////////////////////////
   // smart pointer by value
   {
-    auto m = new MemberVariables();
-    auto k = new Klass("smart member value");
-    m.SmartMemberValue = k;
-    string val = k.getValue();
-    verifyValue("smart member value", val);
-    verifyCount(2, k);
+    auto k = scoped!Klass("smart member value");
+    Klass kmember;
 
-    auto kmember = m.SmartMemberValue;
-    val = kmember.getValue();
-    verifyValue("smart member value", val);
-    verifyCount(3, kmember);
-    verifyCount(3, k);
+    {
+      auto m = scoped!MemberVariables();
+      m.SmartMemberValue = k;
+      string val = k.getValue();
+      verifyValue("smart member value", val);
+      verifyCount(2, k);
 
-    delete m;
+      kmember = m.SmartMemberValue;
+      val = kmember.getValue();
+      verifyValue("smart member value", val);
+      verifyCount(3, kmember);
+      verifyCount(3, k);
+    }
 
     verifyCount(2, kmember);
     verifyCount(2, k);
   }
   // smart pointer by pointer
   {
-    auto m = new MemberVariables();
-    auto k = new Klass("smart member pointer");
-    m.SmartMemberPointer = k;
-    string val = k.getValue();
-    verifyValue("smart member pointer", val);
-    verifyCount(1, k);
+    auto k = scoped!Klass("smart member pointer");
+    Klass kmember;
 
-    auto kmember = m.SmartMemberPointer;
-    val = kmember.getValue();
-    verifyValue("smart member pointer", val);
-    verifyCount(2, kmember);
-    verifyCount(2, k);
+    {
+      auto m = scoped!MemberVariables();
+      m.SmartMemberPointer = k;
+      string val = k.getValue();
+      verifyValue("smart member pointer", val);
+      verifyCount(1, k);
 
-    delete m;
+      kmember = m.SmartMemberPointer;
+      val = kmember.getValue();
+      verifyValue("smart member pointer", val);
+      verifyCount(2, kmember);
+      verifyCount(2, k);
+    }
 
     verifyCount(2, kmember);
     verifyCount(2, k);
   }
   // smart pointer by reference
   {
-    auto m = new MemberVariables();
-    auto k = new Klass("smart member reference");
-    m.SmartMemberReference = k;
-    string val = k.getValue();
-    verifyValue("smart member reference", val);
-    verifyCount(2, k);
+    auto k = scoped!Klass("smart member reference");
+    Klass kmember;
 
-    auto kmember = m.SmartMemberReference;
-    val = kmember.getValue();
-    verifyValue("smart member reference", val);
-    verifyCount(3, kmember);
-    verifyCount(3, k);
+    {
+      auto m = scoped!MemberVariables();
+      m.SmartMemberReference = k;
+      string val = k.getValue();
+      verifyValue("smart member reference", val);
+      verifyCount(2, k);
 
-    // The C++ reference refers to SmartMemberValue...
-    auto kmemberVal = m.SmartMemberValue;
-    val = kmember.getValue();
-    verifyValue("smart member reference", val);
-    verifyCount(4, kmemberVal);
-    verifyCount(4, kmember);
-    verifyCount(4, k);
+      kmember = m.SmartMemberReference;
+      val = kmember.getValue();
+      verifyValue("smart member reference", val);
+      verifyCount(3, kmember);
+      verifyCount(3, k);
 
-    delete m;
+      // The C++ reference refers to SmartMemberValue...
+      auto kmemberVal = m.SmartMemberValue;
+      val = kmember.getValue();
+      verifyValue("smart member reference", val);
+      verifyCount(4, kmemberVal);
+      verifyCount(4, kmember);
+      verifyCount(4, k);
+    }
 
     verifyCount(3, kmember);
     verifyCount(3, k);
   }
   // plain by value
   {
-    auto m = new MemberVariables();
-    auto k = new Klass("plain member value");
-    m.MemberValue = k;
-    string val = k.getValue();
-    verifyValue("plain member value", val);
-    verifyCount(1, k);
+    auto k = scoped!Klass("plain member value");
+    Klass kmember;
 
-    auto kmember = m.MemberValue;
-    val = kmember.getValue();
-    verifyValue("plain member value", val);
-    verifyCount(1, kmember);
-    verifyCount(1, k);
+    {
+      auto m = scoped!MemberVariables();
+      m.MemberValue = k;
+      string val = k.getValue();
+      verifyValue("plain member value", val);
+      verifyCount(1, k);
 
-    delete m;
+      kmember = m.MemberValue;
+      val = kmember.getValue();
+      verifyValue("plain member value", val);
+      verifyCount(1, kmember);
+      verifyCount(1, k);
+    }
 
     verifyCount(1, kmember);
     verifyCount(1, k);
   }
   // plain by pointer
   {
-    auto m = new MemberVariables();
-    auto k = new Klass("plain member pointer");
-    m.MemberPointer = k;
-    string val = k.getValue();
-    verifyValue("plain member pointer", val);
-    verifyCount(1, k);
+    auto k = scoped!Klass("plain member pointer");
+    Klass kmember;
 
-    auto kmember = m.MemberPointer;
-    val = kmember.getValue();
-    verifyValue("plain member pointer", val);
-    verifyCount(1, kmember);
-    verifyCount(1, k);
+    {
+      auto m = scoped!MemberVariables();
+      m.MemberPointer = k;
+      string val = k.getValue();
+      verifyValue("plain member pointer", val);
+      verifyCount(1, k);
 
-    delete m;
+      kmember = m.MemberPointer;
+      val = kmember.getValue();
+      verifyValue("plain member pointer", val);
+      verifyCount(1, kmember);
+      verifyCount(1, k);
+    }
 
     verifyCount(1, kmember);
     verifyCount(1, k);
   }
   // plain by reference
   {
-    auto m = new MemberVariables();
-    auto k = new Klass("plain member reference");
-    m.MemberReference = k;
-    string val = k.getValue();
-    verifyValue("plain member reference", val);
-    verifyCount(1, k);
+    auto k = scoped!Klass("plain member reference");
+    Klass kmember;
 
-    auto kmember = m.MemberReference;
-    val = kmember.getValue();
-    verifyValue("plain member reference", val);
-    verifyCount(1, kmember);
-    verifyCount(1, k);
+    {
+      auto m = scoped!MemberVariables();
+      m.MemberReference = k;
+      string val = k.getValue();
+      verifyValue("plain member reference", val);
+      verifyCount(1, k);
 
-    delete m;
+      kmember = m.MemberReference;
+      val = kmember.getValue();
+      verifyValue("plain member reference", val);
+      verifyCount(1, kmember);
+      verifyCount(1, k);
+    }
 
     verifyCount(1, kmember);
     verifyCount(1, k);
@@ -482,7 +492,7 @@
 
   // null member variables
   {
-    auto m = new MemberVariables();
+    auto m = scoped!MemberVariables();
 
     // shared_ptr by value
     auto k = m.SmartMemberValue;
@@ -504,7 +514,7 @@
     auto kglobal = GlobalSmartValue;
     enforce(kglobal is null, "expected null");
 
-    auto k = new Klass("smart global value");
+    auto k = scoped!Klass("smart global value");
     GlobalSmartValue = k;
     verifyCount(2, k);
 
@@ -520,7 +530,7 @@
   {
     Klass kglobal;
 
-    auto k = new Klass("global value");
+    auto k = scoped!Klass("global value");
     GlobalValue = k;
     verifyCount(1, k);
 
@@ -538,7 +548,7 @@
     auto kglobal = GlobalPointer;
     enforce(kglobal is null, "expected null");
 
-    auto k = new Klass("global pointer");
+    auto k = scoped!Klass("global pointer");
     GlobalPointer = k;
     verifyCount(1, k);
 
@@ -553,7 +563,7 @@
   {
     Klass kglobal;
 
-    auto k = new Klass("global reference");
+    auto k = scoped!Klass("global reference");
     GlobalReference = k;
     verifyCount(1, k);
 
diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i
index 839d28e..bcb8766 100644
--- a/Examples/test-suite/default_args.i
+++ b/Examples/test-suite/default_args.i
@@ -13,6 +13,27 @@
 %inline %{
   #include <string>
 
+  // All kinds of numbers: hex, octal (which pose special problems to Python), negative...
+  void trickyvalue1(int first, int pos = -1) {}
+  void trickyvalue2(int first, unsigned rgb = 0xabcdef) {}
+  void trickyvalue3(int first, int mode = 0644) {}
+
+  void doublevalue1(int first, double num = 0.0e-1) {}
+  void doublevalue2(int first, double num = -0.0E2) {}
+
+  // Long long arguments are not handled at Python level currently but still work.
+  void seek(long long offset = 0LL) {}
+  void seek2(unsigned long long offset = 0ULL) {}
+  void seek3(long offset = 0L) {}
+  void seek4(unsigned long offset = 0UL) {}
+  void seek5(unsigned long offset = 0U) {}
+  void seek6(unsigned long offset = 02U) {}
+  void seek7(unsigned long offset = 00U) {}
+  void seek8(unsigned long offset = 1U) {}
+  void seek9(long offset = 1L) {}
+  void seekA(long long offset = 1LL) {}
+  void seekB(unsigned long long offset = 1ULL) {}
+
   // Anonymous arguments
   int anonymous(int = 7771);
   int anonymous(int x) { return x; }
@@ -29,6 +50,12 @@
       bool blah(speed s = FAST, flavor f = SWEET) { return (s == FAST && f == SWEET); };
   };
 
+  // using base class enum in a derived class
+  class DerivedEnumClass : public EnumClass {
+  public:
+    void accelerate(speed s = SLOW) { }
+  };
+
   // casts
   const char * casts1(const char *m = (const char *) NULL) {
     char *ret = NULL; 
@@ -199,6 +226,7 @@
 struct Klass {
   int val;
   Klass(int val = -1) : val(val) {}
+  static Klass inc(int n = 1, const Klass& k = Klass()) { return Klass(k.val + n); }
 };
 Klass constructorcall(const Klass& k = Klass()) { return k; }
 
diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i
index 091adff..f7fc8cf 100644
--- a/Examples/test-suite/default_constructor.i
+++ b/Examples/test-suite/default_constructor.i
@@ -168,5 +168,11 @@
   } 
 };
 
-
+%inline %{
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
   
diff --git a/Examples/test-suite/director_abstract.i b/Examples/test-suite/director_abstract.i
index cc9dca5..7dfcc89 100644
--- a/Examples/test-suite/director_abstract.i
+++ b/Examples/test-suite/director_abstract.i
@@ -156,7 +156,7 @@
   class Example3
   {
   protected:
-    /* the default constructor is always emitter, even when protected,
+    /* the default constructor is always emitted, even when protected,
         having another public constructor, and 'dirprot' is not used.
         This is just for Java compatibility */
     Example3()
diff --git a/Examples/test-suite/director_exception.i b/Examples/test-suite/director_exception.i
index 3fd3e56..2559ae5 100644
--- a/Examples/test-suite/director_exception.i
+++ b/Examples/test-suite/director_exception.i
@@ -1,5 +1,7 @@
 %module(directors="1") director_exception
 
+%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) return_const_char_star;
+
 %{
 
 #if defined(_MSC_VER)
@@ -106,7 +108,7 @@
 %}
 
 %feature("director") Bar;
-
+%feature("director") ReturnAllTypes;
 
 %inline %{
   struct Exception1
@@ -132,4 +134,28 @@
     virtual std::string pang() throw () { return "Bar::pang()"; }
   };
   
+  // Class to allow regression testing SWIG/PHP not checking if an exception
+  // had been thrown in directorout typemaps.
+  class ReturnAllTypes
+  {
+  public:
+    int call_int() { return return_int(); }
+    double call_double() { return return_double(); }
+    const char * call_const_char_star() { return return_const_char_star(); }
+    std::string call_std_string() { return return_std_string(); }
+    Bar call_Bar() { return return_Bar(); }
+
+    virtual int return_int() { return 0; }
+    virtual double return_double() { return 0.0; }
+    virtual const char * return_const_char_star() { return ""; }
+    virtual std::string return_std_string() { return std::string(); }
+    virtual Bar return_Bar() { return Bar(); }
+    virtual ~ReturnAllTypes() {}
+  };
+
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
 %}
diff --git a/Examples/test-suite/director_keywords.i b/Examples/test-suite/director_keywords.i
index 473786c..53f36a8 100644
--- a/Examples/test-suite/director_keywords.i
+++ b/Examples/test-suite/director_keywords.i
@@ -1,13 +1,16 @@
 // Checks if collisions of argument names with target language keywords are
-// resolved properly when directors are used (currently only »abstract« for
-// C#, D and Java is checked).
+// resolved properly when directors are used
 %module(directors="1") director_keywords
 
+%warnfilter(SWIGWARN_PARSE_KEYWORD);
+
 %feature("director") Foo;
 
 %inline %{
 struct Foo {
   virtual ~Foo() {}
-  virtual void bar(int abstract) {}
+  virtual void check_abstract(int abstract) {} // for Java, C#, D...
+  virtual void check_self(int self) {} // self for Python
+  virtual void check_from(int from) {} // for Python
 };
 %}
diff --git a/Examples/test-suite/director_nested_class.i b/Examples/test-suite/director_nested_class.i
new file mode 100644
index 0000000..f3d627f
--- /dev/null
+++ b/Examples/test-suite/director_nested_class.i
@@ -0,0 +1,25 @@
+%module(directors="1") director_nested_class
+
+
+%feature("director") DirectorOuter::DirectorInner;
+%feature("director") DirectorOuter::DirectorInner::DirectorInnerInner;
+
+%inline %{
+struct DirectorOuter {
+  struct DirectorInner {
+    virtual ~DirectorInner() {}
+    virtual int vmethod(int input) const = 0;
+    struct DirectorInnerInner {
+      DirectorInnerInner(DirectorInner *din = 0) {}
+      virtual ~DirectorInnerInner() {}
+      virtual int innervmethod(int input) const = 0;
+    };
+  };
+  static int callMethod(const DirectorInner &di, int value) {
+    return di.vmethod(value);
+  } 
+  static int callInnerInnerMethod(const DirectorInner::DirectorInnerInner &di, int value) {
+    return di.innervmethod(value);
+  } 
+};
+%}
diff --git a/Examples/test-suite/director_nestedmodule.i b/Examples/test-suite/director_nestedmodule.i
new file mode 100644
index 0000000..4e30434
--- /dev/null
+++ b/Examples/test-suite/director_nestedmodule.i
@@ -0,0 +1,29 @@
+%module(directors="1") "director::nestedmodule"
+
+%{
+#include <string>
+
+class Foo {
+  public:
+    virtual ~Foo() {}
+    virtual std::string ping() { return "Foo::ping()"; }
+    virtual std::string pong() { return "Foo::pong();" + ping(); }
+
+    static Foo* get_self(Foo *slf) {return slf;}
+};
+
+%}
+
+%include <std_string.i>
+
+%feature("director") Foo;
+
+
+class Foo {
+  public:
+    virtual ~Foo();
+    virtual std::string ping();
+    virtual std::string pong();
+
+    static Foo* get_self(Foo *slf);
+};
diff --git a/Examples/test-suite/director_property.i b/Examples/test-suite/director_property.i
new file mode 100644
index 0000000..3363c3c
--- /dev/null
+++ b/Examples/test-suite/director_property.i
@@ -0,0 +1,151 @@
+%module(directors="1") director_property
+
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod;
+
+%{
+ #include <string>
+
+ class Foo {
+ private:
+   std::string a;
+ public:
+   virtual ~Foo() {}
+   virtual std::string ping() { return "Foo::ping()"; }
+   virtual std::string pong() { return "Foo::pong();" + ping(); }
+   virtual std::string getA() { return this->a; }
+   virtual void setA(std::string a) { this->a = a; }
+
+   static Foo* get_self(Foo *slf) {return slf;}
+   
+ };
+
+ %}
+
+ %include <std_string.i>
+
+ %feature("director") Foo;
+
+
+ class Foo {
+ public:
+   virtual ~Foo();
+   virtual std::string ping();
+   virtual std::string pong();
+   virtual std::string getA();
+   virtual void setA(std::string a);
+   
+   static Foo* get_self(Foo *slf);
+   
+ };
+
+ %{
+ #include <complex> 
+ %}
+ %feature("director") A;
+
+ // basic renaming
+ %rename(rg) A::gg;
+ %feature("nodirector") hi::A1::gg;
+
+ %inline %{
+
+ struct A{
+     A(std::complex<int> i, double d=0.0) {}
+     A(int i, bool j=false) {}
+     virtual ~A() {}
+
+     virtual int f(int i=0) {return i;}
+     virtual int gg(int i=0) {return i;}
+ };
+
+ namespace hi  {
+
+   struct A1 : public A {
+     A1(std::complex<int> i, double d=0.0) : A(i, d) {}
+     A1(int i, bool j=false) : A(i, j) {}
+
+     virtual int ff(int i = 0) {return i;}  
+   };
+ }
+
+
+ %}
+
+
+ %feature("director") MyClass;
+
+ %inline %{
+
+ typedef void VoidType;
+
+  struct Bar
+  {
+    int x;
+    Bar(int _x = 0) : x(_x)
+    {
+    }
+ };
+ 
+ 
+
+class MyClass {
+public:
+  MyClass(int a = 0) 
+  {
+  }
+  
+  virtual void method(VoidType *)
+  {
+  }
+  
+  virtual ~MyClass()
+  {
+  }
+
+  virtual Bar vmethod(Bar b)
+  {
+    b.x += 13;
+    return b;
+  }  
+
+  virtual Bar* pmethod(Bar *b)
+  {
+    b->x += 12;
+    return b;
+  }  
+
+  Bar cmethod(const Bar &b)
+  {
+    return vmethod(b);
+  }  
+
+  static MyClass *get_self(MyClass *c) 
+  {
+    return c;
+  }
+
+  static Bar * call_pmethod(MyClass *myclass, Bar *b) {
+    return myclass->pmethod(b);
+  }
+};
+
+template<class T>
+class MyClassT {
+public:
+  MyClassT(int a = 0) 
+  {
+  }
+  
+  virtual void method(VoidType *)
+  {
+  }
+  
+  virtual ~MyClassT()
+  {
+  }
+  
+};
+
+%}
+
+%template(MyClassT_i) MyClassT<int>;
diff --git a/Examples/test-suite/enum_rename.i b/Examples/test-suite/enum_rename.i
index 0cab4d0..23e100d 100644
--- a/Examples/test-suite/enum_rename.i
+++ b/Examples/test-suite/enum_rename.i
@@ -2,7 +2,7 @@
 
 %warnfilter(SWIGWARN_PARSE_REDEFINED) S_May;
 
-// %rename using regex can do the equivalent of these two renames, which was resulting in uncompileable code
+// %rename using regex can do the equivalent of these two renames, which was resulting in uncompilable code
 %rename(May) M_May;
 %rename(May) S_May;
 
diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i
index ec31c27..3ece547 100644
--- a/Examples/test-suite/enum_thorough.i
+++ b/Examples/test-suite/enum_thorough.i
@@ -277,6 +277,18 @@
 OldNameStruct::singlename           renameTest7(OldNameStruct::singlename e) { return e; }
 %}
 
+%rename(Clash1_di1) Clash1::di1;
+%rename(Clash1_di2) Clash1::di2;
+%rename(Clash1_di3) Clash1::di3;
+%inline %{
+namespace Clash1 {
+  enum DuplicateItems1 { di1, di2 = 10, di3 };
+}
+namespace Clash2 {
+  enum DuplicateItems2 { di1, di2 = 10, di3 };
+}
+%}
+
 %inline %{
 struct TreesClass {
   enum trees {oak, fir, pine };
diff --git a/Examples/test-suite/equality.i b/Examples/test-suite/equality.i
new file mode 100644
index 0000000..cdabc48
--- /dev/null
+++ b/Examples/test-suite/equality.i
@@ -0,0 +1,69 @@
+/* File : equality.i */
+/*
+ Specific test for operator== overload. Partially overlaps with
+ operator_overload.i
+*/
+
+%module equality
+
+%warnfilter(SWIGWARN_LANG_IDENTIFIER) operator==;
+
+%inline %{
+
+/* Point has no equality operator */
+typedef struct Point
+{
+  double x;
+  double y;
+} Point;
+
+static const Point s_zeroPoint = { 0.0, 0.0 };
+/* stack version */
+Point MakePoint(double x, double y) 
+  { Point new_point = {x, y}; return new_point; }
+
+const Point* GetZeroPointPtr() { return &s_zeroPoint; }
+Point GetZeroPointCopy() { return s_zeroPoint; }
+
+/* EqualOpDefined has correct equality operator */
+class EqualOpDefined {
+public:
+  EqualOpDefined():
+    x(5) {}
+  EqualOpDefined(int val):
+    x(val) {}
+
+  int x;
+};
+
+/* EqualOpWrong has logically incorrect equality operator */
+class EqualOpWrong {
+public:
+  inline static const EqualOpWrong* GetStaticObject();
+};
+ 
+static EqualOpWrong s_wrongEqOp;
+
+const EqualOpWrong* EqualOpWrong::GetStaticObject()
+  { return &s_wrongEqOp; }
+
+
+inline bool operator==( const EqualOpDefined& first, const EqualOpDefined& second )
+  { return first.x == second.x; }
+
+inline bool operator==( const EqualOpWrong& first, const EqualOpWrong& second )
+  { return false; }
+
+%}
+
+/* 
+  in order to wrapper this correctly
+  we need to extend the class
+  to make the friends & non members part of the class
+*/
+%extend EqualOpDefined {
+	bool operator==(const EqualOpDefined& b){return (*$self) == b;}
+}
+%extend EqualOpWrong {
+	bool operator==(const EqualOpWrong& b){return (*$self) == b;}
+}
diff --git a/Examples/test-suite/errors/.gitignore b/Examples/test-suite/errors/.gitignore
new file mode 100644
index 0000000..22ca119
--- /dev/null
+++ b/Examples/test-suite/errors/.gitignore
@@ -0,0 +1,4 @@
+*.newerr
+cpp_recursive_typedef.py
+cpp_shared_ptr.py
+xxx.py
diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in
index 601dcd3..4c61001 100644
--- a/Examples/test-suite/errors/Makefile.in
+++ b/Examples/test-suite/errors/Makefile.in
@@ -13,42 +13,44 @@
 # file (.stderr) in addition to the test case itself.
 #######################################################################
 
-LANGUAGE     = python
+LANGUAGE     = errors
 ERROR_EXT    = newerr
-# Portable dos2unix / todos for stripping CR
-TODOS        = tr -d '\r'
-#TODOS        = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//'
 
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
 
 # All .i files with prefix 'cpp_' will be treated as C++ input and remaining .i files as C input
-ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(wildcard *.i))
+ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i)))
 CPP_ERROR_TEST_CASES := $(filter cpp_%, $(ALL_ERROR_TEST_CASES))
 C_ERROR_TEST_CASES := $(filter-out $(CPP_ERROR_TEST_CASES), $(ALL_ERROR_TEST_CASES))
 
 ERROR_TEST_CASES := $(CPP_ERROR_TEST_CASES:=.cpptest) \
-	            $(C_ERROR_TEST_CASES:=.ctest)
+		    $(C_ERROR_TEST_CASES:=.ctest)
 
 include $(srcdir)/../common.mk
 
+# Portable dos2unix / todos for stripping CR
+TODOS        = tr -d '\r'
+#TODOS        = sed -e 's/\r$$//' # On OSX behaves as if written 's/r$$//'
+
+# strip source directory from output, so that diffs compare
+STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||'
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	echo "$(ACTION)ing errors testcase $*"
-	-$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $*.i 2>&1 | $(TODOS) > $*.$(ERROR_EXT)
-	$(COMPILETOOL) diff -c $*.stderr $*.$(ERROR_EXT)
+	-$(SWIG) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
+	$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
 
 %.ctest:
 	echo "$(ACTION)ing errors testcase $*"
-	-$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $*.i 2>&1 | $(TODOS) > $*.$(ERROR_EXT)
-	$(COMPILETOOL) diff -c $*.stderr $*.$(ERROR_EXT)
+	-$(SWIG) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT)
+	$(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT)
 
 %.clean:
-	
+	@exit 0
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile $(LANGUAGE)_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean
 	@rm -f *.$(ERROR_EXT) *.py
-
diff --git a/Examples/test-suite/errors/c_extra_rblock.stderr b/Examples/test-suite/errors/c_extra_rblock.stderr
index 8287702..be14eee 100644
--- a/Examples/test-suite/errors/c_extra_rblock.stderr
+++ b/Examples/test-suite/errors/c_extra_rblock.stderr
@@ -1 +1 @@
-c_extra_rblock.i:5: Error: Syntax error in input(1).
+c_extra_rblock.i:5: Error: Syntax error. Extraneous '%}'
diff --git a/Examples/test-suite/errors/c_missing_semi.stderr b/Examples/test-suite/errors/c_missing_semi.stderr
index 791b959..18befaa 100644
--- a/Examples/test-suite/errors/c_missing_semi.stderr
+++ b/Examples/test-suite/errors/c_missing_semi.stderr
@@ -1 +1 @@
-c_missing_semi.i:3: Error: Syntax error in input(1).
+c_missing_semi.i:3: Error: Syntax error - possibly a missing semicolon.
diff --git a/Examples/test-suite/errors/cpp_extra_brackets.stderr b/Examples/test-suite/errors/cpp_extra_brackets.stderr
index 12bb1f3..f1fabc7 100644
--- a/Examples/test-suite/errors/cpp_extra_brackets.stderr
+++ b/Examples/test-suite/errors/cpp_extra_brackets.stderr
@@ -1 +1 @@
-cpp_extra_brackets.i:5: Error: Syntax error in input(3).
+cpp_extra_brackets.i:5: Error: Unexpected ')'.
diff --git a/Examples/test-suite/errors/pp_constant.i b/Examples/test-suite/errors/pp_constant.i
index 2be108e..c29f4c8 100644
--- a/Examples/test-suite/errors/pp_constant.i
+++ b/Examples/test-suite/errors/pp_constant.i
@@ -29,7 +29,9 @@
 %constant int ddd=;
 
 #define E1 1234
-#/*C comment*/define E2 1234
+// This case doesn't actually work, but appeared to before we gave an error
+// for unknown preprocessor directives.
+// #/*C comment*/define E2 1234
 #define E3 1234
 
 %constant int eee=;
diff --git a/Examples/test-suite/errors/pp_constant.stderr b/Examples/test-suite/errors/pp_constant.stderr
index 9c79ec2..54a87ed 100644
--- a/Examples/test-suite/errors/pp_constant.stderr
+++ b/Examples/test-suite/errors/pp_constant.stderr
@@ -2,7 +2,7 @@
 pp_constant.i:15: Warning 305: Bad constant value (ignored).
 pp_constant.i:23: Warning 305: Bad constant value (ignored).
 pp_constant.i:29: Warning 305: Bad constant value (ignored).
-pp_constant.i:35: Warning 305: Bad constant value (ignored).
-pp_constant.i:42: Warning 305: Bad constant value (ignored).
-pp_constant.i:46: Warning 305: Bad constant value (ignored).
-pp_constant.i:49: Warning 305: Bad constant value (ignored).
+pp_constant.i:37: Warning 305: Bad constant value (ignored).
+pp_constant.i:44: Warning 305: Bad constant value (ignored).
+pp_constant.i:48: Warning 305: Bad constant value (ignored).
+pp_constant.i:51: Warning 305: Bad constant value (ignored).
diff --git a/Examples/test-suite/errors/pp_missing_enddef.stderr b/Examples/test-suite/errors/pp_missing_enddef.stderr
index bb4ea3c..c461699 100644
--- a/Examples/test-suite/errors/pp_missing_enddef.stderr
+++ b/Examples/test-suite/errors/pp_missing_enddef.stderr
@@ -1 +1 @@
-pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3
+pp_missing_enddef.i:3: Error: Missing %enddef for macro starting here
diff --git a/Examples/test-suite/errors/pp_missing_endif.stderr b/Examples/test-suite/errors/pp_missing_endif.stderr
index 0bbfad7..4db4021 100644
--- a/Examples/test-suite/errors/pp_missing_endif.stderr
+++ b/Examples/test-suite/errors/pp_missing_endif.stderr
@@ -1 +1 @@
-pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3
+pp_missing_endif.i:3: Error: Missing #endif for conditional starting here
diff --git a/Examples/test-suite/errors/pp_missing_endoffile.i b/Examples/test-suite/errors/pp_missing_endoffile.i
new file mode 100644
index 0000000..2074495
--- /dev/null
+++ b/Examples/test-suite/errors/pp_missing_endoffile.i
@@ -0,0 +1,7 @@
+%module xxx
+/* %beginfile and %endoffile are internal directives inserted when %include is
+ * used.  Users should never use them directly, but test coverage for this
+ * error message still seems useful to have.
+ */
+%includefile "dummy.i" %beginfile
+
diff --git a/Examples/test-suite/errors/pp_missing_endoffile.stderr b/Examples/test-suite/errors/pp_missing_endoffile.stderr
new file mode 100644
index 0000000..7269f2e
--- /dev/null
+++ b/Examples/test-suite/errors/pp_missing_endoffile.stderr
@@ -0,0 +1 @@
+pp_missing_endoffile.i:6: Error: Missing %endoffile for file inclusion block starting here
diff --git a/Examples/test-suite/errors/pp_missing_rblock.stderr b/Examples/test-suite/errors/pp_missing_rblock.stderr
index 8f4a54c..f00457d 100644
--- a/Examples/test-suite/errors/pp_missing_rblock.stderr
+++ b/Examples/test-suite/errors/pp_missing_rblock.stderr
@@ -1 +1 @@
-pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3
+pp_missing_rblock.i:3: Error: Unterminated %{ ... %} block
diff --git a/Examples/test-suite/errors/pp_unknowndirective.i b/Examples/test-suite/errors/pp_unknowndirective.i
new file mode 100644
index 0000000..659a997
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective.i
@@ -0,0 +1,7 @@
+%module xxx
+
+/* This used to give the rather cryptic "Syntax error in input(1)." prior to
+ * SWIG 3.0.4.  This testcase checks that the improved message is actually
+ * issued.
+ */
+%remane("typo") tyop;
diff --git a/Examples/test-suite/errors/pp_unknowndirective.stderr b/Examples/test-suite/errors/pp_unknowndirective.stderr
new file mode 100644
index 0000000..d0d5e24
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective.stderr
@@ -0,0 +1 @@
+pp_unknowndirective.i:7: Error: Unknown directive '%remane'.
diff --git a/Examples/test-suite/errors/pp_unknowndirective2.i b/Examples/test-suite/errors/pp_unknowndirective2.i
new file mode 100644
index 0000000..889e6c5
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective2.i
@@ -0,0 +1,11 @@
+%module xxx
+
+#ifdef FOO
+long long i;
+/* Check we get an error for an unknown directive (this should be #elif).
+ * Unknown directives were silently ignored by SWIG < 3.0.3. */
+#elsif defined(BAR)
+long i;
+#else
+int i;
+#endif
diff --git a/Examples/test-suite/errors/pp_unknowndirective2.stderr b/Examples/test-suite/errors/pp_unknowndirective2.stderr
new file mode 100644
index 0000000..70afa67
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective2.stderr
@@ -0,0 +1 @@
+pp_unknowndirective2.i:7: Error: Unknown SWIG preprocessor directive: elsif (if this is a block of target language code, delimit it with %{ and %})
diff --git a/Examples/test-suite/errors/pp_unterm_char.stderr b/Examples/test-suite/errors/pp_unterm_char.stderr
index 4386e93..147e385 100644
--- a/Examples/test-suite/errors/pp_unterm_char.stderr
+++ b/Examples/test-suite/errors/pp_unterm_char.stderr
@@ -1 +1 @@
-pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4
+pp_unterm_char.i:4: Error: Unterminated character constant
diff --git a/Examples/test-suite/errors/pp_unterm_comment.stderr b/Examples/test-suite/errors/pp_unterm_comment.stderr
index 4ff3423..ab1edac 100644
--- a/Examples/test-suite/errors/pp_unterm_comment.stderr
+++ b/Examples/test-suite/errors/pp_unterm_comment.stderr
@@ -1 +1 @@
-pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3
+pp_unterm_comment.i:3: Error: Unterminated comment
diff --git a/Examples/test-suite/errors/pp_unterm_string.stderr b/Examples/test-suite/errors/pp_unterm_string.stderr
index 16b4034..14e110e 100644
--- a/Examples/test-suite/errors/pp_unterm_string.stderr
+++ b/Examples/test-suite/errors/pp_unterm_string.stderr
@@ -1 +1 @@
-pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4
+pp_unterm_string.i:4: Error: Unterminated string constant
diff --git a/Examples/test-suite/errors/pp_unterminated_block.i b/Examples/test-suite/errors/pp_unterminated_block.i
new file mode 100644
index 0000000..99f5f0b
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unterminated_block.i
@@ -0,0 +1,5 @@
+%module xxx
+
+%{
+int foo(int x);
+
diff --git a/Examples/test-suite/errors/pp_unterminated_block.stderr b/Examples/test-suite/errors/pp_unterminated_block.stderr
new file mode 100644
index 0000000..03c16a4
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unterminated_block.stderr
@@ -0,0 +1 @@
+pp_unterminated_block.i:3: Error: Unterminated %{ ... %} block
diff --git a/Examples/test-suite/exception_order.i b/Examples/test-suite/exception_order.i
index 4dd1385..bca745c 100644
--- a/Examples/test-suite/exception_order.i
+++ b/Examples/test-suite/exception_order.i
@@ -125,6 +125,13 @@
     }
   };
   int A::sfoovar = 1;
+
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+
 %}
 
 %template(ET_i) ET<int>;
diff --git a/Examples/test-suite/exception_partial_info.i b/Examples/test-suite/exception_partial_info.i
index 37b87ef..47b0467 100644
--- a/Examples/test-suite/exception_partial_info.i
+++ b/Examples/test-suite/exception_partial_info.i
@@ -1,6 +1,6 @@
 %module exception_partial_info
 
-// This produced compileable code for Tcl, Python in 1.3.27, fails in 1.3.29
+// This produced compilable code for Tcl, Python in 1.3.27, fails in 1.3.29
 
 %{
 #if defined(_MSC_VER)
diff --git a/Examples/test-suite/extend_default.i b/Examples/test-suite/extend_default.i
index 097b533..d4a015f 100644
--- a/Examples/test-suite/extend_default.i
+++ b/Examples/test-suite/extend_default.i
@@ -93,7 +93,7 @@
 // %extend overrides the class definition
 %extend Override {
   int over(int a) { return a*a; } // SWIG should give a warning then choose this one over the real one
-  int overload(int a) { return a*a; } // Similarly, but this one generated uncompileable code in SWIG-1.3.22
+  int overload(int a) { return a*a; } // Similarly, but this one generated uncompilable code in SWIG-1.3.22
 }
 %inline %{
 struct Override {
diff --git a/Examples/test-suite/extend_special_variables.i b/Examples/test-suite/extend_special_variables.i
index dd68e75..1f218a8 100644
--- a/Examples/test-suite/extend_special_variables.i
+++ b/Examples/test-suite/extend_special_variables.i
@@ -19,3 +19,19 @@
 struct ForExtension {
 };
 %}
+
+%inline %{
+namespace Space {
+  template <class T> class ExtendTemplate {};
+}
+%}
+
+%extend Space::ExtendTemplate
+{
+ void extending() {
+   $parentclassname tmp;
+   (void)tmp;
+  }
+}
+
+%template(ExtendTemplateInt) Space::ExtendTemplate<int>;
diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in
index 535d05a..4480ecf 100644
--- a/Examples/test-suite/go/Makefile.in
+++ b/Examples/test-suite/go/Makefile.in
@@ -24,12 +24,16 @@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
 
+CPP_TEST_CASES = \
+	go_inout \
+	go_director_inout
+
 include $(srcdir)/../common.mk
 
 .SUFFIXES: .cpptest .ctest .multicpptest
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase_cpp)
@@ -39,7 +43,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_multi_testcase)
@@ -47,7 +51,7 @@
 multi_import.multicpptest:
 	$(setup)
 	for f in multi_import_b multi_import_a; do \
-	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
+	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" CXXSRCS="$(CXXSRCS)" \
 	  SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
 	  INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
 	  TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
@@ -57,8 +61,8 @@
 
 # Runs the testcase.
 run_testcase = \
-	if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
-	  $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
+	if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
+	  $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
 	  if $(GOGCC) ; then \
 	    $(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*_wrap.@OBJEXT@; \
 	  elif $(GO12) || $(GO13); then \
@@ -70,8 +74,8 @@
 	fi
 
 run_testcase_cpp = \
-	if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
-	  $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
+	if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
+	  $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
 	  if $(GOGCC) ; then \
 	    $(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*_wrap.@OBJEXT@ -lstdc++; \
 	  elif $(GO12) || $(GO13); then \
@@ -83,8 +87,8 @@
 	fi
 
 run_multi_testcase = \
-	if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
-	  $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
+	if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
+	  $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
 	  if $(GOGCC) ; then \
 	    files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
 	    $(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $${f}_wrap.@OBJEXT@; done` -lstdc++; \
@@ -100,11 +104,12 @@
 	@rm -f $*.go $*_gc.c $*_wrap.* $*_runme
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile go_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" go_clean
 	rm -f mod_a.go mod_b.go imports_a.go imports_b.go
 	rm -f clientdata_prop_a.go clientdata_prop_b.go
 	rm -f multi_import_a.go multi_import_b.go
 	rm -f packageoption_a.go packageoption_b.go packageoption_c.go
+	rm -f import_stl_a.go import_stl_b.go
 
 cvsignore:
 	@echo '*_gc.c *_wrap.* *.so *.dll *.exp *.lib'
diff --git a/Examples/test-suite/go/argout_runme.go b/Examples/test-suite/go/argout_runme.go
new file mode 100644
index 0000000..5f7017e
--- /dev/null
+++ b/Examples/test-suite/go/argout_runme.go
@@ -0,0 +1,41 @@
+package main
+
+import wrap "./argout"
+
+func main() {
+	ip := wrap.New_intp()
+	wrap.Intp_assign(ip, 42)
+	if r := wrap.Incp(ip); r != 42 {
+		panic(r)
+	}
+	if r := wrap.Intp_value(ip); r != 43 {
+		panic(r)
+	}
+
+	p := wrap.New_intp()
+	wrap.Intp_assign(p, 2)
+	if r := wrap.Incp(p); r != 2 {
+		panic(r)
+	}
+	if r := wrap.Intp_value(p); r != 3 {
+		panic(r)
+	}
+
+	r := wrap.New_intp()
+	wrap.Intp_assign(r, 7)
+	if r := wrap.Incr(r); r != 7 {
+		panic(r)
+	}
+	if r := wrap.Intp_value(r); r != 8 {
+		panic(r)
+	}
+
+	tr := wrap.New_intp()
+	wrap.Intp_assign(tr, 4)
+	if r := wrap.Inctr(tr); r != 4 {
+		panic(r)
+	}
+	if r := wrap.Intp_value(tr); r != 5 {
+		panic(r)
+	}
+}
diff --git a/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go b/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go
new file mode 100644
index 0000000..f4b84b1
--- /dev/null
+++ b/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go
@@ -0,0 +1,171 @@
+package main
+
+import "fmt"
+import . "./cpp11_strongly_typed_enumerations"
+
+func enumCheck(actual int, expected int) int {
+	if actual != expected {
+		panic(fmt.Sprintf("Enum value mismatch. Expected: %d Actual: %d", expected, actual))
+	}
+	return expected + 1
+}
+
+func main() {
+	var val = 0
+	val = enumCheck(int(Enum1_Val1), val)
+	val = enumCheck(int(Enum1_Val2), val)
+	val = enumCheck(int(Enum1_Val3), 13)
+	val = enumCheck(int(Enum1_Val4), val)
+	val = enumCheck(int(Enum1_Val5a), 13)
+	val = enumCheck(int(Enum1_Val6a), val)
+
+	val = 0
+	val = enumCheck(int(Enum2_Val1), val)
+	val = enumCheck(int(Enum2_Val2), val)
+	val = enumCheck(int(Enum2_Val3), 23)
+	val = enumCheck(int(Enum2_Val4), val)
+	val = enumCheck(int(Enum2_Val5b), 23)
+	val = enumCheck(int(Enum2_Val6b), val)
+
+	val = 0
+	val = enumCheck(int(Val1), val)
+	val = enumCheck(int(Val2), val)
+	val = enumCheck(int(Val3), 43)
+	val = enumCheck(int(Val4), val)
+
+	val = 0
+	val = enumCheck(int(Enum5_Val1), val)
+	val = enumCheck(int(Enum5_Val2), val)
+	val = enumCheck(int(Enum5_Val3), 53)
+	val = enumCheck(int(Enum5_Val4), val)
+
+	val = 0
+	val = enumCheck(int(Enum6_Val1), val)
+	val = enumCheck(int(Enum6_Val2), val)
+	val = enumCheck(int(Enum6_Val3), 63)
+	val = enumCheck(int(Enum6_Val4), val)
+
+	val = 0
+	val = enumCheck(int(Enum7td_Val1), val)
+	val = enumCheck(int(Enum7td_Val2), val)
+	val = enumCheck(int(Enum7td_Val3), 73)
+	val = enumCheck(int(Enum7td_Val4), val)
+
+	val = 0
+	val = enumCheck(int(Enum8_Val1), val)
+	val = enumCheck(int(Enum8_Val2), val)
+	val = enumCheck(int(Enum8_Val3), 83)
+	val = enumCheck(int(Enum8_Val4), val)
+
+	val = 0
+	val = enumCheck(int(Enum10_Val1), val)
+	val = enumCheck(int(Enum10_Val2), val)
+	val = enumCheck(int(Enum10_Val3), 103)
+	val = enumCheck(int(Enum10_Val4), val)
+
+	val = 0
+	val = enumCheck(int(Class1Enum12_Val1), 1121)
+	val = enumCheck(int(Class1Enum12_Val2), 1122)
+	val = enumCheck(int(Class1Enum12_Val3), val)
+	val = enumCheck(int(Class1Enum12_Val4), val)
+	val = enumCheck(int(Class1Enum12_Val5c), 1121)
+	val = enumCheck(int(Class1Enum12_Val6c), val)
+
+	val = 0
+	val = enumCheck(int(Class1Val1), 1131)
+	val = enumCheck(int(Class1Val2), 1132)
+	val = enumCheck(int(Class1Val3), val)
+	val = enumCheck(int(Class1Val4), val)
+	val = enumCheck(int(Class1Val5d), 1131)
+	val = enumCheck(int(Class1Val6d), val)
+
+	val = 0
+	val = enumCheck(int(Class1Enum14_Val1), 1141)
+	val = enumCheck(int(Class1Enum14_Val2), 1142)
+	val = enumCheck(int(Class1Enum14_Val3), val)
+	val = enumCheck(int(Class1Enum14_Val4), val)
+	val = enumCheck(int(Class1Enum14_Val5e), 1141)
+	val = enumCheck(int(Class1Enum14_Val6e), val)
+
+	// Requires nested class support to work
+	//val = 0
+	//val = enumCheck(int(Class1Struct1Enum12_Val1), 3121)
+	//val = enumCheck(int(Class1Struct1Enum12_Val2), 3122)
+	//val = enumCheck(int(Class1Struct1Enum12_Val3), val)
+	//val = enumCheck(int(Class1Struct1Enum12_Val4), val)
+	//val = enumCheck(int(Class1Struct1Enum12_Val5f), 3121)
+	//val = enumCheck(int(Class1Struct1Enum12_Val6f), val)
+	//
+	//val = 0
+	//val = enumCheck(int(Class1Struct1Val1), 3131)
+	//val = enumCheck(int(Class1Struct1Val2), 3132)
+	//val = enumCheck(int(Class1Struct1Val3), val)
+	//val = enumCheck(int(Class1Struct1Val4), val)
+	//
+	//val = 0
+	//val = enumCheck(int(Class1Struct1Enum14_Val1), 3141)
+	//val = enumCheck(int(Class1Struct1Enum14_Val2), 3142)
+	//val = enumCheck(int(Class1Struct1Enum14_Val3), val)
+	//val = enumCheck(int(Class1Struct1Enum14_Val4), val)
+	//val = enumCheck(int(Class1Struct1Enum14_Val5g), 3141)
+	//val = enumCheck(int(Class1Struct1Enum14_Val6g), val)
+
+	val = 0
+	val = enumCheck(int(Class2Enum12_Val1), 2121)
+	val = enumCheck(int(Class2Enum12_Val2), 2122)
+	val = enumCheck(int(Class2Enum12_Val3), val)
+	val = enumCheck(int(Class2Enum12_Val4), val)
+	val = enumCheck(int(Class2Enum12_Val5h), 2121)
+	val = enumCheck(int(Class2Enum12_Val6h), val)
+
+	val = 0
+	val = enumCheck(int(Class2Val1), 2131)
+	val = enumCheck(int(Class2Val2), 2132)
+	val = enumCheck(int(Class2Val3), val)
+	val = enumCheck(int(Class2Val4), val)
+	val = enumCheck(int(Class2Val5i), 2131)
+	val = enumCheck(int(Class2Val6i), val)
+
+	val = 0
+	val = enumCheck(int(Class2Enum14_Val1), 2141)
+	val = enumCheck(int(Class2Enum14_Val2), 2142)
+	val = enumCheck(int(Class2Enum14_Val3), val)
+	val = enumCheck(int(Class2Enum14_Val4), val)
+	val = enumCheck(int(Class2Enum14_Val5j), 2141)
+	val = enumCheck(int(Class2Enum14_Val6j), val)
+
+	// Requires nested class support to work
+	//val = 0
+	//val = enumCheck(int(Class2Struct1Enum12_Val1), 4121)
+	//val = enumCheck(int(Class2Struct1Enum12_Val2), 4122)
+	//val = enumCheck(int(Class2Struct1Enum12_Val3), val)
+	//val = enumCheck(int(Class2Struct1Enum12_Val4), val)
+	//val = enumCheck(int(Class2Struct1Enum12_Val5k), 4121)
+	//val = enumCheck(int(Class2Struct1Enum12_Val6k), val)
+	//
+	//val = 0
+	//val = enumCheck(int(Class2Struct1Val1), 4131)
+	//val = enumCheck(int(Class2Struct1Val2), 4132)
+	//val = enumCheck(int(Class2Struct1Val3), val)
+	//val = enumCheck(int(Class2Struct1Val4), val)
+	//val = enumCheck(int(Class2Struct1Val5l), 4131)
+	//val = enumCheck(int(Class2Struct1Val6l), val)
+	//
+	//val = 0
+	//val = enumCheck(int(Class2Struct1Enum14_Val1), 4141)
+	//val = enumCheck(int(Class2Struct1Enum14_Val2), 4142)
+	//val = enumCheck(int(Class2Struct1Enum14_Val3), val)
+	//val = enumCheck(int(Class2Struct1Enum14_Val4), val)
+	//val = enumCheck(int(Class2Struct1Enum14_Val5m), 4141)
+	//val = enumCheck(int(Class2Struct1Enum14_Val6m), val)
+
+	class1 := NewClass1()
+	enumCheck(int(class1.Class1Test1(Enum1_Val5a)), 13)
+	enumCheck(int(class1.Class1Test2(Class1Enum12_Val5c)), 1121)
+	//enumCheck(int(class1.Class1Test3(Class1Struct1Enum12_Val5f)), 3121)
+
+	enumCheck(int(GlobalTest1(Enum1_Val5a)), 13)
+	enumCheck(int(GlobalTest2(Class1Enum12_Val5c)), 1121)
+	//enumCheck(int(GlobalTest3(Class1Struct1Enum12_Val5f)), 3121)
+
+}
diff --git a/Examples/test-suite/go/go_director_inout_runme.go b/Examples/test-suite/go/go_director_inout_runme.go
new file mode 100644
index 0000000..9b9df31
--- /dev/null
+++ b/Examples/test-suite/go/go_director_inout_runme.go
@@ -0,0 +1,32 @@
+package main
+
+import (
+	wrap "./go_director_inout"
+)
+
+type GoMyClass struct {}
+
+func (p *GoMyClass) Adjust(m map[string]interface{}) wrap.GoRetStruct {
+	s := ""
+	for k, v := range m {
+		s += k + "," + v.(string) + ";"
+	}
+	return wrap.GoRetStruct{s}
+}
+
+func main() {
+	a := wrap.NewDirectorMyClass(&GoMyClass{})
+	m := map[string]interface{}{
+		"first": "second",
+	}
+	s := a.Adjust(m)
+	if s.Str != "first,second;" {
+		panic(s)
+	}
+
+	a = wrap.NewDirectorMyClass(nil)
+	s = a.Adjust(m)
+	if s.Str != `{"first":"second"}` {
+		panic(s.Str)
+	}
+}
diff --git a/Examples/test-suite/go/go_inout_runme.go b/Examples/test-suite/go/go_inout_runme.go
new file mode 100644
index 0000000..13c429b
--- /dev/null
+++ b/Examples/test-suite/go/go_inout_runme.go
@@ -0,0 +1,43 @@
+package main
+
+import (
+	"encoding/json"
+	"fmt"
+	"reflect"
+
+	"./go_inout"
+)
+
+type S struct {
+	A int
+	B string
+	C float64
+}
+
+func (p *S) MarshalJSON() ([]byte, error) {
+	return json.Marshal(*p)
+}
+
+func main() {
+	v := &S{12, "hi", 34.5}
+	m := go_inout.Same(v)
+	want := map[string]interface{}{
+		// The type of A changes from int to float64 because
+		// JSON has no ints.
+		"A": float64(12),
+		"B": "hi",
+		"C": 34.5,
+	}
+	if !reflect.DeepEqual(m, want) {
+		fmt.Println("got", m, "want", want)
+		panic(m)
+	}
+
+	a := []string{"a", "bc", "def"}
+	go_inout.DoubleArray(&a)
+	dwant := []string{"a", "bc", "def", "aa", "bcbc", "defdef"}
+	if !reflect.DeepEqual(a, dwant) {
+		fmt.Println("got", a, "want", dwant)
+		panic(a)
+	}
+}
diff --git a/Examples/test-suite/go/overload_polymorphic_runme.go b/Examples/test-suite/go/overload_polymorphic_runme.go
new file mode 100644
index 0000000..1720e1a
--- /dev/null
+++ b/Examples/test-suite/go/overload_polymorphic_runme.go
@@ -0,0 +1,11 @@
+package main
+
+import "./overload_polymorphic"
+
+func main(){
+	t := overload_polymorphic.NewDerived()
+	
+	if overload_polymorphic.Test(t) != 0 {
+		panic("failed")
+	}
+}
diff --git a/Examples/test-suite/go_director_inout.i b/Examples/test-suite/go_director_inout.i
new file mode 100644
index 0000000..af59e31
--- /dev/null
+++ b/Examples/test-suite/go_director_inout.i
@@ -0,0 +1,121 @@
+// Test the goin and goout typemaps for directors.
+
+%module(directors="1") go_director_inout
+
+%{
+#include <string>
+%}
+
+%inline
+%{
+
+struct MyStruct {
+  std::string str;
+};
+
+struct RetStruct {
+  std::string str;
+};
+
+%}
+
+%go_import("encoding/json")
+
+%insert(go_header)
+%{
+
+type GoRetStruct struct {
+	Str string
+}
+
+%}
+
+%typemap(gotype) RetStruct "GoRetStruct"
+
+%typemap(imtype) RetStruct "string"
+
+%typemap(goin) RetStruct
+%{
+	$result = $input.Str
+%}
+
+%typemap(in) RetStruct
+%{
+  $result.str.assign($input.p, $input.n);
+%}
+
+%typemap(out) RetStruct
+%{
+  $result = _swig_makegostring($1.str.data(), $1.str.length());
+%}
+
+%typemap(goout) RetStruct
+%{
+	$result = GoRetStruct{Str: $input}
+%}
+
+%typemap(godirectorout) RetStruct
+%{
+	$result = $input.Str
+%}
+
+%typemap(directorout) RetStruct
+%{
+  $result.str.assign($input.p, $input.n);
+%}
+
+%typemap(godirectorin) RetStruct
+%{
+%}
+
+%typemap(gotype) MyStruct "map[string]interface{}"
+
+%typemap(imtype) MyStruct "string"
+
+%typemap(goin) MyStruct
+%{
+	if b, err := json.Marshal($input); err != nil {
+		panic(err)
+	} else {
+		$result = string(b)
+	}
+%}
+
+%typemap(directorin) MyStruct
+%{
+  $input = _swig_makegostring($1.str.data(), $1.str.length());
+%}
+
+%typemap(out) MyStruct
+%{
+  $result = _swig_makegostring($1.str.data(), $1.str.length());
+%}
+
+%typemap(godirectorin) MyStruct
+%{
+	if err := json.Unmarshal([]byte($input), &$result); err != nil {
+		panic(err)
+	}
+%}
+
+%typemap(in) MyStruct
+%{
+  $1.str.assign($input.p, $input.n);
+%}
+
+%feature("director") MyClass;
+
+%inline
+%{
+
+class MyClass {
+ public:
+  virtual ~MyClass() {}
+  virtual RetStruct Adjust(MyStruct s) {
+    RetStruct r;
+    r.str = s.str;
+    return r;
+  }
+};
+
+%}
diff --git a/Examples/test-suite/go_inout.i b/Examples/test-suite/go_inout.i
new file mode 100644
index 0000000..510ed68
--- /dev/null
+++ b/Examples/test-suite/go_inout.i
@@ -0,0 +1,199 @@
+// Test the goin, goout, and goargout typemaps.
+
+%module go_inout
+
+%{
+#include <string>
+#include <vector>
+#include <stdint.h>
+%}
+
+%inline
+%{
+
+struct MyStruct {
+  std::string str;
+};
+
+struct RetStruct {
+  std::string str;
+};
+
+%}
+
+// Write a typemap that calls C++ by converting in and out of JSON.
+
+%go_import("encoding/json", "bytes", "encoding/binary")
+
+%insert(go_header)
+%{
+
+type In json.Marshaler
+
+%}
+
+%typemap(gotype) MyStruct "In"
+
+%typemap(imtype) MyStruct "string"
+
+%typemap(goin) MyStruct
+%{
+	{
+		b, err := $input.MarshalJSON()
+		if err != nil {
+			panic(err)
+		}
+		$result = string(b)
+	}
+%}
+
+%typemap(in) MyStruct
+%{
+  $1.str.assign($input.p, $input.n);
+%}
+
+%typemap(gotype) RetStruct "map[string]interface{}"
+
+%typemap(imtype) RetStruct "string"
+
+%typemap(out) RetStruct
+%{
+  $result = _swig_makegostring($1.str.data(), $1.str.length());
+%}
+
+%typemap(goout) RetStruct
+%{
+	if err := json.Unmarshal([]byte($1), &$result); err != nil {
+		panic(err)
+	}
+%}
+
+%inline
+%{
+
+RetStruct Same(MyStruct s)
+{
+  RetStruct r;
+  r.str = s.str;
+  return r;
+}
+
+%}
+
+%inline
+%{
+
+struct MyArray {
+  std::vector<std::string> strings;
+};
+
+static uint64_t getuint64(const char* s) {
+  uint64_t ret = 0;
+  for (int i = 0; i < 8; i++, s++) {
+    ret |= static_cast<uint64_t>(*s) << i * 8;
+  }
+  return ret;
+}
+
+static void putuint64(std::string *s, size_t off, uint64_t v) {
+  for (int i = 0; i < 8; i++) {
+    (*s)[off + i] = (v >> (i * 8)) & 0xff;
+  }
+}
+
+%}
+
+%typemap(gotype) MyArray* "*[]string"
+
+%typemap(imtype) MyArray* "*string"
+
+// Encode the slice as a single string, with length prefixes.
+%typemap(goin) MyArray*
+%{
+	{
+		var buf bytes.Buffer
+		bin := binary.LittleEndian
+		var b [8]byte
+		bin.PutUint64(b[:], uint64(len(*$input)))
+		buf.Write(b[:])
+		for _, s := range *$input {
+			bin.PutUint64(b[:], uint64(len(s)))
+			buf.Write(b[:])
+			buf.WriteString(s)
+		}
+		str := buf.String()
+		$result = &str
+	}
+%}
+
+// Unpack the string holding the packed slice.
+%typemap(in) MyArray* (MyArray t)
+%{
+  {
+    _gostring_ *s = $input;
+    const char *p = static_cast<const char *>(s->p);
+    uint64_t len = getuint64(p);
+    p += 8;
+    t.strings.resize(len);
+    for (uint64_t i = 0; i < len; i++) {
+      uint64_t slen = getuint64(p);
+      p += 8;
+      t.strings[i].assign(p, slen);
+      p += slen;
+    }
+    $1 = &t;
+  }
+%}
+
+// Pack the vector into a string.
+%typemap(argout) MyArray*
+%{
+  {
+    size_t tot = 8;
+    std::vector<std::string>::const_iterator p;
+    for (p = $1->strings.begin(); p != $1->strings.end(); ++p) {
+      tot += 8 + p->size();
+    }
+    std::string str;
+    str.resize(tot);
+    putuint64(&str, 0, $1->strings.size());
+    size_t off = 8;
+    for (p = $1->strings.begin(); p != $1->strings.end(); ++p) {
+      putuint64(&str, off, p->size());
+      off += 8;
+      str.replace(off, p->size(), *p);
+      off += p->size();
+    }
+    *$input = _swig_makegostring(str.data(), str.size());
+  }
+%}
+
+// Unpack the string into a []string.
+%typemap(goargout) MyArray*
+%{
+	{
+		str := *$input
+		bin := binary.LittleEndian
+		size := bin.Uint64([]byte(str[:8]))
+		str = str[8:]
+		r := make([]string, size)
+		for i := range r {
+			len := bin.Uint64([]byte(str[:8]))
+			str = str[8:]
+			r[i] = str[:len]
+			str = str[len:]
+		}
+		*$1 = r
+	}
+  
+%}
+
+%inline
+%{
+void DoubleArray(MyArray* v) {
+  size_t size = v->strings.size();
+  for (size_t i = 0; i < size; i++) {
+    v->strings.push_back(v->strings[i] + v->strings[i]);
+  }
+}
+%}
diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in
index 0c7b313..9050d76 100644
--- a/Examples/test-suite/guile/Makefile.in
+++ b/Examples/test-suite/guile/Makefile.in
@@ -7,16 +7,18 @@
 LANGUAGE     = guile
 VARIANT      =
 SCRIPTSUFFIX = _runme.scm
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
+
 GUILE        = @GUILE@
 GUILE_RUNTIME=
 
 C_TEST_CASES = long_long \
-               list_vector \
-               multivalue \
-               pointer_in_out
+	       list_vector \
+	       multivalue \
+	       pointer_in_out
 
 
 include $(srcdir)/../common.mk
@@ -28,7 +30,7 @@
 %.multicpptest: SWIGOPT += $(GUILE_RUNTIME)
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -38,7 +40,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -51,8 +53,8 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.scm appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env GUILE_AUTO_COMPILE=0 LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean
@@ -60,4 +62,4 @@
 	@rm -f $*-guile
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile guile_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" guile_clean
diff --git a/Examples/test-suite/import_nomodule.i b/Examples/test-suite/import_nomodule.i
index 4fd5cbf..60ef7e0 100644
--- a/Examples/test-suite/import_nomodule.i
+++ b/Examples/test-suite/import_nomodule.i
@@ -8,7 +8,7 @@
 
 %import "import_nomodule.h"
 
-#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD)
+#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD) && !defined(SWIGPYTHON_BUILTIN)
 
 /**
  * The proxy class does not have Bar derived from Foo, yet an instance of Bar
@@ -40,3 +40,10 @@
 
 #endif
 
+%inline %{
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
diff --git a/Examples/test-suite/infinity.i b/Examples/test-suite/infinity.i
index 726150f..e95bdf9 100644
--- a/Examples/test-suite/infinity.i
+++ b/Examples/test-suite/infinity.i
@@ -10,15 +10,16 @@
 #include <math.h>
 
 /* C99 math.h defines INFINITY. If not available, this is the fallback. */
-#ifndef INFINITY
-	#ifdef _MSC_VER
+#if !defined(INFINITY)
+	#if defined(_MSC_VER)
 		union MSVC_EVIL_FLOAT_HACK
 		{
 			unsigned __int8 Bytes[4];
 			float Value;
 		};
-		static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
+		const union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
 		#define INFINITY (INFINITY_HACK.Value)
+		#define INFINITY_NO_CONST
 	#endif
 
 	#ifdef __GNUC__
@@ -33,15 +34,28 @@
 		#define INFINITY (1e1000)
 	#endif
 #endif
-%}
 
-%inline %{
-/* This will allow us to bind the real INFINITY value through SWIG via MYINFINITY. Use %rename to fix the name. */
+#ifdef INFINITY_NO_CONST
+/* To void: error C2099: initializer is not a constant */
+double MYINFINITY = 0.0;
+void initialise_MYINFINITY(void) {
+  MYINFINITY = INFINITY;
+}
+#else
 const double MYINFINITY = INFINITY;
+void initialise_MYINFINITY(void) {
+}
+#endif
 
-/* Use of float is intentional because the original bug was in the float conversion due to overflow checking. */
 float use_infinity(float inf_val)
 {
     return inf_val;
 }
 %}
+
+/* This will allow us to bind the real INFINITY value through SWIG via MYINFINITY. Use %rename to fix the name. */
+const double MYINFINITY = INFINITY;
+void initialise_MYINFINITY(void);
+/* Use of float is intentional because the original bug was in the float conversion due to overflow checking. */
+float use_infinity(float inf_val);
+
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index 059325c..310f1a7 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -7,6 +7,7 @@
 JAVAC        = @JAVAC@
 JAVAFLAGS    = -Xcheck:jni
 SCRIPTSUFFIX = _runme.java
+
 srcdir       = @srcdir@
 top_srcdir   = ../@top_srcdir@
 top_builddir = ../@top_builddir@
@@ -39,9 +40,13 @@
 	java_typemaps_typewrapper
 #	li_boost_intrusive_ptr
 
+CPP11_TEST_CASES = \
+	cpp11_strongly_typed_enumerations_simple \
+
 include $(srcdir)/../common.mk
 
 # Overridden variables here
+SRCDIR       = ../$(srcdir)/
 JAVA_PACKAGE = $*
 JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
 SWIGOPT += $(JAVA_PACKAGEOPT)
@@ -55,7 +60,7 @@
 director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+(cd $(JAVA_PACKAGE) && $(swig_and_compile_cpp))
 	$(run_testcase)
@@ -65,14 +70,14 @@
 	+(cd $(JAVA_PACKAGE) && $(swig_and_compile_c))
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+(cd $(JAVA_PACKAGE) && $(swig_and_compile_multi_cpp))
 	$(run_testcase)
 
 # Makes a directory for the testcase if it does not exist
 setup = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then	  \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then	  \
 	  echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
 	else								  \
 	  echo "$(ACTION)ing $(LANGUAGE) testcase $*" ;			  \
@@ -86,8 +91,8 @@
 # Note Java uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows, SHLIB_PATH on HPUX and DYLD_LIBRARY_PATH on Mac OS X.
 run_testcase = \
 	cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  $(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  $(COMPILETOOL) $(JAVAC) -classpath . -d . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
 	  env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath . $*_runme; \
 	fi
 
diff --git a/Examples/test-suite/java/constant_directive_runme.java b/Examples/test-suite/java/constant_directive_runme.java
new file mode 100644
index 0000000..b5135a4
--- /dev/null
+++ b/Examples/test-suite/java/constant_directive_runme.java
@@ -0,0 +1,22 @@
+import constant_directive.*;
+
+public class constant_directive_runme {
+
+  static {
+    try {
+	System.loadLibrary("constant_directive");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+
+  public static void main(String argv[]) {
+    if (constant_directive.TYPE1_CONSTANT1.getVal() != 1)
+      throw new RuntimeException("fail");
+    if (constant_directive.TYPE1_CONSTANT2.getVal() != 2)
+      throw new RuntimeException("fail");
+    if (constant_directive.TYPE1_CONSTANT3.getVal() != 3)
+      throw new RuntimeException("fail");
+  }
+}
diff --git a/Examples/test-suite/java/cpp11_strongly_typed_enumerations_runme.java b/Examples/test-suite/java/cpp11_strongly_typed_enumerations_runme.java
new file mode 100644
index 0000000..3e0b3f6
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_strongly_typed_enumerations_runme.java
@@ -0,0 +1,176 @@
+import cpp11_strongly_typed_enumerations.*;
+
+public class cpp11_strongly_typed_enumerations_runme {
+
+  static {
+    try {
+        System.loadLibrary("cpp11_strongly_typed_enumerations");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+
+  public static int enumCheck(int actual, int expected) {
+    if (actual != expected)
+      throw new RuntimeException("Enum value mismatch. Expected " + expected + " Actual: " + actual);
+    return expected + 1;
+  }
+
+  public static void main(String argv[]) {
+    int val = 0;
+    val = enumCheck(Enum1.Val1.swigValue(), val);
+    val = enumCheck(Enum1.Val2.swigValue(), val);
+    val = enumCheck(Enum1.Val3.swigValue(), 13);
+    val = enumCheck(Enum1.Val4.swigValue(), val);
+    val = enumCheck(Enum1.Val5a.swigValue(), 13);
+    val = enumCheck(Enum1.Val6a.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Enum2.Val1.swigValue(), val);
+    val = enumCheck(Enum2.Val2.swigValue(), val);
+    val = enumCheck(Enum2.Val3.swigValue(), 23);
+    val = enumCheck(Enum2.Val4.swigValue(), val);
+    val = enumCheck(Enum2.Val5b.swigValue(), 23);
+    val = enumCheck(Enum2.Val6b.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Enum4.Val1.swigValue(), val);
+    val = enumCheck(Enum4.Val2.swigValue(), val);
+    val = enumCheck(Enum4.Val3.swigValue(), 43);
+    val = enumCheck(Enum4.Val4.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Enum5.Val1.swigValue(), val);
+    val = enumCheck(Enum5.Val2.swigValue(), val);
+    val = enumCheck(Enum5.Val3.swigValue(), 53);
+    val = enumCheck(Enum5.Val4.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Enum6.Val1.swigValue(), val);
+    val = enumCheck(Enum6.Val2.swigValue(), val);
+    val = enumCheck(Enum6.Val3.swigValue(), 63);
+    val = enumCheck(Enum6.Val4.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Enum7td.Val1.swigValue(), val);
+    val = enumCheck(Enum7td.Val2.swigValue(), val);
+    val = enumCheck(Enum7td.Val3.swigValue(), 73);
+    val = enumCheck(Enum7td.Val4.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Enum8.Val1.swigValue(), val);
+    val = enumCheck(Enum8.Val2.swigValue(), val);
+    val = enumCheck(Enum8.Val3.swigValue(), 83);
+    val = enumCheck(Enum8.Val4.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Enum10.Val1.swigValue(), val);
+    val = enumCheck(Enum10.Val2.swigValue(), val);
+    val = enumCheck(Enum10.Val3.swigValue(), 103);
+    val = enumCheck(Enum10.Val4.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class1.Enum12.Val1.swigValue(), 1121);
+    val = enumCheck(Class1.Enum12.Val2.swigValue(), 1122);
+    val = enumCheck(Class1.Enum12.Val3.swigValue(), val);
+    val = enumCheck(Class1.Enum12.Val4.swigValue(), val);
+    val = enumCheck(Class1.Enum12.Val5c.swigValue(), 1121);
+    val = enumCheck(Class1.Enum12.Val6c.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class1.Enum13.Val1.swigValue(), 1131);
+    val = enumCheck(Class1.Enum13.Val2.swigValue(), 1132);
+    val = enumCheck(Class1.Enum13.Val3.swigValue(), val);
+    val = enumCheck(Class1.Enum13.Val4.swigValue(), val);
+    val = enumCheck(Class1.Enum13.Val5d.swigValue(), 1131);
+    val = enumCheck(Class1.Enum13.Val6d.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class1.Enum14.Val1.swigValue(), 1141);
+    val = enumCheck(Class1.Enum14.Val2.swigValue(), 1142);
+    val = enumCheck(Class1.Enum14.Val3.swigValue(), val);
+    val = enumCheck(Class1.Enum14.Val4.swigValue(), val);
+    val = enumCheck(Class1.Enum14.Val5e.swigValue(), 1141);
+    val = enumCheck(Class1.Enum14.Val6e.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class1.Struct1.Enum12.Val1.swigValue(), 3121);
+    val = enumCheck(Class1.Struct1.Enum12.Val2.swigValue(), 3122);
+    val = enumCheck(Class1.Struct1.Enum12.Val3.swigValue(), val);
+    val = enumCheck(Class1.Struct1.Enum12.Val4.swigValue(), val);
+    val = enumCheck(Class1.Struct1.Enum12.Val5f.swigValue(), 3121);
+    val = enumCheck(Class1.Struct1.Enum12.Val6f.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class1.Struct1.Enum13.Val1.swigValue(), 3131);
+    val = enumCheck(Class1.Struct1.Enum13.Val2.swigValue(), 3132);
+    val = enumCheck(Class1.Struct1.Enum13.Val3.swigValue(), val);
+    val = enumCheck(Class1.Struct1.Enum13.Val4.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class1.Struct1.Enum14.Val1.swigValue(), 3141);
+    val = enumCheck(Class1.Struct1.Enum14.Val2.swigValue(), 3142);
+    val = enumCheck(Class1.Struct1.Enum14.Val3.swigValue(), val);
+    val = enumCheck(Class1.Struct1.Enum14.Val4.swigValue(), val);
+    val = enumCheck(Class1.Struct1.Enum14.Val5g.swigValue(), 3141);
+    val = enumCheck(Class1.Struct1.Enum14.Val6g.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class2.Enum12.Val1.swigValue(), 2121);
+    val = enumCheck(Class2.Enum12.Val2.swigValue(), 2122);
+    val = enumCheck(Class2.Enum12.Val3.swigValue(), val);
+    val = enumCheck(Class2.Enum12.Val4.swigValue(), val);
+    val = enumCheck(Class2.Enum12.Val5h.swigValue(), 2121);
+    val = enumCheck(Class2.Enum12.Val6h.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class2.Enum13.Val1.swigValue(), 2131);
+    val = enumCheck(Class2.Enum13.Val2.swigValue(), 2132);
+    val = enumCheck(Class2.Enum13.Val3.swigValue(), val);
+    val = enumCheck(Class2.Enum13.Val4.swigValue(), val);
+    val = enumCheck(Class2.Enum13.Val5i.swigValue(), 2131);
+    val = enumCheck(Class2.Enum13.Val6i.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class2.Enum14.Val1.swigValue(), 2141);
+    val = enumCheck(Class2.Enum14.Val2.swigValue(), 2142);
+    val = enumCheck(Class2.Enum14.Val3.swigValue(), val);
+    val = enumCheck(Class2.Enum14.Val4.swigValue(), val);
+    val = enumCheck(Class2.Enum14.Val5j.swigValue(), 2141);
+    val = enumCheck(Class2.Enum14.Val6j.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class2.Struct1.Enum12.Val1.swigValue(), 4121);
+    val = enumCheck(Class2.Struct1.Enum12.Val2.swigValue(), 4122);
+    val = enumCheck(Class2.Struct1.Enum12.Val3.swigValue(), val);
+    val = enumCheck(Class2.Struct1.Enum12.Val4.swigValue(), val);
+    val = enumCheck(Class2.Struct1.Enum12.Val5k.swigValue(), 4121);
+    val = enumCheck(Class2.Struct1.Enum12.Val6k.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class2.Struct1.Enum13.Val1.swigValue(), 4131);
+    val = enumCheck(Class2.Struct1.Enum13.Val2.swigValue(), 4132);
+    val = enumCheck(Class2.Struct1.Enum13.Val3.swigValue(), val);
+    val = enumCheck(Class2.Struct1.Enum13.Val4.swigValue(), val);
+    val = enumCheck(Class2.Struct1.Enum13.Val5l.swigValue(), 4131);
+    val = enumCheck(Class2.Struct1.Enum13.Val6l.swigValue(), val);
+
+    val = 0;
+    val = enumCheck(Class2.Struct1.Enum14.Val1.swigValue(), 4141);
+    val = enumCheck(Class2.Struct1.Enum14.Val2.swigValue(), 4142);
+    val = enumCheck(Class2.Struct1.Enum14.Val3.swigValue(), val);
+    val = enumCheck(Class2.Struct1.Enum14.Val4.swigValue(), val);
+    val = enumCheck(Class2.Struct1.Enum14.Val5m.swigValue(), 4141);
+    val = enumCheck(Class2.Struct1.Enum14.Val6m.swigValue(), val);
+
+    Class1 class1 = new Class1();
+    enumCheck(class1.class1Test1(Enum1.Val5a).swigValue(), 13);
+    enumCheck(class1.class1Test2(Class1.Enum12.Val5c).swigValue(), 1121);
+    enumCheck(class1.class1Test3(Class1.Struct1.Enum12.Val5f).swigValue(), 3121);
+
+    enumCheck(cpp11_strongly_typed_enumerations.globalTest1(Enum1.Val5a).swigValue(), 13);
+    enumCheck(cpp11_strongly_typed_enumerations.globalTest2(Class1.Enum12.Val5c).swigValue(), 1121);
+    enumCheck(cpp11_strongly_typed_enumerations.globalTest3(Class1.Struct1.Enum12.Val5f).swigValue(), 3121);
+  }
+}
diff --git a/Examples/test-suite/java/cpp11_strongly_typed_enumerations_simple_runme.java b/Examples/test-suite/java/cpp11_strongly_typed_enumerations_simple_runme.java
new file mode 100644
index 0000000..b50e948
--- /dev/null
+++ b/Examples/test-suite/java/cpp11_strongly_typed_enumerations_simple_runme.java
@@ -0,0 +1,176 @@
+import cpp11_strongly_typed_enumerations_simple.*;
+
+public class cpp11_strongly_typed_enumerations_simple_runme {
+
+  static {
+    try {
+        System.loadLibrary("cpp11_strongly_typed_enumerations_simple");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+
+  public static int enumCheck(int actual, int expected) {
+    if (actual != expected)
+      throw new RuntimeException("Enum value mismatch. Expected " + expected + " Actual: " + actual);
+    return expected + 1;
+  }
+
+  public static void main(String argv[]) {
+    int val = 0;
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val1, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val2, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val3, 13);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val4, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val5a, 13);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val6a, val);
+
+    val = 0;
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val1, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val2, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val3, 23);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val4, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val5b, 23);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val6b, val);
+
+    val = 0;
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val1, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val2, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val3, 43);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val4, val);
+
+    val = 0;
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val1, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val2, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val3, 53);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val4, val);
+
+    val = 0;
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val1, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val2, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val3, 63);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val4, val);
+
+    val = 0;
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val1, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val2, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val3, 73);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val4, val);
+
+    val = 0;
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val1, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val2, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val3, 83);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val4, val);
+
+    val = 0;
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val1, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val2, val);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val3, 103);
+    val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val4, val);
+
+    val = 0;
+    val = enumCheck(Class1.Enum12_Val1, 1121);
+    val = enumCheck(Class1.Enum12_Val2, 1122);
+    val = enumCheck(Class1.Enum12_Val3, val);
+    val = enumCheck(Class1.Enum12_Val4, val);
+    val = enumCheck(Class1.Enum12_Val5c, 1121);
+    val = enumCheck(Class1.Enum12_Val6c, val);
+
+    val = 0;
+    val = enumCheck(Class1.Val1, 1131);
+    val = enumCheck(Class1.Val2, 1132);
+    val = enumCheck(Class1.Val3, val);
+    val = enumCheck(Class1.Val4, val);
+    val = enumCheck(Class1.Val5d, 1131);
+    val = enumCheck(Class1.Val6d, val);
+
+    val = 0;
+    val = enumCheck(Class1.Enum14_Val1, 1141);
+    val = enumCheck(Class1.Enum14_Val2, 1142);
+    val = enumCheck(Class1.Enum14_Val3, val);
+    val = enumCheck(Class1.Enum14_Val4, val);
+    val = enumCheck(Class1.Enum14_Val5e, 1141);
+    val = enumCheck(Class1.Enum14_Val6e, val);
+
+    val = 0;
+    val = enumCheck(Class1.Struct1.Enum12_Val1, 3121);
+    val = enumCheck(Class1.Struct1.Enum12_Val2, 3122);
+    val = enumCheck(Class1.Struct1.Enum12_Val3, val);
+    val = enumCheck(Class1.Struct1.Enum12_Val4, val);
+    val = enumCheck(Class1.Struct1.Enum12_Val5f, 3121);
+    val = enumCheck(Class1.Struct1.Enum12_Val6f, val);
+
+    val = 0;
+    val = enumCheck(Class1.Struct1.Val1, 3131);
+    val = enumCheck(Class1.Struct1.Val2, 3132);
+    val = enumCheck(Class1.Struct1.Val3, val);
+    val = enumCheck(Class1.Struct1.Val4, val);
+
+    val = 0;
+    val = enumCheck(Class1.Struct1.Enum14_Val1, 3141);
+    val = enumCheck(Class1.Struct1.Enum14_Val2, 3142);
+    val = enumCheck(Class1.Struct1.Enum14_Val3, val);
+    val = enumCheck(Class1.Struct1.Enum14_Val4, val);
+    val = enumCheck(Class1.Struct1.Enum14_Val5g, 3141);
+    val = enumCheck(Class1.Struct1.Enum14_Val6g, val);
+
+    val = 0;
+    val = enumCheck(Class2.Enum12_Val1, 2121);
+    val = enumCheck(Class2.Enum12_Val2, 2122);
+    val = enumCheck(Class2.Enum12_Val3, val);
+    val = enumCheck(Class2.Enum12_Val4, val);
+    val = enumCheck(Class2.Enum12_Val5h, 2121);
+    val = enumCheck(Class2.Enum12_Val6h, val);
+
+    val = 0;
+    val = enumCheck(Class2.Val1, 2131);
+    val = enumCheck(Class2.Val2, 2132);
+    val = enumCheck(Class2.Val3, val);
+    val = enumCheck(Class2.Val4, val);
+    val = enumCheck(Class2.Val5i, 2131);
+    val = enumCheck(Class2.Val6i, val);
+
+    val = 0;
+    val = enumCheck(Class2.Enum14_Val1, 2141);
+    val = enumCheck(Class2.Enum14_Val2, 2142);
+    val = enumCheck(Class2.Enum14_Val3, val);
+    val = enumCheck(Class2.Enum14_Val4, val);
+    val = enumCheck(Class2.Enum14_Val5j, 2141);
+    val = enumCheck(Class2.Enum14_Val6j, val);
+
+    val = 0;
+    val = enumCheck(Class2.Struct1.Enum12_Val1, 4121);
+    val = enumCheck(Class2.Struct1.Enum12_Val2, 4122);
+    val = enumCheck(Class2.Struct1.Enum12_Val3, val);
+    val = enumCheck(Class2.Struct1.Enum12_Val4, val);
+    val = enumCheck(Class2.Struct1.Enum12_Val5k, 4121);
+    val = enumCheck(Class2.Struct1.Enum12_Val6k, val);
+
+    val = 0;
+    val = enumCheck(Class2.Struct1.Val1, 4131);
+    val = enumCheck(Class2.Struct1.Val2, 4132);
+    val = enumCheck(Class2.Struct1.Val3, val);
+    val = enumCheck(Class2.Struct1.Val4, val);
+    val = enumCheck(Class2.Struct1.Val5l, 4131);
+    val = enumCheck(Class2.Struct1.Val6l, val);
+
+    val = 0;
+    val = enumCheck(Class2.Struct1.Enum14_Val1, 4141);
+    val = enumCheck(Class2.Struct1.Enum14_Val2, 4142);
+    val = enumCheck(Class2.Struct1.Enum14_Val3, val);
+    val = enumCheck(Class2.Struct1.Enum14_Val4, val);
+    val = enumCheck(Class2.Struct1.Enum14_Val5m, 4141);
+    val = enumCheck(Class2.Struct1.Enum14_Val6m, val);
+
+    Class1 class1 = new Class1();
+    enumCheck(class1.class1Test1(cpp11_strongly_typed_enumerations_simple.Enum1_Val5a), 13);
+    enumCheck(class1.class1Test2(Class1.Enum12_Val5c), 1121);
+    enumCheck(class1.class1Test3(Class1.Struct1.Enum12_Val5f), 3121);
+
+    enumCheck(cpp11_strongly_typed_enumerations_simple.globalTest1(cpp11_strongly_typed_enumerations_simple.Enum1_Val5a), 13);
+    enumCheck(cpp11_strongly_typed_enumerations_simple.globalTest2(Class1.Enum12_Val5c), 1121);
+    enumCheck(cpp11_strongly_typed_enumerations_simple.globalTest3(Class1.Struct1.Enum12_Val5f), 3121);
+  }
+}
diff --git a/Examples/test-suite/java/director_nested_class_runme.java b/Examples/test-suite/java/director_nested_class_runme.java
new file mode 100644
index 0000000..5144413
--- /dev/null
+++ b/Examples/test-suite/java/director_nested_class_runme.java
@@ -0,0 +1,41 @@
+
+import director_nested_class.*;
+
+public class director_nested_class_runme {
+
+  static {
+    try {
+      System.loadLibrary("director_nested_class");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+
+  public static void main(String argv[]) {
+
+      director_nested_class_Derived d = new director_nested_class_Derived();
+
+      if (DirectorOuter.callMethod(d, 999) != 9990) {
+          throw new RuntimeException("callMethod(999) failed");
+      }
+
+      director_nested_class_DerivedInnerInner dinner = new director_nested_class_DerivedInnerInner();
+
+      if (DirectorOuter.callInnerInnerMethod(dinner, 999) != 999000) {
+          throw new RuntimeException("callMethod(999) failed");
+      }
+  }
+}
+
+class director_nested_class_Derived extends DirectorOuter.DirectorInner {
+    public int vmethod(int input) {
+        return input * 10;
+    }
+}
+
+class director_nested_class_DerivedInnerInner extends DirectorOuter.DirectorInner.DirectorInnerInner {
+    public int innervmethod(int input) {
+        return input * 1000;
+    }
+}
diff --git a/Examples/test-suite/java/java_director_runme.java b/Examples/test-suite/java/java_director_runme.java
index 812e791..2167d26 100644
--- a/Examples/test-suite/java/java_director_runme.java
+++ b/Examples/test-suite/java/java_director_runme.java
@@ -53,7 +53,7 @@
       };
       int actualCount = Quux.instances();
       if (actualCount != expectedCount)
-        throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
+        System.err.println("GC failed to run (java_director). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
     }
 
     /* Test Quux1's director disconnect method rename */
diff --git a/Examples/test-suite/java/java_lib_various_runme.java b/Examples/test-suite/java/java_lib_various_runme.java
index 203a30e..6d9e13e 100644
--- a/Examples/test-suite/java/java_lib_various_runme.java
+++ b/Examples/test-suite/java/java_lib_various_runme.java
@@ -83,6 +83,25 @@
       if (byjove[i] != b[i])
         throw new RuntimeException("By jove, it failed: [" + new String(b) + "]");
     }
+
+    // NIOBUFFER typemap check
+      java.nio.ByteBuffer buf = java.nio.ByteBuffer.allocateDirect(10); 
+      java_lib_various.niobuffer_fill_hello(buf);
+      if (
+	(char)buf.get(0) != 'h' ||
+	(char)buf.get(1) != 'e' ||
+	(char)buf.get(2) != 'l' ||
+	(char)buf.get(3) != 'l' ||
+	(char)buf.get(4) != 'o'
+      )
+        throw new RuntimeException(
+          "nio test failed: " + 
+          (char)buf.get(0) + 
+          (char)buf.get(1) + 
+          (char)buf.get(2) + 
+          (char)buf.get(3) + 
+          (char)buf.get(4)
+        );
   }
 
 }
diff --git a/Examples/test-suite/java/kwargs_feature_runme.java b/Examples/test-suite/java/kwargs_feature_runme.java
new file mode 100644
index 0000000..ba742d9
--- /dev/null
+++ b/Examples/test-suite/java/kwargs_feature_runme.java
@@ -0,0 +1,23 @@
+import kwargs_feature.*;
+
+public class kwargs_feature_runme {
+
+  static {
+    try {
+	System.loadLibrary("kwargs_feature");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+
+  public static void main(String argv[]) {
+    // Check normal overloading still works (no compactdefaultargs) if the kwargs feature is used,
+    // as the kwargs feature is not supported
+    Foo f = new Foo(99);
+    if (f.foo() != 1)
+      throw new RuntimeException("It went wrong");
+    if (Foo.statfoo(2) != 2)
+      throw new RuntimeException("It went wrong");
+  }
+}
diff --git a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java
index 530008a..750ec50 100644
--- a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java
+++ b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java
@@ -33,7 +33,7 @@
     // Change loop count to run for a long time to monitor memory
     final int loopCount = 5000; //5000;
     for (int i=0; i<loopCount; i++) {
-      new li_boost_intrusive_ptr_runme().runtest();
+      new li_boost_intrusive_ptr_runme().runtest(i);
       System.gc();
       System.runFinalization();
       try {
@@ -78,7 +78,9 @@
       System.out.println("Finished");
   }
 
-  private void runtest() {
+  private int loopCount = 0;
+  private void runtest(int loopCount) {
+    this.loopCount = loopCount;
     // simple shared_ptr usage - created in C++
     {
       Klass k = new Klass("me oh my");
@@ -671,36 +673,36 @@
   }
   private void verifyValue(String expected, String got) {
     if (!expected.equals(got))
-      throw new RuntimeException("verify value failed. Expected: " + expected + " Got: " + got);
+      throw new RuntimeException("verify value failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
   }
   private void verifyCount(int expected, Klass k) {
     int got = li_boost_intrusive_ptr.use_count(k);
     if (expected != got)
-      throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+      throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
   }
   private void verifyCount(int expected, KlassDerived kd) {
       int got = li_boost_intrusive_ptr.use_count(kd);
       if (expected != got)
-        throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+        throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
   }
   private void verifyCount(int expected, KlassDerivedDerived kdd) {
       int got = li_boost_intrusive_ptr.use_count(kdd);
       if (expected != got)
-        throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+        throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
   }
   private void verifyIntrusiveCount(int expected, Klass k) {
     int got = k.use_count();
     if (expected != got)
-      throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+      throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
   }
   private void verifyIntrusiveCount(int expected, KlassDerived kd) {
       int got = kd.use_count();
       if (expected != got)
-        throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+        throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
   }
   private void verifyIntrusiveCount(int expected, KlassDerivedDerived kdd) {
       int got = kdd.use_count();
       if (expected != got)
-        throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+        throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
   }
 }
diff --git a/Examples/test-suite/java/li_boost_shared_ptr_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_runme.java
index aa355c8..64c356f 100644
--- a/Examples/test-suite/java/li_boost_shared_ptr_runme.java
+++ b/Examples/test-suite/java/li_boost_shared_ptr_runme.java
@@ -59,7 +59,7 @@
       }
       int actualCount = Klass.getTotal_count();
       if (actualCount != expectedCount)
-        throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
+        System.err.println("GC failed to run (li_boost_shared_ptr). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
     }
 
     int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count(); 
diff --git a/Examples/test-suite/java/li_std_auto_ptr_runme.java b/Examples/test-suite/java/li_std_auto_ptr_runme.java
index db34fb5..50ed113 100644
--- a/Examples/test-suite/java/li_std_auto_ptr_runme.java
+++ b/Examples/test-suite/java/li_std_auto_ptr_runme.java
@@ -43,7 +43,7 @@
       }
       int actualCount = Klass.getTotal_count();
       if (actualCount != expectedCount)
-        throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
+        System.err.println("GC failed to run (li_std_auto_ptr 1). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
     }
 
     if (!k2.getLabel().equals("second"))
@@ -62,7 +62,7 @@
       };
       int actualCount = Klass.getTotal_count();
       if (actualCount != expectedCount)
-        throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
+        System.err.println("GC failed to run (li_std_auto_ptr 2). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't
     }
   }
 }
diff --git a/Examples/test-suite/java/nested_extend_c_runme.java b/Examples/test-suite/java/nested_extend_c_runme.java
new file mode 100644
index 0000000..5d9d861
--- /dev/null
+++ b/Examples/test-suite/java/nested_extend_c_runme.java
@@ -0,0 +1,45 @@
+import nested_extend_c.*;
+
+public class nested_extend_c_runme {
+
+  static {
+    try {
+        System.loadLibrary("nested_extend_c");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+
+  public static void main(String argv[]) throws Throwable
+  {
+    {
+      hiA hi = new hiA();
+      if (hi.hi_extend() != 'h')
+        throw new RuntimeException("test failed");
+    }
+    {
+      lowA low = new lowA();
+      if (low.low_extend() != 99)
+        throw new RuntimeException("test failed");
+    }
+
+    {
+      hiB hi = new hiB();
+      if (hi.hi_extend() != 'h')
+        throw new RuntimeException("test failed");
+    }
+    {
+      lowB low = new lowB();
+      if (low.low_extend() != 99)
+        throw new RuntimeException("test failed");
+    }
+    {
+      FOO_bar foobar = new FOO_bar();
+      foobar.setD(1234);
+      if (foobar.getD() != 1234)
+        throw new RuntimeException("test failed");
+      foobar.bar_extend();
+    }
+  }
+}
diff --git a/Examples/test-suite/java/nested_template_base_runme.java b/Examples/test-suite/java/nested_template_base_runme.java
new file mode 100644
index 0000000..8404afe
--- /dev/null
+++ b/Examples/test-suite/java/nested_template_base_runme.java
@@ -0,0 +1,27 @@
+import nested_template_base.*;
+
+public class nested_template_base_runme {
+
+  static {
+    try {
+	System.loadLibrary("nested_template_base");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+
+  public static void main(String argv[]) {
+    OuterC.InnerS ois = new OuterC.InnerS(123);
+    OuterC.InnerC oic = new OuterC.InnerC();
+
+    // Check base method is available
+    if (oic.outer(ois).getVal() != 123)
+      throw new RuntimeException("Wrong value calling outer");
+
+    // Check non-derived class using base class
+    if (oic.innerc().outer(ois).getVal() != 123)
+      throw new RuntimeException("Wrong value calling innerc");
+
+  }
+}
diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java
index 123753f..7726b61 100644
--- a/Examples/test-suite/java/preproc_line_file_runme.java
+++ b/Examples/test-suite/java/preproc_line_file_runme.java
@@ -13,13 +13,21 @@
 
   private static void test_file(String file, String suffix) throws Throwable
   {
-      String FILENAME_WINDOWS = "Examples\\test-suite\\preproc_line_file.i";
-      String FILENAME_UNIX = "Examples/test-suite/preproc_line_file.i";
+// For swig-3.0.1 and earlier
+//      String FILENAME_WINDOWS = "Examples\\test-suite\\preproc_line_file.i";
+//      String FILENAME_UNIX = "Examples/test-suite/preproc_line_file.i";
+
+      String FILENAME_WINDOWS2 = "Examples\\test-suite\\java\\..\\preproc_line_file.i";
+      String FILENAME_UNIX2 = "Examples/test-suite/java/../preproc_line_file.i";
+
+      String FILENAME_WINDOWS3 = "..\\.\\..\\preproc_line_file.i";
+      String FILENAME_UNIX3 = ".././../preproc_line_file.i";
 
       // We don't test for exact equality here because the file names are relative to the build directory, which can be different from the source directory,
       // under Unix. But they do need to end with the same path components.
-      if (!file.endsWith(FILENAME_UNIX + suffix) && !file.endsWith(FILENAME_WINDOWS + suffix))
-          throw new RuntimeException("file \"" + file + "\" doesn't end with " + FILENAME_UNIX + suffix);
+      if (!file.endsWith(FILENAME_UNIX2 + suffix) && !file.endsWith(FILENAME_WINDOWS2 + suffix) &&
+          !file.endsWith(FILENAME_UNIX3 + suffix) && !file.endsWith(FILENAME_WINDOWS3 + suffix))
+          throw new RuntimeException("file \"" + file + "\" doesn't end with " + FILENAME_UNIX2 + suffix + " or " + FILENAME_UNIX3 + suffix);
   }
 
   public static void main(String argv[]) throws Throwable
diff --git a/Examples/test-suite/java/smart_pointer_const_overload_runme.java b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
index bb4ae2c..9c10ded 100644
--- a/Examples/test-suite/java/smart_pointer_const_overload_runme.java
+++ b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
@@ -41,7 +41,7 @@
     Assert(f.getAccess() == MUTABLE_ACCESS);
       
     // Test static method
-    b.stat();
+    b.statMethod();
 
     Assert(f.getAccess() == CONST_ACCESS);
 
diff --git a/Examples/test-suite/java/template_default_class_parms_runme.java b/Examples/test-suite/java/template_default_class_parms_runme.java
index 406915b..0a6571f 100644
--- a/Examples/test-suite/java/template_default_class_parms_runme.java
+++ b/Examples/test-suite/java/template_default_class_parms_runme.java
@@ -45,6 +45,11 @@
       foo.setTType(a);
       a = foo.method(a);
     }
+
+    {
+      MapDefaults md = new MapDefaults();
+      md.test_func(10, 20, new DefaultNodeType());
+    }
   }
 }
 
diff --git a/Examples/test-suite/java/template_templated_constructors_runme.java b/Examples/test-suite/java/template_templated_constructors_runme.java
new file mode 100644
index 0000000..cd3f31d
--- /dev/null
+++ b/Examples/test-suite/java/template_templated_constructors_runme.java
@@ -0,0 +1,26 @@
+
+import template_templated_constructors.*;
+
+public class template_templated_constructors_runme {
+
+  static {
+    try {
+	System.loadLibrary("template_templated_constructors");
+    } catch (UnsatisfiedLinkError e) {
+      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+      System.exit(1);
+    }
+  }
+
+  public static void main(String argv[]) {
+    TConstructor1 t1 = new TConstructor1(123);
+    TConstructor2 t2a = new TConstructor2();
+    TConstructor2 t2b = new TConstructor2(123);
+
+    TClass1Int tc1 = new TClass1Int(123.4);
+    TClass2Int tc2a = new TClass2Int();
+    TClass2Int tc2b = new TClass2Int(123.4);
+
+  }
+}
+
diff --git a/Examples/test-suite/java/template_typedef_typedef_runme.java b/Examples/test-suite/java/template_typedef_typedef_runme.java
index f5f3685..5a3af00 100644
--- a/Examples/test-suite/java/template_typedef_typedef_runme.java
+++ b/Examples/test-suite/java/template_typedef_typedef_runme.java
@@ -12,13 +12,13 @@
   }
 
   public static void main(String argv[]) {
-    ObjectBase ob1 = new ObjectBase();
-    ob1.getBlabla1(new ObjectBase());
+    Object1Base ob1 = new Object1Base();
+    ob1.getBlabla1(new Object1Base());
     Object2Base ob2 = new Object2Base();
     ob2.getBlabla2(new Object2Base());
 
     Factory factory = new Factory();
-    factory.getBlabla3(new ObjectBase());
+    factory.getBlabla3(new Object1Base());
     factory.getBlabla4(new Object2Base());
   }
 }
diff --git a/Examples/test-suite/java_lib_various.i b/Examples/test-suite/java_lib_various.i
index 716ae91..180d075 100644
--- a/Examples/test-suite/java_lib_various.i
+++ b/Examples/test-suite/java_lib_various.i
@@ -8,6 +8,7 @@
 %apply char **STRING_ARRAY { char **languages };
 %apply char *BYTE { char *chars };
 %apply char **STRING_OUT { char **string_ptr };
+%apply unsigned char *NIOBUFFER { unsigned char *buf };
 %typemap(freearg) char **languages "" // don't delete memory when setting global variable
 
 %{
@@ -47,5 +48,8 @@
     *string_ptr = ret;
 }
 
+void niobuffer_fill_hello(unsigned char *buf) {
+        sprintf ((char*)buf,"hello");
+}
 %}
 
diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
old mode 100755
new mode 100644
index 7368ea9..83b15f8
--- a/Examples/test-suite/javascript/Makefile.in
+++ b/Examples/test-suite/javascript/Makefile.in
@@ -4,10 +4,15 @@
 
 LANGUAGE     = javascript
 NODEGYP = @NODEGYP@
+NODEJS = @NODEJS@
 SCRIPTSUFFIX = _runme.js
+OBJEXT = @OBJEXT@
+SO = @SO@
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
+
 SWIG  = $(top_builddir)/preinst_swig
 
 ifneq (, $(ENGINE))
@@ -16,23 +21,23 @@
 	JSENGINE=node
 endif
 
+ifneq (, $(V8_VERSION))
+    JSV8_VERSION=$(V8_VERSION)
+else
+    JSV8_VERSION=0x031110
+endif
+
 include $(srcdir)/../common.mk
 
+SWIGOPT += -DV8_VERSION=$(JSV8_VERSION)
+
 _setup = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then	  \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then	  \
 	  echo "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $* (with run test)" ; \
 	else								  \
 	  echo "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $*" ;     \
 	fi;
 
-ifneq (jsc,$(ENGINE))
-
-  # This test can not be run with v8 as it uses v8 API incompatible output typemaps
-  typemap_variables.cpptest:
-	  echo "skipping $(LANGUAGE) ($(JSENGINE)) testcase typemap_variables" ;
-
-endif
-
 ifeq (node,$(JSENGINE))
 
   SWIGOPT += -v8 -DBUILDING_NODE_EXTENSION=1
@@ -47,20 +52,27 @@
   constant_pointers.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
   enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
 
+	setup_node = \
+		test -d $* || mkdir $*; \
+		sed -e 's|$$testcase|$*|g; s|$$cflags|$(GYP_CFLAGS)|g; s|$$srcdir|$(srcdir)|g' \
+			$(srcdir)/node_template/binding.gyp.in > $*/binding.gyp; \
+		sed -e 's|$$testcase|$*|g;' \
+			$(srcdir)/node_template/index.js.in > $*/index.js
+
 	# Note: we need to use swig in C parse mode, but make node-gyp believe it is c++ (via file extension)
 	swig_and_compile_c = \
-		sh ./setup_test.sh $* $(GYP_CFLAGS); \
-		$(SWIG) -javascript $(SWIGOPT) -o $*_wrap.cxx ../$*.i; \
+		$(setup_node); \
+		$(SWIG) -javascript $(SWIGOPT) -o $*_wrap.cxx $(srcdir)/../$*.i; \
 		$(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
 
 	swig_and_compile_cpp = \
-		sh ./setup_test.sh $* $(GYP_CFLAGS); \
-		$(SWIG) -c++ -javascript $(SWIGOPT) ../$*.i; \
+		$(setup_node); \
+		$(SWIG) -c++ -javascript $(SWIGOPT) $(srcdir)/../$*.i; \
 		$(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null
 
 	run_testcase = \
 		if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
-			node $(srcdir)/$*$(SCRIPTSUFFIX); \
+			env NODE_PATH=$$PWD:$(srcdir) $(NODEJS) $(srcdir)/$*$(SCRIPTSUFFIX); \
 		fi
 
 
@@ -83,7 +95,7 @@
 
 	run_testcase = \
 		if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
-			$(top_srcdir)/Tools/javascript/javascript -$(JSENGINE) $(srcdir)/$*$(SCRIPTSUFFIX); \
+		  $(RUNTOOL) $(top_builddir)/Tools/javascript/javascript -$(JSENGINE) $(srcdir)/$*$(SCRIPTSUFFIX); \
 		fi
 
   %.ctest:
@@ -105,10 +117,15 @@
 
 
 %.clean:
-	rm -rf $*
+	@rm -rf $*
+	@rm -f $*_wrap.* $*$(SO) $*.$(OBJEXT)
 
 clean:
-	rm -f *_wrap.cxx
-	rm -f *_wrap.c
-	rm -f *.so
-	rm -f *.o
+	for ext in _wrap.cxx _wrap.$(OBJEXT) $(SO); do \
+		rm -f clientdata_prop_a$${ext} clientdata_prop_b$${ext}; \
+		rm -f imports_a$${ext} imports_b$${ext}; \
+		rm -f import_stl_a$${ext} import_stl_b$${ext}; \
+		rm -f mod_a$${ext} mod_b$${ext}; \
+		rm -f multi_import_a$${ext} multi_import_b$${ext}; \
+		rm -f packageoption_a$${ext} packageoption_b$${ext} packageoption_c$${ext}; \
+	done
diff --git a/Examples/test-suite/javascript/abstract_access_runme.js b/Examples/test-suite/javascript/abstract_access_runme.js
index 8f87d21..f61bb43 100644
--- a/Examples/test-suite/javascript/abstract_access_runme.js
+++ b/Examples/test-suite/javascript/abstract_access_runme.js
@@ -1,4 +1,4 @@
-var abstract_access = require("./abstract_access");
+var abstract_access = require("abstract_access");
 
 var d = new abstract_access.D()
 if (d.do_x() != 1) {
diff --git a/Examples/test-suite/javascript/abstract_inherit_runme.js b/Examples/test-suite/javascript/abstract_inherit_runme.js
index 3af2eae..f732e87 100644
--- a/Examples/test-suite/javascript/abstract_inherit_runme.js
+++ b/Examples/test-suite/javascript/abstract_inherit_runme.js
@@ -1,4 +1,4 @@
-var abstract_inherit = require("./abstract_inherit");
+var abstract_inherit = require("abstract_inherit");
 
 // Shouldn't be able to instantiate any of these classes
 // since none of them implements the pure virtual function
diff --git a/Examples/test-suite/javascript/abstract_typedef2_runme.js b/Examples/test-suite/javascript/abstract_typedef2_runme.js
index c177e49..d8a533a 100644
--- a/Examples/test-suite/javascript/abstract_typedef2_runme.js
+++ b/Examples/test-suite/javascript/abstract_typedef2_runme.js
@@ -1,4 +1,4 @@
-var abstract_typedef2 = require("./abstract_typedef2");
+var abstract_typedef2 = require("abstract_typedef2");
 
 var a = new abstract_typedef2.A_UF();
 
diff --git a/Examples/test-suite/javascript/abstract_typedef_runme.js b/Examples/test-suite/javascript/abstract_typedef_runme.js
index abcfc58..286328f 100644
--- a/Examples/test-suite/javascript/abstract_typedef_runme.js
+++ b/Examples/test-suite/javascript/abstract_typedef_runme.js
@@ -1,4 +1,4 @@
-var abstract_typedef = require("./abstract_typedef");
+var abstract_typedef = require("abstract_typedef");
 
 var e = new abstract_typedef.Engine();
 var a = new abstract_typedef.A()
diff --git a/Examples/test-suite/javascript/abstract_virtual_runme.js b/Examples/test-suite/javascript/abstract_virtual_runme.js
index 9e2814e..9a9ce99 100644
--- a/Examples/test-suite/javascript/abstract_virtual_runme.js
+++ b/Examples/test-suite/javascript/abstract_virtual_runme.js
@@ -1,4 +1,4 @@
-var abstract_virtual = require("./abstract_virtual");
+var abstract_virtual = require("abstract_virtual");
 
 d = new abstract_virtual.D()
 
diff --git a/Examples/test-suite/javascript/array_member_runme.js b/Examples/test-suite/javascript/array_member_runme.js
index 8c4ef1d..3d9bb0e 100644
--- a/Examples/test-suite/javascript/array_member_runme.js
+++ b/Examples/test-suite/javascript/array_member_runme.js
@@ -1,4 +1,4 @@
-var array_member = require("./array_member");
+var array_member = require("array_member");
 
 var f = new array_member.Foo();
 f.data = array_member.global_data;
diff --git a/Examples/test-suite/javascript/arrays_global_runme.js b/Examples/test-suite/javascript/arrays_global_runme.js
index fdb365f..0cbb28e 100644
--- a/Examples/test-suite/javascript/arrays_global_runme.js
+++ b/Examples/test-suite/javascript/arrays_global_runme.js
@@ -1,4 +1,4 @@
-var arrays_global = require("./arrays_global");
+var arrays_global = require("arrays_global");
 
 arrays_global.array_i = arrays_global.array_const_i;
 
diff --git a/Examples/test-suite/javascript/callback_runme.js b/Examples/test-suite/javascript/callback_runme.js
index 9b1ef01..0218886 100644
--- a/Examples/test-suite/javascript/callback_runme.js
+++ b/Examples/test-suite/javascript/callback_runme.js
@@ -1,4 +1,4 @@
-var callback = require("./callback");
+var callback = require("callback");
 
 if (callback.foo(2) !== 2) {
   throw new Error("Failed.");
diff --git a/Examples/test-suite/javascript/char_binary_runme.js b/Examples/test-suite/javascript/char_binary_runme.js
index 42abe60..b2aac92 100644
--- a/Examples/test-suite/javascript/char_binary_runme.js
+++ b/Examples/test-suite/javascript/char_binary_runme.js
@@ -1,4 +1,4 @@
-var char_binary = require("./char_binary");
+var char_binary = require("char_binary");
 
 var t = new char_binary.Test();
 if (t.strlen('hile') != 4) {
diff --git a/Examples/test-suite/javascript/char_strings_runme.js b/Examples/test-suite/javascript/char_strings_runme.js
index cca50d8..fe17cb9 100644
--- a/Examples/test-suite/javascript/char_strings_runme.js
+++ b/Examples/test-suite/javascript/char_strings_runme.js
@@ -1,4 +1,4 @@
-var char_strings = require("./char_strings");
+var char_strings = require("char_strings");
 
 var assertIsEqual = function(expected, actual) {
   if (expected !== actual) {
diff --git a/Examples/test-suite/javascript/class_ignore_runme.js b/Examples/test-suite/javascript/class_ignore_runme.js
index f0a32a1..ffbe021 100644
--- a/Examples/test-suite/javascript/class_ignore_runme.js
+++ b/Examples/test-suite/javascript/class_ignore_runme.js
@@ -1,4 +1,4 @@
-var class_ignore = require("./class_ignore");
+var class_ignore = require("class_ignore");
 
 a = new class_ignore.Bar();
 
diff --git a/Examples/test-suite/javascript/class_scope_weird_runme.js b/Examples/test-suite/javascript/class_scope_weird_runme.js
index ac745d0..73c118d 100644
--- a/Examples/test-suite/javascript/class_scope_weird_runme.js
+++ b/Examples/test-suite/javascript/class_scope_weird_runme.js
@@ -1,4 +1,4 @@
-var class_scope_weird = require("./class_scope_weird");
+var class_scope_weird = require("class_scope_weird");
 
 f = new class_scope_weird.Foo();
 g = new class_scope_weird.Foo(3);
diff --git a/Examples/test-suite/javascript/complextest_runme.js b/Examples/test-suite/javascript/complextest_runme.js
index 1fcc976..b87d6bf 100644
--- a/Examples/test-suite/javascript/complextest_runme.js
+++ b/Examples/test-suite/javascript/complextest_runme.js
@@ -1,4 +1,4 @@
-var complextest = require("./complextest");
+var complextest = require("complextest");
 
 a = [-1,2];
 
diff --git a/Examples/test-suite/javascript/constover_runme.js b/Examples/test-suite/javascript/constover_runme.js
index 764d8b3..9b192b5 100644
--- a/Examples/test-suite/javascript/constover_runme.js
+++ b/Examples/test-suite/javascript/constover_runme.js
@@ -1,4 +1,4 @@
-var constover = require("./constover");
+var constover = require("constover");
 
 p = constover.test("test");
 if (p != "test") {
diff --git a/Examples/test-suite/javascript/constructor_copy_runme.js b/Examples/test-suite/javascript/constructor_copy_runme.js
index 39dce52..179b9fb 100644
--- a/Examples/test-suite/javascript/constructor_copy_runme.js
+++ b/Examples/test-suite/javascript/constructor_copy_runme.js
@@ -1,4 +1,4 @@
-var constructor_copy = require("./constructor_copy");
+var constructor_copy = require("constructor_copy");
 
 f1 = new constructor_copy.Foo1(3);
 f11 = new constructor_copy.Foo1(f1);
diff --git a/Examples/test-suite/javascript/cpp11_strongly_typed_enumerations_runme.js b/Examples/test-suite/javascript/cpp11_strongly_typed_enumerations_runme.js
new file mode 100644
index 0000000..ad9d4e8
--- /dev/null
+++ b/Examples/test-suite/javascript/cpp11_strongly_typed_enumerations_runme.js
@@ -0,0 +1,165 @@
+var cpp11_strongly_typed_enumerations = require("cpp11_strongly_typed_enumerations");
+
+function enumCheck(actual, expected) {
+  if (actual != expected) {
+    throw new Error("Enum value mismatch. Expected: " + expected + " Actual: " + actual);
+  }
+  return expected + 1;
+}
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val3, 13);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val5a, 13);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val6a, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val3, 23);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val5b, 23);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val6b, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Val3, 43);
+val = enumCheck(cpp11_strongly_typed_enumerations.Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val3, 53);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val3, 63);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val3, 73);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val3, 83);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val3, 103);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val1, 1121);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val2, 1122);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c, 1121);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val6c, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val1, 1131);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val2, 1132);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val5d, 1131);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val6d, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val1, 1141);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val2, 1142);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val5e, 1141);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val6e, val);
+
+// Requires nested class support to work
+//val = 0;
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val1, 3121);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val2, 3122);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val3, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val4, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val5f, 3121);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val6f, val);
+//
+//val = 0;
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val1, 3131);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val2, 3132);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val3, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val4, val);
+//
+//val = 0;
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val1, 3141);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val2, 3142);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val3, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val4, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val5g, 3141);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val6g, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val1, 2121);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val2, 2122);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val5h, 2121);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val6h, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val1, 2131);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val2, 2132);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val5i, 2131);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val6i, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val1, 2141);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val2, 2142);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val5j, 2141);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val6j, val);
+
+// Requires nested class support to work
+//val = 0;
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val1, 4121);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val2, 4122);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val3, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val4, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val5k, 4121);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum12_Val6k, val);
+//
+//val = 0;
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val1, 4131);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val2, 4132);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val3, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val4, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val5l, 4131);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Val6l, val);
+//
+//val = 0;
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val1, 4141);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val2, 4142);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val3, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val4, val);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val5m, 4141);
+//val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1_Enum14_Val6m, val);
+
+class1 = new cpp11_strongly_typed_enumerations.Class1();
+enumCheck(class1.class1Test1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);
+enumCheck(class1.class1Test2(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c), 1121);
+//enumCheck(class1.class1Test3(cpp11_strongly_typed_enumerations.Class1.Struct1_Enum12_Val5f), 3121);
+
+enumCheck(cpp11_strongly_typed_enumerations.globalTest1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);
+enumCheck(cpp11_strongly_typed_enumerations.globalTest2(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c), 1121);
+//enumCheck(globalTest3(cpp11_strongly_typed_enumerations.Class1.Struct1_Enum12_Val5f), 3121);
diff --git a/Examples/test-suite/javascript/cpp_enum_runme.js b/Examples/test-suite/javascript/cpp_enum_runme.js
index 35f7c60..8a248c3 100644
--- a/Examples/test-suite/javascript/cpp_enum_runme.js
+++ b/Examples/test-suite/javascript/cpp_enum_runme.js
@@ -1,4 +1,4 @@
-var cpp_enum = require("./cpp_enum");
+var cpp_enum = require("cpp_enum");
 
 var f = new cpp_enum.Foo()
 
diff --git a/Examples/test-suite/javascript/cpp_namespace_runme.js b/Examples/test-suite/javascript/cpp_namespace_runme.js
index 3bdfef3..a6ab799 100644
--- a/Examples/test-suite/javascript/cpp_namespace_runme.js
+++ b/Examples/test-suite/javascript/cpp_namespace_runme.js
@@ -1,4 +1,4 @@
-var cpp_namespace = require("./cpp_namespace");
+var cpp_namespace = require("cpp_namespace");
 
 var n = cpp_namespace.fact(4);
 if (n != 24){
diff --git a/Examples/test-suite/javascript/cpp_static_runme.js b/Examples/test-suite/javascript/cpp_static_runme.js
index 2579aea..c7917e1 100644
--- a/Examples/test-suite/javascript/cpp_static_runme.js
+++ b/Examples/test-suite/javascript/cpp_static_runme.js
@@ -1,4 +1,4 @@
-var cpp_static = require("./cpp_static");
+var cpp_static = require("cpp_static");
 
 cpp_static.StaticFunctionTest.static_func();
 cpp_static.StaticFunctionTest.static_func_2(1);
diff --git a/Examples/test-suite/javascript/director_alternating_runme.js b/Examples/test-suite/javascript/director_alternating_runme.js
index a0411ea..cff288d 100644
--- a/Examples/test-suite/javascript/director_alternating_runme.js
+++ b/Examples/test-suite/javascript/director_alternating_runme.js
@@ -1,4 +1,4 @@
-var director_alternating = require("./director_alternating");
+var director_alternating = require("director_alternating");
 
 id = director_alternating.getBar().id();
 if (id != director_alternating.idFromGetBar())
diff --git a/Examples/test-suite/javascript/disown_runme.js b/Examples/test-suite/javascript/disown_runme.js
index a4a6fd8..ea742b5 100644
--- a/Examples/test-suite/javascript/disown_runme.js
+++ b/Examples/test-suite/javascript/disown_runme.js
@@ -1,4 +1,4 @@
-var disown = require("./disown");
+var disown = require("disown");
 
 var a = new disown.A();
 var tmp = a.thisown;
diff --git a/Examples/test-suite/javascript/dynamic_cast_runme.js b/Examples/test-suite/javascript/dynamic_cast_runme.js
index 0029cb0..32eabcf 100644
--- a/Examples/test-suite/javascript/dynamic_cast_runme.js
+++ b/Examples/test-suite/javascript/dynamic_cast_runme.js
@@ -1,4 +1,4 @@
-var dynamic_cast = require("./dynamic_cast");
+var dynamic_cast = require("dynamic_cast");
 
 var f = new dynamic_cast.Foo();
 var b = new dynamic_cast.Bar();
diff --git a/Examples/test-suite/javascript/empty_runme.js b/Examples/test-suite/javascript/empty_runme.js
index db06b39..7894379 100644
--- a/Examples/test-suite/javascript/empty_runme.js
+++ b/Examples/test-suite/javascript/empty_runme.js
@@ -1 +1 @@
-var empty = require("./empty");
\ No newline at end of file
+var empty = require("empty");
\ No newline at end of file
diff --git a/Examples/test-suite/javascript/enum_template_runme.js b/Examples/test-suite/javascript/enum_template_runme.js
index 20f8c34..1e71e5f 100644
--- a/Examples/test-suite/javascript/enum_template_runme.js
+++ b/Examples/test-suite/javascript/enum_template_runme.js
@@ -1,4 +1,4 @@
-var enum_template = require("./enum_template");
+var enum_template = require("enum_template");
 
 if (enum_template.MakeETest() != 1)
   throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/infinity_runme.js b/Examples/test-suite/javascript/infinity_runme.js
index 7b5182f..8ebe496 100644
--- a/Examples/test-suite/javascript/infinity_runme.js
+++ b/Examples/test-suite/javascript/infinity_runme.js
@@ -1,4 +1,5 @@
-var infinity = require("./infinity");
+var infinity = require("infinity");
 
+infinity.initialise_MYINFINITY();
 var my_infinity = infinity.INFINITY;
 var ret_val = infinity.use_infinity(my_infinity);
diff --git a/Examples/test-suite/javascript/namespace_virtual_method_runme.js b/Examples/test-suite/javascript/namespace_virtual_method_runme.js
index 24d3bd4..4f1e05c 100644
--- a/Examples/test-suite/javascript/namespace_virtual_method_runme.js
+++ b/Examples/test-suite/javascript/namespace_virtual_method_runme.js
@@ -1,3 +1,3 @@
-var namespace_virtual_method = require("./namespace_virtual_method");
+var namespace_virtual_method = require("namespace_virtual_method");
 
 x = new namespace_virtual_method.Spam();
diff --git a/Examples/test-suite/javascript/node_template/binding.gyp.in b/Examples/test-suite/javascript/node_template/binding.gyp.in
index 209774a..a82ac2f 100644
--- a/Examples/test-suite/javascript/node_template/binding.gyp.in
+++ b/Examples/test-suite/javascript/node_template/binding.gyp.in
@@ -3,7 +3,7 @@
     {
       "target_name": "$testcase",
       "sources":[ "../$testcase_wrap.cxx" ],
-      "include_dirs": ["../.."],
+      "include_dirs": ["../$srcdir/.."],
       'defines': [
         'BUILDING_NODE_EXTENSION=1',
       ],
diff --git a/Examples/test-suite/javascript/nspace_extend_runme.js b/Examples/test-suite/javascript/nspace_extend_runme.js
index ab81c19..8cabfe9 100644
--- a/Examples/test-suite/javascript/nspace_extend_runme.js
+++ b/Examples/test-suite/javascript/nspace_extend_runme.js
@@ -1,4 +1,4 @@
-var nspace_extend = require("./nspace_extend");
+var nspace_extend = require("nspace_extend");
 
 // constructors and destructors
 var color1 = new nspace_extend.Outer.Inner1.Color();
diff --git a/Examples/test-suite/javascript/nspace_runme.js b/Examples/test-suite/javascript/nspace_runme.js
index f1afff4..993610d 100644
--- a/Examples/test-suite/javascript/nspace_runme.js
+++ b/Examples/test-suite/javascript/nspace_runme.js
@@ -1,4 +1,4 @@
-var nspace = require("./nspace");
+var nspace = require("nspace");
 
 var color1 = new nspace.Outer.Inner1.Color();
 var color = new nspace.Outer.Inner1.Color(color1);
diff --git a/Examples/test-suite/javascript/null_pointer_runme.js b/Examples/test-suite/javascript/null_pointer_runme.js
new file mode 100644
index 0000000..7c0d612
--- /dev/null
+++ b/Examples/test-suite/javascript/null_pointer_runme.js
@@ -0,0 +1,9 @@
+var null_pointer = require("null_pointer");
+
+if (!null_pointer.func(null)) {
+  throw new Error("Javascript 'null' should be converted into NULL.");
+}
+
+if (null_pointer.getnull() != null) {
+  throw new Error("NULL should be converted into Javascript 'null'.");
+}
diff --git a/Examples/test-suite/javascript/overload_copy_runme.js b/Examples/test-suite/javascript/overload_copy_runme.js
index 1039ffd..e2f6107 100644
--- a/Examples/test-suite/javascript/overload_copy_runme.js
+++ b/Examples/test-suite/javascript/overload_copy_runme.js
@@ -1,4 +1,4 @@
-var overload_copy = require("./overload_copy");
+var overload_copy = require("overload_copy");
 
 f = new overload_copy.Foo();
 g = new overload_copy.Foo(f);
diff --git a/Examples/test-suite/javascript/preproc_include_runme.js b/Examples/test-suite/javascript/preproc_include_runme.js
index 4b827fb..5ec72b8 100644
--- a/Examples/test-suite/javascript/preproc_include_runme.js
+++ b/Examples/test-suite/javascript/preproc_include_runme.js
@@ -1,4 +1,4 @@
-var preproc_include = require("./preproc_include");
+var preproc_include = require("preproc_include");
 
 if (preproc_include.multiply10(10) != 100)
   throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/preproc_runme.js b/Examples/test-suite/javascript/preproc_runme.js
index 669f9d1..167ca5a 100644
--- a/Examples/test-suite/javascript/preproc_runme.js
+++ b/Examples/test-suite/javascript/preproc_runme.js
@@ -1,4 +1,4 @@
-var preproc = require("./preproc");
+var preproc = require("preproc");
 
 if (preproc.endif != 1)
   throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/rename1_runme.js b/Examples/test-suite/javascript/rename1_runme.js
index 8374e6a..68ecc11 100644
--- a/Examples/test-suite/javascript/rename1_runme.js
+++ b/Examples/test-suite/javascript/rename1_runme.js
@@ -1,4 +1,4 @@
-var rename = require("./rename1");
+var rename = require("rename1");
 
 function part1() {
   var xyz = new rename.XYZInt();
diff --git a/Examples/test-suite/javascript/rename2_runme.js b/Examples/test-suite/javascript/rename2_runme.js
index bc6a95a..99f4785 100644
--- a/Examples/test-suite/javascript/rename2_runme.js
+++ b/Examples/test-suite/javascript/rename2_runme.js
@@ -1,4 +1,4 @@
-var rename = require("./rename2");
+var rename = require("rename2");
 
 function part1() {
   var xyz = new rename.XYZInt();
diff --git a/Examples/test-suite/javascript/rename3_runme.js b/Examples/test-suite/javascript/rename3_runme.js
index 9e57e80..237029f 100644
--- a/Examples/test-suite/javascript/rename3_runme.js
+++ b/Examples/test-suite/javascript/rename3_runme.js
@@ -1,4 +1,4 @@
-var rename = require("./rename3");
+var rename = require("rename3");
 
 function part1() {
   var xyz = new rename.XYZInt();
diff --git a/Examples/test-suite/javascript/rename4_runme.js b/Examples/test-suite/javascript/rename4_runme.js
index d651fc7..fed50dc 100644
--- a/Examples/test-suite/javascript/rename4_runme.js
+++ b/Examples/test-suite/javascript/rename4_runme.js
@@ -1,4 +1,4 @@
-var rename = require("./rename4");
+var rename = require("rename4");
 
 function part1() {
   var xyz = new rename.XYZInt();
diff --git a/Examples/test-suite/javascript/rename_scope_runme.js b/Examples/test-suite/javascript/rename_scope_runme.js
index c0226df..fea4d2c 100644
--- a/Examples/test-suite/javascript/rename_scope_runme.js
+++ b/Examples/test-suite/javascript/rename_scope_runme.js
@@ -1,4 +1,4 @@
-var rename_scope = require("./rename_scope");
+var rename_scope = require("rename_scope");
 
 var a = new rename_scope.Natural_UP();
 var b = new rename_scope.Natural_BP();
diff --git a/Examples/test-suite/javascript/rename_simple_runme.js b/Examples/test-suite/javascript/rename_simple_runme.js
index 918dd68..21350cd 100644
--- a/Examples/test-suite/javascript/rename_simple_runme.js
+++ b/Examples/test-suite/javascript/rename_simple_runme.js
@@ -1,4 +1,4 @@
-var rename_simple = require("./rename_simple");
+var rename_simple = require("rename_simple");
 var NewStruct = rename_simple.NewStruct;
 
 var s = new NewStruct();
diff --git a/Examples/test-suite/javascript/ret_by_value_runme.js b/Examples/test-suite/javascript/ret_by_value_runme.js
index d9a77a2..9d08406 100644
--- a/Examples/test-suite/javascript/ret_by_value_runme.js
+++ b/Examples/test-suite/javascript/ret_by_value_runme.js
@@ -1,4 +1,4 @@
-var ret_by_value = require("./ret_by_value");
+var ret_by_value = require("ret_by_value");
 
 a = ret_by_value.get_test();
 if (a.myInt != 100)
diff --git a/Examples/test-suite/javascript/setup_test.sh b/Examples/test-suite/javascript/setup_test.sh
deleted file mode 100644
index 913a74c..0000000
--- a/Examples/test-suite/javascript/setup_test.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-if [ ! -d $1 ]; then
-  mkdir $1;
-fi
-sed -e "s/\$testcase/$1/" -e "s/\$cflags/$2/" < node_template/binding.gyp.in > $1/binding.gyp
-sed s/\$testcase/$1/ node_template/index.js.in > $1/index.js
diff --git a/Examples/test-suite/javascript/string_simple_runme.js b/Examples/test-suite/javascript/string_simple_runme.js
index dbdd413..39ae84e 100644
--- a/Examples/test-suite/javascript/string_simple_runme.js
+++ b/Examples/test-suite/javascript/string_simple_runme.js
@@ -1,4 +1,4 @@
-var string_simple = require("./string_simple");
+var string_simple = require("string_simple");
 
 // Test unicode string
 var str = "olé";
diff --git a/Examples/test-suite/javascript/struct_value_runme.js b/Examples/test-suite/javascript/struct_value_runme.js
index d6b26f7..5b171b8 100644
--- a/Examples/test-suite/javascript/struct_value_runme.js
+++ b/Examples/test-suite/javascript/struct_value_runme.js
@@ -1,4 +1,4 @@
-var struct_value = require("./struct_value");
+var struct_value = require("struct_value");
 
 b = new struct_value.Bar();
 
diff --git a/Examples/test-suite/javascript/template_static_runme.js b/Examples/test-suite/javascript/template_static_runme.js
index 477d972..d610613 100644
--- a/Examples/test-suite/javascript/template_static_runme.js
+++ b/Examples/test-suite/javascript/template_static_runme.js
@@ -1,3 +1,3 @@
-var template_static = require("./template_static");
+var template_static = require("template_static");
 
 template_static.Foo.bar_double(1);
diff --git a/Examples/test-suite/javascript/typedef_class_runme.js b/Examples/test-suite/javascript/typedef_class_runme.js
index 3e4dc90..64e0051 100644
--- a/Examples/test-suite/javascript/typedef_class_runme.js
+++ b/Examples/test-suite/javascript/typedef_class_runme.js
@@ -1,4 +1,4 @@
-var typedef_class = require("./typedef_class");
+var typedef_class = require("typedef_class");
 
 a = new typedef_class.RealA();
 a.a = 3;
diff --git a/Examples/test-suite/javascript/typedef_inherit_runme.js b/Examples/test-suite/javascript/typedef_inherit_runme.js
index 4abcc25..7590e1e 100644
--- a/Examples/test-suite/javascript/typedef_inherit_runme.js
+++ b/Examples/test-suite/javascript/typedef_inherit_runme.js
@@ -1,4 +1,4 @@
-var typedef_inherit = require("./typedef_inherit");
+var typedef_inherit = require("typedef_inherit");
 
 a = new typedef_inherit.Foo();
 b = new typedef_inherit.Bar();
diff --git a/Examples/test-suite/javascript/typedef_scope_runme.js b/Examples/test-suite/javascript/typedef_scope_runme.js
index 0ac5688..5c1368a 100644
--- a/Examples/test-suite/javascript/typedef_scope_runme.js
+++ b/Examples/test-suite/javascript/typedef_scope_runme.js
@@ -1,4 +1,4 @@
-var typedef_scope = require("./typedef_scope");
+var typedef_scope = require("typedef_scope");
 
 b = new typedef_scope.Bar();
 x = b.test1(42,"hello");
diff --git a/Examples/test-suite/javascript/typemap_arrays_runme.js b/Examples/test-suite/javascript/typemap_arrays_runme.js
index cd6827a..610ecdd 100644
--- a/Examples/test-suite/javascript/typemap_arrays_runme.js
+++ b/Examples/test-suite/javascript/typemap_arrays_runme.js
@@ -1,4 +1,4 @@
-var typemap_arrays = require("./typemap_arrays");
+var typemap_arrays = require("typemap_arrays");
 
 if (typemap_arrays.sumA(null) != 60)
     throw "RuntimeError, Sum is wrong";
diff --git a/Examples/test-suite/javascript/typemap_delete_runme.js b/Examples/test-suite/javascript/typemap_delete_runme.js
index 4b31749..1d42ce4 100644
--- a/Examples/test-suite/javascript/typemap_delete_runme.js
+++ b/Examples/test-suite/javascript/typemap_delete_runme.js
@@ -1,4 +1,4 @@
-var typemap_delete = require("./typemap_delete");
+var typemap_delete = require("typemap_delete");
 
 r = new typemap_delete.Rect(123);
 if (r.val != 123)
diff --git a/Examples/test-suite/javascript/typemap_namespace_runme.js b/Examples/test-suite/javascript/typemap_namespace_runme.js
index 614e0ff..2aa3580 100644
--- a/Examples/test-suite/javascript/typemap_namespace_runme.js
+++ b/Examples/test-suite/javascript/typemap_namespace_runme.js
@@ -1,4 +1,4 @@
-var typemap_namespace = require("./typemap_namespace");
+var typemap_namespace = require("typemap_namespace");
 
 if (typemap_namespace.test1("hello") != "hello")
     throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/typemap_ns_using_runme.js b/Examples/test-suite/javascript/typemap_ns_using_runme.js
index 9115c16..7e4019a 100644
--- a/Examples/test-suite/javascript/typemap_ns_using_runme.js
+++ b/Examples/test-suite/javascript/typemap_ns_using_runme.js
@@ -1,4 +1,4 @@
-var typemap_ns_using = require("./typemap_ns_using");
+var typemap_ns_using = require("typemap_ns_using");
 
 if (typemap_ns_using.spam(37) != 37)
     throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/using1_runme.js b/Examples/test-suite/javascript/using1_runme.js
index a2e37fc..2415156 100644
--- a/Examples/test-suite/javascript/using1_runme.js
+++ b/Examples/test-suite/javascript/using1_runme.js
@@ -1,4 +1,4 @@
-var using1 = require("./using1");
+var using1 = require("using1");
 
 if (using1.spam(37) != 37)
     throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/using2_runme.js b/Examples/test-suite/javascript/using2_runme.js
index aa5e9b1..2ef08fa 100644
--- a/Examples/test-suite/javascript/using2_runme.js
+++ b/Examples/test-suite/javascript/using2_runme.js
@@ -1,4 +1,4 @@
-var using2 = require("./using2");
+var using2 = require("using2");
 
 if (using2.spam(37) != 37)
     throw "RuntimeError";
diff --git a/Examples/test-suite/javascript/varargs_runme.js b/Examples/test-suite/javascript/varargs_runme.js
index 69d761e..fc6d945 100644
--- a/Examples/test-suite/javascript/varargs_runme.js
+++ b/Examples/test-suite/javascript/varargs_runme.js
@@ -1,4 +1,4 @@
-var varargs = require("./varargs");
+var varargs = require("varargs");
 
 if (varargs.test("Hello") != "Hello") {
   throw new Error("Failed");
diff --git a/Examples/test-suite/kwargs_feature.i b/Examples/test-suite/kwargs_feature.i
index 8715310..a935b25 100644
--- a/Examples/test-suite/kwargs_feature.i
+++ b/Examples/test-suite/kwargs_feature.i
@@ -1,7 +1,7 @@
 %module kwargs_feature
 
 %nocopyctor;
-%kwargs;
+%feature("kwargs");
 
 %rename(myDel) del;
 %inline 
@@ -35,9 +35,7 @@
 
     virtual ~Foo() {
     }
-    
   };
-
 %}
 
 
@@ -64,8 +62,7 @@
 
 // Functions
 %inline %{
-  int foo(int a = 1, int b = 0) {return a + b; }
-
+  int foo_fn(int a = 1, int b = 0) {return a + b; }
   
   template<typename T> T templatedfunction(T a = 1, T b = 0) { return a + b; }
 %}
@@ -73,10 +70,8 @@
 %template(templatedfunction) templatedfunction<int>;
 
 
-// Deafult args with references
-%inline
-%{
-
+// Default args with references
+%inline %{
   typedef int size_type;
   
   struct Hello 
@@ -84,13 +79,10 @@
     static const size_type hello = 3;
   };
   
-  
-  
   int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() )
   {
     return x;
   }
-  
 %}
 %{
   const int Hello::hello;
@@ -104,9 +96,7 @@
 
   int foo_kw(int from = 1, int except = 2) {return from + except; }
 
-
   int foo_nu(int from = 1, int = 0) {return from; }
 
   int foo_mm(int min = 1, int max = 2) {return min + max; }
-
 %}
diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i
index 4916d02..c3b2112 100644
--- a/Examples/test-suite/li_boost_intrusive_ptr.i
+++ b/Examples/test-suite/li_boost_intrusive_ptr.i
@@ -6,6 +6,9 @@
 // count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on.
 //
 // Also note the debug_shared flag  which can be set from the target language.
+//
+// Usage of intrusive_ptr_add_ref and intrusive_ptr_release based on boost testing:
+// http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/test/intrusive_ptr_test.cpp
 
 %module li_boost_intrusive_ptr
 
@@ -13,10 +16,10 @@
 %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived;
 %warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived;
 
-%{
-template<typename T> void intrusive_ptr_add_ref(const T* r) { r->addref(); }
-template<typename T> void intrusive_ptr_release(const T* r) { r->release(); }
+%ignore intrusive_ptr_add_ref;
+%ignore intrusive_ptr_release;
 
+%{
 #include <boost/shared_ptr.hpp>
 #include <boost/intrusive_ptr.hpp>
 #include <boost/detail/atomic_count.hpp>
@@ -132,6 +135,8 @@
   void release(void) const { if (--count == 0) delete this; }
   int use_count(void) const { return count; }
   static long getTotal_count() { return total_count; }
+  friend void intrusive_ptr_add_ref(const Klass* r) { r->addref(); }
+  friend void intrusive_ptr_release(const Klass* r) { r->release(); }
 
 private:
   static void increment() { ++total_count; if (debug_shared) cout << "      ++xxxxx Klass::increment tot: " << total_count << endl;}
@@ -177,6 +182,8 @@
   void addref(void) const { ++count; }
   void release(void) const { if (--count == 0) delete this; }
   int use_count(void) const { return count; }
+  inline friend void intrusive_ptr_add_ref(const IgnoredRefCountingBase* r) { r->addref(); }
+  inline friend void intrusive_ptr_release(const IgnoredRefCountingBase* r) { r->release(); }
   static long getTotal_count() { return total_count; }
   
  private:
@@ -414,6 +421,8 @@
   void addref(void) const { count++; }
   void release(void) const { if (--count == 0) delete this; }
   int use_count(void) const { return count; }
+  inline friend void intrusive_ptr_add_ref(const Base<T1, T2>* r) { r->addref(); }
+  inline friend void intrusive_ptr_release(const Base<T1, T2>* r) { r->release(); }
 };
 %}
 
diff --git a/Examples/test-suite/li_std_except_as_class.i b/Examples/test-suite/li_std_except_as_class.i
index 0400c9a..01ed1f0 100644
--- a/Examples/test-suite/li_std_except_as_class.i
+++ b/Examples/test-suite/li_std_except_as_class.i
@@ -23,3 +23,11 @@
 %include <std_except.i>
 void test_domain_error() throw(std::domain_error) 
 { throw std::domain_error("std::domain_error"); }
+
+%inline %{
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
diff --git a/Examples/test-suite/li_std_string_extra.i b/Examples/test-suite/li_std_string_extra.i
index aa75853..6bef12f 100644
--- a/Examples/test-suite/li_std_string_extra.i
+++ b/Examples/test-suite/li_std_string_extra.i
@@ -49,6 +49,12 @@
    return x;
 }
 
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+
 %}
 
 %include "li_std_string.i"
diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i
index e0ecde5..80f8603 100644
--- a/Examples/test-suite/li_std_wstring.i
+++ b/Examples/test-suite/li_std_wstring.i
@@ -92,6 +92,12 @@
   #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
 #endif
 
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+
 %}
 
 
diff --git a/Examples/test-suite/li_swigtype_inout.i b/Examples/test-suite/li_swigtype_inout.i
index 9d7e9a4..136c9fa 100644
--- a/Examples/test-suite/li_swigtype_inout.i
+++ b/Examples/test-suite/li_swigtype_inout.i
@@ -13,28 +13,28 @@
 #include <iostream>
 struct XXX {
   XXX(int v) : value(v) {
-    if (debug) std::cout << "Default Constructor " << value << " " << this << std::endl;
+    if (debugging) std::cout << "Default Constructor " << value << " " << this << std::endl;
     count++;
   }
   XXX(const XXX &other) {
     value = other.value;
-    if (debug) std::cout << "Copy    Constructor " << value << " " << this << std::endl;
+    if (debugging) std::cout << "Copy    Constructor " << value << " " << this << std::endl;
     count++;
   }
   XXX& operator=(const XXX &other) {
     value = other.value;
-    if (debug) std::cout << "Assignment operator " << value << " " << this << std::endl;
+    if (debugging) std::cout << "Assignment operator " << value << " " << this << std::endl;
     return *this;
   }
   ~XXX() {
-    if (debug) std::cout << "Destructor          " << value << " " << this << std::endl;
+    if (debugging) std::cout << "Destructor          " << value << " " << this << std::endl;
     count--;
   }
   void showInfo() {
-    if (debug) std::cout << "Info                " << value << " " << this << std::endl;
+    if (debugging) std::cout << "Info                " << value << " " << this << std::endl;
   }
   int value;
-  static const bool debug = false;
+  static const bool debugging = false;
   static int count;
 };
 int XXX::count = 0;
diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in
index 66a0d2d..c562f09 100644
--- a/Examples/test-suite/lua/Makefile.in
+++ b/Examples/test-suite/lua/Makefile.in
@@ -5,6 +5,7 @@
 LANGUAGE     = lua
 LUA          = @LUABIN@
 SCRIPTSUFFIX = _runme.lua
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -28,7 +29,7 @@
 lua_no_module_global.%: SWIGOPT += -nomoduleglobal
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -38,7 +39,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -46,19 +47,19 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.lua appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LUA_PATH="$(srcdir)/?.lua;" $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LUA_PATH="$(srcdir)/?.lua;" $(RUNTOOL) $(LUA) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean: (does nothing, we dont generate extra lua code)
 %.clean:
-	
+	@exit 0
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile lua_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" lua_clean
 
 cvsignore:
 	@echo '*wrap* *.so *.dll *.exp *.lib'
 	@echo Makefile
-	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.lua; done 
-	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.lua CVS/Entries ; then echo $${i}_runme.lua; fi; done 
+	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.lua; done
+	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.lua CVS/Entries ; then echo $${i}_runme.lua; fi; done
diff --git a/Examples/test-suite/lua/cpp11_strongly_typed_enumerations_runme.lua b/Examples/test-suite/lua/cpp11_strongly_typed_enumerations_runme.lua
new file mode 100644
index 0000000..983e25a
--- /dev/null
+++ b/Examples/test-suite/lua/cpp11_strongly_typed_enumerations_runme.lua
@@ -0,0 +1,174 @@
+require("import")	-- the import fn
+import("cpp11_strongly_typed_enumerations")	-- import lib
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+function enumCheck(actual, expected)
+  if not (actual == expected) then
+    error("Enum value mismatch. Expected: "..expected.." Actual: "..actual)
+  end
+  return expected + 1
+end
+
+--val = 0
+--val = enumCheck(cpp11_strongly_typed_enumerations.cpp11_strongly_typed_enumerations.Enum1_Val1, val)
+local val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val1, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val2, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val3, 13)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val4, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val5a, 13)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val6a, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val1, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val2, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val3, 23)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val4, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val5b, 23)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val6b, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Val1, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Val2, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Val3, 43)
+val = enumCheck(cpp11_strongly_typed_enumerations.Val4, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val1, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val2, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val3, 53)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val4, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val1, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val2, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val3, 63)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val4, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val1, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val2, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val3, 73)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val4, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val1, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val2, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val3, 83)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val4, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val1, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val2, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val3, 103)
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val4, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val1, 1121)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val2, 1122)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val3, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val4, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c, 1121)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum12_Val6c, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val1, 1131)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val2, 1132)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val3, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val4, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val5d, 1131)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Val6d, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val1, 1141)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val2, 1142)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val3, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val4, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val5e, 1141)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Enum14_Val6e, val)
+
+-- Requires nested class support to work
+--val = 0
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val1, 3121)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val2, 3122)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val3, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val4, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val5f, 3121)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val6f, val)
+--
+--val = 0
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val1, 3131)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val2, 3132)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val3, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Val4, val)
+--
+--val = 0
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val1, 3141)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val2, 3142)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val3, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val4, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val5g, 3141)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum14_Val6g, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val1, 2121)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val2, 2122)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val3, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val4, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val5h, 2121)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum12_Val6h, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val1, 2131)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val2, 2132)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val3, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val4, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val5i, 2131)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Val6i, val)
+
+val = 0
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val1, 2141)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val2, 2142)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val3, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val4, val)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val5j, 2141)
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Enum14_Val6j, val)
+
+-- Requires nested class support to work
+--val = 0
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val1, 4121)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val2, 4122)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val3, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val4, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val5k, 4121)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum12_Val6k, val)
+--
+--val = 0
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val1, 4131)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val2, 4132)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val3, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val4, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val5l, 4131)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Val6l, val)
+--
+--val = 0
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val1, 4141)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val2, 4142)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val3, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val4, val)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val5m, 4141)
+--val = enumCheck(cpp11_strongly_typed_enumerations.Class2.Struct1.Enum14_Val6m, val)
+
+class1 = cpp11_strongly_typed_enumerations.Class1()
+enumCheck(class1:class1Test1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13)
+enumCheck(class1:class1Test2(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c), 1121)
+--enumCheck(class1:class1Test3(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val5f), 3121)
+
+enumCheck(cpp11_strongly_typed_enumerations.globalTest1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13)
+enumCheck(cpp11_strongly_typed_enumerations.globalTest2(cpp11_strongly_typed_enumerations.Class1.Enum12_Val5c), 1121)
+--enumCheck(globalTest3(cpp11_strongly_typed_enumerations.Class1.Struct1.Enum12_Val5f), 3121)
+
diff --git a/Examples/test-suite/lua/cpp_basic_runme.lua b/Examples/test-suite/lua/cpp_basic_runme.lua
index c7e0325..5a0e1c6 100644
--- a/Examples/test-suite/lua/cpp_basic_runme.lua
+++ b/Examples/test-suite/lua/cpp_basic_runme.lua
@@ -86,3 +86,14 @@
 assert( f2_name == "Foo" )
 assert( f3_name == "Foo" )
 assert( f4_name == "FooSubSub" )
+
+-- Test __eq implementation supplied by default
+
+-- eq_f1 and eq_f2 must be different userdata with same Foo* pointer. If eq_f1 and eq_f2 are the same userdata (e.g.)
+-- > eq_f1 = smth
+-- > eq_f2 = eq_f1
+-- then default Lua equality comparison kicks in and considers them equal. Access to global_fptr is actually a
+-- function call (internally) and it returns new userdata each time.
+eq_f1 = cb.Bar.global_fptr
+eq_f2 = cb.Bar.global_fptr
+assert( eq_f1 == eq_f2 )
diff --git a/Examples/test-suite/lua/equality_runme.lua b/Examples/test-suite/lua/equality_runme.lua
new file mode 100644
index 0000000..cadbede
--- /dev/null
+++ b/Examples/test-suite/lua/equality_runme.lua
@@ -0,0 +1,47 @@
+require("import")	-- the import fn
+import("equality")	-- import code
+eq=equality    -- renaming import
+
+-- catch "undefined" global variables
+local env = _ENV -- Lua 5.2
+if not env then env = getfenv () end -- Lua 5.1
+setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
+
+-- === No equality operator ===
+
+-- logically same data without equality operator are not equal
+p1 = eq.MakePoint(10,9);
+p2 = eq.MakePoint(10,9);
+
+assert( p1 ~= p2 );
+
+-- different wrappers for same Point* are equal
+p3 = eq.GetZeroPointPtr()
+p4 = eq.GetZeroPointPtr()
+
+assert( p3 == p4 )
+
+
+-- === Logically correct equality operator ===
+
+ed1 = eq.EqualOpDefined(10)
+ed2 = eq.EqualOpDefined(10)
+ed3 = eq.EqualOpDefined(15)
+
+assert( ed1 == ed2 )
+assert( ed1 ~= ed3 )
+
+
+-- === Logically incorrect equality operator ===
+
+ew1 = eq.EqualOpWrong()
+ew2 = eq.EqualOpWrong()
+
+assert( ew1 ~= ew2 );
+
+ew3 = eq.EqualOpWrong.GetStaticObject()
+ew4 = eq.EqualOpWrong.GetStaticObject()
+
+-- Even though these are pointers to same object, operator== overload should
+-- state that they are not equal
+assert( ew3 ~= ew4 )
diff --git a/Examples/test-suite/lua/operator_overload_runme.lua b/Examples/test-suite/lua/operator_overload_runme.lua
index 5ba06ff..c34c090 100644
--- a/Examples/test-suite/lua/operator_overload_runme.lua
+++ b/Examples/test-suite/lua/operator_overload_runme.lua
@@ -1,4 +1,4 @@
--- demo of lua swig capacilities (operator overloading)
+-- demo of lua swig capacities (operator overloading)
 require("import")	-- the import fn
 import("operator_overload")	-- import lib
 
@@ -33,7 +33,7 @@
 assert(b>d)
 assert(b>=d)
 
--- lua does not support += operators: skiping
+-- lua does not support += operators: skipping
 
 -- test +
 f=Op(1)
@@ -50,7 +50,7 @@
 
 --lua 5.0.2 defines that unary - is __unm(self,nil)
 --lua 5.1.2 defines that unary - is __unm(self,self)
---C++ expectes unary - as operator-()
+--C++ expects unary - as operator-()
 --however the latest version of SWIG strictly checks the number of args
 --and will complain if too many args are provided
 --therefore disabling these tests for now
@@ -79,7 +79,7 @@
 assert(tostring(Op(-3))=="Op(-3)")
 
 
--- check that operator overloads are correctly propogated down inheritance hierarchy
+-- check that operator overloads are correctly propagated down inheritance hierarchy
 
 a_d=OpDerived()
 b_d=OpDerived(5)
diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in
index fcaf33a..da92f76 100644
--- a/Examples/test-suite/mzscheme/Makefile.in
+++ b/Examples/test-suite/mzscheme/Makefile.in
@@ -5,6 +5,7 @@
 LANGUAGE     = mzscheme
 MZSCHEME     = mzscheme
 SCRIPTSUFFIX = _runme.scm
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -18,7 +19,7 @@
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -28,7 +29,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -36,13 +37,13 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.scm appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(MZSCHEME) -r $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(MZSCHEME) -r $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean
 %.clean:
-	
+	@exit 0
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile mzscheme_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" mzscheme_clean
diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i
index ccb7eca..fe40547 100644
--- a/Examples/test-suite/nested_class.i
+++ b/Examples/test-suite/nested_class.i
@@ -49,6 +49,9 @@
   struct {
     Integer b;
   };
+#else
+  Integer a;
+  Integer b;
 #endif
 
   union {
@@ -164,6 +167,9 @@
   public:
     Integer yy;
   };
+#else
+  Integer xx;
+  Integer yy;
 #endif
 
   ///////////////////////////////////////////
diff --git a/Examples/test-suite/nested_extend_c.i b/Examples/test-suite/nested_extend_c.i
new file mode 100644
index 0000000..64727b9
--- /dev/null
+++ b/Examples/test-suite/nested_extend_c.i
@@ -0,0 +1,102 @@
+%module nested_extend_c
+
+#if !defined(SWIGOCTAVE) && !defined(SWIG_JAVASCRIPT_V8)
+%extend hiA {
+  hiA() {
+   union hiA *self = (union hiA *)malloc(sizeof(union hiA));
+   self->c = 'h';
+   return self;
+  }
+  char hi_extend() {
+    return $self->c;
+  }
+  static const long swig_size = sizeof(union hiA);
+}
+%extend lowA {
+  lowA() {
+    struct lowA *self = (struct lowA *)malloc(sizeof(struct lowA));
+    self->name = 0;
+    self->num = 99;
+    return self;
+  }
+  int low_extend() {
+    return $self->num;
+  }
+  static const long swig_size = sizeof(struct lowA);
+}
+
+%extend hiB {
+  hiB() {
+   union hiB *self = (union hiB *)malloc(sizeof(union hiB));
+   self->c = 'h';
+   return self;
+  }
+  char hi_extend() {
+    return $self->c;
+  }
+  static const long swig_size = sizeof(union hiB);
+}
+%extend lowB {
+  lowB() {
+    struct lowB *self = (struct lowB *)malloc(sizeof(struct lowB));
+    self->name = 0;
+    self->num = 99;
+    return self;
+  }
+  int low_extend() {
+    return $self->num;
+  }
+  static const long swig_size = sizeof(struct lowB);
+}
+
+%extend FOO_bar {
+    void bar_extend()	{
+        $self->d = 1;
+    }
+};
+%extend NestedA {
+  static const long swig_size = sizeof(struct NestedA);
+}
+
+#endif
+
+%inline %{
+typedef struct NestedA {
+    int a;
+    union hiA {
+        char c;
+        int d;
+    } hiA_instance;
+
+    struct lowA {
+        char *name;
+        int num;
+    } lowA_instance;
+} NestedA;
+
+typedef struct {
+    int a;
+    union hiB {
+        char c;
+        int d;
+    } hiB_instance;
+
+    struct lowB {
+        char *name;
+        int num;
+    } lowB_instance;
+} NestedB;
+
+typedef struct {
+    int a;
+    union {
+        char c;
+        int d;
+    } bar;
+} FOO;
+
+struct {
+   int i;
+} THING;
+%}
+
diff --git a/Examples/test-suite/nested_scope.i b/Examples/test-suite/nested_scope.i
index 7894783..bd66eec 100644
--- a/Examples/test-suite/nested_scope.i
+++ b/Examples/test-suite/nested_scope.i
@@ -26,4 +26,42 @@
 #endif
 	};
 }
+		class Outer1 {
+			struct Nested1;
+		public:
+			struct Nested2;
+#ifdef __clang__
+		struct Nested2 {
+			int data;
+		};
+#endif
+			template <class T> class AbstractClass;
+			class Real;
+		};
+#ifndef __clang__
+		struct Outer1::Nested2 {
+			int data;
+		};
+#endif
+		
+		class Klass {
+		public:
+			template <class T> class AbstractClass;
+			class Real;
+		};
+
+		template <class T> class Klass::AbstractClass {
+		public:
+			virtual void Method() = 0;
+			virtual ~AbstractClass() {}
+		};
+%} 
+
+%template(abstract_int) Klass::AbstractClass <int>;
+
+%inline %{
+		class Klass::Real : public AbstractClass <int> {
+		public:
+			virtual void Method() {}
+		};
 %}
diff --git a/Examples/test-suite/nested_template_base.i b/Examples/test-suite/nested_template_base.i
new file mode 100644
index 0000000..0b02722
--- /dev/null
+++ b/Examples/test-suite/nested_template_base.i
@@ -0,0 +1,38 @@
+%module nested_template_base
+
+%inline %{
+  template <class T> class OuterT {
+    public:
+      T outer(T t) { return t; }
+  };
+%}
+ 
+// The %template goes after OuterT and before OuterC as OuterC::InnerC's base is handled inside OuterC
+%template(OuterTInnerS) OuterT<OuterC::InnerS>;
+
+#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
+%feature("flatnested") OuterC::InnerS;
+%feature("flatnested") OuterC::InnerC;
+#endif
+
+
+%inline %{
+  class OuterC {
+  public:
+    struct InnerS;
+    class InnerC;
+  };
+ 
+  struct OuterC::InnerS {
+    int val;
+    InnerS(int val = 0) : val(val) {}
+  };
+
+
+  class OuterC::InnerC : public OuterT<InnerS> {
+  public:
+    OuterT<InnerS>& innerc() {
+      return *this;
+    }
+  }; 
+%}
diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in
index f16c3da..9a4e008 100644
--- a/Examples/test-suite/ocaml/Makefile.in
+++ b/Examples/test-suite/ocaml/Makefile.in
@@ -6,22 +6,23 @@
 OCAMLC       = ocamlc
 VARIANT      = _static
 SCRIPTSUFFIX = _runme.ml
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
 
-C_TEST_CASES = 
+C_TEST_CASES =
 
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \
 	     -f $(top_srcdir)/Examples/test-suite/$*.list ] ; then \
-		$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+		$(COMPILETOOL) $(OCAMLC) -c $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 		$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme; \
-	elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-		$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+		$(COMPILETOOL) $(OCAMLC) -c $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 		$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \
 		$(RUNTOOL) ./runme; \
-	fi ; 
+	fi ;
 
 check_quant:
 	cat /dev/null > testing
@@ -80,4 +81,4 @@
 	@rm -f $*.ml $*.mli;
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile ocaml_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" ocaml_clean
diff --git a/Examples/test-suite/ocaml/makedebugtop b/Examples/test-suite/ocaml/makedebugtop
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in
index dc309e8..fbffd24 100644
--- a/Examples/test-suite/octave/Makefile.in
+++ b/Examples/test-suite/octave/Makefile.in
@@ -5,6 +5,7 @@
 LANGUAGE     = octave
 OCTAVE       = @OCTAVE@
 SCRIPTSUFFIX = _runme.m
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -21,7 +22,7 @@
 	li_std_set \
 	li_std_stream
 
-#C_TEST_CASES += 
+#C_TEST_CASES +=
 
 #
 # This test only works with modern C compilers
@@ -33,13 +34,13 @@
 
 # Overridden variables here
 LIBS       = -L.
-CSRCS      = $(srcdir)/octave_empty.c
+CSRCS      = octave_empty.c
 
 # Custom tests - tests with additional commandline options
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -49,7 +50,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -57,8 +58,8 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.m appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(RUNTOOL) $(OCTAVE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(RUNTOOL) $(OCTAVE) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean: remove the generated .m file
@@ -67,18 +68,18 @@
 	@rm -f $*.m;
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile octave_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" octave_clean
 
 cvsignore:
 	@echo '*wrap* *.mc *.so *.dll *.exp *.lib'
 	@echo Makefile
-	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.m; done 
-	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.m CVS/Entries ; then echo $${i}_runme.m; fi; done 
-	@echo clientdata_prop_a.m 
-	@echo clientdata_prop_b.m 
-	@echo imports_a.m 
-	@echo imports_b.m 
-	@echo mod_a.m mod_b.m 
+	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.m; done
+	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.m CVS/Entries ; then echo $${i}_runme.m; fi; done
+	@echo clientdata_prop_a.m
+	@echo clientdata_prop_b.m
+	@echo imports_a.m
+	@echo imports_b.m
+	@echo mod_a.m mod_b.m
 	@echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.m hugemod_b.m hugemod_runme.m
 	@echo template_typedef_import.m
 
diff --git a/Examples/test-suite/octave/cpp11_strongly_typed_enumerations_runme.m b/Examples/test-suite/octave/cpp11_strongly_typed_enumerations_runme.m
new file mode 100644
index 0000000..f66d3d5
--- /dev/null
+++ b/Examples/test-suite/octave/cpp11_strongly_typed_enumerations_runme.m
@@ -0,0 +1,166 @@
+cpp11_strongly_typed_enumerations
+
+function newvalue = enumCheck(actual, expected)
+  if (actual != expected);
+    error("Enum value mismatch. Expected: %d Actual: %d", expected, actual);
+  endif
+  newvalue = expected + 1;
+end
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val3, 13);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val5a, 13);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val6a, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val3, 23);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val5b, 23);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val6b, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Val3, 43);
+val = enumCheck(cpp11_strongly_typed_enumerations.Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val3, 53);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val3, 63);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val3, 73);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val3, 83);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val1, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val2, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val3, 103);
+val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val4, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val1, 1121);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val2, 1122);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val5c, 1121);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val6c, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val1, 1131);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val2, 1132);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val5d, 1131);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val6d, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val1, 1141);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val2, 1142);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val5e, 1141);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val6e, val);
+
+# Requires nested class support to work
+#val = 0;
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val1, 3121);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val2, 3122);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val3, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val4, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val5f, 3121);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val6f, val);
+#
+#val = 0;
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val1, 3131);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val2, 3132);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val3, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val4, val);
+#
+#val = 0;
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val1, 3141);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val2, 3142);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val3, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val4, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val5g, 3141);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val6g, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val1, 2121);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val2, 2122);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val5h, 2121);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val6h, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val1, 2131);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val2, 2132);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val5i, 2131);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val6i, val);
+
+val = 0;
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val1, 2141);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val2, 2142);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val3, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val4, val);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val5j, 2141);
+val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val6j, val);
+
+# Requires nested class support to work
+#val = 0;
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val1, 4121);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val2, 4122);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val3, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val4, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val5k, 4121);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val6k, val);
+#
+#val = 0;
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val1, 4131);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val2, 4132);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val3, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val4, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val5l, 4131);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val6l, val);
+#
+#val = 0;
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val1, 4141);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val2, 4142);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val3, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val4, val);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val5m, 4141);
+#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val6m, val);
+
+class1 = Class1();
+enumCheck(class1.class1Test1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);
+enumCheck(class1.class1Test2(cpp11_strongly_typed_enumerations.Class1_Enum12_Val5c), 1121);
+#enumCheck(class1.class1Test3(cpp11_strongly_typed_enumerations.Class1_Struct1_Enum12_Val5f), 3121);
+
+enumCheck(cpp11_strongly_typed_enumerations.globalTest1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);
+enumCheck(cpp11_strongly_typed_enumerations.globalTest2(cpp11_strongly_typed_enumerations.Class1_Enum12_Val5c), 1121);
+#enumCheck(globalTest3(cpp11_strongly_typed_enumerations.Class1_Struct1_Enum12_Val5f), 3121);
+
diff --git a/Examples/test-suite/octave/director_detect_runme.m b/Examples/test-suite/octave/director_detect_runme.m
index f2d8c8d..2192571 100644
--- a/Examples/test-suite/octave/director_detect_runme.m
+++ b/Examples/test-suite/octave/director_detect_runme.m
@@ -1,7 +1,7 @@
 director_detect 
 
-global MyBar=@(val=2) \
-    subclass(director_detect.Bar(),'val',val,@get_value,@get_class,@just_do_it,@clone);
+global MyBar=@(val=2) subclass(director_detect.Bar(),'val',val,@get_value,@get_class,@just_do_it,@clone);
+
 function val=get_value(self)
     self.val = self.val + 1;
     val = self.val;
diff --git a/Examples/test-suite/octave/iadd_runme.m b/Examples/test-suite/octave/iadd_runme.m
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/octave/overload_complicated_runme.m b/Examples/test-suite/octave/overload_complicated_runme.m
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/overload_polymorphic.i b/Examples/test-suite/overload_polymorphic.i
new file mode 100644
index 0000000..a1f123b
--- /dev/null
+++ b/Examples/test-suite/overload_polymorphic.i
@@ -0,0 +1,22 @@
+%module overload_polymorphic
+
+%inline %{
+
+class Base {
+public:
+	Base(){}
+	virtual ~Base(){}
+};
+
+class Derived : public Base {
+public:
+	Derived(){}
+	virtual ~Derived(){}
+};
+
+
+
+int test(Base* base){ return 0;}
+int test(int hello){ return 1; }
+
+%}
diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in
index 67eaf5c..ccd12d6 100644
--- a/Examples/test-suite/perl5/Makefile.in
+++ b/Examples/test-suite/perl5/Makefile.in
@@ -5,7 +5,8 @@
 LANGUAGE     = perl5
 PERL         = @PERL@
 SCRIPTSUFFIX = _runme.pl
-TEST_RUNNER  = run-perl-test.pl
+TEST_RUNNER  = $(srcdir)/run-perl-test.pl
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -16,6 +17,7 @@
 	li_cstring \
 	li_cdata_carrays \
 	li_reference \
+	director_nestedmodule \
 
 C_TEST_CASES += \
 	li_cdata \
@@ -31,7 +33,7 @@
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -41,7 +43,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -49,8 +51,8 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.pl appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PERL) $(TEST_RUNNER) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PERL) $(TEST_RUNNER) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean: remove the generated .pm file
@@ -58,4 +60,4 @@
 	@rm -f $*.pm;
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile perl5_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" perl5_clean
diff --git a/Examples/test-suite/perl5/char_binary_runme.pl b/Examples/test-suite/perl5/char_binary_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/class_ignore_runme.pl b/Examples/test-suite/perl5/class_ignore_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/contract_runme.pl b/Examples/test-suite/perl5/contract_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/cpp11_strongly_typed_enumerations_runme.pl b/Examples/test-suite/perl5/cpp11_strongly_typed_enumerations_runme.pl
new file mode 100644
index 0000000..db19bbf
--- /dev/null
+++ b/Examples/test-suite/perl5/cpp11_strongly_typed_enumerations_runme.pl
@@ -0,0 +1,168 @@
+use strict;
+use warnings;
+use Test::More tests => 78;
+BEGIN { use_ok('cpp11_strongly_typed_enumerations') }
+require_ok('cpp11_strongly_typed_enumerations');
+
+sub enumCheck { my($actual, $expected) = @_;
+  is($actual, $expected);
+  return $expected + 1;
+}
+
+my $val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val1, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val2, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val3, 13);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val4, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val5a, 13);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum1_Val6a, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val1, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val2, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val3, 23);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val4, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val5b, 23);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum2_Val6b, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Val1, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Val2, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Val3, 43);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Val4, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum5_Val1, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum5_Val2, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum5_Val3, 53);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum5_Val4, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum6_Val1, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum6_Val2, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum6_Val3, 63);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum6_Val4, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum7td_Val1, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum7td_Val2, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum7td_Val3, 73);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum7td_Val4, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum8_Val1, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum8_Val2, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum8_Val3, 83);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum8_Val4, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum10_Val1, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum10_Val2, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum10_Val3, 103);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Enum10_Val4, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val1, 1121);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val2, 1122);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val3, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val4, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val5c, 1121);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum12_Val6c, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val1, 1131);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val2, 1132);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val3, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val4, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val5d, 1131);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Val6d, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val1, 1141);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val2, 1142);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val3, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val4, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val5e, 1141);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Enum14_Val6e, $val);
+
+# Requires nested class support to work
+#$val = 0;
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val1, 3121);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val2, 3122);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val3, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val4, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val5f, 3121);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val6f, $val);
+#
+#$val = 0;
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Val1, 3131);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Val2, 3132);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Val3, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Val4, $val);
+#
+#$val = 0;
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val1, 3141);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val2, 3142);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val3, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val4, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val5g, 3141);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum14_Val6g, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val1, 2121);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val2, 2122);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val3, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val4, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val5h, 2121);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum12_Val6h, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val1, 2131);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val2, 2132);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val3, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val4, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val5i, 2131);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Val6i, $val);
+
+$val = 0;
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val1, 2141);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val2, 2142);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val3, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val4, $val);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val5j, 2141);
+$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Enum14_Val6j, $val);
+
+# Requires nested class support to work
+#$val = 0;
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val1, 4121);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val2, 4122);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val3, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val4, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val5k, 4121);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum12_Val6k, $val);
+#
+#$val = 0;
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val1, 4131);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val2, 4132);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val3, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val4, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val5l, 4131);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Val6l, $val);
+#
+#$val = 0;
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val1, 4141);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val2, 4142);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val3, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val4, $val);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val5m, 4141);
+#$val = enumCheck($cpp11_strongly_typed_enumerations::Class2::Struct1::Enum14_Val6m, $val);
+
+my $class1 = cpp11_strongly_typed_enumerations::Class1->new();
+enumCheck($class1->class1Test1($cpp11_strongly_typed_enumerations::Enum1_Val5a), 13);
+enumCheck($class1->class1Test2($cpp11_strongly_typed_enumerations::Class1::Enum12_Val5c), 1121);
+#enumCheck($class1->class1Test3($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val5f), 3121);
+
+enumCheck(cpp11_strongly_typed_enumerations::globalTest1($cpp11_strongly_typed_enumerations::Enum1_Val5a), 13);
+enumCheck(cpp11_strongly_typed_enumerations::globalTest2($cpp11_strongly_typed_enumerations::Class1::Enum12_Val5c), 1121);
+#enumCheck(cpp11_strongly_typed_enumerations::globalTest3($cpp11_strongly_typed_enumerations::Class1::Struct1::Enum12_Val5f), 3121);
+
diff --git a/Examples/test-suite/perl5/enum_template_runme.pl b/Examples/test-suite/perl5/enum_template_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/grouping_runme.pl b/Examples/test-suite/perl5/grouping_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/ignore_parameter_runme.pl b/Examples/test-suite/perl5/ignore_parameter_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/inherit_missing_runme.pl b/Examples/test-suite/perl5/inherit_missing_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/li_std_except_runme.pl b/Examples/test-suite/perl5/li_std_except_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/minherit_runme.pl b/Examples/test-suite/perl5/minherit_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/naturalvar_runme.pl b/Examples/test-suite/perl5/naturalvar_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/preproc_runme.pl b/Examples/test-suite/perl5/preproc_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/primitive_types_runme.pl b/Examples/test-suite/perl5/primitive_types_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/reference_global_vars_runme.pl b/Examples/test-suite/perl5/reference_global_vars_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/rename_scope_runme.pl b/Examples/test-suite/perl5/rename_scope_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/return_const_value_runme.pl b/Examples/test-suite/perl5/return_const_value_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/run-perl-test.pl b/Examples/test-suite/perl5/run-perl-test.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/sizet_runme.pl b/Examples/test-suite/perl5/sizet_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/sneaky1_runme.pl b/Examples/test-suite/perl5/sneaky1_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/template_typedef_cplx2_runme.pl b/Examples/test-suite/perl5/template_typedef_cplx2_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/typedef_class_runme.pl b/Examples/test-suite/perl5/typedef_class_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/typename_runme.pl b/Examples/test-suite/perl5/typename_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/using1_runme.pl b/Examples/test-suite/perl5/using1_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/using2_runme.pl b/Examples/test-suite/perl5/using2_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/perl5/wrapmacro_runme.pl b/Examples/test-suite/perl5/wrapmacro_runme.pl
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in
index fcdcac2..c3f8af5 100644
--- a/Examples/test-suite/php/Makefile.in
+++ b/Examples/test-suite/php/Makefile.in
@@ -4,11 +4,13 @@
 
 LANGUAGE     = php
 SCRIPTSUFFIX = _runme.php
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
 
 CPP_TEST_CASES += \
+	php_iterator \
 	php_namewarn_rename \
 
 include $(srcdir)/../common.mk
@@ -29,7 +31,7 @@
 missingtests: missingcpptests missingctests
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	+$(run_testcase)
@@ -39,7 +41,7 @@
 	+$(swig_and_compile_c)
 	+$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	+$(run_testcase)
@@ -56,15 +58,21 @@
 # Runs the testcase. Tries to run testcase_runme.php, and if that's not
 # found, runs testcase.php, except for multicpptests.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \
-	elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
-	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL="$(RUNTOOL)" php_run; \
+	elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
+	  $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php RUNTOOL="$(RUNTOOL)" php_run; \
 	fi
 
 # Clean: remove the generated .php file
 %.clean:
-	@rm -f $*.php;
+	@rm -f $*.php php_$*.h
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" php_clean
+	rm -f clientdata_prop_a.php clientdata_prop_b.php php_clientdata_prop_a.h php_clientdata_prop_b.h
+	rm -f import_stl_a.php import_stl_b.php php_import_stl_a.h php_import_stl_b.h
+	rm -f imports_a.php imports_b.php php_imports_a.h php_imports_b.h
+	rm -f mod_a.php mod_b.php php_mod_a.h php_mod_b.h
+	rm -f multi_import_a.php multi_import_b.php php_multi_import_a.h php_multi_import_b.h
+	rm -f packageoption_a.php packageoption_b.php packageoption_c.php php_packageoption_a.h php_packageoption_b.h php_packageoption_c.h
diff --git a/Examples/test-suite/php/cpp11_strongly_typed_enumerations_runme.php b/Examples/test-suite/php/cpp11_strongly_typed_enumerations_runme.php
new file mode 100644
index 0000000..bee59b2
--- /dev/null
+++ b/Examples/test-suite/php/cpp11_strongly_typed_enumerations_runme.php
@@ -0,0 +1,169 @@
+<?php
+
+require "tests.php";
+require "cpp11_strongly_typed_enumerations.php";
+
+function enumCheck($actual, $expected) {
+  check::equal($actual, $expected, "Enum value mismatch");
+  return $expected + 1;
+}
+
+
+$val = 0;
+$val = enumCheck(Enum1_Val1, $val);
+$val = enumCheck(Enum1_Val2, $val);
+$val = enumCheck(Enum1_Val3, 13);
+$val = enumCheck(Enum1_Val4, $val);
+$val = enumCheck(Enum1_Val5a, 13);
+$val = enumCheck(Enum1_Val6a, $val);
+
+$val = 0;
+$val = enumCheck(Enum2_Val1, $val);
+$val = enumCheck(Enum2_Val2, $val);
+$val = enumCheck(Enum2_Val3, 23);
+$val = enumCheck(Enum2_Val4, $val);
+$val = enumCheck(Enum2_Val5b, 23);
+$val = enumCheck(Enum2_Val6b, $val);
+
+$val = 0;
+$val = enumCheck(Val1, $val);
+$val = enumCheck(Val2, $val);
+$val = enumCheck(Val3, 43);
+$val = enumCheck(Val4, $val);
+
+$val = 0;
+$val = enumCheck(Enum5_Val1, $val);
+$val = enumCheck(Enum5_Val2, $val);
+$val = enumCheck(Enum5_Val3, 53);
+$val = enumCheck(Enum5_Val4, $val);
+
+$val = 0;
+$val = enumCheck(Enum6_Val1, $val);
+$val = enumCheck(Enum6_Val2, $val);
+$val = enumCheck(Enum6_Val3, 63);
+$val = enumCheck(Enum6_Val4, $val);
+
+$val = 0;
+$val = enumCheck(Enum7td_Val1, $val);
+$val = enumCheck(Enum7td_Val2, $val);
+$val = enumCheck(Enum7td_Val3, 73);
+$val = enumCheck(Enum7td_Val4, $val);
+
+$val = 0;
+$val = enumCheck(Enum8_Val1, $val);
+$val = enumCheck(Enum8_Val2, $val);
+$val = enumCheck(Enum8_Val3, 83);
+$val = enumCheck(Enum8_Val4, $val);
+
+$val = 0;
+$val = enumCheck(Enum10_Val1, $val);
+$val = enumCheck(Enum10_Val2, $val);
+$val = enumCheck(Enum10_Val3, 103);
+$val = enumCheck(Enum10_Val4, $val);
+
+$val = 0;
+$val = enumCheck(Class1::Enum12_Val1, 1121);
+$val = enumCheck(Class1::Enum12_Val2, 1122);
+$val = enumCheck(Class1::Enum12_Val3, $val);
+$val = enumCheck(Class1::Enum12_Val4, $val);
+$val = enumCheck(Class1::Enum12_Val5c, 1121);
+$val = enumCheck(Class1::Enum12_Val6c, $val);
+
+$val = 0;
+$val = enumCheck(Class1::Val1, 1131);
+$val = enumCheck(Class1::Val2, 1132);
+$val = enumCheck(Class1::Val3, $val);
+$val = enumCheck(Class1::Val4, $val);
+$val = enumCheck(Class1::Val5d, 1131);
+$val = enumCheck(Class1::Val6d, $val);
+
+$val = 0;
+$val = enumCheck(Class1::Enum14_Val1, 1141);
+$val = enumCheck(Class1::Enum14_Val2, 1142);
+$val = enumCheck(Class1::Enum14_Val3, $val);
+$val = enumCheck(Class1::Enum14_Val4, $val);
+$val = enumCheck(Class1::Enum14_Val5e, 1141);
+$val = enumCheck(Class1::Enum14_Val6e, $val);
+
+# Requires nested class support to work
+#$val = 0;
+#$val = enumCheck(Class1::Struct1.Enum12_Val1, 3121);
+#$val = enumCheck(Class1::Struct1.Enum12_Val2, 3122);
+#$val = enumCheck(Class1::Struct1.Enum12_Val3, $val);
+#$val = enumCheck(Class1::Struct1.Enum12_Val4, $val);
+#$val = enumCheck(Class1::Struct1.Enum12_Val5f, 3121);
+#$val = enumCheck(Class1::Struct1.Enum12_Val6f, $val);
+#
+#$val = 0;
+#$val = enumCheck(Class1::Struct1.$val1, 3131);
+#$val = enumCheck(Class1::Struct1.$val2, 3132);
+#$val = enumCheck(Class1::Struct1.$val3, $val);
+#$val = enumCheck(Class1::Struct1.$val4, $val);
+#
+#$val = 0;
+#$val = enumCheck(Class1::Struct1.Enum14_Val1, 3141);
+#$val = enumCheck(Class1::Struct1.Enum14_Val2, 3142);
+#$val = enumCheck(Class1::Struct1.Enum14_Val3, $val);
+#$val = enumCheck(Class1::Struct1.Enum14_Val4, $val);
+#$val = enumCheck(Class1::Struct1.Enum14_Val5g, 3141);
+#$val = enumCheck(Class1::Struct1.Enum14_Val6g, $val);
+
+$val = 0;
+$val = enumCheck(Class2::Enum12_Val1, 2121);
+$val = enumCheck(Class2::Enum12_Val2, 2122);
+$val = enumCheck(Class2::Enum12_Val3, $val);
+$val = enumCheck(Class2::Enum12_Val4, $val);
+$val = enumCheck(Class2::Enum12_Val5h, 2121);
+$val = enumCheck(Class2::Enum12_Val6h, $val);
+
+$val = 0;
+$val = enumCheck(Class2::Val1, 2131);
+$val = enumCheck(Class2::Val2, 2132);
+$val = enumCheck(Class2::Val3, $val);
+$val = enumCheck(Class2::Val4, $val);
+$val = enumCheck(Class2::Val5i, 2131);
+$val = enumCheck(Class2::Val6i, $val);
+
+$val = 0;
+$val = enumCheck(Class2::Enum14_Val1, 2141);
+$val = enumCheck(Class2::Enum14_Val2, 2142);
+$val = enumCheck(Class2::Enum14_Val3, $val);
+$val = enumCheck(Class2::Enum14_Val4, $val);
+$val = enumCheck(Class2::Enum14_Val5j, 2141);
+$val = enumCheck(Class2::Enum14_Val6j, $val);
+
+# Requires nested class support to work
+#$val = 0;
+#$val = enumCheck(Class2::Struct1.Enum12_Val1, 4121);
+#$val = enumCheck(Class2::Struct1.Enum12_Val2, 4122);
+#$val = enumCheck(Class2::Struct1.Enum12_Val3, $val);
+#$val = enumCheck(Class2::Struct1.Enum12_Val4, $val);
+#$val = enumCheck(Class2::Struct1.Enum12_Val5k, 4121);
+#$val = enumCheck(Class2::Struct1.Enum12_Val6k, $val);
+#
+#$val = 0;
+#$val = enumCheck(Class2::Struct1.$val1, 4131);
+#$val = enumCheck(Class2::Struct1.$val2, 4132);
+#$val = enumCheck(Class2::Struct1.$val3, $val);
+#$val = enumCheck(Class2::Struct1.$val4, $val);
+#$val = enumCheck(Class2::Struct1.$val5l, 4131);
+#$val = enumCheck(Class2::Struct1.$val6l, $val);
+#
+#$val = 0;
+#$val = enumCheck(Class2::Struct1.Enum14_Val1, 4141);
+#$val = enumCheck(Class2::Struct1.Enum14_Val2, 4142);
+#$val = enumCheck(Class2::Struct1.Enum14_Val3, $val);
+#$val = enumCheck(Class2::Struct1.Enum14_Val4, $val);
+#$val = enumCheck(Class2::Struct1.Enum14_Val5m, 4141);
+#$val = enumCheck(Class2::Struct1.Enum14_Val6m, $val);
+
+$class1 = new Class1();
+enumCheck($class1->class1Test1(Enum1_Val5a), 13);
+enumCheck($class1->class1Test2(Class1::Enum12_Val5c), 1121);
+#enumCheck($class1.class1Test3(Class1::Struct1.Enum12_Val5f), 3121);
+
+enumCheck(globalTest1(Enum1_Val5a), 13);
+enumCheck(globalTest2(Class1::Enum12_Val5c), 1121);
+#enumCheck(globalTest3(Class1::Struct1.Enum12_Val5f), 3121);
+
+?>
diff --git a/Examples/test-suite/php/director_exception_runme.php b/Examples/test-suite/php/director_exception_runme.php
index 33e6e9b..8b852c2 100644
--- a/Examples/test-suite/php/director_exception_runme.php
+++ b/Examples/test-suite/php/director_exception_runme.php
@@ -4,9 +4,9 @@
 require "director_exception.php";
 
 // No new functions
-check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang));
+check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin));
 // No new classes
-check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar));
+check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar,ReturnAllTypes));
 // now new vars
 check::globals(array());
 
@@ -74,5 +74,54 @@
 } catch (Exception1 $e1) {
 }
 
+// Check that we can throw exceptions from director methods (this didn't used
+// to work in all cases, as the exception gets "set" in PHP and the method
+// then returns PHP NULL, which the directorout template may fail to convert.
+
+class Bad extends ReturnAllTypes {
+  function return_int() { throw new Exception("bad int"); }
+  function return_double() { throw new Exception("bad double"); }
+  function return_const_char_star() { throw new Exception("bad const_char_star"); }
+  function return_std_string() { throw new Exception("bad std_string"); }
+  function return_Bar() { throw new Exception("bad Bar"); }
+}
+
+$bad = new Bad();
+
+try {
+    $bad->call_int();
+    check::fail("Exception wasn't propagated from Bad::return_int()");
+} catch (Exception $e) {
+    check::equal($e->getMessage(), "bad int", "propagated exception incorrect");
+}
+
+try {
+    $bad->call_double();
+    check::fail("Exception wasn't propagated from Bad::return_double()");
+} catch (Exception $e) {
+    check::equal($e->getMessage(), "bad double", "propagated exception incorrect");
+}
+
+try {
+    $bad->call_const_char_star();
+    check::fail("Exception wasn't propagated from Bad::return_const_char_star()");
+} catch (Exception $e) {
+    check::equal($e->getMessage(), "bad const_char_star", "propagated exception incorrect");
+}
+
+try {
+    $bad->call_std_string();
+    check::fail("Exception wasn't propagated from Bad::return_std_string()");
+} catch (Exception $e) {
+    check::equal($e->getMessage(), "bad std_string", "propagated exception incorrect");
+}
+
+try {
+    $bad->call_Bar();
+    check::fail("Exception wasn't propagated from Bad::return_Bar()");
+} catch (Exception $e) {
+    check::equal($e->getMessage(), "bad Bar", "propagated exception incorrect");
+}
+
 check::done();
 ?>
diff --git a/Examples/test-suite/php/exception_order_runme.php b/Examples/test-suite/php/exception_order_runme.php
index a835981..acb8356 100644
--- a/Examples/test-suite/php/exception_order_runme.php
+++ b/Examples/test-suite/php/exception_order_runme.php
@@ -2,7 +2,7 @@
 require "tests.php";
 require "exception_order.php";
 
-check::functions(array(a_foo,a_bar,a_foobar,a_barfoo));
+check::functions(array(a_foo,a_bar,a_foobar,a_barfoo,is_python_builtin));
 check::classes(array(A,E1,E2,E3,exception_order,ET_i,ET_d));
 check::globals(array(efoovar,foovar,cfoovar,a_sfoovar,a_foovar,a_efoovar));
 
diff --git a/Examples/test-suite/php/import_nomodule_runme.php b/Examples/test-suite/php/import_nomodule_runme.php
index 84191fb..41836ba 100644
--- a/Examples/test-suite/php/import_nomodule_runme.php
+++ b/Examples/test-suite/php/import_nomodule_runme.php
@@ -3,7 +3,7 @@
 require "import_nomodule.php";
 
 // No new functions
-check::functions(array(create_foo,delete_foo,test1));
+check::functions(array(create_foo,delete_foo,test1,is_python_builtin));
 // No new classes
 check::classes(array(import_nomodule,Bar));
 // now new vars
diff --git a/Examples/test-suite/php/php_iterator_runme.php b/Examples/test-suite/php/php_iterator_runme.php
new file mode 100644
index 0000000..d69a5b3
--- /dev/null
+++ b/Examples/test-suite/php/php_iterator_runme.php
@@ -0,0 +1,24 @@
+<?php
+
+require "tests.php";
+require "php_iterator.php";
+
+check::functions(array(myiterator_rewind,myiterator_key,myiterator_current,myiterator_next,myiterator_valid));
+check::classes(array(MyIterator));
+// No new global variables.
+check::globals(array());
+
+$s = '';
+foreach (new MyIterator(1, 6) as $i) {
+  $s .= $i;
+}
+check::equal($s, '12345', 'Simple iteration failed');
+
+$s = '';
+foreach (new MyIterator(2, 5) as $k => $v) {
+  $s .= "($k=>$v)";
+}
+check::equal($s, '(0=>2)(1=>3)(2=>4)', 'Simple iteration failed');
+
+check::done();
+?>
diff --git a/Examples/test-suite/php/threads_exception_runme.php b/Examples/test-suite/php/threads_exception_runme.php
index 31148a1..9e4d04e 100644
--- a/Examples/test-suite/php/threads_exception_runme.php
+++ b/Examples/test-suite/php/threads_exception_runme.php
@@ -4,9 +4,9 @@
 require "threads_exception.php";
 
 // Check functions
-check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi));
+check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
 // Check classes.
-check::classes(array(Exc,Test));
+check::classes(array(Exc,Test,threads_exception));
 // Chek globals.
 check::globals(array(exc_code,exc_msg));
 
diff --git a/Examples/test-suite/php_iterator.i b/Examples/test-suite/php_iterator.i
new file mode 100644
index 0000000..43ab68b
--- /dev/null
+++ b/Examples/test-suite/php_iterator.i
@@ -0,0 +1,20 @@
+/* php_iterator.i - PHP-specific testcase for wrapping to a PHP Iterator */
+%module php_iterator
+
+%typemap("phpinterfaces") MyIterator "Iterator";
+
+%inline %{
+
+class MyIterator {
+  int i, from, to;
+public:
+  MyIterator(int from_, int to_)
+    : i(from_), from(from_), to(to_) { }
+  void rewind() { i = from; }
+  bool valid() const { return i != to; }
+  int key() const { return i - from; }
+  int current() const { return i; }
+  void next() { ++i; }
+};
+
+%}
diff --git a/Examples/test-suite/pike/Makefile.in b/Examples/test-suite/pike/Makefile.in
index 389dc74..92054dd 100644
--- a/Examples/test-suite/pike/Makefile.in
+++ b/Examples/test-suite/pike/Makefile.in
@@ -5,6 +5,7 @@
 LANGUAGE     = pike
 PIKE         = pike
 SCRIPTSUFFIX = _runme.pike
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -18,7 +19,7 @@
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -28,7 +29,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -36,8 +37,8 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.pike appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PIKE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PIKE) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean: remove the generated .pike file
@@ -45,5 +46,4 @@
 	@rm -f $*.pike;
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile pike_clean
-
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" pike_clean
diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i
index e052bff..779c41e 100644
--- a/Examples/test-suite/preproc.i
+++ b/Examples/test-suite/preproc.i
@@ -346,3 +346,20 @@
   return tnt.val;
 }
 %}
+
+/* Null directive */
+# /* comment 1 */
+# // comment 2
+# /** comment 3 */
+# /* comment 4 */ /*comment 5*/
+# /** comment 6
+#
+# more comment 6 */
+# 
+#
+#	    
+int methodX(int x);
+%{
+int methodX(int x) { return x+100; }
+%}
+
diff --git a/Examples/test-suite/preproc_constants.i b/Examples/test-suite/preproc_constants.i
index 7507d63..ef5c35e 100644
--- a/Examples/test-suite/preproc_constants.i
+++ b/Examples/test-suite/preproc_constants.i
@@ -85,6 +85,8 @@
 /// constant assignment in enum
 #if defined(SWIGCSHARP)
 %csconstvalue("1<<2") kValue;
+#elif defined(SWIGD)
+%dconstvalue("1<<2") kValue;
 #endif
 
 %{
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index e7db32f..82a0e9d 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -10,10 +10,13 @@
 
 LANGUAGE     = python
 PYTHON       = $(PYBIN)
+PEP8         = @PEP8@
+PEP8_FLAGS   = --ignore=E402,E501,E30,W291,W391
 
 #*_runme.py for Python 2.x, *_runme3.py for Python 3.x
 PY2SCRIPTSUFFIX = _runme.py
 PY3SCRIPTSUFFIX = _runme3.py
+PY2TO3       = 2to3 -x import
 
 ifeq (,$(PY3))
   SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX)
@@ -25,10 +28,6 @@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
 
-
-PY2TO3 = 2to3 -x import 
-
-
 CPP_TEST_CASES += \
 	argcargvtest \
 	callback \
@@ -41,7 +40,6 @@
 	inout \
 	inplaceadd \
 	input \
-	kwargs_feature \
 	li_cstring \
 	li_cwstring \
 	li_factory \
@@ -88,82 +86,89 @@
 
 include $(srcdir)/../common.mk
 
-BUILTIN_BROKEN = \
-    default_constructor.cpptest \
-    director_exception.cpptest \
-    exception_order.cpptest \
-    li_std_string_extra.cpptest \
-    li_std_wstring.cpptest \
-    python_abstractbase.cpptest \
-    threads_exception.cpptest
-
-BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
-
-builtin-check : $(BUILTIN_NOT_BROKEN)
-
 # Overridden variables here
-LIBS       = -L.
+SCRIPTDIR    = .
+LIBS         = -L.
 VALGRIND_OPT += --suppressions=pythonswig.supp
 
 # Custom tests - tests with additional commandline options
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	+$(convert_testcase)
 	$(setup)
 	+$(swig_and_compile_cpp)
+	$(check_pep8)
 	$(run_testcase)
 
 %.ctest:
 	+$(convert_testcase)
 	$(setup)
 	+$(swig_and_compile_c)
+	$(check_pep8)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	+$(convert_testcase)
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
+	$(check_pep8_multi_cpp)
 	$(run_testcase)
 
 
-# Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file
-%$(PY3SCRIPTSUFFIX): %$(PY2SCRIPTSUFFIX)
-	cp $< $@
-	$(PY2TO3) -w $@ >/dev/null 2>&1 
-
 
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
 
-run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+py_runme  = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
+py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
 
-py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
-py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
+check_pep8 = \
+	if [ -n "$(PEP8)" ]; then \
+	  $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py;\
+	fi
+
+check_pep8_multi_cpp = \
+	if [ -n "$(PEP8)" ]; then \
+	  for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
+	  $(PEP8) $(PEP8_FLAGS) $$f.py; \
+	  done \
+	fi
+
+run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(py_runme)
 
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	if [ -f $(SCRIPTDIR)/$(py_runme) ]; then \
 	  $(run_python);\
 	fi
 
-ifeq (,$(PY3))
+# No copying/conversion needed for in-source-tree Python 2 scripts
+ifeq ($(SCRIPTDIR)|$(SCRIPTSUFFIX),$(srcdir)|$(PY2SCRIPTSUFFIX))
 convert_testcase =
 else
+
 convert_testcase = \
-	if [ -f $(py2_runme) ]; then \
-	  $(MAKE) -f $(srcdir)/Makefile $(py3_runme); \
+	if [ -f $(srcdir)/$(py2_runme) ]; then \
+	  $(MAKE) $(SCRIPTDIR)/$(py_runme); \
 	fi
+
+$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
+	test x$< = x$@ || cp $< $@ || exit 1
+	test x$(PY3) = x || $(PY2TO3) -w $@ >/dev/null 2>&1 || exit 1
+
 endif
 
 # Clean: remove the generated .py file
+# We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
 %.clean:
-	@rm -f $*.py;
-	@#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
-	@if [ -f $(py2_runme) ]; then rm -f $(py3_runme) $(py3_runme).bak; fi
+	@rm -f $*.py
+	@if test -f $(srcdir)/$(py2_runme); then rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; fi
+	@if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py2_runme); fi
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_clean
 	rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
 	rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py
 	rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py
@@ -172,12 +177,12 @@
 cvsignore:
 	@echo '*wrap* *.pyc *.so *.dll *.exp *.lib'
 	@echo Makefile
-	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done 
-	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done 
-	@echo clientdata_prop_a.py 
-	@echo clientdata_prop_b.py 
-	@echo imports_a.py 
-	@echo imports_b.py 
+	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done
+	@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done
+	@echo clientdata_prop_a.py
+	@echo clientdata_prop_b.py
+	@echo imports_a.py
+	@echo imports_b.py
 	@echo mod_a.py mod_b.py
 	@echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
 	@echo template_typedef_import.py
@@ -185,9 +190,8 @@
 hugemod_runme = hugemod$(SCRIPTPREFIX)
 
 hugemod:
-	perl hugemod.pl $(hugemod_runme) 
+	perl hugemod.pl $(hugemod_runme)
 	$(MAKE) hugemod_a.cpptest
 	$(MAKE) hugemod_b.cpptest
 	sh -c "time $(PYTHON) $(hugemod_runme)"
 	sh -c "time $(PYTHON) $(hugemod_runme)"
-
diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py
index 5776ad3..756b859 100644
--- a/Examples/test-suite/python/autodoc_runme.py
+++ b/Examples/test-suite/python/autodoc_runme.py
@@ -1,15 +1,26 @@
 from autodoc import *
 import sys
 
-def check(got, expected):
-  if expected != got:
-    raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got     : [" + str(got) + "]")
+def check(got, expected, expected_builtin = None, skip = False):
+  if not skip:
+    expect = expected
+    if is_python_builtin() and expected_builtin != None:
+      expect = expected_builtin
+    if expect != got:
+      raise RuntimeError("\n" + "Expected: [" + str(expect) + "]\n" + "Got     : [" + str(got) + "]")
 
-check(A.__doc__, "Proxy of C++ A class")
+skip = True # skip builtin check - the autodoc is missing, but it probably should not be
+
+check(A.__doc__, "Proxy of C++ A class", "::A")
 check(A.funk.__doc__, "just a string")
-check(A.func0.__doc__, "func0(self, arg2, hello) -> int")
-check(A.func1.__doc__, "func1(A self, short arg2, Tuple hello) -> int")
-check(A.func2.__doc__,  "\n"
+check(A.func0.__doc__,
+"func0(self, arg2, hello) -> int",
+"func0(arg2, hello) -> int")
+check(A.func1.__doc__,
+"func1(A self, short arg2, Tuple hello) -> int",
+"func1(short arg2, Tuple hello) -> int")
+check(A.func2.__doc__,
+"\n"
 "        func2(self, arg2, hello) -> int\n"
 "\n"
 "        Parameters:\n"
@@ -17,8 +28,18 @@
 "            hello: int tuple[2]\n"
 "\n"
 "        "
+,
+"\n"
+"func2(arg2, hello) -> int\n"
+"\n"
+"Parameters:\n"
+"    arg2: short\n"
+"    hello: int tuple[2]\n"
+"\n"
+""
 )
-check(A.func3.__doc__,  "\n"
+check(A.func3.__doc__,
+"\n"
 "        func3(A self, short arg2, Tuple hello) -> int\n"
 "\n"
 "        Parameters:\n"
@@ -26,19 +47,41 @@
 "            hello: int tuple[2]\n"
 "\n"
 "        "
+,
+"\n"
+"func3(short arg2, Tuple hello) -> int\n"
+"\n"
+"Parameters:\n"
+"    arg2: short\n"
+"    hello: int tuple[2]\n"
+"\n"
+""
 )
 
-check(A.func0default.__doc__, "\n"
+check(A.func0default.__doc__,
+"\n"
 "        func0default(self, e, arg3, hello, f=2) -> int\n"
 "        func0default(self, e, arg3, hello) -> int\n"
 "        "
+,
+"\n"
+"func0default(e, arg3, hello, f=2) -> int\n"
+"func0default(e, arg3, hello) -> int\n"
+""
 )
-check(A.func1default.__doc__, "\n"
+check(A.func1default.__doc__,
+"\n"
 "        func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
 "        func1default(A self, A e, short arg3, Tuple hello) -> int\n"
 "        "
+,
+"\n"
+"func1default(A e, short arg3, Tuple hello, double f=2) -> int\n"
+"func1default(A e, short arg3, Tuple hello) -> int\n"
+""
 )
-check(A.func2default.__doc__,  "\n"
+check(A.func2default.__doc__,
+"\n"
 "        func2default(self, e, arg3, hello, f=2) -> int\n"
 "\n"
 "        Parameters:\n"
@@ -55,8 +98,27 @@
 "            hello: int tuple[2]\n"
 "\n"
 "        "
+,
+"\n"
+"func2default(e, arg3, hello, f=2) -> int\n"
+"\n"
+"Parameters:\n"
+"    e: A *\n"
+"    arg3: short\n"
+"    hello: int tuple[2]\n"
+"    f: double\n"
+"\n"
+"func2default(e, arg3, hello) -> int\n"
+"\n"
+"Parameters:\n"
+"    e: A *\n"
+"    arg3: short\n"
+"    hello: int tuple[2]\n"
+"\n"
+""
 )
-check(A.func3default.__doc__,  "\n"
+check(A.func3default.__doc__,
+"\n"
 "        func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
 "\n"
 "        Parameters:\n"
@@ -73,19 +135,50 @@
 "            hello: int tuple[2]\n"
 "\n"
 "        "
+,
+"\n"
+"func3default(A e, short arg3, Tuple hello, double f=2) -> int\n"
+"\n"
+"Parameters:\n"
+"    e: A *\n"
+"    arg3: short\n"
+"    hello: int tuple[2]\n"
+"    f: double\n"
+"\n"
+"func3default(A e, short arg3, Tuple hello) -> int\n"
+"\n"
+"Parameters:\n"
+"    e: A *\n"
+"    arg3: short\n"
+"    hello: int tuple[2]\n"
+"\n"
+""
 )
 
-check(A.func0static.__doc__, "\n"
+check(A.func0static.__doc__,
+"\n"
 "        func0static(e, arg2, hello, f=2) -> int\n"
 "        func0static(e, arg2, hello) -> int\n"
 "        "
+,
+"\n"
+"func0static(e, arg2, hello, f=2) -> int\n"
+"func0static(e, arg2, hello) -> int\n"
+""
 )
-check(A.func1static.__doc__, "\n"
+check(A.func1static.__doc__,
+"\n"
 "        func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
 "        func1static(A e, short arg2, Tuple hello) -> int\n"
 "        "
+,
+"\n"
+"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
+"func1static(A e, short arg2, Tuple hello) -> int\n"
+""
 )
-check(A.func2static.__doc__,  "\n"
+check(A.func2static.__doc__,
+"\n"
 "        func2static(e, arg2, hello, f=2) -> int\n"
 "\n"
 "        Parameters:\n"
@@ -102,8 +195,27 @@
 "            hello: int tuple[2]\n"
 "\n"
 "        "
+,
+"\n"
+"func2static(e, arg2, hello, f=2) -> int\n"
+"\n"
+"Parameters:\n"
+"    e: A *\n"
+"    arg2: short\n"
+"    hello: int tuple[2]\n"
+"    f: double\n"
+"\n"
+"func2static(e, arg2, hello) -> int\n"
+"\n"
+"Parameters:\n"
+"    e: A *\n"
+"    arg2: short\n"
+"    hello: int tuple[2]\n"
+"\n"
+""
 )
-check(A.func3static.__doc__,  "\n"
+check(A.func3static.__doc__,
+"\n"
 "        func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
 "\n"
 "        Parameters:\n"
@@ -120,31 +232,65 @@
 "            hello: int tuple[2]\n"
 "\n"
 "        "
+,
+"\n"
+"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
+"\n"
+"Parameters:\n"
+"    e: A *\n"
+"    arg2: short\n"
+"    hello: int tuple[2]\n"
+"    f: double\n"
+"\n"
+"func3static(A e, short arg2, Tuple hello) -> int\n"
+"\n"
+"Parameters:\n"
+"    e: A *\n"
+"    arg2: short\n"
+"    hello: int tuple[2]\n"
+"\n"
+""
 )
 
 if sys.version_info[0:2] > (2, 4):
   # Python 2.4 does not seem to work
-  check(A.variable_a.__doc__, "A_variable_a_get(self) -> int")
-  check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
-  check(A.variable_c.__doc__, "\n"
+  check(A.variable_a.__doc__,
+  "A_variable_a_get(self) -> int",
+  "A.variable_a"
+  )
+  check(A.variable_b.__doc__,
+  "A_variable_b_get(A self) -> int",
+  "A.variable_b"
+  )
+  check(A.variable_c.__doc__,
+  "\n"
   "A_variable_c_get(self) -> int\n"
   "\n"
   "Parameters:\n"
   "    self: A *\n"
   "\n"
+  ,
+  "A.variable_c"
   )
-  check(A.variable_d.__doc__, "\n"
+  check(A.variable_d.__doc__,
+  "\n"
   "A_variable_d_get(A self) -> int\n"
   "\n"
   "Parameters:\n"
   "    self: A *\n"
   "\n"
+  ,
+  "A.variable_d"
   )
 
-check(B.__doc__, "Proxy of C++ B class")
-check(C.__init__.__doc__, "__init__(self, a, b, h) -> C")
-check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D")
-check(E.__init__.__doc__, "\n"
+check(B.__doc__,
+"Proxy of C++ B class",
+"::B"
+)
+check(C.__init__.__doc__, "__init__(self, a, b, h) -> C", None, skip)
+check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D", None, skip)
+check(E.__init__.__doc__,
+"\n"
 "        __init__(self, a, b, h) -> E\n"
 "\n"
 "        Parameters:\n"
@@ -153,8 +299,10 @@
 "            h: enum Hola\n"
 "\n"
 "        "
+, None, skip
 )
-check(F.__init__.__doc__, "\n"
+check(F.__init__.__doc__,
+"\n"
 "        __init__(F self, int a, int b, Hola h) -> F\n"
 "\n"
 "        Parameters:\n"
@@ -163,14 +311,23 @@
 "            h: enum Hola\n"
 "\n"
 "        "
+, None, skip
 )
 
-check(B.funk.__doc__, "funk(B self, int c, int d) -> int")
+check(B.funk.__doc__,
+"funk(B self, int c, int d) -> int",
+"funk(int c, int d) -> int")
 check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
-check(funkdefaults.__doc__, "\n"
+check(funkdefaults.__doc__,
+"\n"
 "    funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
 "    funkdefaults(A e, short arg2, int c, int d) -> int\n"
 "    "
+,
+"\n"
+"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
+"funkdefaults(A e, short arg2, int c, int d) -> int\n"
+""
 )
 
 check(func_input.__doc__, "func_input(int * INPUT) -> int")
diff --git a/Examples/test-suite/python/cpp11_function_objects_runme.py b/Examples/test-suite/python/cpp11_function_objects_runme.py
index aac7f9c..5a63b63 100644
--- a/Examples/test-suite/python/cpp11_function_objects_runme.py
+++ b/Examples/test-suite/python/cpp11_function_objects_runme.py
@@ -1,6 +1,13 @@
 import cpp11_function_objects
 import sys
 
+class Test1(cpp11_function_objects.Test):
+    def __init__(self):
+        cpp11_function_objects.Test.__init__(self)
+
+    def __call__(self, a, b):
+        self.value = a * b
+
 t = cpp11_function_objects.Test()
 if t.value != 0:
 	raise RuntimeError("Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value))
@@ -10,3 +17,7 @@
 if t.value != 3:
 	raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))
  
+t2 = Test1()
+a = cpp11_function_objects.testit1(t2, 4,3)
+if a != 12:
+	raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 12, but is " + str(a))
diff --git a/Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py b/Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py
new file mode 100644
index 0000000..6509ba8
--- /dev/null
+++ b/Examples/test-suite/python/cpp11_strongly_typed_enumerations_runme.py
@@ -0,0 +1,164 @@
+from cpp11_strongly_typed_enumerations import *
+
+def enumCheck(actual, expected):
+  if actual != expected:
+    raise RuntimeError("Enum value mismatch. Expected " + str(expected) + " Actual: " + str(actual))
+  return expected + 1
+
+val = 0
+val = enumCheck(Enum1_Val1, val)
+val = enumCheck(Enum1_Val2, val)
+val = enumCheck(Enum1_Val3, 13)
+val = enumCheck(Enum1_Val4, val)
+val = enumCheck(Enum1_Val5a, 13)
+val = enumCheck(Enum1_Val6a, val)
+
+val = 0
+val = enumCheck(Enum2_Val1, val)
+val = enumCheck(Enum2_Val2, val)
+val = enumCheck(Enum2_Val3, 23)
+val = enumCheck(Enum2_Val4, val)
+val = enumCheck(Enum2_Val5b, 23)
+val = enumCheck(Enum2_Val6b, val)
+
+val = 0
+val = enumCheck(Val1, val)
+val = enumCheck(Val2, val)
+val = enumCheck(Val3, 43)
+val = enumCheck(Val4, val)
+
+val = 0
+val = enumCheck(Enum5_Val1, val)
+val = enumCheck(Enum5_Val2, val)
+val = enumCheck(Enum5_Val3, 53)
+val = enumCheck(Enum5_Val4, val)
+
+val = 0
+val = enumCheck(Enum6_Val1, val)
+val = enumCheck(Enum6_Val2, val)
+val = enumCheck(Enum6_Val3, 63)
+val = enumCheck(Enum6_Val4, val)
+
+val = 0
+val = enumCheck(Enum7td_Val1, val)
+val = enumCheck(Enum7td_Val2, val)
+val = enumCheck(Enum7td_Val3, 73)
+val = enumCheck(Enum7td_Val4, val)
+
+val = 0
+val = enumCheck(Enum8_Val1, val)
+val = enumCheck(Enum8_Val2, val)
+val = enumCheck(Enum8_Val3, 83)
+val = enumCheck(Enum8_Val4, val)
+
+val = 0
+val = enumCheck(Enum10_Val1, val)
+val = enumCheck(Enum10_Val2, val)
+val = enumCheck(Enum10_Val3, 103)
+val = enumCheck(Enum10_Val4, val)
+
+val = 0
+val = enumCheck(Class1.Enum12_Val1, 1121)
+val = enumCheck(Class1.Enum12_Val2, 1122)
+val = enumCheck(Class1.Enum12_Val3, val)
+val = enumCheck(Class1.Enum12_Val4, val)
+val = enumCheck(Class1.Enum12_Val5c, 1121)
+val = enumCheck(Class1.Enum12_Val6c, val)
+
+val = 0
+val = enumCheck(Class1.Val1, 1131)
+val = enumCheck(Class1.Val2, 1132)
+val = enumCheck(Class1.Val3, val)
+val = enumCheck(Class1.Val4, val)
+val = enumCheck(Class1.Val5d, 1131)
+val = enumCheck(Class1.Val6d, val)
+
+val = 0
+val = enumCheck(Class1.Enum14_Val1, 1141)
+val = enumCheck(Class1.Enum14_Val2, 1142)
+val = enumCheck(Class1.Enum14_Val3, val)
+val = enumCheck(Class1.Enum14_Val4, val)
+val = enumCheck(Class1.Enum14_Val5e, 1141)
+val = enumCheck(Class1.Enum14_Val6e, val)
+
+# Requires nested class support to work
+#val = 0
+#val = enumCheck(Class1.Struct1.Enum12_Val1, 3121)
+#val = enumCheck(Class1.Struct1.Enum12_Val2, 3122)
+#val = enumCheck(Class1.Struct1.Enum12_Val3, val)
+#val = enumCheck(Class1.Struct1.Enum12_Val4, val)
+#val = enumCheck(Class1.Struct1.Enum12_Val5f, 3121)
+#val = enumCheck(Class1.Struct1.Enum12_Val6f, val)
+#
+#val = 0
+#val = enumCheck(Class1.Struct1.Val1, 3131)
+#val = enumCheck(Class1.Struct1.Val2, 3132)
+#val = enumCheck(Class1.Struct1.Val3, val)
+#val = enumCheck(Class1.Struct1.Val4, val)
+#
+#val = 0
+#val = enumCheck(Class1.Struct1.Enum14_Val1, 3141)
+#val = enumCheck(Class1.Struct1.Enum14_Val2, 3142)
+#val = enumCheck(Class1.Struct1.Enum14_Val3, val)
+#val = enumCheck(Class1.Struct1.Enum14_Val4, val)
+#val = enumCheck(Class1.Struct1.Enum14_Val5g, 3141)
+#val = enumCheck(Class1.Struct1.Enum14_Val6g, val)
+
+val = 0
+val = enumCheck(Class2.Enum12_Val1, 2121)
+val = enumCheck(Class2.Enum12_Val2, 2122)
+val = enumCheck(Class2.Enum12_Val3, val)
+val = enumCheck(Class2.Enum12_Val4, val)
+val = enumCheck(Class2.Enum12_Val5h, 2121)
+val = enumCheck(Class2.Enum12_Val6h, val)
+
+val = 0
+val = enumCheck(Class2.Val1, 2131)
+val = enumCheck(Class2.Val2, 2132)
+val = enumCheck(Class2.Val3, val)
+val = enumCheck(Class2.Val4, val)
+val = enumCheck(Class2.Val5i, 2131)
+val = enumCheck(Class2.Val6i, val)
+
+val = 0
+val = enumCheck(Class2.Enum14_Val1, 2141)
+val = enumCheck(Class2.Enum14_Val2, 2142)
+val = enumCheck(Class2.Enum14_Val3, val)
+val = enumCheck(Class2.Enum14_Val4, val)
+val = enumCheck(Class2.Enum14_Val5j, 2141)
+val = enumCheck(Class2.Enum14_Val6j, val)
+
+# Requires nested class support to work
+#val = 0
+#val = enumCheck(Class2.Struct1.Enum12_Val1, 4121)
+#val = enumCheck(Class2.Struct1.Enum12_Val2, 4122)
+#val = enumCheck(Class2.Struct1.Enum12_Val3, val)
+#val = enumCheck(Class2.Struct1.Enum12_Val4, val)
+#val = enumCheck(Class2.Struct1.Enum12_Val5k, 4121)
+#val = enumCheck(Class2.Struct1.Enum12_Val6k, val)
+#
+#val = 0
+#val = enumCheck(Class2.Struct1.Val1, 4131)
+#val = enumCheck(Class2.Struct1.Val2, 4132)
+#val = enumCheck(Class2.Struct1.Val3, val)
+#val = enumCheck(Class2.Struct1.Val4, val)
+#val = enumCheck(Class2.Struct1.Val5l, 4131)
+#val = enumCheck(Class2.Struct1.Val6l, val)
+#
+#val = 0
+#val = enumCheck(Class2.Struct1.Enum14_Val1, 4141)
+#val = enumCheck(Class2.Struct1.Enum14_Val2, 4142)
+#val = enumCheck(Class2.Struct1.Enum14_Val3, val)
+#val = enumCheck(Class2.Struct1.Enum14_Val4, val)
+#val = enumCheck(Class2.Struct1.Enum14_Val5m, 4141)
+#val = enumCheck(Class2.Struct1.Enum14_Val6m, val)
+
+class1 = Class1()
+enumCheck(class1.class1Test1(Enum1_Val5a), 13)
+enumCheck(class1.class1Test2(Class1.Enum12_Val5c), 1121)
+#enumCheck(class1.class1Test3(Class1.Struct1.Enum12_Val5f), 3121)
+
+enumCheck(globalTest1(Enum1_Val5a), 13)
+enumCheck(globalTest2(Class1.Enum12_Val5c), 1121)
+#enumCheck(globalTest3(Class1.Struct1.Enum12_Val5f), 3121)
+
diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py
index 091a923..f24e825 100644
--- a/Examples/test-suite/python/default_args_runme.py
+++ b/Examples/test-suite/python/default_args_runme.py
@@ -1,64 +1,90 @@
-import default_args 
+# Note that this test is also used by python_default_args_runme.py hence the use of __main__ and the run function
+
+def run(module_name):
+  default_args = __import__(module_name)
+  ec = default_args.EnumClass()
+  if not ec.blah():
+    raise RuntimeError("EnumClass::blah() default arguments don't work")
+
+  de = default_args.DerivedEnumClass()
+  de.accelerate()
+  de.accelerate(default_args.EnumClass.SLOW)
+
+  if default_args.Statics_staticMethod() != 60:
+    raise RuntimeError
+
+  if default_args.cfunc1(1) != 2:
+    raise RuntimeError
+
+  if default_args.cfunc2(1) != 3:
+    raise RuntimeError
+
+  if default_args.cfunc3(1) != 4:
+    raise RuntimeError
 
 
-if default_args.Statics_staticMethod() != 60:
-  raise RuntimeError
-  
-if default_args.cfunc1(1) != 2:
-  raise RuntimeError
+  f = default_args.Foo()
 
-if default_args.cfunc2(1) != 3:
-  raise RuntimeError
-
-if default_args.cfunc3(1) != 4:
-  raise RuntimeError
+  f.newname()
+  f.newname(1)
 
 
-f = default_args.Foo()
+  try:
+    f = default_args.Foo(1)
+    error = 1
+  except:
+    error = 0
+  if error:  raise RuntimeError("Foo::Foo ignore is not working")
 
-f.newname()
-f.newname(1)
+  try:
+    f = default_args.Foo(1,2)
+    error = 1
+  except:
+    error = 0
+  if error:  raise RuntimeError("Foo::Foo ignore is not working")
 
+  try:
+    f = default_args.Foo(1,2,3)
+    error = 1
+  except:
+    error = 0
+  if error:  raise RuntimeError("Foo::Foo ignore is not working")
 
-try:
-  f = default_args.Foo(1)
-  error = 1
-except:
-  error = 0
-if error:  raise RuntimeError,"Foo::Foo ignore is not working"
+  try:
+    m = f.meth(1)
+    error = 1
+  except:
+    error = 0
+  if error:  raise RuntimeError("Foo::meth ignore is not working")
 
-try:
-  f = default_args.Foo(1,2)
-  error = 1
-except:
-  error = 0
-if error:  raise RuntimeError,"Foo::Foo ignore is not working"
+  try:
+    m = f.meth(1,2)
+    error = 1
+  except:
+    error = 0
+  if error:  raise RuntimeError("Foo::meth ignore is not working")
 
-try:
-  f = default_args.Foo(1,2,3)
-  error = 1
-except:
-  error = 0
-if error:  raise RuntimeError,"Foo::Foo ignore is not working"
+  try:
+    m = f.meth(1,2,3)
+    error = 1
+  except:
+    error = 0
+  if error:  raise RuntimeError("Foo::meth ignore is not working")
 
-try:
-  m = f.meth(1)
-  error = 1
-except:
-  error = 0
-if error:  raise RuntimeError,"Foo::meth ignore is not working"
+  if default_args.Klass.inc(100, default_args.Klass(22)).val != 122:
+    raise RuntimeError("Klass::inc failed")
 
-try:
-  m = f.meth(1,2)
-  error = 1
-except:
-  error = 0
-if error:  raise RuntimeError,"Foo::meth ignore is not working"
+  if default_args.Klass.inc(100).val != 99:
+    raise RuntimeError("Klass::inc failed")
 
-try:
-  m = f.meth(1,2,3)
-  error = 1
-except:
-  error = 0
-if error:  raise RuntimeError,"Foo::meth ignore is not working"
+  if default_args.Klass.inc().val != 0:
+    raise RuntimeError("Klass::inc failed")
+
+  default_args.trickyvalue1(10); default_args.trickyvalue1(10, 10)
+  default_args.trickyvalue2(10); default_args.trickyvalue2(10, 10)
+  default_args.trickyvalue3(10); default_args.trickyvalue3(10, 10)
+  default_args.seek(); default_args.seek(10)
+
+if __name__=="__main__":
+  run('default_args')
 
diff --git a/Examples/test-suite/python/default_constructor_runme.py b/Examples/test-suite/python/default_constructor_runme.py
index 59b1305..e653203 100644
--- a/Examples/test-suite/python/default_constructor_runme.py
+++ b/Examples/test-suite/python/default_constructor_runme.py
@@ -1,8 +1,10 @@
+import _default_constructor
+
 # This test is expected to fail with -builtin option.
 # It uses the old static syntax (e.g., dc.new_A() rather than dc.A()),
 # which is not provided with the -builtin option.
-
-import _default_constructor
+if _default_constructor.is_python_builtin():
+  exit(0)
 
 dc = _default_constructor
 
diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py
index 510845a..de3ef22 100644
--- a/Examples/test-suite/python/director_exception_runme.py
+++ b/Examples/test-suite/python/director_exception_runme.py
@@ -68,14 +68,13 @@
 
 # This is expected to fail with -builtin option
 # Throwing builtin classes as exceptions not supported
-try:
-	raise Exception2()
-except Exception2:
-	pass
+if not is_python_builtin():
+	try:
+		raise Exception2()
+	except Exception2:
+		pass
 
-# This is expected to fail with -builtin option
-# Throwing builtin classes as exceptions not supported
-try:
-	raise Exception1()
-except Exception1:
-	pass
+	try:
+		raise Exception1()
+	except Exception1:
+		pass
diff --git a/Examples/test-suite/python/director_keywords_runme.py b/Examples/test-suite/python/director_keywords_runme.py
new file mode 100644
index 0000000..03a5020
--- /dev/null
+++ b/Examples/test-suite/python/director_keywords_runme.py
@@ -0,0 +1,5 @@
+from director_keywords import *
+
+f = Foo()
+f.check_self(20)
+
diff --git a/Examples/test-suite/python/director_property_runme.py b/Examples/test-suite/python/director_property_runme.py
new file mode 100644
index 0000000..303e53b
--- /dev/null
+++ b/Examples/test-suite/python/director_property_runme.py
@@ -0,0 +1,18 @@
+import director_property
+
+class PyFoo(director_property.Foo):
+	a = property(director_property.Foo.getA, director_property.Foo.setA)
+
+	def ping(self):
+		return "PyFoo::ping()"
+
+
+foo = PyFoo()
+
+foo.setA("BLABLA")
+if foo.getA() != "BLABLA":
+	raise RuntimeError
+
+foo.a = "BIBI"
+if foo.a != "BIBI":
+	raise RuntimeError
diff --git a/Examples/test-suite/python/exception_order_runme.py b/Examples/test-suite/python/exception_order_runme.py
index 38b53eb..8f095eb 100644
--- a/Examples/test-suite/python/exception_order_runme.py
+++ b/Examples/test-suite/python/exception_order_runme.py
@@ -2,6 +2,8 @@
 
 # This test is expected to fail with -builtin option.
 # Throwing builtin classes as exceptions not supported
+if is_python_builtin():
+  exit(0)
 
 a = A()
 
diff --git a/Examples/test-suite/python/import_nomodule_runme.py b/Examples/test-suite/python/import_nomodule_runme.py
index ba0abfd..efcff9c 100644
--- a/Examples/test-suite/python/import_nomodule_runme.py
+++ b/Examples/test-suite/python/import_nomodule_runme.py
@@ -1,5 +1,10 @@
 from import_nomodule import *
 
+# This test is expected to fail with -builtin option.
+# The base class is needed for the builtin class hierarchy
+if is_python_builtin():
+  exit(0)
+
 f = create_Foo()
 test1(f,42)
 delete_Foo(f)
diff --git a/Examples/test-suite/python/kwargs_feature_runme.py b/Examples/test-suite/python/kwargs_feature_runme.py
index 5539e21..7792e2e 100644
--- a/Examples/test-suite/python/kwargs_feature_runme.py
+++ b/Examples/test-suite/python/kwargs_feature_runme.py
@@ -44,10 +44,10 @@
 if templatedfunction(b=2) != 3:
   raise RuntimeError
 
-if foo(a=1,b=2) != 3:
+if foo_fn(a=1,b=2) != 3:
   raise RuntimeError
 
-if foo(b=2) != 3:
+if foo_fn(b=2) != 3:
   raise RuntimeError
 
 
diff --git a/Examples/test-suite/python/li_std_except_as_class_runme.py b/Examples/test-suite/python/li_std_except_as_class_runme.py
index 386a878..a86e7a5 100644
--- a/Examples/test-suite/python/li_std_except_as_class_runme.py
+++ b/Examples/test-suite/python/li_std_except_as_class_runme.py
@@ -1,9 +1,19 @@
 from li_std_except_as_class import *
 
-# std::domain_error hierarchy
-try: test_domain_error()
-except domain_error: pass
-try: test_domain_error()
-except logic_error: pass
-try: test_domain_error()
-except exception: pass
+# This test is expected to fail with -builtin option.
+# Throwing builtin classes as exceptions not supported
+if is_python_builtin():
+  try: test_domain_error()
+  except RuntimeError: pass
+  try: test_domain_error()
+  except RuntimeError: pass
+  try: test_domain_error()
+  except RuntimeError: pass
+else:
+  # std::domain_error hierarchy
+  try: test_domain_error()
+  except domain_error: pass
+  try: test_domain_error()
+  except logic_error: pass
+  try: test_domain_error()
+  except exception: pass
diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py
index 9e9e3d2..503d09e 100644
--- a/Examples/test-suite/python/li_std_string_extra_runme.py
+++ b/Examples/test-suite/python/li_std_string_extra_runme.py
@@ -56,14 +56,13 @@
 
 # This is expected to fail with -builtin option
 # Reverse operators not supported in builtin types
-if "hello" + b != "hello world":
-  raise RuntimeError, "bad string mapping"
+if not li_std_string_extra.is_python_builtin():
+  if "hello" + b != "hello world":
+    raise RuntimeError, "bad string mapping"
 
-# This is expected to fail with -builtin option
-# Reverse operators not supported in builtin types
-c = "hello" + b
-if c.find_last_of("l") != 9:
-  raise RuntimeError, "bad string mapping"
+  c = "hello" + b
+  if c.find_last_of("l") != 9:
+    raise RuntimeError, "bad string mapping"
   
 s = "hello world"
 
diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py
index fecc527..a467ae8 100644
--- a/Examples/test-suite/python/li_std_wstring_runme.py
+++ b/Examples/test-suite/python/li_std_wstring_runme.py
@@ -60,13 +60,14 @@
   raise RuntimeError("bad string mapping")
 
 # This is expected to fail if -builtin is used
-if "hello" + b != "hello world":
-  raise RuntimeError("bad string mapping")
+# Reverse operators not supported in builtin types
+if not li_std_wstring.is_python_builtin():
+  if "hello" + b != "hello world":
+    raise RuntimeError("bad string mapping")
 
-# This is expected to fail if -builtin is used
-c = "hello" + b
-if c.find_last_of("l") != 9:
-  raise RuntimeError("bad string mapping")
+  c = "hello" + b
+  if c.find_last_of("l") != 9:
+    raise RuntimeError("bad string mapping")
   
 s = "hello world"
 
diff --git a/Examples/test-suite/python/nested_template_base_runme.py b/Examples/test-suite/python/nested_template_base_runme.py
new file mode 100644
index 0000000..3d54b83
--- /dev/null
+++ b/Examples/test-suite/python/nested_template_base_runme.py
@@ -0,0 +1,13 @@
+from nested_template_base import *
+
+
+ois = InnerS(123);
+oic = InnerC();
+
+# Check base method is available
+if (oic.outer(ois).val != 123):
+  raise RuntimeError("Wrong value calling outer");
+
+# Check non-derived class using base class
+if (oic.innerc().outer(ois).val != 123):
+  raise RuntimeError("Wrong value calling innerc");
diff --git a/Examples/test-suite/python/preproc_runme.py b/Examples/test-suite/python/preproc_runme.py
index c989294..3049f00 100644
--- a/Examples/test-suite/python/preproc_runme.py
+++ b/Examples/test-suite/python/preproc_runme.py
@@ -12,3 +12,5 @@
 if 2*preproc.one != preproc.two:
   raise RuntimeError
 
+if preproc.methodX(99) != 199:
+  raise RuntimeError
diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py
index 94dee3f..9b18996 100644
--- a/Examples/test-suite/python/python_abstractbase_runme3.py
+++ b/Examples/test-suite/python/python_abstractbase_runme3.py
@@ -3,6 +3,8 @@
 
 # This is expected to fail with -builtin option
 # Builtin types can't inherit from pure-python abstract bases
+if is_python_builtin():
+  exit(0)
 
 assert issubclass(Mapii, MutableMapping)
 assert issubclass(Multimapii, MutableMapping)
diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py
index 41cebad..54d7a3e 100644
--- a/Examples/test-suite/python/python_append_runme.py
+++ b/Examples/test-suite/python/python_append_runme.py
@@ -1,11 +1,16 @@
 from python_append import *
+
+# test not relevant for -builtin
+if is_python_builtin():
+  exit(0)
+
 t=Test()
 t.func()
 t.static_func()
 
 if grabpath() != os.path.dirname(mypath):
-  raise RuntimeError
+  raise RuntimeError("grabpath failed")
 
 if grabstaticpath() != os.path.basename(mypath):
-  raise RuntimeError
+  raise RuntimeError("grabstaticpath failed")
 
diff --git a/Examples/test-suite/python/python_threads_runme.py b/Examples/test-suite/python/python_threads_runme.py
new file mode 100644
index 0000000..d00e245
--- /dev/null
+++ b/Examples/test-suite/python/python_threads_runme.py
@@ -0,0 +1,10 @@
+from python_threads import *
+
+action = ActionGroup()
+count = 1
+for child in action.GetActionList():
+  if child.val != count:
+    raise RuntimeError("Expected: " + str(count) + " got: " + str(child.val))
+  count = count + 1
+
+# Was seg faulting at the end here
diff --git a/Examples/test-suite/python/smart_pointer_const_overload_runme.py b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
index f1be315..098e5b4 100644
--- a/Examples/test-suite/python/smart_pointer_const_overload_runme.py
+++ b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
@@ -56,7 +56,7 @@
     raise RuntimeError
     
   # Test static method
-  b.stat()
+  b.statMethod()
 
   if f.access != CONST_ACCESS:
     raise RuntimeError
diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py
index d4b8855..6fe6947 100644
--- a/Examples/test-suite/python/threads_exception_runme.py
+++ b/Examples/test-suite/python/threads_exception_runme.py
@@ -20,15 +20,16 @@
 
 # This is expected fail with -builtin option
 # Throwing builtin classes as exceptions not supported
-try:
-  t.hosed()
-except threads_exception.Exc,e:
-  code = e.code
-  if code != 42:
-    raise RuntimeError, "bad... code: %d" % code
-  msg = e.msg
-  if msg != "Hosed":
-    raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
+if not threads_exception.is_python_builtin():
+  try:
+    t.hosed()
+  except threads_exception.Exc,e:
+    code = e.code
+    if code != 42:
+      raise RuntimeError, "bad... code: %d" % code
+    msg = e.msg
+    if msg != "Hosed":
+      raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
 
 for i in range(1,4):
   try:
diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py
new file mode 100644
index 0000000..e1fc7ad
--- /dev/null
+++ b/Examples/test-suite/python/unicode_strings_runme.py
@@ -0,0 +1,14 @@
+import sys
+
+import unicode_strings
+
+# The 'u' string prefix isn't valid in Python 3.0 - 3.2 and is redundant
+# in 3.3+. Since this file is run through 2to3 before testing, though,
+# mark this as a unicode string in 2.x so it'll become a str in 3.x.
+test_string = u'h\udce9llo w\u00f6rld'
+
+if sys.version_info[0:2] >= (3, 1):
+    if unicode_strings.non_utf8_c_str() != test_string:
+        raise ValueError('Test comparison mismatch')
+    if unicode_strings.non_utf8_std_string() != test_string:
+        raise ValueError('Test comparison mismatch')
diff --git a/Examples/test-suite/python_abstractbase.i b/Examples/test-suite/python_abstractbase.i
index f726882..65f3d99 100644
--- a/Examples/test-suite/python_abstractbase.i
+++ b/Examples/test-suite/python_abstractbase.i
@@ -16,3 +16,11 @@
   %template(IntVector) vector<int>;
   %template(IntList) list<int>;
 }
+
+%inline %{
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
+%}
diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i
index e263c39..f37a6c1 100644
--- a/Examples/test-suite/python_append.i
+++ b/Examples/test-suite/python_append.i
@@ -5,22 +5,22 @@
 %module python_append 
 
 %pythoncode %{
-  mypath = os.path.dirname("/a/b/c/d.txt")
-  funcpath = None
-  staticfuncpath = None
-  def grabpath():
+mypath = os.path.dirname("/a/b/c/d.txt")
+funcpath = None
+staticfuncpath = None
+def grabpath():
     return funcpath
-  def grabstaticpath():
+def grabstaticpath():
     return staticfuncpath
 %}
 
 %pythonappend Test::func %{
-    funcpath = os.path.dirname(funcpath)
+funcpath = os.path.dirname(funcpath)
 %}
 
 %pythonprepend Test::func %{
-        global funcpath
-        funcpath = mypath
+global funcpath
+funcpath = mypath
 %}
 
 %pythonappend Test::static_func %{
@@ -29,9 +29,9 @@
 %}
 
 %pythonprepend Test::static_func {
-    global staticfuncpath
-    staticfuncpath = mypath
-    pass
+global staticfuncpath
+staticfuncpath = mypath
+pass
 }
 
 %pythonbegin %{
@@ -46,5 +46,10 @@
   void func() {};
 };
 
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
 %}
 
diff --git a/Examples/test-suite/python_nondynamic.i b/Examples/test-suite/python_nondynamic.i
index 26c6964..54a3f28 100644
--- a/Examples/test-suite/python_nondynamic.i
+++ b/Examples/test-suite/python_nondynamic.i
@@ -1,7 +1,7 @@
 %module python_nondynamic
 
 /*
- Use the %pythonnondynamic directuve to make the wrapped class a
+ Use the %pythonnondynamic directive to make the wrapped class a
  nondynamic one, ie, a python class that doesn't dynamically add new
  attributes.  Hence, for the class
 
diff --git a/Examples/test-suite/python_threads.i b/Examples/test-suite/python_threads.i
new file mode 100644
index 0000000..08eddef
--- /dev/null
+++ b/Examples/test-suite/python_threads.i
@@ -0,0 +1,40 @@
+%module(threads=1) python_threads
+
+%include <std_vector.i>
+
+%inline %{
+struct Action {
+  int val;
+  Action(int val = 0) : val(val) {}
+};
+%}
+
+%template(VectorActionPtr) std::vector<Action *>;
+
+%inline %{
+#include <vector>
+#include <iostream>
+template <typename T> struct myStlVector : public std::vector<T> {
+};
+typedef myStlVector <Action *> ActionList;
+
+%}
+
+%template(ActionList) myStlVector<Action *>;
+
+%inline %{
+class ActionGroup
+{
+public:
+  ActionList &GetActionList () const {
+    static ActionList list;
+    list.push_back(new Action(1));
+    list.push_back(new Action(2));
+    list.push_back(new Action(3));
+    list.push_back(new Action(4));
+    return list;
+  }
+};
+%}
+
+
diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in
index 18e2d4b..d048953 100644
--- a/Examples/test-suite/r/Makefile.in
+++ b/Examples/test-suite/r/Makefile.in
@@ -6,6 +6,7 @@
 SCRIPTSUFFIX = _runme.R
 WRAPSUFFIX   = .R
 RUNR         = R CMD BATCH --no-save --no-restore
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -28,7 +29,7 @@
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -38,34 +39,34 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_multitestcase)
 
 # Runs the testcase.
-# 
-# Run the runme if it exists.  If not just load the R wrapper to 
+#
+# Run the runme if it exists.  If not just load the R wrapper to
 # check for syntactic correctness
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	else \
-	  $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(WRAPSUFFIX); \
+	  $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX); \
 	fi
 
 run_multitestcase = \
 	for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \
 	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \
-               $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \
+	       $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \
 	else \
-	  $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX); \
+	  $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX); \
 	fi; \
 	done
 # Clean
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile r_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" r_clean
 
 %.clean:
 	@rm -f $*.R $*_wrap.so $*_wrap.cpp $*_wrap.c $*_wrap.o $*_runme.Rout $*.Rout
@@ -74,5 +75,3 @@
 	   rm -f $${f}.R $${f}.Rout ; \
 	done \
 	fi
-
-
diff --git a/Examples/test-suite/r_overload_array.i b/Examples/test-suite/r_overload_array.i
index 1474661..aa714df 100644
--- a/Examples/test-suite/r_overload_array.i
+++ b/Examples/test-suite/r_overload_array.i
@@ -1,7 +1,8 @@
 %module r_overload_array
-%include "stl.i"
-# this tests the situation in which there is a scalar function
-# corresponding with a vector one
+
+%include <stl.i>
+// this tests the situation in which there is a scalar function
+// corresponding with a vector one
 
 %inline %{
 class Foo {
diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in
index ab366cc..ae49958 100644
--- a/Examples/test-suite/ruby/Makefile.in
+++ b/Examples/test-suite/ruby/Makefile.in
@@ -5,12 +5,12 @@
 LANGUAGE     = ruby
 RUBY         = @RUBY@
 SCRIPTSUFFIX = _runme.rb
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
 
 CPP_TEST_CASES = \
-	kwargs_feature \
 	li_cdata \
 	li_cstring \
 	li_factory \
@@ -42,7 +42,7 @@
 ruby_naming.cpptest: SWIGOPT += -autorename
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -52,7 +52,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -60,13 +60,13 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.rb appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) -I$(srcdir):. $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) -I$(srcdir):. $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean
 %.clean:
-	
+	@exit 0
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile ruby_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" ruby_clean
diff --git a/Examples/test-suite/ruby/abstract_access_runme.rb b/Examples/test-suite/ruby/abstract_access_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/access_change_runme.rb b/Examples/test-suite/ruby/access_change_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/add_link_runme.rb b/Examples/test-suite/ruby/add_link_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/anonymous_bitfield_runme.rb b/Examples/test-suite/ruby/anonymous_bitfield_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/apply_signed_char_runme.rb b/Examples/test-suite/ruby/apply_signed_char_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/apply_strings_runme.rb b/Examples/test-suite/ruby/apply_strings_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/argout_runme.rb b/Examples/test-suite/ruby/argout_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/arrays_runme.rb b/Examples/test-suite/ruby/arrays_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/cast_operator_runme.rb b/Examples/test-suite/ruby/cast_operator_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/casts_runme.rb b/Examples/test-suite/ruby/casts_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/check_missing_tests.rb b/Examples/test-suite/ruby/check_missing_tests.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/class_ignore_runme.rb b/Examples/test-suite/ruby/class_ignore_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/const_const_runme.rb b/Examples/test-suite/ruby/const_const_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/constover_runme.rb b/Examples/test-suite/ruby/constover_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/cpp11_strongly_typed_enumerations_runme.rb b/Examples/test-suite/ruby/cpp11_strongly_typed_enumerations_runme.rb
new file mode 100644
index 0000000..897a442
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_strongly_typed_enumerations_runme.rb
@@ -0,0 +1,177 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+# 
+# 
+# 
+#
+
+require 'swig_assert'
+
+require 'cpp11_strongly_typed_enumerations'
+
+include Cpp11_strongly_typed_enumerations
+
+def enumCheck(actual, expected)
+  raise RuntimeError,"Enum value mismatch. Expected #{expected} Actual: #{actual}" if actual != expected
+  return expected + 1
+end
+
+val = 0
+val = enumCheck(Enum1_Val1, val)
+val = enumCheck(Enum1_Val2, val)
+val = enumCheck(Enum1_Val3, 13)
+val = enumCheck(Enum1_Val4, val)
+val = enumCheck(Enum1_Val5a, 13)
+val = enumCheck(Enum1_Val6a, val)
+
+val = 0
+val = enumCheck(Enum2_Val1, val)
+val = enumCheck(Enum2_Val2, val)
+val = enumCheck(Enum2_Val3, 23)
+val = enumCheck(Enum2_Val4, val)
+val = enumCheck(Enum2_Val5b, 23)
+val = enumCheck(Enum2_Val6b, val)
+
+val = 0
+val = enumCheck(Val1, val)
+val = enumCheck(Val2, val)
+val = enumCheck(Val3, 43)
+val = enumCheck(Val4, val)
+
+val = 0
+val = enumCheck(Enum5_Val1, val)
+val = enumCheck(Enum5_Val2, val)
+val = enumCheck(Enum5_Val3, 53)
+val = enumCheck(Enum5_Val4, val)
+
+val = 0
+val = enumCheck(Enum6_Val1, val)
+val = enumCheck(Enum6_Val2, val)
+val = enumCheck(Enum6_Val3, 63)
+val = enumCheck(Enum6_Val4, val)
+
+val = 0
+val = enumCheck(Enum7td_Val1, val)
+val = enumCheck(Enum7td_Val2, val)
+val = enumCheck(Enum7td_Val3, 73)
+val = enumCheck(Enum7td_Val4, val)
+
+val = 0
+val = enumCheck(Enum8_Val1, val)
+val = enumCheck(Enum8_Val2, val)
+val = enumCheck(Enum8_Val3, 83)
+val = enumCheck(Enum8_Val4, val)
+
+val = 0
+val = enumCheck(Enum10_Val1, val)
+val = enumCheck(Enum10_Val2, val)
+val = enumCheck(Enum10_Val3, 103)
+val = enumCheck(Enum10_Val4, val)
+
+val = 0
+val = enumCheck(Class1::Enum12_Val1, 1121)
+val = enumCheck(Class1::Enum12_Val2, 1122)
+val = enumCheck(Class1::Enum12_Val3, val)
+val = enumCheck(Class1::Enum12_Val4, val)
+val = enumCheck(Class1::Enum12_Val5c, 1121)
+val = enumCheck(Class1::Enum12_Val6c, val)
+
+val = 0
+val = enumCheck(Class1::Val1, 1131)
+val = enumCheck(Class1::Val2, 1132)
+val = enumCheck(Class1::Val3, val)
+val = enumCheck(Class1::Val4, val)
+val = enumCheck(Class1::Val5d, 1131)
+val = enumCheck(Class1::Val6d, val)
+
+val = 0
+val = enumCheck(Class1::Enum14_Val1, 1141)
+val = enumCheck(Class1::Enum14_Val2, 1142)
+val = enumCheck(Class1::Enum14_Val3, val)
+val = enumCheck(Class1::Enum14_Val4, val)
+val = enumCheck(Class1::Enum14_Val5e, 1141)
+val = enumCheck(Class1::Enum14_Val6e, val)
+
+# Requires nested class support to work
+#val = 0
+#val = enumCheck(Class1::Struct1.Enum12_Val1, 3121)
+#val = enumCheck(Class1::Struct1.Enum12_Val2, 3122)
+#val = enumCheck(Class1::Struct1.Enum12_Val3, val)
+#val = enumCheck(Class1::Struct1.Enum12_Val4, val)
+#val = enumCheck(Class1::Struct1.Enum12_Val5f, 3121)
+#val = enumCheck(Class1::Struct1.Enum12_Val6f, val)
+#
+#val = 0
+#val = enumCheck(Class1::Struct1.Val1, 3131)
+#val = enumCheck(Class1::Struct1.Val2, 3132)
+#val = enumCheck(Class1::Struct1.Val3, val)
+#val = enumCheck(Class1::Struct1.Val4, val)
+#
+#val = 0
+#val = enumCheck(Class1::Struct1.Enum14_Val1, 3141)
+#val = enumCheck(Class1::Struct1.Enum14_Val2, 3142)
+#val = enumCheck(Class1::Struct1.Enum14_Val3, val)
+#val = enumCheck(Class1::Struct1.Enum14_Val4, val)
+#val = enumCheck(Class1::Struct1.Enum14_Val5g, 3141)
+#val = enumCheck(Class1::Struct1.Enum14_Val6g, val)
+
+val = 0
+val = enumCheck(Class2::Enum12_Val1, 2121)
+val = enumCheck(Class2::Enum12_Val2, 2122)
+val = enumCheck(Class2::Enum12_Val3, val)
+val = enumCheck(Class2::Enum12_Val4, val)
+val = enumCheck(Class2::Enum12_Val5h, 2121)
+val = enumCheck(Class2::Enum12_Val6h, val)
+
+val = 0
+val = enumCheck(Class2::Val1, 2131)
+val = enumCheck(Class2::Val2, 2132)
+val = enumCheck(Class2::Val3, val)
+val = enumCheck(Class2::Val4, val)
+val = enumCheck(Class2::Val5i, 2131)
+val = enumCheck(Class2::Val6i, val)
+
+val = 0
+val = enumCheck(Class2::Enum14_Val1, 2141)
+val = enumCheck(Class2::Enum14_Val2, 2142)
+val = enumCheck(Class2::Enum14_Val3, val)
+val = enumCheck(Class2::Enum14_Val4, val)
+val = enumCheck(Class2::Enum14_Val5j, 2141)
+val = enumCheck(Class2::Enum14_Val6j, val)
+
+# Requires nested class support to work
+#val = 0
+#val = enumCheck(Class2::Struct1.Enum12_Val1, 4121)
+#val = enumCheck(Class2::Struct1.Enum12_Val2, 4122)
+#val = enumCheck(Class2::Struct1.Enum12_Val3, val)
+#val = enumCheck(Class2::Struct1.Enum12_Val4, val)
+#val = enumCheck(Class2::Struct1.Enum12_Val5k, 4121)
+#val = enumCheck(Class2::Struct1.Enum12_Val6k, val)
+#
+#val = 0
+#val = enumCheck(Class2::Struct1.Val1, 4131)
+#val = enumCheck(Class2::Struct1.Val2, 4132)
+#val = enumCheck(Class2::Struct1.Val3, val)
+#val = enumCheck(Class2::Struct1.Val4, val)
+#val = enumCheck(Class2::Struct1.Val5l, 4131)
+#val = enumCheck(Class2::Struct1.Val6l, val)
+#
+#val = 0
+#val = enumCheck(Class2::Struct1.Enum14_Val1, 4141)
+#val = enumCheck(Class2::Struct1.Enum14_Val2, 4142)
+#val = enumCheck(Class2::Struct1.Enum14_Val3, val)
+#val = enumCheck(Class2::Struct1.Enum14_Val4, val)
+#val = enumCheck(Class2::Struct1.Enum14_Val5m, 4141)
+#val = enumCheck(Class2::Struct1.Enum14_Val6m, val)
+
+class1 = Class1.new
+enumCheck(class1.class1Test1(Enum1_Val5a), 13)
+enumCheck(class1.class1Test2(Class1::Enum12_Val5c), 1121)
+#enumCheck(class1.class1Test3(Class1::Struct1.Enum12_Val5f), 3121)
+
+enumCheck(globalTest1(Enum1_Val5a), 13)
+enumCheck(globalTest2(Class1::Enum12_Val5c), 1121)
+#enumCheck(globalTest3(Class1::Struct1.Enum12_Val5f), 3121)
+
diff --git a/Examples/test-suite/ruby/cpp_namespace_runme.rb b/Examples/test-suite/ruby/cpp_namespace_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/default_constructor_runme.rb b/Examples/test-suite/ruby/default_constructor_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/dynamic_cast_runme.rb b/Examples/test-suite/ruby/dynamic_cast_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/enum_thorough_runme.rb b/Examples/test-suite/ruby/enum_thorough_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/function_typedef_runme.rb b/Examples/test-suite/ruby/function_typedef_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/imports_runme.rb b/Examples/test-suite/ruby/imports_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/integers_runme.rb b/Examples/test-suite/ruby/integers_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_cstring_runme.rb b/Examples/test-suite/ruby/li_cstring_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_math_runme.rb b/Examples/test-suite/ruby/li_math_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_functors_runme.rb b/Examples/test-suite/ruby/li_std_functors_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_map_runme.rb b/Examples/test-suite/ruby/li_std_map_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_multimap_runme.rb b/Examples/test-suite/ruby/li_std_multimap_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_pair_runme.rb b/Examples/test-suite/ruby/li_std_pair_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_queue_runme.rb b/Examples/test-suite/ruby/li_std_queue_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_set_runme.rb b/Examples/test-suite/ruby/li_std_set_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_speed2_runme.rb b/Examples/test-suite/ruby/li_std_speed2_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_stack_runme.rb b/Examples/test-suite/ruby/li_std_stack_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_stream_runme.rb b/Examples/test-suite/ruby/li_std_stream_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_vector_enum_runme.rb b/Examples/test-suite/ruby/li_std_vector_enum_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/namespace_typemap_runme.rb b/Examples/test-suite/ruby/namespace_typemap_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_bool_runme.rb b/Examples/test-suite/ruby/overload_bool_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_copy_runme.rb b/Examples/test-suite/ruby/overload_copy_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_extend_runme.rb b/Examples/test-suite/ruby/overload_extend_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_extendc_runme.rb b/Examples/test-suite/ruby/overload_extendc_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_simple_runme.rb b/Examples/test-suite/ruby/overload_simple_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/overload_template_runme.rb b/Examples/test-suite/ruby/overload_template_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/primitive_ref_runme.rb b/Examples/test-suite/ruby/primitive_ref_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb b/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/sneaky1_runme.rb b/Examples/test-suite/ruby/sneaky1_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/std_containers_runme.rb b/Examples/test-suite/ruby/std_containers_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/stl_new_runme.rb b/Examples/test-suite/ruby/stl_new_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/swig_assert.rb b/Examples/test-suite/ruby/swig_assert.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/swig_gc.rb b/Examples/test-suite/ruby/swig_gc.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/template_inherit_runme.rb b/Examples/test-suite/ruby/template_inherit_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/template_ns4_runme.rb b/Examples/test-suite/ruby/template_ns4_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/template_ns_runme.rb b/Examples/test-suite/ruby/template_ns_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/template_rename_runme.rb b/Examples/test-suite/ruby/template_rename_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/typedef_inherit_runme.rb b/Examples/test-suite/ruby/typedef_inherit_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/typedef_scope_runme.rb b/Examples/test-suite/ruby/typedef_scope_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/typemap_namespace_runme.rb b/Examples/test-suite/ruby/typemap_namespace_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/ruby/typename_runme.rb b/Examples/test-suite/ruby/typename_runme.rb
old mode 100755
new mode 100644
diff --git a/Examples/test-suite/smart_pointer_const_overload.i b/Examples/test-suite/smart_pointer_const_overload.i
index e3b000b..75a137b 100644
--- a/Examples/test-suite/smart_pointer_const_overload.i
+++ b/Examples/test-suite/smart_pointer_const_overload.i
@@ -34,7 +34,7 @@
    Foo() : x(0), xp(&x), y(0), yp(&y), access(0) { }
    int getx() const { return x; }
    void setx(int x_) { x = x_; }
-   static void stat() {}
+   static void statMethod() {}
 };
 %}
 
diff --git a/Examples/test-suite/smart_pointer_templatemethods.i b/Examples/test-suite/smart_pointer_templatemethods.i
index f79bbcc..bd8808a 100644
--- a/Examples/test-suite/smart_pointer_templatemethods.i
+++ b/Examples/test-suite/smart_pointer_templatemethods.i
@@ -45,7 +45,7 @@
 %template(QueryInterfaceObjct) Objct::QueryInterface<Objct>;
 #endif
 
-}; // namespace
+} // namespace
  
 %}
 
diff --git a/Examples/test-suite/struct_initialization.i b/Examples/test-suite/struct_initialization.i
index c378ba3..da1604f 100644
--- a/Examples/test-suite/struct_initialization.i
+++ b/Examples/test-suite/struct_initialization.i
@@ -3,7 +3,7 @@
 
 %inline %{
 
-// Named types
+/* Named types */
 struct StructA {
    int x;
 } instanceA1;
diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in
index 49d2a78..82c59de 100644
--- a/Examples/test-suite/tcl/Makefile.in
+++ b/Examples/test-suite/tcl/Makefile.in
@@ -4,7 +4,8 @@
 
 LANGUAGE     = tcl
 TCLSH        = tclsh
-SCRIPTSUFFIX = _runme.tcl 
+SCRIPTSUFFIX = _runme.tcl
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -27,7 +28,7 @@
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -37,7 +38,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -45,13 +46,13 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.tcl appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(TCLSH) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(TCLSH) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean
 %.clean:
-	
+	@exit 0
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile tcl_clean
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" tcl_clean
diff --git a/Examples/test-suite/tcl/cpp11_strongly_typed_enumerations_runme.tcl b/Examples/test-suite/tcl/cpp11_strongly_typed_enumerations_runme.tcl
new file mode 100644
index 0000000..5132101
--- /dev/null
+++ b/Examples/test-suite/tcl/cpp11_strongly_typed_enumerations_runme.tcl
@@ -0,0 +1,172 @@
+
+if [ catch { load ./cpp11_strongly_typed_enumerations[info sharedlibextension] cpp11_strongly_typed_enumerations} err_msg ] {
+	puts stderr "Could not load shared object:\n$err_msg"
+}
+
+proc enumCheck {actual expected} {
+  if {$actual != $expected} {
+    error "Enum value mismatch. Expected $expected. Actual: $actual"
+  }
+  return [expr $expected + 1]
+}
+
+#set val 0
+#set val [enumCheck $Enum1_Val1  $val]
+#set val [enumCheck $Enum1_Val2  $val]
+
+set val 0
+set val [enumCheck $Enum1_Val1 $val]
+set val [enumCheck $Enum1_Val2 $val]
+set val [enumCheck $Enum1_Val3 13]
+set val [enumCheck $Enum1_Val4 $val]
+set val [enumCheck $Enum1_Val5a 13]
+set val [enumCheck $Enum1_Val6a $val]
+
+set val 0
+set val [enumCheck $Enum2_Val1 $val]
+set val [enumCheck $Enum2_Val2 $val]
+set val [enumCheck $Enum2_Val3 23]
+set val [enumCheck $Enum2_Val4 $val]
+set val [enumCheck $Enum2_Val5b 23]
+set val [enumCheck $Enum2_Val6b $val]
+
+set val 0
+set val [enumCheck $Val1 $val]
+set val [enumCheck $Val2 $val]
+set val [enumCheck $Val3 43]
+set val [enumCheck $Val4 $val]
+
+set val 0
+set val [enumCheck $Enum5_Val1 $val]
+set val [enumCheck $Enum5_Val2 $val]
+set val [enumCheck $Enum5_Val3 53]
+set val [enumCheck $Enum5_Val4 $val]
+
+set val 0
+set val [enumCheck $Enum6_Val1 $val]
+set val [enumCheck $Enum6_Val2 $val]
+set val [enumCheck $Enum6_Val3 63]
+set val [enumCheck $Enum6_Val4 $val]
+
+set val 0
+set val [enumCheck $Enum7td_Val1 $val]
+set val [enumCheck $Enum7td_Val2 $val]
+set val [enumCheck $Enum7td_Val3 73]
+set val [enumCheck $Enum7td_Val4 $val]
+
+set val 0
+set val [enumCheck $Enum8_Val1 $val]
+set val [enumCheck $Enum8_Val2 $val]
+set val [enumCheck $Enum8_Val3 83]
+set val [enumCheck $Enum8_Val4 $val]
+
+set val 0
+set val [enumCheck $Enum10_Val1 $val]
+set val [enumCheck $Enum10_Val2 $val]
+set val [enumCheck $Enum10_Val3 103]
+set val [enumCheck $Enum10_Val4 $val]
+
+set val 0
+set val [enumCheck $Class1_Enum12_Val1 1121]
+set val [enumCheck $Class1_Enum12_Val2 1122]
+set val [enumCheck $Class1_Enum12_Val3 $val]
+set val [enumCheck $Class1_Enum12_Val4 $val]
+set val [enumCheck $Class1_Enum12_Val5c 1121]
+set val [enumCheck $Class1_Enum12_Val6c $val]
+
+set val 0
+set val [enumCheck $Class1_Val1 1131]
+set val [enumCheck $Class1_Val2 1132]
+set val [enumCheck $Class1_Val3 $val]
+set val [enumCheck $Class1_Val4 $val]
+set val [enumCheck $Class1_Val5d 1131]
+set val [enumCheck $Class1_Val6d $val]
+
+set val 0
+set val [enumCheck $Class1_Enum14_Val1 1141]
+set val [enumCheck $Class1_Enum14_Val2 1142]
+set val [enumCheck $Class1_Enum14_Val3 $val]
+set val [enumCheck $Class1_Enum14_Val4 $val]
+set val [enumCheck $Class1_Enum14_Val5e 1141]
+set val [enumCheck $Class1_Enum14_Val6e $val]
+
+# Requires nested class support to work
+#set val 0
+#set val [enumCheck $Class1_Struct1_Enum12_Val1 3121]
+#set val [enumCheck $Class1_Struct1_Enum12_Val2 3122]
+#set val [enumCheck $Class1_Struct1_Enum12_Val3 $val]
+#set val [enumCheck $Class1_Struct1_Enum12_Val4 $val]
+#set val [enumCheck $Class1_Struct1_Enum12_Val5f 3121]
+#set val [enumCheck $Class1_Struct1_Enum12_Val6f $val]
+#
+#set val 0
+#set val [enumCheck $Class1_Struct1_Val1 3131]
+#set val [enumCheck $Class1_Struct1_Val2 3132]
+#set val [enumCheck $Class1_Struct1_Val3 $val]
+#set val [enumCheck $Class1_Struct1_Val4 $val]
+#
+#set val 0
+#set val [enumCheck $Class1_Struct1_Enum14_Val1 3141]
+#set val [enumCheck $Class1_Struct1_Enum14_Val2 3142]
+#set val [enumCheck $Class1_Struct1_Enum14_Val3 $val]
+#set val [enumCheck $Class1_Struct1_Enum14_Val4 $val]
+#set val [enumCheck $Class1_Struct1_Enum14_Val5g 3141]
+#set val [enumCheck $Class1_Struct1_Enum14_Val6g $val]
+
+set val 0
+set val [enumCheck $Class2_Enum12_Val1 2121]
+set val [enumCheck $Class2_Enum12_Val2 2122]
+set val [enumCheck $Class2_Enum12_Val3 $val]
+set val [enumCheck $Class2_Enum12_Val4 $val]
+set val [enumCheck $Class2_Enum12_Val5h 2121]
+set val [enumCheck $Class2_Enum12_Val6h $val]
+
+set val 0
+set val [enumCheck $Class2_Val1 2131]
+set val [enumCheck $Class2_Val2 2132]
+set val [enumCheck $Class2_Val3 $val]
+set val [enumCheck $Class2_Val4 $val]
+set val [enumCheck $Class2_Val5i 2131]
+set val [enumCheck $Class2_Val6i $val]
+
+set val 0
+set val [enumCheck $Class2_Enum14_Val1 2141]
+set val [enumCheck $Class2_Enum14_Val2 2142]
+set val [enumCheck $Class2_Enum14_Val3 $val]
+set val [enumCheck $Class2_Enum14_Val4 $val]
+set val [enumCheck $Class2_Enum14_Val5j 2141]
+set val [enumCheck $Class2_Enum14_Val6j $val]
+
+# Requires nested class support to work
+#set val 0
+#set val [enumCheck $Class2_Struct1_Enum12_Val1 4121]
+#set val [enumCheck $Class2_Struct1_Enum12_Val2 4122]
+#set val [enumCheck $Class2_Struct1_Enum12_Val3 $val]
+#set val [enumCheck $Class2_Struct1_Enum12_Val4 $val]
+#set val [enumCheck $Class2_Struct1_Enum12_Val5k 4121]
+#set val [enumCheck $Class2_Struct1_Enum12_Val6k $val]
+#
+#set val 0
+#set val [enumCheck $Class2_Struct1_Val1 4131]
+#set val [enumCheck $Class2_Struct1_Val2 4132]
+#set val [enumCheck $Class2_Struct1_Val3 $val]
+#set val [enumCheck $Class2_Struct1_Val4 $val]
+#set val [enumCheck $Class2_Struct1_Val5l 4131]
+#set val [enumCheck $Class2_Struct1_Val6l $val]
+#
+#set val 0
+#set val [enumCheck $Class2_Struct1_Enum14_Val1 4141]
+#set val [enumCheck $Class2_Struct1_Enum14_Val2 4142]
+#set val [enumCheck $Class2_Struct1_Enum14_Val3 $val]
+#set val [enumCheck $Class2_Struct1_Enum14_Val4 $val]
+#set val [enumCheck $Class2_Struct1_Enum14_Val5m 4141]
+#set val [enumCheck $Class2_Struct1_Enum14_Val6m $val]
+
+set class1 [Class1]
+enumCheck [$class1 class1Test1 $Enum1_Val5a] 13
+enumCheck [$class1 class1Test2 $Class1_Enum12_Val5c] 1121
+#enumCheck [$class1 class1Test3 $Class1_Struct1_Enum12_Val5f] 3121
+
+enumCheck [globalTest1 $Enum1_Val5a] 13
+enumCheck [globalTest2 $Class1_Enum12_Val5c] 1121
+#enumCheck [globalTest3 $Class1_Struct1_Enum12_Val5f] 3121
diff --git a/Examples/test-suite/template_default_class_parms.i b/Examples/test-suite/template_default_class_parms.i
index cd37269..e5a8c9d 100644
--- a/Examples/test-suite/template_default_class_parms.i
+++ b/Examples/test-suite/template_default_class_parms.i
@@ -31,3 +31,49 @@
 %template(FooAnotherType) Space::Foo<Space::AnotherType>;
 
 %template() Space::ATemplate<>;
+
+
+// Github issue #280 segfault
+%inline %{
+namespace Teuchos {
+  class Describable {};
+}
+namespace KokkosClassic {
+  namespace DefaultNode {
+    struct DefaultNodeType {};
+  };
+}
+
+namespace Tpetra {
+  template <class LocalOrdinal = int,
+            class GlobalOrdinal = LocalOrdinal,
+            class Node = KokkosClassic::DefaultNode::DefaultNodeType>
+  class Map : public Teuchos::Describable {
+  public:
+    typedef LocalOrdinal local_ordinal_type;
+    typedef GlobalOrdinal global_ordinal_type;
+    typedef Node node_type;
+    void test_func(LocalOrdinal, GlobalOrdinal, Node) {}
+  };
+}
+%}
+
+#ifdef SWIGJAVA
+// Fixes still required for other languages
+%template(MapDefaults) Tpetra::Map<>;
+#endif
+
+%inline %{
+namespace Details {
+  template < class LO = ::Tpetra::Map<>::local_ordinal_type,
+            class GO = typename ::Tpetra::Map<LO>::global_ordinal_type,
+            class NT = typename ::Tpetra::Map<LO, GO>::node_type >
+  class Transfer : public Teuchos::Describable {
+  public:
+    void transfer_func(LO, GO, NT) {}
+  };
+}
+%}
+
+// Below is not resolving correctly yet
+//%template(TransferDefaults) Details::Transfer<>;
diff --git a/Examples/test-suite/template_templated_constructors.i b/Examples/test-suite/template_templated_constructors.i
new file mode 100644
index 0000000..ee9df94
--- /dev/null
+++ b/Examples/test-suite/template_templated_constructors.i
@@ -0,0 +1,47 @@
+%module template_templated_constructors
+
+%inline %{
+namespace ConstructSpace {
+
+class TConstructor1 {
+public:
+  template<typename T> TConstructor1(T val) {}
+  ~TConstructor1() {}
+};
+
+class TConstructor2 {
+public:
+  TConstructor2() {}
+  template<typename T> TConstructor2(T val) {}
+  ~TConstructor2() {}
+};
+
+template<typename T> class TClass1 {
+public:
+  template<typename Y> TClass1(Y t) {}
+};
+
+template<typename T> class TClass2 {
+public:
+  TClass2() {}
+  template<typename Y> TClass2(Y t) {}
+};
+
+}
+%}
+
+%extend ConstructSpace::TConstructor1 {
+  %template(TConstructor1) TConstructor1<int>;
+}
+
+%template(TConstructor2) ConstructSpace::TConstructor2::TConstructor2<int>;
+
+%template(TClass1Int) ConstructSpace::TClass1<int>;
+%extend ConstructSpace::TClass1<int> {
+  %template(TClass1Int) TClass1<double>;
+}
+
+%template(TClass2Int) ConstructSpace::TClass2<int>;
+%extend ConstructSpace::TClass2<int> {
+  %template(TClass2Int) TClass2<double>;
+}
diff --git a/Examples/test-suite/template_typedef_typedef.i b/Examples/test-suite/template_typedef_typedef.i
index 30077c4..ac96b2d 100644
--- a/Examples/test-suite/template_typedef_typedef.i
+++ b/Examples/test-suite/template_typedef_typedef.i
@@ -1,7 +1,7 @@
 %module template_typedef_typedef
 
 // Github issue #50
-// The Object2::getBlabla2 and Object::getBlabla1 functions were not resolving to the correct template types
+// The Object2::getBlabla2 and Object1::getBlabla1 functions were not resolving to the correct template types
 
 %inline%{
 
@@ -20,7 +20,7 @@
                 };
         };
         template <typename T>
-        class Object:public T {
+        class Object1:public T {
         public:
                 void getBlabla1(typename T::ABCD::CC1 c) {
                 };
@@ -29,7 +29,7 @@
 
 class Factory {
         public:
-        typedef TT::Object<Base> CC1;
+        typedef TT::Object1<Base> CC1;
         typedef TT::Object2<Base> CC2;
         void getBlabla4(CC2 c) {
         };
@@ -38,6 +38,6 @@
 };
 %}
 
-%template(ObjectBase) TT::Object<Base>;
+%template(Object1Base) TT::Object1<Base>;
 %template(Object2Base) TT::Object2<Base>;
 
diff --git a/Examples/test-suite/threads_exception.i b/Examples/test-suite/threads_exception.i
index b374f0c..caa79c7 100644
--- a/Examples/test-suite/threads_exception.i
+++ b/Examples/test-suite/threads_exception.i
@@ -52,4 +52,10 @@
      return 1;
   }
 };
+
+#ifdef SWIGPYTHON_BUILTIN
+bool is_python_builtin() { return true; }
+#else
+bool is_python_builtin() { return false; }
+#endif
 %}
diff --git a/Examples/test-suite/throw_exception.i b/Examples/test-suite/throw_exception.i
index c1ad945..396c633 100644
--- a/Examples/test-suite/throw_exception.i
+++ b/Examples/test-suite/throw_exception.i
@@ -16,15 +16,15 @@
 
 %inline %{
 
-class Error {
+class CError {
 };
 
-void test_is_Error(Error *r) {}
+void test_is_Error(CError *r) {}
 
 namespace Namespace {
-  typedef Error ErrorTypedef;
-  typedef const Error& ErrorRef;
-  typedef const Error* ErrorPtr;
+  typedef CError ErrorTypedef;
+  typedef const CError& ErrorRef;
+  typedef const CError* ErrorPtr;
   typedef int IntArray[10];
   enum EnumTest { enum1, enum2 };
 }
@@ -36,26 +36,26 @@
     void test_msg() throw(const char *) {
       throw "Dead";
     }
-    void test_cls() throw(Error) {
-      throw Error();
+    void test_cls() throw(CError) {
+      throw CError();
     }	
-    void test_cls_ptr() throw(Error *) {
-      static Error StaticError;
+    void test_cls_ptr() throw(CError *) {
+      static CError StaticError;
       throw &StaticError;
     }	
-    void test_cls_ref() throw(Error &) {
-      static Error StaticError;
+    void test_cls_ref() throw(CError &) {
+      static CError StaticError;
       throw StaticError;
     }	
     void test_cls_td() throw(Namespace::ErrorTypedef) {
-      throw Error();
+      throw CError();
     }	
     void test_cls_ptr_td() throw(Namespace::ErrorPtr) {
-      static Error StaticError;
+      static CError StaticError;
       throw &StaticError;
     }	
     void test_cls_ref_td() throw(Namespace::ErrorRef) {
-      static Error StaticError;
+      static CError StaticError;
       throw StaticError;
     }	
     void test_array() throw(Namespace::IntArray) {
@@ -68,10 +68,10 @@
     void test_enum() throw(Namespace::EnumTest) {
       throw Namespace::enum2;
     }	
-    void test_multi(int x) throw(int, const char *, Error) {
+    void test_multi(int x) throw(int, const char *, CError) {
       if (x == 1) throw 37;
       if (x == 2) throw "Dead";
-      if (x == 3) throw Error();
+      if (x == 3) throw CError();
     }
 };
 
diff --git a/Examples/test-suite/typemap_array_qualifiers.i b/Examples/test-suite/typemap_array_qualifiers.i
index 14df649..cbc6c95 100644
--- a/Examples/test-suite/typemap_array_qualifiers.i
+++ b/Examples/test-suite/typemap_array_qualifiers.i
@@ -43,8 +43,8 @@
 /* Correct typemap for $symname: $type */
 }
 %inline %{
-  void func1a(myarray x) {};
-  void func1b(volatile myarray x) {};
+  void func1a(myarray x) {}
+  void func1b(volatile myarray x) {}
 %}
 
 CLEAR_SWIGTYPE_TYPEMAPS;
@@ -57,9 +57,9 @@
 /* Correct typemap for $symname: $type */
 }
 %inline %{
-  void func2a(const myarray x) {};
-  void func2b(const myconstarray x) {};
-  void func2c(const volatile myconstarray x) {};
+  void func2a(const myarray x) {}
+  void func2b(const myconstarray x) {}
+  void func2c(const volatile myconstarray x) {}
 %}
 
 CLEAR_SWIGTYPE_TYPEMAPS;
@@ -72,7 +72,7 @@
 /* Correct typemap for $symname: $type */
 }
 %inline %{
-  void func3a(const mycrazyarray x, const mycrazyarray y[7]) {};
+  void func3a(const mycrazyarray x, const mycrazyarray y[7]) {}
 %}
 
 CLEAR_SWIGTYPE_TYPEMAPS;
@@ -81,5 +81,5 @@
 /* Correct typemap for $symname: $type */
 }
 %inline %{
-  void func4a(mycrazyfunc *const x, const mycrazyfuncptr y) {};
+  void func4a(mycrazyfunc *const x, const mycrazyfuncptr y) {}
 %}
diff --git a/Examples/test-suite/typemap_directorout.i b/Examples/test-suite/typemap_directorout.i
index 4a85bd4..79d0f8d 100644
--- a/Examples/test-suite/typemap_directorout.i
+++ b/Examples/test-suite/typemap_directorout.i
@@ -23,7 +23,7 @@
 #ifdef SWIGD
 %typemap(ddirectorout) MyType & %{ WILL_NOT_COMPILE %}
 %typemap(ddirectorout) MyType &USEME = SWIGTYPE &;
-%typemap(ddirectorout) MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $typemap(ddirectorout, MyType &USEME) /* special end */ %}
+%typemap(ddirectorout, nativepointer="cast(void*)$dcall") MyType &Class1::foo2, MyType &foo1 %{ /* special start */ $typemap(ddirectorout, MyType &USEME) /* special end */ %}
 #endif
 
 #ifdef SWIGJAVA
diff --git a/Examples/test-suite/typemap_variables.i b/Examples/test-suite/typemap_variables.i
index 142e350..687cae1 100644
--- a/Examples/test-suite/typemap_variables.i
+++ b/Examples/test-suite/typemap_variables.i
@@ -13,33 +13,44 @@
 %}
 #endif
 
+// For Javascript V8 we can not use '0' for out typemaps
+#if defined(SWIG_JAVASCRIPT_V8)
+%header %{
+#define OUT_NULL_VALUE SWIGV8_NULL()
+%}
+#else
+%header %{
+#define OUT_NULL_VALUE 0
+%}
+#endif
+
 // Scripting languages use varin/varout for variables (except non-static member variables where in/out are used ???)
 %typemap(varin)  int                           "this_will_not_compile_varin "
 %typemap(varout) int                           "this_will_not_compile_varout"
 %typemap(varin)  int globul                    "/*int globul varin */ TYPEMAP_VARIABLES_FAIL"
-%typemap(varout) int globul                    "/*int globul varout*/ $result=0;"
+%typemap(varout) int globul                    "/*int globul varout*/ $result=OUT_NULL_VALUE;"
 %typemap(varin)  int Space::nspace             "/*int nspace varin */ TYPEMAP_VARIABLES_FAIL"
-%typemap(varout) int Space::nspace             "/*int nspace varout*/ $result=0;"
+%typemap(varout) int Space::nspace             "/*int nspace varout*/ $result=OUT_NULL_VALUE;"
 //%typemap(varin)  int member                    "/*int member varin */"
-//%typemap(varout) int member                    "/*int member varout*/ $result=0;"
+//%typemap(varout) int member                    "/*int member varout*/ $result=OUT_NULL_VALUE;"
 %typemap(varin)  int Space::Struct::smember    "/*int smember varin */ TYPEMAP_VARIABLES_FAIL"
-%typemap(varout) int Space::Struct::smember    "/*int smember varout*/ $result=0;"
+%typemap(varout) int Space::Struct::smember    "/*int smember varout*/ $result=OUT_NULL_VALUE;"
 
 // Statically typed languages use in/out for variables
 %typemap(in)  int                           "this_will_not_compile_in "
 %typemap(out) int                           "this_will_not_compile_out"
 %typemap(in)  int globul                    "/*int globul in */ $1=0;"
-%typemap(out) int globul                    "/*int globul out*/ $result=0;"
+%typemap(out) int globul                    "/*int globul out*/ $result=OUT_NULL_VALUE;"
 %typemap(in)  int Space::nspace             "/*int nspace in */ $1=0;"
-%typemap(out) int Space::nspace             "/*int nspace out*/ $result=0;"
+%typemap(out) int Space::nspace             "/*int nspace out*/ $result=OUT_NULL_VALUE;"
 %typemap(in)  int member                    "/*int member in */ $1=0;"
 #ifdef SWIGTCL
 %typemap(out) int member                    "/*int member out*/"
 #else
-%typemap(out) int member                    "/*int member out*/ $result=0;"
+%typemap(out) int member                    "/*int member out*/ $result=OUT_NULL_VALUE;"
 #endif
 %typemap(in)  int Space::Struct::smember    "/*int smember in */ $1=0;"
-%typemap(out) int Space::Struct::smember    "/*int smember out*/ $result=0;"
+%typemap(out) int Space::Struct::smember    "/*int smember out*/ $result=OUT_NULL_VALUE;"
 
 %typemap(javain)  int                           "this_will_not_compile_javain "
 %typemap(javaout) int                           "this_will_not_compile_javaout"
diff --git a/Examples/test-suite/uffi/Makefile.in b/Examples/test-suite/uffi/Makefile.in
index 8ad1539..275778c 100644
--- a/Examples/test-suite/uffi/Makefile.in
+++ b/Examples/test-suite/uffi/Makefile.in
@@ -5,6 +5,7 @@
 LANGUAGE     = uffi
 UFFI         = @UFFIBIN@
 SCRIPTSUFFIX = _runme.lisp
+
 srcdir       = @srcdir@
 top_srcdir   = @top_srcdir@
 top_builddir = @top_builddir@
@@ -14,13 +15,13 @@
 # Overridden variables here
 # no C++ tests for now
 CPP_TEST_CASES =
-#C_TEST_CASES += 
+#C_TEST_CASES +=
 
 # Custom tests - tests with additional commandline options
 # none!
 
 # Rules for the different types of tests
-%.cpptest: 
+%.cpptest:
 	$(setup)
 	+$(swig_and_compile_cpp)
 	$(run_testcase)
@@ -30,7 +31,7 @@
 	+$(swig_and_compile_c)
 	$(run_testcase)
 
-%.multicpptest: 
+%.multicpptest:
 	$(setup)
 	+$(swig_and_compile_multi_cpp)
 	$(run_testcase)
@@ -38,14 +39,13 @@
 # Runs the testcase. A testcase is only run if
 # a file is found which has _runme.lisp appended after the testcase name.
 run_testcase = \
-	if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
-	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFI) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+	if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
+	  env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFI) -batch -s $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
 	fi
 
 # Clean: (does nothing, we dont generate extra uffi code)
 %.clean:
-	
+	@exit 0
 
 clean:
-	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile uffi_clean
-
+	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" uffi_clean
diff --git a/Examples/test-suite/unicode_strings.i b/Examples/test-suite/unicode_strings.i
new file mode 100644
index 0000000..56063c8
--- /dev/null
+++ b/Examples/test-suite/unicode_strings.i
@@ -0,0 +1,15 @@
+%module unicode_strings
+
+%include <std_string.i>
+
+%inline %{
+
+const char* non_utf8_c_str(void) {
+        return "h\xe9llo w\xc3\xb6rld";
+}
+
+std::string non_utf8_std_string(void) {
+        return std::string("h\xe9llo w\xc3\xb6rld");
+}
+
+%}
diff --git a/Lib/carrays.i b/Lib/carrays.i
index f125105..201c17c 100644
--- a/Lib/carrays.i
+++ b/Lib/carrays.i
@@ -22,7 +22,7 @@
 %{
 static TYPE *new_##NAME(int nelements) { %}
 #ifdef __cplusplus
-%{  return new TYPE[nelements]; %}
+%{  return new TYPE[nelements](); %}
 #else
 %{  return (TYPE *) calloc(nelements,sizeof(TYPE)); %}
 #endif
diff --git a/Lib/csharp/arrays_csharp.i b/Lib/csharp/arrays_csharp.i
index 174a282..237067a 100644
--- a/Lib/csharp/arrays_csharp.i
+++ b/Lib/csharp/arrays_csharp.i
@@ -103,6 +103,7 @@
 CSHARP_ARRAYS(unsigned long long, ulong)
 CSHARP_ARRAYS(float, float)
 CSHARP_ARRAYS(double, double)
+CSHARP_ARRAYS(bool, bool)
 
 
 %define CSHARP_ARRAYS_FIXED( CTYPE, CSTYPE )
@@ -134,4 +135,5 @@
 CSHARP_ARRAYS_FIXED(unsigned long long, ulong)
 CSHARP_ARRAYS_FIXED(float, float)
 CSHARP_ARRAYS_FIXED(double, double)
+CSHARP_ARRAYS_FIXED(bool, bool)
 
diff --git a/Lib/d/boost_shared_ptr.i b/Lib/d/boost_shared_ptr.i
index bfa2aa6..5c17155 100644
--- a/Lib/d/boost_shared_ptr.i
+++ b/Lib/d/boost_shared_ptr.i
@@ -152,7 +152,7 @@
   swigCMemOwn = ownCObject;
 }
 
-public static void* swigGetCPtr($dclassname obj) {
+public static void* swigGetCPtr(typeof(this) obj) {
   return (obj is null) ? null : obj.swigCPtr;
 }
 %}
@@ -167,7 +167,7 @@
   swigCMemOwn = ownCObject;
 }
 
-public static void* swigGetCPtr($dclassname obj) {
+public static void* swigGetCPtr(typeof(this) obj) {
   return (obj is null) ? null : obj.swigCPtr;
 }
 %}
diff --git a/Lib/d/dclassgen.swg b/Lib/d/dclassgen.swg
index ceaf507..68910b4 100644
--- a/Lib/d/dclassgen.swg
+++ b/Lib/d/dclassgen.swg
@@ -72,7 +72,7 @@
   swigCMemOwn = ownCObject;
 }
 
-public static void* swigGetCPtr($dclassname obj) {
+public static void* swigGetCPtr(typeof(this) obj) {
   return (obj is null) ? null : obj.swigCPtr;
 }
 
@@ -88,7 +88,7 @@
   swigCPtr = cObject;
 }
 
-public static void* swigGetCPtr($dclassname obj) {
+public static void* swigGetCPtr(typeof(this) obj) {
   return (obj is null) ? null : obj.swigCPtr;
 }
 
@@ -111,7 +111,7 @@
   swigCPtr = null;
 }
 
-public static void* swigGetCPtr($dclassname obj) {
+public static void* swigGetCPtr(typeof(this) obj) {
   return (obj is null) ? null : obj.swigCPtr;
 }
 
@@ -134,7 +134,7 @@
   swigCPtr = null;
 }
 
-package static char* swigGetCMemberPtr($dclassname obj) {
+package static char* swigGetCMemberPtr(typeof(this) obj) {
   return (obj is null) ? null : obj.swigCPtr;
 }
 
diff --git a/Lib/d/denums.swg b/Lib/d/denums.swg
index 5917da9..3f81246 100644
--- a/Lib/d/denums.swg
+++ b/Lib/d/denums.swg
@@ -16,10 +16,10 @@
 %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE ""
 
 %typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
-%typemap(out) enum SWIGTYPE %{ $result = $1; %}
+%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
 
 %typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
-%typemap(directorin) enum SWIGTYPE "$input = $1;"
+%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
 %typemap(ddirectorin) enum SWIGTYPE "cast($dclassname)$winput"
 %typemap(ddirectorout) enum SWIGTYPE "cast(int)$dcall"
 
@@ -43,9 +43,9 @@
 %typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
 %{ temp = ($*1_ltype)$input;
    $1 = &temp; %}
-%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %}
+%typemap(out) const enum SWIGTYPE & %{ $result = (int)*$1; %}
 
-%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
+%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
 %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
 %{ static $*1_ltype temp = ($*1_ltype)$input;
    $result = &temp; %}
diff --git a/Lib/d/dhead.swg b/Lib/d/dhead.swg
index 7a2f4fd..786ca6e 100644
--- a/Lib/d/dhead.swg
+++ b/Lib/d/dhead.swg
@@ -93,31 +93,26 @@
 
   static void setException(char* message) {
     auto exception = new object.Exception(tango.stdc.stringz.fromStringz(message).dup);
-    exception.next = SwigPendingException.retrieve();
     SwigPendingException.set(exception);
   }
 
   static void setIllegalArgumentException(char* message) {
     auto exception = new tango.core.Exception.IllegalArgumentException(tango.stdc.stringz.fromStringz(message).dup);
-    exception.next = SwigPendingException.retrieve();
     SwigPendingException.set(exception);
   }
 
   static void setIllegalElementException(char* message) {
     auto exception = new tango.core.Exception.IllegalElementException(tango.stdc.stringz.fromStringz(message).dup);
-    exception.next = SwigPendingException.retrieve();
     SwigPendingException.set(exception);
   }
 
   static void setIOException(char* message) {
     auto exception = new tango.core.Exception.IOException(tango.stdc.stringz.fromStringz(message).dup);
-    exception.next = SwigPendingException.retrieve();
     SwigPendingException.set(exception);
   }
 
   static void setNoSuchElementException(char* message) {
     auto exception = new tango.core.Exception.NoSuchElementException(tango.stdc.stringz.fromStringz(message).dup);
-    exception.next = SwigPendingException.retrieve();
     SwigPendingException.set(exception);
   }
 }
@@ -125,51 +120,31 @@
 package class SwigPendingException {
 public:
   static this() {
-    m_sPendingCount = 0;
     m_sPendingException = new ThreadLocalData(null);
   }
 
   static bool isPending() {
-    bool pending = false;
-    if (m_sPendingCount > 0) {
-      if (m_sPendingException.val !is null) {
-        pending = true;
-      }
-    }
-    return pending;
+    return m_sPendingException.val !is null;
   }
 
   static void set(object.Exception e) {
-    if (m_sPendingException.val !is null) {
-      throw new object.Exception("FATAL: An earlier pending exception from C/C++ code " ~
-        "was missed and thus not thrown (" ~ m_sPendingException.val.classinfo.name ~
-        ": " ~ m_sPendingException.val.msg ~ ")!", e);
+    auto pending = m_sPendingException.val;
+    if (pending !is null) {
+      e.next = pending;
+      throw new object.Exception("FATAL: An earlier pending exception from C/C++ " ~
+        "code was missed and thus not thrown (" ~ pending.classinfo.name ~ ": " ~
+        pending.msg ~ ")!", e);
     }
-
     m_sPendingException.val = e;
-    synchronized {
-      ++m_sPendingCount;
-    }
   }
 
   static object.Exception retrieve() {
-    object.Exception e = null;
-    if (m_sPendingCount > 0) {
-      if (m_sPendingException.val !is null) {
-        e = m_sPendingException.val;
-        m_sPendingException.val = null;
-        synchronized {
-          --m_sPendingCount;
-        }
-      }
-    }
+    auto e = m_sPendingException.val;
+    m_sPendingException.val = null;
     return e;
   }
 
 private:
-  // The pending exception counter is stored thread-global.
-  static int m_sPendingCount;
-
   // The reference to the pending exception (if any) is stored thread-local.
   alias tango.core.Thread.ThreadLocal!(object.Exception) ThreadLocalData;
   static ThreadLocalData m_sPendingException;
@@ -195,8 +170,7 @@
   }
 
   static void setException(const char* message) {
-    auto exception = new object.Exception(std.conv.to!string(message).idup);
-    exception.next = SwigPendingException.retrieve();
+    auto exception = new object.Exception(std.conv.to!string(message));
     SwigPendingException.set(exception);
   }
 }
@@ -204,51 +178,31 @@
 package struct SwigPendingException {
 public:
   static this() {
-    m_sPendingCount = 0;
     m_sPendingException = null;
   }
 
   static bool isPending() {
-    bool pending = false;
-    if (m_sPendingCount > 0) {
-      if (m_sPendingException !is null) {
-        pending = true;
-      }
-    }
-    return pending;
+    return m_sPendingException !is null;
   }
 
   static void set(object.Exception e) {
     if (m_sPendingException !is null) {
+      e.next = m_sPendingException;
       throw new object.Exception("FATAL: An earlier pending exception from C/C++ code " ~
         "was missed and thus not thrown (" ~ m_sPendingException.classinfo.name ~
         ": " ~ m_sPendingException.msg ~ ")!", e);
     }
 
     m_sPendingException = e;
-    synchronized {
-      ++m_sPendingCount;
-    }
   }
 
   static object.Exception retrieve() {
-    object.Exception e = null;
-    if (m_sPendingCount > 0) {
-      if (m_sPendingException !is null) {
-        e = m_sPendingException;
-        m_sPendingException = null;
-        synchronized {
-          --m_sPendingCount;
-        }
-      }
-    }
+    auto e = m_sPendingException;
+    m_sPendingException = null;
     return e;
   }
 
 private:
-  // The pending exception counter is stored thread-global.
-  static shared int m_sPendingCount;
-
   // The reference to the pending exception (if any) is stored thread-local.
   static object.Exception m_sPendingException;
 }
diff --git a/Lib/gcj/cni.i b/Lib/gcj/cni.i
index b12148e..fcc5668 100644
--- a/Lib/gcj/cni.i
+++ b/Lib/gcj/cni.i
@@ -4,10 +4,6 @@
 
 %include <gcj/javaprims.i>
 
-extern jobject JvAllocObject (jclass cls);
-
-extern jobject JvAllocObject (jclass cls, jsize sz);
-
 extern void JvInitClass (jclass cls);
 
 extern jstring JvAllocString (jsize sz);
@@ -30,7 +26,7 @@
 
 extern void JvFree (void *ptr);
 
-extern jint JvCreateJavaVM (void* vm_args);
+extern jint JvCreateJavaVM (JvVMInitArgs* vm_args);
 
 extern java::lang::Thread* JvAttachCurrentThread (jstring name, java::lang::ThreadGroup* group);
 
diff --git a/Lib/go/go.swg b/Lib/go/go.swg
index 0c03ae5..c680844 100644
--- a/Lib/go/go.swg
+++ b/Lib/go/go.swg
@@ -225,13 +225,13 @@
 %{ $1 = *($&1_ltype)&$input; %}
 
 %typemap(out) SWIGTYPE *
-%{ *($&1_ltype)&$result = $1; %}
+%{ *($&1_ltype)&$result = ($1_ltype)$1; %}
 
 %typemap(directorin) SWIGTYPE *
-%{ $input = ($1_ltype)$1; %}
+%{ *($&1_ltype)&$input = ($1_ltype)$1; %}
 
 %typemap(directorout) SWIGTYPE *
-%{ $result = ($1_ltype)$input; %}
+%{ $result = *($&1_ltype)&$input; %}
 
 %apply SWIGTYPE * { SWIGTYPE *const }
 
diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg
index 612f830..ef64186 100644
--- a/Lib/go/goruntime.swg
+++ b/Lib/go/goruntime.swg
@@ -57,12 +57,21 @@
 extern "C" {
 #endif
 extern void crosscall2(void (*fn)(void *, int), void *, int);
+extern char* _cgo_topofstack(void) __attribute__ ((weak));
 extern void _cgo_allocate(void *, int);
 extern void _cgo_panic(void *, int);
 #ifdef __cplusplus
 }
 #endif
 
+static char *_swig_topofstack() {
+  if (_cgo_topofstack) {
+    return _cgo_topofstack();
+  } else {
+    return 0;
+  }
+}
+
 static void *_swig_goallocate(size_t len) {
   struct {
     size_t len;
@@ -89,11 +98,11 @@
 #include "runtime.h"
 #include "cgocall.h"
 
-#ifdef _64BIT
-#define SWIG_PARM_SIZE 8
-#else
-#define SWIG_PARM_SIZE 4
-#endif
+#pragma dataflag 16
+static void *cgocall = runtime·cgocall;
+#pragma dataflag 16
+void *·_cgo_runtime_cgocall = &cgocall;
+
 %}
 
 #else
@@ -116,7 +125,7 @@
    file is the same as the version of gccgo.  */
 
 #define SWIG_GCC_VERSION \
-  (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC__PATH_LEVEL__)
+  (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
 
 #if SWIG_GCC_VERSION < 40700
 #define SwigDoCgocall()
@@ -194,6 +203,10 @@
 
 %go_import("unsafe", _ "runtime/cgo")
 
+%insert(go_header) %{
+var _cgo_runtime_cgocall func(unsafe.Pointer, uintptr)
+%}
+
 #else
 
 %go_import("syscall", "unsafe")
@@ -212,6 +225,16 @@
 
 %}
 
+/* Swig_always_false is used to conditionally assign parameters to
+   Swig_escape_val so that the compiler thinks that they escape.  We
+   only assign them if Swig_always_false is true, which it never is.
+   We export the variable so that the compiler doesn't realize that it
+   is never set. */
+%insert(go_header) %{
+var Swig_escape_always_false bool
+var Swig_escape_val interface{}
+%}
+
 /* Function pointers are translated by the code in go.cxx into
    _swig_fnptr.  Member pointers are translated to _swig_memberptr.  */
 
diff --git a/Lib/guile/Makefile b/Lib/guile/Makefile
index 17f5fec..fba7fd5 100644
--- a/Lib/guile/Makefile
+++ b/Lib/guile/Makefile
@@ -1,4 +1,3 @@
 
 co:
 	co RCS/*.i* RCS/*.swg*
-
diff --git a/Lib/guile/guile_scm_run.swg b/Lib/guile/guile_scm_run.swg
index 322d660..94cf4d1 100644
--- a/Lib/guile/guile_scm_run.swg
+++ b/Lib/guile/guile_scm_run.swg
@@ -27,8 +27,7 @@
 #endif
 
 #if SCM_MAJOR_VERSION >= 2
-// scm_c_define_gsubr takes a different parameter type
-// depending on the guile version
+/* scm_c_define_gsubr takes a different parameter type depending on the guile version */
 
 typedef scm_t_subr swig_guile_proc;
 #else
diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i
index d818613..a01e73f 100644
--- a/Lib/guile/typemaps.i
+++ b/Lib/guile/typemaps.i
@@ -172,11 +172,11 @@
   }
   * (int *) &($1) = scm_to_int($input);
 }
-%typemap(out)    enum SWIGTYPE  { $result = scm_from_long($1); }
-%typemap(varout) enum SWIGTYPE  { $result = scm_from_long($1); }
+%typemap(out)    enum SWIGTYPE  { $result = scm_from_long((int)$1); }
+%typemap(varout) enum SWIGTYPE  { $result = scm_from_long((int)$1); }
 %typemap(throws) enum SWIGTYPE {
   scm_throw(scm_from_locale_symbol((char *) "swig-exception"),
-     scm_listify(scm_from_long($1), SCM_UNDEFINED));
+     scm_listify(scm_from_long((int)$1), SCM_UNDEFINED));
 }
 
 /* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of
diff --git a/Lib/java/director.swg b/Lib/java/director.swg
index 819ad90..031cdf2 100644
--- a/Lib/java/director.swg
+++ b/Lib/java/director.swg
@@ -100,6 +100,22 @@
     bool weak_global_;
   };
 
+  /* Local JNI reference deleter */
+  class LocalRefGuard {
+    JNIEnv *jenv_;
+    jobject jobj_;
+
+    // non-copyable
+    LocalRefGuard(const LocalRefGuard &);
+    LocalRefGuard &operator=(const LocalRefGuard &);
+  public:
+    LocalRefGuard(JNIEnv *jenv, jobject jobj): jenv_(jenv), jobj_(jobj) {}
+    ~LocalRefGuard() {
+      if (jobj_)
+        jenv_->DeleteLocalRef(jobj_);
+    }
+  };
+
   /* director base class */
   class Director {
     /* pointer to Java virtual machine */
@@ -152,6 +168,7 @@
       JNIEnvWrapper jnienv(this) ;
       JNIEnv *jenv = jnienv.getJNIEnv() ;
       jobject jobj = swig_self_.get(jenv);
+      LocalRefGuard ref_deleter(jenv, jobj);
 #if defined(DEBUG_DIRECTOR_OWNED)
       std::cout << "Swig::Director::disconnect_director_self(" << jobj << ")" << std::endl;
 #endif
@@ -164,7 +181,6 @@
           jenv->CallVoidMethod(jobj, disconn_meth);
         }
       }
-      jenv->DeleteLocalRef(jobj);
     }
 
   public:
@@ -379,6 +395,5 @@
     }
     return matches;
   }
-
 }
 
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index 3d4d837..98524e8 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -400,11 +400,13 @@
 }
 
 %typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * {
- $input = 0;
+  $input = 0;
   if ($1) {
     $input = JCALL1(NewStringUTF, jenv, (const char *)$1);
     if (!$input) return $null;
   }
+  Swig::LocalRefGuard $1_refguard(jenv, $input);
+// boohoo
 }
 
 %typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); }
@@ -731,6 +733,7 @@
     $input = JCALL1(NewStringUTF, jenv, (const char *)$1);
     if (!$input) return $null;
   }
+  Swig::LocalRefGuard $1_refguard(jenv, $input);
 }
 
 %typemap(argout) char[ANY], char[] ""
diff --git a/Lib/java/std_string.i b/Lib/java/std_string.i
index 5ad7d30..830a896 100644
--- a/Lib/java/std_string.i
+++ b/Lib/java/std_string.i
@@ -49,7 +49,8 @@
    jenv->ReleaseStringUTFChars($input, $1_pstr); %}
 
 %typemap(directorin,descriptor="Ljava/lang/String;") string 
-%{ $input = jenv->NewStringUTF($1.c_str()); %}
+%{ $input = jenv->NewStringUTF($1.c_str());
+   Swig::LocalRefGuard $1_refguard(jenv, $input); %}
 
 %typemap(out) string 
 %{ $result = jenv->NewStringUTF($1.c_str()); %}
@@ -98,7 +99,8 @@
    jenv->ReleaseStringUTFChars($input, $1_pstr); %}
 
 %typemap(directorin,descriptor="Ljava/lang/String;") const string &
-%{ $input = jenv->NewStringUTF($1.c_str()); %}
+%{ $input = jenv->NewStringUTF($1.c_str());
+   Swig::LocalRefGuard $1_refguard(jenv, $input); %}
 
 %typemap(out) const string & 
 %{ $result = jenv->NewStringUTF($1->c_str()); %}
diff --git a/Lib/java/various.i b/Lib/java/various.i
index 7ba7a5e..bfcf346 100644
--- a/Lib/java/various.i
+++ b/Lib/java/various.i
@@ -92,6 +92,7 @@
  * The returned string appears in the 1st element of the passed in Java String array.
  *
  * Example usage wrapping:
+ *   %apply char **STRING_OUT { char **string_out };
  *   void foo(char **string_out);
  *  
  * Java usage:
@@ -154,3 +155,40 @@
 /* Prevent default freearg typemap from being used */
 %typemap(freearg) char *BYTE ""
 
+/* 
+ * unsigned char *NIOBUFFER typemaps. 
+ * This is for mapping Java nio buffers to C char arrays.
+ * It is useful for performance critical code as it reduces the memory copy an marshaling overhead.
+ * Note: The Java buffer has to be allocated with allocateDirect.
+ *
+ * Example usage wrapping:
+ *   %apply unsigned char *NIOBUFFER { unsigned char *buf };
+ *   void foo(unsigned char *buf);
+ *  
+ * Java usage:
+ *   java.nio.ByteBuffer b = ByteBuffer.allocateDirect(20); 
+ *   modulename.foo(b);
+ */
+%typemap(jni) unsigned char *NIOBUFFER "jobject"  
+%typemap(jtype) unsigned char *NIOBUFFER "java.nio.ByteBuffer"  
+%typemap(jstype) unsigned char *NIOBUFFER "java.nio.ByteBuffer"  
+%typemap(javain,
+  pre="  assert $javainput.isDirect() : \"Buffer must be allocated direct.\";") unsigned char *NIOBUFFER "$javainput"
+%typemap(javaout) unsigned char *NIOBUFFER {  
+  return $jnicall;  
+}  
+%typemap(in) unsigned char *NIOBUFFER {  
+  $1 = (unsigned char *) JCALL1(GetDirectBufferAddress, jenv, $input); 
+  if ($1 == NULL) {  
+    SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "Unable to get address of a java.nio.ByteBuffer direct byte buffer. Buffer must be a direct buffer and not a non-direct buffer.");  
+  }  
+}  
+%typemap(memberin) unsigned char *NIOBUFFER {  
+  if ($input) {  
+    $1 = $input;  
+  } else {  
+    $1 = 0;  
+  }  
+}  
+%typemap(freearg) unsigned char *NIOBUFFER ""  
+
diff --git a/Lib/javascript/jsc/javascriptcode.swg b/Lib/javascript/jsc/javascriptcode.swg
index 738b54d..672df86 100644
--- a/Lib/javascript/jsc/javascriptcode.swg
+++ b/Lib/javascript/jsc/javascriptcode.swg
@@ -8,7 +8,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_ctor", "templates")
 %{
-JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
 {
     $jslocals
     if(argc != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
@@ -28,7 +28,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_veto_ctor", "templates")
 %{
-JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject,
+static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject,
     size_t argc, const JSValueRef argv[], JSValueRef* exception)
 {
     SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
@@ -44,7 +44,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_ctor_dispatcher", "templates")
 %{
-JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject,
+static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject,
     size_t argc, const JSValueRef argv[], JSValueRef* exception)
 {
     JSObjectRef thisObject = NULL;
@@ -70,7 +70,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_overloaded_ctor", "templates")
 %{
-JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
 {
     $jslocals
     $jscode
@@ -105,11 +105,16 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_dtor", "templates")
 %{
-void $jswrapper(JSObjectRef thisObject)
+static void $jswrapper(JSObjectRef thisObject)
 {
   SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(thisObject);
-  if(t && t->swigCMemOwn) free (($jstype)t->swigCObject);
-  if(t) free(t);
+  if(t) {
+    if (t->swigCMemOwn) {
+      free (($jstype)t->swigCObject);
+    }
+    JSObjectSetPrivate(thisObject, NULL);
+    free(t);
+  }
 }
 %}
 
@@ -121,14 +126,18 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_dtoroverride", "templates")
 %{
-void $jswrapper(JSObjectRef thisObject)
+static void $jswrapper(JSObjectRef thisObject)
 {
   SwigPrivData* t = (SwigPrivData*) JSObjectGetPrivate(thisObject);
-  if(t && t->swigCMemOwn) {
-    $jstype arg1 = ($jstype)t->swigCObject;
-    ${destructor_action}
+  if(t) {
+    if (t->swigCMemOwn) {
+      $jstype arg1 = ($jstype)t->swigCObject;
+      ${destructor_action}
+    }
+    /* remove the private data to make sure that it isn't accessed elsewhere */
+    JSObjectSetPrivate(thisObject, NULL);
+    free(t);
   }
-  if(t) free(t);
 }
 %}
 
@@ -140,7 +149,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_getter", "templates")
 %{
-JSValueRef $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
+static JSValueRef $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
 {
     $jslocals
     JSValueRef jsresult;
@@ -150,7 +159,7 @@
 
     goto fail;
     fail:
-    return NULL;
+    return JSValueMakeUndefined(context);
 }
 %}
 
@@ -162,7 +171,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_setter", "templates")
 %{
-bool $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+static bool $jswrapper(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
 {
     $jslocals
     $jscode
@@ -183,7 +192,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_function", "templates")
 %{
-JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
 {
   $jslocals
   JSValueRef jsresult;
@@ -195,7 +204,7 @@
 
   goto fail;
   fail:
-  return NULL;
+  return JSValueMakeUndefined(context);
 }
 %}
 
@@ -208,7 +217,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_function_dispatcher", "templates")
 %{
-JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+static JSValueRef $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
 {
   $jslocals
   JSValueRef jsresult;
@@ -220,7 +229,7 @@
 
   goto fail;
   fail:
-  return NULL;
+  return JSValueMakeUndefined(context);
 }
 %}
 
@@ -232,7 +241,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_overloaded_function", "templates")
 %{
-int $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception, JSValueRef* p_result)
+static int $jswrapper(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception, JSValueRef* p_result)
 {
   $jslocals
   JSValueRef jsresult;
@@ -291,11 +300,11 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("jsc_class_declaration", "templates")
 %{
-JSClassDefinition $jsmangledname_classDefinition;
+static JSClassDefinition $jsmangledname_classDefinition;
 
-JSClassDefinition $jsmangledname_objectDefinition;
+static JSClassDefinition $jsmangledname_objectDefinition;
 
-JSClassRef $jsmangledname_classRef;
+static JSClassRef $jsmangledname_classRef;
 %}
 
 /* -----------------------------------------------------------------------------
@@ -308,22 +317,22 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("jsc_class_tables", "templates")
 %{
-JSStaticValue $jsmangledname_staticValues[] = {
+static JSStaticValue $jsmangledname_staticValues[] = {
   $jsstaticclassvariables
   { 0, 0, 0, 0 }
 };
 
-JSStaticFunction $jsmangledname_staticFunctions[] = {
+static JSStaticFunction $jsmangledname_staticFunctions[] = {
   $jsstaticclassfunctions
   { 0, 0, 0 }
 };
 
-JSStaticValue $jsmangledname_values[] = {
+static JSStaticValue $jsmangledname_values[] = {
   $jsclassvariables
   { 0, 0, 0, 0 }
 };
 
-JSStaticFunction $jsmangledname_functions[] = {
+static JSStaticFunction $jsmangledname_functions[] = {
   $jsclassfunctions
   { 0, 0, 0 }
 };
@@ -341,11 +350,11 @@
   $jsmangledname_classDefinition.staticFunctions = $jsmangledname_staticFunctions;
   $jsmangledname_classDefinition.staticValues = $jsmangledname_staticValues;
   $jsmangledname_classDefinition.callAsConstructor = $jsctor;
-  $jsmangledname_classDefinition.finalize = $jsdtor;
+  $jsmangledname_objectDefinition.finalize = $jsdtor;
   $jsmangledname_objectDefinition.staticValues = $jsmangledname_values;
   $jsmangledname_objectDefinition.staticFunctions = $jsmangledname_functions;
   $jsclass_inheritance
-  JSClassRef $jsmangledname_classRef = JSClassCreate(&$jsmangledname_objectDefinition);
+  $jsmangledname_classRef = JSClassCreate(&$jsmangledname_objectDefinition);
   SWIGTYPE_$jsmangledtype->clientdata = $jsmangledname_classRef;
 %}
 
@@ -382,17 +391,17 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("jsc_nspace_declaration", "templates")
 %{
-JSStaticValue $jsnspace_values[] = {
+static JSStaticValue $jsnspace_values[] = {
   $jsglobalvariables
   { 0, 0, 0, 0 }
 };
 
-JSStaticFunction $jsnspace_functions[] = {
+static JSStaticFunction $jsnspace_functions[] = {
   $jsglobalfunctions
   { 0, 0, 0 }
 };
 
-JSClassDefinition $jsnspace_classDefinition;
+static JSClassDefinition $jsnspace_classDefinition;
 %}
 
 /* -----------------------------------------------------------------------------
diff --git a/Lib/javascript/jsc/javascripthelpers.swg b/Lib/javascript/jsc/javascripthelpers.swg
index 820075c..4052801 100644
--- a/Lib/javascript/jsc/javascripthelpers.swg
+++ b/Lib/javascript/jsc/javascripthelpers.swg
@@ -1,6 +1,6 @@
 %insert(wrapper) %{
  
-bool JS_registerClass(JSGlobalContextRef context, JSObjectRef parentObject,
+SWIGINTERN bool JS_registerClass(JSGlobalContextRef context, JSObjectRef parentObject,
                              const char* className,
                              JSClassDefinition* definition) {
 
@@ -14,7 +14,7 @@
     return true;
 }
 
-bool JS_registerNamespace(JSGlobalContextRef context, 
+SWIGINTERN bool JS_registerNamespace(JSGlobalContextRef context, 
                            JSObjectRef namespaceObj, JSObjectRef parentNamespace,
                            const char* name)
 {
@@ -28,7 +28,7 @@
 }
 
 
-bool JS_registerFunction(JSGlobalContextRef context, JSObjectRef object, 
+SWIGINTERN bool JS_registerFunction(JSGlobalContextRef context, JSObjectRef object, 
                         const char* functionName, JSObjectCallAsFunctionCallback callback)
 {
     JSStringRef js_functionName = JSStringCreateWithUTF8CString(functionName);
@@ -39,7 +39,7 @@
     return true;
 }
 
-bool JS_veto_set_variable(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+SWIGINTERN bool JS_veto_set_variable(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
 {
     char buffer[256];
     char msg[512];
@@ -57,7 +57,7 @@
     return false;
 }
 
-JSValueRef JS_CharPtrToJSValue(JSContextRef context, char* cstr) {
+SWIGINTERN JSValueRef JS_CharPtrToJSValue(JSContextRef context, char* cstr) {
   JSValueRef val;
   
   JSStringRef jsstring = JSStringCreateWithUTF8CString((char*) cstr);
diff --git a/Lib/javascript/jsc/javascriptrun.swg b/Lib/javascript/jsc/javascriptrun.swg
index 3463d23..676a458 100644
--- a/Lib/javascript/jsc/javascriptrun.swg
+++ b/Lib/javascript/jsc/javascriptrun.swg
@@ -7,13 +7,28 @@
 #define SWIG_exception(code, msg) SWIG_JSC_exception(context, exception, code, msg)
 #define SWIG_fail                 goto fail
 
-void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) {
- JSStringRef message = JSStringCreateWithUTF8CString(type);
- *exception = JSValueMakeString(context, message);
- JSStringRelease(message);
+SWIGRUNTIME void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) {
+  JSStringRef message = JSStringCreateWithUTF8CString(type);
+  JSValueRef error_arguments[1]; 
+  JSObjectRef exception_object;
+  JSValueRef exception_value;
+  exception_value = JSValueMakeString(context, message);
+  /* Converting the result to an object will let JavascriptCore add 
+     "sourceURL" (file) and "line" (number) and "message" to the exception,
+     instead of just returning a raw string. This is extremely important for debugging your errors.
+     Using JSObjectMakeError is better than JSValueToObject because the latter only populates
+     "sourceURL" and "line", but not "message" or any others I don't know about.
+   */
+  error_arguments[0] = exception_value;
+  exception_object = JSObjectMakeError(context, 1, error_arguments, NULL);
+
+  /* Return the exception_object */
+  *exception = exception_object;
+
+  JSStringRelease(message);
 }
 
-void SWIG_JSC_exception(JSContextRef context, JSValueRef *exception, int code, const char* msg) {
+SWIGRUNTIME void SWIG_JSC_exception(JSContextRef context, JSValueRef *exception, int code, const char* msg) {
   SWIG_Javascript_Raise(context, exception, msg);
 }
 
@@ -28,7 +43,7 @@
   swig_type_info *info;
 } SwigPrivData;
 
-JSValueRef _wrap_SwigObject_disown(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+SWIGRUNTIME JSValueRef _wrap_SwigObject_disown(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
 {
   JSValueRef jsresult;
 
@@ -41,7 +56,7 @@
   return jsresult;
 }
 
-JSValueRef _wrap_SwigObject_getCPtr(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+SWIGRUNTIME JSValueRef _wrap_SwigObject_getCPtr(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
 {
   JSValueRef jsresult;
   long result;
@@ -55,7 +70,7 @@
   return jsresult;
 }
 
-JSValueRef _wrap_SwigObject_equals(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
+SWIGRUNTIME JSValueRef _wrap_SwigObject_equals(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
 {
   JSValueRef jsresult;
   bool result;
@@ -72,13 +87,13 @@
   return jsresult;
 }
 
-JSStaticValue _SwigObject_values[] = {
+SWIGRUNTIME JSStaticValue _SwigObject_values[] = {
   {
     0, 0, 0, 0
   }
 };
 
-JSStaticFunction _SwigObject_functions[] = {
+SWIGRUNTIME JSStaticFunction _SwigObject_functions[] = {
   {
     "disown",_wrap_SwigObject_disown, kJSPropertyAttributeNone
   },
@@ -93,13 +108,15 @@
   }
 };
 
-JSClassDefinition _SwigObject_objectDefinition;
+SWIGRUNTIME JSClassDefinition _SwigObject_objectDefinition;
 
-JSClassRef _SwigObject_classRef;
+SWIGRUNTIME JSClassRef _SwigObject_classRef;
 
 
-int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef objRef, void** ptr, swig_type_info *info, int flags) {
-  SwigPrivData *cdata = (SwigPrivData *) JSObjectGetPrivate(objRef);
+SWIGRUNTIME int SWIG_JSC_ConvertInstancePtr(JSContextRef context, JSObjectRef objRef, void** ptr, swig_type_info *info, int flags) {
+  SwigPrivData *cdata;
+
+  cdata = (SwigPrivData *) JSObjectGetPrivate(objRef);
   if(cdata == NULL) {
     return SWIG_ERROR;
   }
@@ -127,12 +144,20 @@
   return SWIG_OK;
 }
 
-int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, void** ptr, swig_type_info *info, int flags) {
+SWIGRUNTIME int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, void** ptr, swig_type_info *info, int flags) {
+  JSObjectRef objRef;
+
+  /* special case: JavaScript null => C NULL pointer */
+  if(JSValueIsNull(context, valRef)) {
+    *ptr=0;
+    return SWIG_OK;
+  }
+
   if(!JSValueIsObject(context, valRef)) {
     return SWIG_TypeError;
   }
 
-  JSObjectRef objRef = JSValueToObject(context, valRef, NULL);
+  objRef = JSValueToObject(context, valRef, NULL);
   if(objRef == NULL) {
     return SWIG_ERROR;
   }
@@ -140,18 +165,28 @@
   return SWIG_JSC_ConvertInstancePtr(context, objRef, ptr, info, flags);
 }
 
-JSObjectRef SWIG_JSC_NewPointerObj(JSContextRef context, void *ptr, swig_type_info *info, int flags) {
-
+SWIGRUNTIME JSObjectRef SWIG_JSC_NewPointerObj(JSContextRef context, void *ptr, swig_type_info *info, int flags) {
   JSClassRef classRef;
+  JSObjectRef result;
+  SwigPrivData *cdata;
+
+  if (ptr == NULL) {
+    // HACK: it is not possible to use JSValueToObject (causing seg-fault)
+    // This static cast turned out to be a workaround
+    // In future, we should change the interface of this method
+    // to return JSValueRef instead of JSObjectRef.
+    return (JSObjectRef) JSValueMakeNull(context);
+  }
+
   if(info->clientdata == NULL) {
     classRef = _SwigObject_classRef;
   } else {
     classRef = (JSClassRef) info->clientdata;
   }
 
-  JSObjectRef result = JSObjectMake(context, classRef, NULL);
+  result = JSObjectMake(context, classRef, NULL);
 
-  SwigPrivData* cdata = (SwigPrivData*) malloc(sizeof(SwigPrivData));
+  cdata = (SwigPrivData*) malloc(sizeof(SwigPrivData));
   cdata->swigCObject = ptr;
   cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0;
   cdata->info = info;
@@ -181,18 +216,18 @@
   swig_type_info *type;
 } SwigPackedData;
 
-JSStaticValue _SwigPackedData_values[] = {
+SWIGRUNTIME JSStaticValue _SwigPackedData_values[] = {
   {
     0, 0, 0, 0
   }
 };
-JSStaticFunction _SwigPackedData_functions[] = {
+SWIGRUNTIME JSStaticFunction _SwigPackedData_functions[] = {
   {
     0, 0, 0
   }
 };
-JSClassDefinition _SwigPackedData_objectDefinition;
-JSClassRef _SwigPackedData_classRef;
+SWIGRUNTIME JSClassDefinition _SwigPackedData_objectDefinition;
+SWIGRUNTIME JSClassRef _SwigPackedData_classRef;
 
 SWIGRUNTIMEINLINE
 int SwigJSCPacked_Check(JSContextRef context, JSValueRef valRef) {
@@ -243,7 +278,7 @@
 }
 
 /*  SwigPackedData wrappers  */
-
+SWIGRUNTIME
 void _wrap_SwigPackedData_delete(JSObjectRef obj)
 {
   SwigPackedData* cdata = (SwigPackedData*) JSObjectGetPrivate(obj);
@@ -262,7 +297,7 @@
  * Support for IN/OUTPUT typemaps (see Lib/typemaps/inoutlist.swg)
  *
  * ---------------------------------------------------------------------------*/
-
+SWIGRUNTIME
 unsigned int SWIGJSC_ArrayLength(JSContextRef context, JSObjectRef arr) {
   static JSStringRef LENGTH = 0;
   JSValueRef exception = NULL;
@@ -295,4 +330,5 @@
 
   length = SWIGJSC_ArrayLength(context, arr);
   JSObjectSetPropertyAtIndex(context, arr, length, obj, 0);
+  return arr;
 }
diff --git a/Lib/javascript/jsc/javascriptstrings.swg b/Lib/javascript/jsc/javascriptstrings.swg
index 0581c19..b3f46ae 100644
--- a/Lib/javascript/jsc/javascriptstrings.swg
+++ b/Lib/javascript/jsc/javascriptstrings.swg
@@ -8,7 +8,7 @@
   if(JSValueIsString(context, valRef)) {
     JSStringRef js_str = JSValueToStringCopy(context, valRef, NULL);
     size_t len = JSStringGetMaximumUTF8CStringSize(js_str);
-    char* cstr = (char*) malloc(len * sizeof(char));
+    char* cstr = (char*) %new_array(len, char);
     /* JSStringGetUTF8CString returns the length including 0-terminator */
     len = JSStringGetUTF8CString(js_str, cstr, len);
 
@@ -53,7 +53,7 @@
     } else {
       JSStringRef jsstring;
       if(size < 2) {
-        char c[size+1];
+        char c[2];
         int i;
         for(i=0;i<size;++i) {
           c[i] = carray[i];
diff --git a/Lib/javascript/jsc/std_common.i b/Lib/javascript/jsc/std_common.i
old mode 100755
new mode 100644
diff --git a/Lib/javascript/jsc/std_map.i b/Lib/javascript/jsc/std_map.i
old mode 100755
new mode 100644
diff --git a/Lib/javascript/jsc/std_pair.i b/Lib/javascript/jsc/std_pair.i
old mode 100755
new mode 100644
diff --git a/Lib/javascript/jsc/std_string.i b/Lib/javascript/jsc/std_string.i
old mode 100755
new mode 100644
index fb1bd62..dc1378a
--- a/Lib/javascript/jsc/std_string.i
+++ b/Lib/javascript/jsc/std_string.i
@@ -1,69 +1 @@
-/* -----------------------------------------------------------------------------
- * std_string.i
- *
- * Typemaps for const std::string&.
- * To use non-const std::string references use the following %apply:
- *      %apply const std::string & {std::string &};
- *
- * ----------------------------------------------------------------------------- */
-
-%{
-#include <string>
-
-std::string SWIGJSC_valueToString(JSContextRef context, JSValueRef value) {
-  JSStringRef jsstring = JSValueToStringCopy(context, value, /* JSValueRef *exception */ 0);
-  unsigned int length = JSStringGetLength(jsstring);
-  char *cstr = new char[length + 1];
-  JSStringGetUTF8CString(jsstring, cstr, length + 1);
-
-  // create a copy
-  std::string result(cstr);
-
-  JSStringRelease(jsstring);
-  delete[] cstr;
-
-  return result;
-}
-
-JSValueRef SWIGJSC_stringToValue(JSContextRef context, const std::string& s)
-{
-  JSValueRef result;
-  JSStringRef	jsstring = JSStringCreateWithUTF8CString(s.c_str());
-  result = JSValueMakeString(context, jsstring);
-  JSStringRelease(jsstring);
-  return result;
-}
-%}
-
-namespace std {
-  %naturalvar string;
-
-  class string;
-
-
-  %typemap(in) string
-  %{ 
-     $1 = SWIGJSC_valueToString(context, $input);
-  %}
-
-  %typemap(in) const string & 
-  %{ 
-     $1 = new std::string(SWIGJSC_valueToString(context, $input));
-  %}
-
-  %typemap(freearg) const string & 
-  %{ 
-     delete $1;
-  %}
-
-  %typemap(out) string
-  %{
-     $result = SWIGJSC_stringToValue(context, $1);
-  %}
-
-  %typemap(out) const string &
-  %{
-     $result = SWIGJSC_stringToValue(context, *$1);
-  %}
-
-}
+%include <typemaps/std_string.swg>
diff --git a/Lib/javascript/jsc/std_vector.i b/Lib/javascript/jsc/std_vector.i
old mode 100755
new mode 100644
index 3f29b19..971b426
--- a/Lib/javascript/jsc/std_vector.i
+++ b/Lib/javascript/jsc/std_vector.i
@@ -61,7 +61,7 @@
         %rename(add) push_back;
         void push_back(const value_type& x);
         %extend {
-            const_reference get(int i) throw (std::out_of_range) {
+            bool get(int i) throw (std::out_of_range) {
                 int size = int(self->size());
                 if (i>=0 && i<size)
                     return (*self)[i];
diff --git a/Lib/javascript/jsc/stl.i b/Lib/javascript/jsc/stl.i
old mode 100755
new mode 100644
diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg
index 67a8114..12db9b4 100644
--- a/Lib/javascript/v8/javascriptcode.swg
+++ b/Lib/javascript/v8/javascriptcode.swg
@@ -8,8 +8,9 @@
  * ----------------------------------------------------------------------------- */
 
 %fragment("js_ctor", "templates") %{
-SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
-  v8::HandleScope scope;
+static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
+  SWIGV8_HANDLESCOPE();
+  
   v8::Handle<v8::Object> self = args.Holder();
   $jslocals
   if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
@@ -20,7 +21,7 @@
 
   goto fail;
 fail:
-  SWIGV8_RETURN(v8::Undefined());
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
 }
 %}
 
@@ -31,10 +32,11 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_veto_ctor", "templates")
 %{
-SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
-  v8::HandleScope scope;
+static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
+  SWIGV8_HANDLESCOPE();
+  
   SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
-  SWIGV8_RETURN(v8::Undefined());
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
 }
 %}
 
@@ -46,8 +48,9 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_ctor_dispatcher", "templates")
 %{
-SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
-  v8::HandleScope scope;
+static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
+  SWIGV8_HANDLESCOPE();
+  
   OverloadErrorHandler errorHandler;
   v8::Handle<v8::Value> self;
 
@@ -58,7 +61,7 @@
   SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for construction of $jsmangledname");
 
 fail:
-  SWIGV8_RETURN(v8::Undefined());
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
 }
 %}
 
@@ -71,8 +74,9 @@
  *   - $jsmangledtype:    mangled type of class
  * ----------------------------------------------------------------------------- */
 %fragment("js_overloaded_ctor", "templates") %{
-SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler) {
-  v8::HandleScope scope;
+static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler &SWIGV8_ErrorHandler) {
+  SWIGV8_HANDLESCOPE();
+  
   v8::Handle<v8::Object> self = args.Holder();
   $jslocals
   if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
@@ -83,7 +87,7 @@
 
   goto fail;
 fail:
-  SWIGV8_RETURN(v8::Undefined());
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
 }
 %}
 
@@ -98,10 +102,10 @@
 %{
   if(args.Length() == $jsargcount) {
     errorHandler.err.Clear();
-#if SWIG_V8_VERSION < 0x031900
+#if (SWIG_V8_VERSION < 0x031903)
     self = $jswrapper(args, errorHandler);
     if(errorHandler.err.IsEmpty()) {
-      return scope.Close(self);
+      SWIGV8_ESCAPE(self);
     }
 #else
     $jswrapper(args, errorHandler);
@@ -120,13 +124,18 @@
 %fragment ("js_dtor", "templates")
 %{
 
-#if (SWIG_V8_VERSION < 0x031900)
-void $jswrapper(v8::Persistent< v8::Value > object, void *parameter)
-{
+#if (SWIG_V8_VERSION < 0x031710)
+static void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
   SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
+#elif (SWIG_V8_VERSION < 0x031900)
+static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
+  SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
+#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
+static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Object> *object, SWIGV8_Proxy *proxy) {
 #else
-void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWIGV8_Proxy *proxy)
-{
+static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
+  v8::Local<v8::Object> object = data.GetValue();
+  SWIGV8_Proxy *proxy = data.GetParameter();
 #endif
 
   if(proxy->swigCMemOwn && proxy->swigCObject) {
@@ -138,8 +147,11 @@
   delete proxy;
 
   object.Clear();
-#if (SWIG_V8_VERSION < 0x031900)
+  
+#if (SWIG_V8_VERSION < 0x031710)
   object.Dispose();
+#elif (SWIG_V8_VERSION < 0x031900)
+  object.Dispose(isolate);
 #elif (SWIG_V8_VERSION < 0x032100)
   object->Dispose(isolate);
 #else
@@ -156,26 +168,36 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_dtoroverride", "templates")
 %{
-#if (SWIG_V8_VERSION < 0x031900)
-void $jswrapper(v8::Persistent< v8::Value > object, void *parameter)
-{
+#if (SWIG_V8_VERSION < 0x031710)
+static void $jswrapper(v8::Persistent<v8::Value> object, void *parameter) {
   SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
+#elif (SWIG_V8_VERSION < 0x031900)
+static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
+  SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
+#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
+static void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object> *object, SWIGV8_Proxy *proxy) {
 #else
-void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWIGV8_Proxy *proxy)
-{
+static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
+  v8::Local<v8::Object> object = data.GetValue();
+  SWIGV8_Proxy *proxy = data.GetParameter();
 #endif
+
   if(proxy->swigCMemOwn && proxy->swigCObject) {
     $jstype arg1 = ($jstype)proxy->swigCObject;
     ${destructor_action}
   }
   delete proxy;
 
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031710)
   object.Dispose();
+#elif (SWIG_V8_VERSION < 0x031900)
+  object.Dispose(isolate);
 #elif (SWIG_V8_VERSION < 0x032100)
   object->Dispose(isolate);
-#else
+#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
   object->Dispose();
+#else
+  object.Clear();
 #endif
 }
 %}
@@ -188,8 +210,9 @@
  * ----------------------------------------------------------------------------- */
 %fragment("js_getter", "templates")
 %{
-SwigV8ReturnValue $jswrapper(v8::Local<v8::String> property, const SwigV8PropertyCallbackInfo& info) {
-  v8::HandleScope scope;
+static SwigV8ReturnValue $jswrapper(v8::Local<v8::String> property, const SwigV8PropertyCallbackInfo &info) {
+  SWIGV8_HANDLESCOPE();
+  
   v8::Handle<v8::Value> jsresult;
   $jslocals
   $jscode
@@ -197,7 +220,7 @@
 
   goto fail;
 fail:
-  SWIGV8_RETURN_INFO(v8::Undefined(), info);
+  SWIGV8_RETURN_INFO(SWIGV8_UNDEFINED(), info);
 }
 %}
 
@@ -209,9 +232,10 @@
  * ----------------------------------------------------------------------------- */
 %fragment("js_setter", "templates")
 %{
-void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value,
-  const SwigV8PropertyCallbackInfoVoid& info) {
-  v8::HandleScope scope;
+static void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value,
+  const SwigV8PropertyCallbackInfoVoid &info) {
+  SWIGV8_HANDLESCOPE();
+  
   $jslocals
   $jscode
   goto fail;
@@ -228,8 +252,9 @@
  * ----------------------------------------------------------------------------- */
 %fragment("js_function", "templates")
 %{
-SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
-  v8::HandleScope scope;
+static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
+  SWIGV8_HANDLESCOPE();
+  
   v8::Handle<v8::Value> jsresult;
   $jslocals
   if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
@@ -239,7 +264,7 @@
 
   goto fail;
 fail:
-  SWIGV8_RETURN(v8::Undefined());
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
 }
 %}
 
@@ -252,8 +277,9 @@
  * ----------------------------------------------------------------------------- */
 %fragment("js_function_dispatcher", "templates")
 %{
-SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
-  v8::HandleScope scope;
+static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
+  SWIGV8_HANDLESCOPE();
+  
   v8::Handle<v8::Value> jsresult;
   OverloadErrorHandler errorHandler;
   $jscode
@@ -262,7 +288,7 @@
 
   goto fail;
 fail:
-  SWIGV8_RETURN(v8::Undefined());
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
 }
 %}
 
@@ -274,9 +300,10 @@
  * ----------------------------------------------------------------------------- */
 %fragment ("js_overloaded_function", "templates")
 %{
-SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler)
+static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler &SWIGV8_ErrorHandler)
 {
-  v8::HandleScope scope;
+  SWIGV8_HANDLESCOPE();
+  
   v8::Handle<v8::Value> jsresult;
   $jslocals
   $jscode
@@ -284,7 +311,7 @@
 
   goto fail;
 fail:
-  SWIGV8_RETURN(v8::Undefined());
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
 }
 %}
 
@@ -299,10 +326,10 @@
 
   if(args.Length() == $jsargcount) {
     errorHandler.err.Clear();
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031903)
     jsresult = $jswrapper(args, errorHandler);
     if(errorHandler.err.IsEmpty()) {
-      return scope.Close(jsresult);
+      SWIGV8_ESCAPE(jsresult);
     }
 #else
     $jswrapper(args, errorHandler);
@@ -330,12 +357,9 @@
  * ----------------------------------------------------------------------------- */
 %fragment("jsv8_define_class_template", "templates")
 %{
+  /* Name: $jsmangledname, Type: $jsmangledtype, Dtor: $jsdtor */
   v8::Handle<v8::FunctionTemplate> $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
-#if (SWIG_V8_VERSION < 0x031900)
-  $jsmangledname_clientData.class_templ = v8::Persistent<v8::FunctionTemplate>::New($jsmangledname_class);
-#else
-  $jsmangledname_clientData.class_templ.Reset(v8::Isolate::GetCurrent(), $jsmangledname_class);
-#endif
+  SWIGV8_SET_CLASS_TEMPL($jsmangledname_clientData.class_templ, $jsmangledname_class);
   $jsmangledname_clientData.dtor = $jsdtor;
   if (SWIGTYPE_$jsmangledtype->clientdata == 0) {
     SWIGTYPE_$jsmangledtype->clientdata = &$jsmangledname_clientData;
@@ -352,11 +376,11 @@
 %{
   if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty()))
   {
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031903)
     $jsmangledname_class->Inherit(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ);
 #else
     $jsmangledname_class->Inherit(
-      v8::Handle<v8::FunctionTemplate>::New(
+      v8::Local<v8::FunctionTemplate>::New(
         v8::Isolate::GetCurrent(),
         static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ)
      );
@@ -379,6 +403,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment("jsv8_create_class_instance", "templates")
 %{
+  /* Class: $jsname ($jsmangledname) */
   v8::Handle<v8::FunctionTemplate> $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname");
   $jsmangledname_class_0->SetCallHandler($jsctor);
   $jsmangledname_class_0->Inherit($jsmangledname_class);
@@ -394,7 +419,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment("jsv8_register_class", "templates")
 %{
-  $jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj);
+  $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj);
 %}
 
 /* -----------------------------------------------------------------------------
@@ -403,7 +428,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment("jsv8_create_namespace", "templates")
 %{
-  v8::Handle<v8::Object> $jsmangledname_obj = v8::Object::New();
+  v8::Handle<v8::Object> $jsmangledname_obj = SWIGV8_OBJECT_NEW();
 %}
 
 /* -----------------------------------------------------------------------------
@@ -414,7 +439,7 @@
  * ----------------------------------------------------------------------------- */
 %fragment("jsv8_register_namespace", "templates")
 %{
-  $jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj);
+  $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj);
 %}
 
 /* -----------------------------------------------------------------------------
diff --git a/Lib/javascript/v8/javascriptcomplex.swg b/Lib/javascript/v8/javascriptcomplex.swg
index 70c5baf..683b972 100644
--- a/Lib/javascript/v8/javascriptcomplex.swg
+++ b/Lib/javascript/v8/javascriptcomplex.swg
@@ -15,12 +15,13 @@
 SWIGINTERNINLINE v8::Handle<v8::Value>
 SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
 {
-  v8::HandleScope scope;
-  v8::Local<v8::Array> vals = v8::Array::New(2);
+  SWIGV8_HANDLESCOPE_ESC();
+
+  v8::Local<v8::Array> vals = SWIGV8_ARRAY_NEW(2);
 
   vals->Set(0, SWIG_From(double)(Real(c)));
   vals->Set(1, SWIG_From(double)(Imag(c)));
-  return scope.Close(vals);
+  SWIGV8_ESCAPE(vals);
 }
 }
 %enddef
@@ -33,7 +34,7 @@
 SWIGINTERN int
 SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
 {
-  v8::HandleScope scope;
+  SWIGV8_HANDLESCOPE();
   
   if (o->IsArray()) {
     v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(o);
@@ -75,7 +76,7 @@
 SWIGINTERN int
 SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
 {
-  v8::HandleScope scope;
+  SWIGV8_HANDLESCOPE();
 
   if (o->IsArray()) {
     v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(o);
diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg
index 8da6627..9692254 100644
--- a/Lib/javascript/v8/javascripthelpers.swg
+++ b/Lib/javascript/v8/javascripthelpers.swg
@@ -1,7 +1,7 @@
 %insert(runtime) %{
 
 // Note: since 3.19 there are new CallBack types, since 03.21.9 the old ones have been removed
-#if SWIG_V8_VERSION < 0x031900
+#if (SWIG_V8_VERSION < 0x031903)
 typedef v8::InvocationCallback  SwigV8FunctionCallback;
 typedef v8::AccessorGetter      SwigV8AccessorGetterCallback;
 typedef v8::AccessorSetter      SwigV8AccessorSetterCallback;
@@ -16,58 +16,59 @@
 /**
  * Creates a class template for a class with specified initialization function.
  */
-v8::Handle<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const char* symbol) {
-    v8::HandleScope scope;
-    v8::Local<v8::FunctionTemplate> class_templ = v8::FunctionTemplate::New();
-    class_templ->SetClassName(v8::String::NewSymbol(symbol));
+SWIGRUNTIME v8::Handle<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const char* symbol) {
+    SWIGV8_HANDLESCOPE_ESC();
+    
+    v8::Local<v8::FunctionTemplate> class_templ = SWIGV8_FUNCTEMPLATE_NEW_VOID();
+    class_templ->SetClassName(SWIGV8_SYMBOL_NEW(symbol));
 
     v8::Handle<v8::ObjectTemplate> inst_templ = class_templ->InstanceTemplate();
     inst_templ->SetInternalFieldCount(1);
 
     v8::Handle<v8::ObjectTemplate> equals_templ = class_templ->PrototypeTemplate();
-    equals_templ->Set(v8::String::NewSymbol("equals"), v8::FunctionTemplate::New(_SWIGV8_wrap_equals));
+    equals_templ->Set(SWIGV8_SYMBOL_NEW("equals"), SWIGV8_FUNCTEMPLATE_NEW(_SWIGV8_wrap_equals));
 
     v8::Handle<v8::ObjectTemplate> cptr_templ = class_templ->PrototypeTemplate();
-    cptr_templ->Set(v8::String::NewSymbol("getCPtr"), v8::FunctionTemplate::New(_wrap_getCPtr));
+    cptr_templ->Set(SWIGV8_SYMBOL_NEW("getCPtr"), SWIGV8_FUNCTEMPLATE_NEW(_wrap_getCPtr));
 
-    return scope.Close(class_templ);
+    SWIGV8_ESCAPE(class_templ);
 }
 
 /**
  * Registers a class method with given name for a given class template.
  */
-void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
+SWIGRUNTIME void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
   SwigV8FunctionCallback _func) {
     v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->PrototypeTemplate();
-    proto_templ->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func));
+    proto_templ->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func));
 }
 
 /**
  * Registers a class property with given name for a given class template.
  */
-void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
+SWIGRUNTIME void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
   SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
   v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->InstanceTemplate();
-  proto_templ->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
+  proto_templ->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter);
 }
 
 /**
  * Registers a class method with given name for a given object.
  */
-void SWIGV8_AddStaticFunction(v8::Handle<v8::Object> obj, const char* symbol,
+SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Handle<v8::Object> obj, const char* symbol,
   const SwigV8FunctionCallback& _func) {
-  obj->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func)->GetFunction());
+  obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction());
 }
 
 /**
  * Registers a class method with given name for a given object.
  */
-void SWIGV8_AddStaticVariable(v8::Handle<v8::Object> obj, const char* symbol,
+SWIGRUNTIME void SWIGV8_AddStaticVariable(v8::Handle<v8::Object> obj, const char* symbol,
   SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) {
-  obj->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
+  obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter);
 }
 
-void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<v8::Value> value,
+SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<v8::Value> value,
   const SwigV8PropertyCallbackInfoVoid& info)
 {
     char buffer[256];
diff --git a/Lib/javascript/v8/javascriptinit.swg b/Lib/javascript/v8/javascriptinit.swg
index de1fe91..34befa7 100644
--- a/Lib/javascript/v8/javascriptinit.swg
+++ b/Lib/javascript/v8/javascriptinit.swg
@@ -4,16 +4,16 @@
 
 SWIGRUNTIME void
 SWIG_V8_SetModule(void *, swig_module_info *swig_module) {
-  v8::Local<v8::Object> global_obj = v8::Context::GetCurrent()->Global();
-  v8::Local<v8::External> mod = v8::External::New(swig_module);
+  v8::Local<v8::Object> global_obj = SWIGV8_CURRENT_CONTEXT()->Global();
+  v8::Local<v8::External> mod = SWIGV8_EXTERNAL_NEW(swig_module);
   assert(!mod.IsEmpty());
-  global_obj->SetHiddenValue(v8::String::New("swig_module_info_data"), mod);
+  global_obj->SetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data"), mod);
 }
 
 SWIGRUNTIME swig_module_info *
 SWIG_V8_GetModule(void *) {
-  v8::Local<v8::Object> global_obj = v8::Context::GetCurrent()->Global();
-  v8::Local<v8::Value> moduleinfo = global_obj->GetHiddenValue(v8::String::New("swig_module_info_data"));
+  v8::Local<v8::Object> global_obj = SWIGV8_CURRENT_CONTEXT()->Global();
+  v8::Local<v8::Value> moduleinfo = global_obj->GetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data"));
 
   if (moduleinfo.IsEmpty())
   {
@@ -61,7 +61,8 @@
 {
   SWIG_InitializeModule(static_cast<void *>(&exports));
 
-  v8::HandleScope scope;
+  SWIGV8_HANDLESCOPE();
+  
   v8::Handle<v8::Object> exports_obj = exports;
 %}
 
@@ -81,11 +82,7 @@
 %fragment("js_initializer", "templates")
 %{
   // a class template for creating proxies of undefined types
-#if (SWIG_V8_VERSION < 0x031900)
-  SWIGV8_SWIGTYPE_Proxy_class_templ = v8::Persistent<v8::FunctionTemplate>::New(SWIGV8_CreateClassTemplate("SwigProxy"));
-#else
-  SWIGV8_SWIGTYPE_Proxy_class_templ.Reset(v8::Isolate::GetCurrent(), SWIGV8_CreateClassTemplate("SwigProxy"));
-#endif
+  SWIGV8_SET_CLASS_TEMPL(SWIGV8_SWIGTYPE_Proxy_class_templ, SWIGV8_CreateClassTemplate("SwigProxy"));
 
   /* create objects for namespaces */
   $jsv8nspaces
@@ -113,6 +110,6 @@
 }
 
 #if defined(BUILDING_NODE_EXTENSION)
-NODE_MODULE($jsname, $jsname_initialize);
+NODE_MODULE($jsname, $jsname_initialize)
 #endif
 %}
diff --git a/Lib/javascript/v8/javascriptprimtypes.swg b/Lib/javascript/v8/javascriptprimtypes.swg
index 706a799..fe826b8 100644
--- a/Lib/javascript/v8/javascriptprimtypes.swg
+++ b/Lib/javascript/v8/javascriptprimtypes.swg
@@ -9,7 +9,7 @@
 v8::Handle<v8::Value>
 SWIG_From_dec(bool)(bool value)
 {
-  return v8::Boolean::New(value);
+  return SWIGV8_BOOLEAN_NEW(value);
 }
 }
 
@@ -33,7 +33,7 @@
 SWIGINTERNINLINE
 v8::Handle<v8::Value> SWIG_From_dec(int)(int value)
 {
-  return v8::Int32::New(value);
+  return SWIGV8_INT32_NEW(value);
 }
 }
 
@@ -56,7 +56,7 @@
 SWIGINTERNINLINE
 v8::Handle<v8::Value> SWIG_From_dec(long)(long value)
 {
-  return v8::Number::New(value);
+  return SWIGV8_NUMBER_NEW(value);
 }
 }
 
@@ -82,7 +82,7 @@
 v8::Handle<v8::Value> SWIG_From_dec(unsigned long)(unsigned long value)
 {
   return (value > LONG_MAX) ?
-    v8::Integer::NewFromUnsigned(value) : v8::Integer::New(%numeric_cast(value,long));
+    SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long));
 }
 }
 
@@ -116,7 +116,7 @@
 SWIGINTERNINLINE
 v8::Handle<v8::Value> SWIG_From_dec(long long)(long long value)
 {
-  return v8::Number::New(value);
+  return SWIGV8_NUMBER_NEW(value);
 }
 }
 
@@ -146,7 +146,7 @@
 v8::Handle<v8::Value> SWIG_From_dec(unsigned long long)(unsigned long long value)
 {
   return (value > LONG_MAX) ?
-    v8::Integer::NewFromUnsigned(value) : v8::Integer::New(%numeric_cast(value,long));
+    SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long));
 }
 }
 
@@ -179,7 +179,7 @@
 SWIGINTERN
 v8::Handle<v8::Value> SWIG_From_dec(double) (double val)
 {
-  return v8::Number::New(val);
+  return SWIGV8_NUMBER_NEW(val);
 }
 }
 
diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg
index 2e0a467..b37059c 100644
--- a/Lib/javascript/v8/javascriptrun.swg
+++ b/Lib/javascript/v8/javascriptrun.swg
@@ -1,4 +1,97 @@
 /* ---------------------------------------------------------------------------
+ * These typedefs and defines are used to deal with v8 API changes
+ *
+ * ---------------------------------------------------------------------------*/
+
+// First v8 version that uses "SetWeak" and not "MakeWeak"
+
+#define SWIGV8_SETWEAK_VERSION 0x032224
+
+#if (SWIG_V8_VERSION < 0x031803)
+#define SWIGV8_STRING_NEW2(cstr, len) v8::String::New(cstr, len)
+#else
+#define SWIGV8_STRING_NEW2(cstr, len) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::String::kNormalString, len)
+#endif
+
+#if (SWIG_V8_VERSION < 0x031903)
+typedef v8::Handle<v8::Value> SwigV8ReturnValue;
+typedef v8::Arguments SwigV8Arguments;
+typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
+#define SWIGV8_RETURN(val) return scope.Close(val)
+#define SWIGV8_RETURN_INFO(val, info) return scope.Close(val)
+#else
+typedef void SwigV8ReturnValue;
+typedef v8::FunctionCallbackInfo<v8::Value> SwigV8Arguments;
+typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
+#define SWIGV8_RETURN(val) args.GetReturnValue().Set(val); return
+#define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return
+#endif
+
+#if (SWIG_V8_VERSION < 0x032117)
+#define SWIGV8_HANDLESCOPE() v8::HandleScope scope
+#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope
+#define SWIGV8_ESCAPE(val) return scope.Close(val)
+#elif (SWIG_V8_VERSION < 0x032224)
+#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
+#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope(v8::Isolate::GetCurrent());
+#define SWIGV8_ESCAPE(val) return scope.Close(val)
+#else
+#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
+#define SWIGV8_HANDLESCOPE_ESC() v8::EscapableHandleScope scope(v8::Isolate::GetCurrent());
+#define SWIGV8_ESCAPE(val) return scope.Escape(val)
+#endif
+
+#if (SWIG_V8_VERSION < 0x032224)
+#define SWIGV8_ADJUST_MEMORY(size) v8::V8::AdjustAmountOfExternalAllocatedMemory(size)
+#define SWIGV8_CURRENT_CONTEXT() v8::Context::GetCurrent()
+#define SWIGV8_THROW_EXCEPTION(err) v8::ThrowException(err)
+#define SWIGV8_STRING_NEW(str) v8::String::New(str)
+#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewSymbol(sym)
+#else
+#define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size)
+#define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext()
+#define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err)
+#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str)
+#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym)
+#endif
+
+#if (SWIG_V8_VERSION < 0x032318)
+#define SWIGV8_ARRAY_NEW() v8::Array::New()
+#define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(bool)
+#define SWIGV8_EXTERNAL_NEW(val) v8::External::New(val)
+#define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(func)
+#define SWIGV8_FUNCTEMPLATE_NEW_VOID() v8::FunctionTemplate::New()
+#define SWIGV8_INT32_NEW(num) v8::Int32::New(num)
+#define SWIGV8_INTEGER_NEW(num) v8::Integer::New(num)
+#define SWIGV8_INTEGER_NEW_UNS(num) v8::Integer::NewFromUnsigned(num)
+#define SWIGV8_NUMBER_NEW(num) v8::Number::New(num)
+#define SWIGV8_OBJECT_NEW() v8::Object::New()
+#define SWIGV8_UNDEFINED() v8::Undefined()
+#define SWIGV8_NULL() v8::Null()
+#else
+#define SWIGV8_ARRAY_NEW() v8::Array::New(v8::Isolate::GetCurrent())
+#define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(v8::Isolate::GetCurrent(), bool)
+#define SWIGV8_EXTERNAL_NEW(val) v8::External::New(v8::Isolate::GetCurrent(), val)
+#define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), func)
+#define SWIGV8_FUNCTEMPLATE_NEW_VOID() v8::FunctionTemplate::New(v8::Isolate::GetCurrent())
+#define SWIGV8_INT32_NEW(num) v8::Int32::New(v8::Isolate::GetCurrent(), num)
+#define SWIGV8_INTEGER_NEW(num) v8::Integer::New(v8::Isolate::GetCurrent(), num)
+#define SWIGV8_INTEGER_NEW_UNS(num) v8::Integer::NewFromUnsigned(v8::Isolate::GetCurrent(), num)
+#define SWIGV8_NUMBER_NEW(num) v8::Number::New(v8::Isolate::GetCurrent(), num)
+#define SWIGV8_OBJECT_NEW() v8::Object::New(v8::Isolate::GetCurrent())
+#define SWIGV8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent())
+#define SWIGV8_NULL() v8::Null(v8::Isolate::GetCurrent())
+#endif
+
+#if (SWIG_V8_VERSION < 0x031710)
+#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent<v8::FunctionTemplate>::New(class);
+#elif (SWIG_V8_VERSION < 0x031900)
+#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(), class);
+#else
+#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ.Reset(v8::Isolate::GetCurrent(), class);
+#endif
+
+/* ---------------------------------------------------------------------------
  * Error handling
  *
  * ---------------------------------------------------------------------------*/
@@ -8,8 +101,8 @@
 #define SWIG_fail                 goto fail
 #define SWIGV8_OVERLOAD false
 
-void SWIG_V8_Raise(const char* msg) {
-  v8::ThrowException(v8::Exception::Error(v8::String::New(msg)));
+static void SWIG_V8_Raise(const char *msg) {
+  SWIGV8_THROW_EXCEPTION(v8::Exception::Error(SWIGV8_STRING_NEW(msg)));
 }
 
 /*
@@ -28,42 +121,25 @@
 class V8ErrorHandler {
 public:
   virtual ~V8ErrorHandler() {}
-  virtual void error(int code, const char* msg) {
+  virtual void error(int code, const char *msg) {
     SWIG_V8_Raise(msg);
   }
 };
 // this is used in usually
-V8ErrorHandler SWIGV8_ErrorHandler;
+static V8ErrorHandler SWIGV8_ErrorHandler;
 
 // instances of this are used in overloaded functions
 class OverloadErrorHandler: public V8ErrorHandler {
 public:
-  virtual void error(int code, const char* msg) {
-    err = v8::Exception::Error(v8::String::New(msg));
+  virtual void error(int code, const char *msg) {
+    err = v8::Exception::Error(SWIGV8_STRING_NEW(msg));
     if(code != SWIG_TypeError) {
-      v8::ThrowException(err);
+        SWIGV8_THROW_EXCEPTION(err);
     }
   }
   v8::Handle<v8::Value> err;
 };
 
-// Note: these typedefs and defines are used to deal with  v8 API changes since version 3.19.00
-
-#if (SWIG_V8_VERSION < 0x031900)
-typedef v8::Handle<v8::Value> SwigV8ReturnValue;
-typedef v8::Arguments SwigV8Arguments;
-typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
-#define SWIGV8_RETURN(val) return scope.Close(val)
-#define SWIGV8_RETURN_INFO(val, info) return scope.Close(val)
-#else
-typedef void SwigV8ReturnValue;
-typedef v8::FunctionCallbackInfo<v8::Value> SwigV8Arguments;
-typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
-#define SWIGV8_RETURN(val) args.GetReturnValue().Set(val); return
-#define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return
-#endif
-
-
 /* ---------------------------------------------------------------------------
  * Basic Proxy object
  *
@@ -76,20 +152,29 @@
 class SWIGV8_Proxy {
 public:
   SWIGV8_Proxy(): swigCMemOwn(false), swigCObject(0), info(0) {
-    v8::V8::AdjustAmountOfExternalAllocatedMemory(SWIGV8_AVG_OBJ_SIZE);
+    SWIGV8_ADJUST_MEMORY(SWIGV8_AVG_OBJ_SIZE);
   };
 
   ~SWIGV8_Proxy() {
-#if (SWIG_V8_VERSION < 0x031900 || SWIG_V8_VERSION >= 0x032100)
+#if (SWIG_V8_VERSION < 0x031710)
     handle.ClearWeak();
     handle.Dispose();
-#else
+#elif (SWIG_V8_VERSION < 0x032100)
     handle.ClearWeak(v8::Isolate::GetCurrent());
     handle.Dispose(v8::Isolate::GetCurrent());
+#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
+    handle.ClearWeak();
+    handle.Dispose();
+#else    
+    handle.ClearWeak();
+    handle.Reset();
 #endif
 
+#if (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
     handle.Clear();
-    v8::V8::AdjustAmountOfExternalAllocatedMemory(-SWIGV8_AVG_OBJ_SIZE);
+#endif
+
+    SWIGV8_ADJUST_MEMORY(-SWIGV8_AVG_OBJ_SIZE);
   }
 
   bool swigCMemOwn;
@@ -102,21 +187,25 @@
 public:
   v8::Persistent<v8::FunctionTemplate> class_templ;
 
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031710)
   void (*dtor) (v8::Persistent< v8::Value> object, void *parameter);
-#else
+#elif (SWIG_V8_VERSION < 0x031900)
+  void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Value> object, void *parameter);
+#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
   void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy);
+#else
+  void (*dtor) (const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data);
 #endif
 };
 
-v8::Persistent<v8::FunctionTemplate> SWIGV8_SWIGTYPE_Proxy_class_templ;
+static v8::Persistent<v8::FunctionTemplate> SWIGV8_SWIGTYPE_Proxy_class_templ;
 
-int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void** ptr, swig_type_info *info, int flags) {
-  v8::HandleScope scope;
+static int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void **ptr, swig_type_info *info, int flags) {
+  SWIGV8_HANDLESCOPE();
 
   if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
 
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031511)
   v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
   SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(v8::External::Unwrap(cdataRef));
 #else
@@ -143,20 +232,24 @@
   return SWIG_OK;
 }
 
-#if (SWIG_V8_VERSION < 0x031900)
-void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter)
-#else
-void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy)
-#endif
-{
-#if (SWIG_V8_VERSION < 0x031900)
+
+#if (SWIG_V8_VERSION < 0x031710)
+static void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter) {
   SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
+#elif (SWIG_V8_VERSION < 0x031900)
+static void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Value > object, void *parameter) {
+  SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
+#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
+static void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) {
+#else
+static void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
+  SWIGV8_Proxy *proxy = data.GetParameter();
 #endif
 
   delete proxy;
 }
 
-int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void** ptr) {
+static int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void **ptr) {
   if(!valRef->IsObject()) {
     return SWIG_TypeError;
   }
@@ -164,7 +257,7 @@
 
   if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
 
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031511)
   v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
   SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(v8::External::Unwrap(cdataRef));
 #else
@@ -180,47 +273,71 @@
   return SWIG_OK;
 }
 
-void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void* ptr, swig_type_info *info, int flags) {
-  SWIGV8_Proxy* cdata = new SWIGV8_Proxy();
+static void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void *ptr, swig_type_info *info, int flags) {
+  SWIGV8_Proxy *cdata = new SWIGV8_Proxy();
   cdata->swigCObject = ptr;
   cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0;
   cdata->info = info;
 
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031511)
   obj->SetPointerInInternalField(0, cdata);
-  cdata->handle = v8::Persistent<v8::Object>::New(obj);
 #else
   obj->SetAlignedPointerInInternalField(0, cdata);
+#endif
+
+#if (SWIG_V8_VERSION < 0x031710)
+  cdata->handle = v8::Persistent<v8::Object>::New(obj);
+#elif (SWIG_V8_VERSION < 0x031900)
+  cdata->handle = v8::Persistent<v8::Object>::New(v8::Isolate::GetCurrent(), obj);
+#else
   cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
 #endif
 
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031710)
   // clientdata must be set for owned data as we need to register the dtor
   if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
     cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
   } else {
     cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
   }
-  cdata->handle.MarkIndependent();
-#else
+#elif (SWIG_V8_VERSION < 0x031918)
   if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
     cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
   } else {
     cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, SWIGV8_Proxy_DefaultDtor);
   }
+#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
+  if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
+    cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
+  } else {
+    cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
+  }
+#else
+  if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
+    cdata->handle.SetWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
+  } else {
+    cdata->handle.SetWeak(cdata, SWIGV8_Proxy_DefaultDtor);
+  }
+#endif
 
-#if (SWIG_V8_VERSION < 0x032100)
+#if (SWIG_V8_VERSION < 0x031710)
+  cdata->handle.MarkIndependent();
+#elif (SWIG_V8_VERSION < 0x032100)
   cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
 #else
   cdata->handle.MarkIndependent();
 #endif
 
-#endif
 }
 
-int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void** ptr, swig_type_info *info, int flags) {
-  v8::HandleScope scope;
-
+static int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void **ptr, swig_type_info *info, int flags) {
+  SWIGV8_HANDLESCOPE();
+  
+  /* special case: JavaScript null => C NULL pointer */
+  if(valRef->IsNull()) {
+    *ptr=0;
+    return SWIG_OK;
+  }
   if(!valRef->IsObject()) {
     return SWIG_TypeError;
   }
@@ -228,30 +345,41 @@
   return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags);
 }
 
-v8::Handle<v8::Object> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
-  v8::HandleScope scope;
+static v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
+  SWIGV8_HANDLESCOPE_ESC();
+  
   v8::Handle<v8::FunctionTemplate> class_templ;
 
-#if (SWIG_V8_VERSION < 0x031900)
+  if (ptr == NULL) {
+#if (SWIG_V8_VERSION < 0x031903)
+    SWIGV8_ESCAPE(SWIGV8_NULL());
+#else    
+    v8::Local<v8::Primitive> result = SWIGV8_NULL();
+    SWIGV8_ESCAPE(result);
+#endif    
+  }
+
+#if (SWIG_V8_VERSION < 0x031903)
   if(info->clientdata != 0) {
     class_templ = ((SWIGV8_ClientData*) info->clientdata)->class_templ;
   } else {
     class_templ = SWIGV8_SWIGTYPE_Proxy_class_templ;
   }
 #else
-  v8::Isolate *iso = v8::Isolate::GetCurrent();
+  v8::Isolate *isolate = v8::Isolate::GetCurrent();
 
   if(info->clientdata != 0) {
-    class_templ = v8::Handle<v8::FunctionTemplate>::New(iso, ((SWIGV8_ClientData*) info->clientdata)->class_templ);
+    class_templ = v8::Local<v8::FunctionTemplate>::New(isolate, ((SWIGV8_ClientData*) info->clientdata)->class_templ);
   } else {
-    class_templ = v8::Handle<v8::FunctionTemplate>::New(iso, SWIGV8_SWIGTYPE_Proxy_class_templ);
+    class_templ = v8::Local<v8::FunctionTemplate>::New(isolate, SWIGV8_SWIGTYPE_Proxy_class_templ);
   }
 #endif
 
-  v8::Handle<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
+//  v8::Handle<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
+  v8::Local<v8::Object> result = class_templ->InstanceTemplate()->NewInstance();
   SWIGV8_SetPrivateData(result, ptr, info, flags);
 
-  return scope.Close(result);
+  SWIGV8_ESCAPE(result);
 }
 
 #define SWIG_ConvertPtr(obj, ptr, info, flags)    SWIG_V8_ConvertPtr(obj, ptr, info, flags)
@@ -265,12 +393,9 @@
 
 #define SWIG_GetInstancePtr(obj, ptr)    SWIG_V8_GetInstancePtr(obj, ptr)
 
-#if (SWIG_V8_VERSION < 0x031900)
-v8::Handle<v8::Value> _SWIGV8_wrap_equals(const v8::Arguments &args) {
-#else
-void _SWIGV8_wrap_equals(const v8::FunctionCallbackInfo<v8::Value>& args) {
-#endif
-  v8::HandleScope scope;
+static SwigV8ReturnValue _SWIGV8_wrap_equals(const SwigV8Arguments &args) {
+  SWIGV8_HANDLESCOPE();
+  
   v8::Handle<v8::Value> jsresult;
   void *arg1 = (void *) 0 ;
   void *arg2 = (void *) 0 ;
@@ -290,20 +415,17 @@
   }
 
   result = (bool)(arg1 == arg2);
-  jsresult =  v8::Boolean::New(result);
+  jsresult =  SWIGV8_BOOLEAN_NEW(result);
 
   SWIGV8_RETURN(jsresult);
   goto fail;
 fail:
-  SWIGV8_RETURN(v8::Undefined());
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
 }
 
-#if (SWIG_V8_VERSION < 0x031900)
-v8::Handle<v8::Value> _wrap_getCPtr(const v8::Arguments &args) {
-#else
-void _wrap_getCPtr(const v8::FunctionCallbackInfo<v8::Value>& args) {
-#endif
-  v8::HandleScope scope;
+static SwigV8ReturnValue _wrap_getCPtr(const SwigV8Arguments &args) {
+  SWIGV8_HANDLESCOPE();
+  
   v8::Handle<v8::Value> jsresult;
   void *arg1 = (void *) 0 ;
   long result;
@@ -315,12 +437,12 @@
   }
 
   result = (long)arg1;
-  jsresult = v8::Number::New(result);
+  jsresult = SWIGV8_NUMBER_NEW(result);
 
   SWIGV8_RETURN(jsresult);
   goto fail;
 fail:
-  SWIGV8_RETURN(v8::Undefined());
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
 }
 
 /* ---------------------------------------------------------------------------
@@ -335,7 +457,7 @@
   ~SwigV8PackedData() {
   };
 
-  void* data;
+  void *data;
   size_t size;
   swig_type_info *type;
 
@@ -344,22 +466,24 @@
 
 SWIGRUNTIMEINLINE
 int SwigV8Packed_Check(v8::Handle<v8::Value> valRef) {
-  v8::HandleScope scope;
+  SWIGV8_HANDLESCOPE();
+  
   v8::Handle<v8::Object> objRef = valRef->ToObject();
   if(objRef->InternalFieldCount() < 1) return false;
-  v8::Handle<v8::Value> flag = objRef->GetHiddenValue(v8::String::New("__swig__packed_data__"));
+  v8::Handle<v8::Value> flag = objRef->GetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"));
   return (flag->IsBoolean() && flag->BooleanValue());
 }
 
 SWIGRUNTIME
-swig_type_info* SwigV8Packed_UnpackData(v8::Handle<v8::Value> valRef, void *ptr, size_t size) {
+swig_type_info *SwigV8Packed_UnpackData(v8::Handle<v8::Value> valRef, void *ptr, size_t size) {
   if (SwigV8Packed_Check(valRef)) {
-    v8::HandleScope scope;
+    SWIGV8_HANDLESCOPE();
+    
     SwigV8PackedData *sobj;
 
     v8::Handle<v8::Object> objRef = valRef->ToObject();
 
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031511)
     v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
     sobj = static_cast<SwigV8PackedData*>(v8::External::Unwrap(cdataRef));
 #else
@@ -387,57 +511,82 @@
   return SWIG_OK;
 }
 
-#if (SWIG_V8_VERSION < 0x031900)
-void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter)
-{
+#if (SWIG_V8_VERSION < 0x031710)
+static void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter) {
   SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
+#elif (SWIG_V8_VERSION < 0x031900)
+static void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
+  SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
+#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
+static void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Object> *object, SwigV8PackedData *cdata) {
 #else
-void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SwigV8PackedData *cdata)
-{
+static void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData<v8::Object, SwigV8PackedData> &data) {
+  v8::Local<v8::Object> object = data.GetValue();
+  SwigV8PackedData *cdata = data.GetParameter();
 #endif
 
   delete cdata;
 
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031710)
   object.Clear();
   object.Dispose();
+#elif (SWIG_V8_VERSION < 0x031900)
+  object.Clear();
+  object.Dispose(isolate);
 #elif (SWIG_V8_VERSION < 0x032100)
   object->Dispose(isolate);
-#else
+#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
   object->Dispose();
+#else
+  object.Clear();
 #endif
 }
 
 SWIGRUNTIME
 v8::Handle<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) {
-  v8::HandleScope scope;
+  SWIGV8_HANDLESCOPE_ESC();
 
-  SwigV8PackedData* cdata = new SwigV8PackedData(data, size, type);
-  v8::Handle<v8::Object> obj = v8::Object::New();
+  SwigV8PackedData *cdata = new SwigV8PackedData(data, size, type);
+//  v8::Handle<v8::Object> obj = SWIGV8_OBJECT_NEW();
+  v8::Local<v8::Object> obj = SWIGV8_OBJECT_NEW();
 
-  obj->SetHiddenValue(v8::String::New("__swig__packed_data__"), v8::Boolean::New(true));
+  obj->SetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"), SWIGV8_BOOLEAN_NEW(true));
 
-#if (SWIG_V8_VERSION < 0x031900)
+#if (SWIG_V8_VERSION < 0x031511)
   obj->SetPointerInInternalField(0, cdata);
-  cdata->handle = v8::Persistent<v8::Object>::New(obj);
 #else
   obj->SetAlignedPointerInInternalField(0, cdata);
+#endif
+
+#if (SWIG_V8_VERSION < 0x031710)
+  cdata->handle = v8::Persistent<v8::Object>::New(obj);
+#elif (SWIG_V8_VERSION < 0x031900)
+  cdata->handle = v8::Persistent<v8::Object>::New(v8::Isolate::GetCurrent(), obj);
+#else
   cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
 #endif
 
-#if (SWIG_V8_VERSION < 0x031900)
+
+#if (SWIG_V8_VERSION < 0x031710)
   cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete);
-  cdata->handle.MarkIndependent();
-#else
+#elif (SWIG_V8_VERSION < 0x031918)
   cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete);
-# if (SWIG_V8_VERSION < 0x032100)
-  cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
-# else
-  cdata->handle.MarkIndependent();
-# endif
+#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
+  cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete);
+#else
+  cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete);
+//  v8::V8::SetWeak(&cdata->handle, cdata, _wrap_SwigV8PackedData_delete);
 #endif
 
-  return scope.Close(obj);
+#if (SWIG_V8_VERSION < 0x031710)
+  cdata->handle.MarkIndependent();
+#elif (SWIG_V8_VERSION < 0x032100)
+  cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
+#else
+  cdata->handle.MarkIndependent();
+#endif
+
+  SWIGV8_ESCAPE(obj);
 }
 
 #define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIGV8_ConvertPacked(obj, ptr, sz, ty)
@@ -450,13 +599,23 @@
  * ---------------------------------------------------------------------------*/
 
 SWIGRUNTIME
+
+#if (SWIG_V8_VERSION < 0x031903)
 v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Handle<v8::Value> result, v8::Handle<v8::Value> obj) {
-  v8::HandleScope scope;
+#else
+v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Local<v8::Value> result, v8::Handle<v8::Value> obj) {
+#endif
+  SWIGV8_HANDLESCOPE_ESC();
+  
   if (result->IsUndefined()) {
-    result = v8::Array::New();
+    result = SWIGV8_ARRAY_NEW();
   }
+#if (SWIG_V8_VERSION < 0x031903)
   v8::Handle<v8::Array> arr = v8::Handle<v8::Array>::Cast(result);
+#else  
+  v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(result);
+#endif  
   arr->Set(arr->Length(), obj);
 
-  return scope.Close(arr);
+  SWIGV8_ESCAPE(arr);
 }
diff --git a/Lib/javascript/v8/javascriptstrings.swg b/Lib/javascript/v8/javascriptstrings.swg
index 69b6836..65ba20e 100644
--- a/Lib/javascript/v8/javascriptstrings.swg
+++ b/Lib/javascript/v8/javascriptstrings.swg
@@ -47,13 +47,13 @@
   if (carray) {
     if (size > INT_MAX) {
       // TODO: handle extra long strings
-      return v8::Undefined();
+      return SWIGV8_UNDEFINED();
     } else {
-      v8::Handle<v8::String> js_str = v8::String::New(carray, size);
+      v8::Handle<v8::String> js_str = SWIGV8_STRING_NEW2(carray, size);
       return js_str;
     }
   } else {
-    return v8::Undefined();
+    return SWIGV8_UNDEFINED();
   }
 }
 }
diff --git a/Lib/javascript/v8/javascripttypemaps.swg b/Lib/javascript/v8/javascripttypemaps.swg
index 90317a1..4601698 100644
--- a/Lib/javascript/v8/javascripttypemaps.swg
+++ b/Lib/javascript/v8/javascripttypemaps.swg
@@ -26,7 +26,7 @@
 /* Javascript types */
 
 #define SWIG_Object                     v8::Handle<v8::Value>
-#define VOID_Object                     v8::Undefined()
+#define VOID_Object                     SWIGV8_UNDEFINED()
 
 /* Overload of the output/constant/exception/dirout handling */
 
diff --git a/Lib/javascript/v8/std_common.i b/Lib/javascript/v8/std_common.i
old mode 100755
new mode 100644
diff --git a/Lib/javascript/v8/std_map.i b/Lib/javascript/v8/std_map.i
old mode 100755
new mode 100644
diff --git a/Lib/javascript/v8/std_pair.i b/Lib/javascript/v8/std_pair.i
old mode 100755
new mode 100644
diff --git a/Lib/javascript/v8/std_string.i b/Lib/javascript/v8/std_string.i
old mode 100755
new mode 100644
index 5ad1ead..dc1378a
--- a/Lib/javascript/v8/std_string.i
+++ b/Lib/javascript/v8/std_string.i
@@ -1,79 +1 @@
-/* -----------------------------------------------------------------------------
- * std_string.i
- *
- * Typemaps for std::string and const std::string&.
- *
- * To use non-const std::string references use the following %apply:
- *      %apply const std::string & {std::string &};
- *
- * ----------------------------------------------------------------------------- */
-
-%{
-#include <string>
-%}
-
-%fragment("SWIGV8_valueToString", "header", fragment="SWIG_AsCharPtrAndSize") {
-std::string* SWIGV8_valueToStringPtr(v8::Handle<v8::Value> val) {
-
-  if (!val->IsString()) return 0;
-
-  int alloc;
-  size_t size;
-  char* chars;
-  int res = SWIG_AsCharPtrAndSize(val, &chars, &size, &alloc);
-
-  if(res != SWIG_OK) {
-    v8::ThrowException(v8::Exception::TypeError(v8::String::New("Could not convert to string.")));
-    return 0;
-  }
-
-  // copies the data (again)
-  std::string *str = new std::string(chars);
-
-  if (alloc) delete[] chars;
-
-  return str;
-}
-}
-
-%fragment("SWIGV8_stringToValue", "header", fragment="SWIG_FromCharPtrAndSize") {
-v8::Handle<v8::Value> SWIGV8_stringToValue(const std::string &str) {
-  return SWIG_FromCharPtrAndSize(str.c_str(), str.length());
-}
-}
-
-namespace std {
-  %naturalvar string;
-
-  class string;
-
-  %typemap(in, fragment="SWIGV8_valueToString") string (std::string* tmp)
-  %{
-     tmp = SWIGV8_valueToStringPtr($input);
-     $1 = *tmp;
-     if (tmp == 0) { v8::ThrowException(v8::Exception::TypeError(v8::String::New("Null pointer."))); goto fail; }
-     if (tmp) delete tmp;
-  %}
-
-  %typemap(in, fragment="SWIGV8_valueToString") const string &
-  %{
-     $1 = SWIGV8_valueToStringPtr($input);
-     if ($1 == 0) { v8::ThrowException(v8::Exception::TypeError(v8::String::New("Null pointer."))); goto fail; }
-  %}
-
-  %typemap(freearg) const string &
-  %{
-     if ($1) delete $1;
-  %}
-
-  %typemap(out, fragment="SWIGV8_stringToValue") string
-  %{
-     $result = SWIGV8_stringToValue($1);
-  %}
-
-  %typemap(out, fragment="SWIGV8_stringToValue") const string &
-  %{
-     $result = SWIGV8_stringToValue(*$1);
-  %}
-
-}
+%include <typemaps/std_string.swg>
diff --git a/Lib/javascript/v8/std_vector.i b/Lib/javascript/v8/std_vector.i
old mode 100755
new mode 100644
index 3f29b19..971b426
--- a/Lib/javascript/v8/std_vector.i
+++ b/Lib/javascript/v8/std_vector.i
@@ -61,7 +61,7 @@
         %rename(add) push_back;
         void push_back(const value_type& x);
         %extend {
-            const_reference get(int i) throw (std::out_of_range) {
+            bool get(int i) throw (std::out_of_range) {
                 int size = int(self->size());
                 if (i>=0 && i<size)
                     return (*self)[i];
diff --git a/Lib/javascript/v8/stl.i b/Lib/javascript/v8/stl.i
old mode 100755
new mode 100644
diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg
index 60e4185..892d157 100644
--- a/Lib/lua/lua.swg
+++ b/Lib/lua/lua.swg
@@ -44,6 +44,9 @@
 %typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE []
        { SWIG_LUA_CONSTTAB_POINTER("$symname",$value, $1_descriptor) }
 
+%typemap(consttab) SWIGTYPE
+       { SWIG_LUA_CONSTTAB_POINTER("$symname",&$value, $&1_descriptor) }
+
 // member function pointers
 %typemap(consttab) SWIGTYPE (CLASS::*)
        { SWIG_LUA_CONSTTAB_BINARY("$symname", sizeof($type),&$value, $1_descriptor) }
diff --git a/Lib/lua/lua_fnptr.i b/Lib/lua/lua_fnptr.i
index 4e2c8dc..481cfaf 100644
--- a/Lib/lua/lua_fnptr.i
+++ b/Lib/lua/lua_fnptr.i
@@ -103,7 +103,6 @@
 }
 
 void swiglua_ref_set(SWIGLUA_REF* pref,lua_State* L,int idx){
-//	swiglua_ref_clear(pref); /* just in case */
 	pref->L=L;
 	lua_pushvalue(L,idx);                 /* copy obj to top */
 	pref->ref=luaL_ref(L,LUA_REGISTRYINDEX); /* remove obj from top & put into registry */
diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg
index d038f4a..d912488 100644
--- a/Lib/lua/luarun.swg
+++ b/Lib/lua/luarun.swg
@@ -268,7 +268,7 @@
   swig_lua_method   *methods;
   swig_lua_attribute     *attributes;
   swig_lua_namespace    *cls_static;
-  swig_lua_method   *metatable; // 0 for -eluac
+  swig_lua_method   *metatable; /* 0 for -eluac */
   struct swig_lua_class **bases;
   const char **base_names;
 } swig_lua_class;
@@ -392,8 +392,9 @@
 /* This function emulates eLua rotables behaviour. It loads a rotable definition into the usual lua table. */
 SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_entry *table)
 {
+  int i, table_parsed, parsed_tables_array, target_table;
   assert(lua_istable(L,-1));
-  int target_table = lua_gettop(L);
+  target_table = lua_gettop(L);
   /* Get the registry where we put all parsed tables to avoid loops */
   lua_rawgetp(L, LUA_REGISTRYINDEX, &swig_lua_elua_emulate_unique_key);
   if(lua_isnil(L,-1)) {
@@ -402,11 +403,10 @@
     lua_pushvalue(L,-1);
     lua_rawsetp(L,LUA_REGISTRYINDEX,(void*)(&swig_lua_elua_emulate_unique_key));
   }
-  int parsed_tables_array = lua_gettop(L);
+  parsed_tables_array = lua_gettop(L);
   lua_pushvalue(L,target_table);
   lua_rawsetp(L, parsed_tables_array, table);
-  int i;
-  int table_parsed = 0;
+  table_parsed = 0;
   const int SWIGUNUSED pairs_start = lua_gettop(L);
   for(i = 0;table[i].key.type != LUA_TNIL || table[i].value.type != LUA_TNIL;i++)
   {
@@ -606,7 +606,7 @@
 /* helper function - register namespace methods and attributes into namespace */
 SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State *L, swig_lua_namespace *ns)
 {
-  int i = 0;
+  int i;
   /* There must be namespace table (not metatable) at the top of the stack */
   assert(lua_istable(L,-1));
   SWIG_Lua_InstallConstants(L, ns->ns_constants);
@@ -630,10 +630,12 @@
 /* Register all classes in the namespace */
 SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace *ns)
 {
+  swig_lua_class **classes;
+
   /* There must be a module/namespace table at the top of the stack */
   assert(lua_istable(L,-1));
 
-  swig_lua_class **classes = ns->ns_classes;
+  classes = ns->ns_classes;
 
   if( classes != 0 ) {
     while(*classes != 0) {
@@ -650,6 +652,7 @@
 */
 SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg)
 {
+  swig_lua_namespace **sub_namespace;
   /* 1 argument - table on the top of the stack */
   const int SWIGUNUSED begin = lua_gettop(L);
   assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table or parent namespace table */
@@ -681,7 +684,7 @@
   /* Register classes */
   SWIG_Lua_add_namespace_classes(L,ns);
 
-  swig_lua_namespace **sub_namespace = ns->ns_namespaces;
+  sub_namespace = ns->ns_namespaces;
   if( sub_namespace != 0) {
     while(*sub_namespace != 0) {
       SWIG_Lua_namespace_register(L, *sub_namespace, 1);
@@ -705,46 +708,6 @@
 
 SWIGINTERN void  SWIG_Lua_get_class_metatable(lua_State *L,const char *cname);
 
-/* Macros for iteration among class bases */
-#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
-#define SWIG_LUA_INIT_BASE_SEARCH(bases_count)\
-  (void)swig_type;\
-  SWIG_Lua_get_table(L,".bases");\
-  assert(lua_istable(L,-1));\
-  bases_count = lua_rawlen(L,-1);\
-  const int bases_table = lua_gettop(L);
-#define SWIG_LUA_GET_BASE_METATABLE(i,base_swig_type, valid)\
-  lua_rawgeti(L,bases_table,i+1);\
-  base_swig_type = 0;\
-  if(lua_isnil(L,-1)) {\
-    valid = 0;\
-    lua_pop(L,1);\
-  } else\
-    valid = 1;
-  
-#else /* In elua .bases table doesn't exist. Use table from swig_lua_class */
-
-#define SWIG_LUA_INIT_BASE_SEARCH(bases_count)\
-  assert(swig_type!=0);\
-  swig_module_info *module=SWIG_GetModule(L);\
-  swig_lua_class **bases= ((swig_lua_class*)(swig_type->clientdata))->bases;\
-  const char **base_names= ((swig_lua_class*)(swig_type->clientdata))->base_names;\
-  bases_count = 0;\
-  for(;base_names[bases_count];bases_count++);/* get length of bases */
-
-#define SWIG_LUA_GET_BASE_METATABLE(i,base_swig_type, valid)\
-  swig_lua_class *base_class = bases[i];\
-  if(!base_class)\
-    valid = 0;\
-  else {\
-    valid = 1;\
-    SWIG_Lua_get_class_metatable(L,base_class->fqname);\
-    base_swig_type = SWIG_TypeQueryModule(module,module,base_names[i]);\
-    assert(base_swig_type != 0);\
-  }
-
-#endif
-
 typedef int (*swig_lua_base_iterator_func)(lua_State*,swig_type_info*, int, int *ret);
 
 SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED swig_type,
@@ -753,27 +716,70 @@
     /* first_arg - position of the object in stack. Everything that is above are arguments
      * and is passed to every evocation of the func */
     int last_arg = lua_gettop(L);/* position of last argument */
-    lua_getmetatable(L,first_arg);
     int original_metatable = last_arg + 1;
     size_t bases_count;
-    SWIG_LUA_INIT_BASE_SEARCH(bases_count);
     int result = SWIG_ERROR;
+    int bases_table;
+    (void)swig_type;
+    lua_getmetatable(L,first_arg);
+
+    /* initialise base search */
+#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
+    SWIG_Lua_get_table(L,".bases");
+    assert(lua_istable(L,-1));
+    bases_count = lua_rawlen(L,-1);
+    bases_table = lua_gettop(L);
+#else
+    /* In elua .bases table doesn't exist. Use table from swig_lua_class */
+    (void)bases_table;
+    assert(swig_type!=0);
+    swig_module_info *module=SWIG_GetModule(L);
+    swig_lua_class **bases= ((swig_lua_class*)(swig_type->clientdata))->bases;
+    const char **base_names= ((swig_lua_class*)(swig_type->clientdata))->base_names;
+    bases_count = 0;
+    for(;base_names[bases_count];
+      bases_count++);/* get length of bases */
+#endif
+
     if(ret)
       *ret = 0;
     if(bases_count>0)
     {
+      int to_remove;
       size_t i;
       int j;
+      int subcall_last_arg;
       int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */
       int valid = 1;
+      swig_type_info *base_swig_type = 0;
       for(j=first_arg;j<=last_arg;j++)
         lua_pushvalue(L,j);
-      int subcall_last_arg = lua_gettop(L);
-      swig_type_info *base_swig_type = 0;
+      subcall_last_arg = lua_gettop(L);
 
       /* Trick: temporarily replacing original metatable with metatable for base class and call getter */
       for(i=0;i<bases_count;i++) {
-        SWIG_LUA_GET_BASE_METATABLE(i,base_swig_type,valid);
+        /* Iteration through class bases */
+#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
+        lua_rawgeti(L,bases_table,i+1);
+        base_swig_type = 0;
+        if(lua_isnil(L,-1)) {
+          valid = 0;
+          lua_pop(L,1);
+        } else {
+          valid = 1;
+        }
+#else /* In elua .bases table doesn't exist. Use table from swig_lua_class */
+        swig_lua_class *base_class = bases[i];
+        if(!base_class) {
+          valid = 0;
+        } else {
+          valid = 1;
+          SWIG_Lua_get_class_metatable(L,base_class->fqname);
+          base_swig_type = SWIG_TypeQueryModule(module,module,base_names[i]);
+          assert(base_swig_type != 0);
+        }
+#endif
+
         if(!valid)
           continue;
         assert(lua_isuserdata(L, subcall_first_arg));
@@ -789,7 +795,7 @@
       lua_pushvalue(L,original_metatable);
       lua_setmetatable(L,first_arg);
       /* Clear - remove everything between last_arg and subcall_last_arg including */
-      const int to_remove = subcall_last_arg - last_arg;
+      to_remove = subcall_last_arg - last_arg;
       for(j=0;j<to_remove;j++)
         lua_remove(L,last_arg+1);
     } else {
@@ -810,6 +816,7 @@
   (1) userdata (not the meta table)
   (2) string name of the attribute
 */
+  int bases_search_result;
   int substack_start = lua_gettop(L)-2;
   assert(first_arg == substack_start+1);
   lua_checkstack(L,5);
@@ -862,8 +869,7 @@
   /* Remove the metatable */
   lua_pop(L,1);
   /* Search in base classes */
-  
-  int bases_search_result = SWIG_Lua_iterate_bases(L,type,substack_start+1,SWIG_Lua_class_do_get,ret);
+  bases_search_result = SWIG_Lua_iterate_bases(L,type,substack_start+1,SWIG_Lua_class_do_get,ret);
   return bases_search_result;  /* sorry not known */
 }
 
@@ -875,11 +881,14 @@
   (1) userdata (not the meta table)
   (2) string name of the attribute
 */
-  assert(lua_isuserdata(L,1));
-  swig_lua_userdata *usr=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
-  swig_type_info *type = usr->type;
+  int result;
+  swig_lua_userdata *usr;
+  swig_type_info *type;
   int ret = 0;
-  int result = SWIG_Lua_class_do_get(L,type,1,&ret);
+  assert(lua_isuserdata(L,1));
+  usr=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
+  type = usr->type;
+  result = SWIG_Lua_class_do_get(L,type,1,&ret);
   if(result == SWIG_OK)
     return ret;
 
@@ -897,6 +906,7 @@
   (3) any for the new value
   */
 
+  int bases_search_result;
   int substack_start = lua_gettop(L) - 3;
   lua_checkstack(L,5);
   assert(lua_isuserdata(L,substack_start+1));  /* just in case */
@@ -940,7 +950,7 @@
 
   lua_pop(L,1); /* remove metatable */
   /* Search among bases */
-  int bases_search_result = SWIG_Lua_iterate_bases(L,type,first_arg,SWIG_Lua_class_do_set,ret);
+  bases_search_result = SWIG_Lua_iterate_bases(L,type,first_arg,SWIG_Lua_class_do_set,ret);
   if(ret)
     assert(*ret == 0);
   assert(lua_gettop(L) == substack_start + 3);
@@ -957,11 +967,14 @@
   (2) string name of the attribute
   (3) any for the new value
   */
-  assert(lua_isuserdata(L,1));
-  swig_lua_userdata *usr=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
-  swig_type_info *type = usr->type;
   int ret = 0;
-  int result = SWIG_Lua_class_do_set(L,type,1,&ret);
+  int result;
+  swig_lua_userdata *usr;
+  swig_type_info *type;
+  assert(lua_isuserdata(L,1));
+  usr=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
+  type = usr->type;
+  result = SWIG_Lua_class_do_set(L,type,1,&ret);
   if(result != SWIG_OK) {
    SWIG_Lua_pushferrstring(L,"Assignment not possible. No setter/member with this name. For custom assignments implement __setitem method.");
    lua_error(L);
@@ -997,13 +1010,15 @@
 {
 /*  there should be 1 param passed in
   (1) userdata (not the metatable) */
+  const char *className;
+  void* userData;
   assert(lua_isuserdata(L,1));  /* just in case */
-  void* userData = lua_touserdata(L,1); /* get the userdata address for later */
+  userData = lua_touserdata(L,1); /* get the userdata address for later */
   lua_getmetatable(L,1);    /* get the meta table */
   assert(lua_istable(L,-1));  /* just in case */
 
   lua_getfield(L, -1, ".type");
-  const char *className = lua_tostring(L, -1);
+  className = lua_tostring(L, -1);
 
   lua_pushfstring(L, "<%s userdata: %p>", className, userData);
   return 1;
@@ -1022,6 +1037,23 @@
   return 0;
 }
 
+/* lua callable function to compare userdata's value
+the issue is that two userdata may point to the same thing
+but to lua, they are different objects */
+SWIGRUNTIME int SWIG_Lua_class_equal(lua_State *L)
+{
+  int result;
+  swig_lua_userdata *usr1,*usr2;
+  if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2))  /* just in case */
+    return 0;  /* nil reply */
+  usr1=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
+  usr2=(swig_lua_userdata*)lua_touserdata(L,2);  /* get data */
+  /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/
+  result=(usr1->ptr==usr2->ptr);
+   lua_pushboolean(L,result);
+  return 1;
+}
+
 /* populate table at the top of the stack with metamethods that ought to be inherited */
 SWIGINTERN void SWIG_Lua_populate_inheritable_metamethods(lua_State *L)
 {
@@ -1129,7 +1161,7 @@
 
 #if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
 /* Merges two tables  */
-SWIGINTERN int SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source)
+SWIGINTERN void SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source)
 {
   /* iterating */
   lua_pushnil(L);
@@ -1145,7 +1177,7 @@
 }
 
 /* Merges two tables with given name. original - index of target metatable, base - index of source metatable */
-SWIGINTERN int SWIG_Lua_merge_tables(lua_State *L, const char* name, int original, int base)
+SWIGINTERN void SWIG_Lua_merge_tables(lua_State *L, const char* name, int original, int base)
 {
   /* push original[name], then base[name] */
   lua_pushstring(L,name);
@@ -1160,7 +1192,7 @@
 }
 
 /* Function takes all symbols from base and adds it to derived class. It's just a helper. */
-SWIGINTERN int SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls)
+SWIGINTERN void SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls)
 {
   /* There is one parameter - original, i.e. 'derived' class metatable */
   assert(lua_istable(L,-1));
@@ -1174,7 +1206,7 @@
 }
 
 /* Function squashes all symbols from 'clss' bases into itself */
-SWIGINTERN int  SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss)
+SWIGINTERN void  SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss)
 {
   int i;
   SWIG_Lua_get_class_metatable(L,clss->fqname);
@@ -1231,10 +1263,10 @@
 SWIGINTERN void  SWIG_Lua_add_class_instance_details(lua_State *L, swig_lua_class *clss)
 {
   int i;
+  size_t bases_count = 0;
   /* Add bases to .bases table */
   SWIG_Lua_get_table(L,".bases");
   assert(lua_istable(L,-1));  /* just in case */
-  size_t bases_count = 0;
   for(i=0;clss->bases[i];i++)
   {
     SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
@@ -1289,7 +1321,7 @@
 
 /* The real function that resolves a metamethod.
  * Function searches given class and all it's bases(recursively) for first instance of something that is
- * not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actuall metamethod implementation
+ * not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actual metamethod implementation
  * and it is a SWIG-generated C function.). It returns value on the top of the L and there is no garbage below the
  * answer.
  * Returns 1 if found, 0 otherwise.
@@ -1303,6 +1335,9 @@
     int skip_check)
 {
   /* This function is called recursively */
+  int result = 0;
+  int i = 0;
+
   if (!skip_check) {
     SWIG_Lua_get_class_metatable(L, clss->fqname);
     lua_pushvalue(L, metamethod_name_idx);
@@ -1319,8 +1354,6 @@
   }
 
   /* Forwarding calls to bases */
-  int result = 0;
-  int i = 0;
   for(i=0;clss->bases[i];i++)
   {
     result = SWIG_Lua_do_resolve_metamethod(L, clss->bases[i], metamethod_name_idx, 0);
@@ -1335,21 +1368,26 @@
  * and calls it */
 SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L)
 {
+  int numargs;
+  int metamethod_name_idx;
+  const swig_lua_class* clss;
+  int result;
+
   lua_checkstack(L,5);
-  const int numargs = lua_gettop(L); /* number of arguments to pass to actuall metamethod */
+  numargs = lua_gettop(L); /* number of arguments to pass to actual metamethod */
   
   /* Get upvalues from closure */
   lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/
-  const int metamethod_name_idx = lua_gettop(L);
+  metamethod_name_idx = lua_gettop(L);
   
   lua_pushvalue(L, lua_upvalueindex(2));
-  const swig_lua_class* clss = (const swig_lua_class*)(lua_touserdata(L,-1));
+  clss = (const swig_lua_class*)(lua_touserdata(L,-1));
   lua_pop(L,1); /* remove lightuserdata with clss from stack */
 
-  /* Actuall work */
-  const int result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1);
+  /* Actual work */
+  result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1);
   if (!result) {
-   SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actuall metamethod. Memory corruption is most likely explanation.");
+   SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actual metamethod. Memory corruption is most likely explanation.");
    lua_error(L);
    return 0;
   }
@@ -1367,10 +1405,14 @@
  */
 SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *clss, const int metatable_index)
 {
+  int key_index;
+  int success = 0;
+  int i = 0;
+
   /* metamethod name - on the top of the stack */
   assert(lua_isstring(L,-1));
   
-  const int key_index = lua_gettop(L);
+  key_index = lua_gettop(L);
 
   /* Check whether method is already defined in metatable */
   lua_pushvalue(L,key_index); /* copy of the key */
@@ -1382,8 +1424,6 @@
   lua_pop(L,1); 
 
   /* Iterating over immediate bases */
-  int success = 0;
-  int i = 0;
   for(i=0;clss->bases[i];i++)
   {
     const swig_lua_class *base = clss->bases[i];
@@ -1413,11 +1453,16 @@
 
 SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss)
 {
+  int metatable_index;
+  int metamethods_info_index;
+  int tostring_undefined;
+  int eq_undefined = 0;
+
   SWIG_Lua_get_class_metatable(L, clss->fqname);
-  const int metatable_index = lua_gettop(L);
+  metatable_index = lua_gettop(L);
   SWIG_Lua_get_inheritable_metamethods(L);
   assert(lua_istable(L,-1));
-  const int metamethods_info_index = lua_gettop(L);
+  metamethods_info_index = lua_gettop(L);
   lua_pushnil(L); /* first key */
   while(lua_next(L, metamethods_info_index) != 0 ) {
     /* key at index -2, value at index -1 */
@@ -1435,7 +1480,7 @@
   lua_pushstring(L, "__tostring");
   lua_pushvalue(L,-1);
   lua_rawget(L,metatable_index);
-  const int tostring_undefined = lua_isnil(L,-1);
+  tostring_undefined = lua_isnil(L,-1);
   lua_pop(L,1);
   if( tostring_undefined ) {
     lua_pushcfunction(L, SWIG_Lua_class_tostring);
@@ -1444,6 +1489,18 @@
     lua_pop(L,1); /* remove copy of the key */
   }
 
+  /* Special handling for __eq method */
+  lua_pushstring(L, "__eq");
+  lua_pushvalue(L,-1);
+  lua_rawget(L,metatable_index);
+  eq_undefined = lua_isnil(L,-1);
+  lua_pop(L,1);
+  if( eq_undefined ) {
+    lua_pushcfunction(L, SWIG_Lua_class_equal);
+    lua_rawset(L, metatable_index);
+  } else {
+    lua_pop(L,1); /* remove copy of the key */
+  }
   /* Warning: __index and __newindex are SWIG-defined. For user-defined operator[]
    * a __getitem/__setitem method should be defined
    */
@@ -1488,6 +1545,7 @@
 SWIGINTERN void  SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss)
 {
   const int SWIGUNUSED begin = lua_gettop(L);
+  int i;
   /* if name already there (class is already registered) then do nothing */
   SWIG_Lua_get_class_registry(L);  /* get the registry */
   lua_pushstring(L,clss->fqname);  /* get the name */
@@ -1499,7 +1557,6 @@
   }
   lua_pop(L,2); /* tidy stack */
   /* Recursively initialize all bases */
-  int i = 0;
   for(i=0;clss->bases[i];i++)
   {
     SWIG_Lua_class_register_instance(L,clss->bases[i]);
@@ -1513,13 +1570,16 @@
    * It would get us all special methods: __getitem, __add etc.
    * This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away
    */
-  const int new_metatable_index = lua_absindex(L,-1);
-  for(i=0;clss->bases[i];i++)
   {
-    SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
-    const int base_metatable = lua_absindex(L,-1);
-    SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable);
-    lua_pop(L,1);
+    int new_metatable_index = lua_absindex(L,-1);
+    for(i=0;clss->bases[i];i++)
+    {
+      int base_metatable;
+      SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);
+      base_metatable = lua_absindex(L,-1);
+      SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable);
+      lua_pop(L,1);
+    }
   }
   /* And now we will overwrite all incorrectly set data */
 #endif
@@ -1566,6 +1626,7 @@
 
 SWIGINTERN void  SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss)
 {
+  int SWIGUNUSED begin;
   assert(lua_istable(L,-1)); /* This is a table (module or namespace) where classes will be added */
   SWIG_Lua_class_register_instance(L,clss);
   SWIG_Lua_class_register_static(L,clss);
@@ -1580,7 +1641,7 @@
    *                                             |                                ".set" --> ....
    *                                             |=============================== ".instance"
    */
-  const int SWIGUNUSED begin = lua_gettop(L);
+  begin = lua_gettop(L);
   lua_pushstring(L,clss->cls_static->name);
   lua_rawget(L,-2); /* get class static table */
   assert(lua_istable(L,-1));
@@ -1604,6 +1665,7 @@
 SWIGINTERN void SWIG_Lua_elua_class_register_instance(lua_State *L, swig_lua_class *clss)
 {
   const int SWIGUNUSED begin = lua_gettop(L);
+  int i;
   /* if name already there (class is already registered) then do nothing */
   SWIG_Lua_get_class_registry(L);  /* get the registry */
   lua_pushstring(L,clss->fqname);  /* get the name */
@@ -1615,7 +1677,6 @@
   }
   lua_pop(L,2); /* tidy stack */
   /* Recursively initialize all bases */
-  int i = 0;
   for(i=0;clss->bases[i];i++)
   {
     SWIG_Lua_elua_class_register_instance(L,clss->bases[i]);
@@ -1629,7 +1690,7 @@
   lua_pop(L,1);
   assert(lua_gettop(L) == begin);
 }
-#endif // elua && eluac
+#endif /* elua && eluac */
 
 /* -----------------------------------------------------------------------------
  * Class/structure conversion fns
@@ -1757,23 +1818,6 @@
   return 1;
 }
 
-/* lua callable function to compare userdata's value
-the issue is that two userdata may point to the same thing
-but to lua, they are different objects */
-SWIGRUNTIME int SWIG_Lua_equal(lua_State *L)
-{
-  int result;
-  swig_lua_userdata *usr1,*usr2;
-  if (!lua_isuserdata(L,1) || !lua_isuserdata(L,2))  /* just in case */
-    return 0;  /* nil reply */
-  usr1=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
-  usr2=(swig_lua_userdata*)lua_touserdata(L,2);  /* get data */
-  /*result=(usr1->ptr==usr2->ptr && usr1->type==usr2->type); only works if type is the same*/
-  result=(usr1->ptr==usr2->ptr);
-   lua_pushboolean(L,result);
-  return 1;
-}
-
 /* -----------------------------------------------------------------------------
  * global variable support code: class/struct typemap functions
  * ----------------------------------------------------------------------------- */
@@ -1831,8 +1875,8 @@
 #endif
 /* Executes a C string in Lua which is a really simple way of calling lua from C
 Unfortunately lua keeps changing its APIs, so we need a conditional compile
-In lua 5.0.X its lua_dostring()
-In lua 5.1.X its luaL_dostring()
+In lua 5.0.X it's lua_dostring()
+In lua 5.1.X it's luaL_dostring()
 */
 SWIGINTERN int 
 SWIG_Lua_dostring(lua_State *L, const char *str) {
diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg
index 26dab93..8df46e8 100644
--- a/Lib/lua/luaruntime.swg
+++ b/Lib/lua/luaruntime.swg
@@ -29,6 +29,7 @@
 {
 #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */
   int i;
+  int globalRegister = 0;
   /* start with global table */
   lua_pushglobaltable (L);
   /* SWIG's internal initialisation */
@@ -39,7 +40,7 @@
 #if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) || defined(SWIG_LUA_ELUA_EMULATE)
   /* add a global fn */
   SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);
-  SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal);
+  SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_class_equal);
 #endif
 
 #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
@@ -49,7 +50,6 @@
       SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata));
     }
   }
-  int globalRegister = 0;
 #ifdef SWIG_LUA_MODULE_GLOBAL
   globalRegister = 1;
 #endif
diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i
index 7a095a1..c662cd3 100644
--- a/Lib/lua/typemaps.i
+++ b/Lib/lua/typemaps.i
@@ -296,7 +296,7 @@
 for array handling
 */
 %define SWIG_TYPEMAP_NUM_ARR(NAME,TYPE)
-%{SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE);%}
+%{SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE)%}
 
 // fixed size array's
 %typemap(in) TYPE INPUT[ANY]
diff --git a/Lib/mzscheme/Makefile b/Lib/mzscheme/Makefile
index 17f5fec..fba7fd5 100644
--- a/Lib/mzscheme/Makefile
+++ b/Lib/mzscheme/Makefile
@@ -1,4 +1,3 @@
 
 co:
 	co RCS/*.i* RCS/*.swg*
-
diff --git a/Lib/octave/std_carray.i b/Lib/octave/std_carray.i
index 9e2338a..e69de29 100644
--- a/Lib/octave/std_carray.i
+++ b/Lib/octave/std_carray.i
@@ -1,56 +0,0 @@
-%include <pycontainer.swg>
-
-/*
-%fragment("StdCarrayTraits","header",fragment="StdSequenceTraits")
-{
-namespace swig {
-  template <class T, size_t S>
-  struct traits_asptr<std::carray<T, S> >  {
-    static int asptr(PyObject *obj, std::carray<T, S> **array) {
-      return traits_asptr_stdseq<std::carray<T, S> >::asptr(obj, array);
-    }
-  };
-}
-}
-
-%warnfilter(SWIGWARN_IGNORE_OPERATOR_INDEX) std::carray::operator[];
-
-%extend std::carray {
-  %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header",
-	    fragment="SwigPyIterator_T",
-	    fragment=SWIG_Traits_frag(_Type),
-	    fragment="StdCarrayTraits") {
-    namespace swig {
-      template <>  struct traits<std::carray<_Type, _Size > > {
-	typedef pointer_category category;
-	static const char* type_name() {
-	  return "std::carray<" #_Type "," #_Size " >";
-	}
-      };
-    }
-  }
-  
-  %typemaps_asptr(SWIG_TYPECHECK_VECTOR, swig::asptr,
-		  SWIG_Traits_frag(std::carray<_Type, _Size >),
-		  std::carray<_Type, _Size >);
-
-  %typemap(out,noblock=1) iterator, const_iterator {
-    $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1),
-				 swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  }
-  
-  inline size_t __len__() const { return self->size(); }
-  
-  inline const _Type& __getitem__(size_t i) const { return (*self)[i]; }
-  
-  inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; }
-
-  
-  swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) {
-    return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
-  }
-}
-
-%include <std/std_carray.swg>
-*/
-
diff --git a/Lib/perl5/Makefile.in b/Lib/perl5/Makefile.in
index 1fee86c..e0b3b74 100644
--- a/Lib/perl5/Makefile.in
+++ b/Lib/perl5/Makefile.in
@@ -1,6 +1,6 @@
 # ---------------------------------------------------------------
 # SWIG Perl5 Makefile
-# 
+#
 # This file can be used to build various Perl5 extensions with SWIG.
 # By default this file is set up for dynamic loading, but it can
 # be easily customized for static extensions by modifying various
@@ -17,11 +17,11 @@
 # script and should already reflect your machine.
 #----------------------------------------------------------------
 
-SRCS          = 
-CXXSRCS       = 
-OBJCSRCS      = 
-OBJS          = 
-INTERFACE     = 
+SRCS          =
+CXXSRCS       =
+OBJCSRCS      =
+OBJS          =
+INTERFACE     =
 WRAPFILE      = $(INTERFACE:.i=_wrap.c)
 WRAPOBJ       = $(INTERFACE:.i=_wrap.o)
 TARGET        = module@SO@ # Use this kind of target for dynamic loading
@@ -32,8 +32,8 @@
 
 CC            = @CC@
 CXX           = @CXX@
-OBJC          = @CC@ -Wno-import # -Wno-import needed for gcc 
-CFLAGS        = 
+OBJC          = @CC@ -Wno-import # -Wno-import needed for gcc
+CFLAGS        =
 INCLUDES      =
 LIBS          =
 
@@ -42,9 +42,9 @@
 #     SWIGOPT   = SWIG compiler options
 #     SWIGCC    = Compiler used to compile the wrapper file
 
-SWIG          = $(exec_prefix)/bin/swig 
-SWIGOPT       = -perl5 
-SWIGCC        = $(CC) 
+SWIG          = $(exec_prefix)/bin/swig
+SWIGOPT       = -perl5
+SWIGCC        = $(CC)
 
 # SWIG Library files.  Uncomment this to statically rebuild Perl
 #SWIGLIBS      = -static -lperlmain.i
@@ -67,12 +67,12 @@
 # need to provide additional link libraries (this is not always required).
 
 #DLL_LIBS      = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-             -L/usr/local/lib -lg++ -lstdc++ -lgcc
+	     -L/usr/local/lib -lg++ -lstdc++ -lgcc
 
 # Perl installation
 
 PERL_INCLUDE  = -I@PERL5EXT@
-PERL_LIB      = -L@PERL5EXT@ -lperl 
+PERL_LIB      = -L@PERL5EXT@ -lperl
 PERL_FLAGS    = -Dbool=char -Dexplicit=
 
 # Build libraries (needed for static builds)
@@ -118,9 +118,3 @@
 
 clean:
 	rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET)
-
-
-
-
-
-
diff --git a/Lib/perl5/Makefile.pl b/Lib/perl5/Makefile.pl
index 05240f1..cffdc8e 100644
--- a/Lib/perl5/Makefile.pl
+++ b/Lib/perl5/Makefile.pl
@@ -7,7 +7,7 @@
 # 2.  Run perl as 'perl Makefile.pl'
 # 3.  Type 'make' to build your module
 # 4.  Type 'make install' to install your module.
-# 
+#
 # See "Programming Perl", 2nd. Ed, for more gory details than
 # you ever wanted to know.
 
@@ -17,5 +17,3 @@
      'LIBS' => [''],                 # Custom libraries (if any)
      'OBJECT' => '$module_wrap.o'    # Object files
 );
-
-
diff --git a/Lib/perl5/perlinit.swg b/Lib/perl5/perlinit.swg
index d9ffa9b..cdb73d5 100644
--- a/Lib/perl5/perlinit.swg
+++ b/Lib/perl5/perlinit.swg
@@ -21,7 +21,7 @@
 
 %init %{
 
-#ifdef __cplusplus
+#if defined(__cplusplus) && ! defined(XSPROTO)
 extern "C"
 #endif
 
diff --git a/Lib/php/const.i b/Lib/php/const.i
index 82c4802..061ba99 100644
--- a/Lib/php/const.i
+++ b/Lib/php/const.i
@@ -14,7 +14,7 @@
                    signed char,
                    bool,
                    enum SWIGTYPE
-  "SWIG_LONG_CONSTANT($symname, $value);";
+  "SWIG_LONG_CONSTANT($symname, ($1_type)$value);";
 
 %typemap(consttab) float,
                    double
@@ -34,12 +34,12 @@
                    SWIGTYPE &&,
                    SWIGTYPE [] {
   zval *z_var;
+  zend_constant c;
+  size_t len = sizeof("$symname") - 1;
   MAKE_STD_ZVAL(z_var);
   SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0);
-  zend_constant c;
   c.value = *z_var;
   zval_copy_ctor(&c.value);
-  size_t len = sizeof("$symname") - 1;
   c.name = zend_strndup("$symname", len);
   c.name_len = len+1;
   c.flags = CONST_CS | CONST_PERSISTENT;
diff --git a/Lib/php/director.swg b/Lib/php/director.swg
index 06eeb73..92c1499 100644
--- a/Lib/php/director.swg
+++ b/Lib/php/director.swg
@@ -98,8 +98,7 @@
         TSRMLS_SET_CTX(swig_zts_ctx);
       }
 
-      bool swig_is_overridden_method(char *cname, char *lc_fname) {
-        TSRMLS_FETCH_FROM_CTX(swig_zts_ctx);
+      static bool swig_is_overridden_method(char *cname, char *lc_fname TSRMLS_DC) {
         zend_class_entry **ce;
         zend_function *mptr;
 
diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i
index 56f9214..4f21c5c 100644
--- a/Lib/php/globalvar.i
+++ b/Lib/php/globalvar.i
@@ -34,7 +34,7 @@
   zval *z_var;
   MAKE_STD_ZVAL(z_var);
   z_var->type = IS_LONG;
-  z_var->value.lval = $1;
+  z_var->value.lval = (long)$1;
   zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL);
 }
 
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index afa047e..8b5fb7b 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -93,10 +93,12 @@
 
 %typemap(directorout) SWIGTYPE ($&1_ltype tmp)
 {
-	if(SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) {
-          SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
+	/* If exit was via exception, PHP NULL is returned so skip the conversion. */
+	if (!EG(exception)) {
+	  if(SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL)
+	    SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
+	  $result = *tmp;
 	}
-	$result = *tmp;
 }
 
 %typemap(in) SWIGTYPE *,
diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg
index 14f37d2..36e535f 100644
--- a/Lib/php/phpkw.swg
+++ b/Lib/php/phpkw.swg
@@ -625,6 +625,28 @@
 /* Added in PHP 5.6 */
 PHPBN2(LDAP_ESCAPE_DN);
 PHPBN2(LDAP_ESCAPE_FILTER);
+PHPBN2(OPENSSL_DEFAULT_STREAM_CIPHERS);
+PHPBN2(STREAM_CRYPTO_METHOD_ANY_CLIENT);
+PHPBN2(STREAM_CRYPTO_METHOD_ANY_SERVER);
+PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT);
+PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_0_SERVER);
+PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT);
+PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_1_SERVER);
+PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT);
+PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_2_SERVER);
+PHPBN2(PGSQL_CONNECT_ASYNC);
+PHPBN2(PGSQL_CONNECTION_AUTH_OK);
+PHPBN2(PGSQL_CONNECTION_AWAITING_RESPONSE);
+PHPBN2(PGSQL_CONNECTION_MADE);
+PHPBN2(PGSQL_CONNECTION_SETENV);
+PHPBN2(PGSQL_CONNECTION_SSL_STARTUP);
+PHPBN2(PGSQL_CONNECTION_STARTED);
+PHPBN2(PGSQL_DML_ESCAPE);
+PHPBN2(PGSQL_POLLING_ACTIVE);
+PHPBN2(PGSQL_POLLING_FAILED);
+PHPBN2(PGSQL_POLLING_OK);
+PHPBN2(PGSQL_POLLING_READING);
+PHPBN2(PGSQL_POLLING_WRITING);
 
 /* Class names reserved by PHP (case insensitive) */
 PHPCN(directory);
diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg
index 6d922bc..00d8bc5 100644
--- a/Lib/php/phprun.swg
+++ b/Lib/php/phprun.swg
@@ -153,7 +153,7 @@
       }
       Z_SET_REFCOUNT_P(z, 1);
       Z_SET_ISREF_P(z);
-      zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval), NULL);
+      zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval*), NULL);
     }
     return;
   }
diff --git a/Lib/php/utils.i b/Lib/php/utils.i
index 4e53e25..408a3b3 100644
--- a/Lib/php/utils.i
+++ b/Lib/php/utils.i
@@ -92,6 +92,7 @@
 %fragment("t_output_helper","header") %{
 static void
 t_output_helper(zval **target, zval *o TSRMLS_DC) {
+  zval *tmp;
   if ( (*target)->type == IS_ARRAY ) {
     /* it's already an array, just append */
     add_next_index_zval( *target, o );
@@ -102,7 +103,6 @@
     FREE_ZVAL(o);
     return;
   }
-  zval *tmp;
   ALLOC_INIT_ZVAL(tmp);
   *tmp = **target;
   zval_copy_ctor(tmp);
diff --git a/Lib/pointer.i b/Lib/pointer.i
index 8015317..ea8e535 100644
--- a/Lib/pointer.i
+++ b/Lib/pointer.i
@@ -4,7 +4,7 @@
 
 
 %echo "pointer.i is deprecated.  Use cpointer.i instead."
-%echo "See http://www.swig.org/Doc1.3/Library.html"
+%echo "See http://www.swig.org/Doc3.0/Library.html"
 
 
 
diff --git a/Lib/python/Makefile.in b/Lib/python/Makefile.in
index 71effea..27c3844 100644
--- a/Lib/python/Makefile.in
+++ b/Lib/python/Makefile.in
@@ -1,6 +1,6 @@
 # ---------------------------------------------------------------
 # SWIG Python Makefile
-# 
+#
 # This file can be used to build various Python extensions with SWIG.
 # By default this file is set up for dynamic loading, but it can
 # be easily customized for static extensions by modifying various
@@ -17,11 +17,11 @@
 # script and should already reflect your machine.
 #----------------------------------------------------------------
 
-SRCS          = 
-CXXSRCS       = 
-OBJCSRCS      = 
-OBJS          = 
-INTERFACE     = 
+SRCS          =
+CXXSRCS       =
+OBJCSRCS      =
+OBJS          =
+INTERFACE     =
 WRAPFILE      = $(INTERFACE:.i=_wrap.c)
 WRAPOBJ       = $(INTERFACE:.i=_wrap.o)
 TARGET        = module@SO@ # Use this kind of target for dynamic loading
@@ -32,8 +32,8 @@
 
 CC            = @CC@
 CXX           = @CXX@
-OBJC          = @CC@ -Wno-import # -Wno-import needed for gcc 
-CFLAGS        = 
+OBJC          = @CC@ -Wno-import # -Wno-import needed for gcc
+CFLAGS        =
 INCLUDES      =
 LIBS          =
 
@@ -42,9 +42,9 @@
 #     SWIGOPT   = SWIG compiler options
 #     SWIGCC    = Compiler used to compile the wrapper file
 
-SWIG          = $(exec_prefix)/bin/swig 
-SWIGOPT       = -python 
-SWIGCC        = $(CC) 
+SWIG          = $(exec_prefix)/bin/swig
+SWIGOPT       = -python
+SWIGCC        = $(CC)
 
 # SWIG Library files.  Uncomment if rebuilding the Python interpreter
 #SWIGLIBS      = -lembed.i
@@ -67,11 +67,11 @@
 # need to provide additional link libraries (this is not always required).
 
 #DLL_LIBS      = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-             -L/usr/local/lib -lg++ -lstdc++ -lgcc
+	     -L/usr/local/lib -lg++ -lstdc++ -lgcc
 
 # Python installation
 
-PY_INCLUDE    = -DHAVE_CONFIG_H @PYINCLUDE@ 
+PY_INCLUDE    = -DHAVE_CONFIG_H @PYINCLUDE@
 PY_LIB        = @PYLIB@
 
 # Build libraries (needed for static builds)
@@ -107,7 +107,7 @@
 # Convert the wrapper file into an object file
 
 $(WRAPOBJ) : $(WRAPFILE)
-	$(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE) 
+	$(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(PY_INCLUDE)
 
 $(WRAPFILE) : $(INTERFACE)
 	$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE)
@@ -117,7 +117,3 @@
 
 clean:
 	rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET)
-
-
-
-
diff --git a/Lib/python/pyclasses.swg b/Lib/python/pyclasses.swg
index b73ebdb..9d6299f 100644
--- a/Lib/python/pyclasses.swg
+++ b/Lib/python/pyclasses.swg
@@ -72,27 +72,35 @@
 
     SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
     {
+      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
       Py_XINCREF(_obj);      
+      SWIG_PYTHON_THREAD_END_BLOCK;
     }
     
     SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
     {
       if (initial_ref) {
+        SWIG_PYTHON_THREAD_BEGIN_BLOCK;
         Py_XINCREF(_obj);
+        SWIG_PYTHON_THREAD_END_BLOCK;
       }
     }
     
     SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) 
     {
+      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
       Py_XINCREF(item._obj);
       Py_XDECREF(_obj);
       _obj = item._obj;
+      SWIG_PYTHON_THREAD_END_BLOCK;
       return *this;      
     }
     
     ~SwigPtr_PyObject() 
     {
+      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
       Py_XDECREF(_obj);
+      SWIG_PYTHON_THREAD_END_BLOCK;
     }
     
     operator PyObject *() const
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index dcada87..e5543cd 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -710,7 +710,8 @@
 #if defined(SWIGPYTHON_BUILTIN)
   %feature("python:slot", "tp_iter", functype="getiterfunc") iterator;
 #else
-  %pythoncode {def __iter__(self): return self.iterator()}
+  %pythoncode {def __iter__(self):
+    return self.iterator()}
 #endif
   }
 
@@ -873,6 +874,13 @@
       *(swig::getpos(self,i)) = x;
     }
 
+#if defined(SWIGPYTHON_BUILTIN)
+    // This will be called through the mp_ass_subscript slot to delete an entry.
+    void __setitem__(difference_type i) throw (std::out_of_range) {
+      self->erase(swig::getpos(self,i));
+    }
+#endif
+
     void append(const value_type& x) {
       self->push_back(x);
     }
@@ -891,6 +899,13 @@
       *(swig::getpos(self,i)) = x;
     }
 
+#if defined(SWIGPYTHON_BUILTIN)
+    // This will be called through the mp_ass_subscript slot to delete an entry.
+    void __setitem__(difference_type i) throw (std::out_of_range) {
+      self->erase(swig::getpos(self,i));
+    }
+#endif
+
     void append(value_type x) {
       self->push_back(x);
     }
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index b44c2c8..47d3d97 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -375,6 +375,7 @@
   PyObject *public_interface, *public_symbol;
   PyObject *this_descr;
   PyObject *thisown_descr;
+  PyObject *self = 0;
   int i;
 
   (void)builtin_pytype;
@@ -382,6 +383,7 @@
   (void)builtin_basetype;
   (void)tuple;
   (void)static_getset;
+  (void)self;
 
   /* metatype is used to implement static member variables. */
   metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type);
@@ -401,6 +403,7 @@
 #else
   m = Py_InitModule((char *) SWIG_name, SwigMethods);
 #endif
+
   md = d = PyModule_GetDict(m);
   (void)md;
 
diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg
index f93594c..110c431 100644
--- a/Lib/python/pyiterators.swg
+++ b/Lib/python/pyiterators.swg
@@ -344,7 +344,8 @@
   %feature("python:slot", "tp_iternext", functype="iternextfunc") SwigPyIterator::__next__;
 #else
   %extend SwigPyIterator {
-  %pythoncode {def __iter__(self): return self}
+  %pythoncode {def __iter__(self):
+    return self}
   }
 #endif
 
diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg
index f6a4eba..2b14547 100644
--- a/Lib/python/pystrings.swg
+++ b/Lib/python/pystrings.swg
@@ -89,7 +89,11 @@
 	SWIG_InternalNewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void();
     } else {
 %#if PY_VERSION_HEX >= 0x03000000
+%#if PY_VERSION_HEX >= 0x03010000
+      return PyUnicode_DecodeUTF8(carray, %numeric_cast(size,int), "surrogateescape");
+%#else
       return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int));
+%#endif
 %#else
       return PyString_FromStringAndSize(carray, %numeric_cast(size,int));
 %#endif
diff --git a/Lib/python/pythonkw.swg b/Lib/python/pythonkw.swg
index 8ad0ef1..2f76a66 100644
--- a/Lib/python/pythonkw.swg
+++ b/Lib/python/pythonkw.swg
@@ -130,7 +130,7 @@
 /* 
    'self' is also a bad Name
 */
-PYTHONBN(self);
+PYTHONKW(self);
 
 #undef PYTHONBN
 #undef PYTHONKW
diff --git a/Lib/python/pyuserdir.swg b/Lib/python/pyuserdir.swg
index d3c3eb1..00aec07 100644
--- a/Lib/python/pyuserdir.swg
+++ b/Lib/python/pyuserdir.swg
@@ -185,7 +185,6 @@
 #define %clearpythonappend    %feature("pythonappend","")
 
 
-
 /* ------------------------------------------------------------------------- */
 /* 
    %extend_smart_pointer extend the smart pointer support.
diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i
index 66ed68d..58902bc 100644
--- a/Lib/python/std_map.i
+++ b/Lib/python/std_map.i
@@ -176,10 +176,14 @@
 
 #else
   %extend {
-    %pythoncode {def __iter__(self): return self.key_iterator()}    
-    %pythoncode {def iterkeys(self): return self.key_iterator()}
-    %pythoncode {def itervalues(self): return self.value_iterator()}
-    %pythoncode {def iteritems(self): return self.iterator()}
+    %pythoncode {def __iter__(self):
+    return self.key_iterator()}    
+    %pythoncode {def iterkeys(self):
+    return self.key_iterator()}
+    %pythoncode {def itervalues(self):
+    return self.value_iterator()}
+    %pythoncode {def iteritems(self):
+    return self.iterator()}
   }
 #endif
 
diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i
index 7829695..73d47e1 100644
--- a/Lib/python/std_pair.i
+++ b/Lib/python/std_pair.i
@@ -176,18 +176,20 @@
 %define %swig_pair_methods(pair...)
 #if !defined(SWIGPYTHON_BUILTIN)
 %extend {      
-%pythoncode {def __len__(self): return 2
-def __repr__(self): return str((self.first, self.second))
+%pythoncode {def __len__(self):
+    return 2
+def __repr__(self):
+    return str((self.first, self.second))
 def __getitem__(self, index): 
-  if not (index % 2): 
-    return self.first
-  else:
-    return self.second
+    if not (index % 2):
+        return self.first
+    else:
+        return self.second
 def __setitem__(self, index, val):
-  if not (index % 2): 
-    self.first = val
-  else:
-    self.second = val}
+    if not (index % 2):
+        self.first = val
+    else:
+        self.second = val}
 }
 #endif
 %enddef
diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i
index b456035..7374682 100644
--- a/Lib/python/std_unordered_map.i
+++ b/Lib/python/std_unordered_map.i
@@ -231,10 +231,14 @@
       return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
 
-    %pythoncode {def __iter__(self): return self.key_iterator()}    
-    %pythoncode {def iterkeys(self): return self.key_iterator()}
-    %pythoncode {def itervalues(self): return self.value_iterator()}
-    %pythoncode {def iteritems(self): return self.iterator()}
+    %pythoncode {def __iter__(self):
+    return self.key_iterator()}    
+    %pythoncode {def iterkeys(self):
+    return self.key_iterator()}
+    %pythoncode {def itervalues(self):
+    return self.value_iterator()}
+    %pythoncode {def iteritems(self):
+    return self.iterator()}
   }
 %enddef
 
diff --git a/Lib/r/rfragments.swg b/Lib/r/rfragments.swg
index afb75c3..2ec8f86 100644
--- a/Lib/r/rfragments.swg
+++ b/Lib/r/rfragments.swg
@@ -153,7 +153,7 @@
 }
 }
 
-# This is modified from the R header files
+//# This is modified from the R header files
 
 %fragment("SWIG_FromCharPtrAndSize","header") 
 {
diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg
index 9e5aa7b..22639f2 100644
--- a/Lib/r/rtype.swg
+++ b/Lib/r/rtype.swg
@@ -149,34 +149,22 @@
 %typemap(scoerceout) enum SWIGTYPE *const
   %{  $result = enumToInteger($result, "$R_class"); %}
 
-#%typemap(scoerceout) SWIGTYPE 
-#  %{ class($result) <- "$&R_class"; %}
+%typemap(scoerceout) SEXP %{ %}
 
-#%typemap(scoerceout) SWIGTYPE & 
-#  %{ class($result) <- "$R_class"; %}
-
-#%typemap(scoerceout) SWIGTYPE * 
-#  %{ class($result) <- "$R_class"; %}
-
-#%typemap(scoerceout) SWIGTYPE *const
-#  %{ class($result) <- "$R_class"; %}
-
- %typemap(scoerceout) SEXP %{ %}
-
- %typemap(scoerceout) SWIGTYPE 
- %{ $result <- new("$&R_class", ref=$result); %}
+%typemap(scoerceout) SWIGTYPE
+  %{ $result <- new("$&R_class", ref=$result); %}
  
- %typemap(scoerceout) SWIGTYPE & 
- %{ $result <- new("$R_class", ref=$result) ; %}
+%typemap(scoerceout) SWIGTYPE &
+  %{ $result <- new("$R_class", ref=$result) ; %}
  
- %typemap(scoerceout) SWIGTYPE && 
- %{ $result <- new("$R_class", ref=$result) ; %}
+%typemap(scoerceout) SWIGTYPE &&
+  %{ $result <- new("$R_class", ref=$result) ; %}
  
- %typemap(scoerceout) SWIGTYPE * 
- %{ $result <- new("$R_class", ref=$result) ; %}
+%typemap(scoerceout) SWIGTYPE *
+  %{ $result <- new("$R_class", ref=$result) ; %}
  
- %typemap(scoerceout) SWIGTYPE *const
- %{ $result <- new("$R_class", ref=$result) ; %}
+%typemap(scoerceout) SWIGTYPE *const
+  %{ $result <- new("$R_class", ref=$result) ; %}
 
 
 /* Override the SWIGTYPE * above. */
diff --git a/Lib/ruby/Makefile.swig b/Lib/ruby/Makefile.swig
index a7f3ae3..648b321 100644
--- a/Lib/ruby/Makefile.swig
+++ b/Lib/ruby/Makefile.swig
@@ -7,7 +7,7 @@
 # 3.  Type 'make -f Makefile.swig' to generate wrapper code and Makefile.
 # 4.  Type 'make' to build your extension.
 # 5.  Type 'make install' to install your extension.
-# 
+#
 
 MODULE    = yourmodule
 FEATURE   = $(MODULE)
diff --git a/Lib/ruby/file.i b/Lib/ruby/file.i
index d64937e..f9aaa27 100644
--- a/Lib/ruby/file.i
+++ b/Lib/ruby/file.i
@@ -4,7 +4,7 @@
 extern "C" {
 #endif
 
-// Ruby 1.9 changed the file name of this header
+/* Ruby 1.9 changed the file name of this header */
 #ifdef HAVE_RUBY_IO_H
 #include "ruby/io.h"
 #else
diff --git a/Lib/ruby/rubyclasses.swg b/Lib/ruby/rubyclasses.swg
index 5537136..f7b51bd 100644
--- a/Lib/ruby/rubyclasses.swg
+++ b/Lib/ruby/rubyclasses.swg
@@ -37,9 +37,6 @@
 %fragment("GC_VALUE_definition","header") {
 namespace swig {
   class SwigGCReferences {
-    // Hash of all GC_VALUE's currently in use
-    static SwigGCReferences s_references;
-
     VALUE _hash;
 
     SwigGCReferences() : _hash(Qnil) {
@@ -50,13 +47,18 @@
     }
     static void EndProcHandler(VALUE) {
       // Ruby interpreter ending - _hash can no longer be accessed.
+      SwigGCReferences &s_references = instance();
       s_references._hash = Qnil;
     }
   public:
     static SwigGCReferences& instance() {
+      // Hash of all GC_VALUE's currently in use
+      static SwigGCReferences s_references;
+
       return s_references;
     }
     static void initialize() {
+      SwigGCReferences &s_references = instance();
       if (s_references._hash == Qnil) {
         rb_set_end_proc(&EndProcHandler, Qnil);
         s_references._hash = rb_hash_new();
@@ -81,13 +83,13 @@
       if (BUILTIN_TYPE(obj) == T_NONE)
         return;
       if (_hash != Qnil) {
-        VALUE val = rb_hash_aref(s_references._hash, obj);
+        VALUE val = rb_hash_aref(_hash, obj);
         unsigned n = FIXNUM_P(val) ? NUM2UINT(val) : 1;
         --n;
         if (n)
-          rb_hash_aset(s_references._hash, obj, INT2NUM(n));
+          rb_hash_aset(_hash, obj, INT2NUM(n));
         else
-          rb_hash_delete(s_references._hash, obj);
+          rb_hash_delete(_hash, obj);
       }
     }
   };
@@ -302,8 +304,6 @@
   ID  GC_VALUE::lshift_id = rb_intern("<<");
   ID  GC_VALUE::rshift_id = rb_intern(">>");
 
-  SwigGCReferences SwigGCReferences::s_references;
-
   typedef GC_VALUE LANGUAGE_OBJ;
 
 } // namespace swig
diff --git a/Lib/std/std_ios.i b/Lib/std/std_ios.i
index 75484f3..db83c7a 100644
--- a/Lib/std/std_ios.i
+++ b/Lib/std/std_ios.i
@@ -242,17 +242,19 @@
     // 27.4.5.1  basic_ios constructors
     basic_ios();
   private:
-    ios_base(const ios_base&);
+    basic_ios(const basic_ios&);
 
-    ios_base& 
-    operator=(const ios_base&);
+    basic_ios&
+    operator=(const basic_ios&);
   };
   
 }
 
 namespace std {
+  typedef basic_ios<char> ios;
   %template(ios) basic_ios<char>;
 #if defined(SWIG_WCHAR)
+ typedef basic_ios<wchar_t> wios;
   %template(wios) basic_ios<wchar_t>;
 #endif
 }
diff --git a/Lib/tcl/Makefile.in b/Lib/tcl/Makefile.in
index 2ab0f7b..13d7d46 100644
--- a/Lib/tcl/Makefile.in
+++ b/Lib/tcl/Makefile.in
@@ -1,10 +1,10 @@
 # ---------------------------------------------------------------
 # SWIG Tcl Makefile
-# 
+#
 # This file can be used to build various Tcl extensions with SWIG.
 # By default this file is set up for dynamic loading, but it can
 # be easily customized for static extensions by modifying various
-# portions of the file.  
+# portions of the file.
 #
 #        SRCS       = C source files
 #        CXXSRCS    = C++ source files
@@ -19,11 +19,11 @@
 # application.
 #----------------------------------------------------------------
 
-SRCS          = 
-CXXSRCS       = 
-OBJCSRCS      = 
-OBJS          = 
-INTERFACE     = 
+SRCS          =
+CXXSRCS       =
+OBJCSRCS      =
+OBJS          =
+INTERFACE     =
 WRAPFILE      = $(INTERFACE:.i=_wrap.c)
 WRAPOBJ       = $(INTERFACE:.i=_wrap.o)
 TARGET        = module@SO@ # Use this kind of target for dynamic loading
@@ -34,8 +34,8 @@
 
 CC            = @CC@
 CXX           = @CXX@
-OBJC          = @CC@ -Wno-import # -Wno-import needed for gcc 
-CFLAGS        = 
+OBJC          = @CC@ -Wno-import # -Wno-import needed for gcc
+CFLAGS        =
 INCLUDES      =
 LIBS          =
 
@@ -44,9 +44,9 @@
 #     SWIGOPT   = SWIG compiler options
 #     SWIGCC    = Compiler used to compile the wrapper file
 
-SWIG          = $(exec_prefix)/bin/swig 
+SWIG          = $(exec_prefix)/bin/swig
 SWIGOPT       = -tcl # use -tcl8 for Tcl 8.0
-SWIGCC        = $(CC) 
+SWIGCC        = $(CC)
 
 # SWIG Library files.  Uncomment if rebuilding tclsh
 #SWIGLIBS      = -ltclsh.i
@@ -69,7 +69,7 @@
 # need to provide additional link libraries (this is not always required).
 
 #DLL_LIBS      = -L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-             -L/usr/local/lib -lg++ -lstdc++ -lgcc
+	     -L/usr/local/lib -lg++ -lstdc++ -lgcc
 
 # Tcl installation (where is Tcl located)
 
@@ -85,7 +85,7 @@
 # Build options (uncomment only one of these)
 
 BUILD_LIBS    = $(LIBS) # Dynamic loading
-#BUILD_LIBS    = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh  
+#BUILD_LIBS    = $(TCL_LIB) -ltcl $(LIBS) $(SYSLIBS) # tclsh
 
 # Compilation rules for non-SWIG components
 
@@ -110,7 +110,7 @@
 # Convert the wrapper file into an object file
 
 $(WRAPOBJ) : $(WRAPFILE)
-	$(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(TCL_INCLUDE) 
+	$(SWIGCC) -c $(CCSHARED) $(CFLAGS) $(WRAPFILE) $(INCLUDES) $(TCL_INCLUDE)
 
 $(WRAPFILE) : $(INTERFACE)
 	$(SWIG) $(SWIGOPT) -o $(WRAPFILE) $(SWIGLIBS) $(INTERFACE)
@@ -120,7 +120,3 @@
 
 clean:
 	rm -f $(COBJS) $(CXXOBJS) $(OBJCOBJS) $(WRAPOBJ) $(WRAPFILE) $(TARGET)
-
-
-
-
diff --git a/Lib/tcl/std_map.i b/Lib/tcl/std_map.i
index 78f6e32..ade2b0a 100644
--- a/Lib/tcl/std_map.i
+++ b/Lib/tcl/std_map.i
@@ -1,7 +1,5 @@
 //
 // SWIG typemaps for std::map
-// Luigi Ballabio
-// Jan. 2003
 //
 // Common implementation
 
diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg
index f06c8c0..9881139 100644
--- a/Lib/typemaps/attribute.swg
+++ b/Lib/typemaps/attribute.swg
@@ -137,7 +137,7 @@
 
 //
 // Define SWIG_ATTRIBUTE_TEMPLATE if you want to use templates instead of macros for the C++ get and set wrapper methods
-// Does not always generate compileable code, use at your peril!
+// Does not always generate compilable code, use at your peril!
 //
 //#define SWIG_ATTRIBUTE_TEMPLATE
 
diff --git a/Makefile.in b/Makefile.in
index f4d0be0..bb0845f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -100,7 +100,7 @@
 ACTION = check
 NOSKIP =
 
-chk-set-swiglib		= SWIG_LIB=@ROOT_DIR@/Lib
+chk-set-swiglib		= SWIG_LIB=@ROOT_DIR@/$(srcdir)/Lib
 chk-set-swig		= SWIG=@ROOT_DIR@/$(TARGET)
 chk-set-env = $(chk-set-swiglib) $(chk-set-swig)
 
@@ -243,16 +243,18 @@
 
 # individual example
 %.actionexample:
+	@cd Examples && $(MAKE) Makefile
 	@echo $(ACTION)ing Examples/$(LANGUAGE)/$*
 	@(cd Examples/$(LANGUAGE)/$* && $(MAKE) $(FLAGS) $(chk-set-env) $(ACTION) RUNPIPE=$(RUNPIPE))
 
 # gcj individual example
 java.actionexample:
+	@cd Examples && $(MAKE) Makefile
 	@if $(skip-gcj); then					\
-          echo "skipping Examples/$(LANGUAGE)/java $(ACTION) (gcj test)";	\
-        else							\
+	  echo "skipping Examples/$(LANGUAGE)/java $(ACTION) (gcj test)";	\
+	else							\
 	  echo $(ACTION)ing Examples/$(LANGUAGE)/java;		\
-	  (cd Examples/$(LANGUAGE)/java && $(MAKE) $(FLAGS) $(chk-set-env) $(ACTION)) \
+	  (cd Examples/$(LANGUAGE)/java && $(MAKE) $(FLAGS) $(chk-set-env) $(ACTION) RUNPIPE=$(RUNPIPE)) \
 	fi
 
 # Checks testcases in the test-suite excluding those which are known to be broken
@@ -401,7 +403,7 @@
 
 DISTCLEAN-DEAD = config.status config.log config.cache swig.spec Makefile mkmf.log libtool preinst-swig
 
-distclean-helper: distclean-test-suite distclean-examples distclean-dead
+distclean-helper: distclean-test-suite distclean-examples distclean-tools distclean-dead
 
 distclean: distclean-source distclean-ccache distclean-helper
 
@@ -418,10 +420,19 @@
 	@echo distcleaning Examples
 	@$(MAKE) $(FLAGS) clean-examples
 	@cd Examples && $(MAKE) $(FLAGS) distclean
+	@if test "x$(srcdir)" != "x."; then \
+		for mkfile in `cd $(srcdir) && find Examples/ -type f -name Makefile`; do \
+			rm -f "$$mkfile"; \
+		done; \
+	fi
 
 distclean-ccache:
 	@test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) $(FLAGS) distclean)
 
+distclean-tools:
+	@echo distcleaning Tools
+	@cd Tools/javascript && $(MAKE) $(FLAGS) distclean
+
 distclean-dead:
 	rm -f $(DISTCLEAN-DEAD)
 	rm -rf autom4te.cache
@@ -438,12 +449,22 @@
 	@echo maintainer-cleaning CCache
 	@test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) $(FLAGS) maintainer-clean)
 	@echo maintainer-cleaning docs
-	@cd $(DOCS) && $(MAKE) $(FLAGS) maintainer-clean
+	@test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) $(FLAGS) maintainer-clean
 	@echo maintainer-cleaning Lib files
 	@rm -f $(srcdir)/Lib/swigwarn.swg
 	@echo distcleaning
 	@$(MAKE) $(FLAGS) distclean-helper
 
+check-maintainer-clean: maintainer-clean
+	@if test "x$(srcdir)" = "x."; then \
+		echo "skipping maintainer-clean check (in-source-tree build)"; \
+		exit 0; \
+	fi; \
+	for file in `find . -type f`; do \
+		echo "file missed by maintainer-clean: $$file"; \
+	done; \
+	test "x$$file" = x && echo "all files cleaned by maintainer-clean"
+
 #####################################################################
 # Update the Lib/swigwarn.swg file
 # Note: Generated into the source tree rather than build tree
@@ -481,13 +502,13 @@
 lib-modules = std
 
 
-install-lib: 
+install-lib:
 	@echo "Installing the SWIG library"
 	@$(MKINSTDIRS) $(DESTDIR)$(SWIG_LIB)
 	@for file in $(srcdir)/Lib/*.i $(srcdir)/Lib/*.swg ; do \
 	    i=`basename $$file` ;				\
 	    echo "Installing $(DESTDIR)$(SWIG_LIB)/$$i";	\
-            $(INSTALL_DATA) $$file $(DESTDIR)$(SWIG_LIB)/$$i;	\
+	    $(INSTALL_DATA) $$file $(DESTDIR)$(SWIG_LIB)/$$i;	\
 	    done;
 	@for lang in $(lib-languages) $(lib-modules);		\
 	    do							\
diff --git a/README b/README
index 46497c1..969ee4e 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 SWIG (Simplified Wrapper and Interface Generator)
 
-Version: 3.0.1 (in progress)
+Version: 3.0.4 (14 Jan 2015)
 
 Tagline: SWIG is a compiler that integrates C and C++ with languages
          including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua,
diff --git a/RELEASENOTES b/RELEASENOTES
index 949f58e..2aff1d2 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -4,6 +4,26 @@
 
 Release Notes
 =============
+SWIG-3.0.4 summary:
+- Python regression fix when wrapping C++ default arguments.
+- Improved error messages.
+
+SWIG-3.0.3 summary:
+- Add support for C++11 strongly typed enumerations.
+- Numerous bug fixes and minor enhancements for C#, D, Go, Java,
+  Javascript, PHP, Perl and Python wrappers.
+
+SWIG-3.0.2 summary:
+- Bug fix during install and a couple of other minor changes.
+
+SWIG-3.0.1 summary:
+- Javascript module added. This supports JavascriptCore (Safari/Webkit),
+  v8 (Chromium) and node.js currently.
+- A few notable regressions introduced in 3.0.0 have been fixed - in 
+  Lua, nested classes and parsing of operator <<.
+- The usual round of bug fixes and minor improvements for:
+  C#, GCJ, Go, Java, Lua, PHP and Python.
+
 SWIG-3.0.0 summary:
 - This is a major new release focusing primarily on C++ improvements.
 - C++11 support added. Please see documentation for details of supported
diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h
index 6d7342a..84a486f 100644
--- a/Source/CParse/cparse.h
+++ b/Source/CParse/cparse.h
@@ -27,6 +27,7 @@
   extern int cparse_cplusplus;
   extern int cparse_cplusplusout;
   extern int cparse_start_line;
+  extern String *cparse_unknown_directive;
 
   extern void Swig_cparse_cplusplus(int);
   extern void Swig_cparse_cplusplusout(int);
@@ -59,7 +60,7 @@
   extern void cparse_normalize_void(Node *);
   extern Parm *Swig_cparse_parm(String *s);
   extern ParmList *Swig_cparse_parms(String *s, Node *file_line_node);
-
+  extern Node *new_node(const_String_or_char_ptr tag);
 
 /* templ.c */
   extern int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *tscope);
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index de00e2b..d86c459 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -40,6 +40,9 @@
 /* Generate C++ compatible code when wrapping C code */
 int cparse_cplusplusout = 0;
 
+/* To allow better error reporting */
+String *cparse_unknown_directive = 0;
+
 /* Private vars */
 static int scan_init = 0;
 static int num_brace = 0;
@@ -147,7 +150,7 @@
  *  friend ostream& operator<<(ostream&, const char *s);
  *
  * or
- *  friend ostream& operator<<(ostream&, const char *s) { };
+ *  friend ostream& operator<<(ostream&, const char *s) { }
  *
  * ------------------------------------------------------------------------- */
 
@@ -801,8 +804,11 @@
       if (strcmp(yytext, "inline") == 0)
 	return (yylex());
 
-      /* SWIG directives */
     } else {
+      Delete(cparse_unknown_directive);
+      cparse_unknown_directive = NULL;
+
+      /* SWIG directives */
       if (strcmp(yytext, "%module") == 0)
 	return (MODULE);
       if (strcmp(yytext, "%insert") == 0)
@@ -878,6 +884,9 @@
       }
       if (strcmp(yytext, "%warn") == 0)
 	return (WARN);
+
+      /* Note down the apparently unknown directive for error reporting. */
+      cparse_unknown_directive = Swig_copy_string(yytext);
     }
     /* Have an unknown identifier, as a last step, we'll do a typedef lookup on it. */
 
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 7e7e563..1fb7590 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -41,7 +41,6 @@
 
 static Node    *top = 0;      /* Top of the generated parse tree */
 static int      unnamed = 0;  /* Unnamed datatype counter */
-static Hash    *extendhash = 0;     /* Hash table of added methods */
 static Hash    *classes = 0;        /* Hash table of classes */
 static Hash    *classes_typedefs = 0; /* Hash table of typedef classes: typedef struct X {...} Y; */
 static Symtab  *prev_symtab = 0;
@@ -60,6 +59,7 @@
 static int      template_reduce = 0;
 static int      cparse_externc = 0;
 int		ignore_nested_classes = 0;
+int		kwargs_supported = 0;
 /* -----------------------------------------------------------------------------
  *                            Assist Functions
  * ----------------------------------------------------------------------------- */
@@ -71,14 +71,6 @@
   (void)e;
 }
 
-static Node *new_node(const_String_or_char_ptr tag) {
-  Node *n = NewHash();
-  set_nodeType(n,tag);
-  Setfile(n,cparse_file);
-  Setline(n,cparse_line);
-  return n;
-}
-
 /* Copies a node.  Does not copy tree links or symbol table data (except for
    sym:name) */
 
@@ -650,106 +642,6 @@
   }
 }
 
-/* Extension merge.  This function is used to handle the %extend directive
-   when it appears before a class definition.   To handle this, the %extend
-   actually needs to take precedence.  Therefore, we will selectively nuke symbols
-   from the current symbol table, replacing them with the added methods */
-
-static void merge_extensions(Node *cls, Node *am) {
-  Node *n;
-  Node *csym;
-
-  n = firstChild(am);
-  while (n) {
-    String *symname;
-    if (Strcmp(nodeType(n),"constructor") == 0) {
-      symname = Getattr(n,"sym:name");
-      if (symname) {
-	if (Strcmp(symname,Getattr(n,"name")) == 0) {
-	  /* If the name and the sym:name of a constructor are the same,
-             then it hasn't been renamed.  However---the name of the class
-             itself might have been renamed so we need to do a consistency
-             check here */
-	  if (Getattr(cls,"sym:name")) {
-	    Setattr(n,"sym:name", Getattr(cls,"sym:name"));
-	  }
-	}
-      } 
-    }
-
-    symname = Getattr(n,"sym:name");
-    DohIncref(symname);
-    if ((symname) && (!Getattr(n,"error"))) {
-      /* Remove node from its symbol table */
-      Swig_symbol_remove(n);
-      csym = Swig_symbol_add(symname,n);
-      if (csym != n) {
-	/* Conflict with previous definition.  Nuke previous definition */
-	String *e = NewStringEmpty();
-	String *en = NewStringEmpty();
-	String *ec = NewStringEmpty();
-	Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname);
-	Printf(en,"%%extend definition of '%s'.",symname);
-	SWIG_WARN_NODE_BEGIN(n);
-	Swig_warning(WARN_PARSE_REDEFINED,Getfile(csym),Getline(csym),"%s\n",ec);
-	Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en);
-	SWIG_WARN_NODE_END(n);
-	Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(csym),Getline(csym),ec, 
-	       Getfile(n),Getline(n),en);
-	Setattr(csym,"error",e);
-	Delete(e);
-	Delete(en);
-	Delete(ec);
-	Swig_symbol_remove(csym);              /* Remove class definition */
-	Swig_symbol_add(symname,n);            /* Insert extend definition */
-      }
-    }
-    n = nextSibling(n);
-  }
-}
-
-static void append_previous_extension(Node *cls, Node *am) {
-  Node *n, *ne;
-  Node *pe = 0;
-  Node *ae = 0;
-
-  if (!am) return;
-  
-  n = firstChild(am);
-  while (n) {
-    ne = nextSibling(n);
-    set_nextSibling(n,0);
-    /* typemaps and fragments need to be prepended */
-    if (((Cmp(nodeType(n),"typemap") == 0) || (Cmp(nodeType(n),"fragment") == 0)))  {
-      if (!pe) pe = new_node("extend");
-      appendChild(pe, n);
-    } else {
-      if (!ae) ae = new_node("extend");
-      appendChild(ae, n);
-    }    
-    n = ne;
-  }
-  if (pe) prependChild(cls,pe);
-  if (ae) appendChild(cls,ae);
-}
- 
-
-/* Check for unused %extend.  Special case, don't report unused
-   extensions for templates */
- 
-static void check_extensions() {
-  Iterator ki;
-
-  if (!extendhash) return;
-  for (ki = First(extendhash); ki.key; ki = Next(ki)) {
-    if (!Strchr(ki.key,'<')) {
-      SWIG_WARN_NODE_BEGIN(ki.item);
-      Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", SwigType_namestr(ki.key));
-      SWIG_WARN_NODE_END(ki.item);
-    }
-  }
-}
-
 /* Check a set of declarations to see if any are pure-abstract */
 
 static List *pure_abstracts(Node *n) {
@@ -1126,7 +1018,7 @@
     }
   }
 
-  if (!GetFlag(currentOuterClass, "nested")) {
+  if (!currentOuterClass || !GetFlag(currentOuterClass, "nested")) {
     if (nn && Equal(nodeType(nn), "classforward")) {
       Node *n = nn;
       SWIG_WARN_NODE_BEGIN(n);
@@ -1286,7 +1178,7 @@
     if (compact_default_args 
 	|| is_cfunction(function) 
 	|| GetFlag(function,"feature:compactdefaultargs") 
-	|| GetFlag(function,"feature:kwargs")) {
+	|| (GetFlag(function,"feature:kwargs") && kwargs_supported)) {
       ParmList *p = Getattr(function,"parms");
       if (p) 
         Setattr(p,"compactdefargs", "1"); /* mark parameters for special handling */
@@ -1579,7 +1471,6 @@
 		     Setattr(module_node,"name",ModuleName);
 		   }
 		   Setattr($1,"module",module_node);
-		   check_extensions();
 	           top = $1;
                }
                | PARSETYPE parm SEMI {
@@ -1619,7 +1510,11 @@
                | SEMI { $$ = 0; }
                | error {
                   $$ = 0;
-		  Swig_error(cparse_file, cparse_line,"Syntax error in input(1).\n");
+		  if (cparse_unknown_directive) {
+		      Swig_error(cparse_file, cparse_line, "Unknown directive '%s'.\n", cparse_unknown_directive);
+		  } else {
+		      Swig_error(cparse_file, cparse_line, "Syntax error in input(1).\n");
+		  }
 		  exit(1);
                }
 /* Out of class constructor/destructor declarations */
@@ -1683,14 +1578,13 @@
 	       cplus_mode = CPLUS_PUBLIC;
 	       if (!classes) classes = NewHash();
 	       if (!classes_typedefs) classes_typedefs = NewHash();
-	       if (!extendhash) extendhash = NewHash();
 	       clsname = make_class_name($3);
 	       cls = Getattr(classes,clsname);
 	       if (!cls) {
 	         cls = Getattr(classes_typedefs, clsname);
 		 if (!cls) {
 		   /* No previous definition. Create a new scope */
-		   Node *am = Getattr(extendhash,clsname);
+		   Node *am = Getattr(Swig_extend_hash(),clsname);
 		   if (!am) {
 		     Swig_symbol_newscope();
 		     Swig_symbol_setscopename($3);
@@ -1736,13 +1630,13 @@
 		 appendChild(current_class,$$);
 	       } else {
 		 /* We store the extensions in the extensions hash */
-		 Node *am = Getattr(extendhash,clsname);
+		 Node *am = Getattr(Swig_extend_hash(),clsname);
 		 if (am) {
 		   /* Append the members to the previous extend methods */
 		   appendChild(am,$6);
 		 } else {
 		   appendChild($$,$6);
-		   Setattr(extendhash,clsname,$$);
+		   Setattr(Swig_extend_hash(),clsname,$$);
 		 }
 	       }
 	       current_class = 0;
@@ -1991,6 +1885,7 @@
 			   Node *nint = new_node("import");
 			   Node *mnode = new_node("module");
 			   Setattr(mnode,"name", mname);
+                           Setattr(mnode,"options",$2);
 			   appendChild(nint,mnode);
 			   Delete(mnode);
 			   appendChild(nint,firstChild($$));
@@ -2613,6 +2508,7 @@
 template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN valparms GREATERTHAN SEMI {
                   Parm *p, *tp;
 		  Node *n;
+		  Node *outer_class = currentOuterClass;
 		  Symtab *tscope = 0;
 		  int     specialized = 0;
 		  int     variadic = 0;
@@ -2625,6 +2521,9 @@
 		  if (!inclass) {
 		    $5 = resolve_create_node_scope($5);
 		  }
+		  if (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0) {
+		    outer_class	= nscope_inner;
+		  }
 
 		  /*
 		    We use the new namespace entry 'nscope' only to
@@ -2757,7 +2656,7 @@
                             Setattr(templnode,"sym:typename","1");
                           }
 			  /* for now, nested %template is allowed only in the same scope as the template declaration */
-                          if ($3 && !(nnisclass && ((currentOuterClass && (currentOuterClass != Getattr(nn, "nested:outer")))
+                          if ($3 && !(nnisclass && ((outer_class && (outer_class != Getattr(nn, "nested:outer")))
 			    ||(extendmode && current_class && (current_class != Getattr(nn, "nested:outer")))))) {
 			    /*
 			       Comment this out for 1.3.28. We need to
@@ -2786,9 +2685,9 @@
                           Setfile(templnode,cparse_file);
                           Setline(templnode,cparse_line);
                           Delete(temparms);
-			  if (currentOuterClass) {
+			  if (outer_class && nnisclass) {
 			    SetFlag(templnode, "nested");
-			    Setattr(templnode, "nested:outer", currentOuterClass);
+			    Setattr(templnode, "nested:outer", outer_class);
 			  }
                           add_symbols_copy(templnode);
 
@@ -2825,8 +2724,7 @@
 
 			    /* !!! This may be broken.  We may have to add the
 			       %extend methods at the beginning of the class */
-
-                            if (extendhash) {
+                            {
                               String *stmp = 0;
                               String *clsname;
                               Node *am;
@@ -2835,32 +2733,32 @@
                               } else {
                                 clsname = Getattr(templnode,"name");
                               }
-                              am = Getattr(extendhash,clsname);
+                              am = Getattr(Swig_extend_hash(),clsname);
                               if (am) {
                                 Symtab *st = Swig_symbol_current();
                                 Swig_symbol_setscope(Getattr(templnode,"symtab"));
                                 /*			    Printf(stdout,"%s: %s %p %p\n", Getattr(templnode,"name"), clsname, Swig_symbol_current(), Getattr(templnode,"symtab")); */
-                                merge_extensions(templnode,am);
+                                Swig_extend_merge(templnode,am);
                                 Swig_symbol_setscope(st);
-				append_previous_extension(templnode,am);
-                                Delattr(extendhash,clsname);
+				Swig_extend_append_previous(templnode,am);
+                                Delattr(Swig_extend_hash(),clsname);
                               }
 			      if (stmp) Delete(stmp);
                             }
-                            /* Add to classes hash */
-                            if (!classes) classes = NewHash();
 
-                            {
-                              if (Namespaceprefix) {
-                                String *temp = NewStringf("%s::%s", Namespaceprefix, Getattr(templnode,"name"));
-                                Setattr(classes,temp,templnode);
-				Delete(temp);
-                              } else {
-				String *qs = Swig_symbol_qualifiedscopename(templnode);
-                                Setattr(classes, qs,templnode);
-				Delete(qs);
-                              }
-                            }
+                            /* Add to classes hash */
+			    if (!classes)
+			      classes = NewHash();
+
+			    if (Namespaceprefix) {
+			      String *temp = NewStringf("%s::%s", Namespaceprefix, Getattr(templnode,"name"));
+			      Setattr(classes,temp,templnode);
+			      Delete(temp);
+			    } else {
+			      String *qs = Swig_symbol_qualifiedscopename(templnode);
+			      Setattr(classes, qs,templnode);
+			      Delete(qs);
+			    }
                           }
                         }
 
@@ -3126,6 +3024,15 @@
                    skip_balanced('{','}');
                    $$ = 0;
                }
+               | error {
+		   $$ = 0;
+		   if (yychar == RPAREN) {
+		       Swig_error(cparse_file, cparse_line, "Unexpected ')'.\n");
+		   } else {
+		       Swig_error(cparse_file, cparse_line, "Syntax error - possibly a missing semicolon.\n");
+		   }
+		   exit(1);
+               }
               ;
 
 initializer   : def_args { 
@@ -3515,6 +3422,9 @@
 		   } else {
 		     cplus_mode = CPLUS_PUBLIC;
 		   }
+		   if (!cparse_cplusplus) {
+		     set_scope_to_global();
+		   }
 		   Swig_symbol_newscope();
 		   Swig_symbol_setscopename($3);
 		   Swig_inherit_base_symbols(bases);
@@ -3558,8 +3468,14 @@
 		   nscope = Getattr($<node>$, "nested:nscope");
 		   Delattr($<node>$, "nested:innerscope");
 		   Delattr($<node>$, "nested:nscope");
-		   if (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0) /* actual parent class for this class */
-		     Setattr($$, "nested:outer", nscope_inner);
+		   if (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0) { /* actual parent class for this class */
+		     Node* forward_declaration = Swig_symbol_clookup_no_inherit(Getattr($<node>$,"name"), Getattr(nscope_inner, "symtab"));
+		     if (forward_declaration) {
+		       Setattr($<node>$, "access", Getattr(forward_declaration, "access"));
+		     }
+		     Setattr($<node>$, "nested:outer", nscope_inner);
+		     SetFlag($<node>$, "nested");
+                   }
 		   if (!currentOuterClass)
 		     inclass = 0;
 		   cscope = Getattr($$, "prev_symtab");
@@ -3569,13 +3485,12 @@
 		   Setattr($$,"abstracts", pure_abstracts($7));
 		   
 		   /* This bit of code merges in a previously defined %extend directive (if any) */
-		   
-		   if (extendhash) {
+		   {
 		     String *clsname = Swig_symbol_qualifiedscopename(0);
-		     am = Getattr(extendhash, clsname);
+		     am = Getattr(Swig_extend_hash(), clsname);
 		     if (am) {
-		       merge_extensions($$, am);
-		       Delattr(extendhash, clsname);
+		       Swig_extend_merge($$, am);
+		       Delattr(Swig_extend_hash(), clsname);
 		     }
 		     Delete(clsname);
 		   }
@@ -3586,7 +3501,7 @@
 		   appendChild($$, $7);
 		   
 		   if (am) 
-		     append_previous_extension($$, am);
+		     Swig_extend_append_previous($$, am);
 
 		   p = $9;
 		   if (p && !nscope_inner) {
@@ -3639,6 +3554,8 @@
 		   } else if (nscope_inner) {
 		     /* this is tricky */
 		     /* we add the declaration in the original namespace */
+		     if (Strcmp(nodeType(nscope_inner), "class") == 0 && cparse_cplusplus && ignore_nested_classes && !GetFlag($$, "feature:flatnested"))
+		       $$ = nested_forward_declaration($1, $2, $3, Copy($3), $9);
 		     appendChild(nscope_inner, $$);
 		     Swig_symbol_setscope(Getattr(nscope_inner, "symtab"));
 		     Delete(Namespaceprefix);
@@ -3785,15 +3702,16 @@
 		     n = nextSibling(n);
 		   }
 		   n = $8;
-		     /* Check for previous extensions */
-		   if (extendhash) {
+
+		   /* Check for previous extensions */
+		   {
 		     String *clsname = Swig_symbol_qualifiedscopename(0);
-		     Node *am = Getattr(extendhash,clsname);
+		     Node *am = Getattr(Swig_extend_hash(),clsname);
 		     if (am) {
-			 /* Merge the extension into the symbol table */
-		       merge_extensions($$,am);
-		       append_previous_extension($$,am);
-		       Delattr(extendhash,clsname);
+		       /* Merge the extension into the symbol table */
+		       Swig_extend_merge($$,am);
+		       Swig_extend_append_previous($$,am);
+		       Delattr(Swig_extend_hash(),clsname);
 		     }
 		     Delete(clsname);
 		   }
@@ -4116,7 +4034,9 @@
 			Swig_symbol_setscope(cscope);
 			Delete(Namespaceprefix);
 			Namespaceprefix = Swig_symbol_qualifiedscopename(0);
-			if (error) $$ = 0;
+			if (error || (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0)) {
+			  $$ = 0;
+			}
 			if (currentOuterClass)
 			  template_parameters = Getattr(currentOuterClass, "template_parameters");
 			else
@@ -4760,7 +4680,10 @@
                | FRIEND { $$ = "friend"; }
                | EXPLICIT { $$ = "explicit"; }
                | CONSTEXPR { $$ = "constexpr"; }
+               | EXPLICIT CONSTEXPR { $$ = "explicit constexpr"; }
+               | CONSTEXPR EXPLICIT { $$ = "explicit constexpr"; }
                | STATIC CONSTEXPR { $$ = "static constexpr"; }
+               | CONSTEXPR STATIC { $$ = "static constexpr"; }
                | THREAD_LOCAL { $$ = "thread_local"; }
                | THREAD_LOCAL STATIC { $$ = "static thread_local"; }
                | STATIC THREAD_LOCAL { $$ = "static thread_local"; }
diff --git a/Source/CParse/util.c b/Source/CParse/util.c
index 7572dff..320671d 100644
--- a/Source/CParse/util.c
+++ b/Source/CParse/util.c
@@ -88,3 +88,17 @@
     }
   }
 }
+
+/* -----------------------------------------------------------------------------
+ * new_node()
+ *
+ * Create an empty parse node, setting file and line number information
+ * ----------------------------------------------------------------------------- */
+
+Node *new_node(const_String_or_char_ptr tag) {
+  Node *n = NewHash();
+  set_nodeType(n,tag);
+  Setfile(n,cparse_file);
+  Setline(n,cparse_line);
+  return n;
+}
diff --git a/Source/DOH/string.c b/Source/DOH/string.c
index 50676c7..cfc6c70 100644
--- a/Source/DOH/string.c
+++ b/Source/DOH/string.c
@@ -181,10 +181,10 @@
     return s->hashkey;
   } else {
     register char *c = s->str;
-    register int len = s->len > 50 ? 50 : s->len;
-    register int h = 0;
-    register int mlen = len >> 2;
-    register int i = mlen;
+    register unsigned int len = s->len > 50 ? 50 : s->len;
+    register unsigned int h = 0;
+    register unsigned int mlen = len >> 2;
+    register unsigned int i = mlen;
     for (; i; --i) {
       h = (h << 5) + *(c++);
       h = (h << 5) + *(c++);
@@ -195,7 +195,7 @@
       h = (h << 5) + *(c++);
     }
     h &= 0x7fffffff;
-    s->hashkey = h;
+    s->hashkey = (int)h;
     return h;
   }
 }
@@ -1114,6 +1114,7 @@
   str->maxsize = max;
   if (s) {
     strncpy(str->str, s, len);
+    str->str[l] = 0;
     str->len = l;
     str->sp = l;
   } else {
diff --git a/Source/Makefile.am b/Source/Makefile.am
index 9e02e37..da65b23 100644
--- a/Source/Makefile.am
+++ b/Source/Makefile.am
@@ -77,6 +77,7 @@
 		Swig/cwrap.c			\
 		Swig/deprecate.c		\
 		Swig/error.c			\
+		Swig/extend.c			\
 		Swig/fragment.c			\
 		Swig/getopt.c			\
 		Swig/include.c			\
@@ -90,7 +91,7 @@
 		Swig/typeobj.c			\
 		Swig/typemap.c			\
 		Swig/typesys.c			\
-		Swig/wrapfunc.c			
+		Swig/wrapfunc.c
 
 bin_PROGRAMS = eswig
 eswig_LDADD   = @SWIGLIBS@
@@ -99,7 +100,7 @@
 CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 
 # The executable is copied to the root directory for installation and running the test-suite.
-# This occurs on each invocation of make and is a step towards providing support for multiple 
+# This occurs on each invocation of make and is a step towards providing support for multiple
 # build directories.
 all-local: eswig@EXEEXT@
 	cp -f $(top_builddir)/Source/eswig@EXEEXT@ $(top_builddir)/swig@EXEEXT@
@@ -145,4 +146,3 @@
 	indent -kr --honour-newlines --line-length160 --indent-level2 --braces-on-func-def-line --leave-optional-blank-lines $(SWIGTYPEDEFS) $(INDENTFILE) -o $(INDENTFILE).tmp;
 	cat $(INDENTFILE).tmp | sed -e 's/const const /const /' > $(INDENTFILE);
 	rm $(INDENTFILE).tmp;
-
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index d30bd18..3b1e035 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -627,9 +627,11 @@
    * ----------------------------------------------------------------------------- */
 
   void emitBanner(File *f) {
-    Printf(f, "/* ----------------------------------------------------------------------------\n");
-    Swig_banner_target_lang(f, " *");
-    Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
+    Printf(f, "//------------------------------------------------------------------------------\n");
+    Printf(f, "// <auto-generated />\n");
+    Printf(f, "//\n");
+    Swig_banner_target_lang(f, "//");
+    Printf(f, "//------------------------------------------------------------------------------\n\n");
   }
 
   /*-----------------------------------------------------------------------
@@ -717,7 +719,7 @@
     String *overloaded_name = getOverloadedName(n);
 
     if (!Getattr(n, "sym:overloaded")) {
-      if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name))
+      if (!addSymbol(symname, n, imclass_name))
 	return SWIG_ERROR;
     }
 
@@ -912,21 +914,10 @@
     String *null_attribute = 0;
     // Now write code to make the function call
     if (!native_function_flag) {
-      if (Cmp(nodeType(n), "constant") == 0) {
-        // Wrapping a constant hack
-        Swig_save("functionWrapper", n, "wrap:action", NIL);
-
-        // below based on Swig_VargetToFunction()
-        SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
-        Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
-      }
 
       Swig_director_emit_dynamic_cast(n, f);
       String *actioncode = emit_action(n);
 
-      if (Cmp(nodeType(n), "constant") == 0)
-        Swig_restore(n);
-
       /* Return value if necessary  */
       if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
 	canThrow(n, "out", n);
@@ -1088,15 +1079,13 @@
     return ret;
   }
   
-  String *getCurrentScopeName(String *nspace)
-  {
+  String *getCurrentScopeName(String *nspace) {
     String *scope = 0;
     if (nspace || getCurrentClass()) {
       scope = NewString("");
       if (nspace)
 	Printf(scope, "%s", nspace);
-      if (Node* cls = getCurrentClass())
-      {
+      if (Node* cls = getCurrentClass()) {
 	if (Node *outer = Getattr(cls, "nested:outer")) {
 	  String *outerClassesPrefix = Copy(Getattr(outer, "sym:name"));
 	  for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) {
@@ -1266,6 +1255,7 @@
     int unnamedinstance = GetFlag(parent, "unnamedinstance");
     String *parent_name = Getattr(parent, "name");
     String *nspace = getNSpace();
+    String *newsymname = 0;
     String *tmpValue;
 
     // Strange hack from parent method
@@ -1290,14 +1280,20 @@
     {
       EnumFeature enum_feature = decodeEnumFeature(parent);
 
+      if ((enum_feature == SimpleEnum) && GetFlag(parent, "scopedenum")) {
+	newsymname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
+	symname = newsymname;
+      }
+
       // Add to language symbol table
       String *scope = 0;
       if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) {
-	if (proxy_class_name) {
+	String *enumClassPrefix = getEnumClassPrefix();
+	if (enumClassPrefix) {
 	  scope = NewString("");
 	  if (nspace)
 	    Printf(scope, "%s.", nspace);
-	  Printf(scope, "%s", proxy_class_name);
+	  Printf(scope, "%s", enumClassPrefix);
 	} else {
 	  scope = Copy(module_class_name);
 	}
@@ -1308,7 +1304,7 @@
 	else
 	  Printf(scope, ".%s", Getattr(parent, "sym:name"));
       }
-      if (!addSymbol(name, n, scope))
+      if (!addSymbol(symname, n, scope))
 	return SWIG_ERROR;
 
       const String *csattributes = Getattr(n, "feature:cs:attributes");
@@ -1380,6 +1376,7 @@
       Delete(scope);
     }
 
+    Delete(newsymname);
     Delete(tmpValue);
     Swig_restore(n);
     return SWIG_OK;
@@ -3053,6 +3050,16 @@
 	// Use the C syntax to make a true C# constant and hope that it compiles as C# code
 	value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex"));
       } else {
+	String *newsymname = 0;
+	if (!getCurrentClass() || !proxy_flag) {
+	  String *enumClassPrefix = getEnumClassPrefix();
+	  if (enumClassPrefix) {
+	    // A global scoped enum
+	    newsymname = Swig_name_member(0, enumClassPrefix, symname);
+	    symname = newsymname;
+	  }
+	}
+
 	// Get the enumvalue from a PINVOKE call
 	if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) {
 	  // Strange hack to change the name
@@ -3061,7 +3068,7 @@
 	  value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
 	} else {
 	  memberconstantHandler(n);
-	  value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname)));
+	  value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, getEnumClassPrefix(), symname)));
 	}
       }
     }
@@ -3199,43 +3206,6 @@
   }
 
   /* -----------------------------------------------------------------------------
-   * makeParameterName()
-   *
-   * Inputs: 
-   *   n - Node
-   *   p - parameter node
-   *   arg_num - parameter argument number
-   *   setter  - set this flag when wrapping variables
-   * Return:
-   *   arg - a unique parameter name
-   * ----------------------------------------------------------------------------- */
-
-  String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) {
-
-    String *arg = 0;
-    String *pn = Getattr(p, "name");
-
-    // Use C parameter name unless it is a duplicate or an empty parameter name
-    int count = 0;
-    ParmList *plist = Getattr(n, "parms");
-    while (plist) {
-      if ((Cmp(pn, Getattr(plist, "name")) == 0))
-        count++;
-      plist = nextSibling(plist);
-    }
-    String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
-    arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
-
-    if (setter && Cmp(arg, "self") != 0) {
-      // Note that in C# properties, the input variable name is always called 'value'
-      Delete(arg);      
-      arg = NewString("value");
-    }
-
-    return arg;
-  }
-
-  /* -----------------------------------------------------------------------------
    * emitTypeWrapperClass()
    * ----------------------------------------------------------------------------- */
 
@@ -4283,6 +4253,10 @@
     Delete(dirclassname);
   }
 
+  /*----------------------------------------------------------------------
+   * nestedClassesSupport()
+   *--------------------------------------------------------------------*/
+
   NestedClassSupport nestedClassesSupport() const {
     return NCS_Full;
   }
diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx
index 419828e..8546372 100644
--- a/Source/Modules/d.cxx
+++ b/Source/Modules/d.cxx
@@ -803,24 +803,24 @@
     // Emit each enum item.
     Language::enumDeclaration(n);
 
-    if (!GetFlag(n, "nonempty")) {
-      // Do not wrap empty enums; the resulting D code would be illegal.
-      Delete(proxy_enum_code);
-      return SWIG_NOWRAP;
-    }
-
-    // Finish the enum.
-    if (typemap_lookup_type) {
-      Printv(proxy_enum_code,
-	lookupCodeTypemap(n, "dcode", typemap_lookup_type, WARN_NONE), // Extra D code
-	"\n}\n", NIL);
+    if (GetFlag(n, "nonempty")) {
+      // Finish the enum.
+      if (typemap_lookup_type) {
+	Printv(proxy_enum_code,
+	  lookupCodeTypemap(n, "dcode", typemap_lookup_type, WARN_NONE), // Extra D code
+	  "\n}\n", NIL);
+      } else {
+	// Handle anonymous enums.
+	Printv(proxy_enum_code, "\n}\n", NIL);
+      }
+      Replaceall(proxy_enum_code, "$dclassname", symname);
     } else {
-      // Handle anonymous enums.
-      Printv(proxy_enum_code, "\n}\n", NIL);
+      // D enum declarations must have at least one member to be legal, so emit
+      // an alias to int instead (their ctype/imtype is always int).
+      Delete(proxy_enum_code);
+      proxy_enum_code = NewStringf("\nalias int %s;\n", symname);
     }
 
-    Replaceall(proxy_enum_code, "$dclassname", symname);
-
     const String* imports =
       lookupCodeTypemap(n, "dimports", typemap_lookup_type, WARN_NONE);
     String* imports_trimmed;
@@ -1701,21 +1701,10 @@
     String *null_attribute = 0;
     // Now write code to make the function call
     if (!native_function_flag) {
-      if (Cmp(nodeType(n), "constant") == 0) {
-	// Wrapping a constant hack
-	Swig_save("functionWrapper", n, "wrap:action", NIL);
-
-	// below based on Swig_VargetToFunction()
-	SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
-	Setattr(n, "wrap:action", NewStringf("%s = (%s) %s;", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
-      }
 
       Swig_director_emit_dynamic_cast(n, f);
       String *actioncode = emit_action(n);
 
-      if (Cmp(nodeType(n), "constant") == 0)
-	Swig_restore(n);
-
       /* Return value if necessary  */
       if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
 	canThrow(n, "out", n);
@@ -2594,7 +2583,7 @@
     const_String_or_char_ptr wrapper_function_name) {
 
     // TODO: Add support for static linking here.
-    Printf(im_dmodule_code, "extern(C) %s function%s %s;\n", return_type,
+    Printf(im_dmodule_code, "SwigExternC!(%s function%s) %s;\n", return_type,
       parameters, d_name);
     Printv(wrapper_loader_bind_code, wrapper_loader_bind_command, NIL);
     Replaceall(wrapper_loader_bind_code, "$function", d_name);
@@ -2850,7 +2839,7 @@
       // polymorphic call or an explicit method call. Needed to prevent infinite
       // recursion when calling director methods.
       Node *explicit_n = Getattr(n, "explicitcallnode");
-      if (explicit_n) {
+      if (explicit_n && Swig_directorclass(getCurrentClass())) {
 	String *ex_overloaded_name = getOverloadedName(explicit_n);
 	String *ex_intermediary_function_name = Swig_name_member(getNSpace(), proxy_class_name, ex_overloaded_name);
 
@@ -4299,40 +4288,8 @@
     return proxyname;
   }
 
-  /* ---------------------------------------------------------------------------
-   * D::makeParameterName()
-   *
-   * Inputs:
-   *   n - Node
-   *   p - parameter node
-   *   arg_num - parameter argument number
-   *   setter  - set this flag when wrapping variables
-   * Return:
-   *   arg - a unique parameter name
-   * --------------------------------------------------------------------------- */
   String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) const {
-    String *arg = 0;
-    String *pn = Getattr(p, "name");
-
-    // Use C parameter name unless it is a duplicate or an empty parameter name
-    int count = 0;
-    ParmList *plist = Getattr(n, "parms");
-    while (plist) {
-      if ((Cmp(pn, Getattr(plist, "name")) == 0))
-	count++;
-      plist = nextSibling(plist);
-    }
-    String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
-    arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
-
-    if (setter && Cmp(arg, "self") != 0) {
-      // In theory, we could use the normal parameter name for setter functions.
-      // Unfortunately, it is set to "Class::VariableName" for static public
-      // members by the parser, which is not legal D syntax. Thus, we just force
-      // it to "value".
-      Delete(arg);
-      arg = NewString("value");
-    }
+    String *arg = Language::makeParameterName(n, p, arg_num, setter);
 
     if (split_proxy_dmodule && Strncmp(arg, package, Len(arg)) == 0) {
       // If we are in split proxy mode and the argument is named like the target
diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
index e84109f..eac83a5 100644
--- a/Source/Modules/go.cxx
+++ b/Source/Modules/go.cxx
@@ -822,14 +822,13 @@
 
     assert(result);
 
-    bool needs_wrapper;
-    int r = goFunctionWrapper(n, name, go_name, overname, wname, base, parms, result, is_static, &needs_wrapper);
+    int r = goFunctionWrapper(n, name, go_name, overname, wname, base, parms, result, is_static);
     if (r != SWIG_OK) {
       return r;
     }
 
     if (!gccgo_flag) {
-      r = gcFunctionWrapper(n, name, go_name, overname, wname, parms, result, is_static, needs_wrapper);
+      r = gcFunctionWrapper(wname);
       if (r != SWIG_OK) {
 	return r;
       }
@@ -862,12 +861,24 @@
    * base class.
    * ---------------------------------------------------------------------- */
 
-  int goFunctionWrapper(Node *n, String *name, String *go_name, String *overname, String *wname, List *base, ParmList *parms, SwigType *result, bool is_static, bool *p_needs_wrapper) {
+  int goFunctionWrapper(Node *n, String *name, String *go_name, String *overname, String *wname, List *base, ParmList *parms, SwigType *result, bool is_static) {
     Wrapper *dummy = NewWrapper();
     emit_attach_parmmaps(parms, dummy);
+
+    Parm *p = parms;
+    int parm_count = emit_num_arguments(parms);
+    for (int i = 0; i < parm_count; ++i) {
+      p = getParm(p);
+      Swig_cparm_name(p, i);
+      p = nextParm(p);
+    }
+
     Swig_typemap_attach_parms("default", parms, dummy);
     Swig_typemap_attach_parms("gotype", parms, dummy);
-    int parm_count = emit_num_arguments(parms);
+    Swig_typemap_attach_parms("goin", parms, dummy);
+    Swig_typemap_attach_parms("goargout", parms, dummy);
+    Swig_typemap_attach_parms("imtype", parms, dummy);
+
     int required_count = emit_num_required(parms);
 
     String *receiver = class_receiver;
@@ -884,30 +895,44 @@
       receiver = NULL;
     }
 
+    String *goout = Swig_typemap_lookup("goout", n, "swig_r", NULL);
+
     bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !overname && checkFunctionVisibility(n, NULL));
 
     bool needs_wrapper = (gccgo_flag || receiver || is_constructor || is_destructor || parm_count > required_count);
 
-    // See whether any of the function parameters are represented by
-    // interface values When calling the C++ code, we need to convert
-    // back to a uintptr.
-    if (!needs_wrapper) {
-      Parm *p = parms;
-      for (int i = 0; i < parm_count; ++i) {
-	p = getParm(p);
-	String *ty = Getattr(p, "type");
-	if (goTypeIsInterface(p, ty)) {
-	  needs_wrapper = true;
-	  break;
-	}
-	p = nextParm(p);
-      }
+    bool has_goout = false;
+    if (goout) {
+      has_goout = true;
     }
-    if (goTypeIsInterface(n, result)) {
+
+    // See whether any of the function parameters are represented by
+    // interface values.  When calling the C++ code, we need to convert
+    // back to a uintptr.
+    p = parms;
+    for (int i = 0; i < parm_count; ++i) {
+      p = getParm(p);
+      String *ty = Getattr(p, "type");
+      if (Getattr(p, "tmap:goargout")) {
+	has_goout = true;
+	needs_wrapper = true;
+      } else if (goTypeIsInterface(p, ty) || Getattr(p, "tmap:goin")) {
+	needs_wrapper = true;
+      }
+
+      if (paramNeedsEscape(p)) {
+	needs_wrapper = true;
+      }
+
+      p = nextParm(p);
+    }
+    if (goTypeIsInterface(n, result) || goout != NULL) {
       needs_wrapper = true;
     }
 
-    *p_needs_wrapper = needs_wrapper;
+    if (!gccgo_flag) {
+      Printv(f_go_wrappers, "var ", wname, " unsafe.Pointer\n\n", NULL);
+    }
 
     // If this is a method, first declare the C function we will call.
     // If we do not need a wrapper, then we will only be writing a
@@ -920,25 +945,25 @@
 	Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL);
       }
 
+      bool arg = false;
       Printv(f_go_wrappers, "func ", wrapper_name, "(", NULL);
       if (parm_count > required_count) {
-	Printv(f_go_wrappers, "int", NULL);
+	Printv(f_go_wrappers, argName(&arg), " int", NULL);
       }
       Parm *p = getParm(parms);
-      Swig_cparm_name(p, 0);
       int i = 0;
       if (is_destructor) {
 	if (parm_count > required_count) {
 	  Printv(f_go_wrappers, ", ", NULL);
 	}
-	Printv(f_go_wrappers, "uintptr", NULL);
+	Printv(f_go_wrappers, argName(&arg), " uintptr", NULL);
 	++i;
 	p = nextParm(p);
       } else if (receiver && (base || !is_constructor)) {
 	if (parm_count > required_count) {
 	  Printv(f_go_wrappers, ", ", NULL);
 	}
-	Printv(f_go_wrappers, receiver, NULL);
+	Printv(f_go_wrappers, argName(&arg), " ", receiver, NULL);
 	if (!base) {
 	  ++i;
 	  p = nextParm(p);
@@ -946,27 +971,37 @@
       }
       for (; i < parm_count; ++i) {
 	p = getParm(p);
-	// Give the parameter a name we will use below.
-	Swig_cparm_name(p, i);
 	if (i > 0 || (base && receiver) || parm_count > required_count) {
 	  Printv(f_go_wrappers, ", ", NULL);
 	}
 	String *tm = goWrapperType(p, Getattr(p, "type"), false);
-	Printv(f_go_wrappers, tm, NULL);
+	Printv(f_go_wrappers, argName(&arg), " ", tm, NULL);
 	Delete(tm);
 	p = nextParm(p);
       }
       Printv(f_go_wrappers, ")", NULL);
       if (is_constructor) {
-	Printv(f_go_wrappers, " ", class_receiver, NULL);
+	Printv(f_go_wrappers, " (", argName(&arg), " ", class_receiver, ")", NULL);
       } else {
 	if (SwigType_type(result) != T_VOID) {
 	  String *tm = goWrapperType(n, result, true);
-	  Printv(f_go_wrappers, " ", tm, NULL);
+	  Printv(f_go_wrappers, " (", argName(&arg), " ", tm, ")", NULL);
 	  Delete(tm);
 	}
       }
 
+      if (!gccgo_flag) {
+	Printv(f_go_wrappers, " {\n", NULL);
+	if (arg) {
+	  Printv(f_go_wrappers, "\t_swig_p := uintptr(unsafe.Pointer(&base))\n", NULL);
+	} else {
+	  Printv(f_go_wrappers, "\tvar _swig_p uintptr\n", NULL);
+	}
+	Printv(f_go_wrappers, "\t_cgo_runtime_cgocall(", wname, ", _swig_p)\n", NULL);
+	Printv(f_go_wrappers, "\treturn\n", NULL);
+	Printv(f_go_wrappers, "}", NULL);
+      }
+
       Printv(f_go_wrappers, "\n\n", NULL);
     }
 
@@ -978,16 +1013,23 @@
 
     Printv(f_go_wrappers, "func ", NULL);
 
-    Parm *p = parms;
+    p = parms;
     int pi = 0;
 
     // Add the receiver if this is a method.
+    String *first = NULL;
     if (receiver) {
       Printv(f_go_wrappers, "(", NULL);
       if (base && receiver) {
 	Printv(f_go_wrappers, "_swig_base", NULL);
+	if (first == NULL) {
+	  first = NewString("_swig_base");
+	}
       } else {
 	Printv(f_go_wrappers, Getattr(p, "lname"), NULL);
+	if (first == NULL) {
+	  first = Copy(Getattr(p, "lname"));
+	}
 	p = nextParm(p);
 	++pi;
       }
@@ -1015,6 +1057,9 @@
       if (pi == 0 && is_destructor) {
 	String *cl = exportedName(class_name);
 	Printv(parm_print, Getattr(p, "lname"), " ", cl, NULL);
+	if (first == NULL) {
+	  first = Copy(Getattr(p, "lname"));
+	}
 	Delete(cl);
       } else {
 	if (pi > (receiver && !base ? 1 : 0)) {
@@ -1022,10 +1067,14 @@
 	}
 	if (pi >= required_count) {
 	  Printv(parm_print, "_swig_args ...interface{}", NULL);
+	  if (first == NULL) {
+	    first = NewString("_swig_args");
+	  }
 	  break;
 	}
-	if (needs_wrapper) {
-	  Printv(parm_print, Getattr(p, "lname"), " ", NULL);
+	Printv(parm_print, Getattr(p, "lname"), " ", NULL);
+	if (first == NULL) {
+	  first = Copy(Getattr(p, "lname"));
 	}
 	String *tm = goType(p, Getattr(p, "type"));
 	Printv(parm_print, tm, NULL);
@@ -1039,12 +1088,18 @@
     // Write out the result type.
     if (is_constructor) {
       String *cl = exportedName(class_name);
-      Printv(parm_print, " ", cl, NULL);
+      Printv(parm_print, " (_swig_ret ", cl, ")", NULL);
+      if (first == NULL) {
+	first = NewString("_swig_ret");
+      }
       Delete(cl);
     } else {
       if (SwigType_type(result) != T_VOID) {
 	String *tm = goType(n, result);
-	Printv(parm_print, " ", tm, NULL);
+	Printv(parm_print, " (_swig_ret ", tm, ")", NULL);
+	if (first == NULL) {
+	  first = NewString("_swig_ret");
+	}
 	Delete(tm);
       }
     }
@@ -1077,46 +1132,49 @@
 	}
       }
 
+      String *call = NewString("");
+
+      bool need_return_var = SwigType_type(result) != T_VOID && ((gccgo_flag && is_constructor) || has_goout);
+      if (need_return_var) {
+	Printv(f_go_wrappers, "\tvar swig_r ", NULL);
+	if (is_constructor) {
+	  String *cl = exportedName(class_name);
+	  Printv(f_go_wrappers, cl, NULL);
+	  Delete(cl);
+	} else {
+	  Printv(f_go_wrappers, goImType(n, result), NULL);
+	}
+	Printv(f_go_wrappers, "\n", NULL);
+      }
+
       if (gccgo_flag) {
-	if (!is_constructor) {
-	  Printv(f_go_wrappers, "\tdefer SwigCgocallDone()\n", NULL);
-	  Printv(f_go_wrappers, "\tSwigCgocall()\n", NULL);
-	} else {
-	  // For a constructor the wrapper function will return a
-	  // uintptr but we will return an interface.  We want to
-	  // convert the uintptr to the interface after calling
-	  // SwigCgocallDone, so that we don't try to allocate memory
-	  // while the Go scheduler can't see us.
-	  Printv(f_go_wrappers, "\tvar done bool\n", NULL);
-	  Printv(f_go_wrappers, "\tdefer func() {\n", NULL);
-	  Printv(f_go_wrappers, "\t\tif !done {\n", NULL);
-	  Printv(f_go_wrappers, "\t\t\tSwigCgocallDone()\n", NULL);
-	  Printv(f_go_wrappers, "\t\t}\n", NULL);
-	  Printv(f_go_wrappers, "\t}()\n", NULL);
-	  Printv(f_go_wrappers, "\tSwigCgocall()\n", NULL);
+	if (has_goout || is_constructor) {
+	  Printv(call, "\tfunc() {\n", NULL);
 	}
+	Printv(call, "\tdefer SwigCgocallDone()\n", NULL);
+	Printv(call, "\tSwigCgocall()\n", NULL);
       }
 
-      Printv(f_go_wrappers, "\t", NULL);
+      Printv(call, "\t", NULL);
       if (SwigType_type(result) != T_VOID) {
-	if (gccgo_flag && is_constructor) {
-	  Printv(f_go_wrappers, "swig_r := ", NULL);
+	if (need_return_var) {
+	  Printv(call, "swig_r = ", NULL);
 	} else {
-	  Printv(f_go_wrappers, "return ", NULL);
+	  Printv(call, "return ", NULL);
 	}
       }
 
-      Printv(f_go_wrappers, wrapper_name, "(", NULL);
+      Printv(call, wrapper_name, "(", NULL);
 
       if (parm_count > required_count) {
-	Printv(f_go_wrappers, "len(_swig_args)", NULL);
+	Printv(call, "len(_swig_args)", NULL);
       }
 
       if (base && receiver) {
 	if (parm_count > required_count) {
-	  Printv(f_go_wrappers, ", ", NULL);
+	  Printv(call, ", ", NULL);
 	}
-	Printv(f_go_wrappers, "_swig_base", NULL);
+	Printv(call, "_swig_base", NULL);
       }
 
       Parm *p = parms;
@@ -1124,29 +1182,82 @@
 	p = getParm(p);
 	if (i > 0 || (base && receiver)
 	    || parm_count > required_count) {
-	  Printv(f_go_wrappers, ", ", NULL);
+	  Printv(call, ", ", NULL);
 	}
-	Printv(f_go_wrappers, Getattr(p, "lname"), NULL);
 
-	// If this is a destructor, then the C function expects the
-	// C++ value, and we have the interface.  We need to get the
-	// C++ value.  The same is true for a type represented as an
-	// interface.
-	if ((i == 0 && is_destructor) || ((i > 0 || !receiver || base || is_constructor) && goTypeIsInterface(p, Getattr(p, "type")))) {
-	  Printv(f_go_wrappers, ".Swigcptr()", NULL);
+	SwigType *pt = Getattr(p, "type");
+	String *ln = Getattr(p, "lname");
+
+	String *goin = Getattr(p, "tmap:goin");
+	if (goin == NULL) {
+	  Printv(call, ln, NULL);
+	  if ((i == 0 && is_destructor) || ((i > 0 || !receiver || base || is_constructor) && goTypeIsInterface(p, pt))) {
+	    Printv(call, ".Swigcptr()", NULL);
+	  }
+	  Setattr(p, "emit:goinput", ln);
+	} else {
+	  String *ivar = NewString("");
+	  Printf(ivar, "_swig_i_%d", i);
+	  String *itm = goImType(p, pt);
+	  Printv(f_go_wrappers, "\tvar ", ivar, " ", itm, NULL);
+	  goin = Copy(goin);
+	  Replaceall(goin, "$input", ln);
+	  Replaceall(goin, "$result", ivar);
+	  Printv(f_go_wrappers, goin, NULL);
+	  Delete(goin);
+	  Printv(call, ivar, NULL);
+	  Setattr(p, "emit:goinput", ivar);
+	}
+
+	// If the parameter has an argout or freearg typemap, make
+	// sure that it escapes.
+	if (paramNeedsEscape(p)) {
+	  Printv(f_go_wrappers, "\tif Swig_escape_always_false {\n", NULL);
+	  Printv(f_go_wrappers, "\t\tSwig_escape_val = ", Getattr(p, "emit:goinput"), "\n", NULL);
+	  Printv(f_go_wrappers, "\t}\n", NULL);
 	}
 
 	p = nextParm(p);
       }
-      Printv(f_go_wrappers, ")\n", NULL);
+      Printv(call, ")\n", NULL);
 
-      if (gccgo_flag && is_constructor) {
-	Printv(f_go_wrappers, "\tSwigCgocallDone()\n", NULL);
-	Printv(f_go_wrappers, "\tdone = true\n", NULL);
-	Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
+      if (gccgo_flag && (has_goout || is_constructor)) {
+	Printv(call, "\t}()\n", NULL);
+      }
+
+      Printv(f_go_wrappers, call, NULL);
+      Delete(call);
+
+      goargout(parms, parm_count);
+
+      if (need_return_var) {
+	if (goout == NULL) {
+	  Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
+	} else {
+	  String *tm = goType(n, result);
+	  Printv(f_go_wrappers, "\tvar swig_r_1 ", tm, "\n", NULL);
+	  Replaceall(goout, "$input", "swig_r");
+	  Replaceall(goout, "$result", "swig_r_1");
+	  Printv(f_go_wrappers, goout, NULL);
+	  Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
+	}
       }
 
       Printv(f_go_wrappers, "}\n", NULL);
+    } else if (!gccgo_flag) {
+      // We don't need a wrapper.  If we're using gccgo, the function
+      // declaration is all we need--it has a //extern comment to
+      // GCC-compiled wrapper.  If we're not using gccgo, we need to
+      // call the GCC-compiled wrapper here.
+      Printv(f_go_wrappers, " {\n", NULL);
+      if (first == NULL) {
+	Printv(f_go_wrappers, "\tvar _swig_p uintptr\n", NULL);
+      } else {
+	Printv(f_go_wrappers, "\t_swig_p := uintptr(unsafe.Pointer(&", first, "))\n", NULL);
+      }
+      Printv(f_go_wrappers, "\t_cgo_runtime_cgocall(", wname, ", _swig_p)\n", NULL);
+      Printv(f_go_wrappers, "\treturn\n", NULL);
+      Printv(f_go_wrappers, "}", NULL);
     }
 
     Printv(f_go_wrappers, "\n", NULL);
@@ -1158,118 +1269,72 @@
   }
 
   /* ----------------------------------------------------------------------
+   * argName()
+   *
+   * A helper for goFunctionWrapper to output the first argument name
+   * as "base" and all others as "_".
+   * ---------------------------------------------------------------------- */
+
+  const char *argName(bool *arg) {
+    if (*arg) {
+      return "_";
+    }
+    *arg = true;
+    return "base";
+  }
+
+  /* ----------------------------------------------------------------------
+   * paramNeedsEscape()
+   *
+   * A helper for goFunctionWrapper that returns whether a parameter
+   * needs to explicitly escape.  This is true if the parameter has a
+   * non-empty argout or freearg typemap, because in those cases the
+   * Go argument might be or contain a pointer.  We need to ensure
+   * that that pointer does not oint into the stack, which means that
+   * it needs to escape.
+   * ---------------------------------------------------------------------- */
+  bool paramNeedsEscape(Parm *p) {
+    String *argout = Getattr(p, "tmap:argout");
+    String *freearg = Getattr(p, "tmap:freearg");
+    if ((!argout || Len(argout) == 0) && (!freearg || Len(freearg) == 0)) {
+      return false;
+    }
+    // If a C++ type is represented as an interface type in Go, then
+    // we don't care whether it escapes, because we know that the
+    // pointer is a C++ pointer.
+    if (goTypeIsInterface(p, Getattr(p, "type"))) {
+      return false;
+    }
+    return true;
+  }
+
+  /* ----------------------------------------------------------------------
    * gcFunctionWrapper()
    *
    * This is used for 6g/8g, not for gccgo.  Write out the function
-   * wrapper which will be compiled with 6c/8c.
+   * redirector that will be compiled with 6c/8c.  This used to write
+   * out a real function wrapper, but that has moved into Go code.
    * ---------------------------------------------------------------------- */
 
-  int gcFunctionWrapper(Node *n, String *name, String *go_name, String *overname, String *wname, ParmList *parms, SwigType *result, bool is_static, bool needs_wrapper) {
+  int gcFunctionWrapper(String *wname) {
     Wrapper *f = NewWrapper();
 
     Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"\"\n", NULL);
     Printv(f->def, "#pragma cgo_import_static ", wname, "\n", NULL);
-    Printv(f->def, "extern void (*", wname, ")(void*);\n", NULL);
-    Printv(f->def, "static void (*x", wname, ")(void*) = ", wname, ";\n", NULL);
-    Printv(f->def, "\n", NULL);
-    Printv(f->def, "void\n", NULL);
-
-    Wrapper *dummy = NewWrapper();
-    emit_attach_parmmaps(parms, dummy);
-    Swig_typemap_attach_parms("default", parms, dummy);
-    Swig_typemap_attach_parms("gosize", parms, dummy);
-    int parm_count = emit_num_arguments(parms);
-    int required_count = emit_num_required(parms);
-
-    String *parm_size = NewString("");
-
-    if (parm_count > required_count) {
-      Append(parm_size, "SWIG_PARM_SIZE");
-    }
-
-    if (class_receiver && !is_static) {
-      if (Len(parm_size) > 0) {
-	Append(parm_size, " + ");
-      }
-      Append(parm_size, "SWIG_PARM_SIZE");
-    }
-
-    Parm *p = parms;
-    for (int i = 0; i < parm_count; ++i) {
-      p = getParm(p);
-      addGcTypeSize(p, Getattr(p, "type"), parm_size);
-      p = nextParm(p);
-    }
-
-    if (SwigType_type(result) != T_VOID) {
-      addGcTypeSize(n, result, parm_size);
-    }
-
-    if (Len(parm_size) == 0) {
-      Append(parm_size, "1");
-    }
-
-    String *fn_name;
-    if (!needs_wrapper) {
-      fn_name = Copy(go_name);
-      if (overname) {
-	Append(fn_name, overname);
-      }
-    } else {
-      fn_name = buildGoWrapperName(name, overname);
-    }
-
+    Printv(f->def, "extern void ", wname, "(void*);\n", NULL);
+    // Declare this as a uintptr, since it is not a pointer into the
+    // Go heap.
     // \xc2\xb7 is UTF-8 for U+00B7 which is Unicode 'Middle Dot'
-    Printv(f->def, "\xc2\xb7", fn_name, "(struct { uint8 x[", parm_size, "];} p)", NULL);
-
-    Delete(fn_name);
-    Delete(parm_size);
-
-    Printv(f->code, "{\n", NULL);
-    Printv(f->code, "\truntime\xc2\xb7" "cgocall(x", wname, ", &p);\n", NULL);
-    Printv(f->code, "}\n", NULL);
-    Printv(f->code, "\n", NULL);
+    Printv(f->def, "uintptr \xc2\xb7", wname, " = (uintptr)", wname, ";\n", NULL);
 
     Wrapper_print(f, f_gc_wrappers);
 
     DelWrapper(f);
-    DelWrapper(dummy);
 
     return SWIG_OK;
   }
 
   /* ----------------------------------------------------------------------
-   * getGcTypeSize()
-   *
-   * Return the size to use when passing a type from 6g/8g to 6c/8c.
-   * ---------------------------------------------------------------------- */
-
-  String *addGcTypeSize(Node *n, SwigType *type, String *orig) {
-    if (Len(orig) > 0) {
-      Append(orig, " + ");
-    }
-
-    String *go = goType(n, type);
-    if (Cmp(go, "string") == 0) {
-      // A string has a pointer and a length.
-      Append(orig, "(2 * SWIG_PARM_SIZE)");
-    } else if (Strncmp(go, "[]", 2) == 0) {
-      // A slice has a pointer, a length, and a capacity.
-      Append(orig, "(3 * SWIG_PARM_SIZE)");
-    } else if (Strcmp(go, "float64") == 0) {
-      Append(orig, "8");
-    } else if (Strcmp(go, "complex64") == 0) {
-      Append(orig, "8");
-    } else if (Strcmp(go, "complex128") == 0) {
-      Append(orig, "16");
-    } else {
-      Append(orig, "SWIG_PARM_SIZE");
-    }
-
-    return orig;
-  }
-
-  /* ----------------------------------------------------------------------
    * gccFunctionWrapper()
    *
    * This is used for 6g/8g, not for gccgo.  Write out the function
@@ -1315,11 +1380,19 @@
     Parm *p = parms;
     for (int i = 0; i < parm_count; ++i) {
       p = getParm(p);
+
       String *ln = Getattr(p, "lname");
       SwigType *pt = Getattr(p, "type");
       String *ct = gcCTypeForGoValue(p, pt, ln);
       Printv(f->code, "\t\t\t", ct, ";\n", NULL);
       Delete(ct);
+
+      String *gn = NewStringf("_swig_go_%d", i);
+      ct = gcCTypeForGoValue(p, pt, gn);
+      Setattr(p, "emit:input", gn);
+      Wrapper_add_local(f, gn, ct);
+      Delete(ct);
+
       p = nextParm(p);
     }
     if (SwigType_type(result) != T_VOID) {
@@ -1329,27 +1402,39 @@
       Delete(ln);
       Printv(f->code, "\t\t", ct, ";\n", NULL);
       Delete(ct);
+
+      ln = NewString("_swig_go_result");
+      ct = gcCTypeForGoValue(n, result, ln);
+      Wrapper_add_local(f, "_swig_go_result", ct);
+      Delete(ct);
+      Delete(ln);
     }
     Printv(f->code, "\t} *swig_a = (struct swigargs *) swig_v;\n", NULL);
 
     Printv(f->code, "\n", NULL);
 
-    // Copy the input arguments out of the structure into the
-    // parameter variables.
-
+    // Copy the input arguments out of the structure into the Go local
+    // variables.
     p = parms;
     for (int i = 0; i < parm_count; ++i) {
       p = getParm(p);
+      String *ln = Getattr(p, "lname");
+      String *gn = Getattr(p, "emit:input");
+      Printv(f->code, "\t", gn, " = swig_a->", ln, ";\n", NULL);
+      p = nextParm(p);
+    }
 
+    // Apply the in typemaps.
+    p = parms;
+    for (int i = 0; i < parm_count; ++i) {
+      p = getParm(p);
       String *tm = Getattr(p, "tmap:in");
       if (!tm) {
 	Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument\n", SwigType_str(Getattr(p, "type"), 0));
       } else {
-	String *ln = Getattr(p, "lname");
-	String *input = NewString("");
-	Printv(input, "swig_a->", ln, NULL);
-	Replaceall(tm, "$input", input);
-	Setattr(p, "emit:input", input);
+	tm = Copy(tm);
+	String *gn = Getattr(p, "emit:input");
+	Replaceall(tm, "$input", gn);
 	if (i < required_count) {
 	  Printv(f->code, "\t", tm, "\n", NULL);
 	} else {
@@ -1357,6 +1442,7 @@
 	  Printv(f->code, "\t\t", tm, "\n", NULL);
 	  Printv(f->code, "\t}\n", NULL);
 	}
+	Delete(tm);
       }
       p = nextParm(p);
     }
@@ -1464,9 +1550,9 @@
     Delete(fndef);
 
     if (SwigType_type(result) != T_VOID) {
-      String *ln = NewString("go_result");
+      String *ln = NewString("_swig_go_result");
       String *ct = gccgoCTypeForGoValue(n, result, ln);
-      Wrapper_add_local(f, "go_result", ct);
+      Wrapper_add_local(f, "_swig_go_result", ct);
       Delete(ct);
       Delete(ln);
     }
@@ -1486,6 +1572,7 @@
 	String *ln = Getattr(p, "lname");
 	String *pn = NewString("g");
 	Append(pn, ln);
+	tm = Copy(tm);
 	Replaceall(tm, "$input", pn);
 	Setattr(p, "emit:input", pn);
 	if (i < required_count) {
@@ -1495,6 +1582,7 @@
 	  Printv(f->code, "    ", tm, "\n", NULL);
 	  Printv(f->code, "  }\n", NULL);
 	}
+	Delete(tm);
       }
 
       p = nextParm(p);
@@ -1513,7 +1601,7 @@
     cleanupFunction(n, f, parms);
 
     if (SwigType_type(result) != T_VOID) {
-      Printv(f->code, "  return go_result;\n", NULL);
+      Printv(f->code, "  return _swig_go_result;\n", NULL);
     }
 
     Printv(f->code, "}\n", NULL);
@@ -1543,20 +1631,26 @@
       if (!tm) {
 	p = nextSibling(p);
       } else {
+	tm = Copy(tm);
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(f->code, tm, "\n\n", NULL);
+	Delete(tm);
 	p = Getattr(p, "tmap:check:next");
       }
     }
   }
 
   /* -----------------------------------------------------------------------
-   * getGoAction()
+   * emitGoAction()
    *
-   * Get the action of the function.  This is used for C/C++ function.
+   * Emit the action of the function.  This is used for the C/C++ function.
    * ----------------------------------------------------------------------- */
 
   void emitGoAction(Node *n, List *base, ParmList *parms, SwigType *result, Wrapper *f) {
+    if (!gccgo_flag && SwigType_type(result) != T_VOID) {
+      Wrapper_add_local(f, "swig_stktop", "char *swig_stktop");
+      Printv(f->code, "\tswig_stktop = _swig_topofstack();\n", NULL);
+    }
     String *actioncode;
     if (!base || isStatic(n)) {
       Swig_director_emit_dynamic_cast(n, f);
@@ -1593,12 +1687,7 @@
     if (!tm) {
       Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s\n", SwigType_str(result, 0));
     } else {
-      if (!gccgo_flag) {
-	static const String *swig_a_result = NewStringf("swig_a->%s", Swig_cresult_name());
-	Replaceall(tm, "$result", swig_a_result);
-      } else {
-	Replaceall(tm, "$result", "go_result");
-      }
+      Replaceall(tm, "$result", "_swig_go_result");
       if (GetFlag(n, "feature:new")) {
 	Replaceall(tm, "$owner", "1");
       } else {
@@ -1608,6 +1697,14 @@
       Delete(tm);
     }
 
+    if (!gccgo_flag && SwigType_type(result) != T_VOID) {
+      // If the function called back into the Go code, the stack might
+      // have been copied.  We need to adjust swig_a accordingly here.
+      // This is what cgo does.
+      Printv(f->code, "\tswig_a = (struct swigargs*)((char*)swig_a + (_swig_topofstack() - swig_stktop));\n", NULL);
+      Printv(f->code, "\tswig_a->", Swig_cresult_name(), " = ", "_swig_go_result;\n", NULL);
+    }
+
     Swig_restore(n);
   }
 
@@ -1626,15 +1723,43 @@
       if (!tm) {
 	p = nextSibling(p);
       } else {
+	tm = Copy(tm);
 	Replaceall(tm, "$result", Swig_cresult_name());
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(f->code, tm, "\n", NULL);
+	Delete(tm);
 	p = Getattr(p, "tmap:argout:next");
       }
     }
   }
 
   /* -----------------------------------------------------------------------
+   * goargout()
+   *
+   * Handle Go argument output code if any.  This is used for the Go
+   * function.  This assumes that each parameter has an "emit:goinput"
+   * property with the name to use to refer to that parameter.
+   * ----------------------------------------------------------------------- */
+
+  void goargout(ParmList *parms, int parm_count) {
+    Parm *p = parms;
+    for (int i = 0; i < parm_count; ++i) {
+      p = getParm(p);
+      String *tm = Getattr(p, "tmap:goargout");
+      if (!tm) {
+	p = nextSibling(p);
+      } else {
+	tm = Copy(tm);
+	Replaceall(tm, "$result", "swig_r");
+	Replaceall(tm, "$input", Getattr(p, "emit:goinput"));
+	Printv(f_go_wrappers, tm, NULL);
+	Delete(tm);
+	p = Getattr(p, "tmap:goargout:next");
+      }
+    }
+  }
+
+  /* -----------------------------------------------------------------------
    * freearg()
    *
    * Handle argument cleanup code if any.  This is used for the C/C++
@@ -1650,8 +1775,10 @@
       if (!tm) {
 	p = nextSibling(p);
       } else {
+	tm = Copy(tm);
 	Replaceall(tm, "$input", Getattr(p, "emit:input"));
 	Printv(ret, tm, "\n", NULL);
+	Delete(tm);
 	p = Getattr(p, "tmap:freearg:next");
       }
     }
@@ -1835,12 +1962,26 @@
     if (!is_public(n)) {
       return SWIG_OK;
     }
-    if (Getattr(parentNode(n), "unnamed")) {
+
+    Swig_require("enumvalueDeclaration", n, "*sym:name", NIL);
+    Node *parent = parentNode(n);
+
+    if (Getattr(parent, "unnamed")) {
       Setattr(n, "type", NewString("int"));
     } else {
-      Setattr(n, "type", Getattr(parentNode(n), "enumtype"));
+      Setattr(n, "type", Getattr(parent, "enumtype"));
     }
-    return goComplexConstant(n, Getattr(n, "type"));
+
+    if (GetFlag(parent, "scopedenum")) {
+      String *symname = Getattr(n, "sym:name");
+      symname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
+      Setattr(n, "sym:name", symname);
+      Delete(symname);
+    }
+
+    int ret = goComplexConstant(n, Getattr(n, "type"));
+    Swig_restore(n);
+    return ret;
   }
 
   /* -----------------------------------------------------------------------
@@ -2047,7 +2188,7 @@
     }
 
     Append(f_go_wrappers, interfaces);
-    Printf(f_go_wrappers, "}\n\n", NULL);
+    Printv(f_go_wrappers, "}\n\n", NULL);
     Delete(interfaces);
 
     interfaces = NULL;
@@ -2640,6 +2781,7 @@
     DelWrapper(dummy);
 
     Swig_typemap_attach_parms("gotype", parms, NULL);
+    Swig_typemap_attach_parms("imtype", parms, NULL);
     int parm_count = emit_num_arguments(parms);
 
     String *func_name = NewString("NewDirector");
@@ -2666,7 +2808,9 @@
     if (!is_ignored) {
       // Declare the C++ wrapper.
 
-      if (gccgo_flag) {
+      if (!gccgo_flag) {
+	Printv(f_go_wrappers, "var ", wname, " unsafe.Pointer\n\n", NULL);
+      } else {
 	Printv(f_go_wrappers, "//extern ", go_prefix, "_", wname, "\n", NULL);
       }
 
@@ -2674,18 +2818,28 @@
       if (overname) {
 	Printv(f_go_wrappers, overname, NULL);
       }
-      Printv(f_go_wrappers, "(*", director_struct_name, NULL);
+      Printv(f_go_wrappers, "(_swig_director *", director_struct_name, NULL);
 
       p = parms;
       for (int i = 0; i < parm_count; ++i) {
 	p = getParm(p);
 	String *tm = goType(p, Getattr(p, "type"));
-	Printv(f_go_wrappers, ", ", tm, NULL);
+	Printv(f_go_wrappers, ", _ ", tm, NULL);
 	Delete(tm);
 	p = nextParm(p);
       }
 
-      Printv(f_go_wrappers, ") ", go_type_name, "\n\n", NULL);
+      Printv(f_go_wrappers, ") (_swig_ret ", go_type_name, ")", NULL);
+
+      if (!gccgo_flag) {
+	Printv(f_go_wrappers, " {\n", NULL);
+	Printv(f_go_wrappers, "\t_swig_p := uintptr(unsafe.Pointer(&_swig_director))\n", NULL);
+	Printv(f_go_wrappers, "\t_cgo_runtime_cgocall(", wname, ", _swig_p)\n", NULL);
+	Printv(f_go_wrappers, "\treturn\n", NULL);
+	Printv(f_go_wrappers, "}", NULL);
+      }
+
+      Printv(f_go_wrappers, "\n\n", NULL);
 
       Printv(f_go_wrappers, "func ", func_with_over_name, "(v interface{}", NULL);
 
@@ -2754,8 +2908,7 @@
       Setattr(n, "wrap:action", action);
 
       if (!gccgo_flag) {
-	int r = gcFunctionWrapper(n, fn_name, fn_name, overname, wname,
-				  first_parm, result, is_static, false);
+	int r = gcFunctionWrapper(wname);
 	if (r != SWIG_OK) {
 	  return r;
 	}
@@ -3075,6 +3228,7 @@
     DelWrapper(dummy);
 
     Swig_typemap_attach_parms("gotype", parms, NULL);
+    Swig_typemap_attach_parms("imtype", parms, NULL);
     int parm_count = emit_num_arguments(parms);
 
     SwigType *result = Getattr(n, "type");
@@ -3122,6 +3276,9 @@
 
     Swig_typemap_attach_parms("directorin", parms, w);
     Swig_typemap_attach_parms("directorargout", parms, w);
+    Swig_typemap_attach_parms("godirectorin", parms, w);
+    Swig_typemap_attach_parms("goin", parms, dummy);
+    Swig_typemap_attach_parms("goargout", parms, dummy);
 
     if (!is_ignored) {
       // We use an interface to see if this method is defined in Go.
@@ -3155,17 +3312,19 @@
 	// Declare the upcall function, which calls the method on the
 	// parent class.
 
-	if (gccgo_flag) {
+	if (!gccgo_flag) {
+	  Printv(f_go_wrappers, "var ", upcall_wname, " unsafe.Pointer\n\n", NULL);
+	} else {
 	  Printv(f_go_wrappers, "//extern ", go_prefix, "_", upcall_wname, "\n", NULL);
 	}
 
-	Printv(f_go_wrappers, "func ", upcall_gc_name, "(", go_type_name, NULL);
+	Printv(f_go_wrappers, "func ", upcall_gc_name, "(_swig_ptr ", go_type_name, NULL);
 
 	p = parms;
 	for (int i = 0; i < parm_count; ++i) {
 	  p = getParm(p);
 	  String *tm = goWrapperType(p, Getattr(p, "type"), false);
-	  Printv(f_go_wrappers, ", ", tm, NULL);
+	  Printv(f_go_wrappers, ", _ ", tm, NULL);
 	  Delete(tm);
 	  p = nextParm(p);
 	}
@@ -3174,11 +3333,19 @@
 
 	if (SwigType_type(result) != T_VOID) {
 	  String *tm = goWrapperType(n, result, true);
-	  Printv(f_go_wrappers, " ", tm, NULL);
+	  Printv(f_go_wrappers, " (_swig_ret ", tm, ")", NULL);
 	  Delete(tm);
 	}
 
-	Printv(f_go_wrappers, "\n", NULL);
+	if (!gccgo_flag) {
+	  Printv(f_go_wrappers, " {\n", NULL);
+	  Printv(f_go_wrappers, "\t_swig_p := uintptr(unsafe.Pointer(&_swig_ptr))\n", NULL);
+	  Printv(f_go_wrappers, "\t_cgo_runtime_cgocall(", upcall_wname, ", _swig_p)\n", NULL);
+	  Printv(f_go_wrappers, "\treturn\n", NULL);
+	  Printv(f_go_wrappers, "}", NULL);
+	}
+
+	Printv(f_go_wrappers, "\n\n", NULL);
       }
 
       // Define the method on the director class in Go.
@@ -3234,29 +3401,98 @@
       if (GetFlag(n, "abstract")) {
 	Printv(f_go_wrappers, "\tpanic(\"call to pure virtual method\")\n", NULL);
       } else {
-	if (gccgo_flag) {
-	  Printv(f_go_wrappers, "\tdefer SwigCgocallDone()\n", NULL);
-	  Printv(f_go_wrappers, "\tSwigCgocall()\n", NULL);
-	}
-
-	Printv(f_go_wrappers, "\t", NULL);
+	bool has_goout = false;
+	String *goout = NULL;
 	if (SwigType_type(result) != T_VOID) {
-	  Printv(f_go_wrappers, "return ", NULL);
+	  Printv(f_go_wrappers, "\tvar swig_r ", goImType(n, result), "\n", NULL);
+	  goout = Swig_typemap_lookup("goout", n, "swig_r", NULL);
+	  if (goout) {
+	    has_goout = true;
+	  }
 	}
-	Printv(f_go_wrappers, upcall_gc_name, "(swig_p.", go_type_name, NULL);
 
 	p = parms;
 	for (int i = 0; i < parm_count; ++i) {
 	  p = getParm(p);
-	  SwigType *pt = Getattr(p, "type");
-	  Printv(f_go_wrappers, ", ", Getattr(p, "lname"), NULL);
-	  if (goTypeIsInterface(p, pt)) {
-	    Printv(f_go_wrappers, ".Swigcptr()", NULL);
+	  if (Getattr(p, "tmap:goargout")) {
+	    has_goout = true;
 	  }
 	  p = nextParm(p);
 	}
 
-	Printv(f_go_wrappers, ")\n", NULL);
+	String *call = NewString("");
+
+	if (gccgo_flag) {
+	  if (has_goout) {
+	    Printv(call, "\tfunc() {\n", NULL);
+	  }
+	  Printv(call, "\tdefer SwigCgocallDone()\n", NULL);
+	  Printv(call, "\tSwigCgocall()\n", NULL);
+	}
+
+	Printv(call, "\t", NULL);
+	if (SwigType_type(result) != T_VOID) {
+	  Printv(call, "swig_r = ", NULL);
+	}
+	Printv(call, upcall_gc_name, "(swig_p.", go_type_name, NULL);
+
+	p = parms;
+	for (int i = 0; i < parm_count; ++i) {
+	  Printv(call, ", ", NULL);
+	  p = getParm(p);
+	  SwigType *pt = Getattr(p, "type");
+
+	  String *ln = Getattr(p, "lname");
+
+	  // This is an ordinary call from Go to C++, so adjust using
+	  // the goin typemap.
+	  String *goin = Getattr(p, "tmap:goin");
+	  if (goin == NULL) {
+	    Printv(call, ln, NULL);
+	    if (goTypeIsInterface(p, pt)) {
+	      Printv(call, ".Swigcptr()", NULL);
+	    }
+	    Setattr(p, "emit:goinput", ln);
+	  } else {
+	    String *ivar = NewString("");
+	    Printf(ivar, "_swig_i_%d", i);
+	    String *itm = goImType(p, pt);
+	    Printv(f_go_wrappers, "\tvar ", ivar, " ", itm, NULL);
+	    goin = Copy(goin);
+	    Replaceall(goin, "$input", ln);
+	    Replaceall(goin, "$result", ivar);
+	    Printv(f_go_wrappers, goin, NULL);
+	    Delete(goin);
+	    Printv(call, ivar, NULL);
+	    Setattr(p, "emit:goinput", ivar);
+	  }
+
+	  p = nextParm(p);
+	}
+
+	Printv(call, ")\n", NULL);
+
+	if (gccgo_flag && has_goout) {
+	  Printv(call, "\t}()\n", NULL);
+	}
+
+	Printv(f_go_wrappers, call, NULL);
+	Delete(call);
+
+	goargout(parms, parm_count);
+
+	if (SwigType_type(result) != T_VOID) {
+	  if (goout == NULL) {
+	    Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
+	  } else {
+	    String *tm = goType(n, result);
+	    Printv(f_go_wrappers, "\tvar swig_r_1 ", tm, "\n", NULL);
+	    Replaceall(goout, "$input", "swig_r");
+	    Replaceall(goout, "$result", "swig_r_1");
+	    Printv(f_go_wrappers, goout, NULL);
+	    Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
+	  }
+	}
       }
 
       Printv(f_go_wrappers, "}\n\n", NULL);
@@ -3341,7 +3577,7 @@
 	if (!gccgo_flag) {
 	  // Write the upcall wrapper function.  This is compiled by gc
 	  // and calls the C++ function.
-	  int r = gcFunctionWrapper(n, upcall_name, upcall_name, overname, upcall_wname, first_parm, result, is_static, true);
+	  int r = gcFunctionWrapper(upcall_wname);
 	  if (r != SWIG_OK) {
 	    return r;
 	  }
@@ -3389,29 +3625,86 @@
 
 	Printv(f_go_wrappers, " {\n", NULL);
 
-	if (gccgo_flag) {
-	  Printv(f_go_wrappers, "\tdefer SwigCgocallDone()\n", NULL);
-	  Printv(f_go_wrappers, "\tSwigCgocall()\n", NULL);
+	String *goout = NULL;
+	if (SwigType_type(result) != T_VOID) {
+	  Printv(f_go_wrappers, "\tvar swig_r ", goImType(n, result), "\n", NULL);
+	  goout = Swig_typemap_lookup("goout", n, "swig_r", NULL);
 	}
 
-	Printv(f_go_wrappers, "\t", NULL);
-	if (SwigType_type(result) != T_VOID) {
-	  Printv(f_go_wrappers, "return ", NULL);
+	String *call = NewString("");
+
+	if (gccgo_flag) {
+	  if (goout != NULL) {
+	    Printv(call, "\tfunc() {\n", NULL);
+	  }
+	  Printv(call, "\tdefer SwigCgocallDone()\n", NULL);
+	  Printv(call, "\tSwigCgocall()\n", NULL);
 	}
-	Printv(f_go_wrappers, upcall_gc_name, "(p.(*", director_struct_name, ").", go_type_name, NULL);
+
+	Printv(call, "\t", NULL);
+	if (SwigType_type(result) != T_VOID) {
+	  Printv(call, "swig_r = ", NULL);
+	}
+	Printv(call, upcall_gc_name, "(p.(*", director_struct_name, ").", go_type_name, NULL);
 
 	p = parms;
 	for (int i = 0; i < parm_count; ++i) {
+	  Printv(call, ", ", NULL);
 	  p = getParm(p);
 	  SwigType *pt = Getattr(p, "type");
-	  Printv(f_go_wrappers, ", ", Getattr(p, "lname"), NULL);
+
+	  String *ln = Copy(Getattr(p, "lname"));
 	  if (goTypeIsInterface(p, pt)) {
-	    Printv(f_go_wrappers, ".Swigcptr()", NULL);
+	    Printv(ln, ".Swigcptr()", NULL);
 	  }
+
+	  String *goin = Getattr(p, "tmap:goin");
+	  if (goin == NULL) {
+	    Printv(call, ln, NULL);
+	    Setattr(p, "emit:goinput", ln);
+	  } else {
+	    String *ivar = NewString("");
+	    Printf(ivar, "_swig_i_%d", i);
+	    String *itm = goImType(p, pt);
+	    Printv(f_go_wrappers, "\tvar ", ivar, " ", itm, NULL);
+	    goin = Copy(goin);
+	    Replaceall(goin, "$input", ln);
+	    Replaceall(goin, "$result", ivar);
+	    Printv(f_go_wrappers, goin, NULL);
+	    Delete(goin);
+	    Printv(call, ivar, NULL);
+	    Setattr(p, "emit:goinput", ivar);
+	  }
+
+	  Delete(ln);
+
 	  p = nextParm(p);
 	}
 
-	Printv(f_go_wrappers, ")\n", NULL);
+	Printv(call, ")\n", NULL);
+
+	if (gccgo_flag && goout != NULL) {
+	  Printv(call, "\t}()\n", NULL);
+	}
+
+	Printv(f_go_wrappers, call, NULL);
+	Delete(call);
+
+	goargout(parms, parm_count);
+
+	if (SwigType_type(result) != T_VOID) {
+	  if (goout == NULL) {
+	    Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
+	  } else {
+	    String *tm = goType(n, result);
+	    Printv(f_go_wrappers, "\tvar swig_r_1 ", tm, "\n", NULL);
+	    Replaceall(goout, "$input", "swig_r");
+	    Replaceall(goout, "$result", "swig_r_1");
+	    Printv(f_go_wrappers, goout, NULL);
+	    Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
+	  }
+	}
+
 	Printv(f_go_wrappers, "}\n\n", NULL);
       }
 
@@ -3437,34 +3730,53 @@
       }
       Printv(f_go_wrappers, "{\n", NULL);
 
-      if (gccgo_flag) {
-	Printv(f_go_wrappers, "\tSwigCgocallBack()\n", NULL);
-	Printv(f_go_wrappers, "\tdefer SwigCgocallBackDone()\n", NULL);
-      }
-
-      Printv(f_go_wrappers, "\t", NULL);
-
       if (is_ignored) {
-	Printv(f_go_wrappers, "return\n", NULL);
+	Printv(f_go_wrappers, "\treturn\n", NULL);
       } else {
 	bool result_is_interface = false;
+	String *goout = NULL;
 	if (SwigType_type(result) != T_VOID) {
-	  Printv(f_go_wrappers, "return ", NULL);
 	  result_is_interface = goTypeIsInterface(NULL, result);
+	  Printv(f_go_wrappers, "\tvar swig_r ", NULL);
+	  if (!result_is_interface) {
+	    Printv(f_go_wrappers, goType(n, result), NULL);
+	  } else {
+	    Printv(f_go_wrappers, result_wrapper, NULL);
+	  }
+	  Printv(f_go_wrappers, "\n", NULL);
+	  goout = Swig_typemap_lookup("godirectorout", n, "swig_r", NULL);
+	}
+
+	String *call = NewString("");
+
+	if (gccgo_flag) {
+	  if (goout != NULL) {
+	    Printv(call, "\tfunc() {\n", NULL);
+	  }
+	  Printv(call, "\tSwigCgocallBack()\n", NULL);
+	  Printv(call, "\tdefer SwigCgocallBackDone()\n", NULL);
+	}
+
+	Printv(call, "\t", NULL);
+
+	if (SwigType_type(result) != T_VOID) {
+	  Printv(call, "swig_r = ", NULL);
 	  if (result_is_interface) {
-	    Printv(f_go_wrappers, result_wrapper, "(", NULL);
+	    Printv(call, result_wrapper, "(", NULL);
 	  }
 	}
-	Printv(f_go_wrappers, "p.", go_with_over_name, "(", NULL);
+	Printv(call, "p.", go_with_over_name, "(", NULL);
 
 	p = parms;
 	for (int i = 0; i < parm_count; ++i) {
 	  p = getParm(p);
 	  if (i > 0) {
-	    Printv(f_go_wrappers, ", ", NULL);
+	    Printv(call, ", ", NULL);
 	  }
 	  SwigType *pt = Getattr(p, "type");
 
+	  String *ln = NewString("");
+
 	  // If the Go representation is an interface type class, then
 	  // we are receiving a uintptr, and must convert to the
 	  // interface.
@@ -3473,26 +3785,64 @@
 	    // Passing is_result as true to goWrapperType gives us the
 	    // name of the Go type we need to convert to an interface.
 	    String *wt = goWrapperType(p, pt, true);
-	    Printv(f_go_wrappers, wt, "(", NULL);
+	    Printv(ln, wt, "(", NULL);
 	    Delete(wt);
 	  }
 
-	  Printv(f_go_wrappers, Getattr(p, "lname"), NULL);
+	  Printv(ln, Getattr(p, "lname"), NULL);
 
 	  if (is_interface) {
-	    Printv(f_go_wrappers, ")", NULL);
+	    Printv(ln, ")", NULL);
 	  }
 
+	  String *goin = Getattr(p, "tmap:godirectorin");
+	  if (goin == NULL) {
+	    Printv(call, ln, NULL);
+	  } else {
+	    String *ivar = NewString("");
+	    Printf(ivar, "_swig_i_%d", i);
+	    String *itm = goType(p, pt);
+	    Printv(f_go_wrappers, "\tvar ", ivar, " ", itm, NULL);
+	    goin = Copy(goin);
+	    Replaceall(goin, "$input", ln);
+	    Replaceall(goin, "$result", ivar);
+	    Printv(f_go_wrappers, goin, NULL);
+	    Delete(goin);
+	    Printv(call, ivar, NULL);
+	    Delete(ivar);
+	  }
+
+	  Delete(ln);
+
 	  p = nextParm(p);
 	}
 
-	Printv(f_go_wrappers, ")", NULL);
+	Printv(call, ")", NULL);
 
 	if (result_is_interface) {
-	  Printv(f_go_wrappers, ".Swigcptr())", NULL);
+	  Printv(call, ".Swigcptr())", NULL);
+	}
+	Printv(call, "\n", NULL);
+
+	if (gccgo_flag && goout != NULL) {
+	  Printv(call, "\t}()\n", NULL);
 	}
 
-	Printv(f_go_wrappers, "\n", NULL);
+	Printv(f_go_wrappers, call, NULL);
+	Delete(call);
+
+	if (SwigType_type(result) != T_VOID) {
+	  if (goout == NULL) {
+	    Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
+	  } else {
+	    String *tm = goImType(n, result);
+	    Printv(f_go_wrappers, "\tvar swig_r_1 ", tm, "\n", NULL);
+	    Replaceall(goout, "$input", "swig_r");
+	    Replaceall(goout, "$result", "swig_r_1");
+	    Printv(f_go_wrappers, goout, NULL);
+	    Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
+	  }
+	}
       }
 
       Printv(f_go_wrappers, "}\n\n", NULL);
@@ -3610,6 +3960,7 @@
 	      Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file,
 			   line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0));
 	    } else {
+	      tm = Copy(tm);
 	      String *ln = Getattr(p, "lname");
 	      String *input = NewString("");
 	      Printv(input, "swig_a.", ln, NULL);
@@ -3618,12 +3969,28 @@
 	      Replaceall(tm, "$owner", "0");
 	      Delete(input);
 	      Printv(w->code, "\t", tm, "\n", NULL);
+	      Delete(tm);
 	    }
 	    p = Getattr(p, "tmap:directorin:next");
 	  }
 
 	  Printv(w->code, "  crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL);
 
+	  /* Marshal outputs */
+	  for (p = parms; p;) {
+	    String *tm;
+	    if ((tm = Getattr(p, "tmap:directorargout"))) {
+	      tm = Copy(tm);
+	      Replaceall(tm, "$result", "jresult");
+	      Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
+	      Printv(w->code, tm, "\n", NIL);
+	      Delete(tm);
+	      p = Getattr(p, "tmap:directorargout:next");
+	    } else {
+	      p = nextSibling(p);
+	    }
+	  }
+
 	  if (SwigType_type(result) != T_VOID) {
 	    String *result_str = NewString("c_result");
 	    String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL);
@@ -3672,7 +4039,7 @@
 
 	    String *pn = NewString("g");
 	    Append(pn, Getattr(p, "lname"));
-	    Setattr(p, "emit:input", pn);
+	    Setattr(p, "emit:directorinput", pn);
 
 	    String *tm = gccgoCTypeForGoValue(n, Getattr(p, "type"), pn);
 	    Wrapper_add_local(w, pn, tm);
@@ -3683,9 +4050,11 @@
 	      Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file,
 			   line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0));
 	    } else {
+	      tm = Copy(tm);
 	      Replaceall(tm, "$input", pn);
 	      Replaceall(tm, "$owner", 0);
 	      Printv(w->code, "  ", tm, "\n", NULL);
+	      Delete(tm);
 
 	      Printv(args, ", ", pn, NULL);
 	    }
@@ -3699,6 +4068,21 @@
 	  }
 	  Printv(w->code, callback_wname, "(go_val", args, ");\n", NULL);
 
+	  /* Marshal outputs */
+	  for (p = parms; p;) {
+	    String *tm;
+	    if ((tm = Getattr(p, "tmap:directorargout"))) {
+	      tm = Copy(tm);
+	      Replaceall(tm, "$result", "jresult");
+	      Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
+	      Printv(w->code, tm, "\n", NIL);
+	      Delete(tm);
+	      p = Getattr(p, "tmap:directorargout:next");
+	    } else {
+	      p = nextSibling(p);
+	    }
+	  }
+
 	  if (SwigType_type(result) != T_VOID) {
 	    String *result_str = NewString("c_result");
 	    String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL);
@@ -3717,19 +4101,6 @@
 	    Delete(result_str);
 	  }
 	}
-
-	/* Marshal outputs */
-	for (p = parms; p;) {
-	  String *tm;
-	  if ((tm = Getattr(p, "tmap:directorargout"))) {
-	    Replaceall(tm, "$result", "jresult");
-	    Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
-	    Printv(w->code, tm, "\n", NIL);
-	    p = Getattr(p, "tmap:directorargout:next");
-	  } else {
-	    p = nextSibling(p);
-	  }
-	}
       } else {
 	assert(is_pure_virtual);
 	Printv(w->code, "  _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL);
@@ -4057,7 +4428,7 @@
 	    }
 
 	    fn = i + 1;
-	    Printf(f_go_wrappers, "\t\tif _, ok := a[%d].(%s); !ok {\n", j, tm);
+	    Printf(f_go_wrappers, "\t\tif _, ok := a[%d].(%s); !ok {\n", j, goType(pj, Getattr(pj, "type")));
 	    Printf(f_go_wrappers, "\t\t\tgoto check_%d\n", fn);
 	    Printv(f_go_wrappers, "\t\t}\n", NULL);
 	  }
@@ -4462,7 +4833,19 @@
    * ---------------------------------------------------------------------- */
 
   String *goType(Node *n, SwigType *type) {
-    return goTypeWithInfo(n, type, NULL);
+    return goTypeWithInfo(n, type, false, NULL);
+  }
+
+  /* ----------------------------------------------------------------------
+   * goImType()
+   *
+   * Given a SWIG type, return a string for the intermediate Go type
+   * to pass to C/C++.  This is like goType except that it looks for
+   * an imtype typemap entry first.
+   * ---------------------------------------------------------------------- */
+
+  String *goImType(Node *n, SwigType *type) {
+    return goTypeWithInfo(n, type, true, NULL);
   }
 
   /* ----------------------------------------------------------------------
@@ -4470,6 +4853,8 @@
    *
    * Like goType, but return some more information.
    *
+   * If use_imtype is true, this look for a imtype typemap entry.
+   *
    * If the p_is_interface parameter is not NULL, this sets
    * *p_is_interface to indicate whether this type is going to be
    * represented by a Go interface type.  These are cases where the Go
@@ -4477,24 +4862,39 @@
    * forth with C/C++.
    * ---------------------------------------------------------------------- */
 
-  String *goTypeWithInfo(Node *n, SwigType *type, bool *p_is_interface) {
+  String *goTypeWithInfo(Node *n, SwigType *type, bool use_imtype, bool *p_is_interface) {
     if (p_is_interface) {
       *p_is_interface = false;
     }
 
-    String *ret;
-    if (n && Cmp(type, Getattr(n, "type")) == 0) {
-      ret = NULL;
-      if (Strcmp(Getattr(n, "nodeType"), "parm") == 0) {
-	ret = Getattr(n, "tmap:gotype");
+    String *ret = NULL;
+    if (use_imtype) {
+      if (n && Cmp(type, Getattr(n, "type")) == 0) {
+	if (Strcmp(Getattr(n, "nodeType"), "parm") == 0) {
+	  ret = Getattr(n, "tmap:imtype");
+	}
+	if (!ret) {
+	  ret = Swig_typemap_lookup("imtype", n, "", NULL);
+	}
+      } else {
+	Parm *p = NewParm(type, "goImType", n);
+	ret = Swig_typemap_lookup("imtype", p, "", NULL);
+	Delete(p);
       }
-      if (!ret) {
-	ret = Swig_typemap_lookup("gotype", n, "", NULL);
+    }
+    if (!ret) {
+      if (n && Cmp(type, Getattr(n, "type")) == 0) {
+	if (Strcmp(Getattr(n, "nodeType"), "parm") == 0) {
+	  ret = Getattr(n, "tmap:gotype");
+	}
+	if (!ret) {
+	  ret = Swig_typemap_lookup("gotype", n, "", NULL);
+	}
+      } else {
+	Parm *p = NewParm(type, "goType", n);
+	ret = Swig_typemap_lookup("gotype", p, "", NULL);
+	Delete(p);
       }
-    } else {
-      Parm *p = NewParm(type, "goType", n);
-      ret = Swig_typemap_lookup("gotype", p, "", NULL);
-      Delete(p);
     }
 
     if (ret && Strstr(ret, "$gotypename") != 0) {
@@ -4563,7 +4963,7 @@
 	ret = NewString("uintptr");
       } else {
 	bool is_interface;
-	String *base = goTypeWithInfo(n, r, &is_interface);
+	String *base = goTypeWithInfo(n, r, false, &is_interface);
 
 	// At the Go level, an unknown or class type is handled as an
 	// interface wrapping a pointer.  This means that if a
@@ -4627,12 +5027,12 @@
       if (add_pointer) {
 	SwigType_add_pointer(r);
       }
-      ret = goTypeWithInfo(n, r, p_is_interface);
+      ret = goTypeWithInfo(n, r, false, p_is_interface);
       Delete(r);
     } else if (SwigType_isqualifier(t)) {
       SwigType *r = Copy(t);
       SwigType_del_qualifier(r);
-      ret = goTypeWithInfo(n, r, p_is_interface);
+      ret = goTypeWithInfo(n, r, false, p_is_interface);
       Delete(r);
     } else if (SwigType_isvarargs(t)) {
       ret = NewString("[]interface{}");
@@ -4658,7 +5058,7 @@
 
   String *goWrapperType(Node *n, SwigType *type, bool is_result) {
     bool is_interface;
-    String *ret = goTypeWithInfo(n, type, &is_interface);
+    String *ret = goTypeWithInfo(n, type, true, &is_interface);
 
     // If this is an interface, we want to pass the real type.
     if (is_interface) {
@@ -4742,7 +5142,18 @@
 
   String *gcCTypeForGoValue(Node *n, SwigType *type, String *name) {
     bool is_interface;
-    String *gt = goTypeWithInfo(n, type, &is_interface);
+    String *gt = goTypeWithInfo(n, type, true, &is_interface);
+
+    String *tail = NewString("");
+    SwigType *t = SwigType_typedef_resolve_all(type);
+    if (!SwigType_isreference(t)) {
+      while (Strncmp(gt, "*", 1) == 0) {
+	Replace(gt, "*", "", DOH_REPLACE_FIRST);
+	Printv(tail, "*", NULL);
+      }
+    }
+    Delete(t);
+
     bool is_string = Strcmp(gt, "string") == 0;
     bool is_slice = Strncmp(gt, "[]", 2) == 0;
     bool is_function = Strcmp(gt, "_swig_fnptr") == 0;
@@ -4770,18 +5181,21 @@
     if (is_string) {
       // Note that we don't turn a reference to a string into a
       // pointer to a string.  Strings are immutable anyhow.
-      ret = NewString("_gostring_ ");
-      Append(ret, name);
+      ret = NewString("");
+      Printv(ret, "_gostring_", tail, " ", name, NULL);
+      Delete(tail);
       return ret;
     } else if (is_slice) {
       // Slices are always passed as a _goslice_, whether or not references
       // are involved.
-      ret = NewString("_goslice_ ");
-      Append(ret, name);
+      ret = NewString("");
+      Printv(ret, "_goslice_", tail, " ", name, NULL);
+      Delete(tail);
       return ret;
     } else if (is_function || is_member) {
-      ret = NewString("void *");
-      Append(ret, name);
+      ret = NewString("");
+      Printv(ret, "void*", tail, " ", name, NULL);
+      Delete(tail);
       return ret;
     } else if (is_complex64) {
       ret = NewString("_Complex float ");
@@ -4798,6 +5212,7 @@
       SwigType_add_pointer(t);
       ret = SwigType_lstr(t, name);
       Delete(t);
+      Delete(tail);
       return ret;
     } else {
       SwigType *t = SwigType_typedef_resolve_all(type);
@@ -4821,6 +5236,7 @@
 	      }
 	      Delete(q);
 	      Delete(t);
+	      Delete(tail);
 	      return ret;
 	    }
 	  }
@@ -4853,14 +5269,17 @@
       } else if (is_float64) {
 	ret = NewString("double ");
       } else {
+	Delete(tail);
 	return SwigType_lstr(type, name);
       }
     }
 
+    Append(ret, tail);
     if (SwigType_isreference(type)) {
       Append(ret, "* ");
     }
     Append(ret, name);
+    Delete(tail);
     return ret;
   }
 
@@ -4885,7 +5304,7 @@
 
   bool goTypeIsInterface(Node *n, SwigType *type) {
     bool is_interface;
-    Delete(goTypeWithInfo(n, type, &is_interface));
+    Delete(goTypeWithInfo(n, type, false, &is_interface));
     return is_interface;
   }
 
diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx
index a9e51fd..1c135b5 100644
--- a/Source/Modules/guile.cxx
+++ b/Source/Modules/guile.cxx
@@ -1350,7 +1350,7 @@
       Printv(f_header, tm, "\n", NIL);
     } else {
       // Create variable and assign it a value
-      Printf(f_header, "static %s = %s;\n", SwigType_str(type, var_name), rvalue);
+      Printf(f_header, "static %s = (%s)(%s);\n", SwigType_str(type, var_name), SwigType_str(type, 0), rvalue);
     }
     {
       /* Hack alert: will cleanup later -- Dave */
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index 9e16bb4..82ecb41 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -209,7 +209,7 @@
 	   String *symname = Copy(Getattr(n, "sym:name"));
 	   if (symname && !GetFlag(n, "feature:flatnested")) {
 	     for (Node *outer_class = Getattr(n, "nested:outer"); outer_class; outer_class = Getattr(outer_class, "nested:outer")) {
-	       Push(symname, ".");
+	       Push(symname, jnidescriptor ? "$" : ".");
 	       Push(symname, Getattr(outer_class, "sym:name"));
 	     }
 	   }
@@ -838,7 +838,7 @@
     bool is_destructor = (Cmp(Getattr(n, "nodeType"), "destructor") == 0);
 
     if (!Getattr(n, "sym:overloaded")) {
-      if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name))
+      if (!addSymbol(symname, n, imclass_name))
 	return SWIG_ERROR;
     }
 
@@ -1039,26 +1039,15 @@
       }
     }
 
+    // Now write code to make the function call
     if (!native_function_flag) {
-      if (Cmp(nodeType(n), "constant") == 0) {
-        // Wrapping a constant hack
-        Swig_save("functionWrapper", n, "wrap:action", NIL);
 
-        // below based on Swig_VargetToFunction()
-        SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
-        Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
-      }
-
-      // Now write code to make the function call
       Swig_director_emit_dynamic_cast(n, f);
       String *actioncode = emit_action(n);
 
       // Handle exception classes specified in the "except" feature's "throws" attribute
       addThrows(n, "feature:except", n);
 
-      if (Cmp(nodeType(n), "constant") == 0)
-        Swig_restore(n);
-
       /* Return value if necessary  */
       if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
 	addThrows(n, "tmap:out", n);
@@ -1194,15 +1183,13 @@
     return ret;
   }
 
-  String *getCurrentScopeName(String *nspace)
-  {
+  String *getCurrentScopeName(String *nspace) {
     String *scope = 0;
     if (nspace || getCurrentClass()) {
       scope = NewString("");
       if (nspace)
 	Printf(scope, "%s", nspace);
-      if (Node* cls = getCurrentClass())
-      {
+      if (Node* cls = getCurrentClass()) {
 	if (Node *outer = Getattr(cls, "nested:outer")) {
 	  String *outerClassesPrefix = Copy(Getattr(outer, "sym:name"));
 	  for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) {
@@ -1370,6 +1357,7 @@
     int unnamedinstance = GetFlag(parent, "unnamedinstance");
     String *parent_name = Getattr(parent, "name");
     String *nspace = getNSpace();
+    String *newsymname = 0;
     String *tmpValue;
 
     // Strange hack from parent method
@@ -1394,14 +1382,20 @@
     {
       EnumFeature enum_feature = decodeEnumFeature(parent);
 
+      if ((enum_feature == SimpleEnum) && GetFlag(parent, "scopedenum")) {
+	newsymname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
+	symname = newsymname;
+      }
+
       // Add to language symbol table
       String *scope = 0;
       if (unnamedinstance || !parent_name || enum_feature == SimpleEnum) {
-	if (proxy_class_name) {
+	String *enumClassPrefix = getEnumClassPrefix();
+	if (enumClassPrefix) {
 	  scope = NewString("");
 	  if (nspace)
 	    Printf(scope, "%s.", nspace);
-	  Printf(scope, "%s", proxy_class_name);
+	  Printf(scope, "%s", enumClassPrefix);
 	} else {
 	  scope = Copy(constants_interface_name);
 	}
@@ -1412,7 +1406,7 @@
 	else
 	  Printf(scope, ".%s", Getattr(parent, "sym:name"));
       }
-      if (!addSymbol(name, n, scope))
+      if (!addSymbol(symname, n, scope))
 	return SWIG_ERROR;
 
       if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
@@ -1466,6 +1460,7 @@
       Delete(scope);
     }
 
+    Delete(newsymname);
     Delete(tmpValue);
     Swig_restore(n);
     return SWIG_OK;
@@ -2268,7 +2263,7 @@
       Printf(imcall, "swigCPtr");
 
       String *this_type = Copy(getClassType());
-      String *name = NewString("self");
+      String *name = NewString("jself");
       String *qualifier = Getattr(n, "qualifier");
       if (qualifier)
 	SwigType_push(this_type, qualifier);
@@ -2959,6 +2954,16 @@
 	// Use the C syntax to make a true Java constant and hope that it compiles as Java code
 	value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex"));
       } else {
+	String *newsymname = 0;
+	if (!getCurrentClass() || !proxy_flag) {
+	  String *enumClassPrefix = getEnumClassPrefix();
+	  if (enumClassPrefix) {
+	    // A global scoped enum
+	    newsymname = Swig_name_member(0, enumClassPrefix, symname);
+	    symname = newsymname;
+	  }
+	}
+
 	// Get the enumvalue from a JNI call
 	if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) {
 	  // Strange hack to change the name
@@ -2967,8 +2972,9 @@
 	  value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
 	} else {
 	  memberconstantHandler(n);
-	  value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, proxy_class_name, symname)));
+	  value = NewStringf("%s.%s()", full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), Swig_name_member(0, getEnumClassPrefix(), symname)));
 	}
+	Delete(newsymname);
       }
     }
     return value;
@@ -3116,44 +3122,6 @@
   }
 
   /* -----------------------------------------------------------------------------
-   * makeParameterName()
-   *
-   * Inputs: 
-   *   n - Node
-   *   p - parameter node
-   *   arg_num - parameter argument number
-   *   setter  - set this flag when wrapping variables
-   * Return:
-   *   arg - a unique parameter name
-   * ----------------------------------------------------------------------------- */
-
-  String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) {
-
-    String *arg = 0;
-    String *pn = Getattr(p, "name");
-
-    // Use C parameter name unless it is a duplicate or an empty parameter name
-    int count = 0;
-    ParmList *plist = Getattr(n, "parms");
-    while (plist) {
-      if ((Cmp(pn, Getattr(plist, "name")) == 0))
-        count++;
-      plist = nextSibling(plist);
-    }
-    String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
-    arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
-
-    if (setter && Cmp(arg, "self") != 0) {
-      // Note that for setters the parameter name is always set but sometimes includes C++ 
-      // scope resolution, so we need to strip off the scope resolution to make a valid name.
-      Delete(arg);
-      arg = NewString("value");	//Swig_scopename_last(pn);
-    }
-
-    return arg;
-  }
-
-  /* -----------------------------------------------------------------------------
    * emitTypeWrapperClass()
    * ----------------------------------------------------------------------------- */
 
@@ -3670,7 +3638,6 @@
    * --------------------------------------------------------------- */
 
   int classDirectorMethod(Node *n, Node *parent, String *super) {
-    String *classname = Getattr(parent, "sym:name");
     String *c_classname = Getattr(parent, "name");
     String *name = Getattr(n, "name");
     String *symname = Getattr(n, "sym:name");
@@ -3704,14 +3671,7 @@
     String *imcall_args = NewString("");
     int classmeth_off = curr_class_dmethod - first_class_dmethod;
     bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
-    String *qualified_classname = Copy(classname);
-    String *nspace = getNSpace();
-
-    if (nspace && package)
-      Insert(qualified_classname, 0, NewStringf("%s.%s.", package, nspace));
-    else if(nspace)
-      Insert(qualified_classname, 0, NewStringf("%s.", nspace));
-
+    String *qualified_classname = getProxyName(getClassName());
 
     // Kludge Alert: functionWrapper sets sym:overload properly, but it
     // isn't at this point, so we have to manufacture it ourselves. At least
@@ -3772,7 +3732,7 @@
     /* Create the intermediate class wrapper */
     tm = Swig_typemap_lookup("jtype", n, "", 0);
     if (tm) {
-      Printf(callback_def, "  public static %s %s(%s self", tm, imclass_dmethod, qualified_classname);
+      Printf(callback_def, "  public static %s %s(%s jself", tm, imclass_dmethod, qualified_classname);
     } else {
       Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(returntype, 0));
     }
@@ -3834,7 +3794,6 @@
     }
 
     Delete(adjustedreturntypeparm);
-    Delete(qualified_classname);
 
     Swig_director_parms_fixup(l);
 
@@ -3889,7 +3848,7 @@
       Printf(w->code, "if (swigjobj && jenv->IsSameObject(swigjobj, NULL) == JNI_FALSE) {\n");
     }
 
-    /* Start the Java field descriptor for the intermediate class's upcall (insert self object) */
+    /* Start the Java field descriptor for the intermediate class's upcall (insert jself object) */
     Parm *tp = NewParmNode(c_classname, n);
     String *jdesc;
 
@@ -4100,7 +4059,7 @@
 
     /* Emit the intermediate class's upcall to the actual class */
 
-    String *upcall = NewStringf("self.%s(%s)", symname, imcall_args);
+    String *upcall = NewStringf("jself.%s(%s)", symname, imcall_args);
 
     // Handle exception classes specified in the "except" feature's "throws" attribute
     addThrows(n, "feature:except", n);
@@ -4475,18 +4434,15 @@
    * ------------------------------------------------------------ */
 
   int classDirectorEnd(Node *n) {
-    String *classname = Getattr(n, "sym:name");
+    String *full_classname = Getattr(n, "name");
+    String *classname = getProxyName(full_classname, true);
     String *director_classname = directorClassName(n);
     String *internal_classname;
 
     Wrapper *w = NewWrapper();
 
-    if (Len(package_path) > 0 && Len(getNSpace()) > 0)
-      internal_classname = NewStringf("%s/%s/%s", package_path, getNSpace(), classname);
-    else if (Len(package_path) > 0)
+    if (Len(package_path) > 0)
       internal_classname = NewStringf("%s/%s", package_path, classname);
-    else if (Len(getNSpace()) > 0)
-      internal_classname = NewStringf("%s/%s", getNSpace(), classname);
     else
       internal_classname = NewStringf("%s", classname);
 
@@ -4598,6 +4554,7 @@
   /*----------------------------------------------------------------------
    * extraDirectorProtectedCPPMethodsRequired()
    *--------------------------------------------------------------------*/
+
   bool extraDirectorProtectedCPPMethodsRequired() const {
     return false;
   }
@@ -4623,6 +4580,10 @@
     Setattr(n, "director:ctor", class_ctor);
   }
 
+  /*----------------------------------------------------------------------
+   * nestedClassesSupport()
+   *--------------------------------------------------------------------*/
+
   NestedClassSupport nestedClassesSupport() const {
     return NCS_Full;
   }
diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx
index 20af76f..0c3f02a 100644
--- a/Source/Modules/javascript.cxx
+++ b/Source/Modules/javascript.cxx
@@ -318,6 +318,10 @@
    **/
   virtual int fragmentDirective(Node *n);
 
+public:
+
+  virtual String *getNSpace() const;
+
 private:
 
   JSEmitter *emitter;
@@ -467,6 +471,10 @@
   return SWIG_OK;
 }
 
+String *JAVASCRIPT::getNSpace() const {
+  return Language::getNSpace();
+}
+
 /* ---------------------------------------------------------------------
  * top()
  *
@@ -716,19 +724,19 @@
 	// detected via the 'view' attribute.
 	|| (Equal(kind, "variable") && Equal(Getattr(n, "view"), "globalfunctionHandler"))
 	) {
-      bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend");
-      bool is_static = GetFlag(state.function(), IS_STATIC);
+      bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0;
+      bool is_static = GetFlag(state.function(), IS_STATIC) != 0;
       ret = emitFunction(n, is_member, is_static);
     } else if (Cmp(kind, "variable") == 0) {
-      bool is_static = GetFlag(state.variable(), IS_STATIC);
+      bool is_static = GetFlag(state.variable(), IS_STATIC) != 0;
       // HACK: smartpointeraccessed static variables are not treated as statics
       if (GetFlag(n, "allocate:smartpointeraccess")) {
 	is_static = false;
       }
 
-      bool is_member = GetFlag(n, "ismember");
-      bool is_setter = GetFlag(n, "memberset") || GetFlag(n, "varset");
-      bool is_getter = GetFlag(n, "memberget") || GetFlag(n, "varget");
+      bool is_member = GetFlag(n, "ismember") != 0;
+      bool is_setter = GetFlag(n, "memberset") != 0 || GetFlag(n, "varset") != 0;
+      bool is_getter = GetFlag(n, "memberget") != 0 || GetFlag(n, "varget") != 0;
       if (is_setter) {
 	ret = emitSetter(n, is_member, is_static);
       } else if (is_getter) {
@@ -832,7 +840,7 @@
 
   Wrapper *wrapper = NewWrapper();
 
-  bool is_overloaded = GetFlag(n, "sym:overloaded");
+  bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
 
   Template t_ctor(getTemplate("js_ctor"));
 
@@ -1152,7 +1160,7 @@
   Wrapper *wrapper = NewWrapper();
   Template t_function(getTemplate("js_function"));
 
-  bool is_overloaded = GetFlag(n, "sym:overloaded");
+  bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
 
   // prepare the function wrapper name
   String *iname = Getattr(n, "sym:name");
@@ -1223,18 +1231,27 @@
   // substract the extension "sym:overname",
   String *wrap_name = NewString(Getattr(n, "wrap:name"));
   String *overname = Getattr(n, "sym:overname");
+
+  Node *methodclass = Swig_methodclass(n);
+  String *class_name = Getattr(methodclass, "sym:name");
+
   int l1 = Len(wrap_name);
   int l2 = Len(overname);
   Delslice(wrap_name, l1 - l2, l1);
 
-  Setattr(n, "wrap:name", wrap_name);
-  state.function(WRAPPER_NAME, wrap_name);
+  String *new_string = NewStringf("%s_%s", class_name, wrap_name);
+  String *final_wrap_name = Swig_name_wrapper(new_string);
+     
+  Setattr(n, "wrap:name", final_wrap_name);
+  state.function(WRAPPER_NAME, final_wrap_name);
+
+
 
   t_function.replace("$jslocals", wrapper->locals)
       .replace("$jscode", wrapper->code);
 
   // call this here, to replace all variables
-  t_function.replace("$jswrapper", wrap_name)
+  t_function.replace("$jswrapper", final_wrap_name)
       .replace("$jsname", state.function(NAME))
       .pretty_print(f_wrappers);
 
@@ -1280,7 +1297,7 @@
     cresult = defaultResultName;
 
   tm = Swig_typemap_lookup_out("out", n, cresult, wrapper, actioncode);
-  bool should_own = GetFlag(n, "feature:new");
+  bool should_own = GetFlag(n, "feature:new") != 0;
 
   if (tm) {
     Replaceall(tm, "$objecttype", Swig_scopename_last(SwigType_str(SwigType_strip_qualifiers(type), 0)));
@@ -1346,14 +1363,26 @@
     return SWIG_OK;
   }
 
-  String *nspace = Getattr(n, "sym:nspace");
-
   // if nspace is deactivated, everything goes into the global scope
   if (!GetFlag(n, "feature:nspace")) {
     current_namespace = Getattr(namespaces, "::");
     return SWIG_OK;
   }
 
+// EXPERIMENTAL: we want to use Language::getNSpace() here
+// However, it is not working yet.
+// For namespace functions Language::getNSpace() does not give a valid result
+#if 0
+  JAVASCRIPT *lang = static_cast<JAVASCRIPT*>(Language::instance());
+  String *_nspace = lang->getNSpace();
+  if (!Equal(nspace, _nspace)) {
+    Printf(stdout, "##### Custom vs Language::getNSpace(): %s | %s\n", nspace, _nspace);
+    Swig_print_node(n);
+  }
+#endif
+
+  String *nspace = Getattr(n, "sym:nspace");
+
   if (nspace == NULL) {
     // It seems that only classes have 'sym:nspace' set.
     // We try to get the namespace from the qualified name (i.e., everything before the last '::')
@@ -1608,8 +1637,8 @@
 int JSCEmitter::exitFunction(Node *n) {
   Template t_function = getTemplate("jsc_function_declaration");
 
-  bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend");
-  bool is_overloaded = GetFlag(n, "sym:overloaded");
+  bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0;
+  bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
 
   // handle overloaded functions
   if (is_overloaded) {
@@ -2057,10 +2086,10 @@
 }
 
 int V8Emitter::exitFunction(Node *n) {
-  bool is_member = GetFlag(n, "ismember") | GetFlag(n, "feature:extend");
+  bool is_member = GetFlag(n, "ismember") != 0 || GetFlag(n, "feature:extend") != 0;
 
   // create a dispatcher for overloaded functions
-  bool is_overloaded = GetFlag(n, "sym:overloaded");
+  bool is_overloaded = GetFlag(n, "sym:overloaded") != 0;
   if (is_overloaded) {
     if (!Getattr(n, "sym:nextSibling")) {
       //state.function(WRAPPER_NAME, Swig_name_wrapper(Getattr(n, "name")));
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index 5ea79f0..3efd4e4 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -57,7 +57,9 @@
 /* Some status variables used during parsing */
 static int InClass = 0; /* Parsing C++ or not */
 static String *ClassName = 0;	/* This is the real name of the current class */
+static String *EnumClassName = 0; /* Enum class name */
 static String *ClassPrefix = 0;	/* Class prefix */
+static String *EnumClassPrefix = 0; /* Prefix for strongly typed enums (including ClassPrefix) */
 static String *NSpace = 0;	/* Namespace for the nspace feature */
 static String *ClassType = 0;	/* Fully qualified type name to use */
 static String *DirectorClassName = 0;	/* Director name of the current class */
@@ -1650,10 +1652,24 @@
   String *oldNSpace = NSpace;
   NSpace = Getattr(n, "sym:nspace");
 
+  String *oldEnumClassPrefix = EnumClassPrefix;
+  if (GetFlag(n, "scopedenum")) {
+    assert(Getattr(n, "sym:name"));
+    assert(Getattr(n, "name"));
+    EnumClassPrefix = ClassPrefix ? NewStringf("%s_", ClassPrefix) : NewString("");
+    Printv(EnumClassPrefix, Getattr(n, "sym:name"), NIL);
+    EnumClassName = Copy(Getattr(n, "name"));
+  }
   if (!ImportMode) {
     emit_children(n);
   }
 
+  if (GetFlag(n, "scopedenum")) {
+    Delete(EnumClassName);
+    EnumClassName = 0;
+    Delete(EnumClassPrefix);
+    EnumClassPrefix = oldEnumClassPrefix;
+  }
   NSpace = oldNSpace;
 
   return SWIG_OK;
@@ -1667,7 +1683,7 @@
   if (CurrentClass && (cplus_mode != PUBLIC))
     return SWIG_NOWRAP;
 
-  Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL);
+  Swig_require("enumvalueDeclaration", n, "*name", "*sym:name", "?value", NIL);
   String *value = Getattr(n, "value");
   String *name = Getattr(n, "name");
   String *tmpValue;
@@ -1678,6 +1694,13 @@
     tmpValue = NewString(name);
   Setattr(n, "value", tmpValue);
 
+  Node *parent = parentNode(n);
+  if (GetFlag(parent, "scopedenum")) {
+    String *symname = Swig_name_member(0, Getattr(parent, "sym:name"), Getattr(n, "sym:name"));
+    Setattr(n, "sym:name", symname);
+    Delete(symname);
+  }
+
   if (!CurrentClass || !cparse_cplusplus) {
     Setattr(n, "name", tmpValue);	/* for wrapping of enums in a namespace when emit_action is used */
     constantWrapper(n);
@@ -1716,16 +1739,19 @@
     Setattr(n, "feature:except", Getattr(n, "feature:exceptvar"));
   }
 
+  String *enumvalue_symname = Getattr(n, "enumvalueDeclaration:sym:name"); // Only set if a strongly typed enum
   String *name = Getattr(n, "name");
   String *symname = Getattr(n, "sym:name");
   String *value = Getattr(n, "value");
 
-  String *mrename = Swig_name_member(0, ClassPrefix, symname);
+  String *mrename = Swig_name_member(0, EnumClassPrefix, enumvalue_symname ? enumvalue_symname : symname);
   Setattr(n, "sym:name", mrename);
 
   String *new_name = 0;
   if (Extend)
     new_name = Copy(value);
+  else if (EnumClassName)
+    new_name = NewStringf("%s::%s", isNonVirtualProtectedAccess(n) ? DirectorClassName : EnumClassName, name);
   else
     new_name = NewStringf("%s::%s", isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName, name);
   Setattr(n, "name", new_name);
@@ -2043,7 +2069,7 @@
      needed, since there is a public constructor already defined.  
 
      (scottm) This code is needed here to make the director_abstract +
-     test generate compileable code (Example2 in director_abastract.i).
+     test generate compilable code (Example2 in director_abastract.i).
 
      (mmatus) This is very strange, since swig compiled with gcc3.2.3
      doesn't need it here....
@@ -2369,6 +2395,7 @@
   int oldInClass = InClass;
   String *oldClassType = ClassType;
   String *oldClassPrefix = ClassPrefix;
+  String *oldEnumClassPrefix = EnumClassPrefix;
   String *oldClassName = ClassName;
   String *oldDirectorClassName = DirectorClassName;
   String *oldNSpace = NSpace;
@@ -2410,6 +2437,7 @@
     Push(ClassPrefix, "_");
     Push(ClassPrefix, Getattr(outerClass, "sym:name"));
   }
+  EnumClassPrefix = Copy(ClassPrefix);
   if (strip) {
     ClassType = Copy(name);
   } else {
@@ -2477,6 +2505,8 @@
   CurrentClass = oldCurrentClass;
   Delete(ClassType);
   ClassType = oldClassType;
+  Delete(EnumClassPrefix);
+  EnumClassPrefix = oldEnumClassPrefix;
   Delete(ClassPrefix);
   ClassPrefix = oldClassPrefix;
   Delete(ClassName);
@@ -2664,7 +2694,8 @@
       String *scope = Swig_scopename_check(ClassName) ? Swig_scopename_prefix(ClassName) : 0;
       String *actual_name = scope ? NewStringf("%s::%s", scope, name) : NewString(name);
       Delete(scope);
-      if (!Equal(actual_name, expected_name) && !SwigType_istemplate(expected_name)) {
+      if (!Equal(actual_name, expected_name) && !SwigType_istemplate(expected_name) && !SwigType_istemplate(actual_name)) {
+	// Checking templates is skipped but they ought to be checked... they are just somewhat more tricky to check correctly
 	bool illegal_name = true;
 	if (Extend) {
 	  // Check for typedef names used as a constructor name in %extend. This is deprecated except for anonymous
@@ -2962,6 +2993,12 @@
   Delattr(n,"varset");
   Delattr(n,"varget");
 
+  String *newsymname = 0;
+  if (!CurrentClass && EnumClassPrefix) {
+    newsymname = Swig_name_member(0, EnumClassPrefix, symname);
+    symname = newsymname;
+  }
+
   /* If no way to set variables.  We simply create functions */
   int assignable = is_assignable(n);
   int flags = use_naturalvar_mode(n);
@@ -3019,6 +3056,7 @@
   functionWrapper(n);
   Delattr(n, "varget");
   Swig_restore(n);
+  Delete(newsymname);
   return SWIG_OK;
 }
 
@@ -3500,6 +3538,45 @@
 }
 
 /* -----------------------------------------------------------------------------
+ * Language::makeParameterName()
+ *
+ * Inputs: 
+ *   n - Node
+ *   p - parameter node
+ *   arg_num - parameter argument number
+ *   setter  - set this flag when wrapping variables
+ * Return:
+ *   arg - a unique parameter name
+ * ----------------------------------------------------------------------------- */
+String *Language::makeParameterName(Node *n, Parm *p, int arg_num, bool setter) const {
+
+  String *arg = 0;
+  String *pn = Getattr(p, "name");
+
+  // Use C parameter name unless it is a duplicate or an empty parameter name
+  int count = 0;
+  ParmList *plist = Getattr(n, "parms");
+  while (plist) {
+    if ((Cmp(pn, Getattr(plist, "name")) == 0))
+      count++;
+    plist = nextSibling(plist);
+  }
+  String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
+  arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
+
+  if (setter && Cmp(arg, "self") != 0) {
+    // Some languages (C#) insist on calling the input variable "value" while
+    // others (D, Java) could, in principle, use something different but this
+    // would require more work, and so we just use "value" for them too.
+    // For setters the parameter name sometimes includes C++ scope resolution which needs removing.
+    Delete(arg);
+    arg = NewString("value");
+  }
+
+  return arg;
+}
+
+/* -----------------------------------------------------------------------------
  * Language::()
  * ----------------------------------------------------------------------------- */
 
@@ -3517,9 +3594,22 @@
   return true;
 }
 
+/* -----------------------------------------------------------------------------
+ * Language::nestedClassesSupport()
+ * ----------------------------------------------------------------------------- */
+
 Language::NestedClassSupport Language::nestedClassesSupport() const {
   return NCS_Unknown;
 }
+
+/* -----------------------------------------------------------------------------
+ * Language::kwargsSupport()
+ * ----------------------------------------------------------------------------- */
+
+bool Language::kwargsSupport() const {
+  return false;
+}
+
 /* -----------------------------------------------------------------------------
  * Language::is_wrapping_class()
  * ----------------------------------------------------------------------------- */
@@ -3561,6 +3651,14 @@
 }
 
 /* -----------------------------------------------------------------------------
+ * Language::getEnumClassPrefix()
+ * ----------------------------------------------------------------------------- */
+
+String *Language::getEnumClassPrefix() const {
+  return EnumClassPrefix;
+}
+
+/* -----------------------------------------------------------------------------
  * Language::getClassType()
  * ----------------------------------------------------------------------------- */
 
diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
index 46e21fb..8211fb3 100644
--- a/Source/Modules/lua.cxx
+++ b/Source/Modules/lua.cxx
@@ -1184,10 +1184,12 @@
     if (getCurrentClass() && (cplus_mode != PUBLIC))
       return SWIG_NOWRAP;
 
-    Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL);
+    Swig_require("enumvalueDeclaration", n, "*name", "?value", "*sym:name", NIL);
+    String *symname = Getattr(n, "sym:name");
     String *value = Getattr(n, "value");
     String *name = Getattr(n, "name");
     String *tmpValue;
+    Node *parent = parentNode(n);
 
     if (value)
       tmpValue = NewString(value);
@@ -1196,6 +1198,13 @@
     Setattr(n, "value", tmpValue);
 
     Setattr(n, "name", tmpValue);	/* for wrapping of enums in a namespace when emit_action is used */
+
+    if (GetFlag(parent, "scopedenum")) {
+      symname = Swig_name_member(0, Getattr(parent, "sym:name"), symname);
+      Setattr(n, "sym:name", symname);
+      Delete(symname);
+    }
+
     int result = constantWrapper(n);
 
     Delete(tmpValue);
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index 833394b..aa0d7d5 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -50,6 +50,7 @@
 extern "C" {
   extern String *ModuleName;
   extern int ignore_nested_classes;
+  extern int kwargs_supported;
 }
 
 /* usage string split into multiple parts otherwise string is too big for some compilers */
@@ -62,6 +63,8 @@
      -co <file>      - Check <file> out of the SWIG library\n\
      -copyctor       - Automatically generate copy constructors wherever possible\n\
      -cpperraswarn   - Treat the preprocessor #error statement as #warning (default)\n\
+     -cppext <ext>   - Change file extension of generated C++ files to <ext>\n\
+                       (default is cxx, except for PHP which uses cpp)\n\
      -copyright      - Display copyright notices\n\
      -debug-classes  - Display information about the classes found in the interface\n\
      -debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages\n\
@@ -79,6 +82,9 @@
      -directors      - Turn on director mode for all the classes, mainly for testing\n\
      -dirprot        - Turn on wrapping of protected members for director classes (default)\n\
      -D<symbol>      - Define a symbol <symbol> (for conditional compilation)\n\
+";
+
+static const char *usage2 = (const char *) "\
      -E              - Preprocess only, does not generate wrapper code\n\
      -external-runtime [file] - Export the SWIG runtime stack\n\
      -fakeversion <v>- Make SWIG fake the program version number to <v>\n\
@@ -86,9 +92,6 @@
      -features <list>- Set global features, where <list> is a comma separated list of\n\
                        features, eg -features directors,autodoc=1\n\
                        If no explicit value is given to the feature, a default of 1 is used\n\
-";
-
-static const char *usage2 = (const char *) "\
      -fastdispatch   - Enable fast dispatch mode to produce faster overload dispatcher code\n\
      -Fmicrosoft     - Display error/warning messages in Microsoft format\n\
      -Fstandard      - Display error/warning messages in commonly used format\n\
@@ -100,6 +103,9 @@
      -importall      - Follow all #include statements as imports\n\
      -includeall     - Follow all #include statements\n\
      -l<ifile>       - Include SWIG library file <ifile>\n\
+";
+
+static const char *usage3 = (const char *) "\
      -macroerrors    - Report errors inside macros\n\
      -makedefault    - Create default constructors/destructors (the default)\n\
      -M              - List all dependencies\n\
@@ -119,10 +125,10 @@
      -noexcept       - Do not wrap exception specifiers\n\
      -nofastdispatch - Disable fast dispatch mode (default)\n\
      -nopreprocess   - Skip the preprocessor step\n\
+     -notemplatereduce - Disable reduction of the typedefs in templates\n\
 ";
 
-static const char *usage3 = (const char *) "\
-     -notemplatereduce - Disable reduction of the typedefs in templates\n\
+static const char *usage4 = (const char *) "\
      -O              - Enable the optimization options: \n\
                         -fastdispatch -fvirtual \n\
      -o <outfile>    - Set name of the output file to <outfile>\n\
@@ -677,6 +683,15 @@
       } else if (strcmp(argv[i], "-nocpperraswarn") == 0) {
 	Preprocessor_error_as_warning(0);
 	Swig_mark_arg(i);
+      } else if (strcmp(argv[i], "-cppext") == 0) {
+	Swig_mark_arg(i);
+	if (argv[i + 1]) {
+	  SWIG_config_cppext(argv[i + 1]);
+	  Swig_mark_arg(i + 1);
+	  i++;
+	} else {
+	  Swig_arg_error();
+	}
       } else if ((strcmp(argv[i], "-debug-typemap") == 0) || (strcmp(argv[i], "-debug_typemap") == 0) || (strcmp(argv[i], "-tm_debug") == 0)) {
 	tm_debug = 1;
 	Swig_mark_arg(i);
@@ -850,6 +865,7 @@
 	fputs(usage1, stdout);
 	fputs(usage2, stdout);
 	fputs(usage3, stdout);
+	fputs(usage4, stdout);
 	Swig_mark_arg(i);
 	help = 1;
       }
@@ -904,6 +920,8 @@
   // Inform the parser if the nested classes should be ignored unless explicitly told otherwise via feature:flatnested
   ignore_nested_classes = l->nestedClassesSupport() == Language::NCS_Unknown ? 1 : 0;
 
+  kwargs_supported = l->kwargsSupport() ? 1 : 0;
+
   // Create Library search directories
 
   // Check for SWIG_LIB environment variable
@@ -1172,6 +1190,7 @@
 	Printf(stdout, "Processing unnamed structs...\n");
       Swig_nested_name_unnamed_c_structs(top);
     }
+    Swig_extend_unused_check();
 
     if (Verbose) {
       Printf(stdout, "Processing types...\n");
diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
index db5d098..d9a0c92 100644
--- a/Source/Modules/modula3.cxx
+++ b/Source/Modules/modula3.cxx
@@ -1407,25 +1407,12 @@
       }
     }
 
-    if (Cmp(nodeType(n), "constant") == 0) {
-      // Wrapping a constant hack
-      Swig_save("functionWrapper", n, "wrap:action", NIL);
-
-      // below based on Swig_VargetToFunction()
-      SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
-      Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
-    }
-
     Setattr(n, "wrap:name", wname);
 
     // Now write code to make the function call
     if (!native_function_flag) {
       String *actioncode = emit_action(n);
 
-      if (Cmp(nodeType(n), "constant") == 0) {
-        Swig_restore(n);
-      }
-
       /* Return value if necessary  */
       String *tm;
       if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
@@ -3622,35 +3609,6 @@
   }
 
   /* -----------------------------------------------------------------------------
-   * makeParameterName()
-   *
-   * Inputs: 
-   *   n - Node
-   *   p - parameter node
-   *   arg_num - parameter argument number
-   * Return:
-   *   arg - a unique parameter name
-   * ----------------------------------------------------------------------------- */
-
-  String *makeParameterName(Node *n, Parm *p, int arg_num) {
-
-    // Use C parameter name unless it is a duplicate or an empty parameter name
-    String *pn = Getattr(p, "name");
-    int count = 0;
-    ParmList *plist = Getattr(n, "parms");
-    while (plist) {
-      if ((Cmp(pn, Getattr(plist, "name")) == 0))
-	count++;
-      plist = nextSibling(plist);
-    }
-    String *arg = (!pn || (count > 1)) ? NewStringf("arg%d",
-						    arg_num) : Copy(Getattr(p,
-									    "name"));
-
-    return arg;
-  }
-
-  /* -----------------------------------------------------------------------------
    * attachParameterNames()
    *
    * Inputs: 
diff --git a/Source/Modules/nested.cxx b/Source/Modules/nested.cxx
index 3b45e9f..c4ab6a8 100644
--- a/Source/Modules/nested.cxx
+++ b/Source/Modules/nested.cxx
@@ -362,7 +362,15 @@
 	  Delete(bases);
 	}
 	Setattr(classhash, name, c);
+
+	// Merge the extension into the symbol table
+	if (Node *am = Getattr(Swig_extend_hash(), name)) {
+	  Swig_extend_merge(c, am);
+	  Swig_extend_append_previous(c, am);
+	  Delattr(Swig_extend_hash(), name);
+	}
 	Swig_symbol_popscope();
+
 	// process declarations following this type (assign correct new type)
 	SwigType *ty = Copy(name);
 	Node *decl = nextSibling(c);
@@ -376,16 +384,6 @@
 	  decl = nextSibling(decl);
 	}
 	Delete(ty);
-	// Check for extensions
-/*	// TODO: we can save extensions hash like class hash and move check_extensions() after nesting processing
-	if (extendhash) {
-	  if (Node *am = Getattr(extendhash, name)) {
-	    // Merge the extension into the symbol table
-	    merge_extensions(c, am);
-	    append_previous_extension(c, am);
-	    Delattr(extendhash, clsname);
-	  }
-	}*/
 	Swig_symbol_setscope(Swig_symbol_global_scope());
 	add_symbols_c(c);
 
@@ -396,7 +394,12 @@
 	Delete(ins);
 	Delattr(c, "nested:outer");
       } else {
-	// global unnamed struct - ignore it
+	// global unnamed struct - ignore it and it's instances
+	SetFlag(c, "feature:ignore");
+	while (next && Getattr(next, "nested:unnamedtype") == c) {
+	  SetFlag(next, "feature:ignore");
+	  next = nextSibling(next);
+	}
 	c = next;
 	continue;
       }
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
index f1ec8a8..ac73c1f 100644
--- a/Source/Modules/ocaml.cxx
+++ b/Source/Modules/ocaml.cxx
@@ -19,7 +19,7 @@
 Ocaml Options (available with -ocaml)\n\
      -oldvarnames    - Old intermediary method names for variable wrappers\n\
      -prefix <name>  - Set a prefix <name> to be prepended to all names\n\
-     -suffix <name>  - Change .cxx to something else\n\
+     -suffix <name>  - Deprecated alias for general option -cppext\n\
      -where          - Emit library location\n\
 \n";
 
@@ -114,6 +114,7 @@
 	  }
 	} else if (strcmp(argv[i], "-suffix") == 0) {
 	  if (argv[i + 1]) {
+	    Printf(stderr, "swig: warning: -suffix option deprecated.  SWIG 3.0.4 and later provide a -cppext option which should be used instead.\n");
 	    SWIG_config_cppext(argv[i + 1]);
 	    Swig_mark_arg(i);
 	    Swig_mark_arg(i + 1);
@@ -1350,9 +1351,6 @@
 
   /*
    * Modified polymorphism code for Ocaml language module.
-   * Original:
-   * C++/Python polymorphism demo code, copyright (C) 2002 Mark Rose 
-   * <mrose@stm.lbl.gov>
    *
    * TODO
    *
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index 103b591..1290316 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * This file is part of SWIG, which is licensed as a whole under version 3 
+ * This file is part of SWIG, which is licensed as a whole under version 3
  * (or any later version) of the GNU General Public License. Some additional
  * terms also apply to certain portions of SWIG. The full details of the SWIG
  * license and copyrights can be found in the LICENSE and COPYRIGHT files
@@ -75,51 +75,44 @@
     constructor_name(0),
     docs(0)
   {
-     /* Add code to manage protected constructors and directors */
-     director_prot_ctor_code = NewString("");
-     Printv(director_prot_ctor_code,
-	    "if ( $comparison ) { /* subclassed */\n",
-	    "  $director_new \n",
-	    "} else {\n", "  error(\"accessing abstract class or protected constructor\"); \n", "  SWIG_fail;\n", "}\n", NIL);
+    /* Add code to manage protected constructors and directors */
+    director_prot_ctor_code = NewString("");
+    Printv(director_prot_ctor_code,
+           "if ( $comparison ) { /* subclassed */\n",
+           "  $director_new \n",
+           "} else {\n", "  error(\"accessing abstract class or protected constructor\"); \n", "  SWIG_fail;\n", "}\n", NIL);
 
-     enable_cplus_runtime_mode();
-     allow_overloading();
-     director_multiple_inheritance = 1;
-     director_language = 1;
-     docs = NewHash();
-   }
+    enable_cplus_runtime_mode();
+    allow_overloading();
+    director_multiple_inheritance = 1;
+    director_language = 1;
+    docs = NewHash();
+  }
 
   virtual void main(int argc, char *argv[]) {
     for (int i = 1; i < argc; i++) {
       if (argv[i]) {
-	if (strcmp(argv[i], "-help") == 0) {
-	  fputs(usage, stdout);
-	} else if (strcmp(argv[i], "-global") == 0 ||
-                   strcmp(argv[i], "-noglobal") == 0) {
-	  Printv(stderr,
-                 "*** -global/-noglobal are no longer supported\n"
-                 "*** global load behaviour is now determined at module load\n"
-                 "*** see the Perl section in the manual for details.\n", NIL);
-	  SWIG_exit(EXIT_FAILURE);
-	} else if (strcmp(argv[i], "-globals") == 0) {
-	  if (argv[i + 1]) {
-	    global_name = NewString(argv[i + 1]);
-	    Swig_mark_arg(i);
-	    Swig_mark_arg(i + 1);
-	    i++;
-	  } else {
-	    Swig_arg_error();
-	  }
-	} else if (strcmp(argv[i], "-opprefix") == 0) {
-	  if (argv[i + 1]) {
-	    op_prefix = NewString(argv[i + 1]);
-	    Swig_mark_arg(i);
-	    Swig_mark_arg(i + 1);
-	    i++;
-	  } else {
-	    Swig_arg_error();
-	  }
-        }            
+        if (strcmp(argv[i], "-help") == 0) {
+          fputs(usage, stdout);
+        } else if (strcmp(argv[i], "-globals") == 0) {
+          if (argv[i + 1]) {
+            global_name = NewString(argv[i + 1]);
+            Swig_mark_arg(i);
+            Swig_mark_arg(i + 1);
+            i++;
+          } else {
+            Swig_arg_error();
+          }
+        } else if (strcmp(argv[i], "-opprefix") == 0) {
+          if (argv[i + 1]) {
+            op_prefix = NewString(argv[i + 1]);
+            Swig_mark_arg(i);
+            Swig_mark_arg(i + 1);
+            i++;
+          } else {
+            Swig_arg_error();
+          }
+        }
       }
     }
 
@@ -143,21 +136,21 @@
     {
       Node *mod = Getattr(n, "module");
       if (mod) {
-	Node *options = Getattr(mod, "options");
-	if (options) {
-	  int dirprot = 0;
-	  if (Getattr(options, "dirprot")) {
-	    dirprot = 1;
-	  }
-	  if (Getattr(options, "nodirprot")) {
-	    dirprot = 0;
-	  }
-	  if (Getattr(options, "directors")) {
-	    allow_directors();
-	    if (dirprot)
-	      allow_dirprot();
-	  }
-	}
+        Node *options = Getattr(mod, "options");
+        if (options) {
+          int dirprot = 0;
+          if (Getattr(options, "dirprot")) {
+            dirprot = 1;
+          }
+          if (Getattr(options, "nodirprot")) {
+            dirprot = 0;
+          }
+          if (Getattr(options, "directors")) {
+            allow_directors();
+            if (dirprot)
+              allow_dirprot();
+          }
+        }
       }
     }
 
@@ -202,8 +195,8 @@
       Printf(f_runtime, "#define SWIG_DIRECTORS\n");
       Swig_banner(f_directors_h);
       if (dirprot_mode()) {
-	//      Printf(f_directors_h, "#include <map>\n");
-	//      Printf(f_directors_h, "#include <string>\n\n");
+        //      Printf(f_directors_h, "#include <map>\n");
+        //      Printf(f_directors_h, "#include <string>\n\n");
       }
     }
 
@@ -263,19 +256,19 @@
     String *r = NewString("");
     for (int j=0;s[j];++j) {
       if (s[j] == '\n') {
-	Append(r, "\\n\\\n");
+        Append(r, "\\n\\\n");
       } else if (s[j] == '\r') {
-	Append(r, "\\r");
+        Append(r, "\\r");
       } else if (s[j] == '\t') {
-	Append(r, "\\t");
+        Append(r, "\\t");
       } else if (s[j] == '\\') {
-	Append(r, "\\\\");
+        Append(r, "\\\\");
       } else if (s[j] == '\'') {
-	Append(r, "\\\'");
+        Append(r, "\\\'");
       } else if (s[j] == '\"') {
-	Append(r, "\\\"");
+        Append(r, "\\\"");
       } else
-	Putc(s[j], r);
+        Putc(s[j], r);
     }
     return r;
   }
@@ -293,11 +286,11 @@
       String *escaped_doc_str = texinfo_escape(doc_str);
 
       if (Len(doc_str)>0) {
-	Printf(f_doc,"static const char* %s_texinfo = ",wrap_name);
-	Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str);
-	if (Len(decl_info))
-	  Printf(f_doc,"\\n\\\n@end deftypefn");
-	Printf(f_doc,"\";\n");
+        Printf(f_doc,"static const char* %s_texinfo = ",wrap_name);
+        Printf(f_doc,"\"-*- texinfo -*-\\n\\\n%s", escaped_doc_str);
+        if (Len(decl_info))
+          Printf(f_doc,"\\n\\\n@end deftypefn");
+        Printf(f_doc,"\";\n");
       }
 
       Delete(escaped_doc_str);
@@ -313,7 +306,7 @@
     String *decl_info = Getattr(n, "decl_info");
     String *cdecl_info = Getattr(n, "cdecl_info");
     String *args_info = Getattr(n, "args_info");
-    return !Len(synopsis) && !Len(decl_info) && 
+    return !Len(synopsis) && !Len(decl_info) &&
       !Len(cdecl_info) && !Len(args_info);
   }
   String *texinfo_name(Node* n, const char* defval = "0") {
@@ -360,11 +353,11 @@
 
       SwigType *type = Getattr(n, "type");
       if (type && Strcmp(type, "void")) {
-	Node *nn = classLookup(Getattr(n, "type"));
-	String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
-	Append(decl_info, "@var{retval} = ");
-	Printf(args_str, "%s@var{retval} is of type %s. ", args_str, type_str);
-	Delete(type_str);
+        Node *nn = classLookup(Getattr(n, "type"));
+        String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
+        Append(decl_info, "@var{retval} = ");
+        Printf(args_str, "%s@var{retval} is of type %s. ", args_str, type_str);
+        Delete(type_str);
       }
 
       Append(decl_info, name);
@@ -380,8 +373,8 @@
       // strip off {} if necessary
       char *t = Char(str);
       if (*t == '{') {
-	Delitem(str, 0);
-	Delitem(str, DOH_END);
+        Delitem(str, 0);
+        Delitem(str, DOH_END);
       }
 
       // emit into synopsis section
@@ -408,7 +401,7 @@
    * addMissingParameterNames()
    *  For functions that have not had nameless parameters set in the Language class.
    *
-   * Inputs: 
+   * Inputs:
    *   plist - entire parameter list
    *   arg_offset - argument number for first parameter
    * Side effects:
@@ -420,8 +413,8 @@
     int i = arg_offset;
     while (p) {
       if (!Getattr(p, "lname")) {
-	String *pname = Swig_cparm_name(p, i);
-	Delete(pname);
+        String *pname = Swig_cparm_name(p, i);
+        Delete(pname);
       }
       i++;
       p = nextSibling(p);
@@ -444,12 +437,12 @@
 
       String *tm = Getattr(p, "tmap:in");
       if (tm) {
-	pnext = Getattr(p, "tmap:in:next");
-	if (checkAttribute(p, "tmap:in:numinputs", "0")) {
-	  continue;
-	}
+        pnext = Getattr(p, "tmap:in:next");
+        if (checkAttribute(p, "tmap:in:numinputs", "0")) {
+          continue;
+        }
       } else {
-	pnext = nextSibling(p);
+        pnext = nextSibling(p);
       }
 
       String *name = 0;
@@ -457,9 +450,9 @@
       String *value = 0;
       String *pdoc = Getattr(p, "tmap:doc");
       if (pdoc) {
-	name = Getattr(p, "tmap:doc:name");
-	type = Getattr(p, "tmap:doc:type");
-	value = Getattr(p, "tmap:doc:value");
+        name = Getattr(p, "tmap:doc:name");
+        type = Getattr(p, "tmap:doc:type");
+        value = Getattr(p, "tmap:doc:value");
       }
 
       // Note: the generated name should be consistent with that in kwnames[]
@@ -471,28 +464,28 @@
       value = value ? value : Getattr(p, "value");
 
       if (SwigType_isvarargs(type))
-	break;
+        break;
 
       String *tex_name = NewString("");
       if (name)
-	Printf(tex_name, "@var{%s}", name);
+        Printf(tex_name, "@var{%s}", name);
       else
-	Printf(tex_name, "@var{?}");
+        Printf(tex_name, "@var{?}");
 
       if (Len(decl_str))
-	Append(decl_str, ", ");
+        Append(decl_str, ", ");
       Append(decl_str, tex_name);
 
       if (value) {
-	String *new_value = convertValue(value, Getattr(p, "type"));
-	if (new_value) {
-	  value = new_value;
-	} else {
-	  Node *lookup = Swig_symbol_clookup(value, 0);
-	  if (lookup)
-	    value = Getattr(lookup, "sym:name");
-	}
-	Printf(decl_str, " = %s", value);
+        String *new_value = convertValue(value, Getattr(p, "type"));
+        if (new_value) {
+          value = new_value;
+        } else {
+          Node *lookup = Swig_symbol_clookup(value, 0);
+          if (lookup)
+            value = Getattr(lookup, "sym:name");
+        }
+        Printf(decl_str, " = %s", value);
       }
 
       Node *nn = classLookup(Getattr(p, "type"));
@@ -517,18 +510,18 @@
     if (v && Len(v) > 0) {
       char fc = (Char(v))[0];
       if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
-	/* number or string (or maybe NULL pointer) */
-	if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
-	  return NewString("None");
-	else
-	  return v;
+        /* number or string (or maybe NULL pointer) */
+        if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
+          return NewString("None");
+        else
+          return v;
       }
       if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
-	return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
+        return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
       if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
-	return NewString("true");
+        return NewString("true");
       if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
-	return NewString("false");
+        return NewString("false");
     }
     return 0;
   }
@@ -572,89 +565,89 @@
     int varargs = emit_isvarargs(l);
     char source[64];
 
-    Printf(f->code, "if (!SWIG_check_num_args(\"%s\",args.length(),%i,%i,%i)) " 
-	   "{\n SWIG_fail;\n }\n", iname, num_arguments, num_required, varargs);
+    Printf(f->code, "if (!SWIG_check_num_args(\"%s\",args.length(),%i,%i,%i)) "
+           "{\n SWIG_fail;\n }\n", iname, num_arguments, num_required, varargs);
 
     if (constructor && num_arguments == 1 && num_required == 1) {
       if (Cmp(storage, "explicit") == 0) {
-	Node *parent = Swig_methodclass(n);
-	if (GetFlag(parent, "feature:implicitconv")) {
-	  String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n, "type")));
-	  Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc);
-	  Delete(desc);
-	}
+        Node *parent = Swig_methodclass(n);
+        if (GetFlag(parent, "feature:implicitconv")) {
+          String *desc = NewStringf("SWIGTYPE%s", SwigType_manglestr(Getattr(n, "type")));
+          Printf(f->code, "if (SWIG_CheckImplicit(%s)) SWIG_fail;\n", desc);
+          Delete(desc);
+        }
       }
     }
 
     for (j = 0, p = l; j < num_arguments; ++j) {
       while (checkAttribute(p, "tmap:in:numinputs", "0")) {
-	p = Getattr(p, "tmap:in:next");
+        p = Getattr(p, "tmap:in:next");
       }
 
       SwigType *pt = Getattr(p, "type");
 
       String *tm = Getattr(p, "tmap:in");
       if (tm) {
-	if (!tm || checkAttribute(p, "tmap:in:numinputs", "0")) {
-	  p = nextSibling(p);
-	  continue;
-	}
+        if (!tm || checkAttribute(p, "tmap:in:numinputs", "0")) {
+          p = nextSibling(p);
+          continue;
+        }
 
-	sprintf(source, "args(%d)", j);
-	Setattr(p, "emit:input", source);
+        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"));
+        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");
-	} else {
-	  Replaceall(tm, "$disown", "0");
-	}
+        if (Getattr(p, "wrap:disown") || (Getattr(p, "tmap:in:disown"))) {
+          Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN");
+        } else {
+          Replaceall(tm, "$disown", "0");
+        }
 
-	if (Getattr(p, "tmap:in:implicitconv")) {
-	  const char *convflag = "0";
-	  if (!Getattr(p, "hidden")) {
-	    SwigType *ptype = Getattr(p, "type");
-	    convflag = get_implicitconv_flag(classLookup(ptype));
-	  }
-	  Replaceall(tm, "$implicitconv", convflag);
-	  Setattr(p, "implicitconv", convflag);
-	}
+        if (Getattr(p, "tmap:in:implicitconv")) {
+          const char *convflag = "0";
+          if (!Getattr(p, "hidden")) {
+            SwigType *ptype = Getattr(p, "type");
+            convflag = get_implicitconv_flag(classLookup(ptype));
+          }
+          Replaceall(tm, "$implicitconv", convflag);
+          Setattr(p, "implicitconv", convflag);
+        }
 
-	String *getargs = NewString("");
-	if (j >= num_required)
-	  Printf(getargs, "if (%d<args.length()) {\n%s\n}", j, tm);
-	else
-	  Printv(getargs, tm, NIL);
-	Printv(f->code, getargs, "\n", NIL);
-	Delete(getargs);
+        String *getargs = NewString("");
+        if (j >= num_required)
+          Printf(getargs, "if (%d<args.length()) {\n%s\n}", j, tm);
+        else
+          Printv(getargs, tm, NIL);
+        Printv(f->code, getargs, "\n", NIL);
+        Delete(getargs);
 
-	p = Getattr(p, "tmap:in:next");
-	continue;
+        p = Getattr(p, "tmap:in:next");
+        continue;
       } else {
-	Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
-	break;
+        Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0));
+        break;
       }
     }
 
     // Check for trailing varargs
     if (varargs) {
       if (p && (tm = Getattr(p, "tmap:in"))) {
-	Replaceall(tm, "$input", "varargs");
-	Printv(f->code, tm, "\n", NIL);
+        Replaceall(tm, "$input", "varargs");
+        Printv(f->code, tm, "\n", NIL);
       }
     }
 
     // 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");
+        Replaceall(tm, "$target", Getattr(p, "lname"));
+        Printv(f->code, tm, "\n", NIL);
+        p = Getattr(p, "tmap:check:next");
       } else {
-	p = nextSibling(p);
+        p = nextSibling(p);
       }
     }
 
@@ -662,23 +655,23 @@
     String *cleanup = NewString("");
     for (p = l; p;) {
       if ((tm = Getattr(p, "tmap:freearg"))) {
-	if (Getattr(p, "tmap:freearg:implicitconv")) {
-	  const char *convflag = "0";
-	  if (!Getattr(p, "hidden")) {
-	    SwigType *ptype = Getattr(p, "type");
-	    convflag = get_implicitconv_flag(classLookup(ptype));
-	  }
-	  if (strcmp(convflag, "0") == 0) {
-	    tm = 0;
-	  }
-	}
-	if (tm && (Len(tm) != 0)) {
-	  Replaceall(tm, "$source", Getattr(p, "lname"));
-	  Printv(cleanup, tm, "\n", NIL);
-	}
-	p = Getattr(p, "tmap:freearg:next");
+        if (Getattr(p, "tmap:freearg:implicitconv")) {
+          const char *convflag = "0";
+          if (!Getattr(p, "hidden")) {
+            SwigType *ptype = Getattr(p, "type");
+            convflag = get_implicitconv_flag(classLookup(ptype));
+          }
+          if (strcmp(convflag, "0") == 0) {
+            tm = 0;
+          }
+        }
+        if (tm && (Len(tm) != 0)) {
+          Replaceall(tm, "$source", Getattr(p, "lname"));
+          Printv(cleanup, tm, "\n", NIL);
+        }
+        p = Getattr(p, "tmap:freearg:next");
       } else {
-	p = nextSibling(p);
+        p = nextSibling(p);
       }
     }
 
@@ -686,15 +679,15 @@
     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"));
-	Printv(outarg, tm, "\n", NIL);
-	p = Getattr(p, "tmap:argout:next");
+        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"));
+        Printv(outarg, tm, "\n", NIL);
+        p = Getattr(p, "tmap:argout:next");
       } else {
-	p = nextSibling(p);
+        p = nextSibling(p);
       }
     }
 
@@ -720,9 +713,9 @@
       Replaceall(tm, "$result", "_outv");
 
       if (GetFlag(n, "feature:new"))
-	Replaceall(tm, "$owner", "1");
+        Replaceall(tm, "$owner", "1");
       else
-	Replaceall(tm, "$owner", "0");
+        Replaceall(tm, "$owner", "0");
 
       Printf(f->code, "%s\n", tm);
       Printf(f->code, "if (_outv.is_defined()) _outp = " "SWIG_Octave_AppendOutput(_outp, _outv);\n");
@@ -737,8 +730,8 @@
 
     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);
+        Replaceall(tm, "$source", Swig_cresult_name());
+        Printf(f->code, "%s\n", tm);
       }
     }
 
@@ -830,16 +823,16 @@
     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));
-	}
-	emit_action_code(n, setf->code, tm);
-	Delete(tm);
+        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));
+        }
+        emit_action_code(n, setf->code, tm);
+        Delete(tm);
       } else {
-	Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
+        Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
       }
       Append(setf->code, "fail:\n");
       Printf(setf->code, "return octave_value_list();\n");
@@ -995,18 +988,18 @@
       int index = 0;
       b = First(baselist);
       while (b.item) {
-	String *bname = Getattr(b.item, "name");
-	if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) {
-	  b = Next(b);
-	  continue;
-	}
+        String *bname = Getattr(b.item, "name");
+        if ((!bname) || GetFlag(b.item, "feature:ignore") || (!Getattr(b.item, "module"))) {
+          b = Next(b);
+          continue;
+        }
 
-	String *bname_mangled = SwigType_manglestr(SwigType_add_pointer(Copy(bname)));
-	Printf(base_class_names, "\"%s\",", bname_mangled);
-	Printf(base_class, "0,");
-	b = Next(b);
-	index++;
-	Delete(bname_mangled);
+        String *bname_mangled = SwigType_manglestr(SwigType_add_pointer(Copy(bname)));
+        Printf(base_class_names, "\"%s\",", bname_mangled);
+        Printf(base_class, "0,");
+        b = Next(b);
+        index++;
+        Delete(bname_mangled);
       }
     }
 
@@ -1063,8 +1056,8 @@
       bool overloaded = !!Getattr(n, "sym:overloaded");
       if (overloaded)
         Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
-      Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n", 
-	     realname, rname, tname);
+      Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n",
+             realname, rname, tname);
       Delete(rname);
       Delete(tname);
     }
@@ -1112,7 +1105,7 @@
       Delete(name);
       Setattr(self, "lname", "self_obj");
       if (parms)
-	set_nextSibling(self, parms);
+        set_nextSibling(self, parms);
       Setattr(n, "parms", self);
       Setattr(n, "wrap:self", "1");
       Setattr(n, "hidden", "1");
@@ -1144,12 +1137,12 @@
       bool overloaded = !!Getattr(n, "sym:overloaded");
       if (overloaded)
         Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
-      Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n", 
-	     realname, rname, tname);
+      Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n",
+             realname, rname, tname);
       Delete(rname);
       Delete(tname);
     }
-    
+
     return SWIG_OK;
   }
 
@@ -1217,24 +1210,24 @@
     if (!Getattr(n, "defaultargs")) {
       // constructor
       {
-	Wrapper *w = NewWrapper();
-	String *call;
-	String *basetype = Getattr(parent, "classtype");
-	String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
-	call = Swig_csuperclass_call(0, basetype, superparms);
-	Printf(w->def, "%s::%s: %s," "\nSwig::Director(static_cast<%s*>(this)) { \n", classname, target, call, basetype);
-	Append(w->def, "}\n");
-	Delete(target);
-	Wrapper_print(w, f_directors);
-	Delete(call);
-	DelWrapper(w);
+        Wrapper *w = NewWrapper();
+        String *call;
+        String *basetype = Getattr(parent, "classtype");
+        String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
+        call = Swig_csuperclass_call(0, basetype, superparms);
+        Printf(w->def, "%s::%s: %s," "\nSwig::Director(static_cast<%s*>(this)) { \n", classname, target, call, basetype);
+        Append(w->def, "}\n");
+        Delete(target);
+        Wrapper_print(w, f_directors);
+        Delete(call);
+        DelWrapper(w);
       }
 
       // constructor header
       {
-	String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
-	Printf(f_directors_h, "    %s;\n", target);
-	Delete(target);
+        String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
+        Printf(f_directors_h, "    %s;\n", target);
+        Delete(target);
       }
     }
 
@@ -1250,7 +1243,7 @@
     {
       Wrapper *w = NewWrapper();
       Printf(w->def, "SwigDirector_%s::SwigDirector_%s(void* self) :"
-	     "\nSwig::Director((octave_swig_type*)self,static_cast<%s*>(this)) { \n", classname, classname, classname);
+             "\nSwig::Director((octave_swig_type*)self,static_cast<%s*>(this)) { \n", classname, classname, classname);
       Append(w->def, "}\n");
       Wrapper_print(w, f_directors);
       DelWrapper(w);
@@ -1283,7 +1276,7 @@
 
     if (Cmp(storage, "virtual") == 0) {
       if (Cmp(value, "0") == 0) {
-	pure_virtual = true;
+        pure_virtual = true;
       }
     }
 
@@ -1317,18 +1310,18 @@
       Append(declaration, " throw(");
 
       if (throw_parm_list)
-	Swig_typemap_attach_parms("throws", throw_parm_list, 0);
+        Swig_typemap_attach_parms("throws", throw_parm_list, 0);
       for (p = throw_parm_list; p; p = nextSibling(p)) {
-	if (Getattr(p, "tmap:throws")) {
-	  if (gencomma++) {
-	    Append(w->def, ", ");
-	    Append(declaration, ", ");
-	  }
-	  String *str = SwigType_str(Getattr(p, "type"), 0);
-	  Append(w->def, str);
-	  Append(declaration, str);
-	  Delete(str);
-	}
+        if (Getattr(p, "tmap:throws")) {
+          if (gencomma++) {
+            Append(w->def, ", ");
+            Append(declaration, ", ");
+          }
+          String *str = SwigType_str(Getattr(p, "type"), 0);
+          Append(w->def, str);
+          Append(declaration, str);
+          Delete(str);
+        }
       }
 
       Append(w->def, ")");
@@ -1338,27 +1331,27 @@
     Append(w->def, " {");
     Append(declaration, ";\n");
 
-    // declare method return value 
+    // declare method return value
     // if the return value is a reference or const reference, a specialized typemap must
     // handle it, including declaration of c_result ($result).
     if (!is_void) {
       if (!(ignored_method && !pure_virtual)) {
-	String *cres = SwigType_lstr(returntype, "c_result");
-	Printf(w->code, "%s;\n", cres);
-	Delete(cres);
+        String *cres = SwigType_lstr(returntype, "c_result");
+        Printf(w->code, "%s;\n", cres);
+        Delete(cres);
       }
     }
 
     if (ignored_method) {
       if (!pure_virtual) {
-	if (!is_void)
-	  Printf(w->code, "return ");
-	String *super_call = Swig_method_call(super, l);
-	Printf(w->code, "%s;\n", super_call);
-	Delete(super_call);
+        if (!is_void)
+          Printf(w->code, "return ");
+        String *super_call = Swig_method_call(super, l);
+        Printf(w->code, "%s;\n", super_call);
+        Delete(super_call);
       } else {
-	Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname),
-	       SwigType_namestr(name));
+        Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname),
+               SwigType_namestr(name));
       }
     } else {
       // attach typemaps to arguments (C/C++ -> Python)
@@ -1374,50 +1367,50 @@
 
       int outputs = 0;
       if (!is_void)
-	outputs++;
+        outputs++;
 
       // build argument list and type conversion string
       p = l;
       while (p) {
-	if (checkAttribute(p, "tmap:in:numinputs", "0")) {
-	  p = Getattr(p, "tmap:in:next");
-	  continue;
-	}
+        if (checkAttribute(p, "tmap:in:numinputs", "0")) {
+          p = Getattr(p, "tmap:in:next");
+          continue;
+        }
 
-	if (Getattr(p, "tmap:directorargout") != 0)
-	  outputs++;
+        if (Getattr(p, "tmap:directorargout") != 0)
+          outputs++;
 
-	String *pname = Getattr(p, "name");
-	String *ptype = Getattr(p, "type");
-	Wrapper_add_local(w, "tmpv", "octave_value tmpv");
+        String *pname = Getattr(p, "name");
+        String *ptype = Getattr(p, "type");
+        Wrapper_add_local(w, "tmpv", "octave_value tmpv");
 
-	if ((tm = Getattr(p, "tmap:directorin")) != 0) {
-	  String *parse = Getattr(p, "tmap:directorin:parse");
-	  if (!parse) {
-	    Setattr(p, "emit:directorinput", "tmpv");
-	    Replaceall(tm, "$input", "tmpv");
-	    Replaceall(tm, "$owner", "0");
-	    Printv(wrap_args, tm, "\n", NIL);
-	    Printf(wrap_args, "args.append(tmpv);\n");
-	    Putc('O', parse_args);
-	  } else {
-	    Append(parse_args, parse);
-	    Setattr(p, "emit:directorinput", pname);
-	    Replaceall(tm, "$input", pname);
-	    Replaceall(tm, "$owner", "0");
-	    if (Len(tm) == 0)
-	      Append(tm, pname);
-	  }
-	  p = Getattr(p, "tmap:directorin:next");
-	  continue;
-	} else if (Cmp(ptype, "void")) {
-	  Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number,
-		       "Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0),
-		       SwigType_namestr(c_classname), SwigType_namestr(name));
-	  status = SWIG_NOWRAP;
-	  break;
-	}
-	p = nextSibling(p);
+        if ((tm = Getattr(p, "tmap:directorin")) != 0) {
+          String *parse = Getattr(p, "tmap:directorin:parse");
+          if (!parse) {
+            Setattr(p, "emit:directorinput", "tmpv");
+            Replaceall(tm, "$input", "tmpv");
+            Replaceall(tm, "$owner", "0");
+            Printv(wrap_args, tm, "\n", NIL);
+            Printf(wrap_args, "args.append(tmpv);\n");
+            Putc('O', parse_args);
+          } else {
+            Append(parse_args, parse);
+            Setattr(p, "emit:directorinput", pname);
+            Replaceall(tm, "$input", pname);
+            Replaceall(tm, "$owner", "0");
+            if (Len(tm) == 0)
+              Append(tm, pname);
+          }
+          p = Getattr(p, "tmap:directorin:next");
+          continue;
+        } else if (Cmp(ptype, "void")) {
+          Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number,
+                       "Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0),
+                       SwigType_namestr(c_classname), SwigType_namestr(name));
+          status = SWIG_NOWRAP;
+          break;
+        }
+        p = nextSibling(p);
       }
 
       String *method_name = Getattr(n, "sym:name");
@@ -1438,45 +1431,45 @@
 
       // marshal return value
       if (!is_void) {
-	Printf(w->code, "if (out.length()<%d) {\n", outputs);
-	Printf(w->code, "Swig::DirectorTypeMismatchException::raise(\"Octave "
-	       "method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name);
-	Printf(w->code, "}\n");
+        Printf(w->code, "if (out.length()<%d) {\n", outputs);
+        Printf(w->code, "Swig::DirectorTypeMismatchException::raise(\"Octave "
+               "method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name);
+        Printf(w->code, "}\n");
 
-	tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
-	if (tm != 0) {
-	  char temp[24];
-	  sprintf(temp, "out(%d)", idx);
-	  Replaceall(tm, "$input", temp);
-	  //    Replaceall(tm, "$argnum", temp);
-	  Replaceall(tm, "$disown", Getattr(n, "wrap:disown") ? "SWIG_POINTER_DISOWN" : "0");
-	  if (Getattr(n, "tmap:directorout:implicitconv")) {
-	    Replaceall(tm, "$implicitconv", get_implicitconv_flag(n));
-	  }
-	  Replaceall(tm, "$result", "c_result");
-	  Printv(w->code, tm, "\n", NIL);
-	  Delete(tm);
-	} else {
-	  Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
-		       "Unable to use return type %s in director method %s::%s (skipping method).\n",
-		       SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
-	  status = SWIG_ERROR;
-	}
+        tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
+        if (tm != 0) {
+          char temp[24];
+          sprintf(temp, "out(%d)", idx);
+          Replaceall(tm, "$input", temp);
+          //    Replaceall(tm, "$argnum", temp);
+          Replaceall(tm, "$disown", Getattr(n, "wrap:disown") ? "SWIG_POINTER_DISOWN" : "0");
+          if (Getattr(n, "tmap:directorout:implicitconv")) {
+            Replaceall(tm, "$implicitconv", get_implicitconv_flag(n));
+          }
+          Replaceall(tm, "$result", "c_result");
+          Printv(w->code, tm, "\n", NIL);
+          Delete(tm);
+        } else {
+          Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
+                       "Unable to use return type %s in director method %s::%s (skipping method).\n",
+                       SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
+          status = SWIG_ERROR;
+        }
       }
       idx++;
 
       // marshal outputs
       for (p = l; p;) {
-	if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
-	  char temp[24];
-	  sprintf(temp, "out(%d)", idx);
-	  Replaceall(tm, "$result", temp);
-	  Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
-	  Printv(w->code, tm, "\n", NIL);
-	  p = Getattr(p, "tmap:directorargout:next");
-	} else {
-	  p = nextSibling(p);
-	}
+        if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
+          char temp[24];
+          sprintf(temp, "out(%d)", idx);
+          Replaceall(tm, "$result", temp);
+          Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
+          Printv(w->code, tm, "\n", NIL);
+          p = Getattr(p, "tmap:directorargout:next");
+        } else {
+          p = nextSibling(p);
+        }
       }
 
       Delete(parse_args);
@@ -1486,13 +1479,13 @@
 
     if (!is_void) {
       if (!(ignored_method && !pure_virtual)) {
-	String *rettype = SwigType_str(returntype, 0);
-	if (!SwigType_isreference(returntype)) {
-	  Printf(w->code, "return (%s) c_result;\n", rettype);
-	} else {
-	  Printf(w->code, "return (%s) *c_result;\n", rettype);
-	}
-	Delete(rettype);
+        String *rettype = SwigType_str(returntype, 0);
+        if (!SwigType_isreference(returntype)) {
+          Printf(w->code, "return (%s) c_result;\n", rettype);
+        } else {
+          Printf(w->code, "return (%s) *c_result;\n", rettype);
+        }
+        Delete(rettype);
       }
     }
 
@@ -1506,7 +1499,7 @@
       Replaceall(inline_extra_method, name, extra_method_name);
       Replaceall(inline_extra_method, ";\n", " {\n      ");
       if (!is_void)
-	Printf(inline_extra_method, "return ");
+        Printf(inline_extra_method, "return ");
       String *methodcall = Swig_method_call(super, l);
       Printv(inline_extra_method, methodcall, ";\n    }\n", NIL);
       Delete(methodcall);
@@ -1515,10 +1508,10 @@
     // emit the director method
     if (status == SWIG_OK) {
       if (!Getattr(n, "defaultargs")) {
-	Replaceall(w->code, "$symname", symname);
-	Wrapper_print(w, f_directors);
-	Printv(f_directors_h, declaration, NIL);
-	Printv(f_directors_h, inline_extra_method, NIL);
+        Replaceall(w->code, "$symname", symname);
+        Wrapper_print(w, f_directors);
+        Printv(f_directors_h, declaration, NIL);
+        Printv(f_directors_h, inline_extra_method, NIL);
       }
     }
     // clean up
diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx
index ff504d4..224c485 100644
--- a/Source/Modules/perl5.cxx
+++ b/Source/Modules/perl5.cxx
@@ -342,11 +342,18 @@
     Node *options = Getattr(mod, "options");
     module = Copy(Getattr(n,"name"));
 
+    String *underscore_module = Copy(module);
+    Replaceall(underscore_module,":","_");
+
+    if (verbose > 0) {
+      fprintf(stdout, "top: using namespace_module: %s\n", Char(namespace_module));
+    }
+
     if (directorsEnabled()) {
       Swig_banner(f_directors_h);
       Printf(f_directors_h, "\n");
-      Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module);
-      Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module);
+      Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", underscore_module);
+      Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", underscore_module);
       if (dirprot_mode()) {
 	Printf(f_directors_h, "#include <map>\n");
 	Printf(f_directors_h, "#include <string>\n\n");
@@ -379,13 +386,6 @@
 	fprintf(stdout, "top: No package found\n");
       }
     }
-    String *underscore_module = Copy(module);
-    Replaceall(underscore_module,":","_");
-
-    if (verbose > 0) {
-      fprintf(stdout, "top: using namespace_module: %s\n", Char(namespace_module));
-    }
-
     /* If we're in blessed mode, change the package name to "packagec" */
 
     if (blessed) {
@@ -2178,12 +2178,12 @@
 	SwigType_add_pointer(ptype);
 	String *mangle = SwigType_manglestr(ptype);
 
-	Wrapper_add_local(w, "self", "SV *self");
-	Printf(w->code, "self = SWIG_NewPointerObj(SWIG_as_voidptr(this), SWIGTYPE%s, SWIG_SHADOW);\n", mangle);
-	Printf(w->code, "sv_bless(self, gv_stashpv(swig_get_class(), 0));\n");
+	Wrapper_add_local(w, "swigself", "SV *swigself");
+	Printf(w->code, "swigself = SWIG_NewPointerObj(SWIG_as_voidptr(this), SWIGTYPE%s, SWIG_SHADOW);\n", mangle);
+	Printf(w->code, "sv_bless(swigself, gv_stashpv(swig_get_class(), 0));\n");
 	Delete(mangle);
 	Delete(ptype);
-	Append(pstack, "XPUSHs(self);\n");
+	Append(pstack, "XPUSHs(swigself);\n");
       }
 
       Parm *p;
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index b07c82d..a2f0e36 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -44,7 +44,6 @@
 
 static const char *usage = "\
 PHP Options (available with -php)\n\
-     -cppext <ext>    - Change C++ file extension to <ext> (default is cpp)\n\
      -noproxy         - Don't generate proxy classes.\n\
      -prefix <prefix> - Prepend <prefix> to all class names in PHP wrappers\n\
 \n";
@@ -221,15 +220,6 @@
 	} else {
 	  Swig_arg_error();
 	}
-      } else if (strcmp(argv[i], "-cppext") == 0) {
-	if (argv[i + 1]) {
-	  SWIG_config_cppext(argv[i + 1]);
-	  Swig_mark_arg(i);
-	  Swig_mark_arg(i + 1);
-	  i++;
-	} else {
-	  Swig_arg_error();
-	}
       } else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) {
 	shadow = 0;
 	Swig_mark_arg(i);
@@ -836,13 +826,6 @@
       Delete(args);
       args = NULL;
     }
-    if (is_member_director(n)) {
-      Wrapper_add_local(f, "director", "Swig::Director *director = 0");
-      Printf(f->code, "director = dynamic_cast<Swig::Director*>(arg1);\n");
-      Wrapper_add_local(f, "upcall", "bool upcall = false");
-      Printf(f->code, "upcall = !director->swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\");\n",
-	  prefix, Swig_class_name(Swig_methodclass(n)), name);
-    }
 
     // This generated code may be called:
     // 1) as an object method, or
@@ -931,6 +914,12 @@
       Delete(source);
     }
 
+    if (is_member_director(n)) {
+      Wrapper_add_local(f, "upcall", "bool upcall = false");
+      Printf(f->code, "upcall = !Swig::Director::swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\" TSRMLS_CC);\n",
+	  prefix, Swig_class_name(Swig_methodclass(n)), name);
+    }
+
     Swig_director_emit_dynamic_cast(n, f);
 
     /* Insert constraint checking code */
@@ -1278,7 +1267,7 @@
 		  break;
 		char *p;
 		errno = 0;
-		int n = strtol(Char(value), &p, 0);
+		long n = strtol(Char(value), &p, 0);
 	        Clear(value);
 		if (errno || *p) {
 		  Append(value, "?");
@@ -1293,10 +1282,11 @@
 	      case T_SCHAR:
 	      case T_SHORT:
 	      case T_INT:
-	      case T_LONG: {
+	      case T_LONG:
+	      case T_LONGLONG: {
 		char *p;
 		errno = 0;
-		unsigned int n = strtol(Char(value), &p, 0);
+		long n = strtol(Char(value), &p, 0);
 		(void) n;
 		if (errno || *p) {
 		  Clear(value);
@@ -1307,7 +1297,8 @@
 	      case T_UCHAR:
 	      case T_USHORT:
 	      case T_UINT:
-	      case T_ULONG: {
+	      case T_ULONG:
+	      case T_ULONGLONG: {
 		char *p;
 		errno = 0;
 		unsigned int n = strtoul(Char(value), &p, 0);
@@ -1319,7 +1310,8 @@
 		break;
 	      }
 	      case T_FLOAT:
-	      case T_DOUBLE:{
+	      case T_DOUBLE:
+	      case T_LONGDOUBLE: {
 		char *p;
 		errno = 0;
 		/* FIXME: strtod is locale dependent... */
@@ -1338,13 +1330,6 @@
 		}
 		break;
 	      }
-	      case T_REFERENCE:
-	      case T_RVALUE_REFERENCE:
-	      case T_USER:
-	      case T_ARRAY:
-		Clear(value);
-		Append(value, "?");
-		break;
 	      case T_STRING:
 		if (Len(value) < 2) {
 		  // How can a string (including "" be less than 2 characters?)
@@ -1393,6 +1378,11 @@
 		}
 		break;
 	      }
+	      default:
+		/* Safe default */
+		Clear(value);
+		Append(value, "?");
+		break;
 	    }
 
 	    if (!arg_values[argno]) {
@@ -2045,6 +2035,17 @@
       } else if (GetFlag(n, "feature:exceptionclass")) {
 	Append(s_phpclasses, "extends Exception ");
       }
+      {
+	Node *node = NewHash();
+	Setattr(node, "type", Getattr(n, "name"));
+	Setfile(node, Getfile(n));
+	Setline(node, Getline(n));
+	String * interfaces = Swig_typemap_lookup("phpinterfaces", node, "", 0);
+	if (interfaces) {
+	  Printf(s_phpclasses, "implements %s ", interfaces);
+	}
+	Delete(node);
+      }
       Printf(s_phpclasses, "{\n\tpublic $%s=null;\n", SWIG_PTR);
       if (!baseclass) {
 	// Only store this in the base class (NB !baseclass means we *are*
@@ -2622,12 +2623,12 @@
 	Printf(w->code, "zval *args[%d];\n", idx);
       }
       Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name());
-      Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
-      const char * funcname = GetChar(n, "sym:name");
-      Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname));
       Append(w->code, "if (!swig_self) {\n");
       Append(w->code, "  SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");");
       Append(w->code, "}\n\n");
+      Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
+      const char * funcname = GetChar(n, "sym:name");
+      Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname));
 
       /* wrap complex arguments to zvals */
       Printv(w->code, wrap_args, NIL);
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 06c1c48..dde1b60 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -17,6 +17,8 @@
 static int treduce = SWIG_cparse_template_reduce(0);
 
 #include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
 
 #define PYSHADOW_MEMBER  0x2
 #define WARN_PYTHON_MULTIPLE_INH 405
@@ -807,7 +809,7 @@
       Printv(f_shadow, "\nfrom sys import version_info\n", NULL);
 
       if (!builtin && fastproxy) {
-	Printv(f_shadow, "if version_info >= (3,0,0):\n", NULL);
+	Printv(f_shadow, "if version_info >= (3, 0, 0):\n", NULL);
 	Printf(f_shadow, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module);
 	Printv(f_shadow, "else:\n", NULL);
 	Printv(f_shadow, tab4, "from new import instancemethod as new_instancemethod\n", NULL);
@@ -822,7 +824,7 @@
        * isn't available in python 2.4 or earlier, so we have to write some
        * code conditional on the python version.
        */
-      Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL);
+      Printv(f_shadow, "if version_info >= (2, 6, 0):\n", NULL);
       Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL);
       Printv(f_shadow, tab8, "from os.path import dirname\n", NULL);
       Printv(f_shadow, tab8, "import imp\n", NULL);
@@ -852,40 +854,45 @@
 	Printf(f_shadow, "from %s import *\n", module);
       }
       if (modern || !classic) {
-	Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass # Python < 2.2 doesn't have 'property'.\n", NULL);
+	Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass  # Python < 2.2 doesn't have 'property'.\n\n", NULL);
       }
       /* if (!modern) */
       /* always needed, a class can be forced to be no-modern, such as an exception */
       {
 	// Python-2.2 object hack
 	Printv(f_shadow,
-	       "def _swig_setattr_nondynamic(self,class_type,name,value,static=1):\n",
-	       tab4, "if (name == \"thisown\"): return self.this.own(value)\n",
-	       tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
+	       "\n", "def _swig_setattr_nondynamic(self, class_type, name, value, static=1):\n",
+	       tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own(value)\n",
+	       tab4, "if (name == \"this\"):\n", tab8, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
 #ifdef USE_THISOWN
-	       tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n",
+	       tab4, tab8, "if hasattr(value,\"thisown\"):\n", tab8, tab8, "self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n",
 #endif
-	       tab4, tab8, "return\n", tab4, "method = class_type.__swig_setmethods__.get(name,None)\n", tab4, "if method: return method(self,value)\n",
+	       tab4, tab8, "return\n", tab4, "method = class_type.__swig_setmethods__.get(name, None)\n", tab4, "if method:\n", tab4, tab4, "return method(self, value)\n",
 #ifdef USE_THISOWN
 	       tab4, "if (not static) or (name == \"thisown\"):\n",
 #else
 	       tab4, "if (not static):\n",
 #endif
-	       tab4, tab4, "self.__dict__[name] = value\n",
+	       tab4, tab4, "object.__setattr__(self, name, value)\n",
 	       tab4, "else:\n",
 	       tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n\n",
-	       "def _swig_setattr(self,class_type,name,value):\n", tab4, "return _swig_setattr_nondynamic(self,class_type,name,value,0)\n\n", NIL);
+	        "\n", "def _swig_setattr(self, class_type, name, value):\n", tab4, "return _swig_setattr_nondynamic(self, class_type, name, value, 0)\n\n", NIL);
 
 	Printv(f_shadow,
-	       "def _swig_getattr(self,class_type,name):\n",
-	       tab4, "if (name == \"thisown\"): return self.this.own()\n",
-	       tab4, "method = class_type.__swig_getmethods__.get(name,None)\n",
-	       tab4, "if method: return method(self)\n", tab4, "raise AttributeError(name)\n\n", NIL);
+	       "\n", "def _swig_getattr_nondynamic(self, class_type, name, static=1):\n",
+	       tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own()\n",
+	       tab4, "method = class_type.__swig_getmethods__.get(name, None)\n",
+	       tab4, "if method:\n", tab8, "return method(self)\n",
+	       tab4, "if (not static):\n",
+	       tab4, tab4, "return object.__getattr__(self, name)\n",
+	       tab4, "else:\n",
+	       tab4, tab4, "raise AttributeError(name)\n\n",
+	       "def _swig_getattr(self, class_type, name):\n", tab4, "return _swig_getattr_nondynamic(self, class_type, name, 0)\n\n", NIL);
 
 	Printv(f_shadow,
-	       "def _swig_repr(self):\n",
-	       tab4, "try: strthis = \"proxy of \" + self.this.__repr__()\n",
-	       tab4, "except: strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
+	        "\n", "def _swig_repr(self):\n",
+	       tab4, "try:\n", tab8, "strthis = \"proxy of \" + self.this.__repr__()\n",
+	       tab4, "except:\n", tab8, "strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
 
 	if (!classic) {
 	  /* Usage of types.ObjectType is deprecated.
@@ -895,19 +902,19 @@
 //               "import types\n",
 		 "try:\n",
 //               "    _object = types.ObjectType\n",
-		 "    _object = object\n", "    _newclass = 1\n", "except AttributeError:\n", "    class _object : pass\n", "    _newclass = 0\n",
+		 tab4, "_object = object\n", tab4, "_newclass = 1\n", "except AttributeError:\n", tab4, "class _object:\n", tab8, "pass\n", tab4, "_newclass = 0\n",
 //                 "del types\n", 
 		 "\n\n", NIL);
 	}
       }
       if (modern) {
-	Printv(f_shadow, "def _swig_setattr_nondynamic_method(set):\n", tab4, "def set_attr(self,name,value):\n",
+	Printv(f_shadow,  "\n", "def _swig_setattr_nondynamic_method(set):\n", tab4, "def set_attr(self, name, value):\n",
 #ifdef USE_THISOWN
-	       tab4, tab4, "if hasattr(self,name) or (name in (\"this\", \"thisown\")):\n",
+	       tab4, tab4, "if hasattr(self, name) or (name in (\"this\", \"thisown\")):\n",
 #else
-	       tab4, tab4, "if (name == \"thisown\"): return self.this.own(value)\n", tab4, tab4, "if hasattr(self,name) or (name == \"this\"):\n",
+	       tab4, tab4, "if (name == \"thisown\"):\n", tab8, tab4, "return self.this.own(value)\n", tab4, tab4, "if hasattr(self, name) or (name == \"this\"):\n",
 #endif
-	       tab4, tab4, tab4, "set(self,name,value)\n",
+	       tab4, tab4, tab4, "set(self, name, value)\n",
 	       tab4, tab4, "else:\n",
 	       tab4, tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n", tab4, "return set_attr\n\n\n", NIL);
       }
@@ -1523,6 +1530,21 @@
     return ds;
   }
 
+  virtual String *makeParameterName(Node *n, Parm *p, int arg_num, bool = false) const {
+    // For the keyword arguments, we want to preserve the names as much as possible,
+    // so we only minimally rename them in Swig_name_make(), e.g. replacing "keyword"
+    // with "_keyword" if they have any name at all.
+    if (check_kwargs(n)) {
+      String *name = Getattr(p, "name");
+      if (name)
+	return Swig_name_make(p, 0, name, 0, 0);
+    }
+
+    // For the other cases use the general function which replaces arguments whose
+    // names clash with keywords with (less useful) "argN".
+    return Language::makeParameterName(n, p, arg_num);
+  }
+
   /* -----------------------------------------------------------------------------
    * addMissingParameterNames()
    *  For functions that have not had nameless parameters set in the Language class.
@@ -1534,13 +1556,14 @@
    *   The "lname" attribute in each parameter in plist will be contain a parameter name
    * ----------------------------------------------------------------------------- */
 
-  void addMissingParameterNames(ParmList *plist, int arg_offset) {
+  void addMissingParameterNames(Node *n, ParmList *plist, int arg_offset) {
     Parm *p = plist;
     int i = arg_offset;
     while (p) {
       if (!Getattr(p, "lname")) {
-	String *pname = Swig_cparm_name(p, i);
-	Delete(pname);
+	String *name = makeParameterName(n, p, i);
+	Setattr(p, "lname", name);
+	Delete(name);
       }
       i++;
       p = nextSibling(p);
@@ -1563,14 +1586,18 @@
     Parm *pnext;
 
 
-    int lines = 0;
-    int start_arg_num = is_wrapping_class() ? 1 : 0;
-    const int maxwidth = 80;
+    // Normally we start counting auto-generated argument names from 1, but we should do it from 2
+    // if the first argument is "self", i.e. if we're handling a non-static member function.
+    int arg_num = 1;
+    if (is_wrapping_class()) {
+      if (Cmp(Getattr(n, "storage"), "static") != 0)
+	arg_num++;
+    }
 
     if (calling)
       func_annotation = false;
 
-    addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms
+    addMissingParameterNames(n, plist, arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms
     Swig_typemap_attach_parms("in", plist, 0);
     Swig_typemap_attach_parms("doc", plist, 0);
 
@@ -1579,7 +1606,7 @@
       return doc;
     }
 
-    for (p = plist; p; p = pnext) {
+    for (p = plist; p; p = pnext, arg_num++) {
 
       String *tm = Getattr(p, "tmap:in");
       if (tm) {
@@ -1602,25 +1629,22 @@
       }
 
       // Note: the generated name should be consistent with that in kwnames[]
-      name = name ? name : Getattr(p, "name");
-      name = name ? name : Getattr(p, "lname");
-      name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword
+      String *made_name = 0;
+      if (!name) {
+	name = made_name = makeParameterName(n, p, arg_num);
+      }
 
       type = type ? type : Getattr(p, "type");
       value = value ? value : Getattr(p, "value");
 
-      if (SwigType_isvarargs(type))
+      if (SwigType_isvarargs(type)) {
+	Delete(made_name);
 	break;
+      }
 
       if (Len(doc)) {
 	// add a comma to the previous one if any
 	Append(doc, ", ");
-
-	// Do we need to wrap a long line?
-	if ((Len(doc) - lines * maxwidth) > maxwidth) {
-	  Printf(doc, "\n%s", tab4);
-	  lines += 1;
-	}
       }
 
       // Do the param type too?
@@ -1637,22 +1661,16 @@
       }
       // Write the function annotation
       if (func_annotation)
-	Printf(doc, " : '%s'", type_str);
+	Printf(doc, ": '%s'", type_str);
 
       // Write default value
       if (value && !calling) {
 	String *new_value = convertValue(value, Getattr(p, "type"));
-	if (new_value) {
-	  value = new_value;
-	} else {
-	  Node *lookup = Swig_symbol_clookup(value, 0);
-	  if (lookup)
-	    value = Getattr(lookup, "sym:name");
-	}
-	Printf(doc, "=%s", value);
+	if (new_value)
+	  Printf(doc, "=%s", new_value);
       }
       Delete(type_str);
-      Delete(name);
+      Delete(made_name);
     }
     if (pdocs)
       Setattr(n, "feature:pdocs", pdocs);
@@ -1799,57 +1817,192 @@
   }
 
   /* ------------------------------------------------------------
+   *  convertDoubleValue()
+   *    Check if the given string looks like a decimal floating point constant
+   *    and return it if it does, otherwise return NIL.
+   * ------------------------------------------------------------ */
+  String *convertDoubleValue(String *v) {
+    const char *const s = Char(v);
+    char *end;
+
+    double value = strtod(s, &end);
+    (void) value;
+    if (errno != ERANGE && end != s) {
+      // An added complication: at least some versions of strtod() recognize
+      // hexadecimal floating point numbers which don't exist in Python, so
+      // detect them ourselves and refuse to convert them (this can't be done
+      // without loss of precision in general).
+      //
+      // Also don't accept neither "NAN" nor "INFINITY" (both of which
+      // conveniently contain "n").
+      if (strpbrk(s, "xXnN"))
+	return NIL;
+
+      // Disregard optional "f" suffix, it can be just dropped in Python as it
+      // uses doubles for everything anyhow.
+      for (char* p = end; *p != '\0'; ++p) {
+	switch (*p) {
+	  case 'f':
+	  case 'F':
+	    break;
+
+	  default:
+	    return NIL;
+	}
+      }
+
+      // Avoid unnecessary string allocation in the common case when we don't
+      // need to remove any suffix.
+      return *end == '\0' ? v : NewStringWithSize(s, end - s);
+    }
+
+    return NIL;
+  }
+
+  /* ------------------------------------------------------------
    * convertValue()
-   *    Check if string v can be a Python value literal,
-   *    (eg. number or string), or translate it to a Python literal.
+   *    Check if string v can be a Python value literal or a
+   *    constant. Return NIL if it isn't.
    * ------------------------------------------------------------ */
   String *convertValue(String *v, SwigType *t) {
-    if (v && Len(v) > 0) {
-      char fc = (Char(v))[0];
-      if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
-	/* number or string (or maybe NULL pointer) */
-	if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
-	  return NewString("None");
-	else
-	  return v;
-      }
-      if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
-	return NewString("True");
-      if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
-	return NewString("False");
-      if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
-	return SwigType_ispointer(t) ? NewString("None") : NewString("0");
-    }
-    return 0;
-  }
-  /* ------------------------------------------------------------
-   * is_primitive_defaultargs()
-   *    Check if all the default args have primitive type.
-   *    (So we can generate proper parameter list with default 
-   *    values..)
-   * ------------------------------------------------------------ */
-  bool is_primitive_defaultargs(Node *n) {
-    ParmList *plist = CopyParmList(Getattr(n, "parms"));
-    Parm *p;
-    Parm *pnext;
+    const char *const s = Char(v);
+    char *end;
 
-    Swig_typemap_attach_parms("in", plist, 0);
-    for (p = plist; p; p = pnext) {
-      String *tm = Getattr(p, "tmap:in");
-      if (tm) {
-	pnext = Getattr(p, "tmap:in:next");
-	if (checkAttribute(p, "tmap:in:numinputs", "0")) {
-	  continue;
-	}
-      } else {
-	pnext = nextSibling(p);
+    // Check if this is a number in any base.
+    long value = strtol(s, &end, 0);
+    (void) value;
+    if (end != s) {
+      if (errno == ERANGE) {
+	// There was an overflow, we could try representing the value as Python
+	// long integer literal, but for now don't bother with it.
+	return NIL;
       }
-      String *type = Getattr(p, "type");
-      String *value = Getattr(p, "value");
-      if (!convertValue(value, type))
-	return false;
+
+      if (*end != '\0') {
+	// If there is a suffix after the number, we can safely ignore any
+	// combination of "l" and "u", but not anything else (again, stuff like
+	// "LL" could be handled, but we don't bother to do it currently).
+	bool seen_long = false;
+	for (char* p = end; *p != '\0'; ++p) {
+	  switch (*p) {
+	    case 'l':
+	    case 'L':
+	      // Bail out on "LL".
+	      if (seen_long)
+		return NIL;
+	      seen_long = true;
+	      break;
+
+	    case 'u':
+	    case 'U':
+	      break;
+
+	    default:
+	      // Except that our suffix could actually be the fractional part of
+	      // a floating point number, so we still have to check for this.
+	      return convertDoubleValue(v);
+	  }
+	}
+      }
+
+      // Deal with the values starting with 0 first as they can be octal or
+      // hexadecimal numbers or even pointers.
+      if (s[0] == '0') {
+	if (Len(v) == 1) {
+	  // This is just a lone 0, but it needs to be represented differently
+	  // in Python depending on whether it's a zero or a null pointer.
+	  if (SwigType_ispointer(t))
+	    return NewString("None");
+	  else
+	    return v;
+	} else if (s[1] == 'x' || s[1] == 'X') {
+	  // This must have been a hex number, we can use it directly in Python,
+	  // so nothing to do here.
+	} else {
+	  // This must have been an octal number, we have to change its prefix
+	  // to be "0o" in Python 3 only (and as long as we still support Python
+	  // 2.5, this can't be done unconditionally).
+	  if (py3) {
+	    if (end - s > 1) {
+	      String *res = NewString("0o");
+	      Append(res, NewStringWithSize(s + 1, end - s - 1));
+	      return res;
+	    }
+	  }
+	}
+      }
+
+      // Avoid unnecessary string allocation in the common case when we don't
+      // need to remove any suffix.
+      return *end == '\0' ? v : NewStringWithSize(s, end - s);
     }
-    return true;
+
+    // Check if this is a floating point number (notice that it wasn't
+    // necessarily parsed as a long above, consider e.g. ".123").
+    if (String *res = convertDoubleValue(v)) {
+      return res;
+    }
+
+    if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
+      return NewString("True");
+    if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
+      return NewString("False");
+    if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
+      return SwigType_ispointer(t) ? NewString("None") : NewString("0");
+
+    // This could also be an enum type, default value of which could be
+    // representable in Python if it doesn't include any scope (which could,
+    // but currently is not, translated).
+    if (!Strchr(s, ':')) {
+      Node *lookup = Swig_symbol_clookup(v, 0);
+      if (lookup) {
+	if (Cmp(Getattr(lookup, "nodeType"), "enumitem") == 0)
+	  return Getattr(lookup, "sym:name");
+      }
+    }
+
+    return NIL;
+  }
+
+  /* ------------------------------------------------------------
+   * is_representable_as_pyargs()
+   *    Check if the function parameters default argument values
+   *    can be represented in Python.
+   *
+   *    If this method returns false, the parameters will be translated
+   *    to a generic "*args" which allows us to deal with default values
+   *    at C++ code level where they can always be handled.
+   * ------------------------------------------------------------ */
+  bool is_representable_as_pyargs(Node *n) {
+    bool is_representable = true;
+
+    if (Getattr(n, "sym:overloaded")) {
+      ParmList *plist = CopyParmList(Getattr(n, "parms"));
+      Parm *p;
+      Parm *pnext;
+
+      for (p = plist; p; p = pnext) {
+	pnext = NIL;
+	String *tm = Getattr(p, "tmap:in");
+	if (tm) {
+	  pnext = Getattr(p, "tmap:in:next");
+	  if (checkAttribute(p, "tmap:in:numinputs", "0")) {
+	    continue;
+	  }
+	}
+	if (!pnext) {
+	  pnext = nextSibling(p);
+	}
+	if (String *value = Getattr(p, "value")) {
+	  String *type = Getattr(p, "type");
+	  if (!convertValue(value, type)) {
+	    is_representable = false;
+	    break;
+	  }
+	}
+      }
+    }
+    return is_representable;
   }
 
 
@@ -1892,7 +2045,7 @@
       n = nn;
 
     /* For overloaded function, just use *args */
-    if (is_real_overloaded(n) || GetFlag(n, "feature:compactdefaultargs") || !is_primitive_defaultargs(n)) {
+    if (is_real_overloaded(n) || GetFlag(n, "feature:compactdefaultargs") || !is_representable_as_pyargs(n)) {
       String *parms = NewString("");
       if (in_class)
 	Printf(parms, "self, ");
@@ -2012,7 +2165,7 @@
       if (ret)
 	ret = SwigType_str(ret, 0);
     }
-    return (ret && py3) ? NewStringf(" -> \"%s\" ", ret)
+    return (ret && py3) ? NewStringf(" -> \"%s\"", ret)
 	: NewString("");
   }
 
@@ -2029,15 +2182,15 @@
     /* Make a wrapper function to insert the code into */
     Printv(f_dest, "\ndef ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
     if (have_docstring(n))
-      Printv(f_dest, "  ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
+      Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
     if (have_pythonprepend(n))
-      Printv(f_dest, pythoncode(pythonprepend(n), "  "), "\n", NIL);
+      Printv(f_dest, pythoncode(pythonprepend(n), tab4), "\n", NIL);
     if (have_pythonappend(n)) {
-      Printv(f_dest, "  val = ", funcCall(name, callParms), "\n", NIL);
-      Printv(f_dest, pythoncode(pythonappend(n), "  "), "\n", NIL);
-      Printv(f_dest, "  return val\n", NIL);
+      Printv(f_dest, tab4 "val = ", funcCall(name, callParms), "\n", NIL);
+      Printv(f_dest, pythoncode(pythonappend(n), tab4), "\n", NIL);
+      Printv(f_dest, tab4 "return val\n", NIL);
     } else {
-      Printv(f_dest, "  return ", funcCall(name, callParms), "\n", NIL);
+      Printv(f_dest, tab4 "return ", funcCall(name, callParms), "\n", NIL);
     }
 
     if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) {
@@ -2052,7 +2205,7 @@
    *    check if using kwargs is allowed for this Node
    * ------------------------------------------------------------ */
 
-  int check_kwargs(Node *n) {
+  int check_kwargs(Node *n) const {
     return (use_kw || GetFlag(n, "feature:kwargs"))
 	&& !GetFlag(n, "memberset") && !GetFlag(n, "memberget");
   }
@@ -2154,7 +2307,7 @@
 	Append(f->code, "--argc;\n");
     }
 
-    Replaceall(dispatch, "$args", "self,args");
+    Replaceall(dispatch, "$args", "self, args");
 
     Printv(f->code, dispatch, "\n", NIL);
 
@@ -2431,7 +2584,6 @@
       }
 
       SwigType *pt = Getattr(p, "type");
-      String *pn = Getattr(p, "name");
       String *ln = Getattr(p, "lname");
       bool parse_from_tuple = (i > 0 || !add_self);
       if (SwigType_type(pt) == T_VARARGS) {
@@ -2453,18 +2605,9 @@
 
       /* Keyword argument handling */
       if (allow_kwargs && parse_from_tuple) {
-	if (Len(pn)) {
-	  String *tmp = 0;
-	  String *name = pn;
-	  if (!Getattr(p, "hidden")) {
-	    name = tmp = Swig_name_make(p, 0, pn, 0, 0); // rename parameter if a keyword
-	  }
-	  Printf(kwargs, "(char *) \"%s\",", name);
-	  if (tmp)
-	    Delete(tmp);
-	} else {
-	  Printf(kwargs, "(char *)\"arg%d\",", i + 1);
-	}
+	String *name = makeParameterName(n, p, i + 1);
+	Printf(kwargs, "(char *) \"%s\",", name);
+	Delete(name);
       }
 
       /* Look for an input typemap */
@@ -2595,7 +2738,6 @@
 
     /* Insert cleanup code */
     for (p = l; p;) {
-      //      if (!checkAttribute(p,"tmap:in:numinputs","0") && !Getattr(p,"tmap:in:parse")) {
       if (!Getattr(p, "tmap:in:parse") && (tm = Getattr(p, "tmap:freearg"))) {
 	if (Getattr(p, "tmap:freearg:implicitconv")) {
 	  const char *convflag = "0";
@@ -3203,7 +3345,7 @@
    * BEGIN C++ Director Class modifications
    * ------------------------------------------------------------------------- */
 
-  /* C++/Python polymorphism demo code, copyright (C) 2002 Mark Rose <mrose@stm.lbl.gov>
+  /* C++/Python polymorphism demo code
    *
    * TODO
    *
@@ -3901,7 +4043,7 @@
 	  Printv(base_class, bname, NIL);
 	  b = Next(b);
 	  if (b.item) {
-	    Putc(',', base_class);
+            Printv(base_class, ", ", NIL);
 	  }
 	}
       }
@@ -3922,7 +4064,7 @@
       String *abcs = Getattr(n, "feature:python:abc");
       if (py3 && abcs) {
 	if (Len(base_class)) {
-	  Putc(',', base_class);
+	  Printv(base_class, ", ", NIL);
 	}
 	Printv(base_class, abcs, NIL);
       }
@@ -3957,7 +4099,7 @@
 	if (!modern) {
 	  Printv(f_shadow, tab4, "__swig_setmethods__ = {}\n", NIL);
 	  if (Len(base_class)) {
-	    Printf(f_shadow, "%sfor _s in [%s]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))\n", tab4, base_class);
+	    Printv(f_shadow, tab4, "for _s in [", base_class, "]:\n", tab8, "__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))\n", NIL);
 	  }
 
 	  if (!GetFlag(n, "feature:python:nondynamic")) {
@@ -3968,7 +4110,7 @@
 
 	  Printv(f_shadow, tab4, "__swig_getmethods__ = {}\n", NIL);
 	  if (Len(base_class)) {
-	    Printf(f_shadow, "%sfor _s in [%s]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))\n", tab4, base_class);
+	    Printv(f_shadow, tab4, "for _s in [", base_class, "]:\n", tab8, "__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))\n", NIL);
 	  }
 
 	  Printv(f_shadow, tab4, "__getattr__ = lambda self, name: _swig_getattr(self, ", class_name, ", name)\n", NIL);
@@ -4056,7 +4198,7 @@
       Delete(realct);
       if (!have_constructor) {
 	if (!builtin)
-	  Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined",
+	  Printv(f_shadow_file, "\n", tab4, "def __init__(self, *args, **kwargs):\n", tab8, "raise AttributeError(\"", "No constructor defined",
 		 (Getattr(n, "abstracts") ? " - class is abstract" : ""), "\")\n", NIL);
       } else if (fastinit && !builtin) {
 
@@ -4094,12 +4236,12 @@
 	Printv(f_shadow_file, "\nclass ", class_name, "Ptr(", class_name, "):\n", tab4, "def __init__(self, this):\n", NIL);
 	if (!modern) {
 	  Printv(f_shadow_file,
-		 tab8, "try: self.this.append(this)\n",
-		 tab8, "except: self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL);
+		 tab8, "try:\n", tab8, tab4, "self.this.append(this)\n",
+		 tab8, "except:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL);
 	} else {
 	  Printv(f_shadow_file,
-		 tab8, "try: self.this.append(this)\n",
-		 tab8, "except: self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL);
+		 tab8, "try:\n", tab8, tab4, "self.this.append(this)\n",
+		 tab8, "except:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL);
 	}
       }
 
@@ -4108,7 +4250,7 @@
 	  List *shadow_list = Getattr(n, "shadow_methods");
 	  for (int i = 0; i < Len(shadow_list); ++i) {
 	    String *symname = Getitem(shadow_list, i);
-	    Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s,None,%s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname),
+	    Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s, None, %s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname),
 		   class_name);
 	  }
 	}
@@ -4223,12 +4365,11 @@
 	  String *callParms = make_pyParmList(n, true, true, allow_kwargs);
 	  if (!have_addtofunc(n)) {
 	    if (!fastproxy || olddefs) {
-	      Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL);
-	      Printv(f_shadow, " return ", funcCall(fullname, callParms), "\n", NIL);
+	      Printv(f_shadow, "\n", tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
+	      Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n", NIL);
 	    }
 	  } else {
-	    Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL);
-	    Printv(f_shadow, "\n", NIL);
+	    Printv(f_shadow, "\n", tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
 	    if (have_docstring(n))
 	      Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL);
 	    if (have_pythonprepend(n)) {
@@ -4314,7 +4455,7 @@
 	int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0;
 	String *parms = make_pyParmList(n, false, false, kw);
 	String *callParms = make_pyParmList(n, false, true, kw);
-	Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
+	Printv(f_shadow, "\n", tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
 	if (have_docstring(n))
 	  Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL);
 	if (have_pythonprepend(n))
@@ -4326,7 +4467,9 @@
 	} else {
 	  Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL);
 	}
-	Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", symname, ")\n", NIL);
+	if (!modern)
+	  Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
+	Printv(f_shadow, tab4, symname, " = staticmethod(", symname, ")\n", NIL);
 
 	if (!modern) {
 	  Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", symname, "\n", NIL);
@@ -4338,7 +4481,9 @@
 		 NIL);
 	}
 	if (!classic) {
-	  Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
+	  if (!modern)
+	    Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
+	  Printv(f_shadow, tab4, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname),
 		 ")\n", NIL);
 	}
       }
@@ -4427,7 +4572,7 @@
 		Printv(pass_self, tab8, tab4, "_self = None\n", tab8, "else:\n", tab8, tab4, "_self = self\n", NIL);
 	      }
 
-	      Printv(f_shadow, tab4, "def __init__(", parms, ")", returnTypeAnnotation(n), ": \n", NIL);
+	      Printv(f_shadow, "\n", tab4, "def __init__(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
 	      if (have_docstring(n))
 		Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL);
 	      if (have_pythonprepend(n))
@@ -4438,7 +4583,7 @@
 	      } else {
 		Printv(f_shadow,
 		       tab8, "this = ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), "\n",
-		       tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL);
+		       tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", tab8, "except:\n", tab8, tab4, "self.this = this\n", NIL);
 	      }
 	      if (have_pythonappend(n))
 		Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n\n", NIL);
@@ -4524,7 +4669,7 @@
 	Printv(f_shadow, tab4, "__swig_destroy__ = ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "\n", NIL);
 	if (!have_pythonprepend(n) && !have_pythonappend(n)) {
 	  if (proxydel) {
-	    Printv(f_shadow, tab4, "__del__ = lambda self : None;\n", NIL);
+	    Printv(f_shadow, tab4, "__del__ = lambda self: None\n", NIL);
 	  }
 	  return SWIG_OK;
 	}
@@ -4535,7 +4680,7 @@
 	  Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
 #ifdef USE_THISOWN
 	Printv(f_shadow, tab8, "try:\n", NIL);
-	Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "(self)\n", NIL);
+	Printv(f_shadow, tab8, tab4, "if self.thisown:", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "(self)\n", NIL);
 	Printv(f_shadow, tab8, "except: pass\n", NIL);
 #else
 #endif
@@ -4573,11 +4718,12 @@
 	Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL);
       }
       if (!classic) {
-	if (!assignable) {
-	  Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ")\n", NIL);
-	} else {
-	  Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL);
-	}
+	if (!modern)
+	  Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
+	Printv(f_shadow, tab4, symname, " = _swig_property(", module, ".", getname, NIL);
+	if (assignable)
+	  Printv(f_shadow, ", ", module, ".", setname, NIL);
+	Printv(f_shadow, ")\n", NIL);
       }
       Delete(mname);
       Delete(setname);
@@ -4646,11 +4792,12 @@
 	  Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL);
 	}
 	if (!classic && !builtin) {
-	  if (!assignable) {
-	    Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ")\n", NIL);
-	  } else {
-	    Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = _swig_property(", module, ".", getname, ", ", module, ".", setname, ")\n", NIL);
-	  }
+	  if (!modern)
+	    Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL);
+	  Printv(f_shadow, tab4, symname, " = _swig_property(", module, ".", getname, NIL);
+	  if (assignable)
+	    Printv(f_shadow, ", ", module, ".", setname, NIL);
+	  Printv(f_shadow, ")\n", NIL);
 	}
 	String *getter = Getattr(n, "pybuiltin:getter");
 	String *setter = Getattr(n, "pybuiltin:setter");
@@ -4776,6 +4923,13 @@
     return NewString("swigpyrun.h");
   }
 
+  /*----------------------------------------------------------------------
+   * kwargsSupport()
+   *--------------------------------------------------------------------*/
+
+  bool kwargsSupport() const {
+    return true;
+  }
 };
 
 /* ---------------------------------------------------------------
@@ -4813,6 +4967,16 @@
   int idx;
   bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
 
+  if (builtin) {
+    // Rename any wrapped parameters called 'self' as the generated code contains a variable with same name
+    Parm *p;
+    for (p = l; p; p = nextSibling(p)) {
+      String *arg = Getattr(p, "name");
+      if (arg && Cmp(arg, "self") == 0)
+	Delattr(p, "name");
+    }
+  }
+
   if (Cmp(storage, "virtual") == 0) {
     if (Cmp(value, "0") == 0) {
       pure_virtual = true;
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index 6aeaae5..310e89b 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -3426,6 +3426,14 @@
   String *defaultExternalRuntimeFilename() {
     return NewString("swigrubyrun.h");
   }
+
+  /*----------------------------------------------------------------------
+   * kwargsSupport()
+   *--------------------------------------------------------------------*/
+
+  bool kwargsSupport() const {
+    return true;
+  }
 };				/* class RUBY */
 
 /* -----------------------------------------------------------------------------
diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
index 8a0861d..6bbf40d 100644
--- a/Source/Modules/swigmain.cxx
+++ b/Source/Modules/swigmain.cxx
@@ -180,11 +180,6 @@
       } else if (strcmp(argv[i], "-nolang") == 0) {
 	dl = new Language;
 	Swig_mark_arg(i);
-      } else if ((strcmp(argv[i], "-dnone") == 0) ||
-		 (strcmp(argv[i], "-dhtml") == 0) ||
-		 (strcmp(argv[i], "-dlatex") == 0) || (strcmp(argv[i], "-dascii") == 0) || (strcmp(argv[i], "-stat") == 0)) {
-	Printf(stderr, "swig: Warning. %s option deprecated.\n", argv[i]);
-	Swig_mark_arg(i);
       } else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) {
 	if (strcmp(argv[i], "--help") == 0)
 	  strcpy(argv[i], "-help");
diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h
index 63b91ba..a30fdf8 100644
--- a/Source/Modules/swigmod.h
+++ b/Source/Modules/swigmod.h
@@ -291,12 +291,18 @@
   /* Return the current class prefix */
   String *getClassPrefix() const;
 
+  /* Return the current enum class prefix */
+  String *getEnumClassPrefix() const;
+
   /* Fully qualified type name to use */
   String *getClassType() const;
 
   /* Return true if the current method is part of a smart-pointer */
   int is_smart_pointer() const;
 
+  /* Return the name to use for the given parameter. */
+  virtual String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter = false) const;
+
   /* Some language modules require additional wrappers for virtual methods not declared in sub-classes */
   virtual bool extraDirectorProtectedCPPMethodsRequired() const;
 
@@ -315,6 +321,9 @@
   */
   virtual NestedClassSupport nestedClassesSupport() const;
 
+  /* Returns true if the target language supports key word arguments (kwargs) */
+  virtual bool kwargsSupport() const;
+
 protected:
   /* Identifies if a protected members that are generated when the allprotected option is used.
      This does not include protected virtual methods as they are turned on with the dirprot option. */
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index 329a601..3e323f9 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -667,6 +667,9 @@
 
     /* Normalize types. */
     SwigType *ty = Getattr(n, "type");
+    if (!ty) {
+      return SWIG_OK;
+    }
     normalize_type(ty);
     SwigType *decl = Getattr(n, "decl");
     if (decl) {
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index baadf71..ac912f4 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -1376,12 +1376,12 @@
       else if (c == '\"') {
 	start_line = Getline(s);
 	if (skip_tochar(s, '\"', chunk) < 0) {
-	  Swig_error(Getfile(s), -1, "Unterminated string constant starting at line %d\n", start_line);
+	  Swig_error(Getfile(s), start_line, "Unterminated string constant\n");
 	}
       } else if (c == '\'') {
 	start_line = Getline(s);
 	if (skip_tochar(s, '\'', chunk) < 0) {
-	  Swig_error(Getfile(s), -1, "Unterminated character constant starting at line %d\n", start_line);
+	  Swig_error(Getfile(s), start_line, "Unterminated character constant\n");
 	}
       } else if (c == '/')
 	state = 30;		/* Comment */
@@ -1768,6 +1768,10 @@
 	}
       } else if (Equal(id, kpp_level)) {
 	Swig_error(Getfile(s), Getline(id), "cpp debug: level = %d, startlevel = %d\n", level, start_level);
+      } else if (Equal(id, "")) {
+	/* Null directive */
+      } else {
+	Swig_error(Getfile(s), Getline(id), "Unknown SWIG preprocessor directive: %s (if this is a block of target language code, delimit it with %%{ and %%})\n", id);
       }
       for (i = 0; i < cpp_lines; i++)
 	Putc('\n', ns);
@@ -2004,21 +2008,21 @@
     }
   }
   while (level > 0) {
-    Swig_error(Getfile(s), -1, "Missing #endif for conditional starting on line %d\n", cond_lines[level - 1]);
+    Swig_error(Getfile(s), cond_lines[level - 1], "Missing #endif for conditional starting here\n");
     level--;
   }
   if (state == 120) {
-    Swig_error(Getfile(s), -1, "Missing %%endoffile for file inclusion block starting on line %d\n", start_line);
+    Swig_error(Getfile(s), start_line, "Missing %%endoffile for file inclusion block starting here\n");
   }
   if (state == 150) {
     Seek(value, 0, SEEK_SET);
-    Swig_error(Getfile(s), -1, "Missing %%enddef for macro starting on line %d\n", Getline(value));
+    Swig_error(Getfile(s), Getline(value), "Missing %%enddef for macro starting here\n", Getline(value));
   }
   if ((state >= 105) && (state < 107)) {
-    Swig_error(Getfile(s), -1, "Unterminated %%{ ... %%} block starting on line %d\n", start_line);
+    Swig_error(Getfile(s), start_line, "Unterminated %%{ ... %%} block\n");
   }
   if ((state >= 30) && (state < 40)) {
-    Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line);
+    Swig_error(Getfile(s), start_line, "Unterminated comment\n");
   }
 
   copy_location(s, chunk);
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index d15c2e1..9da4e08 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -869,7 +869,7 @@
     String *parentclassname = 0;
     if (parentclass)
       parentclassname = Getattr(parentclass, "name");
-    Replaceall(code, "$parentclassname", parentclassname ? parentclassname : "");
+    Replaceall(code, "$parentclassname", parentclassname ? SwigType_str(parentclassname, "") : "");
   }
 }
 
@@ -1614,7 +1614,14 @@
     Delete(mangled);
     Delete(sname);
   } else {
-    String *nname = SwigType_namestr(name);
+    String *nname = 0;
+    if (Equal(nodeType(n), "constant")) {
+      String *rawval = Getattr(n, "rawval");
+      String *value = rawval ? rawval : Getattr(n, "value");
+      nname = NewStringf("(%s)", value);
+    } else {
+      nname = SwigType_namestr(name);
+    }
     call = Swig_wrapped_var_assign(type, nname, varcref);
     cres = Swig_cresult(ty, Swig_cresult_name(), call);
     Setattr(n, "wrap:action", cres);
diff --git a/Source/Swig/extend.c b/Source/Swig/extend.c
new file mode 100644
index 0000000..30097b4
--- /dev/null
+++ b/Source/Swig/extend.c
@@ -0,0 +1,141 @@
+/* -----------------------------------------------------------------------------
+ * This file is part of SWIG, which is licensed as a whole under version 3 
+ * (or any later version) of the GNU General Public License. Some additional
+ * terms also apply to certain portions of SWIG. The full details of the SWIG
+ * license and copyrights can be found in the LICENSE and COPYRIGHT files
+ * included with the SWIG source code as distributed by the SWIG developers
+ * and at http://www.swig.org/legal.html.
+ *
+ * extend.c
+ *
+ * Extensions support (%extend)
+ * ----------------------------------------------------------------------------- */
+
+#include "swig.h"
+#include "cparse.h"
+
+static Hash *extendhash = 0;     /* Hash table of added methods */
+
+/* -----------------------------------------------------------------------------
+ * Swig_extend_hash()
+ *
+ * Access the extend hash
+ * ----------------------------------------------------------------------------- */
+Hash *Swig_extend_hash(void) {
+  if (!extendhash)
+    extendhash = NewHash();
+  return extendhash;
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_extend_merge()
+ *
+ * Extension merge.  This function is used to handle the %extend directive
+ * when it appears before a class definition.   To handle this, the %extend
+ * actually needs to take precedence.  Therefore, we will selectively nuke symbols
+ * from the current symbol table, replacing them with the added methods.
+ * ----------------------------------------------------------------------------- */
+
+void Swig_extend_merge(Node *cls, Node *am) {
+  Node *n;
+  Node *csym;
+
+  n = firstChild(am);
+  while (n) {
+    String *symname;
+    if (Strcmp(nodeType(n),"constructor") == 0) {
+      symname = Getattr(n,"sym:name");
+      if (symname) {
+	if (Strcmp(symname,Getattr(n,"name")) == 0) {
+	  /* If the name and the sym:name of a constructor are the same,
+             then it hasn't been renamed.  However---the name of the class
+             itself might have been renamed so we need to do a consistency
+             check here */
+	  if (Getattr(cls,"sym:name")) {
+	    Setattr(n,"sym:name", Getattr(cls,"sym:name"));
+	  }
+	}
+      } 
+    }
+
+    symname = Getattr(n,"sym:name");
+    DohIncref(symname);
+    if ((symname) && (!Getattr(n,"error"))) {
+      /* Remove node from its symbol table */
+      Swig_symbol_remove(n);
+      csym = Swig_symbol_add(symname,n);
+      if (csym != n) {
+	/* Conflict with previous definition.  Nuke previous definition */
+	String *e = NewStringEmpty();
+	String *en = NewStringEmpty();
+	String *ec = NewStringEmpty();
+	Printf(ec,"Identifier '%s' redefined by %%extend (ignored),",symname);
+	Printf(en,"%%extend definition of '%s'.",symname);
+	SWIG_WARN_NODE_BEGIN(n);
+	Swig_warning(WARN_PARSE_REDEFINED,Getfile(csym),Getline(csym),"%s\n",ec);
+	Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en);
+	SWIG_WARN_NODE_END(n);
+	Printf(e,"%s:%d:%s\n%s:%d:%s\n",Getfile(csym),Getline(csym),ec, 
+	       Getfile(n),Getline(n),en);
+	Setattr(csym,"error",e);
+	Delete(e);
+	Delete(en);
+	Delete(ec);
+	Swig_symbol_remove(csym);              /* Remove class definition */
+	Swig_symbol_add(symname,n);            /* Insert extend definition */
+      }
+    }
+    n = nextSibling(n);
+  }
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_extend_append_previous()
+ * ----------------------------------------------------------------------------- */
+
+void Swig_extend_append_previous(Node *cls, Node *am) {
+  Node *n, *ne;
+  Node *pe = 0;
+  Node *ae = 0;
+
+  if (!am) return;
+  
+  n = firstChild(am);
+  while (n) {
+    ne = nextSibling(n);
+    set_nextSibling(n,0);
+    /* typemaps and fragments need to be prepended */
+    if (((Cmp(nodeType(n),"typemap") == 0) || (Cmp(nodeType(n),"fragment") == 0)))  {
+      if (!pe) pe = new_node("extend");
+      appendChild(pe, n);
+    } else {
+      if (!ae) ae = new_node("extend");
+      appendChild(ae, n);
+    }    
+    n = ne;
+  }
+  if (pe) prependChild(cls,pe);
+  if (ae) appendChild(cls,ae);
+}
+ 
+
+/* -----------------------------------------------------------------------------
+ * Swig_extend_unused_check()
+ *
+ * Check for unused %extend.  Special case, don't report unused
+ * extensions for templates
+ * ----------------------------------------------------------------------------- */
+ 
+void Swig_extend_unused_check(void) {
+  Iterator ki;
+
+  if (!extendhash) return;
+  for (ki = First(extendhash); ki.key; ki = Next(ki)) {
+    if (!Strchr(ki.key,'<')) {
+      SWIG_WARN_NODE_BEGIN(ki.item);
+      Swig_warning(WARN_PARSE_EXTEND_UNDEF,Getfile(ki.item), Getline(ki.item), "%%extend defined for an undeclared class %s.\n", SwigType_namestr(ki.key));
+      SWIG_WARN_NODE_END(ki.item);
+    }
+  }
+}
+
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index d8c3f7f..b0d608c 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -824,6 +824,9 @@
 	state = 7;
       } else if (c == '=') {
 	return SWIG_TOKEN_MODEQUAL;
+      } else if (c == '}') {
+	Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '%%}'\n");
+	exit(1);
       } else {
 	retract(s, 1);
 	return SWIG_TOKEN_PERCENT;
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index 5334a29..5ee7f8d 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -420,6 +420,13 @@
   extern void Swig_fragment_emit(String *name);
   extern void Swig_fragment_clear(String *section);
 
+/* --- Extension support --- */
+
+  extern Hash *Swig_extend_hash(void);
+  extern void Swig_extend_merge(Node *cls, Node *am);
+  extern void Swig_extend_append_previous(Node *cls, Node *am);
+  extern void Swig_extend_unused_check(void);
+
 /* hacks defined in C++ ! */
   extern int Swig_director_mode(void);
   extern int Swig_director_protected_mode(void);
diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c
index e77f818..2202f61 100644
--- a/Source/Swig/symbol.c
+++ b/Source/Swig/symbol.c
@@ -1875,15 +1875,15 @@
 	  Delete(ntq);
 	  ntq = ty;
 	}
-	/* Printf(stderr,"value %s %s %s\n",value,ntr,ntq); */
 	cp = NewParmWithoutFileLineInfo(ntq, 0);
-        if (lp)
-          set_nextSibling(lp, cp);
-        else
-          expandedparms = CopyParm(cp);
+	if (lp) {
+	  set_nextSibling(lp, cp);
+	  Delete(cp);
+	} else {
+	  expandedparms = cp;
+	}
 	lp = cp;
 	tp = nextSibling(tp);
-	Delete(cp);
 	Delete(nt);
 	Delete(ntq);
       } else {
diff --git a/Tools/config/ax_boost_base.m4 b/Tools/config/ax_boost_base.m4
index 54a2a1b..550b641 100644
--- a/Tools/config/ax_boost_base.m4
+++ b/Tools/config/ax_boost_base.m4
@@ -33,7 +33,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 20
+#serial 23
 
 AC_DEFUN([AX_BOOST_BASE],
 [
@@ -91,9 +91,23 @@
     dnl are found, e.g. when only header-only libraries are installed!
     libsubdirs="lib"
     ax_arch=`uname -m`
-    if test $ax_arch = x86_64 -o $ax_arch = ppc64 -o $ax_arch = s390x -o $ax_arch = sparc64; then
+    case $ax_arch in
+      x86_64|ppc64|s390x|sparc64|aarch64)
         libsubdirs="lib64 lib lib64"
-    fi
+        ;;
+    esac
+
+    dnl allow for real multi-arch paths e.g. /usr/lib/x86_64-linux-gnu. Give
+    dnl them priority over the other paths since, if libs are found there, they
+    dnl are almost assuredly the ones desired.
+    AC_REQUIRE([AC_CANONICAL_HOST])
+    libsubdirs="lib/${host_cpu}-${host_os} $libsubdirs"
+
+    case ${host_cpu} in
+      i?86)
+        libsubdirs="lib/i386-${host_os} $libsubdirs"
+        ;;
+    esac
 
     dnl first we check the system location for boost libraries
     dnl this location ist chosen if boost libraries are installed with the --layout=system option
@@ -256,3 +270,4 @@
 fi
 
 ])
+
diff --git a/Tools/javascript/Makefile.in b/Tools/javascript/Makefile.in
index 373c5d9..1eec5bc 100644
--- a/Tools/javascript/Makefile.in
+++ b/Tools/javascript/Makefile.in
@@ -11,33 +11,46 @@
 #		interpreter (see 'Tools/javascript').
 #
 # ----------------------------------------------------------------
+all: javascript
+
 CC         = @CC@
 # HACK: under OSX a g++ compiled interpreter is seg-faulting when loading module libraries
 # with 'c++' it works... probably some missing flags?
-JSCXX        = @JSINTERPRETERCXX@
+JSCXX      = @JSINTERPRETERCXX@
+CPPFLAGS   = @BOOST_CPPFLAGS@
 CFLAGS     = @PLATCFLAGS@
-CXXFLAGS   = @BOOST_CPPFLAGS@ @PLATCXXFLAGS@
+CXXFLAGS   = @PLATCXXFLAGS@
+LDFLAGS    =
 LINKFLAGS = @JSINTERPRETERLINKFLAGS@
 
 ROOT_DIR = @ROOT_DIR@
 JSINCLUDES = @JSCOREINC@ @JSV8INC@
 JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
-JSLIBRARYPREFIX = @JSLIBRARYPREFIX@
-JSSO =@JSSO@
-JSLDSHARED = @JSLDSHARED@
-JSCXXSHARED = @JSCXXSHARED@
 JSV8ENABLED = @JSV8ENABLED@
 JSCENABLED = @JSCENABLED@
 
+srcdir = @srcdir@
+
+
+ifneq (, $(V8_VERSION))
+    JSV8_VERSION=$(V8_VERSION)
+else
+    JSV8_VERSION=0x031110
+endif
+
+# Regenerate Makefile if Makefile.in or config.status have changed.
+Makefile: $(srcdir)/Makefile.in ../../config.status
+	cd ../.. && $(SHELL) ./config.status Tools/javascript/Makefile
+
 # These settings are provided by 'configure' (see '/configure.in')
 ifeq (1, $(JSV8ENABLED))
-	JS_INTERPRETER_SRC_V8 = v8_shell.cxx
-	JS_INTERPRETER_ENABLE_V8 = -DENABLE_V8
+JS_INTERPRETER_SRC_V8 = v8_shell.cxx
+JS_INTERPRETER_ENABLE_V8 = -DENABLE_V8 -DSWIG_V8_VERSION=$(JSV8_VERSION) -DV8_DEPRECATION_WARNINGS
 endif
 
 ifeq (1, $(JSCENABLED))
-	JS_INTERPRETER_SRC_JSC = jsc_shell.cxx
-	JS_INTERPRETER_ENABLE_JSC = -DENABLE_JSC
+JS_INTERPRETER_SRC_JSC = jsc_shell.cxx
+JS_INTERPRETER_ENABLE_JSC = -DENABLE_JSC
 endif
 
 JS_INTERPRETER_DEFINES = $(JS_INTERPRETER_ENABLE_JSC) $(JS_INTERPRETER_ENABLE_V8)
@@ -45,12 +58,15 @@
 
 JS_INTERPRETER_OBJS = $(JS_INTERPRETER_SRC:.cxx=.o)
 
-%.o: %.cxx
-	$(JSCXX) $(JS_INTERPRETER_DEFINES) $(CXXFLAGS) $(JSINCLUDES) -o $@ -c $<
+%.o: $(srcdir)/%.cxx
+	$(JSCXX) $(JS_INTERPRETER_DEFINES) $(CPPFLAGS) $(CXXFLAGS) $(JSINCLUDES) -o $@ -c $<
 
 javascript: $(JS_INTERPRETER_OBJS)
-	$(JSCXX) $^ $(CXXFLAGS) -o javascript $(JSDYNAMICLINKING) $(LINKFLAGS)
+	$(JSCXX) $^ $(CXXFLAGS) $(LDFLAGS) -o javascript $(JSDYNAMICLINKING) $(LINKFLAGS)
 
 clean:
 	rm -f *.o
 	rm -f javascript
+
+distclean: clean
+	rm -f Makefile
diff --git a/Tools/javascript/v8_shell.cxx b/Tools/javascript/v8_shell.cxx
old mode 100755
new mode 100644
index 4c6334f..7016e9c
--- a/Tools/javascript/v8_shell.cxx
+++ b/Tools/javascript/v8_shell.cxx
@@ -1,313 +1,388 @@
-#include <assert.h>

-#include <fcntl.h>

-#include <string.h>

-#include <stdio.h>

-#include <stdlib.h>

-

-#include <v8.h>

-#include <vector>

-

-#include "js_shell.h"

-

-typedef int (*V8ExtensionInitializer) (v8::Handle<v8::Object> module);

-

-class V8Shell: public JSShell {

-

-public:

-  V8Shell();

-

-  virtual ~V8Shell();

-

-  virtual bool RunScript(const std::string& scriptPath);

-

-  virtual bool RunShell();

-

-

-protected:

-

-  virtual bool InitializeEngine();

-

-  virtual bool ExecuteScript(const std::string& source, const std::string& scriptPath);

-

-  virtual bool DisposeEngine();

-

-private:

-

-  v8::Handle<v8::Value> Import(const std::string& moduleName);

-

-  v8::Persistent<v8::Context> CreateShellContext();

-

-  void ReportException(v8::TryCatch* handler);

-

-  static v8::Handle<v8::Value> Print(const v8::Arguments& args);

-

-  static v8::Handle<v8::Value> Require(const v8::Arguments& args);

-

-  static v8::Handle<v8::Value> Quit(const v8::Arguments& args);

-

-  static v8::Handle<v8::Value> Version(const v8::Arguments& args);

-

-  static const char* ToCString(const v8::String::Utf8Value& value);

-

-  virtual bool _ExecuteScript(const std::string& source, const std::string& scriptPath);

-

-protected:

-

-  v8::Persistent<v8::Context> context;

-};

-

-#ifdef __GNUC__

-#include <dlfcn.h>

-#define LOAD_SYMBOL(handle, name) dlsym(handle, name)

-#else

-#error "implement dll loading"

-#endif

-

-V8Shell::V8Shell(){}

-

-V8Shell::~V8Shell() {}

-

-bool V8Shell::RunScript(const std::string& scriptPath) {

-

-  if (!context.IsEmpty()) {

-    context.Dispose();

-  }

-

-  std::string source = ReadFile(scriptPath);

-

-  context = CreateShellContext();

-  if (context.IsEmpty()) {

-      printf("Could not create context.\n");

-      return false;

-  }

-  context->Enter();

-

-  bool success = _ExecuteScript(source, scriptPath);

-

-  context->Exit();

-  context.Dispose();

-  v8::V8::Dispose();

-

-  return true;

-}

-

-bool V8Shell::_ExecuteScript(const std::string& source, const std::string& scriptPath) {

-  v8::HandleScope scope;

-

-  // Store a pointer to this shell for later use

-  v8::Handle<v8::Object> global = context->Global();

-  v8::Local<v8::External> __shell__ = v8::External::New((void*) (long) this);

-  global->SetHiddenValue(v8::String::New("__shell__"), __shell__);

-

-  // Node.js compatibility: make `print` available as `console.log()`

-  ExecuteScript("var console = {}; console.log = print;", "<console>");

-

-  if(!ExecuteScript(source, scriptPath)) {

-    return false;

-  }

-

-  return true;

-}

-

-bool V8Shell::RunShell() {

-

-  if (!context.IsEmpty()) {

-    context.Dispose();

-  }

-

-  context = CreateShellContext();

-  if (context.IsEmpty()) {

-      printf("Could not create context.\n");

-      return false;

-  }

-

-  context->Enter();

-

-  v8::Context::Scope context_scope(context);

-

-  ExecuteScript("var console = {}; console.log = print;", "<console>");

-

-  static const int kBufferSize = 1024;

-  while (true) {

-    char buffer[kBufferSize];

-    printf("> ");

-    char* str = fgets(buffer, kBufferSize, stdin);

-    if (str == NULL) break;

-    std::string source(str);

-    ExecuteScript(source, "(shell)");

-  }

-  printf("\n");

-

-  context->Exit();

-  context.Dispose();

-  v8::V8::Dispose();

-

-  return true;

-}

-

-

-bool V8Shell::InitializeEngine() {

-  return true;

-}

-

-bool V8Shell::ExecuteScript(const std::string& source, const std::string& name) {

-  v8::HandleScope handle_scope;

-  v8::TryCatch try_catch;

-  v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(source.c_str()), v8::String::New(name.c_str()));

-

-  // Stop if script is empty

-  if (script.IsEmpty()) {

-    // Print errors that happened during compilation.

-    ReportException(&try_catch);

-    return false;

-  }

-

-  v8::Handle<v8::Value> result = script->Run();

-

-  // Print errors that happened during execution.

-  if (try_catch.HasCaught()) {

-    ReportException(&try_catch);

-    return false;

-  } else {

-    return true;

-  }

-}

-

-bool V8Shell::DisposeEngine() {

-  return true;

-}

-

-v8::Persistent<v8::Context> V8Shell::CreateShellContext() {

-  v8::HandleScope scope;

-

-  // Create a template for the global object.

-  v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();

-

-  // Bind global functions

-  global->Set(v8::String::New("print"), v8::FunctionTemplate::New(V8Shell::Print));

-  global->Set(v8::String::New("quit"), v8::FunctionTemplate::New(V8Shell::Quit));

-  global->Set(v8::String::New("require"), v8::FunctionTemplate::New(V8Shell::Require));

-  global->Set(v8::String::New("version"), v8::FunctionTemplate::New(V8Shell::Version));

-

-  v8::Persistent<v8::Context> _context = v8::Context::New(NULL, global);

-

-  return _context;

-}

-

-v8::Handle<v8::Value> V8Shell::Import(const std::string& module_path)

-{

-  v8::HandleScope scope;

-

-  HANDLE library;

-  std::string module_name = LoadModule(module_path, &library);

-

-  std::string symname = std::string(module_name).append("_initialize");

-

-  V8ExtensionInitializer init_function = reinterpret_cast<V8ExtensionInitializer>((long) LOAD_SYMBOL(library, symname.c_str()));

-

-  if(init_function == 0) {

-    printf("Could not find initializer function.");

-    return v8::Undefined();

-  }

-

-  v8::Local<v8::Object> module = v8::Object::New();

-  init_function(module);

-  return scope.Close(module);

-}

-

-v8::Handle<v8::Value> V8Shell::Print(const v8::Arguments& args) {

-  bool first = true;

-  for (int i = 0; i < args.Length(); i++) {

-    v8::HandleScope handle_scope;

-    if (first) {

-      first = false;

-    } else {

-      printf(" ");

-    }

-    v8::String::Utf8Value str(args[i]);

-    const char* cstr = V8Shell::ToCString(str);

-    printf("%s", cstr);

-  }

-  printf("\n");

-  fflush(stdout);

-  return v8::Undefined();

-}

-

-v8::Handle<v8::Value> V8Shell::Require(const v8::Arguments& args) {

-  v8::HandleScope scope;

-

-  if (args.Length() != 1) {

-    printf("Illegal arguments for `require`");

-  };

-

-  v8::String::Utf8Value str(args[0]);

-  const char* cstr = V8Shell::ToCString(str);

-  std::string moduleName(cstr);

-

-  v8::Local<v8::Object> global = v8::Context::GetCurrent()->Global();

-  v8::Local<v8::Value> hidden = global->GetHiddenValue(v8::String::New("__shell__"));

-  v8::Local<v8::External> __shell__ = v8::Local<v8::External>::Cast(hidden);

-  V8Shell* _this = (V8Shell*) (long) __shell__->Value();

-

-  v8::Handle<v8::Value> module = _this->Import(moduleName);

-

-  return scope.Close(module);

-}

-

-v8::Handle<v8::Value> V8Shell::Quit(const v8::Arguments& args) {

-  int exit_code = args[0]->Int32Value();

-  fflush(stdout);

-  fflush(stderr);

-  exit(exit_code);

-  return v8::Undefined();

-}

-

-v8::Handle<v8::Value> V8Shell::Version(const v8::Arguments& args) {

-  return v8::String::New(v8::V8::GetVersion());

-}

-

-void V8Shell::ReportException(v8::TryCatch* try_catch) {

-  v8::HandleScope handle_scope;

-  v8::String::Utf8Value exception(try_catch->Exception());

-  const char* exception_string = V8Shell::ToCString(exception);

-  v8::Handle<v8::Message> message = try_catch->Message();

-  if (message.IsEmpty()) {

-    // V8 didn't provide any extra information about this error; just

-    // print the exception.

-    printf("%s\n", exception_string);

-  } else {

-    // Print (filename):(line number): (message).

-    v8::String::Utf8Value filename(message->GetScriptResourceName());

-    const char* filename_string = V8Shell::ToCString(filename);

-    int linenum = message->GetLineNumber();

-    printf("%s:%i: %s\n", filename_string, linenum, exception_string);

-    // Print line of source code.

-    v8::String::Utf8Value sourceline(message->GetSourceLine());

-    const char* sourceline_string = V8Shell::ToCString(sourceline);

-    printf("%s\n", sourceline_string);

-    // Print wavy underline (GetUnderline is deprecated).

-    int start = message->GetStartColumn();

-    for (int i = 0; i < start; i++) {

-      printf(" ");

-    }

-    int end = message->GetEndColumn();

-    for (int i = start; i < end; i++) {

-      printf("^");

-    }

-    printf("\n");

-    v8::String::Utf8Value stack_trace(try_catch->StackTrace());

-    if (stack_trace.length() > 0) {

-      const char* stack_trace_string = V8Shell::ToCString(stack_trace);

-      printf("%s\n", stack_trace_string);

-    }

-  }

-}

-

-// Extracts a C string from a V8 Utf8Value.

-const char* V8Shell::ToCString(const v8::String::Utf8Value& value) {

-  return *value ? *value : "<string conversion failed>";

-}

-

-JSShell* V8Shell_Create() {

-  return new V8Shell();

-}

+#include <assert.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <v8.h>
+#include <vector>
+
+#include "js_shell.h"
+
+typedef int (*V8ExtensionInitializer) (v8::Handle<v8::Object> module);
+
+// Note: these typedefs and defines are used to deal with  v8 API changes since version 3.19.00
+
+#if (SWIG_V8_VERSION < 0x031903)
+typedef v8::Handle<v8::Value> SwigV8ReturnValue;
+typedef v8::Arguments SwigV8Arguments;
+typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
+#define SWIGV8_RETURN(val) return scope.Close(val)
+#define SWIGV8_RETURN_INFO(val, info) return scope.Close(val)
+#else
+typedef void SwigV8ReturnValue;
+typedef v8::FunctionCallbackInfo<v8::Value> SwigV8Arguments;
+typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
+#define SWIGV8_RETURN(val) args.GetReturnValue().Set(val); return
+#define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return
+#endif
+
+
+#if (SWIG_V8_VERSION < 0x032117)
+#define SWIGV8_HANDLESCOPE() v8::HandleScope scope
+#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope
+#define SWIGV8_ESCAPE(val) return scope.Close(val)
+#elif (SWIG_V8_VERSION < 0x032318)
+#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
+#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope(v8::Isolate::GetCurrent());
+#define SWIGV8_ESCAPE(val) return scope.Close(val)
+#else
+#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
+#define SWIGV8_HANDLESCOPE_ESC() v8::EscapableHandleScope scope(v8::Isolate::GetCurrent());
+#define SWIGV8_ESCAPE(val) return scope.Escape(val)
+#endif
+
+#if (SWIG_V8_VERSION < 0x032318)
+#define SWIGV8_CURRENT_CONTEXT() v8::Context::GetCurrent()
+#define SWIGV8_STRING_NEW(str) v8::String::New(str)
+#define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(func)
+#define SWIGV8_OBJECT_NEW() v8::Object::New()
+#define SWIGV8_EXTERNAL_NEW(val) v8::External::New(val)
+#define SWIGV8_UNDEFINED() v8::Undefined()
+#else
+#define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext()
+#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str)
+#define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(v8::Isolate::GetCurrent(), func)
+#define SWIGV8_OBJECT_NEW() v8::Object::New(v8::Isolate::GetCurrent())
+#define SWIGV8_EXTERNAL_NEW(val) v8::External::New(v8::Isolate::GetCurrent(), val)
+#define SWIGV8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent())
+#endif
+
+
+#if (SWIG_V8_VERSION < 0x031900)
+typedef v8::Persistent<v8::Context> SwigV8Context;
+#else
+typedef v8::Local<v8::Context> SwigV8Context;
+#endif
+
+class V8Shell: public JSShell {
+
+public:
+  V8Shell();
+
+  virtual ~V8Shell();
+
+  virtual bool RunScript(const std::string &scriptPath);
+
+  virtual bool RunShell();
+
+
+protected:
+
+  virtual bool InitializeEngine();
+
+  virtual bool ExecuteScript(const std::string &source, const std::string &scriptPath);
+
+  virtual bool DisposeEngine();
+
+private:
+
+  v8::Handle<v8::Value> Import(const std::string &moduleName);
+
+  SwigV8Context CreateShellContext();
+
+  void ReportException(v8::TryCatch *handler);
+
+  static SwigV8ReturnValue Print(const SwigV8Arguments &args);
+
+  static SwigV8ReturnValue Require(const SwigV8Arguments &args);
+
+  static SwigV8ReturnValue Quit(const SwigV8Arguments &args);
+
+  static SwigV8ReturnValue Version(const SwigV8Arguments &args);
+
+  static const char* ToCString(const v8::String::Utf8Value &value);
+
+};
+
+#ifdef __GNUC__
+#include <dlfcn.h>
+#define LOAD_SYMBOL(handle, name) dlsym(handle, name)
+#else
+#error "implement dll loading"
+#endif
+
+V8Shell::V8Shell() {}
+
+V8Shell::~V8Shell() {}
+
+bool V8Shell::RunScript(const std::string &scriptPath) {
+  std::string source = ReadFile(scriptPath);
+
+  v8::Isolate *isolate = v8::Isolate::New();
+  v8::Isolate::Scope isolate_scope(isolate);
+
+  SWIGV8_HANDLESCOPE();
+
+  SwigV8Context context = CreateShellContext();
+
+  if (context.IsEmpty()) {
+      printf("Could not create context.\n");
+      return false;
+  }
+
+  context->Enter();
+
+  // Store a pointer to this shell for later use
+
+  v8::Handle<v8::Object> global = context->Global();
+  v8::Local<v8::External> __shell__ = SWIGV8_EXTERNAL_NEW((void*) (long) this);
+
+  global->SetHiddenValue(SWIGV8_STRING_NEW("__shell__"), __shell__);
+
+  // Node.js compatibility: make `print` available as `console.log()`
+  ExecuteScript("var console = {}; console.log = print;", "<console>");
+
+  bool success = ExecuteScript(source, scriptPath);
+
+  // Cleanup
+
+  context->Exit();
+
+#if (SWIG_V8_VERSION < 0x031710)
+    context.Dispose();
+#elif (SWIG_V8_VERSION < 0x031900)
+    context.Dispose(v8::Isolate::GetCurrent());
+#else
+//    context.Dispose();
+#endif
+
+//  v8::V8::Dispose();
+
+  return success;
+}
+
+bool V8Shell::RunShell() {
+  SWIGV8_HANDLESCOPE();
+
+  SwigV8Context context = CreateShellContext();
+
+  if (context.IsEmpty()) {
+      printf("Could not create context.\n");
+      return false;
+  }
+
+  context->Enter();
+
+  v8::Context::Scope context_scope(context);
+
+  ExecuteScript("var console = {}; console.log = print;", "<console>");
+
+  static const int kBufferSize = 1024;
+  while (true) {
+    char buffer[kBufferSize];
+    printf("> ");
+    char *str = fgets(buffer, kBufferSize, stdin);
+    if (str == NULL) break;
+    std::string source(str);
+    ExecuteScript(source, "(shell)");
+  }
+  printf("\n");
+
+  // Cleanup
+
+  context->Exit();
+
+#if (SWIG_V8_VERSION < 0x031710)
+    context.Dispose();
+#elif (SWIG_V8_VERSION < 0x031900)
+    context.Dispose(v8::Isolate::GetCurrent());
+#else
+//    context.Dispose();
+#endif
+
+//  v8::V8::Dispose();
+
+  return true;
+}
+
+
+bool V8Shell::InitializeEngine() {
+  return true;
+}
+
+bool V8Shell::ExecuteScript(const std::string &source, const std::string &name) {
+  SWIGV8_HANDLESCOPE();
+
+  v8::TryCatch try_catch;
+  v8::Handle<v8::Script> script = v8::Script::Compile(SWIGV8_STRING_NEW(source.c_str()), SWIGV8_STRING_NEW(name.c_str()));
+
+  // Stop if script is empty
+  if (script.IsEmpty()) {
+    // Print errors that happened during compilation.
+    ReportException(&try_catch);
+    return false;
+  }
+
+  v8::Handle<v8::Value> result = script->Run();
+
+  // Print errors that happened during execution.
+  if (try_catch.HasCaught()) {
+    ReportException(&try_catch);
+    return false;
+  } else {
+    return true;
+  }
+}
+
+bool V8Shell::DisposeEngine() {
+  return true;
+}
+
+SwigV8Context V8Shell::CreateShellContext() {
+  // Create a template for the global object.
+  v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
+
+  // Bind global functions
+  global->Set(SWIGV8_STRING_NEW("print"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Print));
+  global->Set(SWIGV8_STRING_NEW("quit"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Quit));
+  global->Set(SWIGV8_STRING_NEW("require"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Require));
+  global->Set(SWIGV8_STRING_NEW("version"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Version));
+
+#if (SWIG_V8_VERSION < 0x031900)
+  SwigV8Context context = v8::Context::New(NULL, global);
+  return context;
+#else
+  SwigV8Context context = v8::Context::New(v8::Isolate::GetCurrent(), NULL, global);
+  return context;
+#endif
+}
+
+v8::Handle<v8::Value> V8Shell::Import(const std::string &module_path)
+{
+  SWIGV8_HANDLESCOPE_ESC();
+
+  HANDLE library;
+  std::string module_name = LoadModule(module_path, &library);
+
+  std::string symname = std::string(module_name).append("_initialize");
+
+  V8ExtensionInitializer init_function = reinterpret_cast<V8ExtensionInitializer>((long) LOAD_SYMBOL(library, symname.c_str()));
+
+  if(init_function == 0) {
+    printf("Could not find initializer function.");
+
+    return SWIGV8_UNDEFINED();
+  }
+
+  v8::Local<v8::Object> module = SWIGV8_OBJECT_NEW();
+  init_function(module);
+
+  SWIGV8_ESCAPE(module);
+}
+
+SwigV8ReturnValue V8Shell::Print(const SwigV8Arguments &args) {
+  SWIGV8_HANDLESCOPE();
+
+  bool first = true;
+  for (int i = 0; i < args.Length(); i++) {
+
+    if (first) {
+      first = false;
+    } else {
+      printf(" ");
+    }
+    v8::String::Utf8Value str(args[i]);
+    const char *cstr = V8Shell::ToCString(str);
+    printf("%s", cstr);
+  }
+  printf("\n");
+  fflush(stdout);
+
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
+}
+
+SwigV8ReturnValue V8Shell::Require(const SwigV8Arguments &args) {
+  SWIGV8_HANDLESCOPE();
+
+  if (args.Length() != 1) {
+    printf("Illegal arguments for `require`");
+  };
+
+  v8::String::Utf8Value str(args[0]);
+  const char *cstr = V8Shell::ToCString(str);
+  std::string moduleName(cstr);
+
+  v8::Local<v8::Object> global = SWIGV8_CURRENT_CONTEXT()->Global();
+
+  v8::Local<v8::Value> hidden = global->GetHiddenValue(SWIGV8_STRING_NEW("__shell__"));
+  v8::Local<v8::External> __shell__ = v8::Local<v8::External>::Cast(hidden);
+  V8Shell *_this = (V8Shell *) (long) __shell__->Value();
+
+  v8::Handle<v8::Value> module = _this->Import(moduleName);
+
+  SWIGV8_RETURN(module);
+}
+
+SwigV8ReturnValue V8Shell::Quit(const SwigV8Arguments &args) {
+  SWIGV8_HANDLESCOPE();
+
+  int exit_code = args[0]->Int32Value();
+  fflush(stdout);
+  fflush(stderr);
+  exit(exit_code);
+
+  SWIGV8_RETURN(SWIGV8_UNDEFINED());
+}
+
+SwigV8ReturnValue V8Shell::Version(const SwigV8Arguments &args) {
+    SWIGV8_HANDLESCOPE();
+    SWIGV8_RETURN(SWIGV8_STRING_NEW(v8::V8::GetVersion()));
+}
+
+void V8Shell::ReportException(v8::TryCatch *try_catch) {
+  SWIGV8_HANDLESCOPE();
+
+  v8::String::Utf8Value exception(try_catch->Exception());
+  const char *exception_string = V8Shell::ToCString(exception);
+  v8::Handle<v8::Message> message = try_catch->Message();
+  if (message.IsEmpty()) {
+    // V8 didn't provide any extra information about this error; just
+    // print the exception.
+    printf("%s\n", exception_string);
+  } else {
+    // Print (filename):(line number): (message).
+    v8::String::Utf8Value filename(message->GetScriptResourceName());
+    const char *filename_string = V8Shell::ToCString(filename);
+    int linenum = message->GetLineNumber();
+    printf("%s:%i: %s\n", filename_string, linenum, exception_string);
+    // Print line of source code.
+    v8::String::Utf8Value sourceline(message->GetSourceLine());
+    const char *sourceline_string = V8Shell::ToCString(sourceline);
+    printf("%s\n", sourceline_string);
+    // Print wavy underline (GetUnderline is deprecated).
+    int start = message->GetStartColumn();
+    for (int i = 0; i < start; i++) {
+      printf(" ");
+    }
+    int end = message->GetEndColumn();
+    for (int i = start; i < end; i++) {
+      printf("^");
+    }
+    printf("\n");
+    v8::String::Utf8Value stack_trace(try_catch->StackTrace());
+    if (stack_trace.length() > 0) {
+      const char *stack_trace_string = V8Shell::ToCString(stack_trace);
+      printf("%s\n", stack_trace_string);
+    }
+  }
+}
+
+// Extracts a C string from a V8 Utf8Value.
+const char *V8Shell::ToCString(const v8::String::Utf8Value &value) {
+  return *value ? *value : "<string conversion failed>";
+}
+
+JSShell *V8Shell_Create() {
+  return new V8Shell();
+}
diff --git a/configure.ac b/configure.ac
index 091749f..b0c7e86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
 dnl The macros which aren't shipped with the autotools are stored in the
 dnl Tools/config directory in .m4 files.
 
-AC_INIT([swig],[3.0.1],[http://www.swig.org])
+AC_INIT([swig],[3.0.4],[http://www.swig.org])
 
 dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED
 dnl     definition below can be removed
@@ -19,7 +19,7 @@
 /* Default language */
 #define SWIG_LANG               "-tcl"
 
-/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+/* Deal with attempt by Microsoft to deprecate C standard runtime functions */
 #if defined(_MSC_VER)
 # define _CRT_SECURE_NO_DEPRECATE
 #endif
@@ -461,6 +461,8 @@
 
 AC_ARG_WITH(alllang, AS_HELP_STRING([--without-alllang], [Disable all languages]), with_alllang="$withval")
 
+AC_CHECK_PROGS(PKGCONFIG, [pkg-config])
+
 #--------------------------------------------------------------------
 # Look for Tcl
 #--------------------------------------------------------------------
@@ -489,7 +491,7 @@
    if test -f "${with_tclconfig}/tclConfig.sh" ; then
       TCLCONFIG=`(cd ${with_tclconfig}; pwd)`
    else
-      AC_MSG_ERROR([${with_tcl} directory doesn't contain tclConfig.sh])
+      AC_MSG_ERROR([${with_tcl} directory does not contain tclConfig.sh])
    fi
 fi
 # check in a few common install locations
@@ -789,7 +791,7 @@
 AC_SUBST(PY3LIB)
 AC_SUBST(PY3LINK)
 AC_SUBST(PYTHON3DYNAMICLINKING)
-
+AC_CHECK_PROGS(PEP8, pep8)
 
 #----------------------------------------------------------------
 # Look for Perl5
@@ -819,7 +821,7 @@
 # perl -MExtUtils::Embed -e ccopts
 AC_MSG_CHECKING(for Perl5 header files)
 if test -n "$PERL"; then
-	PERL5DIR=`($PERL -e 'use Config; print $Config{archlib}, "\n";') 2>/dev/null`
+	PERL5DIR=`($PERL -MConfig -le 'print $Config{archlibexp}') 2>/dev/null`
 	if test -n "$PERL5DIR" ; then
 		dirs="$PERL5DIR $PERL5DIR/CORE"
 		PERL5EXT=none
@@ -937,25 +939,43 @@
 if test -n "$OCTAVE"; then
    AC_MSG_CHECKING([for Octave preprocessor flags])
    OCTAVE_CPPFLAGS=
-   for n in CPPFLAGS INCFLAGS; do
-     OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} "`unset CPPFLAGS; ${mkoctfile} -p $n`
+   for var in CPPFLAGS INCFLAGS ALL_CXXFLAGS; do
+      for flag in `env - ${mkoctfile} -p ${var}`; do
+         case ${flag} in
+            -D*|-I*) OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} ${flag}";;
+            *) ;;
+         esac
+      done
    done
    AC_MSG_RESULT([$OCTAVE_CPPFLAGS])
    AC_MSG_CHECKING([for Octave compiler flags])
    OCTAVE_CXXFLAGS=
-   for n in ALL_CXXFLAGS; do
-     OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} "`unset CXXFLAGS; ${mkoctfile} -p $n`
+   for var in ALL_CXXFLAGS; do
+      for flag in `env - ${mkoctfile} -p ${var}`; do
+         case ${flag} in
+            -g*|-W*) OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} ${flag}";;
+            *) ;;
+         esac
+      done
    done
+   save_CXXFLAGS="${CXXFLAGS}"
+   CXXFLAGS="-Werror -O0"
+   AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[])
+   ],[
+      OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} -O0"
+   ])
+   CXXFLAGS="${save_CXXFLAGS}"
    AC_MSG_RESULT([$OCTAVE_CXXFLAGS])
    AC_MSG_CHECKING([for Octave linker flags])
    OCTAVE_LDFLAGS=
-   for n in RDYNAMIC_FLAG LFLAGS RLD_FLAG OCTAVE_LIBS LIBS; do
-     OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`${mkoctfile} -p $n`
+   for var in RDYNAMIC_FLAG LFLAGS RLD_FLAG OCTAVE_LIBS LIBS; do
+     OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`env - ${mkoctfile} -p ${var}`
    done
    AC_MSG_RESULT([$OCTAVE_LDFLAGS])
    for octave_opt in --silent --norc --no-history --no-window-system; do
       AC_MSG_CHECKING([if Octave option '${octave_opt}' is supported])
-      octave_out=`${OCTAVE} ${octave_opt} /dev/null 2>&1 | sed -n '1{/unrecognized/p}'`
+      octave_out=`${OCTAVE} ${octave_opt} /dev/null 2>&1 | sed -n '1p' | sed -n '/unrecognized/p'`
       AS_IF([test "x${octave_out}" = x],[
          AC_MSG_RESULT([yes])
          OCTAVE="${OCTAVE} ${octave_opt}"
@@ -1104,27 +1124,14 @@
   #----------------------------------------------------------------
 
   case $host in
-  *-*-cygwin* | *-*-mingw*)
-    JSLIBRARYPREFIX=""
-    ;;
-  *)
-    JSLIBRARYPREFIX="lib"
-    ;;
-  esac
-
-  case $host in
   *-*-darwin*)
     JSSO=".dylib"
-    JSLDSHARED='$(CC) -dynamiclib'
-    JSCXXSHARED='$(CXX) -dynamiclib'
     # HACK: didn't manage to get dynamic module loading working with a g++ compiled interpreter
     JSINTERPRETERCXX='c++'
     JSINTERPRETERLINKFLAGS='-g -Wl,-search_paths_first -Wl,-headerpad_max_install_names'
     ;;
   *)
     JSSO=$SO
-    JSLDSHARED='$(LDSHARED)'
-    JSCXXSHARED='$(CXXSHARED)'
     JSINTERPRETERCXX='$(CXX)'
     JSINTERPRETERLINKFLAGS='-ldl'
     ;;
@@ -1185,37 +1192,21 @@
 
   # check for JavaScriptCore/Webkit libraries
   AC_ARG_WITH(jscorelib,[  --with-jsclib =path      Set location of the JavaScriptCore/Webkit library directory],[JSCORELIB="-L$withval"], [JSCORELIB=])
-  AC_MSG_CHECKING(for JavaScriptCore/Webkit library)
 
-  # look for the library when not provided
-  if test -z "$JSCORELIB"; then
-    case $host in
-    *-*-linux*)
-      dirs="/usr/lib/ /usr/local/lib/"
-      for i in $dirs ; do
-        if test -r $i/libjavascriptcoregtk-1.0.so; then
-          AC_MSG_RESULT($i)
-          JSCORELIB="-L$i -ljavascriptcoregtk-1.0"
-          JSCOREVERSION=`pkg-config --modversion javascriptcoregtk-1.0`
-          break
-        fi
-      done
-
-      if test -z "$JSCORELIB"; then
-        AC_MSG_RESULT(not found)
-        JSCENABLED=0
-      else
-        JSCOREDYNAMICLINKING="$JSCORELIB"
-        JSCENABLED=1
-      fi
-      ;;
-    *-*-darwin*)
-      JSCOREDYNAMICLINKING="-framework JavaScriptCore"
+  if test -z "$JSCORELIB" -a -n "$PKGCONFIG"; then
+    AC_MSG_CHECKING(for JavaScriptCore/Webkit library)
+    if pkg-config javascriptcoregtk-1.0; then
+      JSCORELIB=`$PKGCONFIG --libs javascriptcoregtk-1.0`
+      JSCOREVERSION=`$PKGCONFIG --modversion javascriptcoregtk-1.0`
+    fi
+    if test -z "$JSCORELIB"; then
+      AC_MSG_RESULT(not found)
+      JSCENABLED=
+    else
+      AC_MSG_RESULT([$JSCORELIB])
+      JSCOREDYNAMICLINKING="$JSCORELIB"
       JSCENABLED=1
-      ;;
-    *)
-      ;;
-    esac
+    fi
   fi
 
   #----------------------------------------------------------------
@@ -1224,7 +1215,7 @@
 
   # check for include files
   AC_MSG_CHECKING(for V8 Javascript v8.h)
-  AC_ARG_WITH(jsv8inc, [  --with-v8inc=path    Set location of Javascript v8 include directory], [JSV8INCDIR="$withval"])
+  AC_ARG_WITH(jsv8inc, [  --with-jsv8inc=path    Set location of Javascript v8 include directory], [JSV8INCDIR="$withval"])
 
   # if not include dir is specified we try to find
   if test -z "$JSV8INCDIR"; then
@@ -1257,11 +1248,11 @@
 
   # check for V8 library
   AC_MSG_CHECKING(for V8 Javascript library)
-  AC_ARG_WITH(jsv8lib,[  --with-v8lib=path      Set location of V8 Javascript library directory],[JSV8LIBDIR="$withval"], [JSV8LIB=])
+  AC_ARG_WITH(jsv8lib,[  --with-jsv8lib=path      Set location of V8 Javascript library directory],[JSV8LIBDIR="$withval"], [JSV8LIB=])
 
-  v8libdirs="$JSV8LIBDIR /usr/lib/ /usr/local/lib/"
+  v8libdirs="$JSV8LIBDIR /usr/lib64/ /usr/local/lib64/ /usr/lib/ /usr/local/lib/"
   for d in $v8libdirs ; do
-    if test -r $d/libv8.so; then
+    if test -r $d/libv8$JSSO; then
       JSV8LIBDIR=$d
       JSV8LIB="-L$d -lv8"
       break
@@ -1270,7 +1261,7 @@
 
   if test "$JSV8LIB" = "" ; then
     AC_MSG_RESULT(not found)
-    JSV8ENABLED=0
+    JSV8ENABLED=
   else
     AC_MSG_RESULT($JSV8LIBDIR)
     JSV8ENABLED=1
@@ -1280,7 +1271,7 @@
   # linking options
   case $host in
   *-*-darwin*)
-    JSV8DYNAMICLINKING="" # TODO: add osx configuration
+    JSV8DYNAMICLINKING="$JSV8LIB"
     ;;
   *-*-linux*)
     JSV8DYNAMICLINKING="$JSV8LIB"
@@ -1292,11 +1283,6 @@
 
 fi
 
-AC_SUBST(JSLIBRARYPREFIX)
-AC_SUBST(JSSO)
-AC_SUBST(JSLDSHARED)
-AC_SUBST(JSCXXSHARED)
-
 AC_SUBST(JSINTERPRETERCXX)
 AC_SUBST(JSINTERPRETERLINKFLAGS)
 
@@ -1503,6 +1489,7 @@
 AS_HELP_STRING([--with-ruby=path], [Set location of Ruby executable]),[ RUBYBIN="$withval"], [RUBYBIN=yes])
 
 # First, check for "--without-ruby" or "--with-ruby=no".
+RUBYSO=$SO
 if test x"${RUBYBIN}" = xno -o x"${with_alllang}" = xno ; then
 AC_MSG_NOTICE([Disabling Ruby])
 RUBY=
@@ -1521,7 +1508,7 @@
         # Try Ruby1.9+ first
         RUBYDIR=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["rubyhdrdir"]] || $rubyhdrdir') 2>/dev/null`
 	if test x"$RUBYDIR" = x"" || test x"$RUBYDIR" = x"nil"; then
-		RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]] || $archdir') 2>/dev/null`
+		RUBYDIR=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["archdir"]] || $archdir') 2>/dev/null`
         else
                 RUBYARCH=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["arch"]] || $arch') 2>/dev/null`
         fi
@@ -1546,13 +1533,13 @@
 		# Find library and path for linking.
 		AC_MSG_CHECKING(for Ruby library)
 		RUBYLIB=""
-		rb_libdir=`($RUBY -rrbconfig -e 'print Config::CONFIG[["libdir"]]') 2>/dev/null`
-		rb_bindir=`($RUBY -rrbconfig -e 'print Config::CONFIG[["bindir"]]') 2>/dev/null`
+		rb_libdir=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["libdir"]]') 2>/dev/null`
+		rb_bindir=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["bindir"]]') 2>/dev/null`
 		dirs="$dirs $rb_libdir $rb_bindir"
 
-        rb_libruby=`($RUBY -rrbconfig -e 'print Config::CONFIG[["LIBRUBY_A"]]') 2>/dev/null`
+        rb_libruby=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["LIBRUBY_A"]]') 2>/dev/null`
         RUBYLINK=`($RUBY -rrbconfig -e '
-            c = Config::CONFIG
+            c = RbConfig::CONFIG
             if c.has_key? "LIBRUBYARG_STATIC" # 1.8.x
                 if c[["LIBRUBY"]] == c[["LIBRUBY_A"]]
                     link = c[["LIBRUBYARG_STATIC"]]
@@ -1598,11 +1585,11 @@
 
 	case $host in
 		*-*-mingw*) ;; # do nothing, the default windows libraries are already included
-		*) RUBYLINK="$RUBYLINK `($RUBY -rrbconfig -e 'print Config::CONFIG[["LIBS"]]') 2>/dev/null`";;
+		*) RUBYLINK="$RUBYLINK `($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["LIBS"]]') 2>/dev/null`";;
 	esac
 
-	RUBYCCDLFLAGS=`($RUBY -rrbconfig -e 'print Config::CONFIG[["CCDLFLAGS"]]') 2>/dev/null`
-	RUBYSO=.`($RUBY -rrbconfig -e 'print Config::CONFIG[["DLEXT"]]') 2>/dev/null`
+	RUBYCCDLFLAGS=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["CCDLFLAGS"]]') 2>/dev/null`
+	RUBYSO=.`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["DLEXT"]]') 2>/dev/null`
 else
 	AC_MSG_RESULT(could not figure out how to run ruby)
 fi
@@ -2266,9 +2253,13 @@
       GOGCC=true
       GOVERSIONOPTION=--version
       AC_MSG_CHECKING([whether gccgo version is too old])
-      go_version=`$GO $GOVERSIONOPTION | sed -e 's/[^0-9]* \([0-9.]*\) .*$/\1/' -e 's/[.]//g'`
-      if test "$go_version" -lt 470; then
+      go_version=[`$GO $GOVERSIONOPTION | sed -n '1p' | sed -e 's/^.* \([0-9.]*\) *$/\1/' -e 's/[.]//g'`]
+      if test "x$go_version" = x; then
+        AC_MSG_RESULT([could not determine gccgo version - disabling Go])
+        GO=
+      elif test "$go_version" -lt 470; then
         AC_MSG_RESULT([yes - minimum version is 4.7.0])
+        GO=
       else
 	AC_MSG_RESULT([no])
         if test "$go_version" -lt 480; then
@@ -2287,17 +2278,24 @@
       GOVERSIONOPTION=version
       GOC=$(sh -c "$(go env) && echo \$GOCHAR")c
       go_version=$($GO $GOVERSIONOPTION | sed -e 's/go version //')
+      AC_MSG_CHECKING([whether go version is too old])
       case $go_version in
-      go1.0*) GOOPT="-intgosize 32" ;;
-      *) if test "$GOC" = "6c"; then
-           GOOPT="-intgosize 64"
-         else
-           GOOPT="-intgosize 32"
-	 fi
-	 ;;
+      go1.0* | go1 )
+	AC_MSG_RESULT([yes - minimum version is 1.1])
+	GO=
+	GOOPT="-intgosize 32"
+	;;
+      *)
+	AC_MSG_RESULT([no])
+	if test "$GOC" = "6c"; then
+          GOOPT="-intgosize 64"
+        else
+          GOOPT="-intgosize 32"
+	fi
+	;;
       esac
       case $go_version in
-      go1.0* | go1.1*)
+      go1.0* | go1 | go1.1*)
 	GOOPT="$GOOPT -use-shlib"
 	;;
       go1.2*)
@@ -2311,14 +2309,17 @@
       GOC=`echo $GO | sed -e 's/g/c/'`
       GOVERSIONOPTION=-V
       AC_MSG_CHECKING([whether Go ($GO) version is too old])
-      go_version=`$GO $GOVERSIONOPTION 2>/dev/null | sed -e 's/.*version.* \([[0-9]]*\).*/\1/'`
-      go_min_version=7077
-      if test "$go_version" != "" -a "$go_version" -lt $go_min_version; then
-        AC_MSG_RESULT([yes - minimum version is $go_min_version])
-        GO=
-      else
-        AC_MSG_RESULT([no])
-      fi
+      AC_MSG_RESULT([yes - minimum version is 1.1])
+      GO=
+      dnl Old code retained for now in case we implement an option for it.
+      dnl go_version=`$GO $GOVERSIONOPTION 2>/dev/null | sed -e 's/.*version.* \([[0-9]]*\).*/\1/'`
+      dnl go_min_version=7077
+      dnl if test "$go_version" != "" -a "$go_version" -lt $go_min_version; then
+      dnl   AC_MSG_RESULT([yes - minimum version is $go_min_version])
+      dnl   GO=
+      dnl else
+      dnl   AC_MSG_RESULT([no])
+      dnl fi
       GOOPT="-intgosize 32"
       GO12=false
       GO13=false
@@ -2643,6 +2644,7 @@
     Makefile
     swig.spec
     Examples/Makefile
+    Examples/d/example.mk
     Examples/xml/Makefile
     Examples/test-suite/errors/Makefile
     Examples/test-suite/chicken/Makefile
@@ -2673,5 +2675,71 @@
 AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig])
 AC_CONFIG_FILES([CCache/ccache_swig_config.h])
 
+#--------------------------------------------------------------------
+# Building Examples/ out of source directory
+#--------------------------------------------------------------------
+
+# If building out of source tree, replicate Examples/ source tree in
+# build directory, and copy over Makefiles from source directory.
+# Prefix each Makefile with a header which sets SRCDIR to the relative
+# source directory, and provides a rule for updating the Makefile from
+# its original source.
+AC_CONFIG_COMMANDS([Examples],[
+  if test "x${srcdir}" != "x." ; then
+    AC_MSG_NOTICE([generating Examples build tree])
+    for mkfile in `cd ${srcdir} && find Examples/ -type f -name Makefile`; do
+      dir=`dirname ${mkfile}`
+      d=${dir}
+      reldir="";
+      while test "x$d" != "x." ; do
+        d=`dirname $d`
+        reldir="${reldir}../"
+      done
+      relsrcdir=${reldir}${srcdir}/
+      AS_MKDIR_P([${dir}])
+      cat <<EOF >${mkfile}
+# DO NOT EDIT: instead edit ${relsrcdir}${mkfile}
+# and run (cd ${reldir} && ./config.status) to regenerate
+SRCDIR = ${relsrcdir}${dir}/
+
+EOF
+      cat ${srcdir}/${mkfile} >>${mkfile}
+    done
+  fi
+])
+
+#--------------------------------------------------------------------
+
 AC_OUTPUT
+
+langs=""
+test -n "$SKIP_ALLEGROCL"	|| langs="${langs}allegrocl "
+test -n "$SKIP_CFFI"		|| langs="${langs}cffi "
+test -n "$SKIP_CHICKEN"		|| langs="${langs}chicken "
+test -n "$SKIP_CLISP"		|| langs="${langs}clisp "
+test -n "$SKIP_CSHARP"		|| langs="${langs}csharp "
+test -n "$SKIP_D"		|| langs="${langs}d "
+test -n "$SKIP_GO"		|| langs="${langs}go "
+test -n "$SKIP_GUILE"		|| langs="${langs}guile "
+test -n "$SKIP_JAVA"		|| langs="${langs}java "
+test -n "$SKIP_JAVASCRIPT"	|| langs="${langs}javascript "
+test -n "$SKIP_LUA"		|| langs="${langs}lua "
+test -n "$SKIP_MODULA3"		|| langs="${langs}modula3 "
+test -n "$SKIP_MZSCHEME"	|| langs="${langs}mzscheme "
+test -n "$SKIP_OCAML"		|| langs="${langs}ocaml "
+test -n "$SKIP_OCTAVE"		|| langs="${langs}octave "
+test -n "$SKIP_PERL5"		|| langs="${langs}perl5 "
+test -n "$SKIP_PHP"		|| langs="${langs}php "
+test -n "$SKIP_PIKE"		|| langs="${langs}pike "
+test -n "$SKIP_PYTHON"		|| langs="${langs}python "
+test -n "$SKIP_R"		|| langs="${langs}r "
+test -n "$SKIP_RUBY"		|| langs="${langs}ruby "
+test -n "$SKIP_TCL"		|| langs="${langs}tcl "
+test -n "$SKIP_UFFI"		|| langs="${langs}uffi "
+
+echo "
+The SWIG test-suite and examples are configured for the following languages:
+$langs
+"
+
 dnl configure.ac ends here
diff --git a/preinst-swig.in b/preinst-swig.in
index 0f49e2e..384593c 100755
--- a/preinst-swig.in
+++ b/preinst-swig.in
@@ -4,4 +4,4 @@
 SWIG_LIB=$srcdir/Lib
 #SWIG_LIB=`cygpath -w $srcdir/Lib` # For native Windows version of SWIG
 export SWIG_LIB
-exec "$builddir/swig" $*
+exec "$builddir/swig" "$@"