configure.in
author Ryan C. Gordon <icculus@icculus.org>
Mon, 03 Feb 2014 11:14:25 -0500
changeset 8158 429513cb6707
parent 8153 3e43c73ac79b
child 8159 427e8fdf6f69
permissions -rw-r--r--
Add Mir to configure script's summary output.
     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=1
    24 SDL_INTERFACE_AGE=0
    25 SDL_BINARY_AGE=1
    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 $gcc_bin_path $gcc_lib_path $env_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)
   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 CheckMir()
  1128 {
  1129     AC_ARG_ENABLE(video-mir,
  1130     AC_HELP_STRING([--enable-video-mir], [use Mir video driver [[default=yes]]]),
  1131                    , enable_video_mir=yes)
  1132 
  1133     if test x$enable_video = xyes -a x$enable_video_mir = xyes; then
  1134         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1135 
  1136         if test x$PKG_CONFIG != xno; then
  1137             AC_MSG_CHECKING(for Mir support)
  1138             video_mir=no
  1139             tmp_CFLAGS="$CFLAGS"
  1140             CFLAGS="$EXTRA_CFLAGS `$PKG_CONFIG --cflags egl mirclient xkbcommon`"
  1141 
  1142             AC_TRY_COMPILE([
  1143              #include <EGL/egl.h>
  1144              #include <xkbcommon/xkbcommon.h>
  1145              #include <mir_toolkit/mir_client_library.h>
  1146             ],[
  1147             ],[
  1148             video_mir=yes
  1149             ])
  1150             CFLAGS="$tmp_CFLAGS"
  1151             AC_MSG_RESULT($video_mir)
  1152 
  1153             if test x$video_mir = xyes; then
  1154                   AC_DEFINE(SDL_VIDEO_DRIVER_MIR)
  1155                   SOURCES="$SOURCES $srcdir/src/video/mir/*.c"
  1156                   EXTRA_CFLAGS="$EXTRA_CFLAGS `$PKG_CONFIG --cflags egl mirclient xkbcommon`"
  1157                   EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$PKG_CONFIG --libs egl mirclient xkbcommon`"
  1158                   have_video=yes
  1159                   SUMMARY_video="${SUMMARY_video} mir"
  1160             fi
  1161         fi
  1162     fi
  1163 }
  1164 
  1165 dnl See if GCC's -Wall is supported.
  1166 CheckWarnAll()
  1167 {
  1168     AC_MSG_CHECKING(for GCC -Wall option)
  1169     have_gcc_Wall=no
  1170 
  1171     save_CFLAGS="$CFLAGS"
  1172     CFLAGS="$save_CFLAGS -Wall"
  1173     AC_TRY_COMPILE([
  1174     int x = 0;
  1175     ],[
  1176     ],[
  1177     have_gcc_Wall=yes
  1178     ])
  1179     AC_MSG_RESULT($have_gcc_Wall)
  1180     CFLAGS="$save_CFLAGS"
  1181 
  1182     if test x$have_gcc_Wall = xyes; then
  1183         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
  1184 
  1185         dnl Haiku headers use multicharacter constants all over the place. Ignore these warnings when using -Wall.
  1186         AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
  1187         need_gcc_Wno_multichar=no
  1188         case "$host" in
  1189             *-*-haiku*)
  1190                 need_gcc_Wno_multichar=yes
  1191                 ;;
  1192         esac
  1193         AC_MSG_RESULT($need_gcc_Wno_multichar)
  1194         if test x$need_gcc_Wno_multichar = xyes; then
  1195             EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar"
  1196         fi
  1197     fi
  1198 }
  1199 
  1200 dnl Check for Wayland
  1201 CheckWayland()
  1202 {
  1203     AC_ARG_ENABLE(video-wayland,
  1204 AC_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]),
  1205                   ,enable_video_wayland=yes)
  1206 
  1207     AC_ARG_ENABLE(video-wayland-qt-touch,
  1208 AC_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for Wayland video driver [[default=yes]]]),
  1209                   ,enable_video_wayland_qt_touch=yes)
  1210 
  1211     if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
  1212         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1213         AC_MSG_CHECKING(for Wayland support)
  1214         video_wayland=no
  1215         if test x$PKG_CONFIG != xno; then
  1216             if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
  1217                 WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
  1218                 WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
  1219                 video_wayland=yes
  1220             fi
  1221         fi
  1222         AC_MSG_RESULT($video_wayland)
  1223 
  1224         if test x$video_wayland = xyes; then
  1225             AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND, 1, [ ])
  1226             if test x$enable_video_wayland_qt_touch = xyes; then
  1227                 AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH, 1, [ ])
  1228             fi
  1229             SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
  1230             EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
  1231             AC_ARG_ENABLE(wayland-shared,
  1232 AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[default=maybe]]]),
  1233                           , enable_wayland_shared=maybe)
  1234 
  1235             dnl FIXME: Do BSD and OS X need special cases?
  1236             case "$host" in
  1237                 *)
  1238                     wayland_client_lib=[`find_lib "libwayland-client.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1239                     wayland_egl_lib=[`find_lib "libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1240                     if test x$wayland_egl_lib = x; then
  1241                         dnl This works in Ubuntu 13.10, maybe others
  1242                         wayland_egl_lib=[`find_lib "mesa-egl/libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1243                     fi
  1244                     wayland_cursor_lib=[`find_lib "libwayland-cursor.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1245                     xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1246                     ;;
  1247             esac
  1248 
  1249             if test x$enable_wayland_shared = xmaybe; then
  1250                 enable_wayland_shared=yes
  1251             fi
  1252             if test x$have_loadso != xyes && \
  1253                test x$enable_wayland_shared = xyes; then
  1254                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic WAYLAND loading])
  1255                 enable_wayland_shared=no
  1256             fi
  1257             if test x$have_loadso = xyes && \
  1258                test x$enable_wayland_shared = xyes && \
  1259                test x$wayland_client_lib != x && \
  1260                test x$wayland_egl_lib != x && \
  1261                test x$wayland_cursor_lib != x && \
  1262                test x$xkbcommon_lib != x; then
  1263                 echo "-- dynamic libwayland-client -> $wayland_client_lib"
  1264                 echo "-- dynamic libwayland-egl -> $wayland_egl_lib"
  1265                 echo "-- dynamic libwayland-cursor -> $wayland_cursor_lib"
  1266                 echo "-- dynamic xkbcommon -> $xkbcommon_lib"
  1267                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC, "$wayland_client_lib", [ ])
  1268                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL, "$wayland_egl_lib", [ ])
  1269                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR, "$wayland_cursor_lib", [ ])
  1270                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ])
  1271                 SUMMARY_video="${SUMMARY_video} wayland(dynamic)"
  1272             else
  1273                 enable_wayland_shared=no
  1274                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
  1275                 SUMMARY_video="${SUMMARY_video} wayland"
  1276             fi
  1277             have_video=yes
  1278         fi
  1279     fi
  1280 }
  1281 
  1282 dnl Find the X11 include and library directories
  1283 CheckX11()
  1284 {
  1285 
  1286 
  1287     AC_ARG_ENABLE(video-x11,
  1288 AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
  1289                   , enable_video_x11=yes)
  1290     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
  1291         case "$host" in
  1292             *-*-darwin*)
  1293                 # This isn't necessary for X11, but fixes GLX detection
  1294                 if test "x$x_includes" = xNONE && \
  1295                    test "x$x_libraries" = xNONE && \
  1296                    test -d /usr/X11R6/include && \
  1297                    test -d /usr/X11R6/lib; then
  1298                     x_includes="/usr/X11R6/include"
  1299                     x_libraries="/usr/X11R6/lib"
  1300                 fi
  1301                 ;;
  1302         esac
  1303         AC_PATH_X
  1304         AC_PATH_XTRA
  1305         if test x$have_x = xyes; then
  1306             AC_ARG_ENABLE(x11-shared,
  1307 AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
  1308                           , enable_x11_shared=maybe)
  1309 
  1310             case "$host" in
  1311                 *-*-darwin*)
  1312                     x11_lib='/usr/X11R6/lib/libX11.6.dylib'
  1313                     x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
  1314                     xcursor_lib='/usr/X11R6/lib/libXcursor.1.dylib'
  1315                     xinerama_lib='/usr/X11R6/lib/libXinerama.1.dylib'
  1316                     xinput_lib='/usr/X11R6/lib/libXi.6.dylib'
  1317                     xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
  1318                     xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
  1319                     xss_lib='/usr/X11R6/lib/libXss.1.dylib'
  1320                     xvidmode_lib='/usr/X11R6/lib/libXxf86vm.1.dylib'
  1321                     ;;
  1322                 *-*-openbsd*)
  1323                     x11_lib='libX11.so'
  1324                     x11ext_lib='libXext.so'
  1325                     xcursor_lib='libXcursor.so'
  1326                     xinerama_lib='libXinerama.so'
  1327                     xinput_lib='libXi.so'
  1328                     xrandr_lib='libXrandr.so'
  1329                     xrender_lib='libXrender.so'
  1330                     xss_lib='libXss.so'
  1331                     xvidmode_lib='libXxf86vm.so'
  1332                     ;;
  1333                 *)
  1334                     x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1335                     x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1336                     xcursor_lib=[`find_lib "libXcursor.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1337                     xinerama_lib=[`find_lib "libXinerama.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1338                     xinput_lib=[`find_lib "libXi.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1339                     xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1340                     xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1341                     xss_lib=[`find_lib "libXss.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1342                     xvidmode_lib=[`find_lib "libXxf86vm.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1343                     ;;
  1344             esac
  1345 
  1346             if test x$ac_cv_func_shmat != xyes; then
  1347                 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
  1348             fi
  1349             CFLAGS="$CFLAGS $X_CFLAGS"
  1350             LDFLAGS="$LDFLAGS $X_LIBS"
  1351 
  1352             AC_CHECK_HEADER(X11/extensions/Xext.h,
  1353                             have_xext_h_hdr=yes,
  1354                             have_xext_h_hdr=no,
  1355                             [#include <X11/Xlib.h>
  1356                              #include <X11/Xproto.h>
  1357                             ])
  1358             if test x$have_xext_h_hdr != xyes; then
  1359                AC_MSG_ERROR([
  1360 *** Missing Xext.h, maybe you need to install the libxext-dev package?
  1361                ])
  1362             fi
  1363 
  1364             AC_DEFINE(SDL_VIDEO_DRIVER_X11, 1, [ ])
  1365             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
  1366             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
  1367 
  1368             # Needed so SDL applications can include SDL_syswm.h
  1369             SDL_CFLAGS="$SDL_CFLAGS $X_CFLAGS"
  1370 
  1371             if test x$enable_x11_shared = xmaybe; then
  1372                 enable_x11_shared=yes
  1373             fi
  1374             if test x$have_loadso != xyes && \
  1375                test x$enable_x11_shared = xyes; then
  1376                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
  1377                 enable_x11_shared=no
  1378             fi
  1379             if test x$have_loadso = xyes && \
  1380                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
  1381                 echo "-- dynamic libX11 -> $x11_lib"
  1382                 echo "-- dynamic libX11ext -> $x11ext_lib"
  1383                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib", [ ])
  1384                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib", [ ])
  1385                 SUMMARY_video="${SUMMARY_video} x11(dynamic)"
  1386             else
  1387                 enable_x11_shared=no
  1388                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
  1389                 SUMMARY_video="${SUMMARY_video} x11"
  1390             fi
  1391             have_video=yes
  1392 
  1393             AC_MSG_CHECKING(for const parameter to XextAddDisplay)
  1394             have_const_param_XextAddDisplay=no
  1395             AC_TRY_COMPILE([
  1396               #include <X11/Xlib.h>
  1397               #include <X11/Xproto.h>
  1398               #include <X11/extensions/Xext.h>
  1399               #include <X11/extensions/extutil.h>
  1400               extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
  1401             ],[
  1402             ],[
  1403             have_const_param_XextAddDisplay=yes
  1404             AC_DEFINE(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY)
  1405             ])
  1406             AC_MSG_RESULT($have_const_param_XextAddDisplay)
  1407 
  1408             AC_MSG_CHECKING(for const parameter to _XData32)
  1409 	    have_const_param_xdata32=no
  1410 	    AC_TRY_COMPILE([
  1411 	      #include <X11/Xlibint.h>
  1412 	      extern int _XData32(Display *dpy,register _Xconst long *data,unsigned len);
  1413 	    ],[
  1414 	    ],[
  1415 	    have_const_param_xdata32=yes
  1416 	    AC_DEFINE(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32)
  1417 	    ])
  1418 	    AC_MSG_RESULT($have_const_param_xdata32)
  1419 
  1420             dnl AC_CHECK_LIB(X11, XGetEventData, AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS, 1, [Have XGenericEvent]))
  1421             AC_MSG_CHECKING([for XGenericEvent])
  1422             have_XGenericEvent=no
  1423             AC_TRY_COMPILE([
  1424               	#include <X11/Xlib.h>
  1425             ],[
  1426 Display *display;
  1427 XEvent event;
  1428 XGenericEventCookie *cookie = &event.xcookie;
  1429 XNextEvent(display, &event);
  1430 XGetEventData(display, cookie);
  1431 XFreeEventData(display, cookie);
  1432             ],[
  1433                 have_XGenericEvent=yes
  1434                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS)
  1435             ])
  1436             AC_MSG_RESULT($have_XGenericEvent)
  1437 
  1438             AC_CHECK_LIB(X11, XkbKeycodeToKeysym, AC_DEFINE(SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM, 1, [Have XkbKeycodeToKeysym]))
  1439 
  1440             AC_ARG_ENABLE(video-x11-xcursor,
  1441 AC_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[default=yes]]]),
  1442                             , enable_video_x11_xcursor=yes)
  1443             if test x$enable_video_x11_xcursor = xyes; then
  1444                 definitely_enable_video_x11_xcursor=no
  1445                 AC_CHECK_HEADER(X11/Xcursor/Xcursor.h,
  1446                                 have_xcursor_h_hdr=yes,
  1447                                 have_xcursor_h_hdr=no,
  1448                                 [#include <X11/Xlib.h>
  1449                                 ])
  1450                 if test x$have_xcursor_h_hdr = xyes; then
  1451                     if test x$enable_x11_shared = xyes && test x$xcursor_lib != x ; then
  1452                         echo "-- dynamic libXcursor -> $xcursor_lib"
  1453                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR, "$xcursor_lib", [ ])
  1454                         definitely_enable_video_x11_xcursor=yes
  1455                     else
  1456                         AC_CHECK_LIB(Xcursor, XcursorImageCreate, have_xcursor_lib=yes)
  1457                         if test x$have_xcursor_lib = xyes ; then
  1458                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXcursor"
  1459                             definitely_enable_video_x11_xcursor=yes
  1460                         fi
  1461                     fi
  1462                 fi
  1463             fi
  1464             if test x$definitely_enable_video_x11_xcursor = xyes; then
  1465                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XCURSOR, 1, [ ])
  1466                 SUMMARY_video_x11="${SUMMARY_video_x11} xcursor"
  1467             fi
  1468             AC_ARG_ENABLE(video-x11-xinerama,
  1469 AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
  1470                             , enable_video_x11_xinerama=yes)
  1471             if test x$enable_video_x11_xinerama = xyes; then
  1472                 definitely_enable_video_x11_xinerama=no
  1473                 AC_CHECK_HEADER(X11/extensions/Xinerama.h,
  1474                                 have_xinerama_h_hdr=yes,
  1475                                 have_xinerama_h_hdr=no,
  1476                                 [#include <X11/Xlib.h>
  1477                                 ])
  1478                 if test x$have_xinerama_h_hdr = xyes; then
  1479                     if test x$enable_x11_shared = xyes && test x$xinerama_lib != x ; then
  1480                         echo "-- dynamic libXinerama -> $xinerama_lib"
  1481                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA, "$xinerama_lib", [ ])
  1482                         definitely_enable_video_x11_xinerama=yes
  1483                     else
  1484                         AC_CHECK_LIB(Xinerama, XineramaQueryExtension, have_xinerama_lib=yes)
  1485                         if test x$have_xinerama_lib = xyes ; then
  1486                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXinerama"
  1487                             definitely_enable_video_x11_xinerama=yes
  1488                         fi
  1489                     fi
  1490                 fi
  1491             fi
  1492             if test x$definitely_enable_video_x11_xinerama = xyes; then
  1493                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA, 1, [ ])
  1494                 SUMMARY_video_x11="${SUMMARY_video_x11} xinerama"
  1495             fi
  1496             AC_ARG_ENABLE(video-x11-xinput,
  1497 AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
  1498                             , enable_video_x11_xinput=yes)
  1499             if test x$enable_video_x11_xinput = xyes; then
  1500                 definitely_enable_video_x11_xinput=no
  1501                 AC_CHECK_HEADER(X11/extensions/XInput2.h,
  1502                                 have_xinput_h_hdr=yes,
  1503                                 have_xinput_h_hdr=no,
  1504                                 [#include <X11/Xlib.h>
  1505                                 ])
  1506                 if test x$have_xinput_h_hdr = xyes; then
  1507                     if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
  1508                         echo "-- dynamic libXi -> $xinput_lib"
  1509                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2, "$xinput_lib", [ ])
  1510                         definitely_enable_video_x11_xinput=yes
  1511                     else
  1512                         AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
  1513                         if test x$have_xinput_lib = xyes ; then
  1514                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
  1515                             definitely_enable_video_x11_xinput=yes
  1516                         fi
  1517                     fi
  1518                 fi
  1519             fi
  1520             if test x$definitely_enable_video_x11_xinput = xyes; then
  1521                 SUMMARY_video_x11="${SUMMARY_video_x11} xinput2"
  1522                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ])
  1523                 AC_MSG_CHECKING(for xinput2 multitouch)
  1524             	have_xinput2_multitouch=no
  1525             	AC_TRY_COMPILE([
  1526               		#include <X11/Xlib.h>
  1527              		#include <X11/Xproto.h>
  1528 			#include <X11/extensions/XInput2.h>
  1529             	],[
  1530 int event_type = XI_TouchBegin;
  1531 XITouchClassInfo *t;
  1532 Status 
  1533 XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f)
  1534 {
  1535     return (Status)0;
  1536 }
  1537             	],[
  1538             	have_xinput2_multitouch=yes
  1539             	AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH)
  1540                 SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch"
  1541             	])
  1542             	AC_MSG_RESULT($have_xinput2_multitouch)
  1543             fi
  1544             AC_ARG_ENABLE(video-x11-xrandr,
  1545 AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
  1546                             , enable_video_x11_xrandr=yes)
  1547             if test x$enable_video_x11_xrandr = xyes; then
  1548                 dnl XRRScreenResources is only present in Xrandr >= 1.2, we use that as a test.
  1549                 definitely_enable_video_x11_xrandr=no
  1550                 have_xrandr_h_hdr=no
  1551                 AC_TRY_COMPILE([
  1552                 #include <X11/Xlib.h>
  1553                 #include <X11/extensions/Xrandr.h>
  1554                 ],[
  1555                 XRRScreenResources *res = NULL;
  1556                 ],[
  1557                 have_xrandr_h_hdr=yes
  1558                 ])
  1559                 if test x$have_xrandr_h_hdr = xyes; then
  1560                     if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
  1561                         echo "-- dynamic libXrandr -> $xrandr_lib"
  1562                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib", [ ])
  1563                         definitely_enable_video_x11_xrandr=yes
  1564                     else
  1565                         AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
  1566                         if test x$have_xrandr_lib = xyes ; then
  1567                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr"
  1568                             definitely_enable_video_x11_xrandr=yes
  1569                         fi
  1570                     fi
  1571                 fi
  1572             fi
  1573             if test x$definitely_enable_video_x11_xrandr = xyes; then
  1574                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR, 1, [ ])
  1575                 SUMMARY_video_x11="${SUMMARY_video_x11} xrandr"
  1576             fi
  1577             AC_ARG_ENABLE(video-x11-scrnsaver,
  1578 AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
  1579                             , enable_video_x11_scrnsaver=yes)
  1580             if test x$enable_video_x11_scrnsaver = xyes; then
  1581                 AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
  1582                                 have_scrnsaver_h_hdr=yes,
  1583                                 have_scrnsaver_h_hdr=no,
  1584                                 [#include <X11/Xlib.h>
  1585                                 ])
  1586                 if test x$have_scrnsaver_h_hdr = xyes; then
  1587                     if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
  1588                         echo "-- dynamic libXss -> $xss_lib"
  1589                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib", [ ])
  1590                         definitely_enable_video_x11_scrnsaver=yes
  1591                     else
  1592                         AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
  1593                         if test x$have_xss_lib = xyes ; then
  1594                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
  1595                             definitely_enable_video_x11_scrnsaver=yes
  1596                         fi
  1597                     fi
  1598                 fi
  1599             fi
  1600             if test x$definitely_enable_video_x11_scrnsaver = xyes; then
  1601                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSCRNSAVER, 1, [ ])
  1602                 SUMMARY_video_x11="${SUMMARY_video_x11} xscrnsaver"
  1603             fi
  1604             AC_ARG_ENABLE(video-x11-xshape,
  1605 AC_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default=yes]]]),
  1606                             , enable_video_x11_xshape=yes)
  1607             if test x$enable_video_x11_xshape = xyes; then
  1608                 AC_CHECK_HEADER(X11/extensions/shape.h,
  1609                                 have_shape_h_hdr=yes,
  1610                                 have_shape_h_hdr=no,
  1611                                 [#include <X11/Xlib.h>
  1612                                 ])
  1613                 if test x$have_shape_h_hdr = xyes; then
  1614                     AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSHAPE, 1, [ ])
  1615                     SUMMARY_video_x11="${SUMMARY_video_x11} xshape"
  1616                 fi
  1617             fi
  1618             AC_ARG_ENABLE(video-x11-vm,
  1619 AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
  1620                             , enable_video_x11_vm=yes)
  1621             if test x$enable_video_x11_vm = xyes; then
  1622                 definitely_enable_video_x11_vm=no
  1623                 AC_CHECK_HEADER(X11/extensions/xf86vmode.h,
  1624                                 have_vm_h_hdr=yes,
  1625                                 have_vm_h_hdr=no,
  1626                                 [#include <X11/Xlib.h>
  1627                                 ])
  1628                 if test x$have_vm_h_hdr = xyes; then
  1629                     if test x$enable_x11_shared = xyes && test x$xvidmode_lib != x ; then
  1630                         echo "-- dynamic libXxf86vm -> $xvidmode_lib"
  1631                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE, "$xvidmode_lib", [ ])
  1632                         definitely_enable_video_x11_vm=yes
  1633                     else
  1634                         AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion, have_vm_lib=yes)
  1635                         if test x$have_vm_lib = xyes ; then
  1636                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXxf86vm"
  1637                             definitely_enable_video_x11_vm=yes
  1638                         fi
  1639                     fi
  1640                 fi
  1641             fi
  1642             if test x$definitely_enable_video_x11_vm = xyes; then
  1643                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XVIDMODE, 1, [ ])
  1644                 SUMMARY_video_x11="${SUMMARY_video_x11} xvidmode"
  1645             fi
  1646         fi
  1647     fi
  1648 }
  1649 
  1650 dnl Set up the Haiku video driver if enabled
  1651 CheckHaikuVideo()
  1652 {
  1653     if test x$enable_video = xyes; then
  1654         AC_DEFINE(SDL_VIDEO_DRIVER_HAIKU, 1, [ ])
  1655         SOURCES="$SOURCES $srcdir/src/video/haiku/*.cc"
  1656         have_video=yes
  1657         SUMMARY_video="${SUMMARY_video} haiku"
  1658     fi
  1659 }
  1660 
  1661 dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
  1662 CheckCOCOA()
  1663 {
  1664     AC_ARG_ENABLE(video-cocoa,
  1665 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
  1666                   , enable_video_cocoa=yes)
  1667     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  1668         save_CFLAGS="$CFLAGS"
  1669         dnl work around that we don't have Objective-C support in autoconf
  1670         CFLAGS="$CFLAGS -x objective-c"
  1671         AC_MSG_CHECKING(for Cocoa framework)
  1672         have_cocoa=no
  1673         AC_TRY_COMPILE([
  1674           #import <Cocoa/Cocoa.h>
  1675         ],[
  1676         ],[
  1677         have_cocoa=yes
  1678         ])
  1679         AC_MSG_RESULT($have_cocoa)
  1680         CFLAGS="$save_CFLAGS"
  1681         if test x$have_cocoa = xyes; then
  1682             AC_DEFINE(SDL_VIDEO_DRIVER_COCOA, 1, [ ])
  1683             SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
  1684             SUMMARY_video="${SUMMARY_video} cocoa"
  1685             have_video=yes
  1686         fi
  1687     fi
  1688 }
  1689 
  1690 dnl Find DirectFB
  1691 CheckDirectFB()
  1692 {
  1693     AC_ARG_ENABLE(video-directfb,
  1694 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
  1695                   , enable_video_directfb=no)
  1696     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  1697         video_directfb=no
  1698 
  1699         DIRECTFB_REQUIRED_VERSION=1.0.0
  1700         AC_PATH_PROGS(DIRECTFBCONFIG, directfb-config, no, [$prefix/bin:$PATH])
  1701         if test x$DIRECTFBCONFIG = xno; then
  1702             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1703             if test x$PKG_CONFIG != xno; then
  1704                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
  1705                     DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
  1706                     DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
  1707                     DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
  1708                     video_directfb=yes
  1709                 fi
  1710             fi
  1711         else
  1712             set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
  1713             NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1714             set -- `$DIRECTFBCONFIG --version | sed 's/\./ /g'`
  1715             HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1716             if test $HAVE_VERSION -ge $NEED_VERSION; then
  1717                 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
  1718                 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
  1719                 DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
  1720                 video_directfb=yes
  1721             fi
  1722         fi
  1723         if test x$video_directfb = xyes; then
  1724             # SuSE 11.1 installs directfb-config without directfb-devel
  1725             save_CPPFLAGS="$CPPFLAGS"
  1726             CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
  1727             AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
  1728             CPPFLAGS="$save_CPPFLAGS"
  1729             video_directfb=$have_directfb_hdr
  1730         fi
  1731         AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  1732         AC_MSG_RESULT($video_directfb)
  1733 
  1734         if test x$video_directfb = xyes; then
  1735             AC_ARG_ENABLE(directfb-shared,
  1736 AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
  1737                               , enable_directfb_shared=yes)
  1738 
  1739             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB, 1, [ ])
  1740             AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB, 1, [ ])
  1741             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  1742             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  1743 
  1744             AC_MSG_CHECKING(for directfb dynamic loading support)
  1745             directfb_shared=no
  1746             directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS"`]
  1747             # | sed 's/.*\/\(.*\)/\1/; q'`]
  1748 AC_MSG_WARN("directfb $directfb_lib")
  1749             if test x$have_loadso != xyes && \
  1750                test x$enable_directfb_shared = xyes; then
  1751                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
  1752             fi
  1753             if test x$have_loadso = xyes && \
  1754                test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
  1755                 directfb_shared=yes
  1756                 echo "-- $directfb_lib_spec -> $directfb_lib"
  1757                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib", [ ])
  1758                 SUMMARY_video="${SUMMARY_video} directfb(dynamic)"
  1759             else
  1760                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  1761                 SUMMARY_video="${SUMMARY_video} directfb"
  1762             fi
  1763             AC_MSG_RESULT($directfb_shared)
  1764             have_video=yes
  1765         fi
  1766     fi
  1767 }
  1768 
  1769 dnl Find FusionSound
  1770 CheckFusionSound()
  1771 {
  1772     AC_ARG_ENABLE(fusionsound,
  1773 AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
  1774                   , enable_fusionsound=no)
  1775     if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
  1776         fusionsound=no
  1777 
  1778         FUSIONSOUND_REQUIRED_VERSION=1.1.1
  1779 
  1780         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1781         AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
  1782         if test x$PKG_CONFIG != xno; then
  1783             if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
  1784                 FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
  1785                 FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
  1786                 fusionsound=yes
  1787             fi
  1788         fi
  1789         AC_MSG_RESULT($fusionsound)
  1790 
  1791         if test x$fusionsound = xyes; then
  1792             AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND, 1, [ ])
  1793             SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
  1794             EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
  1795             
  1796             AC_ARG_ENABLE(fusionsound-shared,
  1797 AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
  1798                           , enable_fusionsound_shared=yes)
  1799             fusionsound_shared=no
  1800             AC_MSG_CHECKING(for FusionSound dynamic loading support)
  1801             if test x$have_loadso != xyes && \
  1802                test x$enable_fusionsound_shared = xyes; then
  1803                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
  1804             fi
  1805             if test x$have_loadso = xyes && \
  1806                test x$enable_fusionsound_shared = xyes; then
  1807                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so", [ ])
  1808                 fusionsound_shared=yes
  1809                 SUMMARY_audio="${SUMMARY_audio} fusionsound(dynamic)"
  1810             else
  1811                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
  1812                 SUMMARY_audio="${SUMMARY_audio} fusionsound"
  1813             fi
  1814             AC_MSG_RESULT($fusionsound_shared)
  1815             
  1816             have_audio=yes
  1817         fi
  1818     fi
  1819 }
  1820 
  1821 dnl rcg04172001 Set up the Null video driver.
  1822 CheckDummyVideo()
  1823 {
  1824     AC_ARG_ENABLE(video-dummy,
  1825 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  1826                   , enable_video_dummy=yes)
  1827     if test x$enable_video_dummy = xyes; then
  1828         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY, 1, [ ])
  1829         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1830         have_video=yes
  1831         SUMMARY_video="${SUMMARY_video} dummy"
  1832     fi
  1833 }
  1834 
  1835 dnl Check to see if OpenGL support is desired
  1836 AC_ARG_ENABLE(video-opengl,
  1837 AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  1838               , enable_video_opengl=yes)
  1839 
  1840 dnl Find OpenGL
  1841 CheckOpenGLX11()
  1842 {
  1843     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1844         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1845         video_opengl=no
  1846         AC_TRY_COMPILE([
  1847          #include <GL/gl.h>
  1848          #include <GL/glx.h>
  1849         ],[
  1850         ],[
  1851         video_opengl=yes
  1852         ])
  1853         AC_MSG_RESULT($video_opengl)
  1854         if test x$video_opengl = xyes; then
  1855             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1856             AC_DEFINE(SDL_VIDEO_OPENGL_GLX, 1, [ ])
  1857             AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1858             SUMMARY_video="${SUMMARY_video} opengl"
  1859         fi
  1860     fi
  1861 }
  1862 
  1863 dnl Check to see if OpenGL ES support is desired
  1864 AC_ARG_ENABLE(video-opengles,
  1865 AC_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]),
  1866               , enable_video_opengles=yes)
  1867 
  1868 dnl Find OpenGL ES
  1869 CheckOpenGLESX11()
  1870 {
  1871     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  1872         AC_MSG_CHECKING(for EGL support)
  1873         video_opengl_egl=no
  1874         AC_TRY_COMPILE([
  1875          #include <EGL/egl.h>
  1876         ],[
  1877         ],[
  1878         video_opengl_egl=yes
  1879         ])
  1880         AC_MSG_RESULT($video_opengl_egl)
  1881         if test x$video_opengl_egl = xyes; then
  1882             AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
  1883         fi
  1884             
  1885         AC_MSG_CHECKING(for OpenGL ES v1 headers)
  1886         video_opengles_v1=no
  1887         AC_TRY_COMPILE([
  1888          #include <GLES/gl.h>
  1889          #include <GLES/glext.h>
  1890         ],[
  1891         ],[
  1892         video_opengles_v1=yes
  1893         ])
  1894         AC_MSG_RESULT($video_opengles_v1)
  1895         if test x$video_opengles_v1 = xyes; then
  1896             AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
  1897             AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
  1898             SUMMARY_video="${SUMMARY_video} opengl_es1"
  1899         fi
  1900         
  1901         AC_MSG_CHECKING(for OpenGL ES v2 headers)
  1902         video_opengles_v2=no
  1903         AC_TRY_COMPILE([
  1904          #include <GLES2/gl2.h>
  1905          #include <GLES2/gl2ext.h>
  1906         ],[
  1907         ],[
  1908         video_opengles_v2=yes
  1909         ])
  1910         AC_MSG_RESULT($video_opengles_v2)
  1911         if test x$video_opengles_v2 = xyes; then
  1912             AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  1913             AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  1914             SUMMARY_video="${SUMMARY_video} opengl_es2"
  1915         fi
  1916     fi
  1917 }
  1918 
  1919 dnl Check for Windows OpenGL
  1920 CheckWINDOWSGL()
  1921 {
  1922     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1923         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1924         AC_DEFINE(SDL_VIDEO_OPENGL_WGL, 1, [ ])
  1925         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1926         SUMMARY_video="${SUMMARY_video} opengl"
  1927     fi
  1928 }
  1929 
  1930 dnl Check for Windows OpenGL
  1931 CheckWINDOWSGLES()
  1932 {
  1933     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  1934 
  1935         AC_MSG_CHECKING(for EGL support)
  1936         video_opengl_egl=no
  1937         AC_TRY_COMPILE([
  1938          #include <EGL/egl.h>
  1939         ],[
  1940         ],[
  1941         video_opengl_egl=yes
  1942         ])
  1943         AC_MSG_RESULT($video_opengl_egl)
  1944         if test x$video_opengl_egl = xyes; then
  1945             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1946             AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
  1947             SUMMARY_video="${SUMMARY_video} opengl_es1"
  1948         fi
  1949        
  1950         AC_MSG_CHECKING(for OpenGL ES v2 headers)
  1951         video_opengles_v2=no
  1952         AC_TRY_COMPILE([
  1953          #include <GLES2/gl2.h>
  1954          #include <GLES2/gl2ext.h>
  1955         ],[
  1956         ],[
  1957         video_opengles_v2=yes
  1958         ])
  1959         AC_MSG_RESULT($video_opengles_v2)
  1960         if test x$video_opengles_v2 = xyes; then
  1961             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1962             AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  1963             AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  1964             SUMMARY_video="${SUMMARY_video} opengl_es2"
  1965         fi
  1966     fi
  1967 }
  1968 
  1969 dnl Check for Haiku OpenGL
  1970 CheckHaikuGL()
  1971 {
  1972     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1973         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1974         AC_DEFINE(SDL_VIDEO_OPENGL_HAIKU, 1, [ ])
  1975         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1976         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1977         SUMMARY_video="${SUMMARY_video} opengl"
  1978     fi
  1979 }
  1980 
  1981 dnl Check for MacOS OpenGL
  1982 CheckMacGL()
  1983 {
  1984     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1985         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1986         AC_DEFINE(SDL_VIDEO_OPENGL_CGL, 1, [ ])
  1987         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1988         SUMMARY_video="${SUMMARY_video} opengl"
  1989         case "$host" in
  1990             *-*-darwin*)
  1991                 if test x$enable_video_cocoa = xyes; then
  1992                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
  1993                 fi
  1994         esac
  1995     fi
  1996 }
  1997 
  1998 dnl See if we can use the new unified event interface in Linux 2.4
  1999 CheckInputEvents()
  2000 {
  2001     dnl Check for Linux 2.4 unified input event interface support
  2002         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  2003         use_input_events=no
  2004         AC_TRY_COMPILE([
  2005           #include <linux/input.h>
  2006         ],[
  2007           #ifndef EVIOCGNAME
  2008           #error EVIOCGNAME() ioctl not available
  2009           #endif
  2010         ],[
  2011         use_input_events=yes
  2012         ])
  2013         AC_MSG_RESULT($use_input_events)
  2014         if test x$use_input_events = xyes; then
  2015             AC_DEFINE(SDL_INPUT_LINUXEV, 1, [ ])
  2016             SUMMARY_input="${SUMMARY_input} linuxev"
  2017         fi
  2018 }
  2019 
  2020 dnl See if we can use the kernel kd.h header
  2021 CheckInputKD()
  2022 {
  2023 
  2024     AC_MSG_CHECKING(for Linux kd.h)
  2025     use_input_kd=no
  2026     AC_TRY_COMPILE([
  2027       #include <linux/kd.h>
  2028       #include <linux/keyboard.h>
  2029     ],[
  2030         struct kbentry kbe;
  2031         kbe.kb_table = KG_CTRL;
  2032         ioctl(0, KDGKBENT, &kbe);
  2033     ],[
  2034     use_input_kd=yes
  2035     ])
  2036     AC_MSG_RESULT($use_input_kd)
  2037     if test x$use_input_kd = xyes; then
  2038         AC_DEFINE(SDL_INPUT_LINUXKD, 1, [ ])
  2039         SUMMARY_input="${SUMMARY_input} linuxkd"
  2040     fi
  2041 }
  2042 
  2043 dnl See if the platform offers libudev for device enumeration and hotplugging.
  2044 CheckLibUDev()
  2045 {
  2046     AC_ARG_ENABLE(libudev,
  2047 AC_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
  2048                         , enable_libudev=yes)
  2049     if test x$enable_libudev = xyes; then
  2050         AC_CHECK_HEADER(libudev.h,
  2051                         have_libudev_h_hdr=yes,
  2052                         have_libudev_h_hdr=no)
  2053         if test x$have_libudev_h_hdr = xyes; then
  2054             AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])
  2055         fi
  2056     fi
  2057 }
  2058 
  2059 dnl See if the platform offers libdbus for various IPC techniques.
  2060 CheckDBus()
  2061 {
  2062     AC_ARG_ENABLE(dbus,
  2063 AC_HELP_STRING([--enable-dbus], [enable D-Bus support [[default=yes]]]),
  2064                         , enable_dbus=yes)
  2065     if test x$enable_dbus = xyes; then
  2066         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  2067         if test x$PKG_CONFIG != xno; then
  2068             DBUS_CFLAGS=`$PKG_CONFIG --cflags dbus-1`
  2069             save_CFLAGS="$CFLAGS"
  2070             CFLAGS="$save_CFLAGS $DBUS_CFLAGS"
  2071             AC_CHECK_HEADER(dbus/dbus.h,
  2072                             have_dbus_dbus_h_hdr=yes,
  2073                             have_dbus_dbus_h_hdr=no)
  2074             CFLAGS="$save_CFLAGS"
  2075             if test x$have_dbus_dbus_h_hdr = xyes; then
  2076                 AC_DEFINE(HAVE_DBUS_DBUS_H, 1, [ ])
  2077                 EXTRA_CFLAGS="$EXTRA_CFLAGS $DBUS_CFLAGS"
  2078             fi
  2079         fi
  2080     fi
  2081 }
  2082 
  2083 dnl See if we can use the Touchscreen input library
  2084 CheckTslib()
  2085 {
  2086     AC_ARG_ENABLE(input-tslib,
  2087 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  2088                   , enable_input_tslib=yes)
  2089     if test x$enable_input_tslib = xyes; then
  2090         AC_MSG_CHECKING(for Touchscreen library support)
  2091         enable_input_tslib=no
  2092         AC_TRY_COMPILE([
  2093           #include "tslib.h"
  2094         ],[
  2095         ],[
  2096         enable_input_tslib=yes
  2097         ])
  2098         AC_MSG_RESULT($enable_input_tslib)
  2099         if test x$enable_input_tslib = xyes; then
  2100             AC_DEFINE(SDL_INPUT_TSLIB, 1, [ ])
  2101             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  2102             SUMMARY_input="${SUMMARY_input} ts"
  2103         fi
  2104     fi
  2105 }
  2106 
  2107 dnl See what type of thread model to use on Linux and Solaris
  2108 CheckPTHREAD()
  2109 {
  2110     dnl Check for pthread support
  2111     AC_ARG_ENABLE(pthreads,
  2112 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  2113                   , enable_pthreads=yes)
  2114     dnl This is used on Linux for glibc binary compatibility (Doh!)
  2115     AC_ARG_ENABLE(pthread-sem,
  2116 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  2117                   , enable_pthread_sem=yes)
  2118     case "$host" in
  2119         *-*-linux*|*-*-uclinux*)
  2120             pthread_cflags="-D_REENTRANT"
  2121             pthread_lib="-lpthread"
  2122             ;;
  2123         *-*-bsdi*)
  2124             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2125             pthread_lib=""
  2126             ;;
  2127         *-*-darwin*)
  2128             pthread_cflags="-D_THREAD_SAFE"
  2129 # causes Carbon.p complaints?
  2130 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2131             ;;
  2132         *-*-freebsd*|*-*-dragonfly*)
  2133             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2134             pthread_lib="-pthread"
  2135             ;;
  2136         *-*-netbsd*)
  2137             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2138             pthread_lib="-lpthread"
  2139             ;;
  2140         *-*-openbsd*)
  2141             pthread_cflags="-D_REENTRANT"
  2142             pthread_lib="-pthread"
  2143             ;;
  2144         *-*-solaris2.9)
  2145             # From Solaris 9+, posix4's preferred name is rt.
  2146             pthread_cflags="-D_REENTRANT"
  2147             pthread_lib="-lpthread -lrt"
  2148             ;;
  2149         *-*-solaris2.10)
  2150             # Solaris 10+ merged pthread into libc.
  2151             pthread_cflags="-D_REENTRANT"
  2152             pthread_lib="-lrt"
  2153             ;;
  2154         *-*-solaris*)
  2155             # Solaris 11+ merged rt into libc.
  2156             pthread_cflags="-D_REENTRANT"
  2157             pthread_lib=""
  2158             ;;
  2159         *-*-sysv5*)
  2160             pthread_cflags="-D_REENTRANT -Kthread"
  2161             pthread_lib=""
  2162             ;;
  2163         *-*-aix*)
  2164             pthread_cflags="-D_REENTRANT -mthreads"
  2165             pthread_lib="-lpthread"
  2166             ;;
  2167         *-*-hpux11*)
  2168             pthread_cflags="-D_REENTRANT"
  2169             pthread_lib="-L/usr/lib -lpthread"
  2170             ;;
  2171         *-*-haiku*)
  2172             pthread_cflags="-D_REENTRANT"
  2173             pthread_lib=""
  2174             ;;
  2175         *)
  2176             pthread_cflags="-D_REENTRANT"
  2177             pthread_lib="-lpthread"
  2178             ;;
  2179     esac
  2180     if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
  2181         # Save the original compiler flags and libraries
  2182         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  2183         # Add the pthread compiler flags and libraries
  2184         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  2185         # Check to see if we have pthread support on this system
  2186         AC_MSG_CHECKING(for pthreads)
  2187         use_pthreads=no
  2188         AC_TRY_LINK([
  2189          #include <pthread.h>
  2190         ],[
  2191          pthread_attr_t type;
  2192          pthread_attr_init(&type);
  2193         ],[
  2194         use_pthreads=yes
  2195         ])
  2196         AC_MSG_RESULT($use_pthreads)
  2197         # Restore the compiler flags and libraries
  2198         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  2199 
  2200         # Do futher testing if we have pthread support...
  2201         if test x$use_pthreads = xyes; then
  2202             AC_DEFINE(SDL_THREAD_PTHREAD, 1, [ ])
  2203             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  2204             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  2205             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  2206             SDL_LIBS="$SDL_LIBS $pthread_lib"
  2207 
  2208             # Save the original compiler flags and libraries
  2209             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  2210             # Add the pthread compiler flags and libraries
  2211             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  2212 
  2213             # Check to see if recursive mutexes are available
  2214             AC_MSG_CHECKING(for recursive mutexes)
  2215             has_recursive_mutexes=no
  2216             if test x$has_recursive_mutexes = xno; then
  2217                 AC_TRY_COMPILE([
  2218                   #include <pthread.h>
  2219                 ],[
  2220                   pthread_mutexattr_t attr;
  2221                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  2222                 ],[
  2223                 has_recursive_mutexes=yes
  2224                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX, 1, [ ])
  2225                 ])
  2226             fi
  2227             if test x$has_recursive_mutexes = xno; then
  2228                 AC_TRY_COMPILE([
  2229                   #include <pthread.h>
  2230                 ],[
  2231                   pthread_mutexattr_t attr;
  2232                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  2233                 ],[
  2234                 has_recursive_mutexes=yes
  2235                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP, 1, [ ])
  2236                 ])
  2237             fi
  2238             AC_MSG_RESULT($has_recursive_mutexes)
  2239 
  2240             # Check to see if pthread semaphore support is missing
  2241             if test x$enable_pthread_sem = xyes; then
  2242                 AC_MSG_CHECKING(for pthread semaphores)
  2243                 have_pthread_sem=no
  2244                 AC_TRY_COMPILE([
  2245                   #include <pthread.h>
  2246                   #include <semaphore.h>
  2247                 ],[
  2248                 ],[
  2249                 have_pthread_sem=yes
  2250                 ])
  2251                 AC_MSG_RESULT($have_pthread_sem)
  2252             fi
  2253             if test x$have_pthread_sem = xyes; then
  2254                 AC_MSG_CHECKING(for sem_timedwait)
  2255                 have_sem_timedwait=no
  2256                 AC_TRY_LINK([
  2257                   #include <pthread.h>
  2258                   #include <semaphore.h>
  2259                 ],[
  2260                   sem_timedwait(NULL, NULL);
  2261                 ],[
  2262                 have_sem_timedwait=yes
  2263                 AC_DEFINE(HAVE_SEM_TIMEDWAIT)
  2264                 ])
  2265                 AC_MSG_RESULT($have_sem_timedwait)
  2266             fi
  2267 
  2268             AC_MSG_CHECKING(for pthread_spin_trylock)
  2269             AC_TRY_LINK_FUNC(pthread_spin_trylock, [
  2270               has_pthread_spin_trylock=yes
  2271               AC_DEFINE(HAVE_PTHREAD_SPINLOCK, 1, [ ])
  2272             ],[
  2273               has_pthread_spin_trylock=no
  2274             ])
  2275             AC_MSG_RESULT($has_pthread_spin_trylock)
  2276 
  2277             AC_CHECK_HEADER(pthread_np.h, have_pthread_np_h=yes, have_pthread_np_h=no, [ #include <pthread.h> ])
  2278             if test x$have_pthread_np_h = xyes; then
  2279                 AC_DEFINE(HAVE_PTHREAD_NP_H, 1, [ ])
  2280             fi
  2281 
  2282             # Check to see if pthread naming is available
  2283             AC_MSG_CHECKING(for pthread_setname_np)
  2284             AC_TRY_LINK_FUNC(pthread_setname_np, [
  2285               has_pthread_setname_np=yes
  2286               AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [ ])
  2287             ],[
  2288               has_pthread_setname_np=no
  2289             ])
  2290             AC_MSG_RESULT($has_pthread_setname_np)
  2291 
  2292             AC_MSG_CHECKING(for pthread_set_name_np)
  2293             AC_TRY_LINK_FUNC(pthread_set_name_np, [
  2294               has_pthread_set_name_np=yes
  2295               AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [ ])
  2296             ],[
  2297               has_pthread_set_name_np=no
  2298             ])
  2299             AC_MSG_RESULT($has_pthread_set_name_np)
  2300 
  2301             # Restore the compiler flags and libraries
  2302             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  2303 
  2304             # Basic thread creation functions
  2305             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  2306 
  2307             # Semaphores
  2308             # We can fake these with mutexes and condition variables if necessary
  2309             if test x$have_pthread_sem = xyes; then
  2310                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  2311             else
  2312                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  2313             fi
  2314 
  2315             # Mutexes
  2316             # We can fake these with semaphores if necessary
  2317             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  2318 
  2319             # Condition variables
  2320             # We can fake these with semaphores and mutexes if necessary
  2321             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  2322 
  2323             # Thread local storage
  2324             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systls.c"
  2325 
  2326             have_threads=yes
  2327         fi
  2328     fi
  2329 }
  2330 
  2331 dnl Determine whether the compiler can produce Windows executables
  2332 CheckWINDOWS()
  2333 {
  2334     AC_MSG_CHECKING(Windows compiler)
  2335     have_win32_gcc=no
  2336     AC_TRY_COMPILE([
  2337      #include <windows.h>
  2338     ],[
  2339     ],[
  2340     have_win32_gcc=yes
  2341     ])
  2342     AC_MSG_RESULT($have_win32_gcc)
  2343     if test x$have_win32_gcc != xyes; then
  2344        AC_MSG_ERROR([
  2345 *** Your compiler ($CC) does not produce Windows executables!
  2346        ])
  2347     fi
  2348 
  2349     AC_MSG_CHECKING(Windows CE)
  2350     have_wince=no
  2351     AC_TRY_COMPILE([
  2352 #if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
  2353 #error This is not Windows CE
  2354 #endif
  2355     ],[
  2356     ],[
  2357     have_wince=yes
  2358        AC_MSG_ERROR([
  2359 *** Sorry, Windows CE is no longer supported.
  2360        ])
  2361     ])
  2362     AC_MSG_RESULT($have_wince)
  2363 
  2364     # This fixes Windows stack alignment with newer GCC
  2365     CheckStackBoundary
  2366 }
  2367 
  2368 dnl Find the DirectX includes and libraries
  2369 CheckDIRECTX()
  2370 {
  2371     AC_ARG_ENABLE(directx,
  2372 AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
  2373                   , enable_directx=yes)
  2374     if test x$enable_directx = xyes; then
  2375         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  2376         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  2377         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  2378         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  2379         AC_CHECK_HEADER(xaudio2.h, have_xaudio2=yes)
  2380 
  2381         SUMMARY_video="${SUMMARY_video} directx"
  2382         SUMMARY_audio="${SUMMARY_audio} directx"
  2383 
  2384         # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
  2385         # FIXME:  ...so force it off for now.
  2386         case "$host" in
  2387             *-*-cygwin*)
  2388             have_dinput=false
  2389             ;;
  2390         esac
  2391     fi
  2392 }
  2393 
  2394 dnl Check for the dlfcn.h interface for dynamically loading objects
  2395 CheckDLOPEN()
  2396 {
  2397     AC_ARG_ENABLE(sdl-dlopen,
  2398 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  2399                   , enable_sdl_dlopen=yes)
  2400     if test x$enable_sdl_dlopen = xyes; then
  2401         AC_MSG_CHECKING(for dlopen)
  2402         have_dlopen=no
  2403         AC_TRY_COMPILE([
  2404          #include <dlfcn.h>
  2405         ],[
  2406          void *handle = dlopen("", RTLD_NOW);
  2407          const char *loaderror = (char *) dlerror();
  2408         ],[
  2409         have_dlopen=yes
  2410         ])
  2411         AC_MSG_RESULT($have_dlopen)
  2412 
  2413         if test x$have_dlopen = xyes; then
  2414             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  2415                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  2416                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  2417             AC_DEFINE(SDL_LOADSO_DLOPEN, 1, [ ])
  2418             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  2419             have_loadso=yes
  2420         fi
  2421     fi
  2422 }
  2423 
  2424 dnl Check for the usbhid(3) library on *BSD
  2425 CheckUSBHID()
  2426 {
  2427     case "$host" in
  2428         *-*-*bsd*)
  2429             if test x$enable_joystick = xyes; then
  2430                 AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  2431                 if test x$have_libusbhid = xyes; then
  2432                     AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  2433                     AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  2434                     USB_LIBS="$USB_LIBS -lusbhid"
  2435                 else
  2436                     AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  2437                     AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  2438                     AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  2439                 fi
  2440                     
  2441                 save_CFLAGS="$CFLAGS"
  2442                 CFLAGS="$CFLAGS $USB_CFLAGS"
  2443 
  2444                 AC_MSG_CHECKING(for usbhid)
  2445                 have_usbhid=no
  2446                 AC_TRY_COMPILE([
  2447                   #include <sys/types.h>
  2448                   #if defined(HAVE_USB_H)
  2449                   #include <usb.h>
  2450                   #endif
  2451                   #ifdef __DragonFly__
  2452                   # include <bus/usb/usb.h>
  2453                   # include <bus/usb/usbhid.h>
  2454                   #else
  2455                   # include <dev/usb/usb.h>
  2456                   # include <dev/usb/usbhid.h>
  2457                   #endif
  2458                   #if defined(HAVE_USBHID_H)
  2459                   #include <usbhid.h>
  2460                   #elif defined(HAVE_LIBUSB_H)
  2461                   #include <libusb.h>
  2462                   #elif defined(HAVE_LIBUSBHID_H)
  2463                   #include <libusbhid.h>
  2464                   #endif
  2465                 ],[
  2466                   struct report_desc *repdesc;
  2467                   struct usb_ctl_report *repbuf;
  2468                   hid_kind_t hidkind;
  2469                 ],[
  2470                 have_usbhid=yes
  2471                 ])
  2472                 AC_MSG_RESULT($have_usbhid)
  2473 
  2474                 if test x$have_usbhid = xyes; then
  2475                     AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  2476                     have_usbhid_ucr_data=no
  2477                     AC_TRY_COMPILE([
  2478                       #include <sys/types.h>
  2479                       #if defined(HAVE_USB_H)
  2480                       #include <usb.h>
  2481                       #endif
  2482                       #ifdef __DragonFly__
  2483                       # include <bus/usb/usb.h>
  2484                       # include <bus/usb/usbhid.h>
  2485                       #else
  2486                       # include <dev/usb/usb.h>
  2487                       # include <dev/usb/usbhid.h>
  2488                       #endif
  2489                       #if defined(HAVE_USBHID_H)
  2490                       #include <usbhid.h>
  2491                       #elif defined(HAVE_LIBUSB_H)
  2492                       #include <libusb.h>
  2493                       #elif defined(HAVE_LIBUSBHID_H)
  2494                       #include <libusbhid.h>
  2495                       #endif
  2496                     ],[
  2497                       struct usb_ctl_report buf;
  2498                       if (buf.ucr_data) { }
  2499                     ],[
  2500                     have_usbhid_ucr_data=yes
  2501                     ])
  2502                     if test x$have_usbhid_ucr_data = xyes; then
  2503                         USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  2504                     fi
  2505                     AC_MSG_RESULT($have_usbhid_ucr_data)
  2506                     
  2507                     AC_MSG_CHECKING(for new usbhid API)
  2508                     have_usbhid_new=no
  2509                     AC_TRY_COMPILE([
  2510                       #include <sys/types.h>
  2511                       #if defined(HAVE_USB_H)
  2512                       #include <usb.h>
  2513                       #endif
  2514                       #ifdef __DragonFly__
  2515                       #include <bus/usb/usb.h>
  2516                       #include <bus/usb/usbhid.h>
  2517                       #else
  2518                       #include <dev/usb/usb.h>
  2519                       #include <dev/usb/usbhid.h>
  2520                       #endif
  2521                       #if defined(HAVE_USBHID_H)
  2522                       #include <usbhid.h>
  2523                       #elif defined(HAVE_LIBUSB_H)
  2524                       #include <libusb.h>
  2525                       #elif defined(HAVE_LIBUSBHID_H)
  2526                       #include <libusbhid.h>
  2527                       #endif
  2528                     ],[
  2529                       report_desc_t d;
  2530                       hid_start_parse(d, 1, 1);
  2531                     ],[
  2532                     have_usbhid_new=yes
  2533                     ])
  2534                     if test x$have_usbhid_new = xyes; then
  2535                         USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  2536                     fi
  2537                     AC_MSG_RESULT($have_usbhid_new)
  2538 
  2539                     AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  2540                     have_machine_joystick=no
  2541                     AC_TRY_COMPILE([
  2542                       #include <machine/joystick.h>
  2543                     ],[
  2544                       struct joystick t;
  2545                     ],[
  2546                     have_machine_joystick=yes
  2547                     ])
  2548                     if test x$have_machine_joystick = xyes; then
  2549                         AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
  2550                     fi
  2551                     AC_MSG_RESULT($have_machine_joystick)
  2552 
  2553                     AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
  2554                     SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  2555                     EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  2556                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  2557                     have_joystick=yes
  2558                 fi
  2559                 CFLAGS="$save_CFLAGS"
  2560             fi
  2561         ;;
  2562     esac
  2563 }
  2564 
  2565 dnl Check for clock_gettime()
  2566 CheckClockGettime()
  2567 {
  2568     AC_ARG_ENABLE(clock_gettime,
  2569 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=yes]]]),
  2570                   , enable_clock_gettime=yes)
  2571     if test x$enable_clock_gettime = xyes; then
  2572         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  2573         if test x$have_clock_gettime = xyes; then
  2574             AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  2575             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  2576         else
  2577             AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
  2578             if test x$have_clock_gettime = xyes; then
  2579                AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  2580                EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
  2581             fi
  2582         fi
  2583     fi
  2584 }
  2585 
  2586 dnl Check for a valid linux/version.h
  2587 CheckLinuxVersion()
  2588 {
  2589     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  2590     if test x$have_linux_version_h = xyes; then
  2591         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  2592     fi
  2593 }
  2594 
  2595 dnl Check if we want to use RPATH
  2596 CheckRPATH()
  2597 {
  2598     AC_ARG_ENABLE(rpath,
  2599 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  2600                   , enable_rpath=yes)
  2601 }
  2602 
  2603 dnl Set up the configuration based on the host platform!
  2604 case "$host" in
  2605     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*)
  2606         case "$host" in
  2607             *-raspberry-linux*)
  2608                 # Raspberry Pi
  2609                 ARCH=linux
  2610                 RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
  2611                 CFLAGS="$CFLAGS $RPI_CFLAGS"
  2612                 SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
  2613                 EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
  2614                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L/opt/vc/lib -lbcm_host -ldl"
  2615 
  2616                 if test x$enable_video = xyes; then
  2617                     SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
  2618                     $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
  2619                 fi
  2620                 ;;
  2621             *-*-linux*)         ARCH=linux ;;
  2622             *-*-uclinux*)       ARCH=linux ;;
  2623             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  2624             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  2625             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  2626             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  2627             *-*-bsdi*)          ARCH=bsdi ;;
  2628             *-*-freebsd*)       ARCH=freebsd ;;
  2629             *-*-dragonfly*)     ARCH=freebsd ;;
  2630             *-*-netbsd*)        ARCH=netbsd ;;
  2631             *-*-openbsd*)       ARCH=openbsd ;;
  2632             *-*-sysv5*)         ARCH=sysv5 ;;
  2633             *-*-solaris*)       ARCH=solaris ;;
  2634             *-*-hpux*)          ARCH=hpux ;;
  2635             *-*-aix*)           ARCH=aix ;;
  2636             *-*-minix*)         ARCH=minix ;;
  2637         esac
  2638         CheckVisibilityHidden
  2639         CheckDummyVideo
  2640         CheckDiskAudio
  2641         CheckDummyAudio
  2642         CheckDLOPEN
  2643         CheckOSS
  2644         CheckALSA
  2645         CheckPulseAudio
  2646         CheckARTSC
  2647         CheckESD
  2648         CheckNAS
  2649         CheckSNDIO
  2650         CheckX11
  2651         CheckWayland
  2652         CheckMir
  2653         CheckDirectFB
  2654         CheckFusionSound
  2655         CheckOpenGLX11
  2656         CheckOpenGLESX11
  2657         CheckLibUDev
  2658         CheckDBus
  2659         CheckInputEvents
  2660         CheckInputKD
  2661         CheckTslib
  2662         CheckUSBHID
  2663         CheckPTHREAD
  2664         CheckClockGettime
  2665         CheckLinuxVersion
  2666         CheckRPATH
  2667         # Set up files for the audio library
  2668         if test x$enable_audio = xyes; then
  2669           case $ARCH in
  2670             sysv5|solaris|hpux)
  2671                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
  2672                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2673                 have_audio=yes
  2674             ;;
  2675             netbsd)  # Don't use this on OpenBSD, it's busted.
  2676                 AC_DEFINE(SDL_AUDIO_DRIVER_BSD, 1, [ ])
  2677                 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
  2678                 have_audio=yes
  2679             ;;
  2680             aix)
  2681                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO, 1, [ ])
  2682                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  2683                 have_audio=yes
  2684             ;;
  2685           esac
  2686         fi
  2687         # Set up files for the joystick library
  2688         if test x$enable_joystick = xyes; then
  2689           case $ARCH in
  2690             linux)
  2691                 AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ])
  2692                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  2693                 have_joystick=yes
  2694             ;;
  2695           esac
  2696         fi
  2697         # Set up files for the haptic library
  2698         if test x$enable_haptic = xyes; then
  2699            if test x$use_input_events = xyes; then
  2700              case $ARCH in
  2701                linux)
  2702                    AC_DEFINE(SDL_HAPTIC_LINUX, 1, [ ])
  2703                    SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  2704                    have_haptic=yes
  2705                ;;
  2706              esac
  2707            fi
  2708         fi
  2709         # Set up files for the power library
  2710         if test x$enable_power = xyes; then
  2711              case $ARCH in
  2712                linux)
  2713                    AC_DEFINE(SDL_POWER_LINUX, 1, [ ])
  2714                    SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
  2715                    have_power=yes
  2716                ;;
  2717              esac
  2718         fi
  2719         # Set up files for the filesystem library
  2720         if test x$enable_filesystem = xyes; then
  2721             AC_DEFINE(SDL_FILESYSTEM_UNIX, 1, [ ])
  2722             SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
  2723             have_filesystem=yes
  2724         fi
  2725         # Set up files for the timer library
  2726         if test x$enable_timers = xyes; then
  2727             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  2728             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2729             have_timers=yes
  2730         fi
  2731         # Set up files for udev hotplugging support
  2732         if test x$enable_libudev = xyes && test x$have_libudev_h_hdr = xyes; then
  2733             SOURCES="$SOURCES $srcdir/src/core/linux/SDL_udev.c"               
  2734         fi
  2735         # Set up files for evdev input
  2736         if test x$use_input_events = xyes; then
  2737             SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev.c"
  2738         fi       
  2739         ;;
  2740     *-*-cygwin* | *-*-mingw32*)
  2741         ARCH=win32
  2742         if test "$build" != "$host"; then # cross-compiling
  2743             # Default cross-compile location
  2744             ac_default_prefix=/usr/local/cross-tools/$host
  2745         else
  2746             # Look for the location of the tools and install there
  2747             if test "$BUILD_PREFIX" != ""; then
  2748                 ac_default_prefix=$BUILD_PREFIX
  2749             fi
  2750         fi
  2751         CheckDummyVideo
  2752         CheckDiskAudio
  2753         CheckDummyAudio
  2754         CheckWINDOWS
  2755         CheckWINDOWSGL
  2756         CheckWINDOWSGLES
  2757         CheckDIRECTX
  2758 
  2759         # Set up the core platform files
  2760         SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
  2761 
  2762         # Set up files for the video library
  2763         if test x$enable_video = xyes; then
  2764             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS, 1, [ ])
  2765             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
  2766             have_video=yes
  2767             AC_ARG_ENABLE(render-d3d,
  2768 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2769                                 , enable_render_d3d=yes)
  2770             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2771                 AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ])
  2772             fi
  2773         fi
  2774         # Set up files for the audio library
  2775         if test x$enable_audio = xyes; then
  2776             AC_DEFINE(SDL_AUDIO_DRIVER_WINMM, 1, [ ])
  2777             SOURCES="$SOURCES $srcdir/src/audio/winmm/*.c"
  2778             if test x$have_dsound = xyes; then
  2779                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
  2780                 SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
  2781             fi
  2782             if test x$have_xaudio2 = xyes; then
  2783                 AC_DEFINE(SDL_AUDIO_DRIVER_XAUDIO2, 1, [ ])
  2784                 SOURCES="$SOURCES $srcdir/src/audio/xaudio2/*.c"
  2785             fi
  2786             have_audio=yes
  2787         fi
  2788         # Set up files for the joystick library
  2789         if test x$enable_joystick = xyes; then
  2790             if test x$have_dinput = xyes; then
  2791                 AC_DEFINE(SDL_JOYSTICK_DINPUT, 1, [ ])
  2792                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_dxjoystick.c"
  2793                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
  2794             else
  2795                 AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
  2796                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_mmjoystick.c"
  2797             fi
  2798             have_joystick=yes
  2799         fi
  2800         if test x$enable_haptic = xyes; then
  2801             if test x$have_dinput = xyes; then
  2802                 AC_DEFINE(SDL_HAPTIC_DINPUT, 1, [ ])
  2803                 SOURCES="$SOURCES $srcdir/src/haptic/windows/SDL_syshaptic.c"
  2804                 have_haptic=yes
  2805             fi
  2806         fi
  2807         if test x$enable_power = xyes; then
  2808             AC_DEFINE(SDL_POWER_WINDOWS, 1, [ ])
  2809             SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
  2810             have_power=yes
  2811         fi
  2812         if test x$enable_filesystem = xyes; then
  2813             AC_DEFINE(SDL_FILESYSTEM_WINDOWS, 1, [ ])
  2814             SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c"
  2815             have_filesystem=yes
  2816         fi
  2817         # Set up files for the thread library
  2818         if test x$enable_threads = xyes; then
  2819             AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ])
  2820             SOURCES="$SOURCES $srcdir/src/thread/windows/*.c"
  2821             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2822             have_threads=yes
  2823         fi
  2824         # Set up files for the timer library
  2825         if test x$enable_timers = xyes; then
  2826             AC_DEFINE(SDL_TIMER_WINDOWS, 1, [ ])
  2827             SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
  2828             have_timers=yes
  2829         fi
  2830         # Set up files for the shared object loading library
  2831         if test x$enable_loadso = xyes; then
  2832             AC_DEFINE(SDL_LOADSO_WINDOWS, 1, [ ])
  2833             SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
  2834             have_loadso=yes
  2835         fi
  2836         # Set up the system libraries we need
  2837         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -XCClinker -static-libgcc"
  2838         # The Windows platform requires special setup
  2839         VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
  2840         SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
  2841         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2842         SDL_LIBS="-lSDL2main $SDL_LIBS -mwindows"
  2843 
  2844         # Check to see if this is a mingw or cygwin build
  2845         have_mingw32=
  2846         AC_CHECK_LIB(mingw32, main, [have_mingw32=yes])
  2847         if test x$have_mingw32 = xyes; then
  2848             SDL_LIBS="-lmingw32 $SDL_LIBS"
  2849         else
  2850             SDL_LIBS="-lcygwin $SDL_LIBS"
  2851         fi
  2852         ;;
  2853 
  2854     dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
  2855     *-*-beos*)
  2856         AC_MSG_ERROR([
  2857 *** BeOS support has been removed as of SDL 2.0.2.
  2858         ])
  2859         ;;
  2860 
  2861     *-*-haiku*)
  2862         ARCH=haiku
  2863         ac_default_prefix=/boot/system
  2864         CheckDummyVideo
  2865         CheckDiskAudio
  2866         CheckDummyAudio
  2867         CheckHaikuVideo
  2868         CheckHaikuGL
  2869         CheckPTHREAD
  2870 
  2871         # Set up files for the audio library
  2872         if test x$enable_audio = xyes; then
  2873             AC_DEFINE(SDL_AUDIO_DRIVER_HAIKU, 1, [ ])
  2874             SOURCES="$SOURCES $srcdir/src/audio/haiku/*.cc"
  2875             have_audio=yes
  2876         fi
  2877         # Set up files for the joystick library
  2878         if test x$enable_joystick = xyes; then
  2879             AC_DEFINE(SDL_JOYSTICK_HAIKU, 1, [ ])
  2880             SOURCES="$SOURCES $srcdir/src/joystick/haiku/*.cc"
  2881             have_joystick=yes
  2882         fi
  2883         # Set up files for the timer library
  2884         if test x$enable_timers = xyes; then
  2885             AC_DEFINE(SDL_TIMER_HAIKU, 1, [ ])
  2886             SOURCES="$SOURCES $srcdir/src/timer/haiku/*.c"
  2887             have_timers=yes
  2888         fi
  2889         # Set up files for the shared object loading library
  2890         if test x$enable_loadso = xyes; then
  2891             AC_DEFINE(SDL_LOADSO_HAIKU, 1, [ ])
  2892             SOURCES="$SOURCES $srcdir/src/loadso/haiku/*.c"
  2893             have_loadso=yes
  2894         fi
  2895         # Set up files for the system power library
  2896         if test x$enable_power = xyes; then
  2897             AC_DEFINE(SDL_POWER_HAIKU, 1, [ ])
  2898             SOURCES="$SOURCES $srcdir/src/power/haiku/*.c"
  2899             have_power=yes
  2900         fi
  2901         # Set up files for the system filesystem library
  2902         if test x$enable_filesystem = xyes; then
  2903             AC_DEFINE(SDL_FILESYSTEM_HAIKU, 1, [ ])
  2904             SOURCES="$SOURCES $srcdir/src/filesystem/haiku/*.cc"
  2905             have_filesystem=yes
  2906         fi
  2907         # The Haiku platform requires special setup.
  2908         SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
  2909         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2910         ;;
  2911     arm*-apple-darwin*)
  2912         # iOS - We are not writing anything to confdefs.h because you have to replace
  2913         # SDL_config.h for SDL_config_iphoneos.h anyway
  2914         ARCH=ios
  2915 
  2916         CheckVisibilityHidden
  2917         CheckDummyVideo
  2918         CheckDiskAudio
  2919         CheckDummyAudio
  2920         CheckDLOPEN
  2921         CheckCOCOA
  2922         CheckPTHREAD
  2923 
  2924 
  2925         # Set up files for the audio library
  2926         if test x$enable_audio = xyes; then
  2927             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.c"
  2928             have_audio=yes
  2929         fi
  2930         # Set up files for the joystick library
  2931         if test x$enable_joystick = xyes; then
  2932             SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
  2933             have_joystick=yes
  2934         fi
  2935         # Set up files for the haptic library
  2936         #if test x$enable_haptic = xyes; then
  2937         #    SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2938         #    have_haptic=yes
  2939         #    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2940         #fi
  2941         # Set up files for the power library
  2942         if test x$enable_power = xyes; then
  2943             SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
  2944             have_power=yes
  2945         fi
  2946         # Set up files for the filesystem library
  2947         if test x$enable_filesystem = xyes; then
  2948             SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
  2949             have_filesystem=yes
  2950         fi
  2951         # Set up files for the timer library
  2952         if test x$enable_timers = xyes; then
  2953             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2954             have_timers=yes
  2955         fi
  2956         # Set up additional files for the file library
  2957         if test x$enable_file = xyes; then
  2958             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  2959         fi
  2960         # The iOS platform requires special setup.
  2961         SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
  2962         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2963         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
  2964         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
  2965         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
  2966         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
  2967         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
  2968         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
  2969         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
  2970         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
  2971         ;;
  2972     *-*-darwin* )
  2973         # This could be either full "Mac OS X", or plain "Darwin" which is
  2974         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2975         # Next line is broken, and a few files below require Mac OS X (full)
  2976         ARCH=macosx
  2977 
  2978         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  2979         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  2980         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  2981 
  2982         CheckVisibilityHidden
  2983         CheckDummyVideo
  2984         CheckDiskAudio
  2985         CheckDummyAudio
  2986         CheckDLOPEN
  2987         CheckCOCOA
  2988         CheckX11
  2989         CheckMacGL
  2990         CheckOpenGLX11
  2991         CheckPTHREAD
  2992 
  2993         # Need this or things might misbuild on a G3.
  2994         EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
  2995 
  2996         # Set up files for the audio library
  2997         if test x$enable_audio = xyes; then
  2998             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
  2999             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.c"
  3000             have_audio=yes
  3001         fi
  3002         # Set up files for the joystick library
  3003         if test x$enable_joystick = xyes; then
  3004             AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
  3005             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  3006             have_joystick=yes
  3007         fi
  3008         # Set up files for the haptic library
  3009         if test x$enable_haptic = xyes; then
  3010             AC_DEFINE(SDL_HAPTIC_IOKIT, 1, [ ])
  3011             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  3012             have_haptic=yes
  3013             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  3014         fi
  3015         # Set up files for the power library
  3016         if test x$enable_power = xyes; then
  3017             AC_DEFINE(SDL_POWER_MACOSX, 1, [ ])
  3018             SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
  3019             have_power=yes
  3020         fi
  3021         # Set up files for the filesystem library
  3022         if test x$enable_filesystem = xyes; then
  3023             AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
  3024             SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
  3025             have_filesystem=yes
  3026         fi
  3027         # Set up files for the timer library
  3028         if test x$enable_timers = xyes; then
  3029             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  3030             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  3031             have_timers=yes
  3032         fi
  3033         # Set up additional files for the file library
  3034         if test x$enable_file = xyes; then
  3035             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  3036         fi
  3037         # The Mac OS X platform requires special setup.
  3038         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  3039         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
  3040         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  3041         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  3042         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  3043         # If audio is used, add the AudioUnit framework
  3044         if test x$enable_audio = xyes; then
  3045             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
  3046         fi
  3047         ;;
  3048     *)
  3049         AC_MSG_ERROR([
  3050 *** Unsupported host:  Please add to configure.in
  3051         ])
  3052         ;;
  3053 esac
  3054 
  3055 dnl Do this on all platforms, after everything else.
  3056 CheckWarnAll
  3057 
  3058 # Verify that we have all the platform specific files we need
  3059 
  3060 if test x$have_joystick != xyes; then
  3061     if test x$enable_joystick = xyes; then
  3062         AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
  3063     fi
  3064     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  3065 fi
  3066 if test x$have_haptic != xyes; then
  3067     if test x$enable_haptic = xyes; then
  3068         AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
  3069     fi
  3070     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  3071 fi
  3072 if test x$have_threads != xyes; then
  3073     if test x$enable_threads = xyes; then
  3074         AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
  3075     fi
  3076     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  3077 fi
  3078 if test x$have_timers != xyes; then
  3079     if test x$enable_timers = xyes; then
  3080         AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ])
  3081     fi
  3082     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  3083 fi
  3084 if test x$have_filesystem != xyes; then
  3085     if test x$enable_filesystem = xyes; then
  3086         AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
  3087     fi
  3088     SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c"
  3089 fi
  3090 if test x$have_loadso != xyes; then
  3091     if test x$enable_loadso = xyes; then
  3092         AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
  3093     fi
  3094     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  3095 fi
  3096 if test x$SDLMAIN_SOURCES = x; then
  3097     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  3098 fi
  3099 SDLTEST_SOURCES="$srcdir/src/test/*.c"
  3100 
  3101 OBJECTS=`echo $SOURCES`
  3102 DEPENDS=`echo $SOURCES | tr ' ' '\n'`
  3103 for EXT in asm cc m c S; do
  3104     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
  3105     DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
  3106 \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
  3107 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  3108 done
  3109 
  3110 VERSION_OBJECTS=`echo $VERSION_SOURCES`
  3111 VERSION_DEPENDS=`echo $VERSION_SOURCES`
  3112 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  3113 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
  3114 \\$(objects)/\\2.o: \\1/\\2.rc\\\\
  3115 	\\$(WINDRES) \\$< \\$@,g"`
  3116 
  3117 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
  3118 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
  3119 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  3120 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  3121 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  3122 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  3123 
  3124 SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
  3125 SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
  3126 SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  3127 SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  3128 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  3129 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  3130 
  3131 # Set runtime shared library paths as needed
  3132 
  3133 if test "x$enable_rpath" = "xyes"; then
  3134   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
  3135     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  3136   fi
  3137   if test $ARCH = solaris; then
  3138     SDL_RLD_FLAGS="-R\${libdir}"
  3139   fi
  3140 else
  3141   SDL_RLD_FLAGS=""
  3142 fi
  3143 
  3144 SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  3145 
  3146 dnl Expand the cflags and libraries needed by apps using SDL
  3147 AC_SUBST(SDL_CFLAGS)
  3148 AC_SUBST(SDL_LIBS)
  3149 AC_SUBST(SDL_STATIC_LIBS)
  3150 AC_SUBST(SDL_RLD_FLAGS)
  3151 if test x$enable_shared = xyes; then
  3152     ENABLE_SHARED_TRUE=
  3153     ENABLE_SHARED_FALSE="#"
  3154 else
  3155     ENABLE_SHARED_TRUE="#"
  3156     ENABLE_SHARED_FALSE=
  3157 fi
  3158 if test x$enable_static = xyes; then
  3159     ENABLE_STATIC_TRUE=
  3160     ENABLE_STATIC_FALSE="#"
  3161 else
  3162     ENABLE_STATIC_TRUE="#"
  3163     ENABLE_STATIC_FALSE=
  3164 fi
  3165 AC_SUBST(ENABLE_SHARED_TRUE)
  3166 AC_SUBST(ENABLE_SHARED_FALSE)
  3167 AC_SUBST(ENABLE_STATIC_TRUE)
  3168 AC_SUBST(ENABLE_STATIC_FALSE)
  3169 
  3170 dnl Expand the sources and objects needed to build the library
  3171 AC_SUBST(ac_aux_dir)
  3172 AC_SUBST(INCLUDE)
  3173 AC_SUBST(OBJECTS)
  3174 AC_SUBST(VERSION_OBJECTS)
  3175 AC_SUBST(SDLMAIN_OBJECTS)
  3176 AC_SUBST(SDLTEST_OBJECTS)
  3177 AC_SUBST(BUILD_CFLAGS)
  3178 AC_SUBST(EXTRA_CFLAGS)
  3179 AC_SUBST(BUILD_LDFLAGS)
  3180 AC_SUBST(EXTRA_LDFLAGS)
  3181 AC_SUBST(WINDRES)
  3182 
  3183 cat >Makefile.rules <<__EOF__
  3184 
  3185 # Build rules for objects
  3186 -include \$(OBJECTS:.lo=.d)
  3187 
  3188 # Special dependency for SDL.c, since it depends on SDL_revision.h
  3189 $srcdir/src/SDL.c: update-revision
  3190 $DEPENDS
  3191 $VERSION_DEPENDS
  3192 $SDLMAIN_DEPENDS
  3193 $SDLTEST_DEPENDS
  3194 __EOF__
  3195 
  3196 AC_CONFIG_FILES([
  3197     Makefile:Makefile.in:Makefile.rules sdl2-config SDL2.spec sdl2.pc
  3198 ])
  3199 AC_CONFIG_COMMANDS([sdl2_config],[chmod a+x sdl2-config])
  3200 
  3201 SUMMARY="SDL2 Configure Summary:\n"
  3202 if test x$enable_shared = xyes; then
  3203     SUMMARY="${SUMMARY}Building Shared Libraries\n"
  3204 fi
  3205 if test x$enable_static = xyes; then
  3206     SUMMARY="${SUMMARY}Building Static Libraries\n"
  3207 fi
  3208 SUMMARY="${SUMMARY}Enabled modules :${SUMMARY_modules}\n"
  3209 SUMMARY="${SUMMARY}Assembly Math   :${SUMMARY_math}\n" 
  3210 SUMMARY="${SUMMARY}Audio drivers   :${SUMMARY_audio}\n"
  3211 SUMMARY="${SUMMARY}Video drivers   :${SUMMARY_video}\n"
  3212 if test x$have_x = xyes; then
  3213     SUMMARY="${SUMMARY}X11 libraries   :${SUMMARY_video_x11}\n"
  3214 fi
  3215 SUMMARY="${SUMMARY}Input drivers   :${SUMMARY_input}\n"
  3216 if test x$enable_libudev = xyes; then
  3217     SUMMARY="${SUMMARY}Using libudev   : YES\n"
  3218 else
  3219     SUMMARY="${SUMMARY}Using libudev   : NO\n"
  3220 fi
  3221 if test x$have_dbus_dbus_h_hdr = xyes; then
  3222     SUMMARY="${SUMMARY}Using dbus      : YES\n"
  3223 else
  3224     SUMMARY="${SUMMARY}Using dbus      : NO\n"
  3225 fi
  3226 AC_CONFIG_COMMANDS([summary], [echo -en "$SUMMARY"], [SUMMARY="$SUMMARY"])
  3227 
  3228 AC_OUTPUT