configure.ac
author Sam Lantinga <slouken@libsdl.org>
Wed, 05 Jun 2019 12:03:45 -0700
changeset 12762 0fa532733f3f
parent 12714 9b7633bd0aa0
child 12804 1a330416800d
permissions -rw-r--r--
Fixed bug 4655 - evdev is available on FreeBSD, check in 'configure' limited to Linux

Jan Martin Mikkelsen

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