From 7b56ca399a539600090f1710f9225f706dd5b2eb Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Thu, 10 Nov 2022 17:48:54 +0100
Subject: [PATCH] libtool: use STAGING_DIR_HOST in relocatable patch

Instead of using STAGING_DIR and then go up one dir with '../' use
directly STAGING_DIR_HOST env variable. This should produce cleaner
symbolic links.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 tools/libtool/patches/000-relocatable.patch | 50 ++++++++++-----------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/tools/libtool/patches/000-relocatable.patch b/tools/libtool/patches/000-relocatable.patch
index 6d1651be31..996e6445be 100644
--- a/tools/libtool/patches/000-relocatable.patch
+++ b/tools/libtool/patches/000-relocatable.patch
@@ -13,11 +13,11 @@
  : ${MV="mv -f"}
  : ${RM="rm -f"}
 -: ${SED="@SED@"}
-+if test -n "$STAGING_DIR"; then
-+	: ${EGREP="$STAGING_DIR/../host/bin/grep -E"}
-+	: ${FGREP="$STAGING_DIR/../host/bin/grep -F"}
-+	: ${GREP="$STAGING_DIR/../host/bin/grep"}
-+	: ${SED="$STAGING_DIR/../host/bin/sed"}
++if test -n "$STAGING_DIR_HOST"; then
++	: ${EGREP="$STAGING_DIR_HOST/bin/grep -E"}
++	: ${FGREP="$STAGING_DIR_HOST/bin/grep -F"}
++	: ${GREP="$STAGING_DIR_HOST/bin/grep"}
++	: ${SED="$STAGING_DIR_HOST/bin/sed"}
 +else
 +	: ${EGREP="@EGREP@"}
 +	: ${FGREP="@FGREP@"}
@@ -42,11 +42,11 @@
  : ${MV="mv -f"}
  : ${RM="rm -f"}
 -: ${SED="@SED@"}
-+if test -n "$STAGING_DIR"; then
-+	: ${EGREP="$STAGING_DIR/../host/bin/grep -E"}
-+	: ${FGREP="$STAGING_DIR/../host/bin/grep -F"}
-+	: ${GREP="$STAGING_DIR/../host/bin/grep"}
-+	: ${SED="$STAGING_DIR/../host/bin/sed"}
++if test -n "$STAGING_DIR_HOST"; then
++	: ${EGREP="$STAGING_DIR_HOST/bin/grep -E"}
++	: ${FGREP="$STAGING_DIR_HOST/bin/grep -F"}
++	: ${GREP="$STAGING_DIR_HOST/bin/grep"}
++	: ${SED="$STAGING_DIR_HOST/bin/sed"}
 +else
 +	: ${EGREP="@EGREP@"}
 +	: ${FGREP="@FGREP@"}
@@ -64,11 +64,11 @@
 -  pkgdatadir=@pkgdatadir@
 -  pkgltdldir=@pkgdatadir@
 -  aclocaldir=@aclocaldir@
-+  if test -n "$STAGING_DIR"; then
-+    datadir="$STAGING_DIR/../host/share"
-+    pkgdatadir="$STAGING_DIR/../host/share/libtool"
-+    pkgltdldir="$STAGING_DIR/../host/share/libtool"
-+    aclocaldir="$STAGING_DIR/../host/share/aclocal"
++  if test -n "$STAGING_DIR_HOST"; then
++    datadir="$STAGING_DIR_HOST/share"
++    pkgdatadir="$STAGING_DIR_HOST/share/libtool"
++    pkgltdldir="$STAGING_DIR_HOST/share/libtool"
++    aclocaldir="$STAGING_DIR_HOST/share/aclocal"
 +  else
 +    datadir=@datadir@
 +    pkgdatadir=@pkgdatadir@
@@ -88,11 +88,11 @@
 -  pkgdatadir=@pkgdatadir@
 -  pkgltdldir=@pkgdatadir@
 -  aclocaldir=@aclocaldir@
-+  if test -n "$STAGING_DIR"; then
-+    datadir="$STAGING_DIR/../host/share"
-+    pkgdatadir="$STAGING_DIR/../host/share/libtool"
-+    pkgltdldir="$STAGING_DIR/../host/share/libtool"
-+    aclocaldir="$STAGING_DIR/../host/share/aclocal"
++  if test -n "$STAGING_DIR_HOST"; then
++    datadir="$STAGING_DIR_HOST/share"
++    pkgdatadir="$STAGING_DIR_HOST/share/libtool"
++    pkgltdldir="$STAGING_DIR_HOST/share/libtool"
++    aclocaldir="$STAGING_DIR_HOST/share/aclocal"
 +  else
 +    datadir=@datadir@
 +    pkgdatadir=@pkgdatadir@
@@ -111,7 +111,7 @@
 -
  _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
 -_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
-+_LT_DECL([LTCFLAGS], [CFLAGS], ["-O2 -I\${STAGING_DIR:-$STAGING_DIR}/../host/include"], [LTCC compiler flags])dnl
++_LT_DECL([LTCFLAGS], [CFLAGS], ["-O2 -I\${STAGING_DIR_HOST:-$STAGING_DIR_HOST}/include"], [LTCC compiler flags])dnl
  _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
  _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
  
@@ -122,9 +122,9 @@
 -_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
 -_LT_DECL([], [EGREP], [1], [An ERE matcher])
 -_LT_DECL([], [FGREP], [1], [A literal string matcher])
-+_LT_DECL([], [GREP], ["\${STAGING_DIR:-$STAGING_DIR}/../host/bin/grep"], [A grep program that handles long lines])
-+_LT_DECL([], [EGREP], ["\${STAGING_DIR:-$STAGING_DIR}/../host/bin/grep -E"], [An ERE matcher])
-+_LT_DECL([], [FGREP], ["\${STAGING_DIR:-$STAGING_DIR}/../host/bin/grep -F"], [A literal string matcher])
++_LT_DECL([], [GREP], ["\${STAGING_DIR_HOST:-$STAGING_DIR_HOST}/bin/grep"], [A grep program that handles long lines])
++_LT_DECL([], [EGREP], ["\${STAGING_DIR_HOST:-$STAGING_DIR_HOST}/bin/grep -E"], [An ERE matcher])
++_LT_DECL([], [FGREP], ["\${STAGING_DIR_HOST:-$STAGING_DIR_HOST}/bin/grep -F"], [A literal string matcher])
  dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
  AC_SUBST([GREP])
  ])
@@ -135,7 +135,7 @@
 -test -z "$SED" && SED=sed
  Xsed="$SED -e 1s/^X//"
 -_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
-+_LT_DECL([], [SED], ["\${STAGING_DIR:-$STAGING_DIR}/../host/bin/sed"], [A sed program that does not truncate output])
++_LT_DECL([], [SED], ["\${STAGING_DIR_HOST:-$STAGING_DIR_HOST}/bin/sed"], [A sed program that does not truncate output])
  _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
      [Sed that helps us avoid accidentally triggering echo(1) options like -n])
  ])# _LT_DECL_SED
-- 
2.30.2