SDL: Make sdl2-config interpreter configurable

From b9f005505b194f498494eec6631c38c3e219fa74 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sun, 23 Jun 2024 23:30:50 +0200
Subject: [PATCH] Make sdl2-config interpreter configurable

---
 CMakeLists.txt |  4 ++++
 configure      | 13 +++++++++++++
 configure.ac   | 12 ++++++++++++
 sdl2-config.in |  2 +-
 4 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c927ae7df04e2..c763c132e324c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3176,6 +3176,10 @@ if(SDL_STATIC AND SDL_SHARED AND NOT sdl_static_libname STREQUAL "SDL2")
   message(STATUS "\"pkg-config --static --libs sdl2\" will return invalid information")
 endif()
 
+set(SDL2_CONFIG_INTERPRETER "/bin/sh")
+if(SOLARIS)
+  set(SDL2_CONFIG_INTERPRETER "/bin/bash")
+endif()
 # MESSAGE(STATUS "SDL_LIBS: ${SDL_LIBS}")
 # MESSAGE(STATUS "SDL_STATIC_LIBS: ${SDL_STATIC_LIBS}")
 
diff --git a/configure b/configure
index 7e559cbb459a1..0ac2e85b2d6a6 100755
--- a/configure
+++ b/configure
@@ -727,6 +727,7 @@ ALSA_LIBS
 ALSA_CFLAGS
 ALLOCA
 CPP
+SDL2_CONFIG_INTERPRETER
 LIBTOOLLINKERTAG
 LINKER
 SORT
@@ -18337,6 +18338,18 @@ esac
 
 
 
+case "$host" in
+    # On Solaris, jack must be linked deferred explicitly
+    # to prevent undefined symbol failures.
+    *-*-solaris*)
+        SDL2_CONFIG_INTERPRETER=/bin/bash
+        ;;
+    *)
+        SDL2_CONFIG_INTERPRETER=/bin/sh
+        ;;
+esac
+
+
 if test x$srcdir != x.; then
     INCLUDE="-Iinclude $INCLUDE"
 elif test -d .git; then
diff --git a/configure.ac b/configure.ac
index 46c17dc3b5bf3..280db2980ce47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,6 +113,18 @@ esac
 AC_SUBST(LINKER)
 AC_SUBST(LIBTOOLLINKERTAG)
 
+case "$host" in
+    # On Solaris, jack must be linked deferred explicitly
+    # to prevent undefined symbol failures.
+    *-*-solaris*)
+        SDL2_CONFIG_INTERPRETER=/bin/bash
+        ;;
+    *)
+        SDL2_CONFIG_INTERPRETER=/bin/sh
+        ;;
+esac
+AC_SUBST(SDL2_CONFIG_INTERPRETER)
+
 if test x$srcdir != x.; then
     INCLUDE="-Iinclude $INCLUDE"
 elif test -d .git; then
diff --git a/sdl2-config.in b/sdl2-config.in
index f6eca7668ca43..7708c294e45cd 100644
--- a/sdl2-config.in
+++ b/sdl2-config.in
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!@SDL2_CONFIG_INTERPRETER@
 
 # Get the canonical path of the folder containing this script
 bindir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")