Date-Pcalc

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

#!perl -w

###############################################################################
##                                                                           ##
##    Copyright (c) 1995 - 2009 by Steffen Beyer.                            ##
##    All rights reserved.                                                   ##
##                                                                           ##
##    This package is free software; you can redistribute it                 ##
##    and/or modify it under the same terms as Perl itself.                  ##
##                                                                           ##
###############################################################################

use strict;
use File::Spec;
use File::Copy;
use ExtUtils::MakeMaker;

BEGIN
{
    eval { require Config_m; }; # ExtUtils::FakeConfig (+ ActivePerl)
    eval { require Config;   }  # Everyone else
    if ($@);
}

my($good,$text,$answer,$default,$file,$orig,$PATCHLEVEL,$SUBVERSION);

my($CC,$EXE) = @Config::Config{'cc','_exe'}; # or @Config::Config{'cc','exe_ext'};

my(@PATH) = (File::Spec->path(), '.');

my $ORIG = 'src';
my $C_XS = 'C_XS';
my $Perl = 'Perl';

my $Patchlevel = 'patchlevel.h';

my(@C_XS) = qw(Pcalc.pm Pcalc.xs DatePcalc.c DatePcalc.h ToolBox.h typemap);
my(@Perl) = qw(Pcalc.pm);

my(@Clean) = (@C_XS, $Patchlevel, qw(Pcalc.c));

my %Parameters =
(
    'NAME'              => 'Date::Pcalc',
    'VERSION_FROM'      => 'Pcalc.pm',
    'PREREQ_PM'         =>
                              {
                                  'Carp::Clan'  => 5.3,
                                  'Bit::Vector' => 7.1
                              },
#   ($] >= 5.005 ?
#       ('ABSTRACT'     => 'Gregorian calendar date calculations',
#        'AUTHOR'       => 'Steffen Beyer <STBEY@cpan.org>') : ()),
#   ($] >= 5.005 && $^O eq 'MSWin32' && $Config::Config{'archname'} =~ /-object\b/i ?
#       ('CAPI'         => 'TRUE') : ()),
    'dist'              => { COMPRESS => "gzip -9", SUFFIX => "gz" },
    'clean'             => { FILES => join(' ', @Clean) }
);

sub Check_CC
{
    my($cmd) = $_[0];
    my($dir,$abs);
    return $cmd if (-x $cmd or MM->maybe_command($cmd));
    foreach $dir (@PATH)
    {
        $abs = File::Spec->catfile($dir, $cmd);
        return $cmd if (-x $abs or MM->maybe_command($abs));
    }
    return '';
}

sub Have_CC
{
    my($cmd) = $_[0];
    my(@chunks) = split(/ /, $cmd); # may contain args; try to find out the program part
    while (@chunks)
    {
        return $cmd if (($cmd = Check_CC(join(' ', @chunks      ))) ne '');
        return $cmd if (($cmd = Check_CC(join(' ', @chunks, $EXE))) ne '');
        pop(@chunks);
    }
    return '';
}

if (($good = Have_CC($CC)) ne '')
{
    $CC = $good;
    $text = 'located';
}
else
{
    $CC =~ s/\s+-.+$//;
    $CC .= $EXE;
    $text = 'cannot locate';
}

eval { require ExtUtils::CBuilder; };
unless ($@)
{
    print "Testing your C compiler...\n";
    if ( ExtUtils::CBuilder->new( quiet => 1 )->have_compiler() )
    {
        $good = $CC;
        $text = 'located and successfully tested';
    }
    else
    {
        $good = '';
        $text = 'could not successfully use';
    }
}



( run in 1.856 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )