File: Makefile.PL

package info (click to toggle)
libdigest-crc-perl 0.18-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 92 kB
  • ctags: 39
  • sloc: perl: 251; makefile: 7
file content (80 lines) | stat: -rw-r--r-- 1,284 bytes parent folder | download | duplicates (8)
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
require 5.004;
use ExtUtils::MakeMaker;

use Config qw(%Config);

for (@ARGV) {
  /^-pm/ and $no_xs = 1;
  /^-xs/ and $no_xs = 0;
}

sub init {
  my $hash = $_[1];
  if ($no_xs) {
    @{$hash}{XS,C} = ( {}, [] );
  }
  $hash;
}

sub write_makefile {
  WriteMakefile(
    NAME         => 'Digest::CRC',
    VERSION_FROM => 'lib/Digest/CRC.pm', # finds $VERSION
    PL_FILES     => {},
    CONFIGURE    => \&init,
    clean        => {FILES => 'test.c typemap'}
  );
}

sub no_cc {
  $no_xs = 1;
  print <<"EDQ";

 I cannot determine if you have a C compiler
 so I will install a perl-only implementation

 You can force installation of the XS version with

    perl Makefile.PL -xs

EDQ
  write_makefile();
  exit;
}

if ($] < 5.006001) {
  open(TYPEMAP,">typemap");
  print TYPEMAP <<'EOS';
NV                      T_NV
UV                      T_UV

INPUT
T_NV
	$var = ($type)SvNV($arg)
T_UV
	$var = ($type)SvUV($arg)

OUTPUT
T_NV
	sv_setnv($arg, (NV)$var);
T_UV
	sv_setuv($arg, (UV)$var);

EOS
  close(TYPEMAP);
}

write_makefile();

exit if defined $no_xs;

print "Testing if you have a C compiler\n";

open(F,">test.c") or no_cc();
print F <<EOF;
int main() { return 0; }
EOF
close(F) or no_cc();
$make = $Config{make} || 'make';
system("$make test$Config{obj_ext}") and no_cc();