Commit | Line | Data |
---|---|---|
0f1612a7 JH |
1 | # Module makefile for threads (using ExtUtils::MakeMaker) |
2 | ||
3 | require 5.008; | |
4 | ||
5 | use strict; | |
6 | use warnings; | |
7 | ||
fc6e75a2 | 8 | use ExtUtils::MakeMaker; |
0f1612a7 JH |
9 | |
10 | ||
c0003851 JH |
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 | ||
0f1612a7 JH |
47 | # Build options for different environments |
48 | my @conditional_params; | |
12f27760 | 49 | if (not grep { $_ eq 'PERL_CORE=1' } @ARGV) { |
0f1612a7 | 50 | # CPAN |
c0003851 JH |
51 | |
52 | # Verify that a 'C' compiler is available | |
53 | if (! have_cc()) { | |
561ee912 | 54 | die("OS unsupported: ERROR: No 'C' compiler found to build 'threads'\n"); |
c0003851 JH |
55 | } |
56 | ||
d2c25dc7 JH |
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 | ||
7ef93cb2 | 66 | 'Test::More' => 0, |
d2c25dc7 JH |
67 | 'ExtUtils::testlib' => 0, |
68 | 'Hash::Util' => 0, | |
69 | 'IO::File' => 0, | |
70 | }); | |
0f1612a7 JH |
71 | } |
72 | ||
7f595b02 SP |
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', | |
0f1612a7 | 82 | }, |
24855dff | 83 | 'INSTALLDIRS' => (($] < 5.011) ? 'perl' : 'site'), |
0f1612a7 JH |
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 | |
fc6e75a2 AB |
91 | ); |
92 | ||
7ef93cb2 JH |
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 | ||
0f1612a7 | 111 | # EOF |