Skip to content

Commit

Permalink
Add pkg-config check for SDL lib and fallback to deprecated sdl-config
Browse files Browse the repository at this point in the history
  • Loading branch information
kea committed Jun 1, 2023
1 parent 655e403 commit 4483207
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 39 deletions.
32 changes: 17 additions & 15 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,30 @@ if test "$PHP_SDL" != "no"; then
fi
dnl }}}

AC_MSG_CHECKING(for SDL2 library)

if test "$PHP_SDL" == "yes"; then
AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no)
PKG_CHECK_MODULES([SDL2], [sdl2 < 3.0])
PHP_EVAL_INCLINE($SDL2_CFLAGS)
PHP_EVAL_LIBLINE($SDL2_LIBS, SDL_SHARED_LIBADD)
AC_MSG_RESULT(using SDL2 version `$PKG_CONFIG --modversion`)
else
SDL2_CONFIG="$PHP_SDL"
fi

AC_MSG_CHECKING(for SDL2 library)
if test -x "$SDL2_CONFIG" ; then
SDL2_VERSION=`$SDL2_CONFIG --version`
AC_MSG_RESULT(using SDL2 version $SDL2_VERSION)
PHP_EVAL_INCLINE(`$SDL2_CONFIG --cflags`)
PHP_EVAL_LIBLINE(`$SDL2_CONFIG --libs`, SDL_SHARED_LIBADD)
else
AC_MSG_ERROR(Cannot find sdl2-config)
if test -x "$SDL2_CONFIG" ; then
SDL2_VERSION=`$SDL2_CONFIG --version`
AC_MSG_RESULT(using SDL2 version $SDL2_VERSION)
PHP_EVAL_INCLINE(`$SDL2_CONFIG --cflags`)
PHP_EVAL_LIBLINE(`$SDL2_CONFIG --libs`, SDL_SHARED_LIBADD)
else
AC_MSG_ERROR(Cannot find sdl2-config)
fi
fi

PHP_SUBST(SDL_SHARED_LIBADD)
AC_DEFINE(HAVE_SDL2, 1, [ ])

PHP_CHECK_LIBRARY(SDL2, SDL_GetRevisionNumber, [
AC_DEFINE(HAVE_SDL_GETREVISIONNUMBER, 1, [ ])
PHP_CHECK_LIBRARY(SDL2, SDL_GetRevision, [
AC_DEFINE(HAVE_SDL_GETREVISION, 1, [ ])
])

SDL_SOURCE_FILES="src/blendmode.c \
Expand All @@ -70,7 +73,7 @@ if test "$PHP_SDL" != "no"; then
src/messagebox.c \
src/mouse.c \
src/mutex.c \
src/php_sdl.c \
php_sdl.c \
src/pixels.c \
src/platform.c \
src/power.c \
Expand All @@ -86,5 +89,4 @@ if test "$PHP_SDL" != "no"; then
src/window.c"

PHP_NEW_EXTENSION(sdl, $SDL_SOURCE_FILES, $ext_shared,, $PHP_SDL_CFLAGS)
PHP_ADD_BUILD_DIR($ext_builddir/src)
fi
48 changes: 24 additions & 24 deletions src/php_sdl.c → php_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@

#include "php_sdl.h"

#include "blendmode.h"
#include "cpuinfo.h"
#include "error.h"
#include "event.h"
#include "filesystem.h"
#include "glcontext.h"
#include "keyboard.h"
#include "messagebox.h"
#include "mouse.h"
#include "mutex.h"
#include "platform.h"
#include "power.h"
#include "pixels.h"
#include "rect.h"
#include "render.h"
#include "rwops.h"
#include "sdl.h"
#include "shape.h"
#include "surface.h"
#include "timer.h"
#include "version.h"
#include "video.h"
#include "window.h"
#include "joystick.h"
#include "src/blendmode.h"
#include "src/cpuinfo.h"
#include "src/error.h"
#include "src/event.h"
#include "src/filesystem.h"
#include "src/glcontext.h"
#include "src/keyboard.h"
#include "src/messagebox.h"
#include "src/mouse.h"
#include "src/mutex.h"
#include "src/platform.h"
#include "src/power.h"
#include "src/pixels.h"
#include "src/rect.h"
#include "src/render.h"
#include "src/rwops.h"
#include "src/sdl.h"
#include "src/shape.h"
#include "src/surface.h"
#include "src/timer.h"
#include "src/version.h"
#include "src/video.h"
#include "src/window.h"
#include "src/joystick.h"

#ifdef COMPILE_DL_SDL
ZEND_GET_MODULE(sdl)
Expand Down
File renamed without changes.

0 comments on commit 4483207

Please sign in to comment.