diff -rubB libtool-1.5.22.orig/demo/foo.c libtool-1.5.22/demo/foo.c
--- libtool-1.5.22.orig/demo/foo.c	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/demo/foo.c	2006-09-11 08:25:37.000000000 +0200
@@ -18,7 +18,9 @@
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 USA. */
 
+#define __EXPORT_FOO__
 #include "foo.h"
+#undef __EXPORT_FOO__
 
 #include <stdio.h>
 
@@ -27,7 +29,7 @@
 #endif
 
 /* Give a global variable definition. */
-int nothing = FOO_RET;
+int _foo_EXPORT nothing = FOO_RET;
 
 int
 foo ()
diff -rubB libtool-1.5.22.orig/demo/foo.h libtool-1.5.22/demo/foo.h
--- libtool-1.5.22.orig/demo/foo.h	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/demo/foo.h	2006-09-11 08:25:37.000000000 +0200
@@ -33,6 +33,21 @@
 #  endif
 #endif
 
+/* __PXWC__ is defined whenever compiling under Interix* with wgcc.
+ * If it is defined we need to define some macros to export vars
+ * on native win32.
+ */
+
+#ifdef __PXWC__
+#  ifdef __EXPORT_FOO__
+#    define _foo_EXPORT
+#  else
+#    define _foo_EXPORT __declspec(dllimport)
+#  endif
+#else
+#  define _foo_EXPORT
+#endif
+
 /* __BEGIN_DECLS should be used at the beginning of your declarations,
    so that C++ compilers don't mangle their names.  Use __END_DECLS at
    the end of C declarations. */
@@ -67,7 +82,7 @@
 __BEGIN_DECLS
 int foo LT_PARAMS((void));
 int hello LT_PARAMS((void));
-extern int nothing;
+extern _foo_EXPORT int nothing;
 __END_DECLS
 
 #endif /* !_FOO_H_ */
diff -rubB libtool-1.5.22.orig/depdemo/l1/l1.c libtool-1.5.22/depdemo/l1/l1.c
--- libtool-1.5.22.orig/depdemo/l1/l1.c	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/depdemo/l1/l1.c	2006-09-11 08:25:37.000000000 +0200
@@ -17,10 +17,12 @@
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 USA. */
 
+#define __EXPORT_L1__
 #include "l1/l1.h"
+#undef __EXPORT_L1__
 #include <stdio.h>
 
-int	var_l1 = 0;
+int	_l1_EXPORT var_l1 = 0;
 
 int
 func_l1(indent)
diff -rubB libtool-1.5.22.orig/depdemo/l1/l1.h libtool-1.5.22/depdemo/l1/l1.h
--- libtool-1.5.22.orig/depdemo/l1/l1.h	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/depdemo/l1/l1.h	2006-09-11 08:25:37.000000000 +0200
@@ -23,8 +23,18 @@
 
 #include "sysdep.h"
 
+#if defined(__PXWC__)
+#	if defined(__EXPORT_L1__)
+#		define _l1_EXPORT 
+#	else
+#		define _l1_EXPORT __declspec(dllimport)
+#	endif
+#else
+#	define _l1_EXPORT
+#endif
+
 __BEGIN_DECLS
-extern int var_l1;
+extern _l1_EXPORT int var_l1;
 int	func_l1 __P((int));
 __END_DECLS
 
diff -rubB libtool-1.5.22.orig/depdemo/l2/l2.c libtool-1.5.22/depdemo/l2/l2.c
--- libtool-1.5.22.orig/depdemo/l2/l2.c	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/depdemo/l2/l2.c	2006-09-11 08:25:37.000000000 +0200
@@ -17,12 +17,14 @@
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 USA. */
 
+#define __EXPORT_L2__
 #include "l2/l2.h"
+#undef __EXPORT_L2__
 
 #include "l1/l1.h"
 #include <stdio.h>
 
-int	var_l2 = 0;
+int	_l2_EXPORT var_l2 = 0;
 
 int
 func_l2(indent)
diff -rubB libtool-1.5.22.orig/depdemo/l2/l2.h libtool-1.5.22/depdemo/l2/l2.h
--- libtool-1.5.22.orig/depdemo/l2/l2.h	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/depdemo/l2/l2.h	2006-09-11 08:25:37.000000000 +0200
@@ -23,8 +23,18 @@
 
 #include "sysdep.h"
 
+#if defined(__PXWC__)
+#	if defined(__EXPORT_L2__)
+#		define _l2_EXPORT 
+#	else
+#		define _l2_EXPORT __declspec(dllimport)
+#	endif
+#else
+#	define _l2_EXPORT
+#endif
+
 __BEGIN_DECLS
-extern int var_l2;
+extern _l2_EXPORT int var_l2;
 int	func_l2 __P((int));
 __END_DECLS
 
