File: Makefile.PL

package info (click to toggle)
libip-geolocation-mmdb-perl 1.013-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: perl: 192; makefile: 3
file content (178 lines) | stat: -rw-r--r-- 4,544 bytes parent folder | download
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
# This Makefile.PL for IP-Geolocation-MMDB was generated by
# Dist::Zilla::Plugin::MakeMaker::Awesome 0.49.
# Don't edit it but the dist.ini and plugins used to construct it.

use strict;
use warnings;

use 5.014;
use ExtUtils::MakeMaker;

use Config;
use File::Spec::Functions qw(devnull);
use Math::BigInt;
my @defines;
my $byteorder = $Config{byteorder};
if (!defined $byteorder) {
 warn "\$Config{byteorder} is undefined";
 die "OS unsupported\n";
}
if ($byteorder == 4321 || $byteorder == 87654321) {
 push @defines, '-DWORDS_BIGENDIAN';
}
elsif (!($byteorder == 1234 || $byteorder == 12345678)) {
 warn "Unknown byte order: $byteorder\n";
 die "OS unsupported\n";
}
my $ccflags = '';
my $libs = '';
my $version;
if (eval { require Alien::libmaxminddb }) {
 $ccflags = Alien::libmaxminddb->cflags;
 $libs = Alien::libmaxminddb->libs;
 $version = Alien::libmaxminddb->version;
}
else {
 my $devnull = devnull();
 for my $pkgconf (qw(pkgconf pkg-config)) {
  my $output = `$pkgconf --version 2>$devnull`;
  if ($? == 0) {
   $ccflags = `$pkgconf --cflags libmaxminddb 2>$devnull`;
   last if $? != 0;
   $libs = `$pkgconf --libs libmaxminddb 2>$devnull`;
   last if $? != 0;
   $version = `$pkgconf --modversion libmaxminddb 2>$devnull`;
   last if $? != 0;
   chomp($ccflags, $libs, $version);
   last;
  }
 }
}
if ($^O eq 'MSWin32' && $^V < 5.034) {
 # Amend the library search path
 my $libdir = 'C:\strawberry\c\x86_64-w64-mingw32\lib';
 if (-d $libdir) {
  $libs = "-L$libdir $libs";
 }
}

my %WriteMakefileArgs = (
  "ABSTRACT" => "Read MaxMind DB files",
  "AUTHOR" => "Andreas V\x{f6}gele <voegelas\@cpan.org>",
  "BUILD_REQUIRES" => {
    "Alien::libmaxminddb" => 0,
    "Math::BigInt" => "1.999806"
  },
  "CONFIGURE_REQUIRES" => {
    "Alien::libmaxminddb" => 0,
    "ExtUtils::MakeMaker" => 0,
    "Math::BigInt" => "1.999806"
  },
  "DISTNAME" => "IP-Geolocation-MMDB",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.014",
  "NAME" => "IP::Geolocation::MMDB",
  "PREREQ_PM" => {
    "Math::BigInt" => "1.999806",
    "XSLoader" => 0,
    "utf8" => 0,
    "warnings" => 0
  },
  "TEST_REQUIRES" => {
    "File::Spec::Functions" => 0,
    "Test::More" => 0
  },
  "VERSION" => "1.013",
  "test" => {
    "TESTS" => "t/*.t"
  }
);

%WriteMakefileArgs = (
    %WriteMakefileArgs,
    CCFLAGS => join(q{ }, $ccflags, $Config{ccflags}),
    LIBS => [ $libs ],
    DEFINE => join(q{ }, @defines),
);

my %FallbackPrereqs = (
  "Alien::libmaxminddb" => 0,
  "File::Spec::Functions" => 0,
  "Math::BigInt" => "1.999806",
  "Test::More" => 0,
  "XSLoader" => 0,
  "utf8" => 0,
  "warnings" => 0
);

unless ( eval { ExtUtils::MakeMaker->VERSION('6.63_03') } ) {
  delete $WriteMakefileArgs{TEST_REQUIRES};
  delete $WriteMakefileArgs{BUILD_REQUIRES};
  $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}

delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
  unless eval { ExtUtils::MakeMaker->VERSION(6.52) };

WriteMakefile(%WriteMakefileArgs);

package MY;
# Bail out if something is wrong
sub post_initialize {
 my $text = '';
 if (!defined $version) {
  $text = <<'TEXT';
.PHONY: die
die :
	$(NOECHO) $(ECHO) "Error: libmaxminddb not found"
	$(NOECHO) $(ECHO) "OS unsupported"
	$(FALSE)
TEXT
 }
 elsif ($version =~ m{^(0|1\.[01])\.}) {
  $text = <<'TEXT';
.PHONY: die
die :
	$(NOECHO) $(ECHO) "Error: libmaxminddb is too old"
	$(NOECHO) $(ECHO) "OS unsupported"
	$(FALSE)
TEXT
 }
 elsif (!eval { Math::BigInt->from_bytes(pack 'C6', 0xff, 0xff, 0xb0, 0x09, 0x00, 0x00)->as_hex eq '0xffffb0090000' }) {
  # Some Math::BigInt versions fail on i386 if Perl is built with -Dusequadmath.
  $text = <<'TEXT';
.PHONY: die
die :
	$(NOECHO) $(ECHO) "Error: Math::BigInt is too old or broken"
	$(NOECHO) $(ECHO) "OS unsupported"
	$(FALSE)
TEXT
 }
 return $text;
}
sub const_loadlibs {
 my $text = shift->SUPER::const_loadlibs(@_);
 if ($^O eq 'MSWin32' && $^V < 5.034) {
  # Ignore unneeded libraries, which may contain invalid symbols
  my $filter = sub {
   my $list = shift;
   my $pattern = $list =~ m{"} ? qr{(?<=")\h+(?=")} : qr{\h+};
   join q{ }, grep { m{ maxminddb | ws2_32 }x } split $pattern, $list;
  };
  $text =~ s{
   ^ ( (?: EXTRA | LDLOAD ) LIBS ) \h* = \h* (.*?) \h* $
  }
  {sprintf '%s = %s', $1, $filter->($2)}egxm;
 }
 return $text;
}
sub const_config {
 my $text = shift->SUPER::const_config(@_);
 # Some BSDs prepend -L/usr/local/lib, which may contain an old library
 # version, to the library search path
 $text =~ s{
  ^ ( LD(?:DL)?FLAGS \h* = .*? ) -L/usr/local/lib ( $ | \h+ (.*) $ )
 }
 {$1$2}gxm;
 return $text;
}