configure.in
author Ethan Lee <flibitijibibo@flibitijibibo.com>
Sat, 04 Aug 2018 11:52:46 -0400
changeset 12072 1e46699fa470
parent 12055 bf70bfa02215
child 12081 277e57c09ff4
permissions -rw-r--r--
SDL_exp
     1 dnl Process this file with autoconf to produce a configure script.
     2 AC_INIT(README.txt)
     3 AC_CONFIG_HEADER(include/SDL_config.h)
     4 AC_CONFIG_AUX_DIR(build-scripts)
     5 AC_CONFIG_MACRO_DIR([acinclude])
     6 
     7 dnl Save the CFLAGS to see whether they were passed in or generated
     8 orig_CFLAGS="$CFLAGS"
     9 
    10 dnl Set various version strings - taken gratefully from the GTk sources
    11 #
    12 # Making releases:
    13 # Edit include/SDL_version.h and change the version, then:
    14 #   SDL_MICRO_VERSION += 1;
    15 #   SDL_INTERFACE_AGE += 1;
    16 #   SDL_BINARY_AGE += 1;
    17 # if any functions have been added, set SDL_INTERFACE_AGE to 0.
    18 # if backwards compatibility has been broken,
    19 # set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
    20 #
    21 SDL_MAJOR_VERSION=2
    22 SDL_MINOR_VERSION=0
    23 SDL_MICRO_VERSION=8
    24 SDL_INTERFACE_AGE=0
    25 SDL_BINARY_AGE=8
    26 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
    27 
    28 AC_SUBST(SDL_MAJOR_VERSION)
    29 AC_SUBST(SDL_MINOR_VERSION)
    30 AC_SUBST(SDL_MICRO_VERSION)
    31 AC_SUBST(SDL_INTERFACE_AGE)
    32 AC_SUBST(SDL_BINARY_AGE)
    33 AC_SUBST(SDL_VERSION)
    34 
    35 # libtool versioning
    36 LT_INIT([win32-dll])
    37 
    38 LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
    39 LT_CURRENT=`expr $SDL_MICRO_VERSION - $SDL_INTERFACE_AGE`
    40 LT_REVISION=$SDL_INTERFACE_AGE
    41 LT_AGE=`expr $SDL_BINARY_AGE - $SDL_INTERFACE_AGE`
    42 m4_pattern_allow([^LT_])
    43 
    44 AC_SUBST(LT_RELEASE)
    45 AC_SUBST(LT_CURRENT)
    46 AC_SUBST(LT_REVISION)
    47 AC_SUBST(LT_AGE)
    48 
    49 dnl Detect the canonical build and host environments
    50 dnl AC_CANONICAL_HOST
    51 
    52 dnl Check for tools
    53 AC_PROG_LIBTOOL
    54 AC_PROG_CC
    55 AC_PROG_CXX
    56 AC_PROG_INSTALL
    57 AC_PROG_MAKE_SET
    58 AC_CHECK_TOOL(WINDRES, [windres], [:])
    59 
    60 dnl Make sure that srcdir is a full pathname
    61 case "$host" in
    62     *-*-mingw32*)
    63         # Except on msys, where make can't handle full pathnames (bug 1972)
    64         ;;
    65     *)
    66         srcdir=`cd $srcdir && pwd`
    67         ;;
    68 esac
    69 
    70 dnl Set up the compiler and linker flags
    71 INCLUDE="-I$srcdir/include -idirafter $srcdir/src/video/khronos"
    72 if test x$srcdir != x.; then
    73     INCLUDE="-Iinclude $INCLUDE"
    74 elif test -d .hg; then
    75     AC_MSG_ERROR([
    76 *** When building from Mercurial you should configure and build in a
    77     separate directory so you don't clobber SDL_config.h, SDL_revision.h
    78 ])
    79 fi
    80 BASE_CFLAGS=""
    81 BASE_LDFLAGS=""
    82 case "$host" in
    83     *-*-cygwin*)
    84         # We build SDL on cygwin without the UNIX emulation layer
    85         save_CFLAGS="$CFLAGS"
    86         have_no_cygwin=no
    87         AC_MSG_CHECKING(for GCC -mno-cygwin option)
    88         CFLAGS="$save_CFLAGS -mno-cygwin"
    89 
    90         AC_TRY_COMPILE([
    91         ],[
    92         ],[
    93         have_no_cygwin=yes
    94         ])
    95         AC_MSG_RESULT($have_no_cygwin)
    96         CFLAGS="$save_CFLAGS"
    97 
    98         if test x$have_no_cygwin = xyes; then
    99             BASE_CFLAGS="-mno-cygwin"
   100             BASE_LDFLAGS="-mno-cygwin"
   101         fi
   102         BASE_CFLAGS="$BASE_CFLAGS -I/usr/include/mingw"
   103         ;;
   104 esac
   105 # Uncomment the following line if you want to force SDL and applications
   106 # built with it to be compiled for a particular architecture.
   107 #AX_GCC_ARCHFLAG([no], [BASE_CFLAGS="$BASE_CFLAGS $ax_cv_gcc_archflag]")
   108 BUILD_CFLAGS="$CFLAGS $CPPFLAGS -DUSING_GENERATED_CONFIG_H"
   109 # The default optimization for SDL is -O3 (Bug #31)
   110 if test "x$orig_CFLAGS" = x; then
   111     BUILD_CFLAGS=`echo $BUILD_CFLAGS | sed 's/-O2/-O3/'`
   112 fi
   113 EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
   114 BUILD_LDFLAGS="$LDFLAGS"
   115 EXTRA_LDFLAGS="$BASE_LDFLAGS"
   116 ## These are common directories to find software packages
   117 #for path in /usr/freeware /usr/pkg /usr/X11R6 /usr/local; do
   118 #    if test -d $path/include; then
   119 #        EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
   120 #    fi
   121 #    if test -d $path/lib; then
   122 #        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
   123 #    fi
   124 #done
   125 SDL_CFLAGS="$BASE_CFLAGS"
   126 SDL_LIBS="-lSDL2"
   127 if test "x$BASE_LDFLAGS" != x; then
   128     SDL_LIBS="$SDL_LIBS $BASE_LDFLAGS"
   129 fi
   130 if test "x$EXTRA_CFLAGS" != x; then
   131     CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
   132     CFLAGS="$CFLAGS $EXTRA_CFLAGS"
   133 fi
   134 if test "x$EXTRA_LDFLAGS" != x; then
   135     LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
   136 fi
   137 
   138 dnl set this to use on systems that use lib64 instead of lib
   139 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
   140 
   141 dnl Function to find a library in the compiler search path
   142 find_lib()
   143 {
   144     gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   145     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   146     env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
   147     if test "$cross_compiling" = yes; then
   148         host_lib_path=""
   149     else
   150         host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
   151     fi
   152     for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
   153         lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`]
   154         if test x$lib != x; then
   155             echo $lib
   156             return
   157         fi
   158     done
   159 }
   160 
   161 dnl Check for compiler characteristics
   162 AC_C_CONST
   163 AC_C_INLINE
   164 AC_C_VOLATILE
   165 
   166 dnl See whether we want assertions for debugging/sanity checking SDL itself.
   167 AC_ARG_ENABLE(assertions,
   168 AC_HELP_STRING([--enable-assertions],
   169                [Enable internal sanity checks (auto/disabled/release/enabled/paranoid) [[default=auto]]]),
   170               , enable_assertions=auto)
   171 case "$enable_assertions" in
   172     auto) # Use optimization settings to determine assertion level
   173         ;;
   174     disabled)
   175         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 0, [ ])
   176         ;;
   177     release)
   178         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 1, [ ])
   179         ;;
   180     enabled)
   181         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 2, [ ])
   182         ;;
   183     paranoid)
   184         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 3, [ ])
   185         ;;
   186     *)
   187         AC_MSG_ERROR([*** unknown assertion level. stop.])
   188         ;;
   189 esac
   190 
   191 dnl See whether we can use gcc style dependency tracking
   192 AC_ARG_ENABLE(dependency-tracking,
   193 AC_HELP_STRING([--enable-dependency-tracking],
   194                [Use gcc -MMD -MT dependency tracking [[default=yes]]]),
   195               , enable_dependency_tracking=yes)
   196 if test x$enable_dependency_tracking = xyes; then
   197     have_gcc_mmd_mt=no
   198     AC_MSG_CHECKING(for GCC -MMD -MT option)
   199     AC_TRY_COMPILE([
   200     #if !defined(__GNUC__) || __GNUC__ < 3
   201     #error Dependency tracking requires GCC 3.0 or newer
   202     #endif
   203     ],[
   204     ],[
   205     have_gcc_mmd_mt=yes
   206     ])
   207     AC_MSG_RESULT($have_gcc_mmd_mt)
   208 
   209     if test x$have_gcc_mmd_mt = xyes; then
   210         DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
   211     fi
   212 fi
   213 
   214 AC_MSG_CHECKING(for linker option --no-undefined)
   215 have_no_undefined=no
   216 case "$host" in
   217     dnl Skip this on platforms where it is just simply busted.
   218     *-*-openbsd*)
   219         ;;
   220 
   221     *)
   222         save_LDFLAGS="$LDFLAGS"
   223         LDFLAGS="$LDFLAGS -Wl,--no-undefined"
   224         AC_TRY_LINK([
   225         ],[
   226         ],[
   227         have_no_undefined=yes
   228         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--no-undefined"
   229         ])
   230         LDFLAGS="$save_LDFLAGS"
   231         ;;
   232 esac
   233 AC_MSG_RESULT($have_no_undefined)
   234 
   235 dnl See whether we are allowed to use the system C library
   236 AC_ARG_ENABLE(libc,
   237 AC_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]),
   238               , enable_libc=yes)
   239 if test x$enable_libc = xyes; then
   240     AC_DEFINE(HAVE_LIBC, 1, [ ])
   241 
   242     dnl Check for C library headers
   243     AC_HEADER_STDC
   244     AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h wchar.h inttypes.h stdint.h limits.h ctype.h math.h float.h iconv.h signal.h)
   245 
   246     dnl Check for typedefs, structures, etc.
   247     AC_TYPE_SIZE_T
   248 
   249     dnl Check for defines
   250     AC_CHECK_DEFINE(M_PI, math.h)
   251 
   252     dnl Checks for library functions.
   253     case "$host" in
   254     *-*-cygwin* | *-*-mingw32*)
   255         ;;
   256     *)
   257         AC_FUNC_ALLOCA
   258         ;;
   259     esac
   260 
   261     AC_FUNC_MEMCMP
   262     if test x$ac_cv_func_memcmp_working = xyes; then
   263         AC_DEFINE(HAVE_MEMCMP, 1, [ ])
   264     fi
   265     AC_FUNC_STRTOD
   266     if test x$ac_cv_func_strtod = xyes; then
   267         AC_DEFINE(HAVE_STRTOD, 1, [ ])
   268     fi
   269     AC_CHECK_FUNC(mprotect,
   270         AC_TRY_COMPILE([
   271           #include <sys/types.h>
   272           #include <sys/mman.h>
   273         ],[
   274         ],[
   275         AC_DEFINE(HAVE_MPROTECT, 1, [ ])
   276         ]),
   277     )
   278     AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll)
   279 
   280     AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
   281     AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf fmod fmodf log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
   282 
   283     AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
   284     AC_CHECK_FUNCS(iconv)
   285 
   286     AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE([HAVE_SA_SIGACTION], 1, [ ])], ,[#include <signal.h>])
   287 
   288 	dnl Check for additional non-standard headers
   289     AC_CHECK_HEADERS(libunwind.h)
   290 fi
   291 
   292 dnl AC_CHECK_SIZEOF(void*)
   293 
   294 dnl See whether we can use gcc atomic operations on this architecture
   295 AC_ARG_ENABLE(gcc-atomics,
   296 AC_HELP_STRING([--enable-gcc-atomics],
   297                [Use gcc builtin atomics [[default=yes]]]),
   298               , enable_gcc_atomics=yes)
   299 if test x$enable_gcc_atomics = xyes; then
   300     have_gcc_atomics=no
   301     AC_MSG_CHECKING(for GCC builtin atomic operations)
   302     AC_TRY_LINK([
   303     ],[
   304     int a;
   305     void *x, *y, *z;
   306     __sync_lock_test_and_set(&a, 4);
   307     __sync_lock_test_and_set(&x, y);
   308     __sync_fetch_and_add(&a, 1);
   309     __sync_bool_compare_and_swap(&a, 5, 10);
   310     __sync_bool_compare_and_swap(&x, y, z);
   311     ],[
   312     have_gcc_atomics=yes
   313     ])
   314     AC_MSG_RESULT($have_gcc_atomics)
   315 
   316     if test x$have_gcc_atomics = xyes; then
   317         AC_DEFINE(HAVE_GCC_ATOMICS, 1, [ ])
   318     else
   319         # See if we have the minimum operation needed for GCC atomics
   320         AC_TRY_LINK([
   321         ],[
   322         int a;
   323         __sync_lock_test_and_set(&a, 1);
   324         __sync_lock_release(&a);
   325         ],[
   326         have_gcc_sync_lock_test_and_set=yes
   327         ])
   328         if test x$have_gcc_sync_lock_test_and_set = xyes; then
   329             AC_DEFINE(HAVE_GCC_SYNC_LOCK_TEST_AND_SET, 1, [ ])
   330         fi
   331     fi
   332 fi
   333 
   334 # Standard C sources
   335 SOURCES="$SOURCES $srcdir/src/*.c"
   336 SOURCES="$SOURCES $srcdir/src/atomic/*.c"
   337 SOURCES="$SOURCES $srcdir/src/audio/*.c"
   338 SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
   339 SOURCES="$SOURCES $srcdir/src/dynapi/*.c"
   340 SOURCES="$SOURCES $srcdir/src/events/*.c"
   341 SOURCES="$SOURCES $srcdir/src/file/*.c"
   342 SOURCES="$SOURCES $srcdir/src/haptic/*.c"
   343 SOURCES="$SOURCES $srcdir/src/joystick/*.c"
   344 SOURCES="$SOURCES $srcdir/src/libm/*.c"
   345 SOURCES="$SOURCES $srcdir/src/power/*.c"
   346 #SOURCES="$SOURCES $srcdir/src/filesystem/*.c"
   347 SOURCES="$SOURCES $srcdir/src/render/*.c"
   348 SOURCES="$SOURCES $srcdir/src/render/*/*.c"
   349 SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
   350 SOURCES="$SOURCES $srcdir/src/thread/*.c"
   351 SOURCES="$SOURCES $srcdir/src/timer/*.c"
   352 SOURCES="$SOURCES $srcdir/src/video/*.c"
   353 SOURCES="$SOURCES $srcdir/src/video/yuv2rgb/*.c"
   354 
   355 dnl Enable/disable various subsystems of the SDL library
   356 
   357 AC_ARG_ENABLE(atomic,
   358 AC_HELP_STRING([--enable-atomic], [Enable the atomic operations subsystem [[default=yes]]]),
   359               , enable_atomic=yes)
   360 if test x$enable_atomic != xyes; then
   361     AC_DEFINE(SDL_ATOMIC_DISABLED, 1, [ ])
   362 else
   363     SUMMARY_modules="${SUMMARY_modules} atomic"
   364 fi
   365 AC_ARG_ENABLE(audio,
   366 AC_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]),
   367               , enable_audio=yes)
   368 if test x$enable_audio != xyes; then
   369     AC_DEFINE(SDL_AUDIO_DISABLED, 1, [ ])
   370 else
   371     SUMMARY_modules="${SUMMARY_modules} audio"
   372 fi
   373 AC_ARG_ENABLE(video,
   374 AC_HELP_STRING([--enable-video], [Enable the video subsystem [[default=yes]]]),
   375               , enable_video=yes)
   376 if test x$enable_video != xyes; then
   377     AC_DEFINE(SDL_VIDEO_DISABLED, 1, [ ])
   378 else
   379     SUMMARY_modules="${SUMMARY_modules} video"
   380 fi
   381 AC_ARG_ENABLE(render,
   382 AC_HELP_STRING([--enable-render], [Enable the render subsystem [[default=yes]]]),
   383               , enable_render=yes)
   384 if test x$enable_render != xyes; then
   385     AC_DEFINE(SDL_RENDER_DISABLED, 1, [ ])
   386 else
   387     SUMMARY_modules="${SUMMARY_modules} render"
   388 fi
   389 AC_ARG_ENABLE(events,
   390 AC_HELP_STRING([--enable-events], [Enable the events subsystem [[default=yes]]]),
   391               , enable_events=yes)
   392 if test x$enable_events != xyes; then
   393     AC_DEFINE(SDL_EVENTS_DISABLED, 1, [ ])
   394 else
   395     SUMMARY_modules="${SUMMARY_modules} events"
   396 fi
   397 AC_ARG_ENABLE(joystick,
   398 AC_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes]]]),
   399               , enable_joystick=yes)
   400 if test x$enable_joystick != xyes; then
   401     AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
   402 else
   403     SUMMARY_modules="${SUMMARY_modules} joystick"
   404 fi
   405 AC_ARG_ENABLE(haptic,
   406 AC_HELP_STRING([--enable-haptic], [Enable the haptic (force feedback) subsystem [[default=yes]]]),
   407               , enable_haptic=yes)
   408 if test x$enable_haptic != xyes; then
   409     AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
   410 else
   411     SUMMARY_modules="${SUMMARY_modules} haptic"
   412 fi
   413 AC_ARG_ENABLE(power,
   414 AC_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]),
   415               , enable_power=yes)
   416 if test x$enable_power != xyes; then
   417     AC_DEFINE(SDL_POWER_DISABLED, 1, [ ])
   418 else
   419     SUMMARY_modules="${SUMMARY_modules} power"
   420 fi
   421 AC_ARG_ENABLE(filesystem,
   422 AC_HELP_STRING([--enable-filesystem], [Enable the filesystem subsystem [[default=yes]]]),
   423               , enable_filesystem=yes)
   424 if test x$enable_filesystem != xyes; then
   425     AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
   426 else
   427     SUMMARY_modules="${SUMMARY_modules} filesystem"
   428 fi
   429 AC_ARG_ENABLE(threads,
   430 AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]),
   431               , enable_threads=yes)
   432 if test x$enable_threads != xyes; then
   433     AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
   434 else
   435     SUMMARY_modules="${SUMMARY_modules} threads"
   436 fi
   437 AC_ARG_ENABLE(timers,
   438 AC_HELP_STRING([--enable-timers], [Enable the timer subsystem [[default=yes]]]),
   439               , enable_timers=yes)
   440 if test x$enable_timers != xyes; then
   441     AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ])
   442 else
   443     SUMMARY_modules="${SUMMARY_modules} timers"
   444 fi
   445 AC_ARG_ENABLE(file,
   446 AC_HELP_STRING([--enable-file], [Enable the file subsystem [[default=yes]]]),
   447               , enable_file=yes)
   448 if test x$enable_file != xyes; then
   449     AC_DEFINE(SDL_FILE_DISABLED, 1, [ ])
   450 else
   451     SUMMARY_modules="${SUMMARY_modules} file"
   452 fi
   453 AC_ARG_ENABLE(loadso,
   454 AC_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [[default=yes]]]),
   455               , enable_loadso=yes)
   456 if test x$enable_loadso != xyes; then
   457     AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
   458 else
   459     SUMMARY_modules="${SUMMARY_modules} loadso"
   460 fi
   461 AC_ARG_ENABLE(cpuinfo,
   462 AC_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [[default=yes]]]),
   463               , enable_cpuinfo=yes)
   464 if test x$enable_cpuinfo != xyes; then
   465     AC_DEFINE(SDL_CPUINFO_DISABLED, 1, [ ])
   466 else
   467     SUMMARY_modules="${SUMMARY_modules} cpuinfo"
   468 fi
   469 AC_ARG_ENABLE(assembly,
   470 AC_HELP_STRING([--enable-assembly], [Enable assembly routines [[default=yes]]]),
   471               , enable_assembly=yes)
   472 if test x$enable_assembly = xyes; then
   473     SUMMARY_modules="${SUMMARY_modules} assembly"
   474 
   475     AC_DEFINE(SDL_ASSEMBLY_ROUTINES, 1, [ ])
   476 
   477     # Make sure that we don't generate floating point code that would
   478     # cause illegal instruction exceptions on older processors
   479     case "$host" in
   480         *-*-darwin*)
   481             # Don't need to worry about Apple hardware, it's all SSE capable
   482             default_ssemath=yes
   483             ;;
   484         *64-*-*)
   485             # x86 64-bit architectures all have SSE instructions
   486             default_ssemath=yes
   487             ;;
   488         *)
   489             default_ssemath=no
   490             ;;
   491     esac
   492     AC_ARG_ENABLE(ssemath,
   493 AC_HELP_STRING([--enable-ssemath], [Allow GCC to use SSE floating point math [[default=maybe]]]),
   494                   , enable_ssemath=$default_ssemath)
   495     if test x$enable_ssemath = xno; then
   496         if test x$have_gcc_sse = xyes -o x$have_gcc_sse2 = xyes -o x$have_gcc_sse3 = xyes; then
   497             EXTRA_CFLAGS="$EXTRA_CFLAGS -mfpmath=387"
   498         fi
   499     fi
   500 
   501     dnl Check for various instruction support
   502     AC_ARG_ENABLE(mmx,
   503 AC_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=yes]]]),
   504                   , enable_mmx=yes)
   505     if test x$enable_mmx = xyes; then
   506         save_CFLAGS="$CFLAGS"
   507         have_gcc_mmx=no
   508         AC_MSG_CHECKING(for GCC -mmmx option)
   509         mmx_CFLAGS="-mmmx"
   510         CFLAGS="$save_CFLAGS $mmx_CFLAGS"
   511 
   512         AC_TRY_COMPILE([
   513         #ifdef __MINGW32__
   514         #include <_mingw.h>
   515         #ifdef __MINGW64_VERSION_MAJOR
   516         #include <intrin.h>
   517         #else
   518         #include <mmintrin.h>
   519         #endif
   520         #else
   521         #include <mmintrin.h>
   522         #endif
   523         #ifndef __MMX__
   524         #error Assembler CPP flag not enabled
   525         #endif
   526         ],[
   527         ],[
   528         have_gcc_mmx=yes
   529         ])
   530         AC_MSG_RESULT($have_gcc_mmx)
   531         CFLAGS="$save_CFLAGS"
   532 
   533         if test x$have_gcc_mmx = xyes; then
   534             EXTRA_CFLAGS="$EXTRA_CFLAGS $mmx_CFLAGS"
   535             SUMMARY_math="${SUMMARY_math} mmx"
   536         fi
   537     fi
   538 
   539     AC_ARG_ENABLE(3dnow,
   540 AC_HELP_STRING([--enable-3dnow], [use 3DNow! assembly routines [[default=yes]]]),
   541                   , enable_3dnow=yes)
   542     if test x$enable_3dnow = xyes; then
   543         save_CFLAGS="$CFLAGS"
   544         have_gcc_3dnow=no
   545         AC_MSG_CHECKING(for GCC -m3dnow option)
   546         amd3dnow_CFLAGS="-m3dnow"
   547         CFLAGS="$save_CFLAGS $amd3dnow_CFLAGS"
   548 
   549         AC_TRY_LINK([
   550         #include <mm3dnow.h>
   551         #ifndef __3dNOW__
   552         #error Assembler CPP flag not enabled
   553         #endif
   554         ],[
   555         void *p = 0;
   556         _m_prefetch(p);
   557         ],[
   558         have_gcc_3dnow=yes
   559         ])
   560         AC_MSG_RESULT($have_gcc_3dnow)
   561         CFLAGS="$save_CFLAGS"
   562 
   563         if test x$have_gcc_3dnow = xyes; then
   564             EXTRA_CFLAGS="$EXTRA_CFLAGS $amd3dnow_CFLAGS"
   565             SUMMARY_math="${SUMMARY_math} 3dnow"
   566         fi
   567     fi
   568 
   569     AC_ARG_ENABLE(sse,
   570 AC_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]),
   571                   , enable_sse=yes)
   572     if test x$enable_sse = xyes; then
   573         save_CFLAGS="$CFLAGS"
   574         have_gcc_sse=no
   575         AC_MSG_CHECKING(for GCC -msse option)
   576         sse_CFLAGS="-msse"
   577         CFLAGS="$save_CFLAGS $sse_CFLAGS"
   578 
   579         AC_TRY_COMPILE([
   580         #ifdef __MINGW32__
   581         #include <_mingw.h>
   582         #ifdef __MINGW64_VERSION_MAJOR
   583         #include <intrin.h>
   584         #else
   585         #include <xmmintrin.h>
   586         #endif
   587         #else
   588         #include <xmmintrin.h>
   589         #endif
   590         #ifndef __SSE__
   591         #error Assembler CPP flag not enabled
   592         #endif
   593         ],[
   594         ],[
   595         have_gcc_sse=yes
   596         ])
   597         AC_MSG_RESULT($have_gcc_sse)
   598         CFLAGS="$save_CFLAGS"
   599 
   600         if test x$have_gcc_sse = xyes; then
   601             EXTRA_CFLAGS="$EXTRA_CFLAGS $sse_CFLAGS"
   602             SUMMARY_math="${SUMMARY_math} sse"
   603         fi
   604     fi
   605 
   606     AC_ARG_ENABLE(sse2,
   607 AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=maybe]]]),
   608                   , enable_sse2=$default_ssemath)
   609     if test x$enable_sse2 = xyes; then
   610         save_CFLAGS="$CFLAGS"
   611         have_gcc_sse2=no
   612         AC_MSG_CHECKING(for GCC -msse2 option)
   613         sse2_CFLAGS="-msse2"
   614         CFLAGS="$save_CFLAGS $sse2_CFLAGS"
   615 
   616         AC_TRY_COMPILE([
   617         #ifdef __MINGW32__
   618         #include <_mingw.h>
   619         #ifdef __MINGW64_VERSION_MAJOR
   620         #include <intrin.h>
   621         #else
   622         #include <emmintrin.h>
   623         #endif
   624         #else
   625         #include <emmintrin.h>
   626         #endif
   627         #ifndef __SSE2__
   628         #error Assembler CPP flag not enabled
   629         #endif
   630         ],[
   631         ],[
   632         have_gcc_sse2=yes
   633         ])
   634         AC_MSG_RESULT($have_gcc_sse2)
   635         CFLAGS="$save_CFLAGS"
   636 
   637         if test x$have_gcc_sse2 = xyes; then
   638             EXTRA_CFLAGS="$EXTRA_CFLAGS $sse2_CFLAGS"
   639             SUMMARY_math="${SUMMARY_math} sse2"
   640         fi
   641     fi
   642 
   643     AC_ARG_ENABLE(sse3,
   644 AC_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [[default=maybe]]]),
   645                   , enable_sse3=$default_ssemath)
   646     if test x$enable_sse3 = xyes; then
   647         save_CFLAGS="$CFLAGS"
   648         have_gcc_sse3=no
   649         AC_MSG_CHECKING(for GCC -msse3 option)
   650         sse3_CFLAGS="-msse3"
   651         CFLAGS="$save_CFLAGS $sse3_CFLAGS"
   652 
   653         AC_TRY_COMPILE([
   654         #ifdef __MINGW32__
   655         #include <_mingw.h>
   656         #ifdef __MINGW64_VERSION_MAJOR
   657         #include <intrin.h>
   658         #else
   659         #include <pmmintrin.h>
   660         #endif
   661         #else
   662         #include <pmmintrin.h>
   663         #endif
   664         #ifndef __SSE2__
   665         #error Assembler CPP flag not enabled
   666         #endif
   667         ],[
   668         ],[
   669         have_gcc_sse3=yes
   670         ])
   671         AC_MSG_RESULT($have_gcc_sse3)
   672         CFLAGS="$save_CFLAGS"
   673 
   674         if test x$have_gcc_sse3 = xyes; then
   675             EXTRA_CFLAGS="$EXTRA_CFLAGS $sse3_CFLAGS"
   676             SUMMARY_math="${SUMMARY_math} sse3"
   677         fi
   678     fi
   679 
   680     AC_CHECK_HEADER(immintrin.h,
   681                     have_immintrin_h_hdr=yes,
   682                     have_immintrin_h_hdr=no)
   683     if test x$have_immintrin_h_hdr = xyes; then
   684         AC_DEFINE(HAVE_IMMINTRIN_H, 1, [ ])
   685     fi
   686 
   687     AC_ARG_ENABLE(altivec,
   688 AC_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]),
   689                   , enable_altivec=yes)
   690     if test x$enable_altivec = xyes; then
   691         save_CFLAGS="$CFLAGS"
   692         have_gcc_altivec=no
   693         have_altivec_h_hdr=no
   694         altivec_CFLAGS="-maltivec"
   695         CFLAGS="$save_CFLAGS $altivec_CFLAGS"
   696 
   697         AC_MSG_CHECKING(for Altivec with GCC altivec.h and -maltivec option)
   698         AC_TRY_COMPILE([
   699         #include <altivec.h>
   700         vector unsigned int vzero() {
   701             return vec_splat_u32(0);
   702         }
   703         ],[
   704         ],[
   705         have_gcc_altivec=yes
   706         have_altivec_h_hdr=yes
   707         ])
   708         AC_MSG_RESULT($have_gcc_altivec)
   709 
   710         if test x$have_gcc_altivec = xno; then
   711             AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
   712             AC_TRY_COMPILE([
   713             vector unsigned int vzero() {
   714                 return vec_splat_u32(0);
   715             }
   716             ],[
   717             ],[
   718             have_gcc_altivec=yes
   719             ])
   720             AC_MSG_RESULT($have_gcc_altivec)
   721         fi
   722 
   723         if test x$have_gcc_altivec = xno; then
   724             AC_MSG_CHECKING(for Altivec with GCC altivec.h and -faltivec option)
   725             altivec_CFLAGS="-faltivec"
   726             CFLAGS="$save_CFLAGS $altivec_CFLAGS"
   727             AC_TRY_COMPILE([
   728             #include <altivec.h>
   729             vector unsigned int vzero() {
   730                 return vec_splat_u32(0);
   731             }
   732             ],[
   733             ],[
   734             have_gcc_altivec=yes
   735             have_altivec_h_hdr=yes
   736             ])
   737             AC_MSG_RESULT($have_gcc_altivec)
   738         fi
   739 
   740         if test x$have_gcc_altivec = xno; then
   741             AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
   742             AC_TRY_COMPILE([
   743             vector unsigned int vzero() {
   744                 return vec_splat_u32(0);
   745             }
   746             ],[
   747             ],[
   748             have_gcc_altivec=yes
   749             ])
   750             AC_MSG_RESULT($have_gcc_altivec)
   751         fi
   752         CFLAGS="$save_CFLAGS"
   753 
   754         if test x$have_gcc_altivec = xyes; then
   755             AC_DEFINE(SDL_ALTIVEC_BLITTERS, 1, [ ])
   756             if test x$have_altivec_h_hdr = xyes; then
   757               AC_DEFINE(HAVE_ALTIVEC_H, 1, [ ])
   758             fi
   759             EXTRA_CFLAGS="$EXTRA_CFLAGS $altivec_CFLAGS"
   760             SUMMARY_math="${SUMMARY_math} altivec"
   761         fi
   762     fi
   763 fi
   764 
   765 dnl See if the OSS audio interface is supported
   766 CheckOSS()
   767 {
   768     AC_ARG_ENABLE(oss,
   769 AC_HELP_STRING([--enable-oss], [support the OSS audio API [[default=maybe]]]),
   770                   , enable_oss=maybe)
   771 
   772     # OpenBSD "has" OSS, but it's not really for app use. They want you to
   773     #  use sndio instead. So on there, we default to disabled. You can force
   774     #  it on if you really want, though.
   775     if test x$enable_oss = xmaybe; then
   776         enable_oss=yes
   777         case "$host" in
   778             *-*-openbsd*)
   779                 enable_oss=no;;
   780         esac
   781     fi
   782 
   783     if test x$enable_audio = xyes -a x$enable_oss = xyes; then
   784         AC_MSG_CHECKING(for OSS audio support)
   785         have_oss=no
   786         if test x$have_oss != xyes; then
   787             AC_TRY_COMPILE([
   788               #include <sys/soundcard.h>
   789             ],[
   790               int arg = SNDCTL_DSP_SETFRAGMENT;
   791             ],[
   792             have_oss=yes
   793             ])
   794         fi
   795         if test x$have_oss != xyes; then
   796             AC_TRY_COMPILE([
   797               #include <soundcard.h>
   798             ],[
   799               int arg = SNDCTL_DSP_SETFRAGMENT;
   800             ],[
   801             have_oss=yes
   802             AC_DEFINE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H, 1, [ ])
   803             ])
   804         fi
   805         AC_MSG_RESULT($have_oss)
   806         if test x$have_oss = xyes; then
   807             SUMMARY_audio="${SUMMARY_audio} oss"
   808             AC_DEFINE(SDL_AUDIO_DRIVER_OSS, 1, [ ])
   809             SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c"
   810             have_audio=yes
   811 
   812             # We may need to link with ossaudio emulation library
   813             case "$host" in
   814                 *-*-openbsd*|*-*-netbsd*)
   815                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lossaudio";;
   816             esac
   817         fi
   818     fi
   819 }
   820 
   821 dnl See if the ALSA audio interface is supported
   822 CheckALSA()
   823 {
   824     AC_ARG_ENABLE(alsa,
   825 AC_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]),
   826                   , enable_alsa=yes)
   827     if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
   828         AM_PATH_ALSA(1.0.11, have_alsa=yes, have_alsa=no)
   829         # Restore all flags from before the ALSA detection runs
   830         CFLAGS="$alsa_save_CFLAGS"
   831         LDFLAGS="$alsa_save_LDFLAGS"
   832         LIBS="$alsa_save_LIBS"
   833         if test x$have_alsa = xyes; then
   834             AC_ARG_ENABLE(alsa-shared,
   835 AC_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[default=yes]]]),
   836                           , enable_alsa_shared=yes)
   837             alsa_lib=[`find_lib "libasound.so.*" "$ALSA_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   838 
   839             AC_DEFINE(SDL_AUDIO_DRIVER_ALSA, 1, [ ])
   840             SOURCES="$SOURCES $srcdir/src/audio/alsa/*.c"
   841             EXTRA_CFLAGS="$EXTRA_CFLAGS $ALSA_CFLAGS"
   842             if test x$have_loadso != xyes && \
   843                test x$enable_alsa_shared = xyes; then
   844                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ALSA loading])
   845             fi
   846             if test x$have_loadso = xyes && \
   847                test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
   848                 echo "-- dynamic libasound -> $alsa_lib"
   849                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ALSA_DYNAMIC, "$alsa_lib", [ ])
   850                 SUMMARY_audio="${SUMMARY_audio} alsa(dynamic)"
   851             else
   852                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ALSA_LIBS"
   853                 SUMMARY_audio="${SUMMARY_audio} alsa"
   854             fi
   855             have_audio=yes
   856         fi
   857     fi
   858 }
   859 
   860 dnl Find JACK Audio
   861 CheckJACK()
   862 {
   863     AC_ARG_ENABLE(jack,
   864 AC_HELP_STRING([--enable-jack], [use JACK audio [[default=yes]]]),
   865                   , enable_jack=yes)
   866     if test x$enable_audio = xyes -a x$enable_jack = xyes; then
   867         audio_jack=no
   868 
   869         JACK_REQUIRED_VERSION=0.125
   870 
   871         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   872         AC_MSG_CHECKING(for JACK $JACK_REQUIRED_VERSION support)
   873         if test x$PKG_CONFIG != xno; then
   874         if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $JACK_REQUIRED_VERSION jack; then
   875                 JACK_CFLAGS=`$PKG_CONFIG --cflags jack`
   876                 JACK_LIBS=`$PKG_CONFIG --libs jack`
   877                 audio_jack=yes
   878             fi
   879         fi
   880         AC_MSG_RESULT($audio_jack)
   881 
   882         if test x$audio_jack = xyes; then
   883             AC_ARG_ENABLE(jack-shared,
   884 AC_HELP_STRING([--enable-jack-shared], [dynamically load JACK audio support [[default=yes]]]),
   885                           , enable_jack_shared=yes)
   886             jack_lib=[`find_lib "libjack.so.*" "$JACK_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   887 
   888             AC_DEFINE(SDL_AUDIO_DRIVER_JACK, 1, [ ])
   889             SOURCES="$SOURCES $srcdir/src/audio/jack/*.c"
   890             EXTRA_CFLAGS="$EXTRA_CFLAGS $JACK_CFLAGS"
   891             if test x$have_loadso != xyes && \
   892                test x$enable_jack_shared = xyes; then
   893                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic JACK audio loading])
   894             fi
   895             if test x$have_loadso = xyes && \
   896                test x$enable_jack_shared = xyes && test x$jack_lib != x; then
   897                 echo "-- dynamic libjack -> $jack_lib"
   898                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_JACK_DYNAMIC, "$jack_lib", [ ])
   899                 SUMMARY_audio="${SUMMARY_audio} jack(dynamic)"
   900 
   901                 case "$host" in
   902                     # On Solaris, jack must be linked deferred explicitly
   903                     # to prevent undefined symbol failures.
   904                     *-*-solaris*)
   905                         JACK_LIBS=`echo $JACK_LIBS | sed 's/\-l/-Wl,-l/g'`
   906                         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-zdeferred $JACK_LIBS -Wl,-znodeferred"
   907                 esac
   908             else
   909                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $JACK_LIBS"
   910                 SUMMARY_audio="${SUMMARY_audio} jack"
   911             fi
   912             have_audio=yes
   913         fi
   914     fi
   915 }
   916 
   917 dnl Find the ESD includes and libraries
   918 CheckESD()
   919 {
   920     AC_ARG_ENABLE(esd,
   921 AC_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [[default=yes]]]),
   922                   , enable_esd=yes)
   923     if test x$enable_audio = xyes -a x$enable_esd = xyes; then
   924         AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
   925         if test x$have_esd = xyes; then
   926             AC_ARG_ENABLE(esd-shared,
   927 AC_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]),
   928                           , enable_esd_shared=yes)
   929             esd_lib=[`find_lib "libesd.so.*" "$ESD_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   930 
   931             AC_DEFINE(SDL_AUDIO_DRIVER_ESD, 1, [ ])
   932             SOURCES="$SOURCES $srcdir/src/audio/esd/*.c"
   933             EXTRA_CFLAGS="$EXTRA_CFLAGS $ESD_CFLAGS"
   934             if test x$have_loadso != xyes && \
   935                test x$enable_esd_shared = xyes; then
   936                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ESD loading])
   937             fi
   938             if test x$have_loadso = xyes && \
   939                test x$enable_esd_shared = xyes && test x$esd_lib != x; then
   940                 echo "-- dynamic libesd -> $esd_lib"
   941                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ESD_DYNAMIC, "$esd_lib", [ ])
   942                 SUMMARY_audio="${SUMMARY_audio} esd(dynamic)"
   943             else
   944                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ESD_LIBS"
   945                 SUMMARY_audio="${SUMMARY_audio} esd"
   946             fi
   947             have_audio=yes
   948         fi
   949     fi
   950 }
   951 
   952 dnl Find PulseAudio
   953 CheckPulseAudio()
   954 {
   955     AC_ARG_ENABLE(pulseaudio,
   956 AC_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]),
   957                   , enable_pulseaudio=yes)
   958     if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then
   959         audio_pulseaudio=no
   960 
   961         PULSEAUDIO_REQUIRED_VERSION=0.9
   962 
   963         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   964         AC_MSG_CHECKING(for PulseAudio $PULSEAUDIO_REQUIRED_VERSION support)
   965         if test x$PKG_CONFIG != xno; then
   966         if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSEAUDIO_REQUIRED_VERSION libpulse-simple; then
   967                 PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
   968                 PULSEAUDIO_LIBS=`$PKG_CONFIG --libs libpulse-simple`
   969                 audio_pulseaudio=yes
   970             fi
   971         fi
   972         AC_MSG_RESULT($audio_pulseaudio)
   973 
   974         if test x$audio_pulseaudio = xyes; then
   975             AC_ARG_ENABLE(pulseaudio-shared,
   976 AC_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]),
   977                           , enable_pulseaudio_shared=yes)
   978             pulseaudio_lib=[`find_lib "libpulse-simple.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   979 
   980             AC_DEFINE(SDL_AUDIO_DRIVER_PULSEAUDIO, 1, [ ])
   981             SOURCES="$SOURCES $srcdir/src/audio/pulseaudio/*.c"
   982             EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSEAUDIO_CFLAGS"
   983             if test x$have_loadso != xyes && \
   984                test x$enable_pulseaudio_shared = xyes; then
   985                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic PulseAudio loading])
   986             fi
   987             if test x$have_loadso = xyes && \
   988                test x$enable_pulseaudio_shared = xyes && test x$pulseaudio_lib != x; then
   989                 echo "-- dynamic libpulse-simple -> $pulseaudio_lib"
   990                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC, "$pulseaudio_lib", [ ])
   991                 SUMMARY_audio="${SUMMARY_audio} pulse(dynamic)"
   992 
   993                 case "$host" in
   994                     # On Solaris, pulseaudio must be linked deferred explicitly
   995                     # to prevent undefined symbol failures.
   996                     *-*-solaris*)
   997                         PULSEAUDIO_LIBS=`echo $PULSEAUDIO_LIBS | sed 's/\-l/-Wl,-l/g'`
   998                         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-zdeferred $PULSEAUDIO_LIBS -Wl,-znodeferred"
   999                 esac
  1000             else
  1001                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSEAUDIO_LIBS"
  1002                 SUMMARY_audio="${SUMMARY_audio} pulse"
  1003             fi
  1004             have_audio=yes
  1005         fi
  1006     fi
  1007 }
  1008 
  1009 CheckARTSC()
  1010 {
  1011     AC_ARG_ENABLE(arts,
  1012 AC_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [[default=yes]]]),
  1013                   , enable_arts=yes)
  1014     if test x$enable_audio = xyes -a x$enable_arts = xyes; then
  1015         AC_PATH_PROG(ARTSCONFIG, artsc-config)
  1016         if test x$ARTSCONFIG = x -o x$ARTSCONFIG = x'"$ARTSCONFIG"'; then
  1017             : # arts isn't installed
  1018         else
  1019             ARTS_CFLAGS=`$ARTSCONFIG --cflags`
  1020             ARTS_LIBS=`$ARTSCONFIG --libs`
  1021             AC_MSG_CHECKING(for aRts development environment)
  1022             audio_arts=no
  1023             save_CFLAGS="$CFLAGS"
  1024             CFLAGS="$CFLAGS $ARTS_CFLAGS"
  1025             AC_TRY_COMPILE([
  1026              #include <artsc.h>
  1027             ],[
  1028              arts_stream_t stream;
  1029             ],[
  1030             audio_arts=yes
  1031             ])
  1032             CFLAGS="$save_CFLAGS"
  1033             AC_MSG_RESULT($audio_arts)
  1034             if test x$audio_arts = xyes; then
  1035                 AC_ARG_ENABLE(arts-shared,
  1036 AC_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [[default=yes]]]),
  1037                               , enable_arts_shared=yes)
  1038                 arts_lib=[`find_lib "libartsc.so.*" "$ARTS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1039 
  1040                 AC_DEFINE(SDL_AUDIO_DRIVER_ARTS, 1, [ ])
  1041                 SOURCES="$SOURCES $srcdir/src/audio/arts/*.c"
  1042                 EXTRA_CFLAGS="$EXTRA_CFLAGS $ARTS_CFLAGS"
  1043                 if test x$have_loadso != xyes && \
  1044                    test x$enable_arts_shared = xyes; then
  1045                     AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ARTS loading])
  1046                 fi
  1047                 if test x$have_loadso = xyes && \
  1048                    test x$enable_arts_shared = xyes && test x$arts_lib != x; then
  1049                     echo "-- dynamic libartsc -> $arts_lib"
  1050                     AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ARTS_DYNAMIC, "$arts_lib", [ ])
  1051                     SUMMARY_audio="${SUMMARY_audio} arts(dynamic)"
  1052                 else
  1053                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARTS_LIBS"
  1054                     SUMMARY_audio="${SUMMARY_audio} arts"
  1055                 fi
  1056                 have_audio=yes
  1057             fi
  1058         fi
  1059     fi
  1060 }
  1061 
  1062 dnl See if the NAS audio interface is supported
  1063 CheckNAS()
  1064 {
  1065     AC_ARG_ENABLE(nas,
  1066 AC_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]),
  1067                   , enable_nas=yes)
  1068     if test x$enable_audio = xyes -a x$enable_nas = xyes; then
  1069         AC_CHECK_HEADER(audio/audiolib.h, have_nas_hdr=yes)
  1070         AC_CHECK_LIB(audio, AuOpenServer, have_nas_lib=yes)
  1071 
  1072         AC_MSG_CHECKING(for NAS audio support)
  1073         have_nas=no
  1074 
  1075         if test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then
  1076             have_nas=yes
  1077             NAS_LIBS="-laudio"
  1078 
  1079         elif test -r /usr/X11R6/include/audio/audiolib.h; then
  1080             have_nas=yes
  1081             NAS_CFLAGS="-I/usr/X11R6/include/"
  1082             NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
  1083 
  1084         fi
  1085 
  1086         AC_MSG_RESULT($have_nas)
  1087 
  1088         if test x$have_nas = xyes; then
  1089             AC_ARG_ENABLE(nas-shared,
  1090 AC_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [[default=yes]]]),
  1091                           , enable_nas_shared=yes)
  1092             nas_lib=[`find_lib "libaudio.so.*" "$NAS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1093 
  1094             if test x$have_loadso != xyes && \
  1095                test x$enable_nas_shared = xyes; then
  1096                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic NAS loading])
  1097             fi
  1098             if test x$have_loadso = xyes && \
  1099                test x$enable_nas_shared = xyes && test x$nas_lib != x; then
  1100                 echo "-- dynamic libaudio -> $nas_lib"
  1101                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_NAS_DYNAMIC, "$nas_lib", [ ])
  1102                 SUMMARY_audio="${SUMMARY_audio} nas(dynamic)"
  1103             else
  1104                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
  1105                 SUMMARY_audio="${SUMMARY_audio} nas"
  1106             fi
  1107 
  1108             AC_DEFINE(SDL_AUDIO_DRIVER_NAS, 1, [ ])
  1109             SOURCES="$SOURCES $srcdir/src/audio/nas/*.c"
  1110             EXTRA_CFLAGS="$EXTRA_CFLAGS $NAS_CFLAGS"
  1111             have_audio=yes
  1112         fi
  1113     fi
  1114 }
  1115 
  1116 dnl See if the sndio audio interface is supported
  1117 CheckSNDIO()
  1118 {
  1119     AC_ARG_ENABLE(sndio,
  1120 AC_HELP_STRING([--enable-sndio], [support the sndio audio API [[default=yes]]]),
  1121                   , enable_sndio=yes)
  1122     if test x$enable_audio = xyes -a x$enable_sndio = xyes; then
  1123         AC_CHECK_HEADER(sndio.h, have_sndio_hdr=yes)
  1124         AC_CHECK_LIB(sndio, sio_open, have_sndio_lib=yes)
  1125 
  1126         AC_MSG_CHECKING(for sndio audio support)
  1127         have_sndio=no
  1128 
  1129         if test x$have_sndio_hdr = xyes -a x$have_sndio_lib = xyes; then
  1130             have_sndio=yes
  1131             SNDIO_LIBS="-lsndio"
  1132         fi
  1133 
  1134         AC_MSG_RESULT($have_sndio)
  1135 
  1136         if test x$have_sndio = xyes; then
  1137             AC_ARG_ENABLE(sndio-shared,
  1138 AC_HELP_STRING([--enable-sndio-shared], [dynamically load sndio audio support [[default=yes]]]),
  1139                           , enable_sndio_shared=yes)
  1140             sndio_lib=[`find_lib "libsndio.so.*" "$SNDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1141 
  1142             if test x$have_loadso != xyes && \
  1143                test x$enable_sndio_shared = xyes; then
  1144                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic sndio loading])
  1145             fi
  1146             if test x$have_loadso = xyes && \
  1147                test x$enable_sndio_shared = xyes && test x$sndio_lib != x; then
  1148                 echo "-- dynamic libsndio -> $sndio_lib"
  1149                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC, "$sndio_lib", [ ])
  1150                 SUMMARY_audio="${SUMMARY_audio} sndio(dynamic)"
  1151             else
  1152                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SNDIO_LIBS"
  1153                 SUMMARY_audio="${SUMMARY_audio} sndio"
  1154             fi
  1155 
  1156             AC_DEFINE(SDL_AUDIO_DRIVER_SNDIO, 1, [ ])
  1157             SOURCES="$SOURCES $srcdir/src/audio/sndio/*.c"
  1158             EXTRA_CFLAGS="$EXTRA_CFLAGS $SNDIO_CFLAGS"
  1159             have_audio=yes
  1160         fi
  1161     fi
  1162 }
  1163 
  1164 dnl Find FusionSound
  1165 CheckFusionSound()
  1166 {
  1167     AC_ARG_ENABLE(fusionsound,
  1168 AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
  1169                   , enable_fusionsound=no)
  1170     if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
  1171         fusionsound=no
  1172 
  1173         FUSIONSOUND_REQUIRED_VERSION=1.1.1
  1174 
  1175         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1176         AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
  1177         if test x$PKG_CONFIG != xno; then
  1178             if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
  1179                 FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
  1180                 FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
  1181                 fusionsound=yes
  1182             fi
  1183         fi
  1184         AC_MSG_RESULT($fusionsound)
  1185 
  1186         if test x$fusionsound = xyes; then
  1187             AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND, 1, [ ])
  1188             SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
  1189             EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
  1190             
  1191             AC_ARG_ENABLE(fusionsound-shared,
  1192 AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
  1193                           , enable_fusionsound_shared=yes)
  1194             fusionsound_shared=no
  1195             AC_MSG_CHECKING(for FusionSound dynamic loading support)
  1196             if test x$have_loadso != xyes && \
  1197                test x$enable_fusionsound_shared = xyes; then
  1198                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
  1199             fi
  1200             if test x$have_loadso = xyes && \
  1201                test x$enable_fusionsound_shared = xyes; then
  1202                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so", [ ])
  1203                 fusionsound_shared=yes
  1204                 SUMMARY_audio="${SUMMARY_audio} fusionsound(dynamic)"
  1205             else
  1206                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
  1207                 SUMMARY_audio="${SUMMARY_audio} fusionsound"
  1208             fi
  1209             AC_MSG_RESULT($fusionsound_shared)
  1210             
  1211             have_audio=yes
  1212         fi
  1213     fi
  1214 }
  1215 
  1216 dnl rcg07142001 See if the user wants the disk writer audio driver...
  1217 CheckDiskAudio()
  1218 {
  1219     AC_ARG_ENABLE(diskaudio,
  1220 AC_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [[default=yes]]]),
  1221                   , enable_diskaudio=yes)
  1222     if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
  1223         AC_DEFINE(SDL_AUDIO_DRIVER_DISK, 1, [ ])
  1224         SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
  1225         SUMMARY_audio="${SUMMARY_audio} disk"
  1226     fi
  1227 }
  1228 
  1229 dnl rcg03142006 See if the user wants the dummy audio driver...
  1230 CheckDummyAudio()
  1231 {
  1232     AC_ARG_ENABLE(dummyaudio,
  1233 AC_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=yes]]]),
  1234                   , enable_dummyaudio=yes)
  1235     if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then
  1236         AC_DEFINE(SDL_AUDIO_DRIVER_DUMMY, 1, [ ])
  1237         SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c"
  1238         SUMMARY_audio="${SUMMARY_audio} dummy"
  1239     fi
  1240 }
  1241 
  1242 dnl See if libsamplerate is available
  1243 CheckLibSampleRate()
  1244 {
  1245     AC_ARG_ENABLE(libsamplerate,
  1246 AC_HELP_STRING([--enable-libsamplerate], [use libsamplerate for audio rate conversion [[default=yes]]]),
  1247                   , enable_libsamplerate=yes)
  1248     if test x$enable_libsamplerate = xyes; then
  1249         AC_CHECK_HEADER(samplerate.h,
  1250                         have_samplerate_h_hdr=yes,
  1251                         have_samplerate_h_hdr=no)
  1252         if test x$have_samplerate_h_hdr = xyes; then
  1253             AC_DEFINE(HAVE_LIBSAMPLERATE_H, 1, [ ])
  1254 
  1255             AC_ARG_ENABLE(libsamplerate-shared,
  1256 AC_HELP_STRING([--enable-libsamplerate-shared], [dynamically load libsamplerate [[default=yes]]]),
  1257                           , enable_libsamplerate_shared=yes)
  1258 
  1259             samplerate_lib=[`find_lib "libsamplerate.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
  1260 
  1261             if test x$have_loadso != xyes && \
  1262                test x$enable_libsamplerate_shared = xyes; then
  1263                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic libsamplerate loading])
  1264             fi
  1265             if test x$have_loadso = xyes && \
  1266                test x$enable_libsamplerate_shared = xyes && test x$samplerate_lib != x; then
  1267                 echo "-- dynamic libsamplerate -> $samplerate_lib"
  1268                 AC_DEFINE_UNQUOTED(SDL_LIBSAMPLERATE_DYNAMIC, "$samplerate_lib", [ ])
  1269             else
  1270                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lsamplerate"
  1271             fi
  1272         fi
  1273     fi
  1274 }
  1275 
  1276 dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
  1277 dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
  1278 CheckVisibilityHidden()
  1279 {
  1280     AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
  1281     have_gcc_fvisibility=no
  1282 
  1283     visibility_CFLAGS="-fvisibility=hidden"
  1284     save_CFLAGS="$CFLAGS"
  1285     CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
  1286     AC_TRY_COMPILE([
  1287     #if !defined(__GNUC__) || __GNUC__ < 4
  1288     #error SDL only uses visibility attributes in GCC 4 or newer
  1289     #endif
  1290     ],[
  1291     ],[
  1292     have_gcc_fvisibility=yes
  1293     ])
  1294     AC_MSG_RESULT($have_gcc_fvisibility)
  1295     CFLAGS="$save_CFLAGS"
  1296 
  1297     if test x$have_gcc_fvisibility = xyes; then
  1298         EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
  1299     fi
  1300 }
  1301 
  1302 dnl See if GCC's -mpreferred-stack-boundary is supported.
  1303 dnl  Reference: http://bugzilla.libsdl.org/show_bug.cgi?id=1296
  1304 CheckStackBoundary()
  1305 {
  1306     AC_MSG_CHECKING(for GCC -mpreferred-stack-boundary option)
  1307     have_gcc_preferred_stack_boundary=no
  1308 
  1309     save_CFLAGS="$CFLAGS"
  1310     CFLAGS="$save_CFLAGS -mpreferred-stack-boundary=2"
  1311     AC_TRY_COMPILE([
  1312     int x = 0;
  1313     ],[
  1314     ],[
  1315     have_gcc_preferred_stack_boundary=yes
  1316     ])
  1317     AC_MSG_RESULT($have_gcc_preferred_stack_boundary)
  1318     CFLAGS="$save_CFLAGS"
  1319 
  1320     if test x$have_gcc_preferred_stack_boundary = xyes; then
  1321         EXTRA_CFLAGS="$EXTRA_CFLAGS -mpreferred-stack-boundary=2"
  1322     fi
  1323 }
  1324 
  1325 dnl See if GCC's -Wdeclaration-after-statement is supported.
  1326 dnl  This lets us catch things that would fail on a C89 compiler when using
  1327 dnl  a modern GCC.
  1328 CheckDeclarationAfterStatement()
  1329 {
  1330     AC_MSG_CHECKING(for GCC -Wdeclaration-after-statement option)
  1331     have_gcc_declaration_after_statement=no
  1332 
  1333     save_CFLAGS="$CFLAGS"
  1334     CFLAGS="$save_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement"
  1335     AC_TRY_COMPILE([
  1336     int x = 0;
  1337     ],[
  1338     ],[
  1339     have_gcc_declaration_after_statement=yes
  1340     ])
  1341     AC_MSG_RESULT($have_gcc_declaration_after_statement)
  1342     CFLAGS="$save_CFLAGS"
  1343 
  1344     if test x$have_gcc_declaration_after_statement = xyes; then
  1345         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement"
  1346     fi
  1347 }
  1348 
  1349 dnl See if GCC's -Wall is supported.
  1350 CheckWarnAll()
  1351 {
  1352     AC_MSG_CHECKING(for GCC -Wall option)
  1353     have_gcc_Wall=no
  1354 
  1355     save_CFLAGS="$CFLAGS"
  1356     CFLAGS="$save_CFLAGS -Wall"
  1357     AC_TRY_COMPILE([
  1358     int x = 0;
  1359     ],[
  1360     ],[
  1361     have_gcc_Wall=yes
  1362     ])
  1363     AC_MSG_RESULT($have_gcc_Wall)
  1364     CFLAGS="$save_CFLAGS"
  1365 
  1366     if test x$have_gcc_Wall = xyes; then
  1367         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
  1368 
  1369         dnl Haiku headers use multicharacter constants all over the place. Ignore these warnings when using -Wall.
  1370         AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
  1371         need_gcc_Wno_multichar=no
  1372         case "$host" in
  1373             *-*-haiku*)
  1374                 need_gcc_Wno_multichar=yes
  1375                 ;;
  1376         esac
  1377         AC_MSG_RESULT($need_gcc_Wno_multichar)
  1378         if test x$need_gcc_Wno_multichar = xyes; then
  1379             EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar"
  1380         fi
  1381     fi
  1382 }
  1383 
  1384 dnl Check for Wayland
  1385 CheckWayland()
  1386 {
  1387     AC_ARG_ENABLE(video-wayland,
  1388 AC_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]),
  1389                   ,enable_video_wayland=yes)
  1390 
  1391     AC_ARG_ENABLE(video-wayland-qt-touch,
  1392 AC_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for Wayland video driver [[default=yes]]]),
  1393                   ,enable_video_wayland_qt_touch=yes)
  1394 
  1395     if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
  1396         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1397         AC_MSG_CHECKING(for Wayland support)
  1398         video_wayland=no
  1399         if  test x$PKG_CONFIG != xno && \
  1400             test x$video_opengl_egl = xyes && \
  1401             test x$video_opengles_v2 = xyes; then
  1402             if $PKG_CONFIG --exists wayland-client wayland-scanner wayland-protocols wayland-egl wayland-cursor egl xkbcommon ; then
  1403                 WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
  1404                 WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
  1405                 WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
  1406                 video_wayland=yes
  1407             fi
  1408         fi
  1409         AC_MSG_RESULT($video_wayland)
  1410 
  1411         if test x$video_wayland = xyes; then
  1412             AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND, 1, [ ])
  1413             if test x$enable_video_wayland_qt_touch = xyes; then
  1414                 AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH, 1, [ ])
  1415             fi
  1416 
  1417             SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
  1418             EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)"
  1419             AC_ARG_ENABLE(wayland-shared,
  1420 AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[default=maybe]]]),
  1421                           , enable_wayland_shared=maybe)
  1422 
  1423             dnl FIXME: Do BSD and OS X need special cases?
  1424             case "$host" in
  1425                 *)
  1426                     wayland_client_lib=[`find_lib "libwayland-client.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1427                     wayland_egl_lib=[`find_lib "libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1428                     if test x$wayland_egl_lib = x; then
  1429                         dnl This works in Ubuntu 13.10, maybe others
  1430                         wayland_egl_lib=[`find_lib "mesa-egl/libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1431                     fi
  1432                     wayland_cursor_lib=[`find_lib "libwayland-cursor.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1433                     xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1434                     ;;
  1435             esac
  1436 
  1437             if test x$enable_wayland_shared = xmaybe; then
  1438                 enable_wayland_shared=yes
  1439             fi
  1440             if test x$have_loadso != xyes && \
  1441                test x$enable_wayland_shared = xyes; then
  1442                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Wayland loading])
  1443                 enable_wayland_shared=no
  1444             fi
  1445             if test x$have_loadso = xyes && \
  1446                test x$enable_wayland_shared = xyes && \
  1447                test x$wayland_client_lib != x && \
  1448                test x$wayland_egl_lib != x && \
  1449                test x$wayland_cursor_lib != x && \
  1450                test x$xkbcommon_lib != x; then
  1451                 echo "-- dynamic libwayland-client -> $wayland_client_lib"
  1452                 echo "-- dynamic libwayland-egl -> $wayland_egl_lib"
  1453                 echo "-- dynamic libwayland-cursor -> $wayland_cursor_lib"
  1454                 echo "-- dynamic libxkbcommon -> $xkbcommon_lib"
  1455                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC, "$wayland_client_lib", [ ])
  1456                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL, "$wayland_egl_lib", [ ])
  1457                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR, "$wayland_cursor_lib", [ ])
  1458                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ])
  1459                 SUMMARY_video="${SUMMARY_video} wayland(dynamic)"
  1460             else
  1461                 enable_wayland_shared=no
  1462                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
  1463                 SUMMARY_video="${SUMMARY_video} wayland"
  1464             fi
  1465             have_video=yes
  1466         fi
  1467     fi
  1468 }
  1469 
  1470 dnl Check for Mir
  1471 CheckMir()
  1472 {
  1473     AC_ARG_ENABLE(video-mir,
  1474 AC_HELP_STRING([--enable-video-mir], [use Mir video driver [[default=no]]]),
  1475                   ,enable_video_mir=no)
  1476 
  1477     if test x$enable_video = xyes -a x$enable_video_mir = xyes; then
  1478         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1479         AC_MSG_CHECKING(for Mir support)
  1480         video_mir=no
  1481         if test x$PKG_CONFIG != xno; then
  1482             if $PKG_CONFIG --exists mirclient egl xkbcommon ; then
  1483                 MIR_CFLAGS=`$PKG_CONFIG --cflags mirclient egl xkbcommon`
  1484                 MIR_LIBS=`$PKG_CONFIG --libs mirclient egl xkbcommon`
  1485                 save_CFLAGS="$CFLAGS"
  1486                 CFLAGS="$save_CFLAGS $MIR_CFLAGS"
  1487 
  1488                 dnl This will disable Mir if >= v0.26 is not available
  1489                 AC_TRY_COMPILE([
  1490                 #include <mir_toolkit/mir_client_library.h>
  1491                 ],[
  1492                     MirWindowAttrib attrib = mir_window_attrib_state
  1493                 ],[
  1494                 video_mir=yes
  1495                 ])
  1496                 CFLAGS="$save_CFLAGS"
  1497             fi
  1498         fi
  1499         AC_MSG_RESULT($video_mir)
  1500 
  1501         if test x$video_mir = xyes; then
  1502             AC_DEFINE(SDL_VIDEO_DRIVER_MIR, 1, [ ])
  1503             SOURCES="$SOURCES $srcdir/src/video/mir/*.c"
  1504             EXTRA_CFLAGS="$EXTRA_CFLAGS $MIR_CFLAGS"
  1505             AC_ARG_ENABLE(mir-shared,
  1506 AC_HELP_STRING([--enable-mir-shared], [dynamically load Mir support [[default=maybe]]]),
  1507                           , enable_mir_shared=maybe)
  1508 
  1509             dnl FIXME: Do BSD and OS X need special cases?
  1510             case "$host" in
  1511                 *)
  1512                     mirclient_lib=[`find_lib "libmirclient.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1513                     xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1514                     ;;
  1515             esac
  1516 
  1517             if test x$enable_mir_shared = xmaybe; then
  1518                 enable_mir_shared=yes
  1519             fi
  1520             if test x$have_loadso != xyes && \
  1521                test x$enable_mir_shared = xyes; then
  1522                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Mir loading])
  1523                 enable_mir_shared=no
  1524             fi
  1525             if test x$have_loadso = xyes && \
  1526                test x$enable_mir_shared = xyes && \
  1527                test x$mirclient_lib != x && \
  1528                test x$xkbcommon_lib != x; then
  1529                 echo "-- dynamic libmirclient -> $mirclient_lib"
  1530                 echo "-- dynamic libxkbcommon -> $xkbcommon_lib"
  1531                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_MIR_DYNAMIC, "$mirclient_lib", [ ])
  1532                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ])
  1533                 SUMMARY_video="${SUMMARY_video} mir(dynamic)"
  1534             else
  1535                 enable_mir_shared=no
  1536                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MIR_LIBS"
  1537                 SUMMARY_video="${SUMMARY_video} mir"
  1538             fi
  1539             have_video=yes
  1540         fi
  1541     fi
  1542 }
  1543 
  1544 dnl Check for Native Client stuff
  1545 CheckNativeClient()
  1546 {
  1547         AC_TRY_COMPILE([
  1548           #if !defined(__native_client__)
  1549           #error "NO NACL"
  1550           #endif
  1551         ],[
  1552         ],[
  1553         AC_DEFINE(SDL_VIDEO_DRIVER_NACL, 1, [ ])
  1554         AC_DEFINE(SDL_AUDIO_DRIVER_NACL, 1, [ ])
  1555         AC_DEFINE(HAVE_POW, 1, [ ])
  1556         AC_DEFINE(HAVE_OPENGLES2, 1, [ ])
  1557         AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  1558         AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  1559 
  1560         SDL_LIBS="-lppapi_simple -lppapi_gles2 $SDL_LIBS"
  1561 
  1562         SDLMAIN_SOURCES="$srcdir/src/main/nacl/*.c"
  1563         SOURCES="$SOURCES $srcdir/src/audio/nacl/*.c"
  1564         SUMMARY_audio="${SUMMARY_audio} nacl"
  1565         SOURCES="$SOURCES $srcdir/src/video/nacl/*.c"
  1566         SUMMARY_video="${SUMMARY_video} nacl opengles2"
  1567         ])
  1568 }
  1569 
  1570 
  1571 CheckRPI()
  1572 {
  1573     AC_ARG_ENABLE(video-rpi,
  1574 AC_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=yes]]]),
  1575                   , enable_video_rpi=yes)
  1576     if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then
  1577         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1578         if test x$PKG_CONFIG != xno && $PKG_CONFIG --exists bcm_host; then
  1579             RPI_CFLAGS=`$PKG_CONFIG --cflags bcm_host brcmegl`
  1580             RPI_LDFLAGS=`$PKG_CONFIG --libs bcm_host brcmegl`
  1581         elif test x$ARCH = xnetbsd; then
  1582             RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
  1583             RPI_LDFLAGS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
  1584         else
  1585             RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
  1586             RPI_LDFLAGS="-Wl,-rpath,/opt/vc/lib -L/opt/vc/lib -lbcm_host"
  1587         fi
  1588 
  1589         # Save the original compiler flags and libraries
  1590         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1591 
  1592         # Add the Raspberry Pi compiler flags and libraries
  1593         CFLAGS="$CFLAGS $RPI_CFLAGS"; LIBS="$LIBS $RPI_LDFLAGS"
  1594 
  1595         AC_MSG_CHECKING(for Raspberry Pi)
  1596         have_video_rpi=no
  1597         AC_TRY_LINK([
  1598           #include <bcm_host.h>
  1599         ],[
  1600           bcm_host_init();
  1601         ],[
  1602         have_video_rpi=yes
  1603         ],[
  1604         ])
  1605         AC_MSG_RESULT($have_video_rpi)
  1606 
  1607         # Restore the compiler flags and libraries
  1608         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1609         
  1610         if test x$have_video_rpi = xyes; then
  1611             CFLAGS="$CFLAGS $RPI_CFLAGS"
  1612             SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
  1613             EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
  1614             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $RPI_LDFLAGS"
  1615             SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
  1616             AC_DEFINE(SDL_VIDEO_DRIVER_RPI, 1, [ ])
  1617             SUMMARY_video="${SUMMARY_video} rpi"
  1618         fi
  1619     fi
  1620 }
  1621 
  1622 dnl Find the X11 include and library directories
  1623 CheckX11()
  1624 {
  1625     AC_ARG_ENABLE(video-x11,
  1626 AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
  1627                   , enable_video_x11=yes)
  1628     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
  1629         case "$host" in
  1630             *-*-darwin*)
  1631                 # This isn't necessary for X11, but fixes GLX detection
  1632                 if test "x$x_includes" = xNONE && \
  1633                    test "x$x_libraries" = xNONE && \
  1634                    test -d /usr/X11R6/include && \
  1635                    test -d /usr/X11R6/lib; then
  1636                     x_includes="/usr/X11R6/include"
  1637                     x_libraries="/usr/X11R6/lib"
  1638                 fi
  1639                 ;;
  1640         esac
  1641         AC_PATH_X
  1642         AC_PATH_XTRA
  1643         if test x$have_x = xyes; then
  1644             AC_ARG_ENABLE(x11-shared,
  1645 AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
  1646                           , enable_x11_shared=maybe)
  1647 
  1648             case "$host" in
  1649                 *-*-darwin*)
  1650                     x11_lib='/usr/X11R6/lib/libX11.6.dylib'
  1651                     x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
  1652                     xcursor_lib='/usr/X11R6/lib/libXcursor.1.dylib'
  1653                     xinerama_lib='/usr/X11R6/lib/libXinerama.1.dylib'
  1654                     xinput_lib='/usr/X11R6/lib/libXi.6.dylib'
  1655                     xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
  1656                     xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
  1657                     xss_lib='/usr/X11R6/lib/libXss.1.dylib'
  1658                     xvidmode_lib='/usr/X11R6/lib/libXxf86vm.1.dylib'
  1659                     ;;
  1660                 *-*-openbsd*)
  1661                     x11_lib='libX11.so'
  1662                     x11ext_lib='libXext.so'
  1663                     xcursor_lib='libXcursor.so'
  1664                     xinerama_lib='libXinerama.so'
  1665                     xinput_lib='libXi.so'
  1666                     xrandr_lib='libXrandr.so'
  1667                     xrender_lib='libXrender.so'
  1668                     xss_lib='libXss.so'
  1669                     xvidmode_lib='libXxf86vm.so'
  1670                     ;;
  1671                 *)
  1672                     x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1673                     x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1674                     xcursor_lib=[`find_lib "libXcursor.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1675                     xinerama_lib=[`find_lib "libXinerama.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1676                     xinput_lib=[`find_lib "libXi.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1677                     xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1678                     xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1679                     xss_lib=[`find_lib "libXss.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1680                     xvidmode_lib=[`find_lib "libXxf86vm.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1681                     ;;
  1682             esac
  1683 
  1684             if test x$ac_cv_func_shmat != xyes; then
  1685                 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
  1686             fi
  1687             CFLAGS="$CFLAGS $X_CFLAGS"
  1688             LDFLAGS="$LDFLAGS $X_LIBS"
  1689 
  1690             AC_CHECK_HEADER(X11/extensions/Xext.h,
  1691                             have_xext_h_hdr=yes,
  1692                             have_xext_h_hdr=no,
  1693                             [#include <X11/Xlib.h>
  1694                              #include <X11/Xproto.h>
  1695                             ])
  1696             if test x$have_xext_h_hdr != xyes; then
  1697                AC_MSG_ERROR([
  1698 *** Missing Xext.h, maybe you need to install the libxext-dev package?
  1699                ])
  1700             fi
  1701 
  1702             AC_DEFINE(SDL_VIDEO_DRIVER_X11, 1, [ ])
  1703             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
  1704             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
  1705 
  1706             # Needed so SDL applications can include SDL_syswm.h
  1707             SDL_CFLAGS="$SDL_CFLAGS $X_CFLAGS"
  1708 
  1709             if test x$enable_x11_shared = xmaybe; then
  1710                 enable_x11_shared=yes
  1711             fi
  1712             if test x$have_loadso != xyes && \
  1713                test x$enable_x11_shared = xyes; then
  1714                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
  1715                 enable_x11_shared=no
  1716             fi
  1717             if test x$have_loadso = xyes && \
  1718                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
  1719                 echo "-- dynamic libX11 -> $x11_lib"
  1720                 echo "-- dynamic libX11ext -> $x11ext_lib"
  1721                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib", [ ])
  1722                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib", [ ])
  1723                 SUMMARY_video="${SUMMARY_video} x11(dynamic)"
  1724             else
  1725                 enable_x11_shared=no
  1726                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
  1727                 SUMMARY_video="${SUMMARY_video} x11"
  1728             fi
  1729             have_video=yes
  1730 
  1731             AC_MSG_CHECKING(for const parameter to XextAddDisplay)
  1732             have_const_param_XextAddDisplay=no
  1733             AC_TRY_COMPILE([
  1734               #include <X11/Xlib.h>
  1735               #include <X11/Xproto.h>
  1736               #include <X11/extensions/Xext.h>
  1737               #include <X11/extensions/extutil.h>
  1738               extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
  1739             ],[
  1740             ],[
  1741             have_const_param_XextAddDisplay=yes
  1742             AC_DEFINE([SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY], 1, [ ])
  1743             ])
  1744             AC_MSG_RESULT($have_const_param_XextAddDisplay)
  1745 
  1746             dnl AC_CHECK_LIB(X11, XGetEventData, AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS, 1, [Have XGenericEvent]))
  1747             AC_MSG_CHECKING([for XGenericEvent])
  1748             have_XGenericEvent=no
  1749             AC_TRY_COMPILE([
  1750               	#include <X11/Xlib.h>
  1751             ],[
  1752 Display *display;
  1753 XEvent event;
  1754 XGenericEventCookie *cookie = &event.xcookie;
  1755 XNextEvent(display, &event);
  1756 XGetEventData(display, cookie);
  1757 XFreeEventData(display, cookie);
  1758             ],[
  1759                 have_XGenericEvent=yes
  1760                 AC_DEFINE([SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS], 1, [ ])
  1761             ])
  1762             AC_MSG_RESULT($have_XGenericEvent)
  1763 
  1764             AC_CHECK_LIB(X11, XkbKeycodeToKeysym, AC_DEFINE(SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM, 1, [Have XkbKeycodeToKeysym]))
  1765 
  1766             AC_ARG_ENABLE(video-x11-xcursor,
  1767 AC_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[default=yes]]]),
  1768                             , enable_video_x11_xcursor=yes)
  1769             if test x$enable_video_x11_xcursor = xyes; then
  1770                 definitely_enable_video_x11_xcursor=no
  1771                 AC_CHECK_HEADER(X11/Xcursor/Xcursor.h,
  1772                                 have_xcursor_h_hdr=yes,
  1773                                 have_xcursor_h_hdr=no,
  1774                                 [#include <X11/Xlib.h>
  1775                                 ])
  1776                 if test x$have_xcursor_h_hdr = xyes; then
  1777                     if test x$enable_x11_shared = xyes && test x$xcursor_lib != x ; then
  1778                         echo "-- dynamic libXcursor -> $xcursor_lib"
  1779                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR, "$xcursor_lib", [ ])
  1780                         definitely_enable_video_x11_xcursor=yes
  1781                     else
  1782                         AC_CHECK_LIB(Xcursor, XcursorImageCreate, have_xcursor_lib=yes)
  1783                         if test x$have_xcursor_lib = xyes ; then
  1784                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXcursor"
  1785                             definitely_enable_video_x11_xcursor=yes
  1786                         fi
  1787                     fi
  1788                 fi
  1789             fi
  1790             if test x$definitely_enable_video_x11_xcursor = xyes; then
  1791                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XCURSOR, 1, [ ])
  1792                 SUMMARY_video_x11="${SUMMARY_video_x11} xcursor"
  1793             fi
  1794             AC_ARG_ENABLE(video-x11-xdbe,
  1795 AC_HELP_STRING([--enable-video-x11-xdbe], [enable X11 Xdbe support [[default=yes]]]),
  1796                             , enable_video_x11_xdbe=yes)
  1797             if test x$enable_video_x11_xdbe = xyes; then
  1798                 AC_CHECK_HEADER(X11/extensions/Xdbe.h,
  1799                                 have_dbe_h_hdr=yes,
  1800                                 have_dbe_h_hdr=no,
  1801                                 [#include <X11/Xlib.h>
  1802                                 ])
  1803                 if test x$have_dbe_h_hdr = xyes; then
  1804                     AC_DEFINE(SDL_VIDEO_DRIVER_X11_XDBE, 1, [ ])
  1805                     SUMMARY_video_x11="${SUMMARY_video_x11} xdbe"
  1806                 fi
  1807             fi
  1808             AC_ARG_ENABLE(video-x11-xinerama,
  1809 AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
  1810                             , enable_video_x11_xinerama=yes)
  1811             if test x$enable_video_x11_xinerama = xyes; then
  1812                 definitely_enable_video_x11_xinerama=no
  1813                 AC_CHECK_HEADER(X11/extensions/Xinerama.h,
  1814                                 have_xinerama_h_hdr=yes,
  1815                                 have_xinerama_h_hdr=no,
  1816                                 [#include <X11/Xlib.h>
  1817                                 ])
  1818                 if test x$have_xinerama_h_hdr = xyes; then
  1819                     if test x$enable_x11_shared = xyes && test x$xinerama_lib != x ; then
  1820                         echo "-- dynamic libXinerama -> $xinerama_lib"
  1821                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA, "$xinerama_lib", [ ])
  1822                         definitely_enable_video_x11_xinerama=yes
  1823                     else
  1824                         AC_CHECK_LIB(Xinerama, XineramaQueryExtension, have_xinerama_lib=yes)
  1825                         if test x$have_xinerama_lib = xyes ; then
  1826                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXinerama"
  1827                             definitely_enable_video_x11_xinerama=yes
  1828                         fi
  1829                     fi
  1830                 fi
  1831             fi
  1832             if test x$definitely_enable_video_x11_xinerama = xyes; then
  1833                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA, 1, [ ])
  1834                 SUMMARY_video_x11="${SUMMARY_video_x11} xinerama"
  1835             fi
  1836             AC_ARG_ENABLE(video-x11-xinput,
  1837 AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
  1838                             , enable_video_x11_xinput=yes)
  1839             if test x$enable_video_x11_xinput = xyes; then
  1840                 definitely_enable_video_x11_xinput=no
  1841                 AC_CHECK_HEADER(X11/extensions/XInput2.h,
  1842                                 have_xinput_h_hdr=yes,
  1843                                 have_xinput_h_hdr=no,
  1844                                 [#include <X11/Xlib.h>
  1845                                 ])
  1846                 if test x$have_xinput_h_hdr = xyes; then
  1847                     if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
  1848                         echo "-- dynamic libXi -> $xinput_lib"
  1849                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2, "$xinput_lib", [ ])
  1850                         definitely_enable_video_x11_xinput=yes
  1851                     else
  1852                         AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
  1853                         if test x$have_xinput_lib = xyes ; then
  1854                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
  1855                             definitely_enable_video_x11_xinput=yes
  1856                         fi
  1857                     fi
  1858                 fi
  1859             fi
  1860             if test x$definitely_enable_video_x11_xinput = xyes; then
  1861                 SUMMARY_video_x11="${SUMMARY_video_x11} xinput2"
  1862                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ])
  1863                 AC_MSG_CHECKING(for xinput2 multitouch)
  1864             	have_xinput2_multitouch=no
  1865             	AC_TRY_COMPILE([
  1866               		#include <X11/Xlib.h>
  1867              		#include <X11/Xproto.h>
  1868 			#include <X11/extensions/XInput2.h>
  1869             	],[
  1870 int event_type = XI_TouchBegin;
  1871 XITouchClassInfo *t;
  1872             	],[
  1873             	have_xinput2_multitouch=yes
  1874             	AC_DEFINE([SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH], 1, [])
  1875                 SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch"
  1876             	])
  1877             	AC_MSG_RESULT($have_xinput2_multitouch)
  1878             fi
  1879             AC_ARG_ENABLE(video-x11-xrandr,
  1880 AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
  1881                             , enable_video_x11_xrandr=yes)
  1882             if test x$enable_video_x11_xrandr = xyes; then
  1883                 dnl XRRScreenResources is only present in Xrandr >= 1.2, we use that as a test.
  1884                 definitely_enable_video_x11_xrandr=no
  1885                 have_xrandr_h_hdr=no
  1886                 AC_TRY_COMPILE([
  1887                 #include <X11/Xlib.h>
  1888                 #include <X11/extensions/Xrandr.h>
  1889                 ],[
  1890                 XRRScreenResources *res = NULL;
  1891                 ],[
  1892                 have_xrandr_h_hdr=yes
  1893                 ])
  1894                 if test x$have_xrandr_h_hdr = xyes; then
  1895                     if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
  1896                         echo "-- dynamic libXrandr -> $xrandr_lib"
  1897                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib", [ ])
  1898                         definitely_enable_video_x11_xrandr=yes
  1899                     else
  1900                         AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
  1901                         if test x$have_xrandr_lib = xyes ; then
  1902                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr"
  1903                             definitely_enable_video_x11_xrandr=yes
  1904                         fi
  1905                     fi
  1906                 fi
  1907             fi
  1908             if test x$definitely_enable_video_x11_xrandr = xyes; then
  1909                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR, 1, [ ])
  1910                 SUMMARY_video_x11="${SUMMARY_video_x11} xrandr"
  1911             fi
  1912             AC_ARG_ENABLE(video-x11-scrnsaver,
  1913 AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
  1914                             , enable_video_x11_scrnsaver=yes)
  1915             if test x$enable_video_x11_scrnsaver = xyes; then
  1916                 AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
  1917                                 have_scrnsaver_h_hdr=yes,
  1918                                 have_scrnsaver_h_hdr=no,
  1919                                 [#include <X11/Xlib.h>
  1920                                 ])
  1921                 if test x$have_scrnsaver_h_hdr = xyes; then
  1922                     if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
  1923                         echo "-- dynamic libXss -> $xss_lib"
  1924                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib", [ ])
  1925                         definitely_enable_video_x11_scrnsaver=yes
  1926                     else
  1927                         AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
  1928                         if test x$have_xss_lib = xyes ; then
  1929                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
  1930                             definitely_enable_video_x11_scrnsaver=yes
  1931                         fi
  1932                     fi
  1933                 fi
  1934             fi
  1935             if test x$definitely_enable_video_x11_scrnsaver = xyes; then
  1936                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSCRNSAVER, 1, [ ])
  1937                 SUMMARY_video_x11="${SUMMARY_video_x11} xscrnsaver"
  1938             fi
  1939             AC_ARG_ENABLE(video-x11-xshape,
  1940 AC_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default=yes]]]),
  1941                             , enable_video_x11_xshape=yes)
  1942             if test x$enable_video_x11_xshape = xyes; then
  1943                 AC_CHECK_HEADER(X11/extensions/shape.h,
  1944                                 have_shape_h_hdr=yes,
  1945                                 have_shape_h_hdr=no,
  1946                                 [#include <X11/Xlib.h>
  1947                                 ])
  1948                 if test x$have_shape_h_hdr = xyes; then
  1949                     AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSHAPE, 1, [ ])
  1950                     SUMMARY_video_x11="${SUMMARY_video_x11} xshape"
  1951                 fi
  1952             fi
  1953             AC_ARG_ENABLE(video-x11-vm,
  1954 AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
  1955                             , enable_video_x11_vm=yes)
  1956             if test x$enable_video_x11_vm = xyes; then
  1957                 definitely_enable_video_x11_vm=no
  1958                 AC_CHECK_HEADER(X11/extensions/xf86vmode.h,
  1959                                 have_vm_h_hdr=yes,
  1960                                 have_vm_h_hdr=no,
  1961                                 [#include <X11/Xlib.h>
  1962                                 ])
  1963                 if test x$have_vm_h_hdr = xyes; then
  1964                     if test x$enable_x11_shared = xyes && test x$xvidmode_lib != x ; then
  1965                         echo "-- dynamic libXxf86vm -> $xvidmode_lib"
  1966                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE, "$xvidmode_lib", [ ])
  1967                         definitely_enable_video_x11_vm=yes
  1968                     else
  1969                         AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion, have_vm_lib=yes)
  1970                         if test x$have_vm_lib = xyes ; then
  1971                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXxf86vm"
  1972                             definitely_enable_video_x11_vm=yes
  1973                         fi
  1974                     fi
  1975                 fi
  1976             fi
  1977             if test x$definitely_enable_video_x11_vm = xyes; then
  1978                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XVIDMODE, 1, [ ])
  1979                 SUMMARY_video_x11="${SUMMARY_video_x11} xvidmode"
  1980             fi
  1981         fi
  1982     fi
  1983 }
  1984 
  1985 dnl Set up the Vivante video driver if enabled
  1986 CheckVivanteVideo()
  1987 {
  1988     AC_ARG_ENABLE(video-vivante,
  1989 AC_HELP_STRING([--enable-video-vivante], [use Vivante EGL video driver [[default=yes]]]),
  1990                   , enable_video_vivante=yes)
  1991     if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then
  1992         AC_MSG_CHECKING(for Vivante VDK API)
  1993         have_vivante_vdk=no
  1994         AC_TRY_COMPILE([
  1995           #define LINUX
  1996           #define EGL_API_FB
  1997           #include <gc_vdk.h>
  1998         ],[
  1999         ],[
  2000         have_vivante_vdk=yes
  2001         ])
  2002         AC_MSG_RESULT($have_vivante_vdk)
  2003 
  2004         AC_MSG_CHECKING(for Vivante FB API)
  2005         have_vivante_egl=no
  2006         AC_TRY_COMPILE([
  2007           #define LINUX
  2008           #define EGL_API_FB
  2009           #include <EGL/eglvivante.h>
  2010         ],[
  2011         ],[
  2012         have_vivante_egl=yes
  2013         ])
  2014         AC_MSG_RESULT($have_vivante_egl)
  2015 
  2016         if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then
  2017             AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE, 1, [ ])
  2018             EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB"
  2019             if test x$have_vivante_vdk = xyes; then
  2020                 AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE_VDK, 1, [ ])
  2021                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK"
  2022             fi
  2023             SOURCES="$SOURCES $srcdir/src/video/vivante/*.c"
  2024             SUMMARY_video="${SUMMARY_video} vivante"
  2025             have_video=yes
  2026         fi
  2027     fi
  2028 }
  2029 
  2030 dnl Set up the Haiku video driver if enabled
  2031 CheckHaikuVideo()
  2032 {
  2033     if test x$enable_video = xyes; then
  2034         AC_DEFINE(SDL_VIDEO_DRIVER_HAIKU, 1, [ ])
  2035         SOURCES="$SOURCES $srcdir/src/video/haiku/*.cc"
  2036         have_video=yes
  2037         SUMMARY_video="${SUMMARY_video} haiku"
  2038     fi
  2039 }
  2040 
  2041 dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
  2042 CheckCOCOA()
  2043 {
  2044     AC_ARG_ENABLE(video-cocoa,
  2045 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
  2046                   , enable_video_cocoa=yes)
  2047     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  2048         save_CFLAGS="$CFLAGS"
  2049         dnl Work around that we don't have Objective-C support in autoconf
  2050         CFLAGS="$CFLAGS -x objective-c"
  2051         AC_MSG_CHECKING(for Cocoa framework)
  2052         have_cocoa=no
  2053         AC_TRY_COMPILE([
  2054           #import <Cocoa/Cocoa.h>
  2055         ],[
  2056         ],[
  2057         have_cocoa=yes
  2058         ])
  2059         AC_MSG_RESULT($have_cocoa)
  2060         CFLAGS="$save_CFLAGS"
  2061         if test x$have_cocoa = xyes; then
  2062             AC_DEFINE(SDL_VIDEO_DRIVER_COCOA, 1, [ ])
  2063             SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
  2064             SUMMARY_video="${SUMMARY_video} cocoa"
  2065             have_video=yes
  2066         fi
  2067     fi
  2068 }
  2069 
  2070 CheckMETAL()
  2071 {
  2072     AC_ARG_ENABLE(render-metal,
  2073 AC_HELP_STRING([--enable-render-metal], [enable the Metal render driver [[default=yes]]]),
  2074                                 , enable_render_metal=yes)
  2075     if test x$enable_render = xyes -a x$enable_render_metal = xyes; then
  2076         save_CFLAGS="$CFLAGS"
  2077         dnl Work around that we don't have Objective-C support in autoconf
  2078         CFLAGS="$CFLAGS -x objective-c"
  2079         AC_MSG_CHECKING(for Metal framework)
  2080         have_metal=no
  2081         AC_TRY_COMPILE([
  2082           #import <Cocoa/Cocoa.h>
  2083           #import <Metal/Metal.h>
  2084           #import <QuartzCore/CAMetalLayer.h>
  2085 
  2086           #if !TARGET_CPU_X86_64
  2087           #error Metal doesn't work on this configuration
  2088           #endif
  2089         ],[
  2090         ],[
  2091         have_metal=yes
  2092         ])
  2093         CFLAGS="$save_CFLAGS"
  2094         AC_MSG_RESULT($have_metal)
  2095         if test x$have_metal = xyes; then
  2096             AC_DEFINE(SDL_VIDEO_RENDER_METAL, 1, [ ])
  2097             SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
  2098             SUMMARY_video="${SUMMARY_video} metal"
  2099         else
  2100             enable_render_metal=no
  2101         fi
  2102     fi
  2103 }
  2104 
  2105 
  2106 dnl Find DirectFB
  2107 CheckDirectFB()
  2108 {
  2109     AC_ARG_ENABLE(video-directfb,
  2110 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
  2111                   , enable_video_directfb=no)
  2112     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  2113         video_directfb=no
  2114 
  2115         DIRECTFB_REQUIRED_VERSION=1.0.0
  2116         AC_PATH_PROGS(DIRECTFBCONFIG, directfb-config, no, [$prefix/bin:$PATH])
  2117         if test x$DIRECTFBCONFIG = xno; then
  2118             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2119             if test x$PKG_CONFIG != xno; then
  2120                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
  2121                     DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
  2122                     DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
  2123                     DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
  2124                     video_directfb=yes
  2125                 fi
  2126             fi
  2127         else
  2128             set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
  2129             NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  2130             set -- `$DIRECTFBCONFIG --version | sed 's/\./ /g'`
  2131             HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  2132             if test $HAVE_VERSION -ge $NEED_VERSION; then
  2133                 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
  2134                 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
  2135                 DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
  2136                 video_directfb=yes
  2137             fi
  2138         fi
  2139         if test x$video_directfb = xyes; then
  2140             # SuSE 11.1 installs directfb-config without directfb-devel
  2141             save_CPPFLAGS="$CPPFLAGS"
  2142             CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
  2143             AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
  2144             CPPFLAGS="$save_CPPFLAGS"
  2145             video_directfb=$have_directfb_hdr
  2146         fi
  2147         AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  2148         AC_MSG_RESULT($video_directfb)
  2149 
  2150         if test x$video_directfb = xyes; then
  2151             AC_ARG_ENABLE(directfb-shared,
  2152 AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
  2153                               , enable_directfb_shared=yes)
  2154 
  2155             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB, 1, [ ])
  2156             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  2157             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  2158 
  2159             AC_MSG_CHECKING(for directfb dynamic loading support)
  2160             directfb_shared=no
  2161             directfb_lib=[`find_lib "libdirectfb*.so.*" "$DIRECTFB_LIBS"`]
  2162             # | sed 's/.*\/\(.*\)/\1/; q'`]
  2163 AC_MSG_WARN("directfb $directfb_lib")
  2164             if test x$have_loadso != xyes && \
  2165                test x$enable_directfb_shared = xyes; then
  2166                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
  2167             fi
  2168             if test x$have_loadso = xyes && \
  2169                test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
  2170                 directfb_shared=yes
  2171                 echo "-- $directfb_lib_spec -> $directfb_lib"
  2172                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib", [ ])
  2173                 SUMMARY_video="${SUMMARY_video} directfb(dynamic)"
  2174             else
  2175                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  2176                 SUMMARY_video="${SUMMARY_video} directfb"
  2177             fi
  2178             AC_MSG_RESULT($directfb_shared)
  2179             SDL_CFLAGS="$SDL_CFLAGS $DIRECTFB_CFLAGS"
  2180             have_video=yes
  2181         fi
  2182     fi
  2183 }
  2184 
  2185 dnl Find KMSDRM
  2186 CheckKMSDRM()
  2187 {
  2188     AC_ARG_ENABLE(video-kmsdrm,
  2189 AC_HELP_STRING([--enable-video-kmsdrm], [use KMSDRM video driver [[default=no]]]),
  2190                   , enable_video_kmsdrm=no)
  2191 
  2192     if test x$enable_video = xyes -a x$enable_video_kmsdrm = xyes; then
  2193         video_kmsdrm=no
  2194         libdrm_avail=no
  2195         libgbm_avail=no
  2196 
  2197         LIBDRM_REQUIRED_VERSION=2.4.46
  2198         LIBGBM_REQUIRED_VERSION=9.0.0
  2199 
  2200         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2201         if test x$PKG_CONFIG != xno; then
  2202             if $PKG_CONFIG --atleast-pkgconfig-version 0.7; then
  2203                 if $PKG_CONFIG --atleast-version $LIBDRM_REQUIRED_VERSION libdrm; then
  2204                     LIBDRM_CFLAGS=`$PKG_CONFIG --cflags libdrm`
  2205                     LIBDRM_LIBS=`$PKG_CONFIG --libs libdrm`
  2206                     LIBDRM_PREFIX=`$PKG_CONFIG --variable=prefix libdrm`
  2207                     libdrm_avail=yes
  2208                 fi
  2209                 if $PKG_CONFIG --atleast-version $LIBGBM_REQUIRED_VERSION gbm; then
  2210                     LIBGBM_CFLAGS=`$PKG_CONFIG --cflags gbm`
  2211                     LIBGBM_LIBS=`$PKG_CONFIG --libs gbm`
  2212                     LIBGBM_PREFIX=`$PKG_CONFIG --variable=prefix gbm`
  2213                     libgbm_avail=yes
  2214                 fi
  2215                 if test x$libdrm_avail = xyes -a x$libgbm_avail = xyes; then
  2216                     video_kmsdrm=yes
  2217                 fi
  2218  
  2219                 AC_MSG_CHECKING(for libdrm $LIBDRM_REQUIRED_VERSION library for kmsdrm support)
  2220                 AC_MSG_RESULT($libdrm_avail)
  2221                 AC_MSG_CHECKING(for libgbm $LIBGBM_REQUIRED_VERSION library for kmsdrm support)
  2222                 AC_MSG_RESULT($libgbm_avail)
  2223 
  2224                 if test x$video_kmsdrm = xyes; then
  2225                     AC_ARG_ENABLE(kmsdrm-shared,
  2226 AC_HELP_STRING([--enable-kmsdrm-shared], [dynamically load kmsdrm support [[default=yes]]]),
  2227                               , enable_kmsdrm_shared=yes)
  2228 
  2229                     AC_DEFINE(SDL_VIDEO_DRIVER_KMSDRM, 1, [ ])
  2230                     SOURCES="$SOURCES $srcdir/src/video/kmsdrm/*.c"
  2231                     EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBDRM_CFLAGS $LIBGBM_CFLAGS"
  2232 
  2233                     AC_MSG_CHECKING(for kmsdrm dynamic loading support)
  2234                     kmsdrm_shared=no
  2235                     drm_lib=[`find_lib "libdrm.so.*" "$DRM_LIBS"`]
  2236                     gbm_lib=[`find_lib "libgbm.so.*" "$DRM_LIBS"`]
  2237                     if test x$have_loadso != xyes && \
  2238                        test x$enable_kmsdrm_shared = xyes; then
  2239                         AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic kmsdrm loading])
  2240                     fi
  2241                     if test x$have_loadso = xyes && \
  2242                        test x$enable_kmsdrm_shared = xyes && test x$drm_lib != x && test x$gbm_lib != x; then
  2243                         kmsdrm_shared=yes
  2244                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC, "$drm_lib", [ ])
  2245                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM, "$gbm_lib", [ ])
  2246                         AC_DEFINE_UNQUOTED(HAVE_KMSDRM_SHARED, "TRUE", [ ])
  2247                         SUMMARY_video="${SUMMARY_video} kmsdrm(dynamic)"
  2248                     else
  2249                         EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBDRM_LIBS $LIBGBM_LIBS"
  2250                         SUMMARY_video="${SUMMARY_video} kmsdrm"
  2251                     fi
  2252                     AC_MSG_RESULT($kmsdrm_shared)
  2253                     have_video=yes
  2254                 fi
  2255             fi
  2256         fi
  2257     fi
  2258 }
  2259 
  2260 dnl rcg04172001 Set up the Null video driver.
  2261 CheckDummyVideo()
  2262 {
  2263     AC_ARG_ENABLE(video-dummy,
  2264 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  2265                   , enable_video_dummy=yes)
  2266     if test x$enable_video_dummy = xyes; then
  2267         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY, 1, [ ])
  2268         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  2269         have_video=yes
  2270         SUMMARY_video="${SUMMARY_video} dummy"
  2271     fi
  2272 }
  2273 
  2274 dnl Set up the QNX video driver if enabled
  2275 CheckQNXVideo()
  2276 {
  2277     if test x$enable_video = xyes; then
  2278         AC_DEFINE(SDL_VIDEO_DRIVER_QNX, 1, [ ])
  2279         SOURCES="$SOURCES $srcdir/src/video/qnx/*.c"
  2280         have_video=yes
  2281         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lscreen -lEGL -lGLESv2"
  2282         SUMMARY_video="${SUMMARY_video} qnx"
  2283     fi
  2284 }
  2285 
  2286 dnl Set up the QNX audio driver if enabled
  2287 CheckQNXAudio()
  2288 {
  2289     if test x$enable_audio = xyes; then
  2290         AC_DEFINE(SDL_AUDIO_DRIVER_QSA, 1, [ ])
  2291         SOURCES="$SOURCES $srcdir/src/audio/qsa/*.c"
  2292         have_audio=yes
  2293         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
  2294         SUMMARY_audio="${SUMMARY_audio} qsa"
  2295     fi
  2296 }
  2297 
  2298 dnl Check to see if OpenGL support is desired
  2299 AC_ARG_ENABLE(video-opengl,
  2300 AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  2301               , enable_video_opengl=yes)
  2302 
  2303 dnl Find OpenGL
  2304 CheckOpenGLX11()
  2305 {
  2306     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  2307         AC_MSG_CHECKING(for OpenGL (GLX) support)
  2308         video_opengl=no
  2309         AC_TRY_COMPILE([
  2310          #include <GL/gl.h>
  2311          #include <GL/glx.h>
  2312         ],[
  2313         ],[
  2314         video_opengl=yes
  2315         ])
  2316         AC_MSG_RESULT($video_opengl)
  2317         if test x$video_opengl = xyes; then
  2318             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2319             AC_DEFINE(SDL_VIDEO_OPENGL_GLX, 1, [ ])
  2320             AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  2321             SUMMARY_video="${SUMMARY_video} opengl"
  2322         fi
  2323     fi
  2324 }
  2325 
  2326 dnl Check to see if OpenGL ES support is desired
  2327 AC_ARG_ENABLE(video-opengles,
  2328 AC_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]),
  2329               , enable_video_opengles=yes)
  2330 AC_ARG_ENABLE(video-opengles1,
  2331 AC_HELP_STRING([--enable-video-opengles1], [include OpenGL ES 1.1 support [[default=yes]]]),
  2332               , enable_video_opengles1=yes)
  2333 AC_ARG_ENABLE(video-opengles2,
  2334 AC_HELP_STRING([--enable-video-opengles2], [include OpenGL ES 2.0 support [[default=yes]]]),
  2335               , enable_video_opengles2=yes)
  2336 
  2337 dnl Find OpenGL ES
  2338 CheckOpenGLESX11()
  2339 {
  2340     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  2341         AC_MSG_CHECKING(for EGL support)
  2342         video_opengl_egl=no
  2343         AC_TRY_COMPILE([
  2344           #define LINUX
  2345           #define EGL_API_FB
  2346           #include <EGL/egl.h>
  2347           #include <EGL/eglext.h>
  2348         ],[
  2349         ],[
  2350         video_opengl_egl=yes
  2351         ])
  2352         AC_MSG_RESULT($video_opengl_egl)
  2353         if test x$video_opengl_egl = xyes; then
  2354             AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
  2355         fi
  2356             
  2357         if test x$enable_video_opengles1 = xyes; then
  2358             AC_MSG_CHECKING(for OpenGL ES v1 headers)
  2359             video_opengles_v1=no
  2360             AC_TRY_COMPILE([
  2361              #include <GLES/gl.h>
  2362              #include <GLES/glext.h>
  2363             ],[
  2364             ],[
  2365             video_opengles_v1=yes
  2366             ])
  2367             AC_MSG_RESULT($video_opengles_v1)
  2368             if test x$video_opengles_v1 = xyes; then
  2369                 AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
  2370                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
  2371                 SUMMARY_video="${SUMMARY_video} opengl_es1"
  2372             fi
  2373         fi
  2374         
  2375         if test x$enable_video_opengles2 = xyes; then
  2376             AC_MSG_CHECKING(for OpenGL ES v2 headers)
  2377             video_opengles_v2=no
  2378             AC_TRY_COMPILE([
  2379              #include <GLES2/gl2.h>
  2380              #include <GLES2/gl2ext.h>
  2381             ],[
  2382             ],[
  2383             video_opengles_v2=yes
  2384             ])
  2385             AC_MSG_RESULT($video_opengles_v2)
  2386             if test x$video_opengles_v2 = xyes; then
  2387                 AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  2388                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  2389                 SUMMARY_video="${SUMMARY_video} opengl_es2"
  2390             fi
  2391         fi
  2392     fi
  2393 }
  2394 
  2395 dnl Check for Windows OpenGL
  2396 CheckWINDOWSGL()
  2397 {
  2398     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  2399         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2400         AC_DEFINE(SDL_VIDEO_OPENGL_WGL, 1, [ ])
  2401         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  2402         SUMMARY_video="${SUMMARY_video} opengl"
  2403     fi
  2404 }
  2405 
  2406 dnl Check for Windows OpenGL
  2407 CheckWINDOWSGLES()
  2408 {
  2409     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  2410 
  2411         AC_MSG_CHECKING(for EGL support)
  2412         video_opengl_egl=no
  2413         AC_TRY_COMPILE([
  2414          #include <EGL/egl.h>
  2415         ],[
  2416         ],[
  2417         video_opengl_egl=yes
  2418         ])
  2419         AC_MSG_RESULT($video_opengl_egl)
  2420         if test x$video_opengl_egl = xyes; then
  2421             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2422             AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
  2423             SUMMARY_video="${SUMMARY_video} opengl_es1"
  2424         fi
  2425        
  2426         AC_MSG_CHECKING(for OpenGL ES v2 headers)
  2427         video_opengles_v2=no
  2428         AC_TRY_COMPILE([
  2429          #include <GLES2/gl2.h>
  2430          #include <GLES2/gl2ext.h>
  2431         ],[
  2432         ],[
  2433         video_opengles_v2=yes
  2434         ])
  2435         AC_MSG_RESULT($video_opengles_v2)
  2436         if test x$video_opengles_v2 = xyes; then
  2437             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2438             AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  2439             AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  2440             SUMMARY_video="${SUMMARY_video} opengl_es2"
  2441         fi
  2442     fi
  2443 }
  2444 
  2445 dnl Check for Haiku OpenGL
  2446 CheckHaikuGL()
  2447 {
  2448     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  2449         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2450         AC_DEFINE(SDL_VIDEO_OPENGL_HAIKU, 1, [ ])
  2451         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  2452         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  2453         SUMMARY_video="${SUMMARY_video} opengl"
  2454     fi
  2455 }
  2456 
  2457 dnl Check for MacOS OpenGL
  2458 CheckMacGL()
  2459 {
  2460     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  2461         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2462         AC_DEFINE(SDL_VIDEO_OPENGL_CGL, 1, [ ])
  2463         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  2464         SUMMARY_video="${SUMMARY_video} opengl"
  2465     fi
  2466 }
  2467 
  2468 dnl Check for MacOS OpenGLES
  2469 CheckMacGLES()
  2470 {
  2471     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  2472         video_opengl_egl=yes
  2473         AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
  2474         video_opengles_v2=yes
  2475         AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  2476         AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  2477         SUMMARY_video="${SUMMARY_video} opengl_es2"
  2478     fi
  2479 }
  2480 
  2481 CheckEmscriptenGLES()
  2482 {
  2483     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  2484         AC_MSG_CHECKING(for EGL support)
  2485         video_opengl_egl=no
  2486         AC_TRY_COMPILE([
  2487          #include <EGL/egl.h>
  2488         ],[
  2489         ],[
  2490         video_opengl_egl=yes
  2491         ])
  2492         AC_MSG_RESULT($video_opengl_egl)
  2493         if test x$video_opengl_egl = xyes; then
  2494             AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
  2495         fi
  2496 
  2497         AC_MSG_CHECKING(for OpenGL ES v2 headers)
  2498         video_opengles_v2=no
  2499         AC_TRY_COMPILE([
  2500          #include <GLES2/gl2.h>
  2501          #include <GLES2/gl2ext.h>
  2502         ],[
  2503         ],[
  2504         video_opengles_v2=yes
  2505         ])
  2506         AC_MSG_RESULT($video_opengles_v2)
  2507         if test x$video_opengles_v2 = xyes; then
  2508             AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  2509             AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  2510             SUMMARY_video="${SUMMARY_video} opengl_es2"
  2511         fi
  2512     fi
  2513 }
  2514 
  2515 dnl Check to see if Vulkan support is desired
  2516 AC_ARG_ENABLE(video-vulkan,
  2517 AC_HELP_STRING([--enable-video-vulkan], [include Vulkan support [[default=yes]]]),
  2518               , enable_video_vulkan=yes)
  2519 
  2520 dnl Find Vulkan Header
  2521 CheckVulkan()
  2522 {
  2523     if test x$enable_video = xyes -a x$enable_video_vulkan = xyes; then
  2524         case "$host" in
  2525             *-*-android*)
  2526                 AC_TRY_COMPILE([
  2527                   #if defined(__ARM_ARCH) && __ARM_ARCH < 7
  2528                   #error Vulkan doesn't work on this configuration
  2529                   #endif
  2530                 ],[
  2531                 ],[
  2532                 ],[
  2533                     enable_video_vulkan=no
  2534                 ])
  2535                 ;;
  2536             *-*-darwin*)
  2537                 save_CFLAGS="$CFLAGS"
  2538                 dnl Work around that we don't have Objective-C support in autoconf
  2539                 CFLAGS="$CFLAGS -x objective-c"
  2540                 AC_TRY_COMPILE([
  2541                   #include <Cocoa/Cocoa.h>
  2542                   #include <Metal/Metal.h>
  2543                   #include <QuartzCore/CAMetalLayer.h>
  2544 
  2545                   #if !TARGET_CPU_X86_64
  2546                   #error Vulkan doesn't work on this configuration
  2547                   #endif
  2548                 ],[
  2549                 ],[
  2550                 ],[
  2551                     enable_video_vulkan=no
  2552                 ])
  2553                 CFLAGS="$save_CFLAGS"
  2554                 ;;
  2555             *)
  2556                 ;;
  2557         esac
  2558         if test x$enable_video_vulkan = xno; then
  2559             # For reasons I am totally unable to see, I get an undefined macro error if
  2560             # I put this in the AC_TRY_COMPILE.
  2561             AC_MSG_WARN([Vulkan does not work on this configuration.])
  2562         fi
  2563     fi
  2564     if test x$enable_video_vulkan = xyes; then
  2565         AC_DEFINE(SDL_VIDEO_VULKAN, 1, [ ])
  2566         SUMMARY_video="${SUMMARY_video} vulkan"
  2567     fi
  2568 }
  2569 
  2570 dnl See if we can use the new unified event interface in Linux 2.4
  2571 CheckInputEvents()
  2572 {
  2573     dnl Check for Linux 2.4 unified input event interface support
  2574         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  2575         use_input_events=no
  2576         AC_TRY_COMPILE([
  2577           #include <linux/input.h>
  2578         ],[
  2579           #ifndef EVIOCGNAME
  2580           #error EVIOCGNAME() ioctl not available
  2581           #endif
  2582         ],[
  2583         use_input_events=yes
  2584         ])
  2585         AC_MSG_RESULT($use_input_events)
  2586         if test x$use_input_events = xyes; then
  2587             AC_DEFINE(SDL_INPUT_LINUXEV, 1, [ ])
  2588             SUMMARY_input="${SUMMARY_input} linuxev"
  2589         fi
  2590 }
  2591 
  2592 dnl See if we can use the kernel kd.h header
  2593 CheckInputKD()
  2594 {
  2595 
  2596     AC_MSG_CHECKING(for Linux kd.h)
  2597     use_input_kd=no
  2598     AC_TRY_COMPILE([
  2599       #include <linux/kd.h>
  2600       #include <linux/keyboard.h>
  2601     ],[
  2602         struct kbentry kbe;
  2603         kbe.kb_table = KG_CTRL;
  2604         ioctl(0, KDGKBENT, &kbe);
  2605     ],[
  2606     use_input_kd=yes
  2607     ])
  2608     AC_MSG_RESULT($use_input_kd)
  2609     if test x$use_input_kd = xyes; then
  2610         AC_DEFINE(SDL_INPUT_LINUXKD, 1, [ ])
  2611         SUMMARY_input="${SUMMARY_input} linuxkd"
  2612     fi
  2613 }
  2614 
  2615 dnl See if the platform offers libudev for device enumeration and hotplugging.
  2616 CheckLibUDev()
  2617 {
  2618     AC_ARG_ENABLE(libudev,
  2619 AC_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
  2620                         , enable_libudev=yes)
  2621     if test x$enable_libudev = xyes; then
  2622         AC_CHECK_HEADER(libudev.h,
  2623                         have_libudev_h_hdr=yes,
  2624                         have_libudev_h_hdr=no)
  2625         if test x$have_libudev_h_hdr = xyes; then
  2626             AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])
  2627 
  2628             udev_lib=[`find_lib "libudev.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
  2629             if test x$udev_lib != x; then
  2630                 echo "-- dynamic udev -> $udev_lib"
  2631                 AC_DEFINE_UNQUOTED(SDL_UDEV_DYNAMIC, "$udev_lib", [ ])
  2632             fi
  2633         fi
  2634     fi
  2635 }
  2636 
  2637 dnl See if the platform offers libdbus for various IPC techniques.
  2638 CheckDBus()
  2639 {
  2640     AC_ARG_ENABLE(dbus,
  2641 AC_HELP_STRING([--enable-dbus], [enable D-Bus support [[default=yes]]]),
  2642                         , enable_dbus=yes)
  2643     if test x$enable_dbus = xyes; then
  2644         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2645         if test x$PKG_CONFIG != xno; then
  2646             DBUS_CFLAGS=`$PKG_CONFIG --cflags dbus-1`
  2647             save_CFLAGS="$CFLAGS"
  2648             CFLAGS="$save_CFLAGS $DBUS_CFLAGS"
  2649             AC_CHECK_HEADER(dbus/dbus.h,
  2650                             have_dbus_dbus_h_hdr=yes,
  2651                             have_dbus_dbus_h_hdr=no)
  2652             CFLAGS="$save_CFLAGS"
  2653             if test x$have_dbus_dbus_h_hdr = xyes; then
  2654                 AC_DEFINE(HAVE_DBUS_DBUS_H, 1, [ ])
  2655                 EXTRA_CFLAGS="$EXTRA_CFLAGS $DBUS_CFLAGS"
  2656                 SOURCES="$SOURCES $srcdir/src/core/linux/SDL_dbus.c"
  2657             fi
  2658         fi
  2659     fi
  2660 }
  2661 
  2662 dnl See if the platform wanna IME support.
  2663 CheckIME()
  2664 {
  2665     AC_ARG_ENABLE(ime,
  2666 AC_HELP_STRING([--enable-ime], [enable IME support [[default=yes]]]),
  2667                   , enable_ime=yes)
  2668     if test x$enable_ime = xyes; then
  2669         AC_DEFINE(SDL_USE_IME, 1, [ ])
  2670             SOURCES="$SOURCES $srcdir/src/core/linux/SDL_ime.c"
  2671     fi
  2672 }
  2673 
  2674 dnl See if the platform has libibus IME support.
  2675 CheckIBus()
  2676 {
  2677     AC_ARG_ENABLE(ibus,
  2678 AC_HELP_STRING([--enable-ibus], [enable IBus support [[default=yes]]]),
  2679                   , enable_ibus=yes)
  2680     if test x$enable_ibus = xyes; then
  2681         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2682         if test x$PKG_CONFIG != xno; then
  2683             IBUS_CFLAGS=`$PKG_CONFIG --cflags ibus-1.0`
  2684             save_CFLAGS="$CFLAGS"
  2685             CFLAGS="$save_CFLAGS $IBUS_CFLAGS"
  2686             AC_CHECK_HEADER(ibus-1.0/ibus.h,
  2687                             have_ibus_ibus_h_hdr=yes,
  2688                             have_ibus_ibus_h_hdr=no)
  2689             AC_CHECK_HEADER(sys/inotify.h,
  2690                             have_inotify_inotify_h_hdr=yes,
  2691                             have_inotify_inotify_h_hdr=no)
  2692             CFLAGS="$save_CFLAGS"
  2693             if test x$have_ibus_ibus_h_hdr = xyes; then
  2694                 if test x$enable_ime != xyes; then
  2695                     AC_MSG_WARN([IME support is required for IBus.])
  2696                     have_ibus_ibus_h_hdr=no
  2697                 elif test x$enable_dbus != xyes; then
  2698                     AC_MSG_WARN([DBus support is required for IBus.])
  2699                     have_ibus_ibus_h_hdr=no
  2700                 elif test x$have_inotify_inotify_h_hdr != xyes; then
  2701                     AC_MSG_WARN([INotify support is required for IBus.])
  2702                     have_ibus_ibus_h_hdr=no
  2703                 else
  2704                     AC_DEFINE(HAVE_IBUS_IBUS_H, 1, [ ])
  2705                     EXTRA_CFLAGS="$EXTRA_CFLAGS $IBUS_CFLAGS"
  2706                     SOURCES="$SOURCES $srcdir/src/core/linux/SDL_ibus.c"
  2707                fi
  2708             fi
  2709         fi
  2710     fi
  2711 }
  2712 
  2713 dnl See if the platform has fcitx IME support.
  2714 CheckFcitx()
  2715 {
  2716     AC_ARG_ENABLE(fcitx,
  2717 AC_HELP_STRING([--enable-fcitx], [enable fcitx support [[default=yes]]]),
  2718                   , enable_fcitx=yes)
  2719     if test x$enable_fcitx = xyes; then
  2720         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2721         if test x$PKG_CONFIG != xno; then
  2722             FCITX_CFLAGS=`$PKG_CONFIG --cflags fcitx`
  2723             CFLAGS="$CFLAGS $FCITX_CFLAGS"
  2724             AC_CHECK_HEADER(fcitx/frontend.h,
  2725                             have_fcitx_frontend_h_hdr=yes,
  2726                             have_fcitx_frontend_h_hdr=no)
  2727             CFLAGS="$save_CFLAGS"
  2728             if test x$have_fcitx_frontend_h_hdr = xyes; then
  2729                 if test x$enable_ime != xyes; then
  2730                     AC_MSG_WARN([IME support is required for fcitx.])
  2731                     have_fcitx_frontend_h_hdr=no
  2732                 elif test x$enable_dbus != xyes; then
  2733                     AC_MSG_WARN([DBus support is required for fcitx.])
  2734                     have_fcitx_frontend_h_hdr=no
  2735                 else
  2736                     AC_DEFINE(HAVE_FCITX_FRONTEND_H, 1, [ ])
  2737                     EXTRA_CFLAGS="$EXTRA_CFLAGS $FCITX_CFLAGS"
  2738                     SOURCES="$SOURCES $srcdir/src/core/linux/SDL_fcitx.c"
  2739                fi
  2740             fi
  2741         fi
  2742     fi
  2743 }
  2744 
  2745 dnl See if we can use the Touchscreen input library
  2746 CheckTslib()
  2747 {
  2748     AC_ARG_ENABLE(input-tslib,
  2749 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  2750                   , enable_input_tslib=yes)
  2751     if test x$enable_input_tslib = xyes; then
  2752         AC_MSG_CHECKING(for Touchscreen library support)
  2753         enable_input_tslib=no
  2754         AC_TRY_COMPILE([
  2755           #include "tslib.h"
  2756         ],[
  2757         ],[
  2758         enable_input_tslib=yes
  2759         ])
  2760         AC_MSG_RESULT($enable_input_tslib)
  2761         if test x$enable_input_tslib = xyes; then
  2762             AC_DEFINE(SDL_INPUT_TSLIB, 1, [ ])
  2763             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  2764             SUMMARY_input="${SUMMARY_input} ts"
  2765         fi
  2766     fi
  2767 }
  2768 
  2769 dnl See what type of thread model to use on Linux and Solaris
  2770 CheckPTHREAD()
  2771 {
  2772     dnl Check for pthread support
  2773     AC_ARG_ENABLE(pthreads,
  2774 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  2775                   , enable_pthreads=yes)
  2776     dnl This is used on Linux for glibc binary compatibility (Doh!)
  2777     AC_ARG_ENABLE(pthread-sem,
  2778 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  2779                   , enable_pthread_sem=yes)
  2780     case "$host" in
  2781          *-*-android*)
  2782             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2783             pthread_lib=""
  2784             ;;
  2785         *-*-linux*|*-*-uclinux*)
  2786             pthread_cflags="-D_REENTRANT"
  2787             pthread_lib="-lpthread"
  2788             ;;
  2789         *-*-bsdi*)
  2790             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2791             pthread_lib=""
  2792             ;;
  2793         *-*-darwin*)
  2794             pthread_cflags="-D_THREAD_SAFE"
  2795 # causes Carbon.p complaints?
  2796 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2797             ;;
  2798         *-*-freebsd*|*-*-dragonfly*)
  2799             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2800             pthread_lib="-pthread"
  2801             ;;
  2802         *-*-netbsd*)
  2803             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2804             pthread_lib="-lpthread"
  2805             ;;
  2806         *-*-openbsd*)
  2807             pthread_cflags="-D_REENTRANT"
  2808             pthread_lib="-pthread"
  2809             ;;
  2810         *-*-solaris2.9)
  2811             # From Solaris 9+, posix4's preferred name is rt.
  2812             pthread_cflags="-D_REENTRANT"
  2813             pthread_lib="-lpthread -lrt"
  2814             ;;
  2815         *-*-solaris2.10)
  2816             # Solaris 10+ merged pthread into libc.
  2817             pthread_cflags="-D_REENTRANT"
  2818             pthread_lib="-lrt"
  2819             ;;
  2820         *-*-solaris*)
  2821             # Solaris 11+ merged rt into libc.
  2822             pthread_cflags="-D_REENTRANT"
  2823             pthread_lib=""
  2824             ;;
  2825         *-*-sysv5*)
  2826             pthread_cflags="-D_REENTRANT -Kthread"
  2827             pthread_lib=""
  2828             ;;
  2829         *-*-aix*)
  2830             pthread_cflags="-D_REENTRANT -mthreads"
  2831             pthread_lib="-lpthread"
  2832             ;;
  2833         *-*-hpux11*)
  2834             pthread_cflags="-D_REENTRANT"
  2835             pthread_lib="-L/usr/lib -lpthread"
  2836             ;;
  2837         *-*-haiku*)
  2838             pthread_cflags="-D_REENTRANT"
  2839             pthread_lib=""
  2840             ;;
  2841         *-*-nto*)
  2842             pthread_cflags="-D_REENTRANT"
  2843             pthread_lib=""
  2844             ;;
  2845         *)
  2846             pthread_cflags="-D_REENTRANT"
  2847             pthread_lib="-lpthread"
  2848             ;;
  2849     esac
  2850     if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
  2851         # Save the original compiler flags and libraries
  2852         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  2853         # Add the pthread compiler flags and libraries
  2854         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  2855         # Check to see if we have pthread support on this system
  2856         AC_MSG_CHECKING(for pthreads)
  2857         use_pthreads=no
  2858         AC_TRY_LINK([
  2859          #include <pthread.h>
  2860         ],[
  2861          pthread_attr_t type;
  2862          pthread_attr_init(&type);
  2863         ],[
  2864         use_pthreads=yes
  2865         ])
  2866         AC_MSG_RESULT($use_pthreads)
  2867         # Restore the compiler flags and libraries
  2868         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  2869 
  2870         # Do futher testing if we have pthread support...
  2871         if test x$use_pthreads = xyes; then
  2872             AC_DEFINE(SDL_THREAD_PTHREAD, 1, [ ])
  2873             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  2874             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  2875             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  2876 
  2877             # Save the original compiler flags and libraries
  2878             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  2879             # Add the pthread compiler flags and libraries
  2880             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  2881 
  2882             # Check to see if recursive mutexes are available
  2883             AC_MSG_CHECKING(for recursive mutexes)
  2884             has_recursive_mutexes=no
  2885             if test x$has_recursive_mutexes = xno; then
  2886                 AC_TRY_LINK([
  2887                   #define _GNU_SOURCE 1
  2888                   #include <pthread.h>
  2889                 ],[
  2890                   pthread_mutexattr_t attr;
  2891                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  2892                 ],[
  2893                 has_recursive_mutexes=yes
  2894                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX, 1, [ ])
  2895                 ])
  2896             fi
  2897             if test x$has_recursive_mutexes = xno; then
  2898                 AC_TRY_LINK([
  2899                   #define _GNU_SOURCE 1
  2900                   #include <pthread.h>
  2901                 ],[
  2902                   pthread_mutexattr_t attr;
  2903                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  2904                 ],[
  2905                 has_recursive_mutexes=yes
  2906                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP, 1, [ ])
  2907                 ])
  2908             fi
  2909             AC_MSG_RESULT($has_recursive_mutexes)
  2910 
  2911             # Check to see if pthread semaphore support is missing
  2912             if test x$enable_pthread_sem = xyes; then
  2913                 AC_MSG_CHECKING(for pthread semaphores)
  2914                 have_pthread_sem=no
  2915                 AC_TRY_COMPILE([
  2916                   #include <pthread.h>
  2917                   #include <semaphore.h>
  2918                 ],[
  2919                 ],[
  2920                 have_pthread_sem=yes
  2921                 ])
  2922                 AC_MSG_RESULT($have_pthread_sem)
  2923             fi
  2924             if test x$have_pthread_sem = xyes; then
  2925                 AC_MSG_CHECKING(for sem_timedwait)
  2926                 have_sem_timedwait=no
  2927                 AC_TRY_LINK([
  2928                   #include <pthread.h>
  2929                   #include <semaphore.h>
  2930                 ],[
  2931                   sem_timedwait(NULL, NULL);
  2932                 ],[
  2933                 have_sem_timedwait=yes
  2934                 AC_DEFINE([HAVE_SEM_TIMEDWAIT], 1, [ ])
  2935                 ])
  2936                 AC_MSG_RESULT($have_sem_timedwait)
  2937             fi
  2938 
  2939             AC_CHECK_HEADER(pthread_np.h, have_pthread_np_h=yes, have_pthread_np_h=no, [ #include <pthread.h> ])
  2940             if test x$have_pthread_np_h = xyes; then
  2941                 AC_DEFINE(HAVE_PTHREAD_NP_H, 1, [ ])
  2942             fi
  2943 
  2944             # Check to see if pthread naming is available
  2945             AC_MSG_CHECKING(for pthread_setname_np)
  2946             AC_TRY_LINK_FUNC(pthread_setname_np, [
  2947               has_pthread_setname_np=yes
  2948               AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [ ])
  2949             ],[
  2950               has_pthread_setname_np=no
  2951             ])
  2952             AC_MSG_RESULT($has_pthread_setname_np)
  2953 
  2954             AC_MSG_CHECKING(for pthread_set_name_np)
  2955             AC_TRY_LINK_FUNC(pthread_set_name_np, [
  2956               has_pthread_set_name_np=yes
  2957               AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [ ])
  2958             ],[
  2959               has_pthread_set_name_np=no
  2960             ])
  2961             AC_MSG_RESULT($has_pthread_set_name_np)
  2962 
  2963             # Restore the compiler flags and libraries
  2964             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  2965 
  2966             # Basic thread creation functions
  2967             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  2968 
  2969             # Semaphores
  2970             # We can fake these with mutexes and condition variables if necessary
  2971             if test x$have_pthread_sem = xyes; then
  2972                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  2973             else
  2974                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  2975             fi
  2976 
  2977             # Mutexes
  2978             # We can fake these with semaphores if necessary
  2979             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  2980 
  2981             # Condition variables
  2982             # We can fake these with semaphores and mutexes if necessary
  2983             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  2984 
  2985             # Thread local storage
  2986             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systls.c"
  2987 
  2988             have_threads=yes
  2989         fi
  2990     fi
  2991 }
  2992 
  2993 dnl Determine whether the compiler can produce Windows executables
  2994 CheckWINDOWS()
  2995 {
  2996     AC_MSG_CHECKING(Windows compiler)
  2997     have_win32_gcc=no
  2998     AC_TRY_COMPILE([
  2999      #include <windows.h>
  3000     ],[
  3001     ],[
  3002     have_win32_gcc=yes
  3003     ])
  3004     AC_MSG_RESULT($have_win32_gcc)
  3005     if test x$have_win32_gcc != xyes; then
  3006        AC_MSG_ERROR([
  3007 *** Your compiler ($CC) does not produce Windows executables!
  3008        ])
  3009     fi
  3010 
  3011     AC_MSG_CHECKING(Windows CE)
  3012     have_wince=no
  3013     AC_TRY_COMPILE([
  3014 #if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
  3015 #error This is not Windows CE
  3016 #endif
  3017     ],[
  3018     ],[
  3019     have_wince=yes
  3020        AC_MSG_ERROR([
  3021 *** Sorry, Windows CE is no longer supported.
  3022        ])
  3023     ])
  3024     AC_MSG_RESULT($have_wince)
  3025 
  3026     # This fixes Windows stack alignment with newer GCC
  3027     CheckStackBoundary
  3028 }
  3029 
  3030 dnl Find the DirectX includes and libraries
  3031 CheckDIRECTX()
  3032 {
  3033     AC_ARG_ENABLE(directx,
  3034 AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
  3035                   , enable_directx=yes)
  3036     if test x$enable_directx = xyes; then
  3037         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  3038         AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes)
  3039         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  3040         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  3041         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  3042         AC_CHECK_HEADER(dxgi.h, have_dxgi=yes)
  3043         AC_CHECK_HEADER(xinput.h, have_xinput=yes)
  3044         AC_CHECK_HEADER(mmdeviceapi.h, have_wasapi=yes)
  3045         AC_CHECK_HEADER(audioclient.h,,have_wasapi=no)
  3046         AC_TRY_COMPILE([
  3047 #include <windows.h>
  3048 #include <xinput.h>
  3049 XINPUT_GAMEPAD_EX x1;
  3050         ],[],[have_xinput_gamepadex=yes])
  3051         AC_TRY_COMPILE([
  3052 #include <windows.h>
  3053 #include <xinput.h>
  3054 XINPUT_STATE_EX s1;
  3055         ],[],[have_xinput_stateex=yes])
  3056 
  3057         if test x$have_ddraw = xyes; then
  3058             AC_DEFINE(HAVE_DDRAW_H, 1, [ ])
  3059         fi
  3060         if test x$have_dinput = xyes; then
  3061             AC_DEFINE(HAVE_DINPUT_H, 1, [ ])
  3062         fi
  3063         if test x$have_dsound = xyes; then
  3064             AC_DEFINE(HAVE_DSOUND_H, 1, [ ])
  3065         fi
  3066         if test x$have_dxgi = xyes; then
  3067             AC_DEFINE(HAVE_DXGI_H, 1, [ ])
  3068         fi
  3069         if test x$have_xinput = xyes; then
  3070             AC_DEFINE(HAVE_XINPUT_H, 1, [ ])
  3071         fi
  3072         if test x$have_xinput_gamepadex = xyes; then
  3073             AC_DEFINE(HAVE_XINPUT_GAMEPAD_EX, 1, [ ])
  3074         fi
  3075         if test x$have_xinput_stateex = xyes; then
  3076             AC_DEFINE(HAVE_XINPUT_STATE_EX, 1, [ ])
  3077         fi
  3078 
  3079         SUMMARY_video="${SUMMARY_video} directx"
  3080         SUMMARY_audio="${SUMMARY_audio} directx"
  3081 
  3082         AC_ARG_ENABLE(wasapi,
  3083 AC_HELP_STRING([--enable-wasapi], [use the Windows WASAPI audio driver [[default=yes]]]),
  3084                                 , enable_wasapi=yes)
  3085 
  3086         # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
  3087         # FIXME:  ...so force it off for now.
  3088         case "$host" in
  3089             *-*-cygwin*)
  3090             have_dinput=false
  3091             ;;
  3092         esac
  3093     fi
  3094 }
  3095 
  3096 dnl Check for the dlfcn.h interface for dynamically loading objects
  3097 CheckDLOPEN()
  3098 {
  3099     AC_ARG_ENABLE(sdl-dlopen,
  3100 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  3101                   , enable_sdl_dlopen=yes)
  3102     if test x$enable_sdl_dlopen = xyes; then
  3103         AC_MSG_CHECKING(for dlopen)
  3104         have_dlopen=no
  3105         AC_TRY_COMPILE([
  3106          #include <dlfcn.h>
  3107         ],[
  3108          void *handle = dlopen("", RTLD_NOW);
  3109          const char *loaderror = (char *) dlerror();
  3110         ],[
  3111         have_dlopen=yes
  3112         ])
  3113         AC_MSG_RESULT($have_dlopen)
  3114 
  3115         if test x$have_dlopen = xyes; then
  3116             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  3117                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  3118                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  3119             AC_DEFINE(SDL_LOADSO_DLOPEN, 1, [ ])
  3120             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  3121             have_loadso=yes
  3122         fi
  3123     fi
  3124 }
  3125 
  3126 dnl Check for the usbhid(3) library on *BSD
  3127 CheckUSBHID()
  3128 {
  3129     case "$host" in
  3130         *-*-*bsd*)
  3131             if test x$enable_joystick = xyes; then
  3132                 AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  3133                 if test x$have_libusbhid = xyes; then
  3134                     AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  3135                     AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  3136                     USB_LIBS="$USB_LIBS -lusbhid"
  3137                 else
  3138                     AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  3139                     AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  3140                     AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  3141                 fi
  3142                     
  3143                 save_CFLAGS="$CFLAGS"
  3144                 CFLAGS="$CFLAGS $USB_CFLAGS"
  3145 
  3146                 AC_MSG_CHECKING(for usbhid)
  3147                 have_usbhid=no
  3148                 AC_TRY_COMPILE([
  3149                   #include <sys/types.h>
  3150                   #if defined(HAVE_USB_H)
  3151                   #include <usb.h>
  3152                   #endif
  3153                   #ifdef __DragonFly__
  3154                   # include <bus/usb/usb.h>
  3155                   # include <bus/usb/usbhid.h>
  3156                   #else
  3157                   # include <dev/usb/usb.h>
  3158                   # include <dev/usb/usbhid.h>
  3159                   #endif
  3160                   #if defined(HAVE_USBHID_H)
  3161                   #include <usbhid.h>
  3162                   #elif defined(HAVE_LIBUSB_H)
  3163                   #include <libusb.h>
  3164                   #elif defined(HAVE_LIBUSBHID_H)
  3165                   #include <libusbhid.h>
  3166                   #endif
  3167                 ],[
  3168                   struct report_desc *repdesc;
  3169                   struct usb_ctl_report *repbuf;
  3170                   hid_kind_t hidkind;
  3171                 ],[
  3172                 have_usbhid=yes
  3173                 ])
  3174                 AC_MSG_RESULT($have_usbhid)
  3175 
  3176                 if test x$have_usbhid = xyes; then
  3177                     AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  3178                     have_usbhid_ucr_data=no
  3179                     AC_TRY_COMPILE([
  3180                       #include <sys/types.h>
  3181                       #if defined(HAVE_USB_H)
  3182                       #include <usb.h>
  3183                       #endif
  3184                       #ifdef __DragonFly__
  3185                       # include <bus/usb/usb.h>
  3186                       # include <bus/usb/usbhid.h>
  3187                       #else
  3188                       # include <dev/usb/usb.h>
  3189                       # include <dev/usb/usbhid.h>
  3190                       #endif
  3191                       #if defined(HAVE_USBHID_H)
  3192                       #include <usbhid.h>
  3193                       #elif defined(HAVE_LIBUSB_H)
  3194                       #include <libusb.h>
  3195                       #elif defined(HAVE_LIBUSBHID_H)
  3196                       #include <libusbhid.h>
  3197                       #endif
  3198                     ],[
  3199                       struct usb_ctl_report buf;
  3200                       if (buf.ucr_data) { }
  3201                     ],[
  3202                     have_usbhid_ucr_data=yes
  3203                     ])
  3204                     if test x$have_usbhid_ucr_data = xyes; then
  3205                         USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  3206                     fi
  3207                     AC_MSG_RESULT($have_usbhid_ucr_data)
  3208                     
  3209                     AC_MSG_CHECKING(for new usbhid API)
  3210                     have_usbhid_new=no
  3211                     AC_TRY_COMPILE([
  3212                       #include <sys/types.h>
  3213                       #if defined(HAVE_USB_H)
  3214                       #include <usb.h>
  3215                       #endif
  3216                       #ifdef __DragonFly__
  3217                       #include <bus/usb/usb.h>
  3218                       #include <bus/usb/usbhid.h>
  3219                       #else
  3220                       #include <dev/usb/usb.h>
  3221                       #include <dev/usb/usbhid.h>
  3222                       #endif
  3223                       #if defined(HAVE_USBHID_H)
  3224                       #include <usbhid.h>
  3225                       #elif defined(HAVE_LIBUSB_H)
  3226                       #include <libusb.h>
  3227                       #elif defined(HAVE_LIBUSBHID_H)
  3228                       #include <libusbhid.h>
  3229                       #endif
  3230                     ],[
  3231                       report_desc_t d;
  3232                       hid_start_parse(d, 1, 1);
  3233                     ],[
  3234                     have_usbhid_new=yes
  3235                     ])
  3236                     if test x$have_usbhid_new = xyes; then
  3237                         USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  3238                     fi
  3239                     AC_MSG_RESULT($have_usbhid_new)
  3240 
  3241                     AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  3242                     have_machine_joystick=no
  3243                     AC_TRY_COMPILE([
  3244                       #include <machine/joystick.h>
  3245                     ],[
  3246                       struct joystick t;
  3247                     ],[
  3248                     have_machine_joystick=yes
  3249                     ])
  3250                     if test x$have_machine_joystick = xyes; then
  3251                         AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
  3252                     fi
  3253                     AC_MSG_RESULT($have_machine_joystick)
  3254 
  3255                     AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
  3256                     SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  3257                     EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  3258                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  3259                     have_joystick=yes
  3260                 fi
  3261                 CFLAGS="$save_CFLAGS"
  3262             fi
  3263         ;;
  3264     esac
  3265 }
  3266 
  3267 dnl Check for clock_gettime()
  3268 CheckClockGettime()
  3269 {
  3270     AC_ARG_ENABLE(clock_gettime,
  3271 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=yes]]]),
  3272                   , enable_clock_gettime=yes)
  3273     if test x$enable_clock_gettime = xyes; then
  3274         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  3275         if test x$have_clock_gettime = xyes; then
  3276             AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  3277             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  3278         else
  3279             AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
  3280             if test x$have_clock_gettime = xyes; then
  3281                AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  3282                EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
  3283             fi
  3284         fi
  3285     fi
  3286 }
  3287 
  3288 dnl Check for a valid linux/version.h
  3289 CheckLinuxVersion()
  3290 {
  3291     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  3292     if test x$have_linux_version_h = xyes; then
  3293         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  3294     fi
  3295 }
  3296 
  3297 dnl Check if we want to use RPATH
  3298 CheckRPATH()
  3299 {
  3300     AC_ARG_ENABLE(rpath,
  3301 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  3302                   , enable_rpath=yes)
  3303 }
  3304 
  3305 dnl Do this on all platforms, before everything else (other things might want to override it).
  3306 CheckWarnAll
  3307 
  3308 dnl Set up the configuration based on the host platform!
  3309 case "$host" in
  3310     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*|*-*-nto*)
  3311         case "$host" in
  3312             *-*-android*)
  3313                 # Android
  3314                 ARCH=android
  3315                 ANDROID_CFLAGS="-DGL_GLEXT_PROTOTYPES"
  3316                 CFLAGS="$CFLAGS $ANDROID_CFLAGS"
  3317                 SDL_CFLAGS="$SDL_CFLAGS $ANDROID_CFLAGS"
  3318                 EXTRA_CFLAGS="$EXTRA_CFLAGS $ANDROID_CFLAGS"
  3319                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl -lGLESv1_CM -lGLESv2 -llog -landroid"
  3320                 SDLMAIN_SOURCES="$srcdir/src/main/android/*.c"
  3321 
  3322                 if test x$enable_video = xyes; then
  3323                     SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c"
  3324                     # FIXME: confdefs? Not AC_DEFINE?
  3325                     $as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
  3326                     SUMMARY_video="${SUMMARY_video} android"
  3327                 fi
  3328                 ;;
  3329             *-*-linux*)         ARCH=linux ;;
  3330             *-*-uclinux*)       ARCH=linux ;;
  3331             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  3332             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  3333             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  3334             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  3335             *-*-bsdi*)          ARCH=bsdi ;;
  3336             *-*-freebsd*)       ARCH=freebsd ;;
  3337             *-*-dragonfly*)     ARCH=freebsd ;;
  3338             *-*-netbsd*)        ARCH=netbsd ;;
  3339             *-*-openbsd*)       ARCH=openbsd ;;
  3340             *-*-sysv5*)         ARCH=sysv5 ;;
  3341             *-*-solaris*)       ARCH=solaris ;;
  3342             *-*-hpux*)          ARCH=hpux ;;
  3343             *-*-aix*)           ARCH=aix ;;
  3344             *-*-minix*)         ARCH=minix ;;
  3345             *-*-nto*)           ARCH=nto
  3346                 CheckQNXVideo
  3347                 ;;
  3348         esac
  3349         CheckVisibilityHidden
  3350         CheckDeclarationAfterStatement
  3351         CheckDummyVideo
  3352         CheckDiskAudio
  3353         CheckDummyAudio
  3354         CheckDLOPEN
  3355         CheckOSS
  3356         CheckALSA
  3357         CheckPulseAudio
  3358         CheckJACK
  3359         CheckARTSC
  3360         CheckESD
  3361         CheckNAS
  3362         CheckSNDIO
  3363         CheckFusionSound
  3364         CheckLibSampleRate
  3365         # Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
  3366         CheckRPI
  3367         CheckX11
  3368         CheckDirectFB
  3369         CheckKMSDRM
  3370         CheckOpenGLX11
  3371         CheckOpenGLESX11
  3372         CheckVulkan
  3373         CheckMir
  3374         CheckWayland
  3375         CheckLibUDev
  3376         CheckDBus
  3377         CheckIME
  3378         CheckIBus
  3379         CheckFcitx
  3380         case $ARCH in
  3381           linux)
  3382               CheckInputEvents
  3383               CheckInputKD
  3384           ;;
  3385         esac
  3386         CheckTslib
  3387         CheckUSBHID
  3388         CheckPTHREAD
  3389         CheckClockGettime
  3390         CheckLinuxVersion
  3391         CheckRPATH
  3392         CheckVivanteVideo
  3393 
  3394         # Set up files for the audio library
  3395         if test x$enable_audio = xyes; then
  3396           case $ARCH in
  3397             sysv5|solaris|hpux)
  3398                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
  3399                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  3400                 SUMMARY_audio="${SUMMARY_audio} sun"
  3401                 have_audio=yes
  3402             ;;
  3403             netbsd)  # Don't use this on OpenBSD, it's busted.
  3404                 AC_DEFINE(SDL_AUDIO_DRIVER_NETBSD, 1, [ ])
  3405                 SOURCES="$SOURCES $srcdir/src/audio/netbsd/*.c"
  3406                 SUMMARY_audio="${SUMMARY_audio} netbsd"
  3407                 have_audio=yes
  3408             ;;
  3409             aix)
  3410                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO, 1, [ ])
  3411                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  3412                 SUMMARY_audio="${SUMMARY_audio} paudio"
  3413                 have_audio=yes
  3414             ;;
  3415             android)
  3416                 AC_DEFINE(SDL_AUDIO_DRIVER_ANDROID, 1, [ ])
  3417                 SOURCES="$SOURCES $srcdir/src/audio/android/*.c"
  3418                 SUMMARY_audio="${SUMMARY_audio} android"
  3419                 have_audio=yes
  3420             ;;
  3421             nto)
  3422                 CheckQNXAudio
  3423             ;;
  3424           esac
  3425         fi
  3426         # Set up files for the joystick library
  3427         if test x$enable_joystick = xyes; then
  3428           case $ARCH in
  3429             linux)
  3430                 AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ])
  3431                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  3432                 SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c"
  3433                 have_joystick=yes
  3434             ;;
  3435             android)
  3436                 AC_DEFINE(SDL_JOYSTICK_ANDROID, 1, [ ])
  3437                 SOURCES="$SOURCES $srcdir/src/joystick/android/*.c"
  3438                 SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c"
  3439                 have_joystick=yes
  3440             ;;
  3441           esac
  3442         fi
  3443         # Set up files for the haptic library
  3444         if test x$enable_haptic = xyes; then
  3445           case $ARCH in
  3446             linux)
  3447                 if test x$use_input_events = xyes; then
  3448                     AC_DEFINE(SDL_HAPTIC_LINUX, 1, [ ])
  3449                     SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  3450                     have_haptic=yes
  3451                 fi
  3452             ;;
  3453             android)
  3454                 AC_DEFINE(SDL_HAPTIC_ANDROID, 1, [ ])
  3455                 SOURCES="$SOURCES $srcdir/src/haptic/android/*.c"
  3456                 have_haptic=yes
  3457             ;;
  3458           esac
  3459         fi
  3460         # Set up files for the power library
  3461         if test x$enable_power = xyes; then
  3462              case $ARCH in
  3463                linux)
  3464                    AC_DEFINE(SDL_POWER_LINUX, 1, [ ])
  3465                    SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
  3466                    have_power=yes
  3467                ;;
  3468                android)
  3469                    AC_DEFINE(SDL_POWER_ANDROID, 1, [ ])
  3470                    SOURCES="$SOURCES $srcdir/src/power/android/*.c"
  3471                    have_power=yes
  3472                ;;
  3473              esac
  3474         fi
  3475         # Set up files for the filesystem library
  3476         if test x$enable_filesystem = xyes; then
  3477              case $ARCH in
  3478                android)
  3479                    AC_DEFINE(SDL_FILESYSTEM_ANDROID, 1, [ ])
  3480                    SOURCES="$SOURCES $srcdir/src/filesystem/android/*.c"
  3481                    have_filesystem=yes
  3482                ;;
  3483                *)
  3484                    AC_DEFINE(SDL_FILESYSTEM_UNIX, 1, [ ])
  3485                    SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
  3486                    have_filesystem=yes
  3487                ;;
  3488              esac
  3489         fi
  3490         # Set up files for the timer library
  3491         if test x$enable_timers = xyes; then
  3492             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  3493             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  3494             have_timers=yes
  3495         fi
  3496         # Set up files for udev hotplugging support
  3497         if test x$enable_libudev = xyes && test x$have_libudev_h_hdr = xyes; then
  3498             SOURCES="$SOURCES $srcdir/src/core/linux/SDL_udev.c"               
  3499         fi
  3500         # Set up files for evdev input
  3501         if test x$use_input_events = xyes; then
  3502             SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev*.c"
  3503         fi       
  3504         # Set up other core UNIX files
  3505         SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
  3506         ;;
  3507     *-*-cygwin* | *-*-mingw32*)
  3508         ARCH=win32
  3509         if test "$build" != "$host"; then # cross-compiling
  3510             # Default cross-compile location
  3511             ac_default_prefix=/usr/local/cross-tools/$host
  3512         else
  3513             # Look for the location of the tools and install there
  3514             if test "$BUILD_PREFIX" != ""; then
  3515                 ac_default_prefix=$BUILD_PREFIX
  3516             fi
  3517         fi
  3518         CheckDeclarationAfterStatement
  3519         CheckDummyVideo
  3520         CheckDiskAudio
  3521         CheckDummyAudio
  3522         CheckWINDOWS
  3523         CheckWINDOWSGL
  3524         CheckWINDOWSGLES
  3525         CheckVulkan
  3526         CheckDIRECTX
  3527 
  3528         # Set up the core platform files
  3529         SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
  3530 
  3531         # Set up files for the video library
  3532         if test x$enable_video = xyes; then
  3533             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS, 1, [ ])
  3534             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
  3535             have_video=yes
  3536             AC_ARG_ENABLE(render-d3d,
  3537 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  3538                                 , enable_render_d3d=yes)
  3539             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  3540                 AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ])
  3541             fi
  3542             if test x$enable_render_d3d = xyes -a x$have_d3d11 = xyes; then
  3543                 AC_DEFINE(SDL_VIDEO_RENDER_D3D11, 1, [ ])
  3544             fi
  3545         fi
  3546         # Set up files for the audio library
  3547         if test x$enable_audio = xyes; then
  3548             AC_DEFINE(SDL_AUDIO_DRIVER_WINMM, 1, [ ])
  3549             SOURCES="$SOURCES $srcdir/src/audio/winmm/*.c"
  3550             if test x$have_dsound = xyes; then
  3551                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
  3552                 SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
  3553             fi
  3554             if test x$have_wasapi = xyes -a x$enable_wasapi = xyes; then
  3555                 AC_DEFINE(SDL_AUDIO_DRIVER_WASAPI, 1, [ ])
  3556                 SUMMARY_audio="${SUMMARY_audio} wasapi"
  3557                 SOURCES="$SOURCES $srcdir/src/audio/wasapi/*.c"
  3558             fi
  3559             have_audio=yes
  3560         fi
  3561         # Set up files for the joystick library
  3562         if test x$enable_joystick = xyes; then
  3563             if test x$have_dinput = xyes -o x$have_xinput = xyes; then
  3564                 if test x$have_xinput = xyes; then
  3565                     AC_DEFINE(SDL_JOYSTICK_XINPUT, 1, [ ])
  3566                 fi
  3567                 if test x$have_dinput = xyes; then
  3568                     AC_DEFINE(SDL_JOYSTICK_DINPUT, 1, [ ])
  3569                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
  3570                 fi
  3571             else
  3572                 AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
  3573             fi
  3574             SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
  3575             have_joystick=yes
  3576         fi
  3577         if test x$enable_haptic = xyes; then
  3578             if test x$have_dinput = xyes -o x$have_xinput = xyes; then
  3579                 if test x$have_xinput = xyes; then
  3580                     AC_DEFINE(SDL_HAPTIC_XINPUT, 1, [ ])
  3581                 fi
  3582                 if test x$have_dinput = xyes; then
  3583                     AC_DEFINE(SDL_HAPTIC_DINPUT, 1, [ ])
  3584                 fi
  3585                 SOURCES="$SOURCES $srcdir/src/haptic/windows/*.c"
  3586                 have_haptic=yes
  3587             fi
  3588         fi
  3589         if test x$enable_power = xyes; then
  3590             AC_DEFINE(SDL_POWER_WINDOWS, 1, [ ])
  3591             SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
  3592             have_power=yes
  3593         fi
  3594         if test x$enable_filesystem = xyes; then
  3595             AC_DEFINE(SDL_FILESYSTEM_WINDOWS, 1, [ ])
  3596             SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c"
  3597             have_filesystem=yes
  3598         fi
  3599         # Set up files for the thread library
  3600         if test x$enable_threads = xyes; then
  3601             AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ])
  3602             SOURCES="$SOURCES $srcdir/src/thread/windows/*.c"
  3603             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  3604             have_threads=yes
  3605         fi
  3606         # Set up files for the timer library
  3607         if test x$enable_timers = xyes; then
  3608             AC_DEFINE(SDL_TIMER_WINDOWS, 1, [ ])
  3609             SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
  3610             have_timers=yes
  3611         fi
  3612         # Set up files for the shared object loading library
  3613         if test x$enable_loadso = xyes; then
  3614             AC_DEFINE(SDL_LOADSO_WINDOWS, 1, [ ])
  3615             SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
  3616             have_loadso=yes
  3617         fi
  3618         # Set up the system libraries we need
  3619         if test -f /lib/w32api/libuuid.a; then
  3620             LIBUUID=/lib/w32api/libuuid.a
  3621         else
  3622             LIBUUID=-luuid
  3623         fi
  3624         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion $LIBUUID -static-libgcc"
  3625         # The Windows platform requires special setup
  3626         VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
  3627         SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
  3628         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  3629         SDL_LIBS="-lSDL2main $SDL_LIBS -mwindows"
  3630 
  3631         # Check to see if this is a mingw or cygwin build
  3632         have_mingw32=
  3633         AC_CHECK_LIB(mingw32, main, [have_mingw32=yes])
  3634         if test x$have_mingw32 = xyes; then
  3635             SDL_LIBS="-lmingw32 $SDL_LIBS"
  3636         else
  3637             SDL_LIBS="-lcygwin $SDL_LIBS"
  3638         fi
  3639         ;;
  3640 
  3641     dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
  3642     *-*-beos*)
  3643         AC_MSG_ERROR([
  3644 *** BeOS support has been removed as of SDL 2.0.2.
  3645         ])
  3646         ;;
  3647 
  3648     *-*-haiku*)
  3649         ARCH=haiku
  3650         ac_default_prefix=/boot/system
  3651         CheckDummyVideo
  3652         CheckDiskAudio
  3653         CheckDummyAudio
  3654         CheckDLOPEN
  3655         CheckHaikuVideo
  3656         CheckHaikuGL
  3657         CheckPTHREAD
  3658 
  3659         # Set up files for the audio library
  3660         if test x$enable_audio = xyes; then
  3661             AC_DEFINE(SDL_AUDIO_DRIVER_HAIKU, 1, [ ])
  3662             SOURCES="$SOURCES $srcdir/src/audio/haiku/*.cc"
  3663             SUMMARY_audio="${SUMMARY_audio} haiku"
  3664             have_audio=yes
  3665         fi
  3666         # Set up files for the joystick library
  3667         if test x$enable_joystick = xyes; then
  3668             AC_DEFINE(SDL_JOYSTICK_HAIKU, 1, [ ])
  3669             SOURCES="$SOURCES $srcdir/src/joystick/haiku/*.cc"
  3670             have_joystick=yes
  3671         fi
  3672         # Set up files for the timer library
  3673         if test x$enable_timers = xyes; then
  3674             AC_DEFINE(SDL_TIMER_HAIKU, 1, [ ])
  3675             SOURCES="$SOURCES $srcdir/src/timer/haiku/*.c"
  3676             have_timers=yes
  3677         fi
  3678         # Set up files for the system power library
  3679         if test x$enable_power = xyes; then
  3680             AC_DEFINE(SDL_POWER_HAIKU, 1, [ ])
  3681             SOURCES="$SOURCES $srcdir/src/power/haiku/*.c"
  3682             have_power=yes
  3683         fi
  3684         # Set up files for the system filesystem library
  3685         if test x$enable_filesystem = xyes; then
  3686             AC_DEFINE(SDL_FILESYSTEM_HAIKU, 1, [ ])
  3687             SOURCES="$SOURCES $srcdir/src/filesystem/haiku/*.cc"
  3688             have_filesystem=yes
  3689         fi
  3690         # The Haiku platform requires special setup.
  3691         SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
  3692         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  3693         # Haiku's x86 spins use libstdc++.r4.so (for binary compat?), but
  3694         #  other spins, like x86-64, use a more standard "libstdc++.so.*"
  3695         AC_CHECK_FILE("/boot/system/lib/libstdc++.r4.so", EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++.r4", EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++")
  3696         ;;
  3697     arm*-apple-darwin*|*-ios-*)
  3698         ARCH=ios
  3699 
  3700         CheckVisibilityHidden
  3701         CheckDeclarationAfterStatement
  3702         CheckDummyVideo
  3703         CheckDiskAudio
  3704         CheckDummyAudio
  3705         CheckDLOPEN
  3706         CheckMETAL
  3707         CheckVulkan
  3708         CheckPTHREAD
  3709 
  3710         # Set up files for the audio library
  3711         if test x$enable_audio = xyes; then
  3712             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
  3713             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
  3714             SUMMARY_audio="${SUMMARY_audio} coreaudio"
  3715             have_audio=yes
  3716         fi
  3717         # Set up files for the joystick library
  3718         if test x$enable_joystick = xyes; then
  3719             AC_DEFINE(SDL_JOYSTICK_MFI, 1, [ ])
  3720             SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
  3721             SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c"
  3722             have_joystick=yes
  3723         fi
  3724         # Set up files for the haptic library
  3725         #if test x$enable_haptic = xyes; then
  3726         #    SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  3727         #    have_haptic=yes
  3728         #    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  3729         #fi
  3730         # Set up files for the power library
  3731         if test x$enable_power = xyes; then
  3732             AC_DEFINE(SDL_POWER_UIKIT, 1, [ ])
  3733             SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
  3734             have_power=yes
  3735         fi
  3736         # Set up files for the filesystem library
  3737         if test x$enable_filesystem = xyes; then
  3738             SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
  3739             have_filesystem=yes
  3740         fi
  3741         # Set up additional files for the file library
  3742         if test x$enable_file = xyes; then
  3743             AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
  3744             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  3745         fi
  3746         # Set up files for the timer library
  3747         if test x$enable_timers = xyes; then
  3748             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  3749             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  3750             have_timers=yes
  3751         fi
  3752         # Set up other core UNIX files
  3753         SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
  3754         # The iOS platform requires special setup.
  3755         AC_DEFINE(SDL_VIDEO_DRIVER_UIKIT, 1, [ ])
  3756         AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  3757         AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
  3758         AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
  3759         AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  3760         SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
  3761         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
  3762         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AVFoundation"
  3763         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
  3764         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
  3765         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
  3766         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
  3767         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
  3768         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,GameController"
  3769         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
  3770         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
  3771         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
  3772 
  3773         if test x$enable_render = xyes -a x$enable_render_metal = xyes; then
  3774             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Metal"
  3775         fi
  3776         ;;
  3777     *-*-darwin* )
  3778         # This could be either full "Mac OS X", or plain "Darwin" which is
  3779         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  3780         # Next line is broken, and a few files below require Mac OS X (full)
  3781         ARCH=macosx
  3782 
  3783         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  3784         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  3785         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  3786 
  3787         CheckVisibilityHidden
  3788         CheckDeclarationAfterStatement
  3789         CheckDummyVideo
  3790         CheckDiskAudio
  3791         CheckDummyAudio
  3792         CheckDLOPEN
  3793         CheckCOCOA
  3794         CheckMETAL
  3795         CheckX11
  3796         CheckMacGL
  3797         CheckMacGLES
  3798         CheckOpenGLX11
  3799         CheckVulkan
  3800         CheckPTHREAD
  3801 
  3802         # Set up files for the audio library
  3803         if test x$enable_audio = xyes; then
  3804             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
  3805             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
  3806             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox"
  3807             SUMMARY_audio="${SUMMARY_audio} coreaudio"
  3808             have_audio=yes
  3809         fi
  3810         # Set up files for the joystick library
  3811         if test x$enable_joystick = xyes; then
  3812             AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
  3813             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  3814             have_joystick=yes
  3815         fi
  3816         # Set up files for the haptic library
  3817         if test x$enable_haptic = xyes; then
  3818             AC_DEFINE(SDL_HAPTIC_IOKIT, 1, [ ])
  3819             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  3820             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  3821             have_haptic=yes
  3822         fi
  3823         # Set up files for the power library
  3824         if test x$enable_power = xyes; then
  3825             AC_DEFINE(SDL_POWER_MACOSX, 1, [ ])
  3826             SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
  3827             have_power=yes
  3828         fi
  3829         # Set up files for the filesystem library
  3830         if test x$enable_filesystem = xyes; then
  3831             AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
  3832             SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
  3833             have_filesystem=yes
  3834         fi
  3835         # Set up files for the timer library
  3836         if test x$enable_timers = xyes; then
  3837             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  3838             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  3839             have_timers=yes
  3840         fi
  3841         # Set up additional files for the file library
  3842         if test x$enable_file = xyes; then
  3843             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  3844         fi
  3845         # Set up other core UNIX files
  3846         SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
  3847         # The Mac OS X platform requires special setup.
  3848         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
  3849         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreVideo"
  3850         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  3851         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  3852         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  3853 
  3854         if test x$enable_render = xyes -a x$enable_render_metal = xyes; then
  3855             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-weak_framework,QuartzCore -Wl,-weak_framework,Metal"
  3856         fi
  3857         ;;
  3858     *-nacl|*-pnacl)
  3859         ARCH=nacl
  3860         CheckNativeClient
  3861         CheckDummyAudio
  3862         CheckDummyVideo
  3863         CheckInputEvents
  3864         CheckPTHREAD
  3865         
  3866         # Set up files for the timer library
  3867         if test x$enable_timers = xyes; then
  3868             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  3869             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  3870             have_timers=yes
  3871         fi
  3872         
  3873         if test x$enable_filesystem = xyes; then
  3874             AC_DEFINE(SDL_FILESYSTEM_NACL, 1, [ ])
  3875             SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c"
  3876             have_filesystem=yes
  3877         fi
  3878         ;;
  3879     *-*-emscripten* )
  3880         if test x$enable_video = xyes; then
  3881             AC_DEFINE(SDL_VIDEO_DRIVER_EMSCRIPTEN, 1, [ ])
  3882             SOURCES="$SOURCES $srcdir/src/video/emscripten/*.c"
  3883             have_video=yes
  3884             SUMMARY_video="${SUMMARY_video} emscripten"
  3885         fi
  3886 
  3887         if test x$enable_audio = xyes; then
  3888             AC_DEFINE(SDL_AUDIO_DRIVER_EMSCRIPTEN, 1, [ ])
  3889             SOURCES="$SOURCES $srcdir/src/audio/emscripten/*.c"
  3890             have_audio=yes
  3891             SUMMARY_audio="${SUMMARY_audio} emscripten"
  3892         fi
  3893 
  3894         CheckVisibilityHidden
  3895         CheckDeclarationAfterStatement
  3896         CheckDummyVideo
  3897         CheckDiskAudio
  3898         CheckDummyAudio
  3899         CheckDLOPEN
  3900         CheckClockGettime
  3901         CheckEmscriptenGLES
  3902 
  3903          # Set up files for the power library
  3904         if test x$enable_power = xyes; then
  3905             AC_DEFINE(SDL_POWER_EMSCRIPTEN, 1, [ ])
  3906             SOURCES="$SOURCES $srcdir/src/power/emscripten/*.c"
  3907             have_power=yes
  3908         fi
  3909         
  3910         # Set up files for the power library
  3911         if test x$enable_joystick = xyes; then
  3912             AC_DEFINE(SDL_JOYSTICK_EMSCRIPTEN, 1, [ ])
  3913             SOURCES="$SOURCES $srcdir/src/joystick/emscripten/*.c"
  3914             have_joystick=yes
  3915         fi
  3916 
  3917         # Set up files for the filesystem library
  3918         if test x$enable_filesystem = xyes; then
  3919             AC_DEFINE(SDL_FILESYSTEM_EMSCRIPTEN, 1, [ ])
  3920             SOURCES="$SOURCES $srcdir/src/filesystem/emscripten/*.c"
  3921             have_filesystem=yes
  3922         fi
  3923         # Set up files for the timer library
  3924         if test x$enable_timers = xyes; then
  3925             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  3926             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  3927             have_timers=yes
  3928         fi
  3929         ;;
  3930     *)
  3931         AC_MSG_ERROR([
  3932 *** Unsupported host:  Please add to configure.in
  3933         ])
  3934         ;;
  3935 esac
  3936 
  3937 # Verify that we have all the platform specific files we need
  3938 
  3939 if test x$have_joystick != xyes; then
  3940     if test x$enable_joystick = xyes; then
  3941         AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
  3942     fi
  3943     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  3944 fi
  3945 if test x$have_haptic != xyes; then
  3946     if test x$enable_haptic = xyes; then
  3947         AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
  3948     fi
  3949     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  3950 fi
  3951 if test x$have_threads != xyes; then
  3952     if test x$enable_threads = xyes; then
  3953         AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
  3954     fi
  3955     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  3956 fi
  3957 if test x$have_timers != xyes; then
  3958     if test x$enable_timers = xyes; then
  3959         AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ])
  3960     fi
  3961     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  3962 fi
  3963 if test x$have_filesystem != xyes; then
  3964     if test x$enable_filesystem = xyes; then
  3965         AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
  3966     fi
  3967     SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c"
  3968 fi
  3969 if test x$have_loadso != xyes; then
  3970     if test x$enable_loadso = xyes; then
  3971         AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
  3972     fi
  3973     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  3974 fi
  3975 if test x$SDLMAIN_SOURCES = x; then
  3976     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  3977 fi
  3978 SDLTEST_SOURCES="$srcdir/src/test/*.c"
  3979 
  3980 if test x$video_wayland = xyes; then
  3981     WAYLAND_PROTOCOLS=`cd $srcdir/wayland-protocols ; for p in *.xml ; do echo -n "\$p" |sed 's,\\.xml\$, ,g' ; done`
  3982     WAYLAND_PROTOCOLS_SOURCES=`for p in $WAYLAND_PROTOCOLS ; do echo -n "\\$(gen)/\$p-protocol.c " ; done`
  3983     WAYLAND_PROTOCOLS_HEADERS=`for p in $WAYLAND_PROTOCOLS ; do echo -n "\\$(gen)/\$p-client-protocol.h " ; done`
  3984     GEN_SOURCES="$GEN_SOURCES $WAYLAND_PROTOCOLS_SOURCES"
  3985     GEN_HEADERS="$GEN_HEADERS $WAYLAND_PROTOCOLS_HEADERS"
  3986 
  3987     WAYLAND_PROTOCOLS_DEPENDS=`for p in $WAYLAND_PROTOCOLS ; do\
  3988         echo ;\
  3989         echo "\\$(gen)/\$p-client-protocol.h: \\$(srcdir)/wayland-protocols/\$p.xml" ;\
  3990         echo "	@\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\
  3991         echo "	\\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) client-header \\$< \\$@" ;\
  3992         echo ;\
  3993         echo "\\$(gen)/\$p-protocol.c: \\$(srcdir)/wayland-protocols/\$p.xml" ;\
  3994         echo "	@\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\
  3995         echo "	\\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) code \\$< \\$@" ;\
  3996         echo ;\
  3997         echo "\\$(objects)/\$p-protocol.lo: \\$(gen)/\$p-protocol.c \\$(gen)/\$p-client-protocol.h" ;\
  3998         echo "	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@" ;\
  3999         done`
  4000 fi
  4001 
  4002 OBJECTS=`echo $SOURCES`
  4003 DEPENDS=`echo $SOURCES | tr ' ' '\n'`
  4004 for EXT in asm cc m c S; do
  4005     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
  4006     DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
  4007 \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
  4008 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  4009 done
  4010 
  4011 GEN_OBJECTS=`echo "$GEN_SOURCES" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
  4012 
  4013 VERSION_OBJECTS=`echo $VERSION_SOURCES`
  4014 VERSION_DEPENDS=`echo $VERSION_SOURCES`
  4015 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  4016 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
  4017 \\$(objects)/\\2.o: \\1/\\2.rc\\\\
  4018 	\\$(WINDRES) \\$< \\$@,g"`
  4019 
  4020 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
  4021 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
  4022 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
  4023 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  4024 \\$(objects)/\\2.lo: \\1/\\2.c\\\\
  4025 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  4026 
  4027 SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
  4028 SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
  4029 SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
  4030 SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  4031 \\$(objects)/\\2.lo: \\1/\\2.c\\\\
  4032 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  4033 
  4034 # Set runtime shared library paths as needed
  4035 
  4036 if test "x$enable_rpath" = "xyes"; then
  4037   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
  4038     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  4039 
  4040     AC_MSG_CHECKING(for linker option --enable-new-dtags)
  4041     have_enable_new_dtags=no
  4042     save_LDFLAGS="$LDFLAGS"
  4043     LDFLAGS="$LDFLAGS -Wl,--enable-new-dtags"
  4044     AC_TRY_LINK([
  4045     ],[
  4046     ],[
  4047     have_enable_new_dtags=yes
  4048     SDL_RLD_FLAGS="$SDL_RLD_FLAGS -Wl,--enable-new-dtags"
  4049     ])
  4050     LDFLAGS="$save_LDFLAGS"
  4051     AC_MSG_RESULT($have_enable_new_dtags)
  4052   fi
  4053   if test $ARCH = solaris; then
  4054     SDL_RLD_FLAGS="-R\${libdir}"
  4055   fi
  4056 else
  4057   SDL_RLD_FLAGS=""
  4058 fi
  4059 
  4060 SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  4061 
  4062 dnl Expand the cflags and libraries needed by apps using SDL
  4063 AC_SUBST(SDL_CFLAGS)
  4064 AC_SUBST(SDL_LIBS)
  4065 AC_SUBST(SDL_STATIC_LIBS)
  4066 AC_SUBST(SDL_RLD_FLAGS)
  4067 if test x$enable_shared = xyes; then
  4068     ENABLE_SHARED_TRUE=
  4069     ENABLE_SHARED_FALSE="#"
  4070 else
  4071     ENABLE_SHARED_TRUE="#"
  4072     ENABLE_SHARED_FALSE=
  4073 fi
  4074 if test x$enable_static = xyes; then
  4075     ENABLE_STATIC_TRUE=
  4076     ENABLE_STATIC_FALSE="#"
  4077 else
  4078     ENABLE_STATIC_TRUE="#"
  4079     ENABLE_STATIC_FALSE=
  4080 fi
  4081 AC_SUBST(ENABLE_SHARED_TRUE)
  4082 AC_SUBST(ENABLE_SHARED_FALSE)
  4083 AC_SUBST(ENABLE_STATIC_TRUE)
  4084 AC_SUBST(ENABLE_STATIC_FALSE)
  4085 
  4086 dnl Expand the sources and objects needed to build the library
  4087 AC_SUBST(ac_aux_dir)
  4088 AC_SUBST(INCLUDE)
  4089 AC_SUBST(OBJECTS)
  4090 AC_SUBST(GEN_HEADERS)
  4091 AC_SUBST(GEN_OBJECTS)
  4092 AC_SUBST(VERSION_OBJECTS)
  4093 AC_SUBST(SDLMAIN_OBJECTS)
  4094 AC_SUBST(SDLTEST_OBJECTS)
  4095 AC_SUBST(BUILD_CFLAGS)
  4096 AC_SUBST(EXTRA_CFLAGS)
  4097 AC_SUBST(BUILD_LDFLAGS)
  4098 AC_SUBST(EXTRA_LDFLAGS)
  4099 AC_SUBST(WINDRES)
  4100 AC_SUBST(WAYLAND_SCANNER)
  4101 
  4102 cat >Makefile.rules <<__EOF__
  4103 
  4104 # Build rules for objects
  4105 -include \$(OBJECTS:.lo=.d)
  4106 
  4107 # Special dependency for SDL.c, since it depends on SDL_revision.h
  4108 $srcdir/src/SDL.c: update-revision
  4109 $DEPENDS
  4110 $VERSION_DEPENDS
  4111 $SDLMAIN_DEPENDS
  4112 $SDLTEST_DEPENDS
  4113 $WAYLAND_PROTOCOLS_DEPENDS
  4114 __EOF__
  4115 
  4116 AC_CONFIG_FILES([
  4117     Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake SDL2.spec sdl2.pc
  4118 ])
  4119 AC_CONFIG_COMMANDS([sdl2_config],[chmod a+x sdl2-config])
  4120 
  4121 SUMMARY="SDL2 Configure Summary:\n"
  4122 if test x$enable_shared = xyes; then
  4123     SUMMARY="${SUMMARY}Building Shared Libraries\n"
  4124 fi
  4125 if test x$enable_static = xyes; then
  4126     SUMMARY="${SUMMARY}Building Static Libraries\n"
  4127 fi
  4128 SUMMARY="${SUMMARY}Enabled modules :${SUMMARY_modules}\n"
  4129 SUMMARY="${SUMMARY}Assembly Math   :${SUMMARY_math}\n" 
  4130 SUMMARY="${SUMMARY}Audio drivers   :${SUMMARY_audio}\n"
  4131 SUMMARY="${SUMMARY}Video drivers   :${SUMMARY_video}\n"
  4132 if test x$have_x = xyes; then
  4133     SUMMARY="${SUMMARY}X11 libraries   :${SUMMARY_video_x11}\n"
  4134 fi
  4135 SUMMARY="${SUMMARY}Input drivers   :${SUMMARY_input}\n"
  4136 if test x$have_samplerate_h_hdr = xyes; then
  4137     SUMMARY="${SUMMARY}Using libsamplerate : YES\n"
  4138 else
  4139     SUMMARY="${SUMMARY}Using libsamplerate : NO\n"
  4140 fi
  4141 if test x$have_libudev_h_hdr = xyes; then
  4142     SUMMARY="${SUMMARY}Using libudev       : YES\n"
  4143 else
  4144     SUMMARY="${SUMMARY}Using libudev       : NO\n"
  4145 fi
  4146 if test x$have_dbus_dbus_h_hdr = xyes; then
  4147     SUMMARY="${SUMMARY}Using dbus          : YES\n"
  4148 else
  4149     SUMMARY="${SUMMARY}Using dbus          : NO\n"
  4150 fi
  4151 if test x$enable_ime = xyes; then
  4152     SUMMARY="${SUMMARY}Using ime           : YES\n"
  4153 else
  4154     SUMMARY="${SUMMARY}Using ime           : NO\n"
  4155 fi
  4156 if test x$have_ibus_ibus_h_hdr = xyes; then
  4157     SUMMARY="${SUMMARY}Using ibus          : YES\n"
  4158 else
  4159     SUMMARY="${SUMMARY}Using ibus          : NO\n"
  4160 fi
  4161 if test x$have_fcitx_frontend_h_hdr = xyes; then
  4162     SUMMARY="${SUMMARY}Using fcitx         : YES\n"
  4163 else
  4164     SUMMARY="${SUMMARY}Using fcitx         : NO\n"
  4165 fi
  4166 AC_CONFIG_COMMANDS([summary], [echo -en "$SUMMARY"], [SUMMARY="$SUMMARY"])
  4167 
  4168 AC_OUTPUT