Include the Encode extension in the ALL_STATIC build on Win32 for VC++
authorSteve Hay <steve.m.hay@googlemail.com>
Sat, 8 Jun 2013 01:16:17 +0000 (02:16 +0100)
committerSteve Hay <steve.m.hay@googlemail.com>
Sat, 8 Jun 2013 01:16:17 +0000 (02:16 +0100)
Thanks to Jan Dubois and Nicholas Clark for pointing out that Encode has
subextensions which need statically linking too, and that Configure has
a special case for handling this which we can mimic in config_sh.PL.

Unfortunately, however, while this works for VC++, with MinGW it gives
undefined reference errors to three symbols from Encode/CN.o
(_cp936_encoding, _euc_cn_encoding and MacChineseSimp_encoding) and two
from Encode/JP.o (_cp932_encoding and _euc_jp_encoding), so we must retain
the exclusion on Encode for MinGW for now, much like the Compress/Raw/Bzip2
problem found before. Hopefully these are all fixable soon.

win32/Makefile
win32/config_sh.PL
win32/makefile.mk

index 545dc92..cb3f7df 100644 (file)
@@ -772,8 +772,7 @@ SETARGV_OBJ = setargv$(o)
 !IF "$(ALL_STATIC)" == "define"
 # some exclusions, unfortunately, until fixed:
 #  - MakeMaker isn't capable enough for SDBM_File (small bug)
-#  - Encode (encoding search algorithm relies on shared library?)
-STATIC_EXT     = * !SDBM_File !Encode
+STATIC_EXT     = * !SDBM_File
 !ELSE
 # specify static extensions here, for example:
 # (be sure to include Win32CORE to load Win32 on demand)
index d866f76..eb9471c 100644 (file)
@@ -56,6 +56,19 @@ $opt{dynamic_ext}      = join(' ',FindExt::dynamic_ext()) || ' ';
 $opt{extensions}       = join(' ',FindExt::extensions()) || ' ';
 $opt{known_extensions} = join(' ',FindExt::known_extensions()) || ' ';
 
+# Encode is a special case.  If we are building Encode as a static
+# extension, we need to explicitly list its subextensions as well.
+# For other nested extensions, this is handled automatically by
+# the appropriate Makefile.PL.
+if ($opt{static_ext} =~ /\bEncode\b/) {
+    foreach my $file (`dir /s /b ..\\cpan\\Encode\\Makefile.PL`) {
+       if ($file =~ /\b(Encode\\.+)\\Makefile\.PL/) {
+           (my $xxx = $1) =~ s|\\|/|g;
+           $opt{static_ext} .= " $xxx";
+       }
+    }
+}
+
 my $pl_h = '../patchlevel.h';
 
 if (-e $pl_h) {
index 0e383cd..57373c2 100644 (file)
@@ -875,11 +875,11 @@ SETARGV_OBJ       = setargv$(o)
 .IF "$(ALL_STATIC)" == "define"
 # some exclusions, unfortunately, until fixed:
 #  - MakeMaker isn't capable enough for SDBM_File (small bug)
-#  - Encode (encoding search algorithm relies on shared library?)
-#  - GCC's linker gets undefined reference to _BZ2_compressBlock
-STATIC_EXT     = * !SDBM_File !Encode
+#  - GCC's linker gets undefined references to _BZ2_compressBlock and
+#    _cp936_encoding, _cp932_encoding and others in Encode/CN.o and Encode/JP.o
+STATIC_EXT     = * !SDBM_File
 .IF "$(CCTYPE)" == "GCC"
-STATIC_EXT     += !Compress/Raw/Bzip2
+STATIC_EXT     += !Compress/Raw/Bzip2 !Encode
 .ENDIF
 .ELSE
 # specify static extensions here, for example: