🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

234 lines
7.9 KiB

  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. #
  8. # Changelog:
  9. # * also look for SDL2.framework under Mac OS X
  10. # serial 1
  11. dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  12. dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
  13. dnl
  14. AC_DEFUN([AM_PATH_SDL2],
  15. [dnl
  16. dnl Get the cflags and libraries from the sdl2-config script
  17. dnl
  18. AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
  19. sdl_prefix="$withval", sdl_prefix="")
  20. AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
  21. sdl_exec_prefix="$withval", sdl_exec_prefix="")
  22. AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
  23. , enable_sdltest=yes)
  24. AC_ARG_ENABLE(sdlframework, [ --disable-sdlframework Do not search for SDL2.framework],
  25. , search_sdl_framework=yes)
  26. AC_ARG_VAR(SDL2_FRAMEWORK, [Path to SDL2.framework])
  27. min_sdl_version=ifelse([$1], ,2.0.0,$1)
  28. if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
  29. PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version],
  30. [sdl_pc=yes],
  31. [sdl_pc=no])
  32. else
  33. sdl_pc=no
  34. if test x$sdl_exec_prefix != x ; then
  35. sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
  36. if test x${SDL2_CONFIG+set} != xset ; then
  37. SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config
  38. fi
  39. fi
  40. if test x$sdl_prefix != x ; then
  41. sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
  42. if test x${SDL2_CONFIG+set} != xset ; then
  43. SDL2_CONFIG=$sdl_prefix/bin/sdl2-config
  44. fi
  45. fi
  46. fi
  47. if test "x$sdl_pc" = xyes ; then
  48. no_sdl=""
  49. SDL2_CONFIG="pkg-config sdl2"
  50. else
  51. as_save_PATH="$PATH"
  52. if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then
  53. PATH="$prefix/bin:$prefix/usr/bin:$PATH"
  54. fi
  55. AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH])
  56. PATH="$as_save_PATH"
  57. no_sdl=""
  58. if test "$SDL2_CONFIG" = "no" -a "x$search_sdl_framework" = "xyes"; then
  59. AC_MSG_CHECKING(for SDL2.framework)
  60. if test "x$SDL2_FRAMEWORK" != x; then
  61. sdl_framework=$SDL2_FRAMEWORK
  62. else
  63. for d in / ~/ /System/; do
  64. if test -d "$dLibrary/Frameworks/SDL2.framework"; then
  65. sdl_framework="$dLibrary/Frameworks/SDL2.framework"
  66. fi
  67. done
  68. fi
  69. if test x"$sdl_framework" != x && test -d "$sdl_framework"; then
  70. AC_MSG_RESULT($sdl_framework)
  71. sdl_framework_dir=`dirname $sdl_framework`
  72. SDL_CFLAGS="-F$sdl_framework_dir -Wl,-framework,SDL2 -I$sdl_framework/include"
  73. SDL_LIBS="-F$sdl_framework_dir -Wl,-framework,SDL2"
  74. else
  75. no_sdl=yes
  76. fi
  77. fi
  78. if test "$SDL2_CONFIG" != "no"; then
  79. if test "x$sdl_pc" = "xno"; then
  80. AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
  81. SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags`
  82. SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs`
  83. fi
  84. sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \
  85. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  86. sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \
  87. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  88. sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \
  89. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  90. if test "x$enable_sdltest" = "xyes" ; then
  91. ac_save_CFLAGS="$CFLAGS"
  92. ac_save_CXXFLAGS="$CXXFLAGS"
  93. ac_save_LIBS="$LIBS"
  94. CFLAGS="$CFLAGS $SDL_CFLAGS"
  95. CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
  96. LIBS="$LIBS $SDL_LIBS"
  97. dnl
  98. dnl Now check if the installed SDL is sufficiently new. (Also sanity
  99. dnl checks the results of sdl2-config to some extent
  100. dnl
  101. rm -f conf.sdltest
  102. AC_TRY_RUN([
  103. #include <stdio.h>
  104. #include <stdlib.h>
  105. #include <string.h>
  106. #include "SDL.h"
  107. char*
  108. my_strdup (char *str)
  109. {
  110. char *new_str;
  111. if (str)
  112. {
  113. new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
  114. strcpy (new_str, str);
  115. }
  116. else
  117. new_str = NULL;
  118. return new_str;
  119. }
  120. int main (int argc, char *argv[])
  121. {
  122. int major, minor, micro;
  123. char *tmp_version;
  124. /* This hangs on some systems (?)
  125. system ("touch conf.sdltest");
  126. */
  127. { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
  128. /* HP/UX 9 (%@#!) writes to sscanf strings */
  129. tmp_version = my_strdup("$min_sdl_version");
  130. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  131. printf("%s, bad version string\n", "$min_sdl_version");
  132. exit(1);
  133. }
  134. if (($sdl_major_version > major) ||
  135. (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
  136. (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
  137. {
  138. return 0;
  139. }
  140. else
  141. {
  142. printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
  143. printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro);
  144. printf("*** best to upgrade to the required version.\n");
  145. printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n");
  146. printf("*** to point to the correct copy of sdl2-config, and remove the file\n");
  147. printf("*** config.cache before re-running configure\n");
  148. return 1;
  149. }
  150. }
  151. ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  152. CFLAGS="$ac_save_CFLAGS"
  153. CXXFLAGS="$ac_save_CXXFLAGS"
  154. LIBS="$ac_save_LIBS"
  155. fi
  156. if test "x$sdl_pc" = "xno"; then
  157. if test "x$no_sdl" = "xyes"; then
  158. AC_MSG_RESULT(no)
  159. else
  160. AC_MSG_RESULT(yes)
  161. fi
  162. fi
  163. fi
  164. fi
  165. if test "x$no_sdl" = x ; then
  166. ifelse([$2], , :, [$2])
  167. else
  168. if test "$SDL2_CONFIG" = "no" ; then
  169. echo "*** The sdl2-config script installed by SDL could not be found"
  170. echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
  171. echo "*** your path, or set the SDL2_CONFIG environment variable to the"
  172. echo "*** full path to sdl2-config."
  173. else
  174. if test -f conf.sdltest ; then
  175. :
  176. else
  177. echo "*** Could not run SDL test program, checking why..."
  178. CFLAGS="$CFLAGS $SDL_CFLAGS"
  179. CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
  180. LIBS="$LIBS $SDL_LIBS"
  181. AC_TRY_LINK([
  182. #include <stdio.h>
  183. #include "SDL.h"
  184. int main(int argc, char *argv[])
  185. { return 0; }
  186. #undef main
  187. #define main K_and_R_C_main
  188. ], [ return 0; ],
  189. [ echo "*** The test program compiled, but did not run. This usually means"
  190. echo "*** that the run-time linker is not finding SDL or finding the wrong"
  191. echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
  192. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  193. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  194. echo "*** is required on your system"
  195. echo "***"
  196. echo "*** If you have an old version installed, it is best to remove it, although"
  197. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  198. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  199. echo "*** exact error that occured. This usually means SDL was incorrectly installed"
  200. echo "*** or that you have moved SDL since it was installed. In the latter case, you"
  201. echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ])
  202. CFLAGS="$ac_save_CFLAGS"
  203. CXXFLAGS="$ac_save_CXXFLAGS"
  204. LIBS="$ac_save_LIBS"
  205. fi
  206. fi
  207. SDL_CFLAGS=""
  208. SDL_LIBS=""
  209. ifelse([$3], , :, [$3])
  210. fi
  211. AC_SUBST(SDL_CFLAGS)
  212. AC_SUBST(SDL_LIBS)
  213. rm -f conf.sdltest
  214. ])