Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes allowing IO::Interface to build on illumos (and probably on solaris, too) #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,72 @@

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 sockio.h...";
if (!-r "/usr/include/sys/sockio.h") {
print " Nope, will not use it.\n";
} else {
push @flags, '-DHAVE_SOCKIO_H';
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',
build_requires => {
'ExtUtils::CBuilder' => 0,
dynamic_config => 1,
extra_compiler_flags => compiler_flags(),
build_requires => {
'Config' => 0,
'ExtUtils::CBuilder' => 0,
},
requires => {
'perl' => '5.005',
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();

Expand Down
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Revision history for Perl extension IO::Interface.

1.10 Sun Dec 10 15:54:57 GMT 2017
-Fix build flags after switching to Module::Build

1.09 Tue Dec 9 11:22:56 EST 2014
-Converted to use Module::Build

Expand Down
2 changes: 0 additions & 2 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ lib/IO/Interface.xs
lib/IO/Interface/Simple.pm
LICENSE
MANIFEST
META.json
META.yml Module meta-data (added by MakeMaker)
README.md
t/basic.t
t/simple.t
2 changes: 1 addition & 1 deletion lib/IO/Interface.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ my @flags = qw(IFF_ALLMULTI IFF_AUTOMEDIA IFF_BROADCAST
@EXPORT = qw( );

@ISA = qw(Exporter DynaLoader);
$VERSION = '1.09';
$VERSION = '1.10';

sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
Expand Down
18 changes: 9 additions & 9 deletions lib/IO/Interface.xs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#endif

#ifndef SIOCGIFCONF
#if defined(HAVE_SOCKIO_H)
#include <sys/sockio.h>
#endif

Expand Down Expand Up @@ -426,7 +426,7 @@ if_addr(sock, name, ...)
if (strncmp(name,"any",3) == 0) {
RETVAL = "0.0.0.0";
} else {
bzero((void*)&ifr,sizeof(struct ifreq));
memset((void*)&ifr,0,sizeof(struct ifreq));
strncpy(ifr.ifr_name,name,IFNAMSIZ-1);
ifr.ifr_addr.sa_family = AF_INET;
if (items > 2) {
Expand Down Expand Up @@ -465,7 +465,7 @@ if_broadcast(sock, name, ...)
#if !(defined(HAS_IOCTL) && defined(SIOCGIFBRDADDR))
XSRETURN_UNDEF;
#else
bzero((void*)&ifr,sizeof(struct ifreq));
memset((void*)&ifr,0,sizeof(struct ifreq));
strncpy(ifr.ifr_name,name,IFNAMSIZ-1);
ifr.ifr_addr.sa_family = AF_INET;
if (items > 2) {
Expand Down Expand Up @@ -503,7 +503,7 @@ if_netmask(sock, name, ...)
#if !(defined(HAS_IOCTL) && defined(SIOCGIFNETMASK))
XSRETURN_UNDEF;
#else
bzero((void*)&ifr,sizeof(struct ifreq));
memset((void*)&ifr,0,sizeof(struct ifreq));
strncpy(ifr.ifr_name,name,IFNAMSIZ-1);
ifr.ifr_addr.sa_family = AF_INET;
if (items > 2) {
Expand Down Expand Up @@ -544,7 +544,7 @@ if_dstaddr(sock, name, ...)
#if !(defined(HAS_IOCTL) && defined(SIOCGIFDSTADDR))
XSRETURN_UNDEF;
#else
bzero((void*)&ifr,sizeof(struct ifreq));
memset((void*)&ifr,0,sizeof(struct ifreq));
strncpy(ifr.ifr_name,name,IFNAMSIZ-1);
ifr.ifr_addr.sa_family = AF_INET;
if (items > 2) {
Expand Down Expand Up @@ -621,7 +621,7 @@ if_hwaddr(sock, name, ...)

RETVAL = hwaddr;
#elif (defined(HAS_IOCTL) && defined(SIOCGIFHWADDR))
bzero((void*)&ifr,sizeof(struct ifreq));
memset((void*)&ifr,0,sizeof(struct ifreq));
strncpy(ifr.ifr_name,name,IFNAMSIZ-1);
ifr.ifr_hwaddr.sa_family = AF_UNSPEC;
if (items > 2) {
Expand Down Expand Up @@ -658,7 +658,7 @@ if_flags(sock, name, ...)
#if !(defined(HAS_IOCTL) && defined(SIOCGIFFLAGS))
XSRETURN_UNDEF;
#endif
bzero((void*)&ifr,sizeof(struct ifreq));
memset((void*)&ifr,0,sizeof(struct ifreq));
strncpy(ifr.ifr_name,name,IFNAMSIZ-1);
if (items > 2) {
ifr.ifr_flags = SvIV(ST(2));
Expand Down Expand Up @@ -690,7 +690,7 @@ if_mtu(sock, name, ...)
#if !(defined(HAS_IOCTL) && defined(SIOCGIFFLAGS))
XSRETURN_UNDEF;
#endif
bzero((void*)&ifr,sizeof(struct ifreq));
memset((void*)&ifr,0,sizeof(struct ifreq));
strncpy(ifr.ifr_name,name,IFNAMSIZ-1);
if (items > 2) {
ifr.ifr_flags = SvIV(ST(2));
Expand Down Expand Up @@ -722,7 +722,7 @@ if_metric(sock, name, ...)
#if !(defined(HAS_IOCTL) && defined(SIOCGIFFLAGS))
XSRETURN_UNDEF;
#endif
bzero((void*)&ifr,sizeof(struct ifreq));
memset((void*)&ifr,0,sizeof(struct ifreq));
strncpy(ifr.ifr_name,name,IFNAMSIZ-1);
if (items > 2) {
ifr.ifr_flags = SvIV(ST(2));
Expand Down