1# Configure paths for SDL 2# Sam Lantinga 9/21/99 3# stolen from Manish Singh 4# stolen back from Frank Belew 5# stolen from Manish Singh 6# Shamelessly stolen from Owen Taylor 7 8AC_DEFUN([AC_DEFINE_DIR], [ 9 prefix_NONE= 10 exec_prefix_NONE= 11 test "x$prefix" = xNONE && prefix_NONE=yes && 12prefix=$ac_default_prefix 13 test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && 14exec_prefix=$prefix 15dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn 16dnl refers to ${prefix}. Thus we have to use `eval' twice. 17 eval ac_define_dir="\"[$]$2\"" 18 eval ac_define_dir="\"$ac_define_dir\"" 19 AC_SUBST($1, "$ac_define_dir") 20 AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3]) 21 test "$prefix_NONE" && prefix=NONE 22 test "$exec_prefix_NONE" && exec_prefix=NONE 23]) 24 25dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 26dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS 27dnl 28AC_DEFUN(AM_PATH_SDL, 29[dnl 30dnl Get the cflags and libraries from the sdl-config script 31dnl 32AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], 33 sdl_prefix="$withval", sdl_prefix="") 34AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], 35 sdl_exec_prefix="$withval", sdl_exec_prefix="") 36AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], 37 , enable_sdltest=yes) 38 39 if test x$sdl_exec_prefix != x ; then 40 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" 41 if test x${SDL_CONFIG+set} != xset ; then 42 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config 43 fi 44 fi 45 if test x$sdl_prefix != x ; then 46 sdl_args="$sdl_args --prefix=$sdl_prefix" 47 if test x${SDL_CONFIG+set} != xset ; then 48 SDL_CONFIG=$sdl_prefix/bin/sdl-config 49 fi 50 fi 51 52 AC_PATH_PROG(SDL_CONFIG, sdl-config, no) 53 min_sdl_version=ifelse([$1], ,0.11.0,$1) 54 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) 55 no_sdl="" 56 if test "$SDL_CONFIG" = "no" ; then 57 no_sdl=yes 58 else 59 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` 60 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` 61 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" 70 ac_save_LIBS="$LIBS" 71 CFLAGS="$CFLAGS $SDL_CFLAGS" 72 LIBS="$LIBS $SDL_LIBS" 73dnl 74dnl Now check if the installed SDL is sufficiently new. (Also sanity 75dnl checks the results of sdl-config to some extent 76dnl 77 rm -f conf.sdltest 78 AC_TRY_RUN([ 79#include <stdio.h> 80#include <stdlib.h> 81#include <string.h> 82#include "SDL.h" 83 84char* 85my_strdup (char *str) 86{ 87 char *new_str; 88 89 if (str) 90 { 91 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); 92 strcpy (new_str, str); 93 } 94 else 95 new_str = NULL; 96 97 return new_str; 98} 99 100int main (int argc, char *argv[]) 101{ 102 int major, minor, micro; 103 char *tmp_version; 104 105 /* This hangs on some systems (?) 106 system ("touch conf.sdltest"); 107 */ 108 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } 109 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"); 114 exit(1); 115 } 116 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))) 120 { 121 return 0; 122 } 123 else 124 { 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"); 131 return 1; 132 } 133} 134 135],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 136 CFLAGS="$ac_save_CFLAGS" 137 LIBS="$ac_save_LIBS" 138 fi 139 fi 140 if test "x$no_sdl" = x ; then 141 AC_MSG_RESULT(yes) 142 ifelse([$2], , :, [$2]) 143 else 144 AC_MSG_RESULT(no) 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." 150 else 151 if test -f conf.sdltest ; then 152 : 153 else 154 echo "*** Could not run SDL test program, checking why..." 155 CFLAGS="$CFLAGS $SDL_CFLAGS" 156 LIBS="$LIBS $SDL_LIBS" 157 AC_TRY_LINK([ 158#include <stdio.h> 159#include "SDL.h" 160], [ return 0; ], 161 [ echo "*** The test program compiled, but did not run. This usually means" 162 echo "*** that the run-time linker is not finding SDL or finding the wrong" 163 echo "*** version of SDL. If it is not finding SDL, you'll need to set your" 164 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 165 echo "*** to the installed location Also, make sure you have run ldconfig if that" 166 echo "*** is required on your system" 167 echo "***" 168 echo "*** If you have an old version installed, it is best to remove it, although" 169 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 170 [ echo "*** The test program failed to compile or link. See the file config.log for the" 171 echo "*** exact error that occured. This usually means SDL was incorrectly installed" 172 echo "*** or that you have moved SDL since it was installed. In the latter case, you" 173 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) 174 CFLAGS="$ac_save_CFLAGS" 175 LIBS="$ac_save_LIBS" 176 fi 177 fi 178 SDL_CFLAGS="" 179 SDL_LIBS="" 180 ifelse([$3], , :, [$3]) 181 fi 182 AC_SUBST(SDL_CFLAGS) 183 AC_SUBST(SDL_LIBS) 184 rm -f conf.sdltest 185]) 186 187dnl Available from the GNU Autoconf Macro Archive at: 188dnl http://www.gnu.org/software/ac-archive/htmldoc/mdl_have_opengl.html 189dnl 190AC_DEFUN([MDL_HAVE_OPENGL], 191[ 192 AC_REQUIRE([AC_PROG_CC]) 193 AC_REQUIRE([AC_PATH_X]) 194 AC_REQUIRE([AC_PATH_XTRA]) 195 196 AC_CACHE_CHECK([for OpenGL], mdl_cv_have_OpenGL, 197 [ 198dnl Don't check for Mesa first, vendor specific is usually more optimized 199dnl Check for Mesa first, unless we were asked not to. 200dnl AC_ARG_WITH([--with-Mesa], 201dnl [Prefer the Mesa library over a vendors native OpenGL library (default=yes)], 202dnl with_Mesa_help_string) 203dnl AC_ARG_ENABLE(Mesa, $with_Mesa_help_string, use_Mesa=$enableval, use_Mesa=yes) 204 205dnl if test x"$use_Mesa" = xyes; then 206dnl GL_search_list="MesaGL GL" 207dnl GLU_search_list="MesaGLU GLU" 208dnl GLX_search_list="MesaGLX GLX" 209dnl else 210 GL_search_list="GL MesaGL" 211 GLU_search_list="GLU MesaGLU" 212 GLX_search_list="GLX MesaGLX" 213dnl fi 214 215 AC_LANG_SAVE 216 AC_LANG_C 217 218dnl If we are running under X11 then add in the appropriate libraries. 219if test x"$no_x" != xyes; then 220dnl Add everything we need to compile and link X programs to GL_X_CFLAGS 221dnl and GL_X_LIBS. 222 GL_CFLAGS="$X_CFLAGS" 223 GL_X_LIBS="$X_PRE_LIBS $X_LIBS -lX11 -lXext -lXmu -lXt -lXi $X_EXTRA_LIBS" 224fi 225 GL_save_CPPFLAGS="$CPPFLAGS" 226 CPPFLAGS="$GL_CFLAGS" 227 228 GL_save_LIBS="$LIBS" 229 LIBS="$GL_X_LIBS" 230 231 232 # Save the "AC_MSG_RESULT file descriptor" to FD 8. 233 exec 8>&AC_FD_MSG 234 235 # Temporarily turn off AC_MSG_RESULT so that the user gets pretty 236 # messages. 237 exec AC_FD_MSG>/dev/null 238 239 AC_SEARCH_LIBS(glAccum, $GL_search_list, have_GL=yes, have_GL=no) 240 AC_SEARCH_LIBS(gluBeginCurve, $GLU_search_list, have_GLU=yes, have_GLU=no) 241 AC_SEARCH_LIBS(glXChooseVisual, $GLX_search_list, have_GLX=yes, have_GLX=no) 242 AC_SEARCH_LIBS(glutInit, glut, have_glut=yes, have_glut=no) 243 244 245 246 # Restore pretty messages. 247 exec AC_FD_MSG>&8 248 249 if test -n "$LIBS"; then 250 mdl_cv_have_OpenGL=yes 251 GL_LIBS="$LIBS" 252 AC_SUBST(GL_CFLAGS) 253 AC_SUBST(GL_LIBS) 254 else 255 mdl_cv_have_OpenGL=no 256 GL_CFLAGS= 257 fi 258 259dnl Reset GL_X_LIBS regardless, since it was just a temporary variable 260dnl and we don't want to be global namespace polluters. 261 GL_X_LIBS= 262 263 LIBS="$GL_save_LIBS" 264 CPPFLAGS="$GL_save_CPPFLAGS" 265 266 AC_LANG_RESTORE 267 268dnl bugfix: dont forget to cache this variables, too 269 mdl_cv_GL_CFLAGS="$GL_CFLAGS" 270 mdl_cv_GL_LIBS="$GL_LIBS" 271 mdl_cv_have_GL="$have_GL" 272 mdl_cv_have_GLU="$have_GLU" 273 mdl_cv_have_GLX="$have_GLX" 274 mdl_cv_have_glut="$have_glut" 275 ]) 276 GL_CFLAGS="$mdl_cv_GL_CFLAGS" 277 GL_LIBS="$mdl_cv_GL_LIBS" 278 have_GL="$mdl_cv_have_GL" 279 have_GLU="$mdl_cv_have_GLU" 280 have_GLX="$mdl_cv_have_GLX" 281 have_glut="$mdl_cv_have_glut" 282]) 283dnl endof bugfix -ainan 284