Subject: | Fails to build with glibc without Sun RPC, try using libnsl2 instead |
Fedora 28 stopped provided Sun RPC libraries and header files from Glibc and hence the build fails like this:
gcc -c -D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -DVERSION=\"0.44\" -DXS_VERSION=\"0.44\" -fPIC "-I/usr/lib64/perl5/CORE" NIS.c
NIS.xs:9:10: fatal error: rpc/rpc.h: No such file or directory
9 | #include <rpc/rpc.h>
| ^~~~~~~~~~~
An attached patch fixes it. Please note that there are some compiler warnings not addressed by this patch. Also please note that all tests pass, but I did not check the code against a real NIS server as I have none.
Subject: | 0001-Use-libnsl2-if-possible.patch |
From e6fe1f9deec0f3a302b71d621d27f78d56c1b1fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Mon, 4 May 2020 09:43:36 +0200
Subject: [PATCH] Use libnsl2 if possible
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Glibc can be built without a support for Sun RPC and applications are
advised to use libnsl2 library instead. This is the case of Fedora 28
Linux distribution.
This patch uses ExtUtils::PkgConfig to locate and link with libnsl2
library if it is found. Otherwise it falls back to linking to libnsl
as it used until now.
Signed-off-by: Petr PÃsaÅ <ppisar@redhat.com>
---
Makefile.PL | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 642f9a8..8184df6 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,16 +1,27 @@
# $Id$
use ExtUtils::MakeMaker;
+use ExtUtils::PkgConfig;
+use Config;
# It's 2007. Time to forget about 5.005.
use 5.006;
+my %flags;
+if (ExtUtils::PkgConfig->exists('libnsl')) {
+ %flags = ExtUtils::PkgConfig->find('libnsl');
+} else {
+ $flags{cflags} = '';
+ $flags{libs} = '-lnsl';
+}
+
WriteMakefile(
NAME => 'Net::NIS',
AUTHOR => 'Eduardo Santiago <esm@cpan.org>',
VERSION_FROM => 'NIS.pm',
ABSTRACT_FROM => 'NIS.pod',
- LIBS => '-lnsl',
- PREREQ_PM => { 'Test::More' => 0 },
+ CCFLAGS => join(' ', $Config{ccflags}, $flags{cflags}),
+ LIBS => $flags{libs},
+ PREREQ_PM => { 'Config' => '0', 'ExtUtils::PkgConfig' => '0', 'Test::More' => 0 },
# The PREOP condition prevents me from doing incomplete releases :-)
dist => {
--
2.21.3