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

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