Skip to content

Commit 4483207

Browse files
committed
Add pkg-config check for SDL lib and fallback to deprecated sdl-config
1 parent 655e403 commit 4483207

File tree

3 files changed

+41
-39
lines changed

3 files changed

+41
-39
lines changed

config.m4

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,30 @@ if test "$PHP_SDL" != "no"; then
3636
fi
3737
dnl }}}
3838

39+
AC_MSG_CHECKING(for SDL2 library)
40+
3941
if test "$PHP_SDL" == "yes"; then
40-
AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no)
42+
PKG_CHECK_MODULES([SDL2], [sdl2 < 3.0])
43+
PHP_EVAL_INCLINE($SDL2_CFLAGS)
44+
PHP_EVAL_LIBLINE($SDL2_LIBS, SDL_SHARED_LIBADD)
45+
AC_MSG_RESULT(using SDL2 version `$PKG_CONFIG --modversion`)
4146
else
4247
SDL2_CONFIG="$PHP_SDL"
43-
fi
44-
45-
AC_MSG_CHECKING(for SDL2 library)
46-
if test -x "$SDL2_CONFIG" ; then
47-
SDL2_VERSION=`$SDL2_CONFIG --version`
48-
AC_MSG_RESULT(using SDL2 version $SDL2_VERSION)
49-
PHP_EVAL_INCLINE(`$SDL2_CONFIG --cflags`)
50-
PHP_EVAL_LIBLINE(`$SDL2_CONFIG --libs`, SDL_SHARED_LIBADD)
51-
else
52-
AC_MSG_ERROR(Cannot find sdl2-config)
48+
if test -x "$SDL2_CONFIG" ; then
49+
SDL2_VERSION=`$SDL2_CONFIG --version`
50+
AC_MSG_RESULT(using SDL2 version $SDL2_VERSION)
51+
PHP_EVAL_INCLINE(`$SDL2_CONFIG --cflags`)
52+
PHP_EVAL_LIBLINE(`$SDL2_CONFIG --libs`, SDL_SHARED_LIBADD)
53+
else
54+
AC_MSG_ERROR(Cannot find sdl2-config)
55+
fi
5356
fi
5457

5558
PHP_SUBST(SDL_SHARED_LIBADD)
5659
AC_DEFINE(HAVE_SDL2, 1, [ ])
5760

58-
PHP_CHECK_LIBRARY(SDL2, SDL_GetRevisionNumber, [
59-
AC_DEFINE(HAVE_SDL_GETREVISIONNUMBER, 1, [ ])
61+
PHP_CHECK_LIBRARY(SDL2, SDL_GetRevision, [
62+
AC_DEFINE(HAVE_SDL_GETREVISION, 1, [ ])
6063
])
6164

6265
SDL_SOURCE_FILES="src/blendmode.c \
@@ -70,7 +73,7 @@ if test "$PHP_SDL" != "no"; then
7073
src/messagebox.c \
7174
src/mouse.c \
7275
src/mutex.c \
73-
src/php_sdl.c \
76+
php_sdl.c \
7477
src/pixels.c \
7578
src/platform.c \
7679
src/power.c \
@@ -86,5 +89,4 @@ if test "$PHP_SDL" != "no"; then
8689
src/window.c"
8790

8891
PHP_NEW_EXTENSION(sdl, $SDL_SOURCE_FILES, $ext_shared,, $PHP_SDL_CFLAGS)
89-
PHP_ADD_BUILD_DIR($ext_builddir/src)
9092
fi

src/php_sdl.c renamed to php_sdl.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@
1717

1818
#include "php_sdl.h"
1919

20-
#include "blendmode.h"
21-
#include "cpuinfo.h"
22-
#include "error.h"
23-
#include "event.h"
24-
#include "filesystem.h"
25-
#include "glcontext.h"
26-
#include "keyboard.h"
27-
#include "messagebox.h"
28-
#include "mouse.h"
29-
#include "mutex.h"
30-
#include "platform.h"
31-
#include "power.h"
32-
#include "pixels.h"
33-
#include "rect.h"
34-
#include "render.h"
35-
#include "rwops.h"
36-
#include "sdl.h"
37-
#include "shape.h"
38-
#include "surface.h"
39-
#include "timer.h"
40-
#include "version.h"
41-
#include "video.h"
42-
#include "window.h"
43-
#include "joystick.h"
20+
#include "src/blendmode.h"
21+
#include "src/cpuinfo.h"
22+
#include "src/error.h"
23+
#include "src/event.h"
24+
#include "src/filesystem.h"
25+
#include "src/glcontext.h"
26+
#include "src/keyboard.h"
27+
#include "src/messagebox.h"
28+
#include "src/mouse.h"
29+
#include "src/mutex.h"
30+
#include "src/platform.h"
31+
#include "src/power.h"
32+
#include "src/pixels.h"
33+
#include "src/rect.h"
34+
#include "src/render.h"
35+
#include "src/rwops.h"
36+
#include "src/sdl.h"
37+
#include "src/shape.h"
38+
#include "src/surface.h"
39+
#include "src/timer.h"
40+
#include "src/version.h"
41+
#include "src/video.h"
42+
#include "src/window.h"
43+
#include "src/joystick.h"
4444

4545
#ifdef COMPILE_DL_SDL
4646
ZEND_GET_MODULE(sdl)
File renamed without changes.

0 commit comments

Comments
 (0)