diff -rubB libtool-1.5.22.orig/depdemo/l3/l3.c libtool-1.5.22/depdemo/l3/l3.c
--- libtool-1.5.22.orig/depdemo/l3/l3.c	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/depdemo/l3/l3.c	2006-09-11 08:25:37.000000000 +0200
@@ -17,13 +17,15 @@
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 USA. */
 
+#define __EXPORT_L3__
 #include "l3/l3.h"
+#undef __EXPORT_L3__
 
 #include "l1/l1.h"
 #include "l2/l2.h"
 #include <stdio.h>
 
-int	var_l3 = 0;
+int	_l3_EXPORT var_l3 = 0;
 
 int
 func_l3(indent)
diff -rubB libtool-1.5.22.orig/depdemo/l3/l3.h libtool-1.5.22/depdemo/l3/l3.h
--- libtool-1.5.22.orig/depdemo/l3/l3.h	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/depdemo/l3/l3.h	2006-09-11 08:25:37.000000000 +0200
@@ -23,8 +23,18 @@
 
 #include "sysdep.h"
 
+#if defined(__PXWC__)
+#   if defined(__EXPORT_L3__)
+#       define _l3_EXPORT 
+#   else
+#       define _l3_EXPORT __declspec(dllimport)
+#   endif
+#else
+#   define _l3_EXPORT
+#endif
+
 __BEGIN_DECLS
-extern int var_l3;
+extern _l3_EXPORT int var_l3;
 int	func_l3 __P((int));
 __END_DECLS
 
diff -rubB libtool-1.5.22.orig/depdemo/l4/l4.c libtool-1.5.22/depdemo/l4/l4.c
--- libtool-1.5.22.orig/depdemo/l4/l4.c	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/depdemo/l4/l4.c	2006-09-11 08:25:37.000000000 +0200
@@ -17,7 +17,9 @@
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 USA. */
 
+#define __EXPORT_L4__
 #include "l4/l4.h"
+#undef __EXPORT_L4__
 
 #include "l3/l3.h"
 #include <stdio.h>
@@ -26,7 +28,7 @@
 #include <math.h>
 #endif
 
-int	var_l4 = 0;
+int	_l4_EXPORT var_l4 = 0;
 
 int
 func_l4(indent)
diff -rubB libtool-1.5.22.orig/depdemo/l4/l4.h libtool-1.5.22/depdemo/l4/l4.h
--- libtool-1.5.22.orig/depdemo/l4/l4.h	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/depdemo/l4/l4.h	2006-09-11 08:25:37.000000000 +0200
@@ -23,8 +23,18 @@
 
 #include "sysdep.h"
 
+#if defined(__PXWC__)
+#   if defined(__EXPORT_L4__)
+#       define _l4_EXPORT 
+#   else
+#       define _l4_EXPORT __declspec(dllimport)
+#   endif
+#else
+#   define _l4_EXPORT
+#endif
+
 __BEGIN_DECLS
-extern int var_l4;
+extern _l4_EXPORT int var_l4;
 int	func_l4 __P((int));
 __END_DECLS
 
diff -rubB libtool-1.5.22.orig/libltdl/ltdl.c libtool-1.5.22/libltdl/ltdl.c
--- libtool-1.5.22.orig/libltdl/ltdl.c	2005-10-31 20:44:43.000000000 +0100
+++ libtool-1.5.22/libltdl/ltdl.c	2006-09-11 08:25:37.000000000 +0200
@@ -1304,6 +1304,88 @@
 /* dynamic linking for Win32 */
 
 #include <windows.h>
