From 1669d02d5425a01e08aaa4584d0c5fe61a0cb7a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Mon, 5 Mar 2018 17:14:27 +0100
Subject: [PATCH] Include <sys/sysmacros.h> on glibc
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

glibc-2.27.9000 changed something in header files and minor() symbol
is not defined without including <sys/sysmacros.h> now:

+ make test
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Mknod.bs blib/arch/auto/Unix/M
knod/Mknod.bs 644
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef
*Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
Can't load '/home/test/fedora/perl-Unix-Mknod/Unix-Mknod-0.04/blib/arch/auto/Unix/Mknod/Mk
nod.so' for module Unix::Mknod: /home/test/fedora/perl-Unix-Mknod/Unix-Mknod-0.04/blib/arc
h/auto/Unix/Mknod/Mknod.so: undefined symbol: minor at /usr/lib64/perl5/DynaLoader.pm line
 193.

This patch fixes it by including <sys/sysmacros.h> on systems with glibc.

CPAN RT#124687

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 Makefile.PL | 2 ++
 Mknod.xs    | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/Makefile.PL b/Makefile.PL
index a78f929..f0fe012 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -4,6 +4,8 @@ use Config(%Config);
 
 $defines= '-DHAS_SYSMKDEV'
 	if ($Config{osname} eq 'solaris');
+$defines= '-DHAS_SYSSYSMACROS'
+	if (defined $Config{d_gnulibc});
 
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.
diff --git a/Mknod.xs b/Mknod.xs
index 3b9f55f..263614e 100644
--- a/Mknod.xs
+++ b/Mknod.xs
@@ -11,6 +11,9 @@ extern "C" {
 #ifdef HAS_SYSMKDEV
 #include <sys/mkdev.h>
 #endif
+#ifdef HAS_SYSSYSMACROS
+#include <sys/sysmacros.h>
+#endif
 
 #ifdef __cplusplus
 }
-- 
2.13.6