visualtest/acinclude.m4
author David Ludwig <dludwig@pobox.com>
Wed, 25 Dec 2013 21:39:48 -0500
changeset 8563 c0e68f3b6bbb
parent 7924 fcb86d323770
permissions -rwxr-xr-x
WinRT: compiled the d3d11 renderer's shaders into SDL itself

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