+#ifdef __PXWC__
+#include <dirent.h>
+
+
+/* recursivly searches a dir for a matching .dll file for the given
+ * import library name
+ */
+static char* _search_dir_rec(char* dirname, char * basename)
+{
+	struct dirent * entry;
+	char * final = NULL;
+	DIR* dir = opendir(dirname);
+
+	if(!dir)
+		return NULL;
+
+	while((entry = readdir(dir)) != NULL)
+	{
+		char absolute[MAX_PATH];
+		struct stat info;
+		strcpy(absolute, dirname);
+		strcat(absolute, "\\");
+		strcat(absolute, entry->d_name);
+		stat(absolute, &info);
+
+		if(info.st_mode & S_IFDIR && !(strcmp(entry->d_name, "..") == 0 || strcmp(entry->d_name, ".") == 0))
+		{
+			final = _search_dir_rec(absolute, basename);
+			if(final)
+				break;
+		} else if(!(info.st_mode & S_IFDIR)) {
+			if(strstr(entry->d_name, ".dll") && strstr(entry->d_name, basename))
+			{
+				final = strdup(absolute);
+				break;
+			}	
+		}
+	}
+
+	closedir(dir);
+	return final;
+}
+
+/* searches the given directory for a .dll file dor the given import lib
+ */
+static char * _find_dll_file(char * imp_lib)
+{
+	if(strstr(imp_lib, ".so"))
+	{
+		char dirname[MAX_PATH];
+		int slash_idx = -1;
+		char * tmp;
+		DIR* dir = NULL;
+		char basename[MAX_PATH];
+		char * final;
+
+		strcpy(dirname, imp_lib);
+		tmp  = dirname + strlen(dirname) -1;
+
+		/* get dirname */
+		while(*tmp != '\\' && tmp != dirname)
+			tmp--;
+
+		strcpy(basename, tmp+1);
+		*tmp = '\0';
+
+		/* up one mor dir! */
+		while(*tmp != '\\' && tmp != dirname)
+			tmp--;
+
+		*tmp = '\0';
+
+		final = _search_dir_rec(dirname, basename);
+		
+		return final;
+	} else {
+		return NULL;
+	}
+}
+
+#endif
+
 
 /* Forward declaration; required to implement handle search below. */
 static lt_dlhandle handles;
@@ -1361,6 +1443,24 @@
       cygwin_conv_to_full_win32_path (searchname, wpath);
       module = LoadLibrary (wpath);
     }
+#elif defined(__PXWC__)
+	{
+	  char wpath[MAX_PATH];
+	  char * tmp;
+	  strcpy(wpath, searchname);
+	  __pxwc_convert(wpath, MAX_PATH);
+
+	  /* try finding a matching module */
+	  tmp = _find_dll_file(wpath);
+
+	  if(tmp)
+	  {
+	    module = LoadLibrary(tmp);
+		free(tmp);
+	  } else {
+		module = GetModuleHandle(NULL);
+	  }
+	}
 #else
     module = LoadLibrary (searchname);
 #endif
@@ -1433,6 +1533,80 @@
 
   if (!address)
     {
+#ifdef __PXWC__
+		char tmp[MAX_PATH] = "_";
+		char * strtmp;
+		char fname[MAX_PATH];
+
+		/* find module name needed for symbol name mangling... */
+		GetModuleFileName(module, fname, MAX_PATH);
+
+		strtmp = fname + strlen(fname);
+
+		while(*strtmp != '\\' && strtmp != fname)
+			strtmp--;
+
+		strtmp++;
+
+		/* demangled module name for symbol mangling */
+		strtmp[strcspn(strtmp, ".")] = '\0';
+
+		if(strtmp && strlen(strtmp) > 0)
+		{
+			strcat(tmp, strtmp);
+		}
+
+		strcat(tmp, "_LTX_");
+		strcat(tmp, symbol);
+		address = GetProcAddress(module, tmp);
+		if(address)
+			return address;
+
+		/* __imp_ and __imp__ are dangerous here i think, because they
+		 * are pointers to the real symbol, so one should dereference this
+		 * but i think the symbol should be found without __imp__ anyway
+		 */
+		strcpy(tmp, "__imp_");
+		if(strtmp && strlen(strtmp) > 0)
+		{
+			strcat(tmp, strtmp);
+		}
+
+		strcat(tmp, "_LTX_");
+		strcat(tmp, symbol);
+		address = GetProcAddress(module, tmp);
+		if(address)
+			return *((void**)address);
+
+		strcpy(tmp, "__imp__");
+		if(strtmp && strlen(strtmp) > 0)
+		{
+			strcat(tmp, strtmp);
+		}
+
+		strcat(tmp, "_LTX_");
+		strcat(tmp, symbol);
+		address = GetProcAddress(module, tmp);
+		if(address)
+			return *((void**)address);
+
+		strcat(tmp, symbol);
+		address = GetProcAddress(module, tmp);
+		if(address)
+			return address;
+		
+		strcpy(tmp, "__imp_");
+		strcat(tmp, symbol);
+		address = GetProcAddress(module, tmp);
+		if(address)
+			return *((void**)address);
+		
+		strcpy(tmp, "__imp__");
+		strcat(tmp, symbol);
+		address = GetProcAddress(module, tmp);
+		if(address)
+			return *((void**)address);
+#endif
       LT_DLMUTEX_SETERROR (LT_DLSTRERROR (SYMBOL_NOT_FOUND));
     }
 
@@ -2744,12 +2918,21 @@
   char	     **pdir	= (char **) data1;
   FILE	     **pfile	= (FILE **) data2;
   int	     is_done	= 0;
+#if defined(__PXWC__)  
+  char		 wpath[MAX_PATH];
+#endif  
 
   assert (filename && *filename);
   assert (pdir);
   assert (pfile);
 
