sdl2.m4
changeset 10382 9befd0acb9ef
parent 7492 98de3e4f1c36
child 12647 fa75f0fb9e96
equal deleted inserted replaced
10381:6f77a03fb8cd 10382:9befd0acb9ef
     2 # Sam Lantinga 9/21/99
     2 # Sam Lantinga 9/21/99
     3 # stolen from Manish Singh
     3 # stolen from Manish Singh
     4 # stolen back from Frank Belew
     4 # stolen back from Frank Belew
     5 # stolen from Manish Singh
     5 # stolen from Manish Singh
     6 # Shamelessly stolen from Owen Taylor
     6 # Shamelessly stolen from Owen Taylor
       
     7 #
       
     8 # Changelog:
       
     9 # * also look for SDL2.framework under Mac OS X
     7 
    10 
     8 # serial 1
    11 # serial 1
     9 
    12 
    10 dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
    13 dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
    11 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
    14 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
    18             sdl_prefix="$withval", sdl_prefix="")
    21             sdl_prefix="$withval", sdl_prefix="")
    19 AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
    22 AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
    20             sdl_exec_prefix="$withval", sdl_exec_prefix="")
    23             sdl_exec_prefix="$withval", sdl_exec_prefix="")
    21 AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
    24 AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
    22 		    , enable_sdltest=yes)
    25 		    , enable_sdltest=yes)
       
    26 AC_ARG_ENABLE(sdlframework, [  --disable-sdlframework Do not search for SDL2.framework],
       
    27         , search_sdl_framework=yes)
       
    28 
       
    29 AC_ARG_VAR(SDL2_FRAMEWORK, [Path to SDL2.framework])
    23 
    30 
    24   min_sdl_version=ifelse([$1], ,2.0.0,$1)
    31   min_sdl_version=ifelse([$1], ,2.0.0,$1)
    25 
    32 
    26   if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
    33   if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
    27     PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version],
    34     PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version],
    51     if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then
    58     if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then
    52       PATH="$prefix/bin:$prefix/usr/bin:$PATH"
    59       PATH="$prefix/bin:$prefix/usr/bin:$PATH"
    53     fi
    60     fi
    54     AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH])
    61     AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH])
    55     PATH="$as_save_PATH"
    62     PATH="$as_save_PATH"
    56     AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
       
    57     no_sdl=""
    63     no_sdl=""
    58 
    64 
    59     if test "$SDL2_CONFIG" = "no" ; then
    65     if test "$SDL2_CONFIG" = "no" -a "x$search_sdl_framework" = "xyes"; then
    60       no_sdl=yes
    66       AC_MSG_CHECKING(for SDL2.framework)
    61     else
    67       if test "x$SDL2_FRAMEWORK" != x; then
    62       SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags`
    68         sdl_framework=$SDL2_FRAMEWORK
    63       SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs`
    69       else
       
    70         for d in / ~/ /System/; do
       
    71           if test -d "$dLibrary/Frameworks/SDL2.framework"; then
       
    72             sdl_framework="$dLibrary/Frameworks/SDL2.framework"
       
    73           fi
       
    74         done
       
    75       fi
       
    76 
       
    77       if test -d $sdl_framework; then
       
    78         AC_MSG_RESULT($sdl_framework)
       
    79         sdl_framework_dir=`dirname $sdl_framework`
       
    80         SDL_CFLAGS="-F$sdl_framework_dir -Wl,-framework,SDL2 -I$sdl_framework/include"
       
    81         SDL_LIBS="-F$sdl_framework_dir -Wl,-framework,SDL2"
       
    82       else
       
    83         no_sdl=yes
       
    84       fi
       
    85     fi
       
    86 
       
    87     if test "$SDL2_CONFIG" != "no"; then
       
    88       if test "x$sdl_pc" = "xno"; then
       
    89         AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
       
    90         SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags`
       
    91         SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs`
       
    92       fi
    64 
    93 
    65       sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \
    94       sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \
    66              sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
    95              sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
    67       sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \
    96       sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \
    68              sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
    97              sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
   139 
   168 
   140 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
   169 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
   141         CFLAGS="$ac_save_CFLAGS"
   170         CFLAGS="$ac_save_CFLAGS"
   142         CXXFLAGS="$ac_save_CXXFLAGS"
   171         CXXFLAGS="$ac_save_CXXFLAGS"
   143         LIBS="$ac_save_LIBS"
   172         LIBS="$ac_save_LIBS"
   144       fi
   173 
   145     fi
   174       fi
   146     if test "x$no_sdl" = x ; then
   175       if test "x$sdl_pc" = "xno"; then
   147       AC_MSG_RESULT(yes)
   176         if test "x$no_sdl" = "xyes"; then
   148     else
   177           AC_MSG_RESULT(no)
   149       AC_MSG_RESULT(no)
   178         else
       
   179           AC_MSG_RESULT(yes)
       
   180         fi
       
   181       fi
   150     fi
   182     fi
   151   fi
   183   fi
   152   if test "x$no_sdl" = x ; then
   184   if test "x$no_sdl" = x ; then
   153      ifelse([$2], , :, [$2])
   185      ifelse([$2], , :, [$2])
   154   else
   186   else