diff options
Diffstat (limited to 'acinclude.m4')
| -rw-r--r-- | acinclude.m4 | 129 |
1 files changed, 73 insertions, 56 deletions
| diff --git a/acinclude.m4 b/acinclude.m4 index 0d44c45..a03b2d2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 | |||
| @@ -7,12 +7,12 @@ | |||
| 7 | 7 | ||
| 8 | # serial 1 | 8 | # serial 1 |
| 9 | 9 | ||
| 10 | dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | 10 | 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 | 11 | dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS |
| 12 | dnl | 12 | dnl |
| 13 | AC_DEFUN([AM_PATH_SDL], | 13 | AC_DEFUN([AM_PATH_SDL2], |
| 14 | [dnl | 14 | [dnl |
| 15 | dnl Get the cflags and libraries from the sdl-config script | 15 | dnl Get the cflags and libraries from the sdl2-config script |
| 16 | dnl | 16 | dnl |
| 17 | AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], | 17 | AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], |
| 18 | sdl_prefix="$withval", sdl_prefix="") | 18 | sdl_prefix="$withval", sdl_prefix="") |
| @@ -21,50 +21,63 @@ AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL | |||
| 21 | AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], | 21 | AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], |
| 22 | , enable_sdltest=yes) | 22 | , enable_sdltest=yes) |
| 23 | 23 | ||
| 24 | if test x$sdl_exec_prefix != x ; then | 24 | min_sdl_version=ifelse([$1], ,2.0.0,$1) |
| 25 | sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" | 25 | |
| 26 | if test x${SDL_CONFIG+set} != xset ; then | 26 | if test "x$sdl_prefix$sdl_exec_prefix" = x ; then |
| 27 | SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config | 27 | PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version], |
| 28 | [sdl_pc=yes], | ||
| 29 | [sdl_pc=no]) | ||
| 30 | else | ||
| 31 | sdl_pc=no | ||
| 32 | if test x$sdl_exec_prefix != x ; then | ||
| 33 | sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" | ||
| 34 | if test x${SDL2_CONFIG+set} != xset ; then | ||
| 35 | SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config | ||
| 36 | fi | ||
| 28 | fi | 37 | fi |
| 29 | fi | 38 | if test x$sdl_prefix != x ; then |
| 30 | if test x$sdl_prefix != x ; then | 39 | sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" |
| 31 | sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" | 40 | if test x${SDL2_CONFIG+set} != xset ; then |
| 32 | if test x${SDL_CONFIG+set} != xset ; then | 41 | SDL2_CONFIG=$sdl_prefix/bin/sdl2-config |
| 33 | SDL_CONFIG=$sdl_prefix/bin/sdl-config | 42 | fi |
| 34 | fi | 43 | fi |
| 35 | fi | 44 | fi |
| 36 | 45 | ||
| 37 | as_save_PATH="$PATH" | 46 | if test "x$sdl_pc" = xyes ; then |
| 38 | if test "x$prefix" != xNONE; then | 47 | no_sdl="" |
| 39 | PATH="$prefix/bin:$prefix/usr/bin:$PATH" | 48 | SDL2_CONFIG="pkg-config sdl2" |
| 40 | fi | ||
| 41 | AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) | ||
| 42 | PATH="$as_save_PATH" | ||
| 43 | min_sdl_version=ifelse([$1], ,0.11.0,$1) | ||
| 44 | AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) | ||
| 45 | no_sdl="" | ||
| 46 | if test "$SDL_CONFIG" = "no" ; then | ||
| 47 | no_sdl=yes | ||
| 48 | else | 49 | else |
| 49 | SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags` | 50 | as_save_PATH="$PATH" |
| 50 | SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs` | 51 | if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then |
| 52 | PATH="$prefix/bin:$prefix/usr/bin:$PATH" | ||
| 53 | fi | ||
| 54 | AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH]) | ||
| 55 | PATH="$as_save_PATH" | ||
| 56 | AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) | ||
| 57 | no_sdl="" | ||
| 51 | 58 | ||
| 52 | sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \ | 59 | if test "$SDL2_CONFIG" = "no" ; then |
| 53 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` | 60 | no_sdl=yes |
| 54 | sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \ | 61 | else |
| 55 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` | 62 | SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags` |
| 56 | sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ | 63 | SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs` |
| 57 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` | 64 | |
| 58 | if test "x$enable_sdltest" = "xyes" ; then | 65 | sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \ |
| 59 | ac_save_CFLAGS="$CFLAGS" | 66 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
| 60 | ac_save_CXXFLAGS="$CXXFLAGS" | 67 | sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \ |
| 61 | ac_save_LIBS="$LIBS" | 68 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
| 62 | CFLAGS="$CFLAGS $SDL_CFLAGS" | 69 | sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \ |
| 63 | CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" | 70 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
| 64 | LIBS="$LIBS $SDL_LIBS" | 71 | if test "x$enable_sdltest" = "xyes" ; then |
| 72 | ac_save_CFLAGS="$CFLAGS" | ||
| 73 | ac_save_CXXFLAGS="$CXXFLAGS" | ||
| 74 | ac_save_LIBS="$LIBS" | ||
| 75 | CFLAGS="$CFLAGS $SDL_CFLAGS" | ||
| 76 | CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" | ||
| 77 | LIBS="$LIBS $SDL_LIBS" | ||
| 65 | dnl | 78 | dnl |
| 66 | dnl Now check if the installed SDL is sufficiently new. (Also sanity | 79 | dnl Now check if the installed SDL is sufficiently new. (Also sanity |
| 67 | dnl checks the results of sdl-config to some extent | 80 | dnl checks the results of sdl2-config to some extent |
| 68 | dnl | 81 | dnl |
| 69 | rm -f conf.sdltest | 82 | rm -f conf.sdltest |
| 70 | AC_TRY_RUN([ | 83 | AC_TRY_RUN([ |
| @@ -114,32 +127,36 @@ int main (int argc, char *argv[]) | |||
| 114 | } | 127 | } |
| 115 | else | 128 | else |
| 116 | { | 129 | { |
| 117 | printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); | 130 | printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); |
| 118 | printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); | 131 | printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro); |
| 119 | printf("*** best to upgrade to the required version.\n"); | 132 | printf("*** best to upgrade to the required version.\n"); |
| 120 | printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); | 133 | printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n"); |
| 121 | printf("*** to point to the correct copy of sdl-config, and remove the file\n"); | 134 | printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); |
| 122 | printf("*** config.cache before re-running configure\n"); | 135 | printf("*** config.cache before re-running configure\n"); |
| 123 | return 1; | 136 | return 1; |
| 124 | } | 137 | } |
| 125 | } | 138 | } |
| 126 | 139 | ||
| 127 | ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) | 140 | ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
| 128 | CFLAGS="$ac_save_CFLAGS" | 141 | CFLAGS="$ac_save_CFLAGS" |
| 129 | CXXFLAGS="$ac_save_CXXFLAGS" | 142 | CXXFLAGS="$ac_save_CXXFLAGS" |
| 130 | LIBS="$ac_save_LIBS" | 143 | LIBS="$ac_save_LIBS" |
| 131 | fi | 144 | fi |
| 145 | fi | ||
| 146 | if test "x$no_sdl" = x ; then | ||
| 147 | AC_MSG_RESULT(yes) | ||
| 148 | else | ||
| 149 | AC_MSG_RESULT(no) | ||
| 150 | fi | ||
| 132 | fi | 151 | fi |
| 133 | if test "x$no_sdl" = x ; then | 152 | if test "x$no_sdl" = x ; then |
| 134 | AC_MSG_RESULT(yes) | 153 | ifelse([$2], , :, [$2]) |
| 135 | ifelse([$2], , :, [$2]) | ||
| 136 | else | 154 | else |
| 137 | AC_MSG_RESULT(no) | 155 | if test "$SDL2_CONFIG" = "no" ; then |
| 138 | if test "$SDL_CONFIG" = "no" ; then | 156 | echo "*** The sdl2-config script installed by SDL could not be found" |
| 139 | echo "*** The sdl-config script installed by SDL could not be found" | ||
| 140 | echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" | 157 | echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" |
| 141 | echo "*** your path, or set the SDL_CONFIG environment variable to the" | 158 | echo "*** your path, or set the SDL2_CONFIG environment variable to the" |
| 142 | echo "*** full path to sdl-config." | 159 | echo "*** full path to sdl2-config." |
| 143 | else | 160 | else |
| 144 | if test -f conf.sdltest ; then | 161 | if test -f conf.sdltest ; then |
| 145 | : | 162 | : |
| @@ -169,7 +186,7 @@ int main(int argc, char *argv[]) | |||
| 169 | [ echo "*** The test program failed to compile or link. See the file config.log for the" | 186 | [ echo "*** The test program failed to compile or link. See the file config.log for the" |
| 170 | echo "*** exact error that occured. This usually means SDL was incorrectly installed" | 187 | echo "*** exact error that occured. This usually means SDL was incorrectly installed" |
| 171 | echo "*** or that you have moved SDL since it was installed. In the latter case, you" | 188 | echo "*** or that you have moved SDL since it was installed. In the latter case, you" |
| 172 | echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) | 189 | echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ]) |
| 173 | CFLAGS="$ac_save_CFLAGS" | 190 | CFLAGS="$ac_save_CFLAGS" |
| 174 | CXXFLAGS="$ac_save_CXXFLAGS" | 191 | CXXFLAGS="$ac_save_CXXFLAGS" |
| 175 | LIBS="$ac_save_LIBS" | 192 | LIBS="$ac_save_LIBS" |
| @@ -182,4 +199,4 @@ int main(int argc, char *argv[]) | |||
| 182 | AC_SUBST(SDL_CFLAGS) | 199 | AC_SUBST(SDL_CFLAGS) |
| 183 | AC_SUBST(SDL_LIBS) | 200 | AC_SUBST(SDL_LIBS) |
| 184 | rm -f conf.sdltest | 201 | rm -f conf.sdltest |
| 185 | ]) \ No newline at end of file | 202 | ]) |
