1 From 6bc7b5fa3f4a4d120da985f79566713ddc9ca2d7 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian.droege@collabora.co.uk>
3 Date: Wed, 14 Nov 2012 17:44:00 +0100
4 Subject: [PATCH 07/14] Don't require libsdl to be installed for autoreconf
8 m4/sdl.m4 | 185 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9 2 files changed, 187 insertions(+)
10 create mode 100644 m4/sdl.m4
12 diff --git a/Makefile.am b/Makefile.am
13 index 831bb9b..0ecf95b 100644
17 +ACLOCAL_AMFLAGS = -I m4
22 diff --git a/m4/sdl.m4 b/m4/sdl.m4
24 index 0000000..639eb85
28 +# Configure paths for SDL
29 +# Sam Lantinga 9/21/99
30 +# stolen from Manish Singh
31 +# stolen back from Frank Belew
32 +# stolen from Manish Singh
33 +# Shamelessly stolen from Owen Taylor
37 +dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
38 +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
40 +AC_DEFUN([AM_PATH_SDL],
42 +dnl Get the cflags and libraries from the sdl-config script
44 +AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
45 + sdl_prefix="$withval", sdl_prefix="")
46 +AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
47 + sdl_exec_prefix="$withval", sdl_exec_prefix="")
48 +AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
49 + , enable_sdltest=yes)
51 + if test x$sdl_exec_prefix != x ; then
52 + sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
53 + if test x${SDL_CONFIG+set} != xset ; then
54 + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
57 + if test x$sdl_prefix != x ; then
58 + sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
59 + if test x${SDL_CONFIG+set} != xset ; then
60 + SDL_CONFIG=$sdl_prefix/bin/sdl-config
64 + as_save_PATH="$PATH"
65 + if test "x$prefix" != xNONE; then
66 + PATH="$prefix/bin:$prefix/usr/bin:$PATH"
68 + AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
69 + PATH="$as_save_PATH"
70 + min_sdl_version=ifelse([$1], ,0.11.0,$1)
71 + AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
73 + if test "$SDL_CONFIG" = "no" ; then
76 + SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags`
77 + SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs`
79 + sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \
80 + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
81 + sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \
82 + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
83 + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
84 + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
85 + if test "x$enable_sdltest" = "xyes" ; then
86 + ac_save_CFLAGS="$CFLAGS"
87 + ac_save_CXXFLAGS="$CXXFLAGS"
88 + ac_save_LIBS="$LIBS"
89 + CFLAGS="$CFLAGS $SDL_CFLAGS"
90 + CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
91 + LIBS="$LIBS $SDL_LIBS"
93 +dnl Now check if the installed SDL is sufficiently new. (Also sanity
94 +dnl checks the results of sdl-config to some extent
104 +my_strdup (char *str)
110 + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
111 + strcpy (new_str, str);
119 +int main (int argc, char *argv[])
121 + int major, minor, micro;
124 + /* This hangs on some systems (?)
125 + system ("touch conf.sdltest");
127 + { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
129 + /* HP/UX 9 (%@#!) writes to sscanf strings */
130 + tmp_version = my_strdup("$min_sdl_version");
131 + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
132 + printf("%s, bad version string\n", "$min_sdl_version");
136 + if (($sdl_major_version > major) ||
137 + (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
138 + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
144 + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
145 + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
146 + printf("*** best to upgrade to the required version.\n");
147 + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
148 + printf("*** to point to the correct copy of sdl-config, and remove the file\n");
149 + printf("*** config.cache before re-running configure\n");
154 +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
155 + CFLAGS="$ac_save_CFLAGS"
156 + CXXFLAGS="$ac_save_CXXFLAGS"
157 + LIBS="$ac_save_LIBS"
160 + if test "x$no_sdl" = x ; then
162 + ifelse([$2], , :, [$2])
165 + if test "$SDL_CONFIG" = "no" ; then
166 + echo "*** The sdl-config script installed by SDL could not be found"
167 + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
168 + echo "*** your path, or set the SDL_CONFIG environment variable to the"
169 + echo "*** full path to sdl-config."
171 + if test -f conf.sdltest ; then
174 + echo "*** Could not run SDL test program, checking why..."
175 + CFLAGS="$CFLAGS $SDL_CFLAGS"
176 + CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
177 + LIBS="$LIBS $SDL_LIBS"
182 +int main(int argc, char *argv[])
185 +#define main K_and_R_C_main
187 + [ echo "*** The test program compiled, but did not run. This usually means"
188 + echo "*** that the run-time linker is not finding SDL or finding the wrong"
189 + echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
190 + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
191 + echo "*** to the installed location Also, make sure you have run ldconfig if that"
192 + echo "*** is required on your system"
194 + echo "*** If you have an old version installed, it is best to remove it, although"
195 + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
196 + [ echo "*** The test program failed to compile or link. See the file config.log for the"
197 + echo "*** exact error that occured. This usually means SDL was incorrectly installed"
198 + echo "*** or that you have moved SDL since it was installed. In the latter case, you"
199 + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
200 + CFLAGS="$ac_save_CFLAGS"
201 + CXXFLAGS="$ac_save_CXXFLAGS"
202 + LIBS="$ac_save_LIBS"
207 + ifelse([$3], , :, [$3])
209 + AC_SUBST(SDL_CFLAGS)