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