Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2991 in orxonox.OLD for orxonox/trunk/aclocal.m4


Ignore:
Timestamp:
Nov 26, 2004, 12:07:17 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: better configure, just works better on less configured systems like win32

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/aclocal.m4

    r2980 r2991  
    6969
    7070
    71 
    72 # Configure paths for SDL
    73 # Sam Lantinga 9/21/99
    74 # stolen from Manish Singh
    75 # stolen back from Frank Belew
    76 # stolen from Manish Singh
    77 # Shamelessly stolen from Owen Taylor
    78 
    79 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
    80 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
    81 dnl
    82 AC_DEFUN([AM_PATH_SDL],
    83 [dnl
    84 dnl Get the cflags and libraries from the sdl-config script
    85 dnl
    86 AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)],
    87             sdl_prefix="$withval", sdl_prefix="")
    88 AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
    89             sdl_exec_prefix="$withval", sdl_exec_prefix="")
    90 AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
    91                     , enable_sdltest=yes)
    92 
    93   if test x$sdl_exec_prefix != x ; then
    94      sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
    95      if test x${SDL_CONFIG+set} != xset ; then
    96         SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
    97      fi
    98   fi
    99   if test x$sdl_prefix != x ; then
    100      sdl_args="$sdl_args --prefix=$sdl_prefix"
    101      if test x${SDL_CONFIG+set} != xset ; then
    102         SDL_CONFIG=$sdl_prefix/bin/sdl-config
    103      fi
    104   fi
    105 
    106   AC_REQUIRE([AC_CANONICAL_TARGET])
    107   PATH="$prefix/bin:$prefix/usr/bin:$PATH"
    108   AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
    109   min_sdl_version=ifelse([$1], ,0.11.0,$1)
    110   AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
    111   no_sdl=""
    112   if test "$SDL_CONFIG" = "no" ; then
    113     no_sdl=yes
    114   else
    115     SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
    116     SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
    117 
    118     sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
    119            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
    120     sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
    121            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
    122     sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
    123            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
    124     if test "x$enable_sdltest" = "xyes" ; then
    125       ac_save_CFLAGS="$CFLAGS"
    126       ac_save_LIBS="$LIBS"
    127       CFLAGS="$CFLAGS $SDL_CFLAGS"
    128       LIBS="$LIBS $SDL_LIBS"
    129 dnl
    130 dnl Now check if the installed SDL is sufficiently new. (Also sanity
    131 dnl checks the results of sdl-config to some extent
    132 dnl
    133       rm -f conf.sdltest
    134       AC_TRY_RUN([
    135 #include <stdio.h>
    136 #include <stdlib.h>
    137 #include <string.h>
    138 #include "SDL.h"
    139 
    140 char*
    141 my_strdup (char *str)
    142 {
    143   char *new_str;
    144  
    145   if (str)
    146     {
    147       new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
    148       strcpy (new_str, str);
    149     }
    150   else
    151     new_str = NULL;
    152  
    153   return new_str;
    154 }
    155 
    156 int main (int argc, char *argv[])
    157 {
    158   int major, minor, micro;
    159   char *tmp_version;
    160 
    161   /* This hangs on some systems (?)
    162   system ("touch conf.sdltest");
    163   */
    164   { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
    165 
    166   /* HP/UX 9 (%@#!) writes to sscanf strings */
    167   tmp_version = my_strdup("$min_sdl_version");
    168   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
    169      printf("%s, bad version string\n", "$min_sdl_version");
    170      exit(1);
    171    }
    172 
    173    if (($sdl_major_version > major) ||
    174       (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
    175       (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
    176     {
    177       return 0;
    178     }
    179   else
    180     {
    181       printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
    182       printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
    183       printf("*** best to upgrade to the required version.\n");
    184       printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
    185       printf("*** to point to the correct copy of sdl-config, and remove the file\n");
    186       printf("*** config.cache before re-running configure\n");
    187       return 1;
    188     }
    189 }
    190 
    191 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
    192        CFLAGS="$ac_save_CFLAGS"
    193        LIBS="$ac_save_LIBS"
    194      fi
    195   fi
    196   if test "x$no_sdl" = x ; then
    197      AC_MSG_RESULT(yes)
    198      ifelse([$2], , :, [$2])     
    199   else
    200      AC_MSG_RESULT(no)
    201      if test "$SDL_CONFIG" = "no" ; then
    202        echo "*** The sdl-config script installed by SDL could not be found"
    203        echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
    204        echo "*** your path, or set the SDL_CONFIG environment variable to the"
    205        echo "*** full path to sdl-config."
    206      else
    207        if test -f conf.sdltest ; then
    208         :
    209        else
    210           echo "*** Could not run SDL test program, checking why..."
    211           CFLAGS="$CFLAGS $SDL_CFLAGS"
    212           LIBS="$LIBS $SDL_LIBS"
    213           AC_TRY_LINK([
    214 #include <stdio.h>
    215 #include "SDL.h"
    216 
    217 int main(int argc, char *argv[])
    218 { return 0; }
    219 #undef  main
    220 #define main K_and_R_C_main
    221 ],      [ return 0; ],
    222         [ echo "*** The test program compiled, but did not run. This usually means"
    223           echo "*** that the run-time linker is not finding SDL or finding the wrong"
    224           echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
    225           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
    226           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
    227           echo "*** is required on your system"
    228           echo "***"
    229           echo "*** If you have an old version installed, it is best to remove it, although"
    230           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
    231         [ echo "*** The test program failed to compile or link. See the file config.log for the"
    232           echo "*** exact error that occured. This usually means SDL was incorrectly installed"
    233           echo "*** or that you have moved SDL since it was installed. In the latter case, you"
    234           echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
    235           CFLAGS="$ac_save_CFLAGS"
    236           LIBS="$ac_save_LIBS"
    237        fi
    238      fi
    239      SDL_CFLAGS=""
    240      SDL_LIBS=""
    241      ifelse([$3], , :, [$3])
    242   fi
    243   AC_SUBST(SDL_CFLAGS)
    244   AC_SUBST(SDL_LIBS)
    245   rm -f conf.sdltest
    246 ])
    24771
    24872#                                                        -*- Autoconf -*-
Note: See TracChangeset for help on using the changeset viewer.