diff mbox

[2/6] package/pkg-utils.mk: add get_rpaths helpers

Message ID 1436718395-10536-3-git-send-email-s.martin49@gmail.com
State Rejected
Headers show

Commit Message

Samuel Martin July 12, 2015, 4:26 p.m. UTC
This helper computes the value of the RPATH for the given binary.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
---
 package/pkg-utils.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox

Patch

diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index 442c528..b556525 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -54,6 +54,18 @@  relative-path = $(strip \
 	$(__r)$(subst /%,%,$(2))))
 
 
+# Return the RPATH value starting with XORIGIN instead of $ORIGIN.
+# This helper supports multi-libdirs in RPATH.
+#   $1: base directory, e.g. $(HOST_DIR)
+#   $2: binary path (should start with base directory)
+#   $3: libdirs, a space-separated list of paths (each libdir should
+#       start with base directory)
+get_rpaths = $(eval __rp :=) \
+	$(foreach libdir,$(3),\
+		$(eval __rp := $(__rp):XORIGIN/$(call \
+			relative-path,$(dir $(patsubst $(1)%,%,$(2))),$(patsubst $(1)%,%,$(libdir))))) \
+	$(patsubst :%,%,$(__rp))
+
 #
 # Manipulation of .config files based on the Kconfig
 # infrastructure. Used by the BusyBox package, the Linux kernel