about summary refs log tree commit diff
path: root/Makeconfig
diff options
context:
space:
mode:
Diffstat (limited to 'Makeconfig')
-rw-r--r--Makeconfig17
1 files changed, 17 insertions, 0 deletions
diff --git a/Makeconfig b/Makeconfig
index cbb2db0102..47c48d4615 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -301,8 +301,10 @@ ifeq ($(elf),yes)
 endif
 ifdef objpfx
 csu-objpfx = $(objpfx)
+elf-objpfx = $(objpfx)
 else
 csu-objpfx = $(..)csu/
+elf-objpfx = $(..)elf/
 endif
 
 ifeq (yes,$(build-shared))
@@ -311,6 +313,21 @@ rtld-installed-name = ld.so
 endif
 endif
 
+# How to run a program we just linked with our library.
+# The program binary is assumed to be $(word 2,$^).
+built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
+ifneq (yes,$(build-shared))
+built-program-cmd = $(built-program-file)
+else
+, = ,
+define built-program-cmd
+LD_LIBRARY_PATH=$(common-objdir)$(patsubst -Wl$,-rpath-link=%,:%,\
+					   $(filter -Wl$,-rpath-link=%,\
+						    $(sysdep-LDFLAGS))) \
+$(elf-objpfx)ld.so $(built-program-file)
+endef
+endif
+
 ifndef LD
 LD := ld -X
 endif