diff --git a/bin/mangohud.in b/bin/mangohud.in index e9fec054..eadce2d2 100755 --- a/bin/mangohud.in +++ b/bin/mangohud.in @@ -13,10 +13,10 @@ if [ "$1" = "--dlsym" ]; then shift fi -MANGOHUD_LIB_NAME="libMangoHud.so" +MANGOHUD_LIB_NAME="@ld_libdir_mangohud_abs@libMangoHud.so" if [ "$MANGOHUD_DLSYM" = "1" ]; then - MANGOHUD_LIB_NAME="libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}" + MANGOHUD_LIB_NAME="@ld_libdir_mangohud_abs@libMangoHud_dlsym.so:${MANGOHUD_LIB_NAME}" fi # Preload using the plain filesnames of the libs, the dynamic linker will diff --git a/build.sh b/build.sh index 81fc8bf5..5bca4d7c 100755 --- a/build.sh +++ b/build.sh @@ -142,14 +142,14 @@ configure() { dependencies git submodule update --init --depth 50 if [[ ! -f "build/meson64/build.ninja" ]]; then - meson build/meson64 --libdir lib/mangohud/lib --prefix /usr -Dappend_libdir_mangohud=false -Dld_libdir_prefix=true $@ ${CONFIGURE_OPTS} + meson build/meson64 --libdir lib/mangohud/lib --prefix /usr -Dappend_libdir_mangohud=false -Dld_libdir_prefix=true -Dld_libdir_abs=true $@ ${CONFIGURE_OPTS} fi if [[ ! -f "build/meson32/build.ninja" ]]; then export CC="gcc -m32" export CXX="g++ -m32" export PKG_CONFIG_PATH="/usr/lib32/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:/usr/lib/pkgconfig:${PKG_CONFIG_PATH_32}" export LLVM_CONFIG="/usr/bin/llvm-config32" - meson build/meson32 --libdir lib/mangohud/lib32 --prefix /usr -Dappend_libdir_mangohud=false -Dld_libdir_prefix=true $@ ${CONFIGURE_OPTS} + meson build/meson32 --libdir lib/mangohud/lib32 --prefix /usr -Dappend_libdir_mangohud=false -Dld_libdir_prefix=true -Dld_libdir_abs=true $@ ${CONFIGURE_OPTS} fi } diff --git a/meson_options.txt b/meson_options.txt index 87338e5e..9bac7910 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,6 +2,7 @@ option('glibcxx_asserts', type : 'boolean', value : false) option('use_system_vulkan', type : 'feature', value : 'disabled', description: 'Use system vulkan headers instead of the provided ones') option('append_libdir_mangohud', type : 'boolean', value : true, description: 'Append "mangohud" to libdir path or not.') option('ld_libdir_prefix', type : 'boolean', value : false, description: 'Set ld libdir to "$prefix/lib/mangohud/\$LIB"') +option('ld_libdir_abs', type : 'boolean', value : false, description: 'Use absolute path in LD_PRELOAD') option('include_doc', type : 'boolean', value : true, description: 'Include the example config') option('with_nvml', type : 'combo', value : 'enabled', choices: ['enabled', 'system', 'disabled'], description: 'Enable NVML support') option('with_xnvctrl', type : 'feature', value : 'enabled', description: 'Enable XNVCtrl support') diff --git a/src/meson.build b/src/meson.build index da4847e2..63935265 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,6 @@ glslang = find_program('glslangValidator') +ld_libdir_mangohud_abs = '' # Needs prefix for configure_file() if get_option('append_libdir_mangohud') libdir_mangohud = join_paths(get_option('libdir'), 'mangohud') @@ -15,6 +16,10 @@ if get_option('ld_libdir_prefix') ld_libdir_mangohud = get_option('prefix') + '/lib/mangohud/\$LIB/' endif +if get_option('ld_libdir_abs') + ld_libdir_mangohud_abs = ld_libdir_mangohud +endif + overlay_shaders = [ 'overlay.frag', 'overlay.vert', @@ -205,7 +210,8 @@ configure_file(input : 'mangohud.json.in', configure_file(input : '../bin/mangohud.in', output : 'mangohud', - configuration : {'ld_libdir_mangohud' : ld_libdir_mangohud}, + configuration : {'ld_libdir_mangohud' : ld_libdir_mangohud, + 'ld_libdir_mangohud_abs': ld_libdir_mangohud_abs}, install_dir : get_option('bindir'), )