From: Adrian M. Enache Date: Thu, 3 Apr 2003 15:50:48 +0000 (+0300) Subject: LD_PRELOAD hack, still badly flawed / a solution X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9b9c6f34276ee8dd10904b2f4e725d7aaa1617e5;p=p5sagit%2Fp5-mst-13.2.git LD_PRELOAD hack, still badly flawed / a solution Message-ID: <20030403125048.GA6107@ratsnest.hole> On linux, when building a shared library, generate a small shell wrapper, "preload", that preloads libperl.so only if it exists. Useful when the 'make' process stops before the link phase. p4raw-id: //depot/perl@19150 --- diff --git a/Makefile.SH b/Makefile.SH index 63e3176..676eb52 100644 --- a/Makefile.SH +++ b/Makefile.SH @@ -96,26 +96,32 @@ true) ldlibpth=`echo $ldlibpth | sed 's/:*$//'` ;; esac - ;; -*) pldlflags='' - static_target='static' - ;; -esac -case "$ldlibpth" in -# Protect any spaces -*" "*) ldlibpth=`echo $ldlibpth|sed 's/ /\\\\ /g'` ;; -esac + case "$ldlibpth" in + # Protect any spaces + *" "*) ldlibpth=`echo $ldlibpth|sed 's/ /\\\\ /g'` ;; + esac -case "$osname" in -linux) - case "$useshrplib" in - true) - ldlibpth="LD_PRELOAD=\"\$\$LD_PRELOAD `pwd`/$libperl\" $ldlibpth" - ;; + case "$osname" in + linux) + cat <<-'EOT' >| preload + #! /bin/sh + lib=$1 + shift + test -r $lib && export LD_PRELOAD="$lib $LD_PRELOAD" + exec "$@" + EOT + chmod 755 preload + ldlibpth="$ldlibpth `pwd`/preload `pwd`/$libperl" + ;; + os390) test -f /bin/env && ldlibpth="/bin/env $ldlibpth" + ;; esac + ;; -os390) test -f /bin/env && ldlibpth="/bin/env $ldlibpth" + +*) pldlflags='' + static_target='static' ;; esac @@ -944,6 +950,7 @@ _cleaner2: rm -f lib/.exists lib/*/.exists lib/*/*/.exists rm -f h2ph.man pstruct rm -rf .config + rm -f preload rm -f testcompile compilelog -rmdir lib/B lib/Data lib/Digest rm -rf lib/Encode