forked from lstein/LibIO-Interface-Perl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.PL
78 lines (67 loc) · 2.08 KB
/
Build.PL
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
#!/usr/bin/perl
use strict;
use Module::Build;
use Config;
sub compiler_flags() {
my @flags = ();
my %cfg = (
'freebsd' => '-D__USE_BSD',
'netbsd' => '-D__USE_BSD',
'openbsd' => '-D__USE_BSD',
);
print "Checking for BSD-like operating system...";
if (exists $cfg{$^O}) {
push @flags, $cfg{$^O};
print " Okay, present.\n";
} else {
print " Nope, not present.\n";
}
print "Checking for SIOCGIFCONF...";
if (!-r "/usr/include/sys/sockio.h") {
print " Nope, will not use it.\n";
} else {
push @flags, '-DSIOCGIFCONF';
print " Okay, I will use it.\n";
}
print "Checking for getifaddrs()...";
eval { require 'ifaddrs.ph' };
if ($@ && !-r "/usr/include/ifaddrs.h") {
print " Nope, will not use it.\n";
} else {
push @flags, '-DUSE_GETIFADDRS';
print " Okay, I will use it.\n";
}
print "Checking for sockaddr_dl...";
if (!-r "/usr/include/net/if_dl.h") {
print " Nope, will not use it.\n";
} else {
push @flags, '-DHAVE_SOCKADDR_DL_STRUCT';
print " Okay, I will use it.\n";
}
return \@flags;
}
my $build = Module::Build->new(
module_name => 'IO::Interface',
dist_version_from => 'lib/IO/Interface.pm',
dist_author => 'Lincoln Stein <[email protected]>',
dist_abstract => 'Access and modify network interface card configuration',
license => 'perl',
dynamic_config => 1,
extra_compiler_flags => compiler_flags(),
build_requires => {
'Config' => 0,
'ExtUtils::CBuilder' => 0,
},
requires => {
'perl' => '5.005',
},
'resources' => {
'homepage' => 'http://search.cpan.org/dist/IO-Interface/',
'repository' => 'https://github.com/lstein/LibIO-Interface-Perl/',
},
);
$build->create_build_script();
# get rid of annoying warning from ExtUtils::ParseXS
my $sub = 's/\$\^W\s*=\s*1/\$^W = 0/';
system "perl -pi -e '$sub' Build";
exit 0;