Subject: | Can't compile if libmagic need additionnal ldflags |
I was unable to compile the module because on my amd64 libmagic need the -lz flags.
This patch automate the search of ldflags need to compil it by looking the libmagic.la file. A bit ugly but it works.
--- Makefile.PL.orig 2005-06-19 22:42:26.228123424 +0200
+++ Makefile.PL 2005-06-19 22:42:34.965648149 +0200
@@ -2,8 +2,12 @@
use 5.008;
use ExtUtils::MakeMaker;
+use ExtUtils::Liblist;
use Config qw/%Config/;
+my $magiclibdir = (ExtUtils::Liblist->ext('-lmagic'))[3];
+my $otherlflags = `sh -c '. $magiclibdir/libmagic.la; echo "\$dependency_libs"'`;
+
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
@@ -12,7 +16,7 @@ WriteMakefile(
'PREREQ_PM' => {}, # e.g., Module::Name => 1.1
'ABSTRACT_FROM' => 'LibMagic.pm', # retrieve abstract from module
'AUTHOR' => 'Andreas Fitzner <fitzner@informatik.hu-berlin.de>',
- 'LIBS' => ['-lmagic'], # e.g., '-lm'
+ 'LIBS' => ["-lmagic $otherlflags"], # e.g., '-lm'
'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
'INC' => '-I.', # e.g., '-I. -I/usr/include/other'
# Un-comment this if you add C files to link with later:
@@ -57,7 +61,7 @@ EOT
my $exe = "test-if-libmagic-exists$Config{exe_ext}";
$cc_cmd .= "$Config{cc} $Config{ccflags} -I$Config{archlibexp}/CORE -o $exe";
- my $rc = system("$cc_cmd $Config{ldflags} test-if-libmagic-exists.c -lmagic $Config{libs}");
+ my $rc = system("$cc_cmd $Config{ldflags} test-if-libmagic-exists.c -lmagic $Config{libs} $otherlflags" );
unlink("test-if-libmagic-exists.c", $exe, "test-if-libmagic-exists$Config{obj_ext}");