+#if defined(__PXWC__)
+  strcpy(wpath, filename);
+  __pxwc_convert(wpath, MAX_PATH);
+  if ((*pfile = fopen (wpath, LT_READTEXT_MODE)))
+#else
   if ((*pfile = fopen (filename, LT_READTEXT_MODE)))
+#endif
     {
       char *dirend = strrchr (filename, '/');
 
@@ -3205,7 +3388,14 @@
 	}
       if (!file)
 	{
+#if defined(__PXWC__)
+		char wpath[MAX_PATH];
+		strcpy(wpath, filename);
+		__pxwc_convert(wpath, MAX_PATH);
+		file = fopen (wpath, LT_READTEXT_MODE);
+#else
 	  file = fopen (filename, LT_READTEXT_MODE);
+#endif
 	}
 
       /* If we didn't find the file by now, it really isn't there.  Set
@@ -3675,13 +3865,22 @@
 {
   DIR	*dirp	  = 0;
   int    errors	  = 0;
+#if defined(__PXWC__)  
+  char wpath[MAX_PATH];
+#endif  
 
   assert (dirnam && *dirnam);
   assert (pargz);
   assert (pargz_len);
   assert (dirnam[LT_STRLEN(dirnam) -1] != '/');
 
+#if defined(__PXWC__)
+	strcpy(wpath, dirnam);
+	__pxwc_convert(wpath, MAX_PATH);
+	dirp = opendir (wpath);
+#else
   dirp = opendir (dirnam);
+#endif
   if (dirp)
     {
       struct dirent *dp	= 0;
diff -rubB libtool-1.5.22.orig/libltdl/ltmain.sh libtool-1.5.22/libltdl/ltmain.sh
--- libtool-1.5.22.orig/libltdl/ltmain.sh	2005-12-18 23:14:54.000000000 +0100
+++ libtool-1.5.22/libltdl/ltmain.sh	2006-09-11 09:00:19.000000000 +0200
@@ -4024,7 +4024,7 @@
 	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
 	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
 	  :
-	else
+	elif "`uname`" ne "Interix"; then
 	  # The command line is too long to link in one step, link piecewise.
 	  $echo "creating reloadable object files..."
 
@@ -4569,10 +4569,16 @@
 	  fi
 
 	  for arg in $dlprefiles; do
+	    case "$CC" in
+		*wgcc*)
+		  ;;
+		*)  
 	    $show "extracting global C symbols from \`$arg'"
 	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
 	    $run eval '$echo ": $name " >> "$nlist"'
 	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+		  ;;
+		esac  
 	  done
 
 	  if test -z "$run"; then
@@ -5310,6 +5316,14 @@
 "
 
 	if test "$fast_install" = yes; then
+	case "`uname`:$CC" in
+	Interix:wgcc)
+	  $echo >> $output "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+		;;
+	*)	
 	  $echo >> $output "\
   program=lt-'$outputname'$exeext
   progdir=\"\$thisdir/$objdir\"
@@ -5343,6 +5357,8 @@
       $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
     $rm \"\$progdir/\$file\"
   fi"
+		;;
+	esac	
 	else
 	  $echo >> $output "\
   program='$outputname'
diff -rubB libtool-1.5.22.orig/libtool.m4 libtool-1.5.22/libtool.m4
--- libtool-1.5.22.orig/libtool.m4	2005-12-18 22:53:17.000000000 +0100
+++ libtool-1.5.22/libtool.m4	2006-09-11 08:25:37.000000000 +0200
@@ -928,9 +928,15 @@
    ;;
 
   cygwin*)
+  	case "$CC" in
+	*wgcc*)
+		;;
+	*)	
     lt_cv_dlopen="dlopen"
     lt_cv_dlopen_libs=
    ;;
+	esac	
+   ;;
 
   darwin*)
   # if libdl is installed we need to link against it
@@ -1063,6 +1069,11 @@
    cd ..
    rmdir conftest
    $rm conftest*
+   case "$CC" in
+   *wgcc*)
+   	$rm -rf conftest
+	;;
+   esac	
 ])
 ])# AC_LIBTOOL_PROG_CC_C_O
 
@@ -1357,6 +1368,36 @@
   dynamic_linker='Win32 ld.exe'
   # FIXME: first we should search . and the directory the executable is in
   shlibpath_var=PATH
+
+	case $cc_basename in
+	*wgcc*)
+		shrext_cmds=".so"
+		version_type=linux
+		need_lib_prefix=no
+		need_version=no
+		library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+		soname_spec='${libname}${release}${shared_ext}$major'
+		hardcode_into_libs=yes
+
+		shlibpath_var=PATH
+		shlibpath_overrides_runpath=yes
+		dynamic_linker='Interix to Win32 cross linker (wgcc)'
+		# the wgcc linker gives .dll files with the .so's...
+		postinstall_cmds='base_file=`basename \${file}`~
+			dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+			dldir=$destdir/`dirname \$dlpath` ~
+			set dummy `ls -l $dir/\$dlname*.dll` ~
+			while test -n "\${3}" ; do shift; done ~
+			dllname=`basename ${2}` ~
+			test -d \${dldir}/../bin || mkdir -p \${dldir}/../bin ~
+			$install_prog $dir/$dllname \$dldir/../bin/$dllname ~
+			chmod a+x \$dldir/../bin/$dllname'
+		postuninstall_cmds='dlpath=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+			set dummy `ls -l $dir/../bin/\$dlname*.dll` ~
+			while test -n "\${3}" ; do shift; done ~
+			$rm ${2}'
+	;;
+	esac
   ;;
 
 darwin* | rhapsody*)
@@ -1503,7 +1544,7 @@
   postinstall_cmds='chmod 555 $lib'
   ;;
 
-interix3*)
+interix*)
   version_type=linux
   need_lib_prefix=no
   need_version=no
@@ -1513,6 +1554,29 @@
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
   hardcode_into_libs=yes
+
+	case $cc_basename in
+	*wgcc*)
+		shlibpath_var=PATH
+		shlibpath_overrides_runpath=yes
+		dynamic_linker='Interix to Win32 cross linker (wgcc)'
+		# the wgcc linker gives .dll files with the .so's...
+		postinstall_cmds='base_file=`basename \${file}`~
+			dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+			dldir=$destdir/`dirname \$dlpath` ~
+			set dummy `ls -l $dir/\$dlname*.dll` ~
+			while test -n "\${3}" ; do shift; done ~
+			dllname=`basename ${2}` ~
+			test -d \${dldir}/../bin || mkdir -p \${dldir}/../bin ~
+			$install_prog $dir/$dllname \$dldir/../bin/$dllname ~
+			chmod a+x \$dldir/../bin/$dllname'
+		postuninstall_cmds='dlpath=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+			set dummy `ls -l $dir/../bin/\$dlname*.dll` ~
+			while test -n "\${3}" ; do shift; done ~
+			$rm ${2}'
+	;;
+	esac
+  
   ;;
 
 irix5* | irix6* | nonstopux*)
@@ -2289,9 +2353,16 @@
 
 cygwin*)
   # func_win32_libid is a shell function defined in ltmain.sh
+  case $CC in
+  *wgcc*)
+  lt_cv_deplibs_check_method='pass_all'
+	  ;;
+  *) 
   lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
   lt_cv_file_magic_cmd='func_win32_libid'
   ;;
+  esac
+  ;;
 
 mingw* | pw32*)
   # Base MSYS/MinGW do not provide the 'file' command needed by
@@ -2342,10 +2413,17 @@
   esac
   ;;
 
-interix3*)
+interix*)
   # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  case $CC in
+  *wgcc*)
+  lt_cv_deplibs_check_method='pass_all'
+	  ;;
+  *) 
   lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
   ;;
+  esac 
+  ;;
 
 irix5* | irix6* | nonstopux*)
   case $LD in
@@ -3005,6 +3083,22 @@
     ;;
 
   cygwin* | mingw* | pw32*)
+  	case "$CC" in
+	*wgcc*)
+		_LT_AC_TAGVAR(hardcode_direct, $1)=no
+		_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+		_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+		_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=''
+		# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+		# Instead, shared libraries are loaded at an image base (0x10000000 by
+		# default) and relocated if they conflict, which is a slow very memory
+		# consuming and fragmenting process.  To avoid this, we pick a random,
+		# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+		# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+		_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+		_LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+		;;
+	*)
     # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
     # as there is no search path for DLLs.
     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
@@ -3027,6 +3121,8 @@
       _LT_AC_TAGVAR(ld_shlibs, $1)=no
     fi
   ;;
+	esac
+  ;;
       darwin* | rhapsody*)
         case $host_os in
         rhapsody* | darwin1.[[012]])
@@ -3233,11 +3329,18 @@
 	;;
     esac
     ;;
-  interix3*)
+  interix*)
     _LT_AC_TAGVAR(hardcode_direct, $1)=no
     _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
     _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	case $cc_basename in
+	*wgcc*)
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=''
+		;;
+	*)
     _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+		;;
+	esac	
     # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
     # Instead, shared libraries are loaded at an image base (0x10000000 by
     # default) and relocated if they conflict, which is a slow very memory
@@ -3864,7 +3967,7 @@
 # PORTME: override above test on systems where it is broken
 ifelse([$1],[CXX],
 [case $host_os in
-interix3*)
+interix*)
   # Interix 3.5 installs completely hosed .la files for C++, so rather than
   # hack all around it, let's just trust "g++" to DTRT.
   _LT_AC_TAGVAR(predep_objects,$1)=
@@ -3872,6 +3975,18 @@
   _LT_AC_TAGVAR(postdeps,$1)=
   ;;
 
+  
+cygwin* | mingw* | pw32*)
+	case "$CC" in
+	*wgcc*)
+	  # wgcc comes from Interix, so make it feel home ;o)
+	  _LT_AC_TAGVAR(predep_objects,$1)=
+	  _LT_AC_TAGVAR(postdep_objects,$1)=
+	  _LT_AC_TAGVAR(postdeps,$1)=
+	;;
+	esac
+	;;
+
 solaris*)
   case $cc_basename in
   CC*)
@@ -4855,7 +4970,7 @@
       # DJGPP does not support shared libraries at all
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
       ;;
-    interix3*)
+    interix*)
       # Interix 3.x gcc -fpic/-fPIC options generate broken code.
       # Instead, we relocate shared libraries at runtime.
       ;;
@@ -4949,9 +5064,27 @@
 	    ;;
 	esac
 	;;
+	cygwin*|mingw*|pw32*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+
+	case $cc_basename in
+	*wgcc*)
+		_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+		_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+		;;
+	esac
+	;;
       interix*)
 	# This is c89, which is MS Visual C++ (no shared libs)
 	# Anyone wants to do a port?
+
+	case $cc_basename in
+	*wgcc*)
+		_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+		_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+		;;
+	esac
 	;;
       irix5* | irix6* | nonstopux*)
 	case $cc_basename in
@@ -5127,7 +5260,7 @@
       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
       ;;
 
-    interix3*)
+    interix*)
       # Interix 3.x gcc -fpic/-fPIC options generate broken code.
       # Instead, we relocate shared libraries at runtime.
       ;;
@@ -5207,6 +5340,24 @@
       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
       ;;
 
+	cygwin*|mingw*|pw32*)
+	case $cc_basename in
+	*wgcc*)
+		_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+		_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+		;;
+	esac
+	;;
+
+	interix*)
+	case $cc_basename in
+	*wgcc*)
+		_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+		_LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+		;;
+	esac
+	;;
+
     irix5* | irix6* | nonstopux*)
       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
       # PIC (with -KPIC) is the default.
@@ -5357,8 +5508,14 @@
     _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
   ;;
   cygwin* | mingw*)
+  	case "$CC" in
+	*wgcc*)
+		;;
+	*)	
     _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
+	esac	
+  ;;
   *)
     _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   ;;
@@ -5410,6 +5567,12 @@
     if test "$GCC" != yes; then
       with_gnu_ld=no
     fi
+
+	case "$CC" in
+	*wgcc*)
+		with_gnu_ld=yes
+		;;
+	esac	
     ;;
   interix*)
     # we just hope/assume this is gcc and not c89 (= MSVC++)
@@ -5490,6 +5653,22 @@
       ;;
 
     cygwin* | mingw* | pw32*)
+	  case "$CC" in
+	  *wgcc*)
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=''
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	  	;;
+	  *)
       # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
       # as there is no search path for DLLs.
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
@@ -5513,12 +5692,21 @@
 	_LT_AC_TAGVAR(ld_shlibs, $1)=no
       fi
       ;;
+	  esac
+      ;;
 
-    interix3*)
+    interix*)
       _LT_AC_TAGVAR(hardcode_direct, $1)=no
       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+	  case $cc_basename in
+	  *wgcc*)
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=''
+		  ;;
+	  *)
       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+		  ;;
+	  esac 
       # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
       # Instead, shared libraries are loaded at an image base (0x10000000 by
       # default) and relocated if they conflict, which is a slow very memory
@@ -5790,6 +5978,22 @@
       ;;
 
     cygwin* | mingw* | pw32*)
+	  case "$CC" in
+	  *wgcc*)
+	  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=''
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	  	;;
+	  *)
       # When not using gcc, we currently assume that we are using
       # Microsoft Visual C++.
       # hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -5809,6 +6013,8 @@
       _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
       _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
       ;;
+	  esac
+	  ;;
 
     darwin* | rhapsody*)
       case $host_os in
diff -rubB libtool-1.5.22.orig/ltdl.m4 libtool-1.5.22/ltdl.m4
--- libtool-1.5.22.orig/ltdl.m4	2005-12-18 22:53:17.000000000 +0100
+++ libtool-1.5.22/ltdl.m4	2006-09-11 08:25:37.000000000 +0200
@@ -134,6 +134,14 @@
   hpux10*|hpux11*)
     libltdl_cv_sys_dlopen_deplibs=yes
     ;;
+  cygwin*|mingw*|pw32*)
+  	case "$CC" in
+	*wgcc*)
+		libltdl_cv_sys_dlopen_deplibs=yes
+		;;
+	esac
+	;;
+
   interix*)
     libltdl_cv_sys_dlopen_deplibs=yes
     ;;
diff -rubB libtool-1.5.22.orig/ltmain.in libtool-1.5.22/ltmain.in
--- libtool-1.5.22.orig/ltmain.in	2005-12-18 22:43:52.000000000 +0100
+++ libtool-1.5.22/ltmain.in	2006-09-11 08:25:37.000000000 +0200
@@ -4024,7 +4024,7 @@
 	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
 	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
 	  :
-	else
+	elif "`uname`" ne "Interix"; then
 	  # The command line is too long to link in one step, link piecewise.
 	  $echo "creating reloadable object files..."
 
@@ -4569,10 +4569,16 @@
 	  fi
 
 	  for arg in $dlprefiles; do
+	    case "$CC" in
+		*wgcc*)
+		  ;;
+		*)  
 	    $show "extracting global C symbols from \`$arg'"
 	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
 	    $run eval '$echo ": $name " >> "$nlist"'
 	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+		  ;;
+		esac  
 	  done
 
 	  if test -z "$run"; then
@@ -5310,6 +5316,14 @@
 "
 
 	if test "$fast_install" = yes; then
+	case "`uname`:$CC" in
+	Interix:wgcc)
+	  $echo >> $output "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+		;;
+	*)	
 	  $echo >> $output "\
   program=lt-'$outputname'$exeext
   progdir=\"\$thisdir/$objdir\"
@@ -5343,6 +5357,8 @@
       $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
     $rm \"\$progdir/\$file\"
   fi"
+		;;
+	esac	
 	else
 	  $echo >> $output "\
   program='$outputname'
diff -rubB libtool-1.5.22.orig/ltmain.sh libtool-1.5.22/ltmain.sh
--- libtool-1.5.22.orig/ltmain.sh	2005-12-18 23:14:54.000000000 +0100
+++ libtool-1.5.22/ltmain.sh	2006-09-11 09:00:19.000000000 +0200
@@ -4024,7 +4024,7 @@
 	   len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
 	   test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
 	  :
-	else
+	elif "`uname`" ne "Interix"; then
 	  # The command line is too long to link in one step, link piecewise.
 	  $echo "creating reloadable object files..."
 
@@ -4569,10 +4569,16 @@
 	  fi
 
 	  for arg in $dlprefiles; do
+	    case "$CC" in
+		*wgcc*)
+		  ;;
+		*)  
 	    $show "extracting global C symbols from \`$arg'"
 	    name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
 	    $run eval '$echo ": $name " >> "$nlist"'
 	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+		  ;;
+		esac  
 	  done
 
 	  if test -z "$run"; then
@@ -5310,6 +5316,14 @@
 "
 
 	if test "$fast_install" = yes; then
+	case "`uname`:$CC" in
+	Interix:wgcc)
+	  $echo >> $output "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+		;;
+	*)	
 	  $echo >> $output "\
   program=lt-'$outputname'$exeext
   progdir=\"\$thisdir/$objdir\"
@@ -5343,6 +5357,8 @@
       $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
     $rm \"\$progdir/\$file\"
   fi"
+		;;
+	esac	
 	else
 	  $echo >> $output "\
   program='$outputname'
diff -rubB libtool-1.5.22.orig/pdemo/foo.h libtool-1.5.22/pdemo/foo.h
--- libtool-1.5.22.orig/pdemo/foo.h	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/pdemo/foo.h	2006-09-11 08:25:37.000000000 +0200
@@ -32,6 +32,21 @@
 #  endif
 #endif
 
+/* __PXWC__ is defined whenever compiling under Interix* with wgcc.
+ * If it is defined we need to define some macros to export vars
+ * on native win32.
+ */
+
+#ifdef __PXWC__
+#  ifdef _LIBFOO_COMPILATION_
+#    define _foo_EXPORT 
+#  else
+#    define _foo_EXPORT __declspec(dllimport)
+#  endif
+#else
+#  define _foo_EXPORT
+#endif
+
 /* __BEGIN_DECLS should be used at the beginning of your declarations,
    so that C++ compilers don't mangle their names.  Use __END_DECLS at
    the end of C declarations. */
