This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move Pod::Simple from ext/ to cpan/
[perl5.git] / ext / List-Util / Makefile.PL
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;
7 use ExtUtils::MakeMaker;
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 }
16
17 WriteMakefile(
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   ),
53 );
54
55
56 sub can_cc {
57
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     }
67
68     return;
69 }
70
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};
85 }
86