Silence MinGW warnings about system headers when building Errno
authorSteve Hay <SteveHay@planit.com>
Thu, 30 Jun 2005 07:57:25 +0000 (07:57 +0000)
committerSteve Hay <SteveHay@planit.com>
Thu, 30 Jun 2005 07:57:25 +0000 (07:57 +0000)
Thanks to Mike Guy for the suggested fix.

p4raw-id: //depot/perl@25014

ext/Errno/Errno_pm.PL

index 5c76d89..bd87f62 100644 (file)
@@ -16,8 +16,24 @@ 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) {
+       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";
@@ -178,6 +194,8 @@ sub get_files {
                if (/$pat/o) {
                   my $f = $1;
                   $f =~ s,\\\\,/,g;
+                  next if $f eq 'errno.c';
+                  next unless -f $f;
                   $file{$f} = 1;
                }
            }