@@ -84,7 +99,7 @@
 __BEGIN_DECLS
 int foo LT_PARAMS((void));
 int hello LT_PARAMS((void));
-EXTERN int nothing;
+EXTERN int _foo_EXPORT nothing;
 __END_DECLS
 
 #endif /* !_FOO_H_ */
diff -rubB libtool-1.5.22.orig/pdemo/longer_file_name_foo.c libtool-1.5.22/pdemo/longer_file_name_foo.c
--- libtool-1.5.22.orig/pdemo/longer_file_name_foo.c	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/pdemo/longer_file_name_foo.c	2006-09-11 08:25:37.000000000 +0200
@@ -29,7 +29,7 @@
 #endif
 
 /* Give a global variable definition. */
-int nothing = FOO_RET;
+int _foo_EXPORT nothing = FOO_RET;
 
 int
 foo ()
diff -rubB libtool-1.5.22.orig/tagdemo/foo.cpp libtool-1.5.22/tagdemo/foo.cpp
--- libtool-1.5.22.orig/tagdemo/foo.cpp	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/tagdemo/foo.cpp	2006-09-11 08:25:37.000000000 +0200
@@ -20,7 +20,13 @@
 // USA.
 
 #include "foo.h"
+
+#ifdef __PXWC__
+#include <iostream>
+using namespace std;
+#else
 #include <iostream.h>
