From 23bfc418bd444e4963f9acc87169f9c9233457aa Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Fri, 27 May 2016 04:03:48 +0100 Subject: [PATCH] Allow LD_PRELOAD libs to be configured at build time Signed-off-by: Ikey Doherty --- configure.ac | 8 ++++++++ src/shim/lsi.h | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7afad1d..b16e0a4 100644 --- a/configure.ac +++ b/configure.ac @@ -57,6 +57,13 @@ AC_SUBST(STEAMBIN) AC_DEFINE_UNQUOTED(STEAM_BINARY, "$STEAMBIN", [The location of the real Steam binary]) +# The LD_PRELOAD list required to integrate gracefully with the official Steam Runtime +AC_ARG_WITH([preload-libs], AS_HELP_STRING([--with-preload-libs], + [the preload libs to use with Steams own runtime]), [preloadlibs="${withval}"], + [preloadlibs="/usr/\$LIB/libX11.so.6:/usr/\$LIB/libstdc++.so.6"]) + +AC_DEFINE_UNQUOTED([LSI_PRELOAD_LIBS], "$preloadlibs", + [Libraries to preload with Steams runtime]) m4_define([gtk_required_version], [3.4.0]) @@ -88,6 +95,7 @@ AC_MSG_RESULT([ New C++ ABI: ${use_new_abi} Real Steam binary: ${STEAMBIN} GTK+ Frontend: ${have_frontend} + preload-libs: ${preloadlibs} compiler: ${CC} cflags: ${CFLAGS} diff --git a/src/shim/lsi.h b/src/shim/lsi.h index e3832a9..d025383 100644 --- a/src/shim/lsi.h +++ b/src/shim/lsi.h @@ -19,6 +19,8 @@ #include #include +#include "config.h" + /* Mark a variable/argument as unused to skip warnings */ #define __lsi_unused__ __attribute__((unused)) @@ -86,7 +88,11 @@ __lsi_inline__ static inline bool lsi_system_requires_preload(void) */ __lsi_inline__ static inline const char *lsi_preload_list(void) { - return "/usr/$LIB/libX11.so.6:/usr/$LIB/libstdc++.so.6"; + /* Respect existing LD_PRELOAD in environment */ + if (getenv("LD_PRELOAD")) { + return "$LD_PRELOAD:" LSI_PRELOAD_LIBS; + } + return LSI_PRELOAD_LIBS; } /**