summaryrefslogtreecommitdiff
path: root/mk/buildlink2/libtool-fix-la
diff options
context:
space:
mode:
authorjlam <jlam>2002-08-22 08:21:26 +0000
committerjlam <jlam>2002-08-22 08:21:26 +0000
commit13ad1e0372f81cf5075b43a950b78e3ad355baa5 (patch)
tree69a889ca0e05738ba516fadb4850a77ad43da185 /mk/buildlink2/libtool-fix-la
parent3cc8461d11203cee9d2cb73386c1f0c19e08bf83 (diff)
downloadpkgsrc-13ad1e0372f81cf5075b43a950b78e3ad355baa5.tar.gz
Merge pkgsrc/mk from the buildlink2 branch back into the main trunk.
Diffstat (limited to 'mk/buildlink2/libtool-fix-la')
-rw-r--r--mk/buildlink2/libtool-fix-la100
1 files changed, 100 insertions, 0 deletions
diff --git a/mk/buildlink2/libtool-fix-la b/mk/buildlink2/libtool-fix-la
new file mode 100644
index 00000000000..e662f4b2827
--- /dev/null
+++ b/mk/buildlink2/libtool-fix-la
@@ -0,0 +1,100 @@
+# $NetBSD: libtool-fix-la,v 1.2 2002/08/22 08:21:29 jlam Exp $
+#
+# For *.la files, in the "relink_command" line, we make the following
+# replacements:
+#
+# "libfoo.la" -> "-L./.libs libfoo.la"
+# "dirpath/libfoo.la" -> "-Ldirpath/.libs libfoo.la"
+#
+# This allows the libraries to be found within ${WRKSRC} during relinking.
+# We rely on the proper rpath settings to be set by libtool.
+#
+# For the *.lai files, in the "dependency_libs" line, we remove redundant
+# -Ldir and -llib options.
+
+labase=`@BASENAME@ $lafile .la`
+ladir=`@DIRNAME@ $lafile`
+latimestamp=${ladir}/.${labase}.la.timestamp
+laifile=${ladir}/.libs/${labase}.lai
+if [ ! -f $latimestamp ]; then
+ . ${ladir}/${labase}.la
+
+ relink=
+ for i in ${relink_command}; do
+ case "$i" in
+ -I*|-D*)
+ ;;
+ -L*)
+ case "$relink" in
+ *"$i "*) ;;
+ *"$i") ;;
+ *) relink="${relink} $i" ;;
+ esac
+ ;;
+ $lafile)
+ relink="${relink} $i"
+ ;;
+ *.la)
+ ltlibsdir=`@DIRNAME@ $i`/.libs
+ case "$relink" in
+ *"-L$ltlibsdir "*) ;;
+ *"-L$ltlibsdir") ;;
+ *) relink="$relink -L$ltlibsdir" ;;
+ esac
+ relink="${relink} $i"
+ ;;
+ *)
+ relink="${relink} $i"
+ ;;
+ esac
+ done
+ if [ -n "$relink" ]; then
+ @MV@ -f $lafile ${lafile}.blsav
+ (
+ @CAT@ ${lafile}.blsav | @SED@ -e '/^relink_command=/,$d'
+ @ECHO@ "relink_command='$relink'"
+ @CAT@ ${lafile}.blsav | @SED@ -e '1,/^relink_command=/d'
+ ) > $lafile
+ @ECHO@ "==> Fixed $lafile" >> $wrapperlog
+ fi
+ if [ -n "$laifile" ] && [ -f "$laifile" ]; then
+ @SED@ @_BLNK_WRAP_LT_UNTRANSFORM_SED@ \
+ $laifile > ${laifile}.tmp
+ . ${laifile}.tmp
+ L=; l=; lexist=; prev=
+ for i in ${dependency_libs}; do
+ case "$i" in
+ $prev)
+ ;;
+ -L*)
+ case "$L" in
+ *"$i "*) ;;
+ *"$i") ;;
+ *) L="$L $i" ;;
+ esac
+ ;;
+ -l*)
+ lexist=1
+ l="$l $i"
+ ;;
+ *)
+ l="$l $i"
+ ;;
+ esac
+ prev="$i"
+ done
+ if [ -z "$lexist" ]; then
+ L=
+ fi
+ deps="$L$l"
+ @MV@ -f $laifile ${laifile}.blsav
+ (
+ @CAT@ ${laifile}.tmp | @SED@ -e '/^dependency_libs=/,$d'
+ @ECHO@ "dependency_libs='$deps'"
+ @CAT@ ${laifile}.tmp | @SED@ -e '1,/^dependency_libs=/d'
+ ) > ${laifile}
+ @RM@ -f ${laifile}.tmp
+ @ECHO@ "==> Fixed $laifile" >> $wrapperlog
+ fi
+ @TOUCH@ $latimestamp
+fi