6 use ExtUtils::MakeMaker;
7 BEGIN { if ( $^O eq 'cygwin' ) {
8 require ExtUtils::MM_Cygwin;
9 require ExtUtils::MM_Win32;
10 if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) {
11 *ExtUtils::MM_Cygwin::maybe_command = sub {
12 my ($self, $file) = @_;
13 if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) {
14 ExtUtils::MM_Win32->maybe_command($file);
16 ExtUtils::MM_Unix->maybe_command($file);
22 my $mymeta_works = eval { ExtUtils::MakeMaker->VERSION('6.5707'); 1 };
23 my $mymeta = $mymeta_works || eval { ExtUtils::MakeMaker->VERSION('6.5702'); 1 };
28 'Sub::Exporter::Progressive' => '0.001006',
29 ( (defined ${^GLOBAL_PHASE} or !can_xs() )
31 : ('Devel::GlobalDestruction::XS' => 0)
35 my %WriteMakefileArgs = (
36 NAME => 'Devel::GlobalDestruction',
37 VERSION_FROM => 'lib/Devel/GlobalDestruction.pm',
39 INSTALLDIRS => 'site',
41 MIN_PERL_VERSION => '5.006',
42 PREREQ_PM => \%RUN_DEPS,
43 CONFIGURE_REQUIRES => { 'ExtUtils::CBuilder' => 0.27 },
46 homepage => 'http://search.cpan.org/dist/Devel-GlobalDestruction',
47 repository => 'git://git.shadowcat.co.uk/p5sagit/Devel-GlobalDestruction.git',
48 bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Devel-GlobalDestruction',
50 requires => \%RUN_DEPS,
52 ($mymeta and !$mymeta_works) ? ( 'NO_MYMETA' => 1 ) : (),
55 unless ( eval { ExtUtils::MakeMaker->VERSION('6.56') } ) {
56 my $br = delete $WriteMakefileArgs{BUILD_REQUIRES};
57 my $pp = $WriteMakefileArgs{PREREQ_PM};
58 for my $mod ( keys %$br ) {
59 if ( exists $pp->{$mod} ) {
60 $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod};
63 $pp->{$mod} = $br->{$mod};
68 delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
69 unless eval { ExtUtils::MakeMaker->VERSION('6.52') };
71 WriteMakefile(%WriteMakefileArgs);
73 # can we locate a (the) C compiler
75 my @chunks = split(/ /, $Config::Config{cc}) or return;
77 # $Config{cc} may contain args; try to find out the program part
79 return can_run("@chunks") || (pop(@chunks), next);
85 # check if we can run some command
89 return $cmd if -x $cmd;
90 if (my $found_cmd = MM->maybe_command($cmd)) {
95 for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
97 my $abs = File::Spec->catfile($dir, $cmd);
98 return $abs if (-x $abs or $abs = MM->maybe_command($abs));
104 # Can our C compiler environment build XS files
106 # Do we have the configure_requires checker?
108 eval "require ExtUtils::CBuilder; ExtUtils::CBuilder->VERSION(0.27)";
110 # They don't obey configure_requires, so it is
111 # someone old and delicate. Try to avoid hurting
112 # them by falling back to an older simpler test.
116 # Do we have a working C compiler
117 my $builder = ExtUtils::CBuilder->new(
120 unless ( $builder->have_compiler ) {
121 # No working C compiler
125 # Write a C file representative of what XS becomes
127 my ( $FH, $tmpfile ) = File::Temp::tempfile(
137 int main(int argc, char **argv) {
148 # Can the C compiler access the same headers XS does
153 $object = $builder->compile(
156 @libs = $builder->link(
158 module_name => 'sanexs',
161 my $result = $@ ? 0 : 1;
163 # Clean up all the build files
164 foreach ( $tmpfile, $object, @libs ) {
165 next unless defined $_;