🛠️🐜 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.

337 lines
12 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. # serial 2
  8. dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  9. dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
  10. dnl
  11. AC_DEFUN([AM_PATH_SDL2],
  12. [dnl
  13. dnl Get the cflags and libraries from the sdl2-config script
  14. dnl
  15. AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
  16. sdl_prefix="$withval", sdl_prefix="")
  17. AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
  18. sdl_exec_prefix="$withval", sdl_exec_prefix="")
  19. AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
  20. , enable_sdltest=yes)
  21. min_sdl_version=ifelse([$1], ,2.0.0,$1)
  22. if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
  23. PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version],
  24. [sdl_pc=yes],
  25. [sdl_pc=no])
  26. else
  27. sdl_pc=no
  28. if test x$sdl_exec_prefix != x ; then
  29. sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
  30. if test x${SDL2_CONFIG+set} != xset ; then
  31. SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config
  32. fi
  33. fi
  34. if test x$sdl_prefix != x ; then
  35. sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
  36. if test x${SDL2_CONFIG+set} != xset ; then
  37. SDL2_CONFIG=$sdl_prefix/bin/sdl2-config
  38. fi
  39. fi
  40. fi
  41. if test "x$sdl_pc" = xyes ; then
  42. no_sdl=""
  43. SDL2_CONFIG="pkg-config sdl2"
  44. else
  45. as_save_PATH="$PATH"
  46. if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then
  47. PATH="$prefix/bin:$prefix/usr/bin:$PATH"
  48. fi
  49. AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH])
  50. PATH="$as_save_PATH"
  51. AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
  52. no_sdl=""
  53. if test "$SDL2_CONFIG" = "no" ; then
  54. no_sdl=yes
  55. else
  56. SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags`
  57. SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs`
  58. sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \
  59. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  60. sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \
  61. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  62. sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \
  63. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  64. if test "x$enable_sdltest" = "xyes" ; then
  65. ac_save_CFLAGS="$CFLAGS"
  66. ac_save_CXXFLAGS="$CXXFLAGS"
  67. ac_save_LIBS="$LIBS"
  68. CFLAGS="$CFLAGS $SDL_CFLAGS"
  69. CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
  70. LIBS="$LIBS $SDL_LIBS"
  71. dnl
  72. dnl Now check if the installed SDL is sufficiently new. (Also sanity
  73. dnl checks the results of sdl2-config to some extent
  74. dnl
  75. rm -f conf.sdltest
  76. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  77. #include <stdio.h>
  78. #include <stdlib.h>
  79. #include "SDL.h"
  80. int main (int argc, char *argv[])
  81. {
  82. int major, minor, micro;
  83. FILE *fp = fopen("conf.sdltest", "w");
  84. if (fp) fclose(fp);
  85. if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, &micro) != 3) {
  86. printf("%s, bad version string\n", "$min_sdl_version");
  87. exit(1);
  88. }
  89. if (($sdl_major_version > major) ||
  90. (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
  91. (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
  92. {
  93. return 0;
  94. }
  95. else
  96. {
  97. printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
  98. printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro);
  99. printf("*** best to upgrade to the required version.\n");
  100. printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n");
  101. printf("*** to point to the correct copy of sdl2-config, and remove the file\n");
  102. printf("*** config.cache before re-running configure\n");
  103. return 1;
  104. }
  105. }
  106. ]])], [], [no_sdl=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"])
  107. CFLAGS="$ac_save_CFLAGS"
  108. CXXFLAGS="$ac_save_CXXFLAGS"
  109. LIBS="$ac_save_LIBS"
  110. fi
  111. fi
  112. if test "x$no_sdl" = x ; then
  113. AC_MSG_RESULT(yes)
  114. else
  115. AC_MSG_RESULT(no)
  116. fi
  117. fi
  118. if test "x$no_sdl" = x ; then
  119. ifelse([$2], , :, [$2])
  120. else
  121. if test "$SDL2_CONFIG" = "no" ; then
  122. echo "*** The sdl2-config script installed by SDL could not be found"
  123. echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
  124. echo "*** your path, or set the SDL2_CONFIG environment variable to the"
  125. echo "*** full path to sdl2-config."
  126. else
  127. if test -f conf.sdltest ; then
  128. :
  129. else
  130. echo "*** Could not run SDL test program, checking why..."
  131. CFLAGS="$CFLAGS $SDL_CFLAGS"
  132. CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
  133. LIBS="$LIBS $SDL_LIBS"
  134. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  135. #include <stdio.h>
  136. #include "SDL.h"
  137. int main(int argc, char *argv[])
  138. { return 0; }
  139. #undef main
  140. #define main K_and_R_C_main
  141. ]], [[ return 0; ]])],
  142. [ echo "*** The test program compiled, but did not run. This usually means"
  143. echo "*** that the run-time linker is not finding SDL or finding the wrong"
  144. echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
  145. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  146. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  147. echo "*** is required on your system"
  148. echo "***"
  149. echo "*** If you have an old version installed, it is best to remove it, although"
  150. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  151. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  152. echo "*** exact error that occured. This usually means SDL was incorrectly installed"
  153. echo "*** or that you have moved SDL since it was installed. In the latter case, you"
  154. echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ])
  155. CFLAGS="$ac_save_CFLAGS"
  156. CXXFLAGS="$ac_save_CXXFLAGS"
  157. LIBS="$ac_save_LIBS"
  158. fi
  159. fi
  160. SDL_CFLAGS=""
  161. SDL_LIBS=""
  162. ifelse([$3], , :, [$3])
  163. fi
  164. AC_SUBST(SDL_CFLAGS)
  165. AC_SUBST(SDL_LIBS)
  166. rm -f conf.sdltest
  167. ])
  168. # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
  169. # serial 1 (pkg-config-0.24)
  170. #
  171. # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
  172. #
  173. # This program is free software; you can redistribute it and/or modify
  174. # it under the terms of the GNU General Public License as published by
  175. # the Free Software Foundation; either version 2 of the License, or
  176. # (at your option) any later version.
  177. #
  178. # This program is distributed in the hope that it will be useful, but
  179. # WITHOUT ANY WARRANTY; without even the implied warranty of
  180. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  181. # General Public License for more details.
  182. #
  183. # You should have received a copy of the GNU General Public License
  184. # along with this program; if not, write to the Free Software
  185. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  186. #
  187. # As a special exception to the GNU General Public License, if you
  188. # distribute this file as part of a program that contains a
  189. # configuration script generated by Autoconf, you may include it under
  190. # the same distribution terms that you use for the rest of that program.
  191. # PKG_PROG_PKG_CONFIG([MIN-VERSION])
  192. # ----------------------------------
  193. AC_DEFUN([PKG_PROG_PKG_CONFIG],
  194. [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
  195. m4_pattern_allow([^PKG_CONFIG(_PATH|_LIBDIR)?$])
  196. AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
  197. AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
  198. AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
  199. if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
  200. AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
  201. fi
  202. if test -n "$PKG_CONFIG"; then
  203. _pkg_min_version=m4_default([$1], [0.9.0])
  204. AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
  205. if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
  206. AC_MSG_RESULT([yes])
  207. else
  208. AC_MSG_RESULT([no])
  209. PKG_CONFIG=""
  210. fi
  211. fi[]dnl
  212. ])# PKG_PROG_PKG_CONFIG
  213. # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  214. #
  215. # Check to see whether a particular set of modules exists. Similar
  216. # to PKG_CHECK_MODULES(), but does not set variables or print errors.
  217. #
  218. # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  219. # only at the first occurence in configure.ac, so if the first place
  220. # it's called might be skipped (such as if it is within an "if", you
  221. # have to call PKG_CHECK_EXISTS manually
  222. # --------------------------------------------------------------
  223. AC_DEFUN([PKG_CHECK_EXISTS],
  224. [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
  225. if test -n "$PKG_CONFIG" && \
  226. AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
  227. m4_default([$2], [:])
  228. m4_ifvaln([$3], [else
  229. $3])dnl
  230. fi])
  231. # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
  232. # ---------------------------------------------
  233. m4_define([_PKG_CONFIG],
  234. [if test -n "$$1"; then
  235. pkg_cv_[]$1="$$1"
  236. elif test -n "$PKG_CONFIG"; then
  237. PKG_CHECK_EXISTS([$3],
  238. [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
  239. [pkg_failed=yes])
  240. else
  241. pkg_failed=untried
  242. fi[]dnl
  243. ])# _PKG_CONFIG
  244. # _PKG_SHORT_ERRORS_SUPPORTED
  245. # -----------------------------
  246. AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
  247. [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  248. if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
  249. _pkg_short_errors_supported=yes
  250. else
  251. _pkg_short_errors_supported=no
  252. fi[]dnl
  253. ])# _PKG_SHORT_ERRORS_SUPPORTED
  254. # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
  255. # [ACTION-IF-NOT-FOUND])
  256. #
  257. #
  258. # Note that if there is a possibility the first call to
  259. # PKG_CHECK_MODULES might not happen, you should be sure to include an
  260. # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
  261. #
  262. #
  263. # --------------------------------------------------------------
  264. AC_DEFUN([PKG_CHECK_MODULES],
  265. [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
  266. AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
  267. AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
  268. pkg_failed=no
  269. AC_MSG_CHECKING([for $2])
  270. _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
  271. _PKG_CONFIG([$1][_LIBS], [libs], [$2])
  272. m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
  273. and $1[]_LIBS to avoid the need to call pkg-config.
  274. See the pkg-config man page for more details.])
  275. if test $pkg_failed = yes; then
  276. AC_MSG_RESULT([no])
  277. _PKG_SHORT_ERRORS_SUPPORTED
  278. if test $_pkg_short_errors_supported = yes; then
  279. $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
  280. else
  281. $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
  282. fi
  283. # Put the nasty error message in config.log where it belongs
  284. echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
  285. m4_default([$4], [AC_MSG_ERROR(
  286. [Package requirements ($2) were not met:
  287. $$1_PKG_ERRORS
  288. Consider adjusting the PKG_CONFIG_PATH environment variable if you
  289. installed software in a non-standard prefix.
  290. _PKG_TEXT])[]dnl
  291. ])
  292. elif test $pkg_failed = untried; then
  293. AC_MSG_RESULT([no])
  294. m4_default([$4], [AC_MSG_FAILURE(
  295. [The pkg-config script could not be found or is too old. Make sure it
  296. is in your PATH or set the PKG_CONFIG environment variable to the full
  297. path to pkg-config.
  298. _PKG_TEXT
  299. To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
  300. ])
  301. else
  302. $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
  303. $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
  304. AC_MSG_RESULT([yes])
  305. $3
  306. fi[]dnl
  307. ])# PKG_CHECK_MODULES