Bump version and other misc. changes. 3rd patch from:
[p5sagit/p5-mst-13.2.git] / ext / threads / Makefile.PL
index 349cb4b..c10f046 100755 (executable)
@@ -8,6 +8,42 @@ use warnings;
 use ExtUtils::MakeMaker;
 
 
+# Used to check for a 'C' compiler
+sub check_cc
+{
+    require File::Spec;
+
+    my $cmd = $_[0];
+    if (-x $cmd or MM->maybe_command($cmd)) {
+        return (1);       # CC command found
+    }
+    for my $dir (File::Spec->path(), '.') {
+        my $abs = File::Spec->catfile($dir, $cmd);
+        if (-x $abs or MM->maybe_command($abs)) {
+            return (1);   # CC command found
+        }
+    }
+    return;
+}
+
+sub have_cc
+{
+    eval { require Config_m; };     # ExtUtils::FakeConfig (+ ActivePerl)
+    if ($@) {
+        eval { require Config; };   # Everyone else
+    }
+    my @chunks = split(/ /, $Config::Config{cc});
+    # $Config{cc} may contain args; try to find out the program part
+    while (@chunks) {
+        if (check_cc("@chunks")) {
+            return (1);   # CC command found
+        }
+        pop(@chunks);
+    }
+    return;
+}
+
+
 # Build options for different environments
 my @conditional_params;
 if (grep { $_ eq 'PERL_CORE=1' } @ARGV) {
@@ -16,10 +52,17 @@ if (grep { $_ eq 'PERL_CORE=1' } @ARGV) {
                               'NORECURS' => 1);
 } else {
     # CPAN
-    push(@conditional_params, 'CCFLAGS'  => '-DHAS_PPPORT_H');
+
+    # Verify that a 'C' compiler is available
+    if (! have_cc()) {
+        die("No 'C' compiler found to build 'threads'\n");
+    }
+
+    push(@conditional_params, 'DEFINE' => '-DHAS_PPPORT_H');
 }
 
 
+# Create Makefile
 WriteMakefile(
     'NAME'              => 'threads',
     'AUTHOR'            => 'Artur Bergman <sky AT crucially DOT net>',
@@ -29,7 +72,6 @@ WriteMakefile(
         'threads.pm'    => '$(INST_LIBDIR)/threads.pm',
     },
     'PREREQ_PM'         => {
-        'threads::shared' => 0,
         'XSLoader'        => 0,
     },
     'INSTALLDIRS'       => 'perl',
@@ -42,19 +84,4 @@ WriteMakefile(
     @conditional_params
 );
 
-
-# Add additional target(s) to Makefile for use by module maintainer
-sub MY::postamble
-{
-    return <<'_EXTRAS_';
-ppport:
-       @( cd /tmp; perl -e 'use Devel::PPPort; Devel::PPPort::WriteFile("ppport.h");' )
-       @if ! cmp -s ppport.h /tmp/ppport.h; then \
-           diff ppport.h /tmp/ppport.h ; \
-           echo; \
-           perl /tmp/ppport.h; \
-       fi
-_EXTRAS_
-}
-
 # EOF