Subject: | [PATCH] parse @ARGV like EU::MM |
Until recently, I used to be able to build File::LibMagic against my
private installation of libmagic, thus:
perl Makefile.PL LIBS=-L$HOME/local/lib INC=-I$HOME/local/include
Now the author added Devel::CheckLib to his Makefile.PL and so it
erroneously aborts:
Can't link/include 'magic.h', 'magic'
The reason for that is that Devel::CheckLib does not check the
command-line parameters like EU::MM does. The attached patch fixes this.
It applies cleanly against 0.5 with:
git apply 0001-parse-ARGV-like-EU-MM.patch
Subject: | 0001-parse-ARGV-like-EU-MM.patch |
From 6253f023415f2beaf971b8571320855bcebdabcf Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Lars=20D=C9=AA=E1=B4=87=E1=B4=84=E1=B4=8B=E1=B4=8F=E1=B4=A1=20=E8=BF=AA=E6=8B=89=E6=96=AF?= <daxim@cpan.org>
Date: Wed, 13 May 2009 19:41:02 +0200
Subject: [PATCH] parse @ARGV like EU::MM
---
lib/Devel/CheckLib.pm | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/lib/Devel/CheckLib.pm b/lib/Devel/CheckLib.pm
index d7167f4..2a3abad 100644
--- a/lib/Devel/CheckLib.pm
+++ b/lib/Devel/CheckLib.pm
@@ -149,14 +149,27 @@ sub assert_lib {
if $args{incpath};
# work-a-like for Makefile.PL's LIBS and INC arguments
+ # if given as command-line argument, append to %args
+ for my $arg (@ARGV) {
+ for my $mm_attr_key qw(LIBS INC) {
+ if (my ($mm_attr_value) = $arg =~ /\A $mm_attr_key = (.*)/x) {
+ # it is tempting to put some \s* into the expression, but the
+ # MM command-line parser only accepts LIBS etc. followed by =,
+ # so we should not be any more lenient with whitespace than that
+ $args{$mm_attr_key} .= " $mm_attr_value";
+ }
+ }
+ }
+
+ # using special form of split to trim whitespace
if(defined($args{LIBS})) {
- foreach my $arg (split(/\s+/, $args{LIBS})) {
+ foreach my $arg (split(' ', $args{LIBS})) {
die("LIBS argument badly-formed: $arg\n") unless($arg =~ /^-l/i);
push @{$arg =~ /^-l/ ? \@libs : \@libpaths}, substr($arg, 2);
}
}
if(defined($args{INC})) {
- foreach my $arg (split(/\s+/, $args{INC})) {
+ foreach my $arg (split(' ', $args{INC})) {
die("INC argument badly-formed: $arg\n") unless($arg =~ /^-I/);
push @incpaths, substr($arg, 2);
}
--
1.6.3