1 # aclocal.m4 generated automatically by aclocal 1.5
3 # Copyright 1996, 1997, 1998, 1999, 2000, 2001
4 # Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 # $Id: acinclude.m4,v 1.1 2003/11/17 20:13:23 nsubtil Exp $
16 # Configure paths for SDL
17 # Sam Lantinga 9/21/99
18 # stolen from Manish Singh
19 # stolen back from Frank Belew
20 # stolen from Manish Singh
21 # Shamelessly stolen from Owen Taylor
23 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
24 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
28 dnl Get the cflags and libraries from the sdl-config script
30 AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
31 sdl_prefix="$withval", sdl_prefix="")
32 AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
33 sdl_exec_prefix="$withval", sdl_exec_prefix="")
34 AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
37 if test x$sdl_exec_prefix != x ; then
38 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
39 if test x${SDL_CONFIG+set} != xset ; then
40 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
43 if test x$sdl_prefix != x ; then
44 sdl_args="$sdl_args --prefix=$sdl_prefix"
45 if test x${SDL_CONFIG+set} != xset ; then
46 SDL_CONFIG=$sdl_prefix/bin/sdl-config
50 AC_REQUIRE([AC_CANONICAL_TARGET])
51 PATH="$prefix/bin:$prefix/usr/bin:$PATH"
52 AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
53 min_sdl_version=ifelse([$1], ,0.11.0,$1)
54 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
56 if test "$SDL_CONFIG" = "no" ; then
59 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
60 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
62 sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
63 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
64 sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
65 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
66 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
67 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
68 if test "x$enable_sdltest" = "xyes" ; then
69 ac_save_CFLAGS="$CFLAGS"
71 CFLAGS="$CFLAGS $SDL_CFLAGS"
72 LIBS="$LIBS $SDL_LIBS"
74 dnl Now check if the installed SDL is sufficiently new. (Also sanity
75 dnl checks the results of sdl-config to some extent
91 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
92 strcpy (new_str, str);
100 int main (int argc, char *argv[])
102 int major, minor, micro;
105 /* This hangs on some systems (?)
106 system ("touch conf.sdltest");
108 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
110 /* HP/UX 9 (%@#!) writes to sscanf strings */
111 tmp_version = my_strdup("$min_sdl_version");
112 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
113 printf("%s, bad version string\n", "$min_sdl_version");
117 if (($sdl_major_version > major) ||
118 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
119 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
125 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
126 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
127 printf("*** best to upgrade to the required version.\n");
128 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
129 printf("*** to point to the correct copy of sdl-config, and remove the file\n");
130 printf("*** config.cache before re-running configure\n");
135 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
136 CFLAGS="$ac_save_CFLAGS"
140 if test "x$no_sdl" = x ; then
142 ifelse([$2], , :, [$2])
145 if test "$SDL_CONFIG" = "no" ; then
146 echo "*** The sdl-config script installed by SDL could not be found"
147 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
148 echo "*** your path, or set the SDL_CONFIG environment variable to the"
149 echo "*** full path to sdl-config."
151 if test -f conf.sdltest ; then
154 echo "*** Could not run SDL test program, checking why..."
155 CFLAGS="$CFLAGS $SDL_CFLAGS"
156 LIBS="$LIBS $SDL_LIBS"
161 int main(int argc, char *argv[])
164 #define main K_and_R_C_main
166 [ echo "*** The test program compiled, but did not run. This usually means"
167 echo "*** that the run-time linker is not finding SDL or finding the wrong"
168 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
169 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
170 echo "*** to the installed location Also, make sure you have run ldconfig if that"
171 echo "*** is required on your system"
173 echo "*** If you have an old version installed, it is best to remove it, although"
174 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
175 [ echo "*** The test program failed to compile or link. See the file config.log for the"
176 echo "*** exact error that occured. This usually means SDL was incorrectly installed"
177 echo "*** or that you have moved SDL since it was installed. In the latter case, you"
178 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
179 CFLAGS="$ac_save_CFLAGS"
185 ifelse([$3], , :, [$3])