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