difforig perl-5.10.0/ext/Win32CORE

2008-04-16 16:15:50  <rurban@x-ray.at>

	Enable static Win32CORE compilation esp. for cygwin. This enables static cygwin perl compilation.
	The EXTCONST hack is needed for -Uusedl, because Win32CORE requires extern __declspec(dllimport)
	for the windows symbols, but no dllimport attribute for non-shared libperl symbols.

diff -ub  perl-5.10.0/ext/Win32CORE/Makefile.PL.orig
--- perl-5.10.0/ext/Win32CORE/Makefile.PL.orig	2007-12-18 11:47:07.000000000 +0100
+++ perl-5.10.0/ext/Win32CORE/Makefile.PL	2008-04-28 12:20:35.390625000 +0200
@@ -4,3 +4,17 @@
     'NAME'		=> 'Win32CORE',
     'VERSION_FROM'	=> 'Win32CORE.pm',
 );
+
+# undef USEIMPORTLIB for static compilation
+sub MY::cflags {
+  package MY;         # so that "SUPER" works right
+  my ($self, $libperl)=@_;
+  return '' unless $self->needs_linking();
+  my $base = $self->SUPER::cflags($libperl);
+  #print STDERR "cflags:\n$base";
+  if ($self->{LINKTYPE} eq 'static') {
+    #print STDERR "LINKTYPE=static\n";
+    $base =~ s/CCFLAGS =(.*)$/CCFLAGS =\1 -UUSEIMPORTLIB -DLINKSTATIC/m;
+  }
+  return $base;
+}
diff -ub  perl-5.10.0/ext/Win32CORE/Win32CORE.c.orig
--- perl-5.10.0/ext/Win32CORE/Win32CORE.c.orig	2007-12-18 11:47:07.000000000 +0100
+++ perl-5.10.0/ext/Win32CORE/Win32CORE.c	2008-04-28 12:20:35.406250000 +0200
@@ -10,7 +10,13 @@
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
+#if defined(__CYGWIN__) && !defined(USEIMPORTLIB)
+  #undef WIN32
+#endif
 #include "EXTERN.h"
+#if defined(__CYGWIN__) && !defined(USEIMPORTLIB)
+  #define EXTCONST extern const
+#endif
 #include "perl.h"
 #include "XSUB.h"
 
@@ -62,7 +68,7 @@
      * should never be called though, as Win32CORE.pm doesn't use DynaLoader.
      */
 }
-#ifdef __CYGWIN__
+#if defined(__CYGWIN__) && defined(USEIMPORTLIB)
 __declspec(dllexport)
 #endif
 void

