Remove sdl3.m4 and sdl3-config, and document pkg-config as the recommended replacement

Fixes https://github.com/libsdl-org/SDL/issues/6639
This commit is contained in:
Sam Lantinga 2022-11-27 13:19:44 -08:00
parent 0fdabf9595
commit 2af4f74e1c
13 changed files with 32 additions and 392 deletions

View file

@ -16,7 +16,7 @@ indent_style = space
indent_size = 4
indent_style = space
[{CMakeLists.txt,sdl3-config*.cmake.in,cmake/*.cmake}]
[{CMakeLists.txt,cmake/*.cmake}]
indent_size = 2
indent_style = space

View file

@ -62,12 +62,6 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }}
cmake --build cmake_config_build --verbose
- name: Verify sdl3-config
if: ${{ matrix.platform.name == 'CMake' }}
run: |
export CC="${{ steps.setup_ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=${{ matrix.platform.arch }}-none-linux-androideabi${{ matrix.platform.android_platform }}"
export PATH=${{ env.SDL3_DIR }}/bin:$PATH
cmake/test/test_sdlconfig.sh
- name: Verify sdl3.pc
if: ${{ matrix.platform.name == 'CMake' }}
run: |

View file

@ -96,10 +96,6 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }}
cmake --build cmake_config_build --verbose
- name: Verify sdl3-config
run: |
export PATH=${{ env.SDL3_DIR }}/bin:$PATH
cmake/test/test_sdlconfig.sh
- name: Verify sdl3.pc
run: |
export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig

View file

@ -47,12 +47,6 @@ jobs:
-DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }} \
-DCMAKE_BUILD_TYPE=Release
cmake --build cmake_config_build --verbose
- name: Verify sdl3-config
run: |
export CC=mips64r5900el-ps2-elf-gcc
export PATH=${{ env.SDL3_DIR }}/bin:$PATH
export EXTRA_LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib"
cmake/test/test_sdlconfig.sh
- name: Verify sdl3.pc
run: |
export CC=mips64r5900el-ps2-elf-gcc

View file

@ -36,12 +36,6 @@ jobs:
-DTEST_SHARED=FALSE \
-DCMAKE_BUILD_TYPE=Release
cmake --build cmake_config_build --verbose
- name: Verify sdl3-config
run: |
export CC=psp-gcc
export PATH=${{ env.SDL3_DIR }}/bin:$PATH
export EXTRA_LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
cmake/test/test_sdlconfig.sh
- name: Verify sdl3.pc
run: |
export CC=psp-gcc

View file

@ -41,11 +41,6 @@ jobs:
-DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }} \
-DCMAKE_BUILD_TYPE=Release
cmake --build cmake_config_build --verbose
- name: Verify sdl3-config
run: |
export CC=arm-vita-eabi-gcc
export PATH=${{ env.SDL3_DIR }}/bin:$PATH
cmake/test/test_sdlconfig.sh
- name: Verify sdl3.pc
run: |
export CC=arm-vita-eabi-gcc

View file

@ -321,8 +321,7 @@ if(MSVC)
endif()
endif()
# Those are used for pkg-config and friends, so that the sdl3.pc, sdl3-config,
# etc. are created correctly.
# Those are used for pkg-config so sdl3.pc is created correctly.
set(SDL_LIBS "-lSDL3")
set(SDL_CFLAGS )
@ -3023,8 +3022,6 @@ endif()
configure_file("${SDL3_SOURCE_DIR}/sdl3.pc.in"
"${SDL3_BINARY_DIR}/sdl3.pc" @ONLY)
configure_file("${SDL3_SOURCE_DIR}/sdl3-config.in"
"${SDL3_BINARY_DIR}/sdl3-config" @ONLY)
macro(check_add_debug_flag FLAG SUFFIX)
check_c_compiler_flag(${FLAG} HAS_C_FLAG_${SUFFIX})
@ -3466,11 +3463,6 @@ if(NOT SDL3_DISABLE_INSTALL)
install(FILES ${SDL3_BINARY_DIR}/sdl3.pc
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif()
if(NOT (WINDOWS OR CYGWIN) OR MINGW)
install(PROGRAMS ${SDL3_BINARY_DIR}/sdl3-config DESTINATION "${CMAKE_INSTALL_BINDIR}")
# TODO: what about the .spec file? Is it only needed for RPM creation?
install(FILES "${SDL3_SOURCE_DIR}/sdl3.m4" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/aclocal")
endif()
endif()
##### Uninstall target #####

View file

@ -1,51 +0,0 @@
#!/bin/sh
if test "x$CC" = "x"; then
CC=cc
fi
machine="$($CC -dumpmachine)"
case "$machine" in
*mingw* )
EXEPREFIX=""
EXESUFFIX=".exe"
;;
*android* )
EXEPREFIX="lib"
EXESUFFIX=".so"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -shared"
;;
* )
EXEPREFIX=""
EXESUFFIX=""
;;
esac
set -e
# Get the canonical path of the folder containing this script
testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
CFLAGS="$( sdl3-config --cflags )"
LDFLAGS="$( sdl3-config --libs )"
STATIC_LDFLAGS="$( sdl3-config --static-libs )"
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_sdlconfig.c.o $CFLAGS $EXTRA_CFLAGS"
link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig${EXESUFFIX} $LDFLAGS $EXTRA_LDFLAGS"
static_link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig_static${EXESUFFIX} $STATIC_LDFLAGS $EXTRA_LDFLAGS"
echo "-- CC: $CC"
echo "-- CFLAGS: $CFLAGS"
echo "-- EXTRA_CFLAGS: $EXTRA_CFLAGS"
echo "-- LDFLAGS: $LDFLAGS"
echo "-- STATIC_LDFLAGS: $STATIC_LDFLAGS"
echo "-- EXTRA_LDFLAGS: $EXTRA_LDFLAGS"
echo "-- COMPILE: $compile_cmd"
echo "-- LINK: $link_cmd"
echo "-- STATIC_LINK: $static_link_cmd"
set -x
$compile_cmd
$link_cmd
$static_link_cmd

View file

@ -76,12 +76,11 @@ NSApplicationDelegate implementation:
# Using the Simple DirectMedia Layer with a traditional Makefile
An existing build system for your SDL app has good chances
to work almost unchanged on macOS. However, to produce a "real" Mac binary
that you can distribute to users, you need to put the generated binary into a
so called "bundle", which is basically a fancy folder with a name like
"MyCoolGame.app".
An existing build system for your SDL app has good chances to work almost
unchanged on macOS, as long as you link with the SDL framework. However,
to produce a "real" Mac binary that you can distribute to users, you need
to put the generated binary into a so called "bundle", which is basically
a fancy folder with a name like "MyCoolGame.app".
To get this build automatically, add something like the following rule to
your Makefile.am:
@ -124,24 +123,8 @@ But beware! That is only part of the story! With the above, you end up with
a barebones .app bundle, which is double-clickable from the Finder. But
there are some more things you should do before shipping your product...
1. The bundle right now probably is dynamically linked against SDL. That
means that when you copy it to another computer, *it will not run*,
unless you also install SDL on that other computer. A good solution
for this dilemma is to static link against SDL. On macOS, you can
achieve that by linking against the libraries listed by
```bash
sdl3-config --static-libs
```
instead of those listed by
```bash
sdl3-config --libs
```
Depending on how exactly SDL is integrated into your build systems, the
way to achieve that varies, so I won't describe it here in detail
1. You'll need to copy the SDL framework into the Contents/Frameworks
folder in your bundle, so it is included along with your application.
2. Add an 'Info.plist' to your application. That is a special XML file which
contains some meta-information about your application (like some copyright

View file

@ -6,6 +6,28 @@ We have provided a handy Python script to automate some of this work for you [li
SDL headers should now be included as `#include <SDL3/SDL.h>`. Typically that's the only header you'll need in your application unless you are using OpenGL or Vulkan functionality.
CMake users should use this snippet to include SDL support in their project:
```
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3main)
if(TARGET SDL3::SDL3main)
target_link_libraries(mygame PRIVATE SDL3::SDL3main)
endif()
target_link_libraries(mygame PRIVATE SDL3::SDL3)
```
Autotools users should use this snippet to include SDL support in their project:
```
PKG_CHECK_MODULES([SDL3], [sdl3])
```
and then add $SDL3_CFLAGS to their project CFLAGS and $SDL3_LIBS to their project LDFLAGS
Makefile users can use this snippet to include SDL support in their project:
```
CFLAGS += $(shell pkg-config sdl3 --cflags)
LDFLAGS += $(shell pkg-config sdl3 --libs)
```
## SDL_platform.h

View file

@ -87,7 +87,7 @@ The final step is compiling SDL itself.
To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths:
perl -w -pi -e "s#$PWD/rpi-sdl3-installed#/usr/local#g;" ./rpi-sdl3-installed/lib/libSDL3.la ./rpi-sdl3-installed/lib/pkgconfig/sdl3.pc ./rpi-sdl3-installed/bin/sdl3-config
perl -w -pi -e "s#$PWD/rpi-sdl3-installed#/usr/local#g;" ./rpi-sdl3-installed/lib/libSDL3.la ./rpi-sdl3-installed/lib/pkgconfig/sdl3.pc
Apps don't work or poor video/audio performance
-----------------------------------------------

View file

@ -1,65 +0,0 @@
#!/bin/sh
# 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_set=no
libdir=@libdir@
@ENABLE_STATIC_FALSE@usage="\
@ENABLE_STATIC_FALSE@Usage: $0 [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs]"
@ENABLE_STATIC_TRUE@usage="\
@ENABLE_STATIC_TRUE@Usage: $0 [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]"
if test $# -eq 0; then
echo "${usage}" 1>&2
exit 1
fi
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--prefix=*)
prefix=$optarg
if test $exec_prefix_set = no ; then
exec_prefix=$optarg
fi
;;
--prefix)
echo $prefix
;;
--exec-prefix=*)
exec_prefix=$optarg
exec_prefix_set=yes
;;
--exec-prefix)
echo $exec_prefix
;;
--version)
echo @SDL_VERSION@
;;
--cflags)
echo -I@includedir@ -I@includedir@/SDL3 @SDL_CFLAGS@
;;
@ENABLE_SHARED_TRUE@ --libs)
@ENABLE_SHARED_TRUE@ echo -L@libdir@ @SDL_RLD_FLAGS@ @SDL_LIBS@
@ENABLE_SHARED_TRUE@ ;;
@ENABLE_STATIC_TRUE@@ENABLE_SHARED_TRUE@ --static-libs)
@ENABLE_STATIC_TRUE@@ENABLE_SHARED_FALSE@ --libs|--static-libs)
@ENABLE_STATIC_TRUE@ sdl_static_libs=$(echo "@SDL_LIBS@ @SDL_STATIC_LIBS@" | sed -E "s#-lSDL3[ $]#$libdir/libSDL3.a #g")
@ENABLE_STATIC_TRUE@ echo -L@libdir@ $sdl_static_libs
@ENABLE_STATIC_TRUE@ ;;
*)
echo "${usage}" 1>&2
exit 1
;;
esac
shift
done

214
sdl3.m4
View file

@ -1,214 +0,0 @@
# Configure paths for SDL
# Sam Lantinga 9/21/99
# stolen from Manish Singh
# stolen back from Frank Belew
# stolen from Manish Singh
# Shamelessly stolen from Owen Taylor
#
# Changelog:
# * also look for SDL3.framework under macOS
# * removed HP/UX 9 support.
# * updated for newer autoconf.
# serial 2
dnl AM_PATH_SDL3([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
dnl
AC_DEFUN([AM_PATH_SDL3],
[dnl
dnl Get the cflags and libraries from the sdl3-config script
dnl
AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
sdl_prefix="$withval", sdl_prefix="")
AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
sdl_exec_prefix="$withval", sdl_exec_prefix="")
AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
, enable_sdltest=yes)
AC_ARG_ENABLE(sdlframework, [ --disable-sdlframework Do not search for SDL3.framework],
, search_sdl_framework=yes)
AC_ARG_VAR(SDL3_FRAMEWORK, [Path to SDL3.framework])
min_sdl_version=ifelse([$1], ,3.0.0,$1)
if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
PKG_CHECK_MODULES([SDL], [sdl3 >= $min_sdl_version],
[sdl_pc=yes],
[sdl_pc=no])
else
sdl_pc=no
if test x$sdl_exec_prefix != x ; then
sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
if test x${SDL3_CONFIG+set} != xset ; then
SDL3_CONFIG=$sdl_exec_prefix/bin/sdl3-config
fi
fi
if test x$sdl_prefix != x ; then
sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
if test x${SDL3_CONFIG+set} != xset ; then
SDL3_CONFIG=$sdl_prefix/bin/sdl3-config
fi
fi
fi
if test "x$sdl_pc" = xyes ; then
no_sdl=""
SDL3_CONFIG="pkg-config sdl3"
else
as_save_PATH="$PATH"
if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then
PATH="$prefix/bin:$prefix/usr/bin:$PATH"
fi
AC_PATH_PROG(SDL3_CONFIG, sdl3-config, no, [$PATH])
PATH="$as_save_PATH"
no_sdl=""
if test "$SDL3_CONFIG" = "no" -a "x$search_sdl_framework" = "xyes"; then
AC_MSG_CHECKING(for SDL3.framework)
if test "x$SDL3_FRAMEWORK" != x; then
sdl_framework=$SDL3_FRAMEWORK
else
for d in / ~/ /System/; do
if test -d "${d}Library/Frameworks/SDL3.framework"; then
sdl_framework="${d}Library/Frameworks/SDL3.framework"
fi
done
fi
if test x"$sdl_framework" != x && test -d "$sdl_framework"; then
AC_MSG_RESULT($sdl_framework)
sdl_framework_dir=`dirname $sdl_framework`
SDL_CFLAGS="-F$sdl_framework_dir -Wl,-framework,SDL3 -I$sdl_framework/include"
SDL_LIBS="-F$sdl_framework_dir -Wl,-framework,SDL3"
else
no_sdl=yes
fi
fi
if test "$SDL3_CONFIG" != "no"; then
if test "x$sdl_pc" = "xno"; then
AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
SDL_CFLAGS=`$SDL3_CONFIG $sdl_config_args --cflags`
SDL_LIBS=`$SDL3_CONFIG $sdl_config_args --libs`
fi
sdl_major_version=`$SDL3_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
sdl_minor_version=`$SDL3_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
sdl_micro_version=`$SDL3_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_sdltest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_CXXFLAGS="$CXXFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $SDL_CFLAGS"
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
dnl
dnl Now check if the installed SDL is sufficiently new. (Also sanity
dnl checks the results of sdl3-config to some extent
dnl
rm -f conf.sdltest
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main (int argc, char *argv[])
{
int major, minor, micro;
FILE *fp = fopen("conf.sdltest", "w");
if (fp) fclose(fp);
if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, &micro) != 3) {
printf("%s, bad version string\n", "$min_sdl_version");
exit(1);
}
if (($sdl_major_version > major) ||
(($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
(($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
{
return 0;
}
else
{
printf("\n*** 'sdl3-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
printf("*** of SDL required is %d.%d.%d. If sdl3-config is correct, then it is\n", major, minor, micro);
printf("*** best to upgrade to the required version.\n");
printf("*** If sdl3-config was wrong, set the environment variable SDL3_CONFIG\n");
printf("*** to point to the correct copy of sdl3-config, and remove the file\n");
printf("*** config.cache before re-running configure\n");
return 1;
}
}
]])], [], [no_sdl=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS"
fi
if test "x$sdl_pc" = "xno"; then
if test "x$no_sdl" = "xyes"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
fi
fi
fi
fi
if test "x$no_sdl" = x ; then
ifelse([$2], , :, [$2])
else
if test "$SDL3_CONFIG" = "no" ; then
echo "*** The sdl3-config script installed by SDL could not be found"
echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the SDL3_CONFIG environment variable to the"
echo "*** full path to sdl3-config."
else
if test -f conf.sdltest ; then
:
else
echo "*** Could not run SDL test program, checking why..."
CFLAGS="$CFLAGS $SDL_CFLAGS"
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include "SDL.h"
int main(int argc, char *argv[])
{ return 0; }
#undef main
#define main K_and_R_C_main
]], [[ return 0; ]])],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding SDL or finding the wrong"
echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means SDL was incorrectly installed"
echo "*** or that you have moved SDL since it was installed. In the latter case, you"
echo "*** may want to edit the sdl3-config script: $SDL3_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
SDL_CFLAGS=""
SDL_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS)
rm -f conf.sdltest
])