+#endif
 
 #ifdef HAVE_MATH_H
 #include <math.h>
diff -rubB libtool-1.5.22.orig/tagdemo/main.cpp libtool-1.5.22/tagdemo/main.cpp
--- libtool-1.5.22.orig/tagdemo/main.cpp	2005-04-23 07:39:20.000000000 +0200
+++ libtool-1.5.22/tagdemo/main.cpp	2006-09-11 08:25:37.000000000 +0200
@@ -22,8 +22,13 @@
 
 #include "foo.h"
 #include "baz.h"
-#include <iostream.h>
 
+#ifdef __PXWC__
+#include <iostream>
+using namespace std;
+#else
+#include <iostream.h>
+#endif
 
 int
 main (int, char *[])
diff -rubB libtool-1.5.22.orig/tests/build-relink.test libtool-1.5.22/tests/build-relink.test
--- libtool-1.5.22.orig/tests/build-relink.test	2002-11-19 10:42:39.000000000 +0100
+++ libtool-1.5.22/tests/build-relink.test	2006-09-11 08:25:37.000000000 +0200
@@ -65,6 +65,8 @@
   exit 1
 fi
 
+export PATH=${PATH}:$prefix/bin
+
 ./hell # so that it links on-demand if needed
 
 echo "removing libhello.la from ../demo"
