Make the sdl2-config script relocatable

main
Anonymous Maarten 2022-06-03 23:08:22 +02:00 committed by Sam Lantinga
parent 142a3630d3
commit 799d39a302
4 changed files with 16 additions and 1 deletions

View File

@ -2697,6 +2697,7 @@ configure_file("${SDL2_SOURCE_DIR}/include/SDL_revision.h.cmake"
if(NOT WINDOWS OR CYGWIN OR MINGW) if(NOT WINDOWS OR CYGWIN OR MINGW)
set(prefix ${CMAKE_INSTALL_PREFIX}) set(prefix ${CMAKE_INSTALL_PREFIX})
file(RELATIVE_PATH bin_prefix_relpath "${CMAKE_INSTALL_FULL_BINDIR}" "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}") set(exec_prefix "\${prefix}")
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")

5
configure vendored
View File

@ -653,6 +653,7 @@ SDL_RLD_FLAGS
SDL_STATIC_LIBS SDL_STATIC_LIBS
SDL_LIBS SDL_LIBS
SDL_CFLAGS SDL_CFLAGS
bin_prefix_relpath
cmake_prefix_relpath cmake_prefix_relpath
INSTALL_SDL2_CONFIG INSTALL_SDL2_CONFIG
LIBUSB_LIBS LIBUSB_LIBS
@ -27058,6 +27059,10 @@ eval pkg_cmakedir=$libdir/cmake/SDL2
cmake_prefix_relpath="$(echo -n "$pkg_cmakedir" | sed -E "s#^$pkg_prefix##" | sed -E "s#[A-Za-z0-9_ .-]+#..#g" )" cmake_prefix_relpath="$(echo -n "$pkg_cmakedir" | sed -E "s#^$pkg_prefix##" | sed -E "s#[A-Za-z0-9_ .-]+#..#g" )"
eval pkg_bindir=$bindir
bin_prefix_relpath="$(echo -n "pkg_bindir" | sed -E "s#^$pkg_prefix##" | sed -E "s#[A-Za-z0-9_ .-]+#..#g" )"

View File

@ -4694,6 +4694,11 @@ eval pkg_cmakedir=$libdir/cmake/SDL2
cmake_prefix_relpath="$(echo -n "$pkg_cmakedir" | sed -E "s#^$pkg_prefix##" | sed -E "s#[A-Za-z0-9_ .-]+#..#g" )" cmake_prefix_relpath="$(echo -n "$pkg_cmakedir" | sed -E "s#^$pkg_prefix##" | sed -E "s#[A-Za-z0-9_ .-]+#..#g" )"
AC_SUBST([cmake_prefix_relpath]) AC_SUBST([cmake_prefix_relpath])
dnl Calculate the location of the prefix, relative to bindir
eval pkg_bindir=$bindir
bin_prefix_relpath="$(echo -n "pkg_bindir" | sed -E "s#^$pkg_prefix##" | sed -E "s#[A-Za-z0-9_ .-]+#..#g" )"
AC_SUBST([bin_prefix_relpath])
dnl Expand the cflags and libraries needed by apps using SDL dnl Expand the cflags and libraries needed by apps using SDL
AC_SUBST(SDL_CFLAGS) AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS) AC_SUBST(SDL_LIBS)

View File

@ -1,6 +1,10 @@
#!/bin/sh #!/bin/sh
prefix=@prefix@ # Get the canonical path of the folder containing this script
bindir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
# Calculate the canonical path of the prefix, relative to the folder of this script
prefix=$(cd -P -- "$bindir/@bin_prefix_relpath@" && printf '%s\n' "$(pwd -P)")
exec_prefix=@exec_prefix@ exec_prefix=@exec_prefix@
exec_prefix_set=no exec_prefix_set=no
libdir=@libdir@ libdir=@libdir@