1dnl ####################################################### 2dnl ## SDL 3dnl ####################################################### 4 5dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 6dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS 7dnl 8AC_DEFUN(AM_PATH_SDL, 9[dnl 10dnl Get the cflags and libraries from the sdl-config script 11dnl 12AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], sdl_prefix="$withval", sdl_prefix="") 13 14AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], sdl_exec_prefix="$withval", sdl_exec_prefix="") 15 16AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], , enable_sdltest=yes) 17 18 if test x$sdl_exec_prefix != x ; then 19 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" 20 if test x${SDL_CONFIG+set} != xset ; then 21 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config 22 fi 23 fi 24 if test x$sdl_prefix != x ; then 25 sdl_args="$sdl_args --prefix=$sdl_prefix" 26 if test x${SDL_CONFIG+set} != xset ; then 27 SDL_CONFIG=$sdl_prefix/bin/sdl-config 28 fi 29 fi 30 31 AC_REQUIRE([AC_CANONICAL_TARGET]) 32 AC_PATH_PROG(SDL_CONFIG, sdl-config, no) 33 min_sdl_version=ifelse([$1], ,0.11.0,$1) 34 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) 35 no_sdl="" 36 if test "$SDL_CONFIG" = "no" ; then 37 no_sdl=yes 38 else 39 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` 40 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` 41 42 sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ 43 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 44 sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ 45 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 46 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ 47 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 48 if test "x$enable_sdltest" = "xyes" ; then 49 ac_save_CFLAGS="$CFLAGS" 50 ac_save_LIBS="$LIBS" 51 CFLAGS="$CFLAGS $SDL_CFLAGS" 52 LIBS="$LIBS $SDL_LIBS" 53dnl 54dnl Now check if the installed SDL is sufficiently new. (Also sanity 55dnl checks the results of sdl-config to some extent 56dnl 57 rm -f conf.sdltest 58 AC_TRY_RUN([ 59#include <stdio.h> 60#include <stdlib.h> 61#include <string.h> 62#include "SDL.h" 63 64char* 65my_strdup (char *str) 66{ 67 char *new_str; 68 69 if (str) 70 { 71 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); 72 strcpy (new_str, str); 73 } 74 else 75 new_str = NULL; 76 77 return new_str; 78} 79 80int main (int argc, char *argv[]) 81{ 82 int major, minor, micro; 83 char *tmp_version; 84 85 /* This hangs on some systems (?) 86 system ("touch conf.sdltest"); 87 */ 88 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } 89 90 /* HP/UX 9 (%@#!) writes to sscanf strings */ 91 tmp_version = my_strdup("$min_sdl_version"); 92 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 93 printf("%s, bad version string\n", "$min_sdl_version"); 94 exit(1); 95 } 96 97 if (($sdl_major_version > major) || 98 (($sdl_major_version == major) && ($sdl_minor_version > minor)) || 99 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) 100 { 101 return 0; 102 } 103 else 104 { 105 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); 106 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); 107 printf("*** best to upgrade to the required version.\n"); 108 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); 109 printf("*** to point to the correct copy of sdl-config, and remove the file\n"); 110 printf("*** config.cache before re-running configure\n"); 111 return 1; 112 } 113} 114 115],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 116 CFLAGS="$ac_save_CFLAGS" 117 LIBS="$ac_save_LIBS" 118 fi 119 fi 120 if test "x$no_sdl" = x ; then 121 AC_MSG_RESULT(yes) 122 ifelse([$2], , :, [$2]) 123 else 124 AC_MSG_RESULT(no) 125 if test "$SDL_CONFIG" = "no" ; then 126 echo "*** The sdl-config script installed by SDL could not be found" 127 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" 128 echo "*** your path, or set the SDL_CONFIG environment variable to the" 129 echo "*** full path to sdl-config." 130 else 131 if test -f conf.sdltest ; then 132 : 133 else 134 echo "*** Could not run SDL test program, checking why..." 135 CFLAGS="$CFLAGS $SDL_CFLAGS" 136 LIBS="$LIBS $SDL_LIBS" 137 AC_TRY_LINK([ 138#include <stdio.h> 139#include "SDL.h" 140 141int main(int argc, char *argv[]) 142{ return 0; } 143#undef main 144#define main K_and_R_C_main 145], [ return 0; ], 146 [ echo "*** The test program compiled, but did not run. This usually means" 147 echo "*** that the run-time linker is not finding SDL or finding the wrong" 148 echo "*** version of SDL. If it is not finding SDL, you'll need to set your" 149 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 150 echo "*** to the installed location Also, make sure you have run ldconfig if that" 151 echo "*** is required on your system" 152 echo "***" 153 echo "*** If you have an old version installed, it is best to remove it, although" 154 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 155 [ echo "*** The test program failed to compile or link. See the file config.log for the" 156 echo "*** exact error that occured. This usually means SDL was incorrectly installed" 157 echo "*** or that you have moved SDL since it was installed. In the latter case, you" 158 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) 159 CFLAGS="$ac_save_CFLAGS" 160 LIBS="$ac_save_LIBS" 161 fi 162 fi 163 SDL_CFLAGS="" 164 SDL_LIBS="" 165 ifelse([$3], , :, [$3]) 166 fi 167 AC_SUBST(SDL_CFLAGS) 168 AC_SUBST(SDL_LIBS) 169 rm -f conf.sdltest 170]) 171 172dnl ####################################################### 173dnl ## CppUnit 174dnl ####################################################### 175 176dnl 177dnl AM_PATH_CPPUNIT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 178dnl 179AC_DEFUN(AM_PATH_CPPUNIT, 180[ 181 182AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)], 183 cppunit_config_prefix="$withval", cppunit_config_prefix="") 184AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)], 185 cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="") 186 187 if test x$cppunit_config_exec_prefix != x ; then 188 cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix" 189 if test x${CPPUNIT_CONFIG+set} != xset ; then 190 CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config 191 fi 192 fi 193 if test x$cppunit_config_prefix != x ; then 194 cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix" 195 if test x${CPPUNIT_CONFIG+set} != xset ; then 196 CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config 197 fi 198 fi 199 200 AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no) 201 cppunit_version_min=$1 202 203 AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min) 204 no_cppunit="" 205 if test "$CPPUNIT_CONFIG" = "no" ; then 206 no_cppunit=yes 207 else 208 CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags` 209 CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs` 210 cppunit_version=`$CPPUNIT_CONFIG --version` 211 212 cppunit_major_version=`echo $cppunit_version | \ 213 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 214 cppunit_minor_version=`echo $cppunit_version | \ 215 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 216 cppunit_micro_version=`echo $cppunit_version | \ 217 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 218 219 cppunit_major_min=`echo $cppunit_version_min | \ 220 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 221 cppunit_minor_min=`echo $cppunit_version_min | \ 222 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 223 cppunit_micro_min=`echo $cppunit_version_min | \ 224 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 225 226 cppunit_version_proper=`expr \ 227 $cppunit_major_version \> $cppunit_major_min \| \ 228 $cppunit_major_version \= $cppunit_major_min \& \ 229 $cppunit_minor_version \> $cppunit_minor_min \| \ 230 $cppunit_major_version \= $cppunit_major_min \& \ 231 $cppunit_minor_version \= $cppunit_minor_min \& \ 232 $cppunit_micro_version \>= $cppunit_micro_min ` 233 234 if test "$cppunit_version_proper" = "1" ; then 235 AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version]) 236 else 237 AC_MSG_RESULT(no) 238 no_cppunit=yes 239 fi 240 fi 241 242 if test "x$no_cppunit" = x ; then 243 ifelse([$2], , :, [$2]) 244 else 245 CPPUNIT_CFLAGS="" 246 CPPUNIT_LIBS="" 247 ifelse([$3], , :, [$3]) 248 fi 249 250 AC_SUBST(CPPUNIT_CFLAGS) 251 AC_SUBST(CPPUNIT_LIBS) 252]) 253 254 255dnl ####################################################### 256dnl ## ALLEGRO 257dnl ####################################################### 258 259dnl Allegro has a similar *-config program to run, i guess it will 260dnl work if I copy the sdl.m4 and replace all 'sdl' with 'allegro' :P 261 262dnl AM_PATH_ALLEGRO([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 263dnl Test for ALLEGRO, and define ALLEGRO_CFLAGS and ALLEGRO_LIBS 264dnl 265AC_DEFUN(AM_PATH_ALLEGRO, 266[dnl 267dnl Get the cflags and libraries from the allegro-config script 268dnl 269AC_ARG_WITH(allegro-prefix,[ --with-allegro-prefix=PFX Prefix where Allegro is installed (optional)], allegro_prefix="$withval", allegro_prefix="") 270 271AC_ARG_WITH(allegro-exec-prefix,[ --with-allegro-exec-prefix=PFX Exec prefix where Allegro is installed (optional)], allegro_exec_prefix="$withval", allegro_exec_prefix="") 272 273AC_ARG_ENABLE(allegrotest, [ --disable-allegrotest Do not try to compile and run a test Allegro program], , enable_allegrotest=yes) 274 275 if test x$allegro_exec_prefix != x ; then 276 allegro_args="$allegro_args --exec-prefix=$allegro_exec_prefix" 277 if test x${ALLEGRO_CONFIG+set} != xset ; then 278 ALLEGRO_CONFIG=$allegro_exec_prefix/bin/allegro-config 279 fi 280 fi 281 if test x$allegro_prefix != x ; then 282 allegro_args="$allegro_args --prefix=$allegro_prefix" 283 if test x${ALLEGRO_CONFIG+set} != xset ; then 284 ALLEGRO_CONFIG=$allegro_prefix/bin/allegro-config 285 fi 286 fi 287 288 AC_REQUIRE([AC_CANONICAL_TARGET]) 289 AC_PATH_PROG(ALLEGRO_CONFIG, allegro-config, no) 290 min_allegro_version=ifelse([$1], ,0.11.0,$1) 291 AC_MSG_CHECKING(for ALLEGRO - version >= $min_allegro_version) 292 no_allegro="" 293 if test "$ALLEGRO_CONFIG" = "no" ; then 294 no_allegro=yes 295 else 296 ALLEGRO_CFLAGS=`$ALLEGRO_CONFIG $allegroconf_args --cflags` 297 ALLEGRO_LIBS=`$ALLEGRO_CONFIG $allegroconf_args --libs` 298 299 allegro_major_version=`$ALLEGRO_CONFIG $allegro_args --version | \ 300 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 301 allegro_minor_version=`$ALLEGRO_CONFIG $allegro_args --version | \ 302 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 303 allegro_micro_version=`$ALLEGRO_CONFIG $allegro_config_args --version | \ 304 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 305 if test "x$enable_allegrotest" = "xyes" ; then 306 ac_save_CFLAGS="$CFLAGS" 307 ac_save_LIBS="$LIBS" 308 CFLAGS="$CFLAGS $ALLEGRO_CFLAGS" 309 LIBS="$LIBS $ALLEGRO_LIBS" 310dnl 311dnl Now check if the installed ALLEGRO is sufficiently new. (Also sanity 312dnl checks the results of allegro-config to some extent 313dnl 314 rm -f conf.allegrotest 315 AC_TRY_RUN([ 316#include <stdio.h> 317#include <stdlib.h> 318#include <string.h> 319#include "allegro.h" 320 321char* 322my_strdup (char *str) 323{ 324 char *new_str; 325 326 if (str) 327 { 328 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); 329 strcpy (new_str, str); 330 } 331 else 332 new_str = NULL; 333 334 return new_str; 335} 336 337int main (int argc, char *argv[]) 338{ 339 int major, minor, micro; 340 char *tmp_version; 341 342 /* This hangs on some systems (?) 343 system ("touch conf.allegrotest"); 344 */ 345 { FILE *fp = fopen("conf.allegrotest", "a"); if ( fp ) fclose(fp); } 346 347 /* HP/UX 9 writes to sscanf strings */ 348 tmp_version = my_strdup("$min_allegro_version"); 349 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 350 printf("%s, bad version string\n", "$min_allegro_version"); 351 exit(1); 352 } 353 354 if (($allegro_major_version > major) || 355 (($allegro_major_version == major) && ($allegro_minor_version > minor)) || 356 (($allegro_major_version == major) && ($allegro_minor_version == minor) && ($allegro_micro_version >= micro))) 357 { 358 return 0; 359 } 360 else 361 { 362 printf("\n*** 'allegro-config --version' returned %d.%d.%d, but the minimum version\n", $allegro_major_version, $allegro_minor_version, $allegro_micro_version); 363 printf("*** of Allegro required is %d.%d.%d. If allegro-config is correct, then it is\n", major, minor, micro); 364 printf("*** best to upgrade to the required version.\n"); 365 printf("*** If allegro-config was wrong, set the environment variable ALLEGRO_CONFIG\n"); 366 printf("*** to point to the correct copy of allegro-config, and remove the file\n"); 367 printf("*** config.cache before re-running configure\n"); 368 return 1; 369 } 370} 371 372END_OF_MAIN(); 373 374],, no_allegro=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 375 CFLAGS="$ac_save_CFLAGS" 376 LIBS="$ac_save_LIBS" 377 fi 378 fi 379 if test "x$no_allegro" = x ; then 380 AC_MSG_RESULT(yes) 381 ifelse([$2], , :, [$2]) 382 else 383 AC_MSG_RESULT(no) 384 if test "$ALLEGRO_CONFIG" = "no" ; then 385 echo "*** The allegro-config script installed by Allegro could not be found" 386 echo "*** If Allegro was installed in PREFIX, make sure PREFIX/bin is in" 387 echo "*** your path, or set the ALLEGRO_CONFIG environment variable to the" 388 echo "*** full path to allegro-config." 389 else 390 if test -f conf.allegrotest ; then 391 : 392 else 393 echo "*** Could not run Allegro test program, checking why..." 394 CFLAGS="$CFLAGS $ALLEGRO_CFLAGS" 395 LIBS="$LIBS $ALLEGRO_LIBS" 396 AC_TRY_LINK([ 397#include <stdio.h> 398#include "ALLEGRO.h" 399 400int main(int argc, char *argv[]) 401{ return 0; } 402 403END_OF_MAIN(); 404 405#undef main 406#define main K_and_R_C_main 407], [ return 0; ], 408 [ echo "*** The test program compiled, but did not run. This usually means" 409 echo "*** that the run-time linker is not finding Allegro or finding the wrong" 410 echo "*** version of Allegro. If it is not finding Allegro, you'll need to set your" 411 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 412 echo "*** to the installed location Also, make sure you have run ldconfig if that" 413 echo "*** is required on your system" 414 echo "***" 415 echo "*** If you have an old version installed, it is best to remove it, although" 416 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 417 [ echo "*** The test program failed to compile or link. See the file config.log for the" 418 echo "*** exact error that occured. This usually means Allegro was incorrectly installed" 419 echo "*** or that you have moved Allegro since it was installed. In the latter case, you" 420 echo "*** may want to edit the allegro-config script: $ALLEGRO_CONFIG" ]) 421 CFLAGS="$ac_save_CFLAGS" 422 LIBS="$ac_save_LIBS" 423 fi 424 fi 425 ALLEGRO_CFLAGS="" 426 ALLEGRO_LIBS="" 427 ifelse([$3], , :, [$3]) 428 fi 429 AC_SUBST(ALLEGRO_CFLAGS) 430 AC_SUBST(ALLEGRO_LIBS) 431 rm -f conf.allegrotest 432]) 433