]> eyrie.org Git - kerberos/sident.git/commitdiff
Okay, I think this actually works for getting the module to build against
authorRuss Allbery <rra@stanford.edu>
Sun, 13 Jun 2004 03:08:32 +0000 (03:08 +0000)
committerRuss Allbery <rra@stanford.edu>
Sun, 13 Jun 2004 03:08:32 +0000 (03:08 +0000)
the newly built libsident library, without hard-coding an rpath to my
build tree.

perl/Makefile.PL.in

index 1edc6f2cae9f9f166d397674e4521d184b09cd43..096b7dbc9cc88ac870d245567ae3dddca182970c 100644 (file)
@@ -2,21 +2,50 @@
 # $Id$
 
 # It's practically impossible to change the library link order with the Perl
-# build system.  This is just broken.
+# build system.  It's also pratically impossible to correctly link a Perl
+# extension against a library that's built out of the same source tree without
+# introducing an rpath to the source tree, a potential security hole.
+#
+# If I don't tell MakeMaker about the full path to the just-built library, it
+# will helpfully delete the -lsident reference and then create a broken
+# module, while saying that this is probably harmless.  If I do include it, I
+# have to fight with it to not add an rpath to the built module.  I did the
+# latter.  I don't know how portable this will be, but it's the only thing I
+# can come up with that actually works.
+
 use Config;
+use ExtUtils::MakeMaker;
+
+# We have to tell MakeMaker to find the sident libraries here.
+$PATH = '@abs_top_builddir@/requester/.libs';
+
+# Hack the local path into lddlflags so that it will be first.  Otherwise, we
+# may accidentally build against an already installed libsident instead of the
+# one that we just built.
 my $lddlflags = $Config{lddlflags};
-my $additions = '-L@abs_top_builddir@/requester @LDFLAGS@ @KRB_LDFLAGS@';
+my $additions = "-L$PATH @LDFLAGS@ @KRB_LDFLAGS@";
 $lddlflags =~ s%(^| )-L% $additions -L%;
 
-use ExtUtils::MakeMaker;
+# Override extliblist so that it never puts anything relative to the build
+# directory into LD_RUN_PATH.  Otherwise, ExtUtils::Liblist will hard-code the
+# build directory into the rpath of the module .so because it's trying to be
+# *way* too helpful.
+package MY;
+sub const_loadlibs {
+    my $loadlibs = shift->SUPER::const_loadlibs (@_);
+    $loadlibs =~ s%^(LD_RUN_PATH =.*[\s:])$main::PATH(:|\n)%$1$2%m;
+    return $loadlibs;
+}
+package main;
+
+# Okay, we can finally generate the Makefile.
 WriteMakefile(
     NAME                => 'Net::Sident',
     VERSION_FROM        => 'Sident.pm',
     ($] >= 5.005 ?
      (ABSTRACT_FROM     => 'Sident.pm',
       AUTHOR            => 'Booker Bense (bbense@stanford.edu)') : ()),
-    INC                 => '-I@top_srcdir@/include @CPPFLAGS@'
-                           . ' @KRB_CPPFLAGS@',
+    INC                 => '-I@top_srcdir@/include @CPPFLAGS@ @KRB_CPPFLAGS@',
     LDDLFLAGS           => $lddlflags,
     LIBS                => "$additions -lsident @KRB_LIBS@ @LIBS@"
 );