File: Makefile.PL

package info (click to toggle)
libdate-pcalc-perl 6.1-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 1,856 kB
  • ctags: 619
  • sloc: perl: 16,706; ansic: 3,083; sh: 14; makefile: 4
file content (201 lines) | stat: -rw-r--r-- 5,733 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!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';
    }
}

print <<"VERBATIM";

Config.pm indicates that your version of Perl was built with
this C compiler:

    $CC

VERBATIM

if ($good ne '')
{
    print <<"VERBATIM";
I have $text this compiler on your system.

You now have the option to either install the (fast) C/XS implementation of
this module (recommended), or a (somewhat slower) pure-Perl implementation.

VERBATIM
}
else
{
    print <<"VERBATIM";
I $text this compiler on your system.

Therefore you now have the option to install a (somewhat slower) pure-Perl
implementation of this module instead of the (fast) C/XS implementation.

If however the C compiler mentioned above really is installed on your system,
please make sure it can be found in the PATH and then try running this program
again. Or if you think I should have found this compiler, and if you are sure
it is available and functional, simply answer 'c' to the next question.

VERBATIM
}

$answer = '';
$default = ($good ne '') ? 'c' : 'p';
while (1)
{
    $answer = prompt(q{Install C/XS version (answer 'c') or pure-Perl version (answer 'p')?}, $default);
    last if $answer =~ /^[CcPp]$/;
}

foreach $file (@Clean)
{
    if (-e $file) { unless (unlink($file)) { warn "Can't unlink file <$file>: $!\n"; exit 0; } }
}

if ($answer =~ /^[Cc]$/)
{
    foreach $file (@C_XS)
    {
        $orig = File::Spec->catfile($ORIG,$C_XS,$file);
        unless (copy($orig,$file)) { warn "Can't copy file <$orig> to <$file>: $!\n"; exit 0; }
    }
    $Parameters{'OBJECT'} = '$(O_FILES)';
    WriteMakefile(%Parameters);

    $PATCHLEVEL = $Config::Config{'PATCHLEVEL'} || $Config::Config{'patchlevel'} || substr($],2,3);
    $SUBVERSION = $Config::Config{'SUBVERSION'} || $Config::Config{'subversion'} || substr($],5) || 0;

    unless
    (
        open(PATCHLEVEL, ">$Patchlevel")                          and
        print("Writing $Patchlevel for $^X ($])\n")               and
        printf(PATCHLEVEL "#define PATCHLEVEL %d\n", $PATCHLEVEL) and
        printf(PATCHLEVEL "#define SUBVERSION %d\n", $SUBVERSION) and
        close(PATCHLEVEL)
    )
    {
        warn "Oops: Could not write file <$Patchlevel>: $!\n";
        warn "However, you might succeed in building this module anyway;\n";
        warn "Just give it a try!\n";
        exit 0;
    }
}
else
{
    foreach $file (@Perl)
    {
        $orig = File::Spec->catfile($ORIG,$Perl,$file);
        unless (copy($orig,$file)) { warn "Can't copy file <$orig> to <$file>: $!\n"; exit 0; }
    }
    WriteMakefile(%Parameters);
}

__END__