diff --git a/Build.PL b/Build.PL index 8f93f76..6b912c3 100644 --- a/Build.PL +++ b/Build.PL @@ -2,6 +2,51 @@ 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', @@ -9,13 +54,20 @@ my $build = Module::Build->new( dist_author => 'Lincoln Stein ', 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(); diff --git a/Changes b/Changes index 9be2ad3..ed49d7c 100644 --- a/Changes +++ b/Changes @@ -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 diff --git a/MANIFEST b/MANIFEST index e8d2d0d..f3cdb52 100644 --- a/MANIFEST +++ b/MANIFEST @@ -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 diff --git a/lib/IO/Interface.pm b/lib/IO/Interface.pm index 419aa00..8d5096d 100644 --- a/lib/IO/Interface.pm +++ b/lib/IO/Interface.pm @@ -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() diff --git a/lib/IO/Interface.xs b/lib/IO/Interface.xs index 9d500d9..903931f 100644 --- a/lib/IO/Interface.xs +++ b/lib/IO/Interface.xs @@ -28,7 +28,7 @@ #endif -#ifndef SIOCGIFCONF +#if defined(HAVE_SOCKIO_H) #include #endif @@ -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) { @@ -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) { @@ -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) { @@ -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) { @@ -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) { @@ -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)); @@ -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)); @@ -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));