be smarter about extracting LIBS linker entries
authorcturner <devnull@localhost>
Sun, 14 Apr 2002 03:12:14 +0000 (03:12 +0000)
committercturner <devnull@localhost>
Sun, 14 Apr 2002 03:12:14 +0000 (03:12 +0000)
CVS patchset: 5404
CVS date: 2002/04/14 03:12:14

perl-RPM2/Makefile.PL

index 51741a3d7d9f9db8a60a8e7d7d3598a56bfa2ffe..96663c7207d27cd5a6e301df39e1fa8366b295be 100644 (file)
@@ -1,11 +1,27 @@
 use ExtUtils::MakeMaker;
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.
+
+my $libs = "-lrpm -lrpmdb -lrpmio -lpopt";
+
+# try to be smart about which shared libs we should load.
+# use the .la file.  probably linux only.
+
+if (open FH, "</usr/lib/librpm.la") {
+  my ($line, @rest) = grep { /^dependency_libs=/ } <FH>;
+  if ($line and not @rest) {
+    if ($line =~ /^dependency_libs='(.*)'$/) {
+      $libs = "-lrpm $1";
+      print "libs: $libs\n"
+    }
+  }
+}
+
 WriteMakefile(
     'NAME'             => 'RPM2',
     'VERSION_FROM'     => 'RPM2.pm', # finds $VERSION
     'PREREQ_PM'                => {}, # e.g., Module::Name => 1.1
-    'LIBS'             => ['-lpopt -lrpm -lrpmio -lrpmdb'], # e.g., '-lm'
+    'LIBS'             => [ $libs ], # e.g., '-lm'
     'DEFINE'           => '', # e.g., '-DHAVE_SOMETHING'
     'INC'              => '-I/usr/include/rpm', # e.g., '-I/usr/include/other'
     'TYPEMAPS'          => [ 'typemap' ],