1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-25 05:06:15 +02:00

Updated SDL configure check

This check was copied from SDL 1.2.15's version of "sdl.m4".

This fixes a problem where "sdl.h" cannot be found on native compiles
because the output of the sdl-config script is ignored when compiling
the test program.
This commit is contained in:
Maarten ter Huurne 2015-04-21 17:43:26 +02:00
parent 51685e4758
commit 6418ff065f

View File

@ -5,10 +5,12 @@
# stolen from Manish Singh # stolen from Manish Singh
# Shamelessly stolen from Owen Taylor # Shamelessly stolen from Owen Taylor
# serial 1
dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
dnl dnl
AC_DEFUN(AM_PATH_SDL, AC_DEFUN([AM_PATH_SDL],
[dnl [dnl
dnl Get the cflags and libraries from the sdl-config script dnl Get the cflags and libraries from the sdl-config script
dnl dnl
@ -20,38 +22,45 @@ AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run
, enable_sdltest=yes) , enable_sdltest=yes)
if test x$sdl_exec_prefix != x ; then if test x$sdl_exec_prefix != x ; then
sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
if test x${SDL_CONFIG+set} != xset ; then if test x${SDL_CONFIG+set} != xset ; then
SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
fi fi
fi fi
if test x$sdl_prefix != x ; then if test x$sdl_prefix != x ; then
sdl_args="$sdl_args --prefix=$sdl_prefix" sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
if test x${SDL_CONFIG+set} != xset ; then if test x${SDL_CONFIG+set} != xset ; then
SDL_CONFIG=$sdl_prefix/bin/sdl-config SDL_CONFIG=$sdl_prefix/bin/sdl-config
fi fi
fi fi
AC_PATH_PROG(SDL_CONFIG, sdl-config, no) as_save_PATH="$PATH"
if test "x$prefix" != xNONE; then
PATH="$prefix/bin:$prefix/usr/bin:$PATH"
fi
AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
PATH="$as_save_PATH"
min_sdl_version=ifelse([$1], ,0.11.0,$1) min_sdl_version=ifelse([$1], ,0.11.0,$1)
AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
no_sdl="" no_sdl=""
if test "$SDL_CONFIG" = "no" ; then if test "$SDL_CONFIG" = "no" ; then
no_sdl=yes no_sdl=yes
else else
SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags`
SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs`
sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_sdltest" = "xyes" ; then if test "x$enable_sdltest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS" ac_save_CFLAGS="$CFLAGS"
ac_save_CXXFLAGS="$CXXFLAGS"
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $SDL_CFLAGS" CFLAGS="$CFLAGS $SDL_CFLAGS"
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS" LIBS="$LIBS $SDL_LIBS"
dnl dnl
dnl Now check if the installed SDL is sufficiently new. (Also sanity dnl Now check if the installed SDL is sufficiently new. (Also sanity
@ -117,6 +126,7 @@ int main (int argc, char *argv[])
],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS" CFLAGS="$ac_save_CFLAGS"
CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS" LIBS="$ac_save_LIBS"
fi fi
fi fi
@ -136,10 +146,16 @@ int main (int argc, char *argv[])
else else
echo "*** Could not run SDL test program, checking why..." echo "*** Could not run SDL test program, checking why..."
CFLAGS="$CFLAGS $SDL_CFLAGS" CFLAGS="$CFLAGS $SDL_CFLAGS"
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS" LIBS="$LIBS $SDL_LIBS"
AC_TRY_LINK([ AC_TRY_LINK([
#include <stdio.h> #include <stdio.h>
#include "SDL.h" #include "SDL.h"
int main(int argc, char *argv[])
{ return 0; }
#undef main
#define main K_and_R_C_main
], [ return 0; ], ], [ return 0; ],
[ echo "*** The test program compiled, but did not run. This usually means" [ 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 "*** that the run-time linker is not finding SDL or finding the wrong"
@ -155,6 +171,7 @@ int main (int argc, char *argv[])
echo "*** or that you have moved SDL since it was installed. In the latter case, you" echo "*** or that you have moved SDL since it was installed. In the latter case, you"
echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
CFLAGS="$ac_save_CFLAGS" CFLAGS="$ac_save_CFLAGS"
CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS" LIBS="$ac_save_LIBS"
fi fi
fi fi