Make B::Deparse able to handle pragmas from %^H.
[p5sagit/p5-mst-13.2.git] / ext / Errno / Errno_pm.PL
index 5c76d89..6f20c5e 100644 (file)
@@ -2,7 +2,7 @@ use ExtUtils::MakeMaker;
 use Config;
 use strict;
 
-our $VERSION = "1.09_01";
+our $VERSION = "1.10";
 
 my %err = ();
 my %wsa = ();
@@ -16,8 +16,26 @@ unlink "Errno.pm" if -f "Errno.pm";
 open OUT, ">Errno.pm" or die "Cannot open Errno.pm: $!";
 select OUT;
 my $file;
-foreach $file (get_files()) {
-    process_file($file);
+my @files = get_files();
+if ($Config{gccversion} ne '' && $^O eq 'MSWin32') {
+    # MinGW complains "warning: #pragma system_header ignored outside include
+    # file" if the header files are processed individually, so include them
+    # all in .c file and process that instead.
+    open INCS, '>includes.c' or
+       die "Cannot open includes.c";
+    foreach $file (@files) {
+       next if $file eq 'errno.c';
+       next unless -f $file;
+       print INCS qq[#include "$file"\n];
+    }
+    close INCS;
+    process_file('includes.c');
+    unlink 'includes.c';
+}
+else {
+    foreach $file (@files) {
+       process_file($file);
+    }
 }
 write_errno_pm();
 unlink "errno.c" if -f "errno.c";
@@ -116,8 +134,16 @@ sub get_files {
     } elsif ($Config{archname} eq 'epoc') {
        # Watch out for cross compiling for EPOC (usually done on linux)
        $file{'/usr/local/epocemx/epocsdk/include/libc/sys/errno.h'} = 1;
+    } elsif ($Config{archname} eq 'arm-riscos') {
+       # Watch out for cross compiling for RISC OS
+       my $dep = `echo "#include <errno.h>" | gcc -E -M -`;
+       if ($dep =~ /(\S+errno\.h)/) {
+            $file{$1} = 1;
+       }
     } elsif ($^O eq 'linux' &&
-            $Config{gccversion} ne '' # might be using, say, Intel's icc
+             $Config{gccversion} ne '' && 
+             $Config{gccversion} !~ /intel/i
+             # might be using, say, Intel's icc
             ) {
        # Some Linuxes have weird errno.hs which generate
        # no #file or #line directives