diff -rubB libtool-1.5.22.orig/tests/build-relink2.test libtool-1.5.22/tests/build-relink2.test
--- libtool-1.5.22.orig/tests/build-relink2.test	2002-11-19 10:42:39.000000000 +0100
+++ libtool-1.5.22/tests/build-relink2.test	2006-09-11 08:25:37.000000000 +0200
@@ -10,6 +10,8 @@
 fi
 . $srcdir/defs || exit 1
 
+export PATH=${PATH}:$prefix/bin
+
 # Check that things are built.
 if (test -f $prefix/lib/extra/libl3.la || test -f $prefix/lib/libl3.la) \
     && cd ../depdemo && test -f l3/libl3.la; then :
diff -rubB libtool-1.5.22.orig/tests/link-order.test libtool-1.5.22/tests/link-order.test
--- libtool-1.5.22.orig/tests/link-order.test	2005-11-18 22:04:34.000000000 +0100
+++ libtool-1.5.22/tests/link-order.test	2006-09-11 08:25:37.000000000 +0200
@@ -34,13 +34,25 @@
   mkdir $srcdir
 
   cat >$srcdir/a_$i.c <<EOF
-extern int c;
+#ifdef __WGCC
+# define _IMPORT __declspec(dllimport)
+#else
+# define _IMPORT
+#endif
+
+extern int _IMPORT c;
 extern int b_$i();
 int a_$i() { return c + b_$i(); }
 EOF
 
   cat >$srcdir/b_$i.c <<EOF
-extern int c;
+#ifdef __WGCC
+# define _IMPORT __declspec(dllimport)
+#else
+# define _IMPORT
+#endif
+
+extern int _IMPORT c;
 int b_$i() { return 1 + c; }
 EOF
 
@@ -81,6 +93,10 @@
   $libtool --mode=compile $CC $CFLAGS -c $srcdir/main_$i.c -o $srcdir/main_$i.lo
   $libtool --mode=link $CC $CFLAGS $LDFLAGS -o $srcdir/main_$i $srcdir/main_$i.lo \
       -L$prefix/lib -la || retcode=1
+  prefix=`eval echo \\$prefix_$i`
+  # wgcc built windows dlls need path set
+  export PATH=$prefix/bin:${PATH}
+  echo "Set prefix: $prefix"
   if $srcdir/main_$i; then :
   else
     echo "$0: cannot execute $srcdir/main_$i" 1>&2
@@ -93,5 +109,5 @@
   fi
 done
 
-rm -rf $top_dir
+#rm -rf $top_dir
 exit $retcode
