Commit | Line | Data |
---|---|---|
2ff28616 GB |
1 | # -*- perl -*- |
2 | BEGIN { require 5.006; } # allow CPAN testers to get the point | |
3 | use strict; | |
4 | use warnings; | |
5 | use Config; | |
6 | use File::Spec; | |
f4a2945e | 7 | use ExtUtils::MakeMaker; |
2ff28616 GB |
8 | my $PERL_CORE = grep { $_ eq 'PERL_CORE=1' } @ARGV; |
9 | ||
10 | my $do_xs = $PERL_CORE || can_cc(); | |
11 | ||
12 | for (@ARGV) { | |
13 | /^-pm/ and $do_xs = 0; | |
14 | /^-xs/ and $do_xs = 1; | |
15 | } | |
f4a2945e JH |
16 | |
17 | WriteMakefile( | |
2ff28616 GB |
18 | NAME => q[List::Util], |
19 | ABSTRACT => q[Common Scalar and List utility subroutines], | |
20 | AUTHOR => q[Graham Barr <gbarr@cpan.org>], | |
21 | DEFINE => q[-DPERL_EXT], | |
22 | DISTNAME => q[Scalar-List-Utils], | |
23 | VERSION_FROM => 'lib/List/Util.pm', | |
24 | ||
25 | # We go through the ListUtil.xs trickery to foil platforms | |
26 | # that have the feature combination of | |
27 | # (1) static builds | |
28 | # (2) allowing only one object by the same name in the static library | |
29 | # (3) the object name matching being case-blind | |
30 | # This means that we can't have the top-level util.o | |
31 | # and the extension-level Util.o in the same build. | |
32 | # One such platform is the POSIX-BC BS2000 EBCDIC mainframe platform. | |
33 | XS => {'ListUtil.xs' => 'ListUtil.c'}, | |
34 | OBJECT => 'ListUtil$(OBJ_EXT)', | |
35 | ( $PERL_CORE | |
36 | ? () | |
37 | : ( | |
38 | INSTALLDIRS => q[perl], | |
39 | PREREQ_PM => {'Test::More' => 0,}, | |
40 | (eval { ExtUtils::MakeMaker->VERSION(6.31) } ? (LICENSE => 'perl') : ()), | |
41 | ($do_xs ? () : (XS => {}, C => [], OBJECT => '')), | |
42 | ( eval { ExtUtils::MakeMaker->VERSION(6.46) } ? ( | |
43 | META_MERGE => { | |
44 | resources => { ## | |
45 | repository => 'http://github.com/gbarr/Scalar-List-Utils', | |
46 | }, | |
47 | } | |
48 | ) | |
49 | : () | |
50 | ), | |
51 | ) | |
52 | ), | |
f4a2945e JH |
53 | ); |
54 | ||
376b1d05 | 55 | |
2ff28616 | 56 | sub can_cc { |
376b1d05 | 57 | |
2ff28616 GB |
58 | foreach my $cmd (split(/ /, $Config::Config{cc})) { |
59 | my $_cmd = $cmd; | |
60 | return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); | |
61 | ||
62 | for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { | |
63 | my $abs = File::Spec->catfile($dir, $_[1]); | |
64 | return $abs if (-x $abs or $abs = MM->maybe_command($abs)); | |
65 | } | |
66 | } | |
5f929d0c | 67 | |
2ff28616 | 68 | return; |
5f929d0c IZ |
69 | } |
70 | ||
2ff28616 GB |
71 | package MY; |
72 | ||
73 | sub init_PM { | |
74 | my $self = shift; | |
75 | ||
76 | $self->SUPER::init_PM(@_); | |
77 | ||
78 | return if $do_xs; | |
79 | ||
80 | my $pm = $self->{PM}; | |
81 | my $pm_file = File::Spec->catfile(qw(lib List Util XS.pm)); | |
82 | ||
83 | # When installing pure perl, install XS.pp as XS.pm | |
84 | $self->{PM}{'XS.pp'} = delete $self->{PM}{$pm_file}; | |
376b1d05 | 85 | } |
2ff28616 | 86 |