1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/visualtest/acinclude.m4 Sun Nov 10 00:32:23 2013 -0500
1.3 @@ -0,0 +1,359 @@
1.4 +# Configure paths for SDL
1.5 +# Sam Lantinga 9/21/99
1.6 +# stolen from Manish Singh
1.7 +# stolen back from Frank Belew
1.8 +# stolen from Manish Singh
1.9 +# Shamelessly stolen from Owen Taylor
1.10 +
1.11 +# serial 1
1.12 +
1.13 +dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1.14 +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
1.15 +dnl
1.16 +AC_DEFUN([AM_PATH_SDL2],
1.17 +[dnl
1.18 +dnl Get the cflags and libraries from the sdl2-config script
1.19 +dnl
1.20 +AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
1.21 + sdl_prefix="$withval", sdl_prefix="")
1.22 +AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
1.23 + sdl_exec_prefix="$withval", sdl_exec_prefix="")
1.24 +AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
1.25 + , enable_sdltest=yes)
1.26 +
1.27 + min_sdl_version=ifelse([$1], ,0.9.0,$1)
1.28 +
1.29 + if test "x$sdl_prefix$sdl_exec_prefix" = x ; then
1.30 + PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version],
1.31 + [sdl_pc=yes],
1.32 + [sdl_pc=no])
1.33 + else
1.34 + sdl_pc=no
1.35 + if test x$sdl_exec_prefix != x ; then
1.36 + sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix"
1.37 + if test x${SDL_CONFIG+set} != xset ; then
1.38 + SDL_CONFIG=$sdl_exec_prefix/bin/sdl2-config
1.39 + fi
1.40 + fi
1.41 + if test x$sdl_prefix != x ; then
1.42 + sdl_config_args="$sdl_config_args --prefix=$sdl_prefix"
1.43 + if test x${SDL_CONFIG+set} != xset ; then
1.44 + SDL_CONFIG=$sdl_prefix/bin/sdl2-config
1.45 + fi
1.46 + fi
1.47 + fi
1.48 +
1.49 + if test "x$sdl_pc" = xyes ; then
1.50 + no_sdl=""
1.51 + SDL_CONFIG="pkg-config sdl2"
1.52 + else
1.53 + as_save_PATH="$PATH"
1.54 + if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then
1.55 + PATH="$prefix/bin:$prefix/usr/bin:$PATH"
1.56 + fi
1.57 + AC_PATH_PROG(SDL_CONFIG, sdl2-config, no, [$PATH])
1.58 + PATH="$as_save_PATH"
1.59 + AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
1.60 + no_sdl=""
1.61 +
1.62 + if test "$SDL_CONFIG" = "no" ; then
1.63 + no_sdl=yes
1.64 + else
1.65 + SDL_CFLAGS=`$SDL_CONFIG $sdl_config_args --cflags`
1.66 + SDL_LIBS=`$SDL_CONFIG $sdl_config_args --libs`
1.67 +
1.68 + sdl_major_version=`$SDL_CONFIG $sdl_config_args --version | \
1.69 + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1.70 + sdl_minor_version=`$SDL_CONFIG $sdl_config_args --version | \
1.71 + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1.72 + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
1.73 + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1.74 + if test "x$enable_sdltest" = "xyes" ; then
1.75 + ac_save_CFLAGS="$CFLAGS"
1.76 + ac_save_CXXFLAGS="$CXXFLAGS"
1.77 + ac_save_LIBS="$LIBS"
1.78 + CFLAGS="$CFLAGS $SDL_CFLAGS"
1.79 + CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
1.80 + LIBS="$LIBS $SDL_LIBS"
1.81 +dnl
1.82 +dnl Now check if the installed SDL is sufficiently new. (Also sanity
1.83 +dnl checks the results of sdl2-config to some extent
1.84 +dnl
1.85 + rm -f conf.sdltest
1.86 + AC_TRY_RUN([
1.87 +#include <stdio.h>
1.88 +#include <stdlib.h>
1.89 +#include <string.h>
1.90 +#include "SDL.h"
1.91 +
1.92 +char*
1.93 +my_strdup (char *str)
1.94 +{
1.95 + char *new_str;
1.96 +
1.97 + if (str)
1.98 + {
1.99 + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
1.100 + strcpy (new_str, str);
1.101 + }
1.102 + else
1.103 + new_str = NULL;
1.104 +
1.105 + return new_str;
1.106 +}
1.107 +
1.108 +int main (int argc, char *argv[])
1.109 +{
1.110 + int major, minor, micro;
1.111 + char *tmp_version;
1.112 +
1.113 + /* This hangs on some systems (?)
1.114 + system ("touch conf.sdltest");
1.115 + */
1.116 + { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
1.117 +
1.118 + /* HP/UX 9 (%@#!) writes to sscanf strings */
1.119 + tmp_version = my_strdup("$min_sdl_version");
1.120 + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
1.121 + printf("%s, bad version string\n", "$min_sdl_version");
1.122 + exit(1);
1.123 + }
1.124 +
1.125 + if (($sdl_major_version > major) ||
1.126 + (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
1.127 + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
1.128 + {
1.129 + return 0;
1.130 + }
1.131 + else
1.132 + {
1.133 + printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
1.134 + printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro);
1.135 + printf("*** best to upgrade to the required version.\n");
1.136 + printf("*** If sdl2-config was wrong, set the environment variable SDL_CONFIG\n");
1.137 + printf("*** to point to the correct copy of sdl2-config, and remove the file\n");
1.138 + printf("*** config.cache before re-running configure\n");
1.139 + return 1;
1.140 + }
1.141 +}
1.142 +
1.143 +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1.144 + CFLAGS="$ac_save_CFLAGS"
1.145 + CXXFLAGS="$ac_save_CXXFLAGS"
1.146 + LIBS="$ac_save_LIBS"
1.147 + fi
1.148 + fi
1.149 + if test "x$no_sdl" = x ; then
1.150 + AC_MSG_RESULT(yes)
1.151 + else
1.152 + AC_MSG_RESULT(no)
1.153 + fi
1.154 + fi
1.155 + if test "x$no_sdl" = x ; then
1.156 + ifelse([$2], , :, [$2])
1.157 + else
1.158 + if test "$SDL_CONFIG" = "no" ; then
1.159 + echo "*** The sdl2-config script installed by SDL could not be found"
1.160 + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
1.161 + echo "*** your path, or set the SDL_CONFIG environment variable to the"
1.162 + echo "*** full path to sdl2-config."
1.163 + else
1.164 + if test -f conf.sdltest ; then
1.165 + :
1.166 + else
1.167 + echo "*** Could not run SDL test program, checking why..."
1.168 + CFLAGS="$CFLAGS $SDL_CFLAGS"
1.169 + CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
1.170 + LIBS="$LIBS $SDL_LIBS"
1.171 + AC_TRY_LINK([
1.172 +#include <stdio.h>
1.173 +#include "SDL.h"
1.174 +
1.175 +int main(int argc, char *argv[])
1.176 +{ return 0; }
1.177 +#undef main
1.178 +#define main K_and_R_C_main
1.179 +], [ return 0; ],
1.180 + [ echo "*** The test program compiled, but did not run. This usually means"
1.181 + echo "*** that the run-time linker is not finding SDL or finding the wrong"
1.182 + echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
1.183 + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
1.184 + echo "*** to the installed location Also, make sure you have run ldconfig if that"
1.185 + echo "*** is required on your system"
1.186 + echo "***"
1.187 + echo "*** If you have an old version installed, it is best to remove it, although"
1.188 + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
1.189 + [ echo "*** The test program failed to compile or link. See the file config.log for the"
1.190 + echo "*** exact error that occured. This usually means SDL was incorrectly installed"
1.191 + echo "*** or that you have moved SDL since it was installed. In the latter case, you"
1.192 + echo "*** may want to edit the sdl2-config script: $SDL_CONFIG" ])
1.193 + CFLAGS="$ac_save_CFLAGS"
1.194 + CXXFLAGS="$ac_save_CXXFLAGS"
1.195 + LIBS="$ac_save_LIBS"
1.196 + fi
1.197 + fi
1.198 + SDL_CFLAGS=""
1.199 + SDL_LIBS=""
1.200 + ifelse([$3], , :, [$3])
1.201 + fi
1.202 + AC_SUBST(SDL_CFLAGS)
1.203 + AC_SUBST(SDL_LIBS)
1.204 + rm -f conf.sdltest
1.205 +])
1.206 +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
1.207 +# serial 1 (pkg-config-0.24)
1.208 +#
1.209 +# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
1.210 +#
1.211 +# This program is free software; you can redistribute it and/or modify
1.212 +# it under the terms of the GNU General Public License as published by
1.213 +# the Free Software Foundation; either version 2 of the License, or
1.214 +# (at your option) any later version.
1.215 +#
1.216 +# This program is distributed in the hope that it will be useful, but
1.217 +# WITHOUT ANY WARRANTY; without even the implied warranty of
1.218 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.219 +# General Public License for more details.
1.220 +#
1.221 +# You should have received a copy of the GNU General Public License
1.222 +# along with this program; if not, write to the Free Software
1.223 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1.224 +#
1.225 +# As a special exception to the GNU General Public License, if you
1.226 +# distribute this file as part of a program that contains a
1.227 +# configuration script generated by Autoconf, you may include it under
1.228 +# the same distribution terms that you use for the rest of that program.
1.229 +
1.230 +# PKG_PROG_PKG_CONFIG([MIN-VERSION])
1.231 +# ----------------------------------
1.232 +AC_DEFUN([PKG_PROG_PKG_CONFIG],
1.233 +[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
1.234 +m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
1.235 +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
1.236 +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
1.237 +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
1.238 +
1.239 +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
1.240 + AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1.241 +fi
1.242 +if test -n "$PKG_CONFIG"; then
1.243 + _pkg_min_version=m4_default([$1], [0.9.0])
1.244 + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
1.245 + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
1.246 + AC_MSG_RESULT([yes])
1.247 + else
1.248 + AC_MSG_RESULT([no])
1.249 + PKG_CONFIG=""
1.250 + fi
1.251 +fi[]dnl
1.252 +])# PKG_PROG_PKG_CONFIG
1.253 +
1.254 +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1.255 +#
1.256 +# Check to see whether a particular set of modules exists. Similar
1.257 +# to PKG_CHECK_MODULES(), but does not set variables or print errors.
1.258 +#
1.259 +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1.260 +# only at the first occurence in configure.ac, so if the first place
1.261 +# it's called might be skipped (such as if it is within an "if", you
1.262 +# have to call PKG_CHECK_EXISTS manually
1.263 +# --------------------------------------------------------------
1.264 +AC_DEFUN([PKG_CHECK_EXISTS],
1.265 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1.266 +if test -n "$PKG_CONFIG" && \
1.267 + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
1.268 + m4_default([$2], [:])
1.269 +m4_ifvaln([$3], [else
1.270 + $3])dnl
1.271 +fi])
1.272 +
1.273 +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
1.274 +# ---------------------------------------------
1.275 +m4_define([_PKG_CONFIG],
1.276 +[if test -n "$$1"; then
1.277 + pkg_cv_[]$1="$$1"
1.278 + elif test -n "$PKG_CONFIG"; then
1.279 + PKG_CHECK_EXISTS([$3],
1.280 + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
1.281 + [pkg_failed=yes])
1.282 + else
1.283 + pkg_failed=untried
1.284 +fi[]dnl
1.285 +])# _PKG_CONFIG
1.286 +
1.287 +# _PKG_SHORT_ERRORS_SUPPORTED
1.288 +# -----------------------------
1.289 +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
1.290 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
1.291 +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1.292 + _pkg_short_errors_supported=yes
1.293 +else
1.294 + _pkg_short_errors_supported=no
1.295 +fi[]dnl
1.296 +])# _PKG_SHORT_ERRORS_SUPPORTED
1.297 +
1.298 +
1.299 +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
1.300 +# [ACTION-IF-NOT-FOUND])
1.301 +#
1.302 +#
1.303 +# Note that if there is a possibility the first call to
1.304 +# PKG_CHECK_MODULES might not happen, you should be sure to include an
1.305 +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
1.306 +#
1.307 +#
1.308 +# --------------------------------------------------------------
1.309 +AC_DEFUN([PKG_CHECK_MODULES],
1.310 +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
1.311 +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
1.312 +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
1.313 +
1.314 +pkg_failed=no
1.315 +AC_MSG_CHECKING([for $1])
1.316 +
1.317 +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
1.318 +_PKG_CONFIG([$1][_LIBS], [libs], [$2])
1.319 +
1.320 +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
1.321 +and $1[]_LIBS to avoid the need to call pkg-config.
1.322 +See the pkg-config man page for more details.])
1.323 +
1.324 +if test $pkg_failed = yes; then
1.325 + AC_MSG_RESULT([no])
1.326 + _PKG_SHORT_ERRORS_SUPPORTED
1.327 + if test $_pkg_short_errors_supported = yes; then
1.328 + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
1.329 + else
1.330 + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
1.331 + fi
1.332 + # Put the nasty error message in config.log where it belongs
1.333 + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
1.334 +
1.335 + m4_default([$4], [AC_MSG_ERROR(
1.336 +[Package requirements ($2) were not met:
1.337 +
1.338 +$$1_PKG_ERRORS
1.339 +
1.340 +Consider adjusting the PKG_CONFIG_PATH environment variable if you
1.341 +installed software in a non-standard prefix.
1.342 +
1.343 +_PKG_TEXT])dnl
1.344 + ])
1.345 +elif test $pkg_failed = untried; then
1.346 + AC_MSG_RESULT([no])
1.347 + m4_default([$4], [AC_MSG_FAILURE(
1.348 +[The pkg-config script could not be found or is too old. Make sure it
1.349 +is in your PATH or set the PKG_CONFIG environment variable to the full
1.350 +path to pkg-config.
1.351 +
1.352 +_PKG_TEXT
1.353 +
1.354 +To get pkg-config, see <http://pkg-config.freedesktop.org/>.])dnl
1.355 + ])
1.356 +else
1.357 + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
1.358 + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
1.359 + AC_MSG_RESULT([yes])
1.360 + $3
1.361 +fi[]dnl
1.362 +])# PKG_CHECK_MODULES