summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--RPM4/Makefile.PL35
-rw-r--r--RPM4/NEWS1
-rw-r--r--RPM4/src/Makefile.PL8
3 files changed, 34 insertions, 10 deletions
diff --git a/RPM4/Makefile.PL b/RPM4/Makefile.PL
index 82a0877..d9d4037 100644
--- a/RPM4/Makefile.PL
+++ b/RPM4/Makefile.PL
@@ -2,19 +2,40 @@
# use 5.008;
use ExtUtils::MakeMaker;
+use ExtUtils::PkgConfig;
use Getopt::Long;
-our %CONFIGURE_REQUIRES => (
+# minimum required version of dependencies we need to build
+our %build_reqs = (
+ 'rpm' => '4.9.0',
+);
+our %CONFIGURE_REQUIRES = (
'ExtUtils::MakeMaker' => '6.64',
+ 'ExtUtils::Depends' => '0',
+ 'ExtUtils::PkgConfig' => '0',
'Getopt::Long' => '0',
);
-#- require at least rpm 4.9
-my $rpm_version = `LC_ALL=C rpm --version` =~ /version ([0-9.]+)(?:-(?:beta|rc).*)?$/ ? version->new("v$1") : ();
-$rpm_version ge 4.9.0
- or die <<BARF;
-Unable to build RPM4 with too old (or undetected) rpm version $rpm_version
-BARF
+# Writing a fake Makefile ensures that CPAN will pick up the correct
+# dependencies and install them.
+unless (eval "use ExtUtils::Depends '$CONFIGURE_REQUIRES{'ExtUtils::Depends'}';"
+ . "use ExtUtils::PkgConfig '$CONFIGURE_REQUIRES{'ExtUtils::PkgConfig'}';"
+ . "1") {
+ warn "$@\n";
+ WriteMakefile(
+ NAME => 'URPM',
+ PREREQ_FATAL => 1,
+ PREREQ_PM => \%CONFIGURE_REQUIRES,
+ );
+ exit 1; # not reached
+}
+
+my %cfg;
+unless (eval { %cfg = ExtUtils::PkgConfig->find("rpm >= $build_reqs{rpm}"); 1 })
+{
+ warn $@;
+ exit 0;
+}
sub MY::postamble() {
<<MAKECHANGELOG;
diff --git a/RPM4/NEWS b/RPM4/NEWS
index 7ccf574..18c4250 100644
--- a/RPM4/NEWS
+++ b/RPM4/NEWS
@@ -1,5 +1,6 @@
- cpan testers:
o list dependancies
+ o use PkgConfig in order to find rpm
Version 0.37 - 27 October 2017
diff --git a/RPM4/src/Makefile.PL b/RPM4/src/Makefile.PL
index 7474562..0295f36 100644
--- a/RPM4/src/Makefile.PL
+++ b/RPM4/src/Makefile.PL
@@ -2,6 +2,7 @@
# use 5.008;
use ExtUtils::MakeMaker;
+use ExtUtils::PkgConfig;
use Getopt::Long;
my $rpmv;
@@ -24,7 +25,8 @@ foreach (qw(
$rpmheaderlocation or die "Can't find rpmheader location";
-$rpmv ||= (`rpm --version` =~ /([\d\.]+)/)[0];
+my %cfg = ExtUtils::PkgConfig->find("rpm");
+$rpmv ||= $cfg{modversion};
open(my $FH, "> rpmversion.h") or die "Can't open rpmversion.h";
print $FH "/* File generated by Mafile.PL\n";
print $FH ' * $Id$' . "\n";
@@ -86,7 +88,7 @@ WriteMakefile(
VERSION_FROM => '../lib/RPM4.pm',
OBJECT => "RPM4.o $obj",
INC => "-I$rpmheaderlocation",
- LIBS => "-lrpmsign -lrpm -lrpmio -lrpmbuild -lpopt -lz -lbz2 $ldd",
- 'CCFLAGS' => "-Wall $fl",
+ LIBS => [ $cfg{libs} . " -lrpmsign -lrpmbuild $ldd" ],
+ CCFLAGS => "$cfg{cflags} -Wall $fl",
depend => { "RPM4.xs" => join(" ", @rpmconstantfiles) },
);