This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
cautionary note about "no VERSION"
[perl5.git] / dist / threads / Makefile.PL
1 # Module makefile for threads (using ExtUtils::MakeMaker)
2
3 require 5.008;
4
5 use strict;
6 use warnings;
7
8 use ExtUtils::MakeMaker;
9
10
11 # Used to check for a 'C' compiler
12 sub check_cc
13 {
14     require File::Spec;
15
16     my $cmd = $_[0];
17     if (-x $cmd or MM->maybe_command($cmd)) {
18         return (1);       # CC command found
19     }
20     for my $dir (File::Spec->path(), '.') {
21         my $abs = File::Spec->catfile($dir, $cmd);
22         if (-x $abs or MM->maybe_command($abs)) {
23             return (1);   # CC command found
24         }
25     }
26     return;
27 }
28
29 sub have_cc
30 {
31     eval { require Config_m; };     # ExtUtils::FakeConfig (+ ActivePerl)
32     if ($@) {
33         eval { require Config; };   # Everyone else
34     }
35     my @chunks = split(/ /, $Config::Config{cc});
36     # $Config{cc} may contain args; try to find out the program part
37     while (@chunks) {
38         if (check_cc("@chunks")) {
39             return (1);   # CC command found
40         }
41         pop(@chunks);
42     }
43     return;
44 }
45
46
47 # Build options for different environments
48 my @conditional_params;
49 if (not grep { $_ eq 'PERL_CORE=1' } @ARGV) {
50     # CPAN
51
52     # Verify that a 'C' compiler is available
53     if (! have_cc()) {
54         die("OS unsupported:  ERROR: No 'C' compiler found to build 'threads'\n");
55     }
56
57     push(@conditional_params, 'DEFINE' => '-DHAS_PPPORT_H',
58                               'PREREQ_PM'         => {
59                                     'strict'            => 0,
60                                     'warnings'          => 0,
61                                     'overload'          => 0,
62                                     'Config'            => 0,
63                                     'Carp'              => 0,
64                                     'XSLoader'          => 0,
65
66                                     'Test::More'        => 0,
67                                     'ExtUtils::testlib' => 0,
68                                     'Hash::Util'        => 0,
69                                     'IO::File'          => 0,
70                               });
71 }
72
73
74 # Create Makefile
75 WriteMakefile(
76     'NAME'              => 'threads',
77     'AUTHOR'            => 'Artur Bergman, Jerry D. Hedden <jdhedden AT cpan DOT org>',
78     'VERSION_FROM'      => 'threads.pm',
79     'ABSTRACT_FROM'     => 'threads.pm',
80     'PM' => {
81         'threads.pm'    => '$(INST_LIBDIR)/threads.pm',
82     },
83     'INSTALLDIRS'       => (($] < 5.011) ? 'perl' : 'site'),
84
85     ((ExtUtils::MakeMaker->VERSION() lt '6.25') ?
86         ('PL_FILES' => { })            : ()),
87     ((ExtUtils::MakeMaker->VERSION() gt '6.30') ?
88         ('LICENSE'  => 'perl')         : ()),
89
90     @conditional_params
91 );
92
93 # Additional 'make' targets
94 sub MY::postamble
95 {
96     return <<'_EXTRAS_';
97 fixfiles:
98         @dos2unix `cat MANIFEST`
99         @$(CHMOD) 644 `cat MANIFEST`
100         @$(CHMOD) 755 examples/*.pl
101
102 ppport:
103         @( cd /tmp; perl -e 'use Devel::PPPort; Devel::PPPort::WriteFile("ppport.h");' )
104         @if ! cmp -s ppport.h /tmp/ppport.h; then \
105             ( tkdiff ppport.h /tmp/ppport.h & ); \
106             perl /tmp/ppport.h; \
107         fi
108 _EXTRAS_
109 }
110
111 # EOF