cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

configure.in (129430B)


      1dnl Process this file with autoconf to produce a configure script.
      2AC_INIT(README.txt)
      3AC_CONFIG_HEADER(include/SDL_config.h)
      4AC_CONFIG_AUX_DIR(build-scripts)
      5AC_CONFIG_MACRO_DIR([acinclude])
      6
      7dnl Save the CFLAGS to see whether they were passed in or generated
      8orig_CFLAGS="$CFLAGS"
      9
     10dnl 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#
     21SDL_MAJOR_VERSION=2
     22SDL_MINOR_VERSION=0
     23SDL_MICRO_VERSION=4
     24SDL_INTERFACE_AGE=0
     25SDL_BINARY_AGE=4
     26SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
     27
     28AC_SUBST(SDL_MAJOR_VERSION)
     29AC_SUBST(SDL_MINOR_VERSION)
     30AC_SUBST(SDL_MICRO_VERSION)
     31AC_SUBST(SDL_INTERFACE_AGE)
     32AC_SUBST(SDL_BINARY_AGE)
     33AC_SUBST(SDL_VERSION)
     34
     35# libtool versioning
     36LT_INIT([win32-dll])
     37
     38LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
     39LT_CURRENT=`expr $SDL_MICRO_VERSION - $SDL_INTERFACE_AGE`
     40LT_REVISION=$SDL_INTERFACE_AGE
     41LT_AGE=`expr $SDL_BINARY_AGE - $SDL_INTERFACE_AGE`
     42m4_pattern_allow([^LT_])
     43
     44AC_SUBST(LT_RELEASE)
     45AC_SUBST(LT_CURRENT)
     46AC_SUBST(LT_REVISION)
     47AC_SUBST(LT_AGE)
     48
     49dnl Detect the canonical build and host environments
     50dnl AC_CANONICAL_HOST
     51
     52dnl Check for tools
     53AC_PROG_LIBTOOL
     54AC_PROG_CC
     55AC_PROG_CXX
     56AC_PROG_INSTALL
     57AC_PROG_MAKE_SET
     58AC_CHECK_TOOL(WINDRES, [windres], [:])
     59
     60dnl Make sure that srcdir is a full pathname
     61case "$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        ;;
     68esac
     69
     70dnl Set up the compiler and linker flags
     71INCLUDE="-I$srcdir/include"
     72if test x$srcdir != x.; then
     73    INCLUDE="-Iinclude $INCLUDE"
     74elif 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])
     79fi
     80BASE_CFLAGS=""
     81BASE_LDFLAGS=""
     82case "$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        ;;
    104esac
    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]")
    108BUILD_CFLAGS="$CFLAGS $CPPFLAGS -DUSING_GENERATED_CONFIG_H"
    109# The default optimization for SDL is -O3 (Bug #31)
    110if test "x$orig_CFLAGS" = x; then
    111    BUILD_CFLAGS=`echo $BUILD_CFLAGS | sed 's/-O2/-O3/'`
    112fi
    113EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
    114BUILD_LDFLAGS="$LDFLAGS"
    115EXTRA_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
    125SDL_CFLAGS="$BASE_CFLAGS"
    126SDL_LIBS="-lSDL2 $BASE_LDFLAGS"
    127CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
    128CFLAGS="$CFLAGS $EXTRA_CFLAGS"
    129LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
    130
    131dnl set this to use on systems that use lib64 instead of lib
    132base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
    133
    134dnl Function to find a library in the compiler search path
    135find_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
    154dnl Check for compiler characteristics
    155AC_C_CONST
    156AC_C_INLINE
    157AC_C_VOLATILE
    158
    159dnl See whether we want assertions for debugging/sanity checking SDL itself.
    160AC_ARG_ENABLE(assertions,
    161AC_HELP_STRING([--enable-assertions],
    162               [Enable internal sanity checks (auto/disabled/release/enabled/paranoid) [[default=auto]]]),
    163              , enable_assertions=auto)
    164case "$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        ;;
    182esac
    183
    184dnl See whether we can use gcc style dependency tracking
    185AC_ARG_ENABLE(dependency-tracking,
    186AC_HELP_STRING([--enable-dependency-tracking],
    187               [Use gcc -MMD -MT dependency tracking [[default=yes]]]),
    188              , enable_dependency_tracking=yes)
    189if 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
    205fi
    206
    207AC_MSG_CHECKING(for linker option --no-undefined)
    208have_no_undefined=no
    209case "$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        ;;
    225esac
    226AC_MSG_RESULT($have_no_undefined)
    227
    228dnl See whether we are allowed to use the system C library
    229AC_ARG_ENABLE(libc,
    230AC_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]),
    231              , enable_libc=yes)
    232if test x$enable_libc = xyes; then
    233    AC_DEFINE(HAVE_LIBC, 1, [ ])
    234
    235    dnl Check for C library headers
    236    AC_HEADER_STDC
    237    AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)
    238
    239    dnl Check for typedefs, structures, etc.
    240    AC_TYPE_SIZE_T
    241
    242    dnl Check for defines
    243    AC_CHECK_DEFINE(M_PI, math.h)
    244
    245    dnl Checks for library functions.
    246    case "$host" in
    247    *-*-cygwin* | *-*-mingw32*)
    248        ;;
    249    *)
    250        AC_FUNC_ALLOCA
    251        ;;
    252    esac
    253
    254    AC_FUNC_MEMCMP
    255    if test x$ac_cv_func_memcmp_working = xyes; then
    256        AC_DEFINE(HAVE_MEMCMP, 1, [ ])
    257    fi
    258    AC_FUNC_STRTOD
    259    if test x$ac_cv_func_strtod = xyes; then
    260        AC_DEFINE(HAVE_STRTOD, 1, [ ])
    261    fi
    262    AC_CHECK_FUNC(mprotect,
    263        AC_TRY_COMPILE([
    264          #include <sys/types.h>
    265          #include <sys/mman.h>
    266        ],[
    267        ],[
    268        AC_DEFINE(HAVE_MPROTECT, 1, [ ])
    269        ]),
    270    )
    271    AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname)
    272
    273    AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
    274    AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
    275
    276    AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
    277    AC_CHECK_FUNCS(iconv)
    278
    279    AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE(HAVE_SA_SIGACTION)], ,[#include <signal.h>])
    280fi
    281
    282dnl AC_CHECK_SIZEOF(void*)
    283
    284dnl See whether we can use gcc atomic operations on this architecture
    285AC_ARG_ENABLE(gcc-atomics,
    286AC_HELP_STRING([--enable-gcc-atomics],
    287               [Use gcc builtin atomics [[default=yes]]]),
    288              , enable_gcc_atomics=yes)
    289if 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
    322fi
    323
    324# Standard C sources
    325SOURCES="$SOURCES $srcdir/src/*.c"
    326SOURCES="$SOURCES $srcdir/src/atomic/*.c"
    327SOURCES="$SOURCES $srcdir/src/audio/*.c"
    328SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
    329SOURCES="$SOURCES $srcdir/src/dynapi/*.c"
    330SOURCES="$SOURCES $srcdir/src/events/*.c"
    331SOURCES="$SOURCES $srcdir/src/file/*.c"
    332SOURCES="$SOURCES $srcdir/src/haptic/*.c"
    333SOURCES="$SOURCES $srcdir/src/joystick/*.c"
    334SOURCES="$SOURCES $srcdir/src/libm/*.c"
    335SOURCES="$SOURCES $srcdir/src/power/*.c"
    336#SOURCES="$SOURCES $srcdir/src/filesystem/*.c"
    337SOURCES="$SOURCES $srcdir/src/render/*.c"
    338SOURCES="$SOURCES $srcdir/src/render/*/*.c"
    339SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
    340SOURCES="$SOURCES $srcdir/src/thread/*.c"
    341SOURCES="$SOURCES $srcdir/src/timer/*.c"
    342SOURCES="$SOURCES $srcdir/src/video/*.c"
    343
    344dnl Enable/disable various subsystems of the SDL library
    345
    346AC_ARG_ENABLE(atomic,
    347AC_HELP_STRING([--enable-atomic], [Enable the atomic operations subsystem [[default=yes]]]),
    348              , enable_atomic=yes)
    349if test x$enable_atomic != xyes; then
    350    AC_DEFINE(SDL_ATOMIC_DISABLED, 1, [ ])
    351else
    352    SUMMARY_modules="${SUMMARY_modules} atomic"
    353fi
    354AC_ARG_ENABLE(audio,
    355AC_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]),
    356              , enable_audio=yes)
    357if test x$enable_audio != xyes; then
    358    AC_DEFINE(SDL_AUDIO_DISABLED, 1, [ ])
    359else
    360    SUMMARY_modules="${SUMMARY_modules} audio"
    361fi
    362AC_ARG_ENABLE(video,
    363AC_HELP_STRING([--enable-video], [Enable the video subsystem [[default=yes]]]),
    364              , enable_video=yes)
    365if test x$enable_video != xyes; then
    366    AC_DEFINE(SDL_VIDEO_DISABLED, 1, [ ])
    367else
    368    SUMMARY_modules="${SUMMARY_modules} video"
    369fi
    370AC_ARG_ENABLE(render,
    371AC_HELP_STRING([--enable-render], [Enable the render subsystem [[default=yes]]]),
    372              , enable_render=yes)
    373if test x$enable_render != xyes; then
    374    AC_DEFINE(SDL_RENDER_DISABLED, 1, [ ])
    375else
    376    SUMMARY_modules="${SUMMARY_modules} render"
    377fi
    378AC_ARG_ENABLE(events,
    379AC_HELP_STRING([--enable-events], [Enable the events subsystem [[default=yes]]]),
    380              , enable_events=yes)
    381if test x$enable_events != xyes; then
    382    AC_DEFINE(SDL_EVENTS_DISABLED, 1, [ ])
    383else
    384    SUMMARY_modules="${SUMMARY_modules} events"
    385fi
    386AC_ARG_ENABLE(joystick,
    387AC_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes]]]),
    388              , enable_joystick=yes)
    389if test x$enable_joystick != xyes; then
    390    AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
    391else
    392    SUMMARY_modules="${SUMMARY_modules} joystick"
    393fi
    394AC_ARG_ENABLE(haptic,
    395AC_HELP_STRING([--enable-haptic], [Enable the haptic (force feedback) subsystem [[default=yes]]]),
    396              , enable_haptic=yes)
    397if test x$enable_haptic != xyes; then
    398    AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
    399else
    400    SUMMARY_modules="${SUMMARY_modules} haptic"
    401fi
    402AC_ARG_ENABLE(power,
    403AC_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]),
    404              , enable_power=yes)
    405if test x$enable_power != xyes; then
    406    AC_DEFINE(SDL_POWER_DISABLED, 1, [ ])
    407else
    408    SUMMARY_modules="${SUMMARY_modules} power"
    409fi
    410AC_ARG_ENABLE(filesystem,
    411AC_HELP_STRING([--enable-filesystem], [Enable the filesystem subsystem [[default=yes]]]),
    412              , enable_filesystem=yes)
    413if test x$enable_filesystem != xyes; then
    414    AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
    415else
    416    SUMMARY_modules="${SUMMARY_modules} filesystem"
    417fi
    418AC_ARG_ENABLE(threads,
    419AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]),
    420              , enable_threads=yes)
    421if test x$enable_threads != xyes; then
    422    AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
    423else
    424    SUMMARY_modules="${SUMMARY_modules} threads"
    425fi
    426AC_ARG_ENABLE(timers,
    427AC_HELP_STRING([--enable-timers], [Enable the timer subsystem [[default=yes]]]),
    428              , enable_timers=yes)
    429if test x$enable_timers != xyes; then
    430    AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ])
    431else
    432    SUMMARY_modules="${SUMMARY_modules} timers"
    433fi
    434AC_ARG_ENABLE(file,
    435AC_HELP_STRING([--enable-file], [Enable the file subsystem [[default=yes]]]),
    436              , enable_file=yes)
    437if test x$enable_file != xyes; then
    438    AC_DEFINE(SDL_FILE_DISABLED, 1, [ ])
    439else
    440    SUMMARY_modules="${SUMMARY_modules} file"
    441fi
    442AC_ARG_ENABLE(loadso,
    443AC_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [[default=yes]]]),
    444              , enable_loadso=yes)
    445if test x$enable_loadso != xyes; then
    446    AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
    447else
    448    SUMMARY_modules="${SUMMARY_modules} loadso"
    449fi
    450AC_ARG_ENABLE(cpuinfo,
    451AC_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [[default=yes]]]),
    452              , enable_cpuinfo=yes)
    453if test x$enable_cpuinfo != xyes; then
    454    AC_DEFINE(SDL_CPUINFO_DISABLED, 1, [ ])
    455else
    456    SUMMARY_modules="${SUMMARY_modules} cpuinfo"
    457fi
    458AC_ARG_ENABLE(assembly,
    459AC_HELP_STRING([--enable-assembly], [Enable assembly routines [[default=yes]]]),
    460              , enable_assembly=yes)
    461if 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,
    482AC_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,
    492AC_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,
    529AC_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,
    559AC_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,
    596AC_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,
    633AC_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
    708fi
    709
    710dnl See if the OSS audio interface is supported
    711CheckOSS()
    712{
    713    AC_ARG_ENABLE(oss,
    714AC_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
    766dnl See if the ALSA audio interface is supported
    767CheckALSA()
    768{
    769    AC_ARG_ENABLE(alsa,
    770AC_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,
    780AC_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
    805dnl Find the ESD includes and libraries
    806CheckESD()
    807{
    808    AC_ARG_ENABLE(esd,
    809AC_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,
    815AC_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
    840dnl Find PulseAudio
    841CheckPulseAudio()
    842{
    843    AC_ARG_ENABLE(pulseaudio,
    844AC_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,
    864AC_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
    897CheckARTSC()
    898{
    899    AC_ARG_ENABLE(arts,
    900AC_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,
    924AC_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
    950dnl See if the NAS audio interface is supported
    951CheckNAS()
    952{
    953    AC_ARG_ENABLE(nas,
    954AC_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,
    978AC_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
   1004dnl See if the sndio audio interface is supported
   1005CheckSNDIO()
   1006{
   1007    AC_ARG_ENABLE(sndio,
   1008AC_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,
   1026AC_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
   1052dnl rcg07142001 See if the user wants the disk writer audio driver...
   1053CheckDiskAudio()
   1054{
   1055    AC_ARG_ENABLE(diskaudio,
   1056AC_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
   1065dnl rcg03142006 See if the user wants the dummy audio driver...
   1066CheckDummyAudio()
   1067{
   1068    AC_ARG_ENABLE(dummyaudio,
   1069AC_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
   1078dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
   1079dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
   1080CheckVisibilityHidden()
   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
   1104dnl See if GCC's -mpreferred-stack-boundary is supported.
   1105dnl  Reference: http://bugzilla.libsdl.org/show_bug.cgi?id=1296
   1106CheckStackBoundary()
   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
   1127dnl See if GCC's -Wall is supported.
   1128CheckWarnAll()
   1129{
   1130    AC_MSG_CHECKING(for GCC -Wall option)
   1131    have_gcc_Wall=no
   1132
   1133    save_CFLAGS="$CFLAGS"
   1134    CFLAGS="$save_CFLAGS -Wall"
   1135    AC_TRY_COMPILE([
   1136    int x = 0;
   1137    ],[
   1138    ],[
   1139    have_gcc_Wall=yes
   1140    ])
   1141    AC_MSG_RESULT($have_gcc_Wall)
   1142    CFLAGS="$save_CFLAGS"
   1143
   1144    if test x$have_gcc_Wall = xyes; then
   1145        EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
   1146
   1147        dnl Haiku headers use multicharacter constants all over the place. Ignore these warnings when using -Wall.
   1148        AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
   1149        need_gcc_Wno_multichar=no
   1150        case "$host" in
   1151            *-*-haiku*)
   1152                need_gcc_Wno_multichar=yes
   1153                ;;
   1154        esac
   1155        AC_MSG_RESULT($need_gcc_Wno_multichar)
   1156        if test x$need_gcc_Wno_multichar = xyes; then
   1157            EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar"
   1158        fi
   1159    fi
   1160}
   1161
   1162dnl See if GCC's -Wshadow is supported.
   1163CheckWarnShadow()
   1164{
   1165    AC_MSG_CHECKING(for GCC -Wshadow option)
   1166    have_gcc_Wshadow=no
   1167
   1168    save_CFLAGS="$CFLAGS"
   1169    CFLAGS="$save_CFLAGS -Wshadow"
   1170    AC_TRY_COMPILE([
   1171    int x = 0;
   1172    ],[
   1173    ],[
   1174    have_gcc_Wshadow=yes
   1175    ])
   1176    AC_MSG_RESULT($have_gcc_Wshadow)
   1177    CFLAGS="$save_CFLAGS"
   1178
   1179    if test x$have_gcc_Wshadow = xyes; then
   1180        EXTRA_CFLAGS="$EXTRA_CFLAGS -Wshadow"
   1181    fi
   1182}
   1183
   1184dnl Check for Wayland
   1185CheckWayland()
   1186{
   1187    AC_ARG_ENABLE(video-wayland,
   1188AC_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]),
   1189                  ,enable_video_wayland=yes)
   1190
   1191    AC_ARG_ENABLE(video-wayland-qt-touch,
   1192AC_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for Wayland video driver [[default=yes]]]),
   1193                  ,enable_video_wayland_qt_touch=yes)
   1194
   1195    if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
   1196        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   1197        AC_MSG_CHECKING(for Wayland support)
   1198        video_wayland=no
   1199        if  test x$PKG_CONFIG != xno && \
   1200            test x$video_opengl_egl = xyes && \
   1201            test x$video_opengles_v2 = xyes; then
   1202            if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
   1203                WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
   1204                WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
   1205                video_wayland=yes
   1206            fi
   1207        fi
   1208        AC_MSG_RESULT($video_wayland)
   1209
   1210        if test x$video_wayland = xyes; then
   1211            AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND, 1, [ ])
   1212            if test x$enable_video_wayland_qt_touch = xyes; then
   1213                AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH, 1, [ ])
   1214            fi
   1215            SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
   1216            EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
   1217            AC_ARG_ENABLE(wayland-shared,
   1218AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[default=maybe]]]),
   1219                          , enable_wayland_shared=maybe)
   1220
   1221            dnl FIXME: Do BSD and OS X need special cases?
   1222            case "$host" in
   1223                *)
   1224                    wayland_client_lib=[`find_lib "libwayland-client.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   1225                    wayland_egl_lib=[`find_lib "libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   1226                    if test x$wayland_egl_lib = x; then
   1227                        dnl This works in Ubuntu 13.10, maybe others
   1228                        wayland_egl_lib=[`find_lib "mesa-egl/libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   1229                    fi
   1230                    wayland_cursor_lib=[`find_lib "libwayland-cursor.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   1231                    xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   1232                    ;;
   1233            esac
   1234
   1235            if test x$enable_wayland_shared = xmaybe; then
   1236                enable_wayland_shared=yes
   1237            fi
   1238            if test x$have_loadso != xyes && \
   1239               test x$enable_wayland_shared = xyes; then
   1240                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Wayland loading])
   1241                enable_wayland_shared=no
   1242            fi
   1243            if test x$have_loadso = xyes && \
   1244               test x$enable_wayland_shared = xyes && \
   1245               test x$wayland_client_lib != x && \
   1246               test x$wayland_egl_lib != x && \
   1247               test x$wayland_cursor_lib != x && \
   1248               test x$xkbcommon_lib != x; then
   1249                echo "-- dynamic libwayland-client -> $wayland_client_lib"
   1250                echo "-- dynamic libwayland-egl -> $wayland_egl_lib"
   1251                echo "-- dynamic libwayland-cursor -> $wayland_cursor_lib"
   1252                echo "-- dynamic libxkbcommon -> $xkbcommon_lib"
   1253                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC, "$wayland_client_lib", [ ])
   1254                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL, "$wayland_egl_lib", [ ])
   1255                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR, "$wayland_cursor_lib", [ ])
   1256                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ])
   1257                SUMMARY_video="${SUMMARY_video} wayland(dynamic)"
   1258            else
   1259                enable_wayland_shared=no
   1260                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
   1261                SUMMARY_video="${SUMMARY_video} wayland"
   1262            fi
   1263            have_video=yes
   1264        fi
   1265    fi
   1266}
   1267
   1268dnl Check for Mir
   1269CheckMir()
   1270{
   1271    AC_ARG_ENABLE(video-mir,
   1272AC_HELP_STRING([--enable-video-mir], [use Mir video driver [[default=yes]]]),
   1273                  ,enable_video_mir=yes)
   1274
   1275    if test x$enable_video = xyes -a x$enable_video_mir = xyes; then
   1276        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   1277        AC_MSG_CHECKING(for Mir support)
   1278        video_mir=no
   1279        if test x$PKG_CONFIG != xno; then
   1280            if $PKG_CONFIG --exists mirclient egl xkbcommon ; then
   1281                MIR_CFLAGS=`$PKG_CONFIG --cflags mirclient egl xkbcommon`
   1282                MIR_LIBS=`$PKG_CONFIG --libs mirclient egl xkbcommon`
   1283                save_CFLAGS="$CFLAGS"
   1284                CFLAGS="$save_CFLAGS $MIR_CFLAGS"
   1285                
   1286                dnl This will disable Mir on Ubuntu < 14.04
   1287                AC_TRY_COMPILE([
   1288                #include <mir_toolkit/mir_client_library.h>
   1289                ],[
   1290                    MirMotionToolType tool = mir_motion_tool_type_mouse;
   1291                ],[
   1292                video_mir=yes
   1293                ])
   1294                CFLAGS="$save_CFLAGS"
   1295            fi
   1296        fi
   1297        AC_MSG_RESULT($video_mir)
   1298
   1299        if test x$video_mir = xyes; then
   1300            AC_DEFINE(SDL_VIDEO_DRIVER_MIR, 1, [ ])
   1301            SOURCES="$SOURCES $srcdir/src/video/mir/*.c"
   1302            EXTRA_CFLAGS="$EXTRA_CFLAGS $MIR_CFLAGS"
   1303            AC_ARG_ENABLE(mir-shared,
   1304AC_HELP_STRING([--enable-mir-shared], [dynamically load Mir support [[default=maybe]]]),
   1305                          , enable_mir_shared=maybe)
   1306
   1307            dnl FIXME: Do BSD and OS X need special cases?
   1308            case "$host" in
   1309                *)
   1310                    mirclient_lib=[`find_lib "libmirclient.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   1311                    xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   1312                    ;;
   1313            esac
   1314
   1315            if test x$enable_mir_shared = xmaybe; then
   1316                enable_mir_shared=yes
   1317            fi
   1318            if test x$have_loadso != xyes && \
   1319               test x$enable_mir_shared = xyes; then
   1320                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Mir loading])
   1321                enable_mir_shared=no
   1322            fi
   1323            if test x$have_loadso = xyes && \
   1324               test x$enable_mir_shared = xyes && \
   1325               test x$mirclient_lib != x && \
   1326               test x$xkbcommon_lib != x; then
   1327                echo "-- dynamic libmirclient -> $mirclient_lib"
   1328                echo "-- dynamic libxkbcommon -> $xkbcommon_lib"
   1329                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_MIR_DYNAMIC, "$mirclient_lib", [ ])
   1330                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ])
   1331                SUMMARY_video="${SUMMARY_video} mir(dynamic)"
   1332            else
   1333                enable_mir_shared=no
   1334                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MIR_LIBS"
   1335                SUMMARY_video="${SUMMARY_video} mir"
   1336            fi
   1337            have_video=yes
   1338        fi
   1339    fi
   1340}
   1341
   1342dnl Check for Native Client stuff
   1343CheckNativeClient()
   1344{
   1345        AC_TRY_COMPILE([
   1346          #if !defined(__native_client__)
   1347          #error "NO NACL"
   1348          #endif
   1349        ],[
   1350        ],[
   1351        AC_DEFINE(SDL_VIDEO_DRIVER_NACL)
   1352        AC_DEFINE(SDL_AUDIO_DRIVER_NACL)
   1353        AC_DEFINE(HAVE_POW, 1, [ ])
   1354        AC_DEFINE(HAVE_OPENGLES2, 1, [ ])
   1355        AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
   1356        AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
   1357
   1358        SDL_LIBS="-lppapi_simple -lppapi_gles2 $SDL_LIBS"
   1359
   1360        SDLMAIN_SOURCES="$srcdir/src/main/nacl/*.c"
   1361        SOURCES="$SOURCES $srcdir/src/audio/nacl/*.c"
   1362        SUMMARY_audio="${SUMMARY_audio} nacl"
   1363        SOURCES="$SOURCES $srcdir/src/video/nacl/*.c"
   1364        SUMMARY_video="${SUMMARY_video} nacl opengles2"
   1365        ])
   1366}
   1367
   1368
   1369dnl Find the X11 include and library directories
   1370CheckX11()
   1371{
   1372
   1373
   1374    AC_ARG_ENABLE(video-x11,
   1375AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
   1376                  , enable_video_x11=yes)
   1377    if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
   1378        case "$host" in
   1379            *-*-darwin*)
   1380                # This isn't necessary for X11, but fixes GLX detection
   1381                if test "x$x_includes" = xNONE && \
   1382                   test "x$x_libraries" = xNONE && \
   1383                   test -d /usr/X11R6/include && \
   1384                   test -d /usr/X11R6/lib; then
   1385                    x_includes="/usr/X11R6/include"
   1386                    x_libraries="/usr/X11R6/lib"
   1387                fi
   1388                ;;
   1389        esac
   1390        AC_PATH_X
   1391        AC_PATH_XTRA
   1392        if test x$have_x = xyes; then
   1393            AC_ARG_ENABLE(x11-shared,
   1394AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
   1395                          , enable_x11_shared=maybe)
   1396
   1397            case "$host" in
   1398                *-*-darwin*)
   1399                    x11_lib='/usr/X11R6/lib/libX11.6.dylib'
   1400                    x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
   1401                    xcursor_lib='/usr/X11R6/lib/libXcursor.1.dylib'
   1402                    xinerama_lib='/usr/X11R6/lib/libXinerama.1.dylib'
   1403                    xinput_lib='/usr/X11R6/lib/libXi.6.dylib'
   1404                    xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
   1405                    xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
   1406                    xss_lib='/usr/X11R6/lib/libXss.1.dylib'
   1407                    xvidmode_lib='/usr/X11R6/lib/libXxf86vm.1.dylib'
   1408                    ;;
   1409                *-*-openbsd*)
   1410                    x11_lib='libX11.so'
   1411                    x11ext_lib='libXext.so'
   1412                    xcursor_lib='libXcursor.so'
   1413                    xinerama_lib='libXinerama.so'
   1414                    xinput_lib='libXi.so'
   1415                    xrandr_lib='libXrandr.so'
   1416                    xrender_lib='libXrender.so'
   1417                    xss_lib='libXss.so'
   1418                    xvidmode_lib='libXxf86vm.so'
   1419                    ;;
   1420                *)
   1421                    x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   1422                    x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   1423                    xcursor_lib=[`find_lib "libXcursor.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   1424                    xinerama_lib=[`find_lib "libXinerama.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   1425                    xinput_lib=[`find_lib "libXi.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   1426                    xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   1427                    xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   1428                    xss_lib=[`find_lib "libXss.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   1429                    xvidmode_lib=[`find_lib "libXxf86vm.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   1430                    ;;
   1431            esac
   1432
   1433            if test x$ac_cv_func_shmat != xyes; then
   1434                X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
   1435            fi
   1436            CFLAGS="$CFLAGS $X_CFLAGS"
   1437            LDFLAGS="$LDFLAGS $X_LIBS"
   1438
   1439            AC_CHECK_HEADER(X11/extensions/Xext.h,
   1440                            have_xext_h_hdr=yes,
   1441                            have_xext_h_hdr=no,
   1442                            [#include <X11/Xlib.h>
   1443                             #include <X11/Xproto.h>
   1444                            ])
   1445            if test x$have_xext_h_hdr != xyes; then
   1446               AC_MSG_ERROR([
   1447*** Missing Xext.h, maybe you need to install the libxext-dev package?
   1448               ])
   1449            fi
   1450
   1451            AC_DEFINE(SDL_VIDEO_DRIVER_X11, 1, [ ])
   1452            SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
   1453            EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
   1454
   1455            # Needed so SDL applications can include SDL_syswm.h
   1456            SDL_CFLAGS="$SDL_CFLAGS $X_CFLAGS"
   1457
   1458            if test x$enable_x11_shared = xmaybe; then
   1459                enable_x11_shared=yes
   1460            fi
   1461            if test x$have_loadso != xyes && \
   1462               test x$enable_x11_shared = xyes; then
   1463                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
   1464                enable_x11_shared=no
   1465            fi
   1466            if test x$have_loadso = xyes && \
   1467               test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
   1468                echo "-- dynamic libX11 -> $x11_lib"
   1469                echo "-- dynamic libX11ext -> $x11ext_lib"
   1470                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib", [ ])
   1471                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib", [ ])
   1472                SUMMARY_video="${SUMMARY_video} x11(dynamic)"
   1473            else
   1474                enable_x11_shared=no
   1475                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
   1476                SUMMARY_video="${SUMMARY_video} x11"
   1477            fi
   1478            have_video=yes
   1479
   1480            AC_MSG_CHECKING(for const parameter to XextAddDisplay)
   1481            have_const_param_XextAddDisplay=no
   1482            AC_TRY_COMPILE([
   1483              #include <X11/Xlib.h>
   1484              #include <X11/Xproto.h>
   1485              #include <X11/extensions/Xext.h>
   1486              #include <X11/extensions/extutil.h>
   1487              extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
   1488            ],[
   1489            ],[
   1490            have_const_param_XextAddDisplay=yes
   1491            AC_DEFINE(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY)
   1492            ])
   1493            AC_MSG_RESULT($have_const_param_XextAddDisplay)
   1494
   1495            AC_MSG_CHECKING(for const parameter to _XData32)
   1496	    have_const_param_xdata32=no
   1497	    AC_TRY_COMPILE([
   1498	      #include <X11/Xlibint.h>
   1499	      extern int _XData32(Display *dpy,register _Xconst long *data,unsigned len);
   1500	    ],[
   1501	    ],[
   1502	    have_const_param_xdata32=yes
   1503	    AC_DEFINE(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32)
   1504	    ])
   1505	    AC_MSG_RESULT($have_const_param_xdata32)
   1506
   1507            dnl AC_CHECK_LIB(X11, XGetEventData, AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS, 1, [Have XGenericEvent]))
   1508            AC_MSG_CHECKING([for XGenericEvent])
   1509            have_XGenericEvent=no
   1510            AC_TRY_COMPILE([
   1511              	#include <X11/Xlib.h>
   1512            ],[
   1513Display *display;
   1514XEvent event;
   1515XGenericEventCookie *cookie = &event.xcookie;
   1516XNextEvent(display, &event);
   1517XGetEventData(display, cookie);
   1518XFreeEventData(display, cookie);
   1519            ],[
   1520                have_XGenericEvent=yes
   1521                AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS)
   1522            ])
   1523            AC_MSG_RESULT($have_XGenericEvent)
   1524
   1525            AC_CHECK_LIB(X11, XkbKeycodeToKeysym, AC_DEFINE(SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM, 1, [Have XkbKeycodeToKeysym]))
   1526
   1527            AC_ARG_ENABLE(video-x11-xcursor,
   1528AC_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[default=yes]]]),
   1529                            , enable_video_x11_xcursor=yes)
   1530            if test x$enable_video_x11_xcursor = xyes; then
   1531                definitely_enable_video_x11_xcursor=no
   1532                AC_CHECK_HEADER(X11/Xcursor/Xcursor.h,
   1533                                have_xcursor_h_hdr=yes,
   1534                                have_xcursor_h_hdr=no,
   1535                                [#include <X11/Xlib.h>
   1536                                ])
   1537                if test x$have_xcursor_h_hdr = xyes; then
   1538                    if test x$enable_x11_shared = xyes && test x$xcursor_lib != x ; then
   1539                        echo "-- dynamic libXcursor -> $xcursor_lib"
   1540                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR, "$xcursor_lib", [ ])
   1541                        definitely_enable_video_x11_xcursor=yes
   1542                    else
   1543                        AC_CHECK_LIB(Xcursor, XcursorImageCreate, have_xcursor_lib=yes)
   1544                        if test x$have_xcursor_lib = xyes ; then
   1545                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXcursor"
   1546                            definitely_enable_video_x11_xcursor=yes
   1547                        fi
   1548                    fi
   1549                fi
   1550            fi
   1551            if test x$definitely_enable_video_x11_xcursor = xyes; then
   1552                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XCURSOR, 1, [ ])
   1553                SUMMARY_video_x11="${SUMMARY_video_x11} xcursor"
   1554            fi
   1555            AC_ARG_ENABLE(video-x11-xinerama,
   1556AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
   1557                            , enable_video_x11_xinerama=yes)
   1558            if test x$enable_video_x11_xinerama = xyes; then
   1559                definitely_enable_video_x11_xinerama=no
   1560                AC_CHECK_HEADER(X11/extensions/Xinerama.h,
   1561                                have_xinerama_h_hdr=yes,
   1562                                have_xinerama_h_hdr=no,
   1563                                [#include <X11/Xlib.h>
   1564                                ])
   1565                if test x$have_xinerama_h_hdr = xyes; then
   1566                    if test x$enable_x11_shared = xyes && test x$xinerama_lib != x ; then
   1567                        echo "-- dynamic libXinerama -> $xinerama_lib"
   1568                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA, "$xinerama_lib", [ ])
   1569                        definitely_enable_video_x11_xinerama=yes
   1570                    else
   1571                        AC_CHECK_LIB(Xinerama, XineramaQueryExtension, have_xinerama_lib=yes)
   1572                        if test x$have_xinerama_lib = xyes ; then
   1573                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXinerama"
   1574                            definitely_enable_video_x11_xinerama=yes
   1575                        fi
   1576                    fi
   1577                fi
   1578            fi
   1579            if test x$definitely_enable_video_x11_xinerama = xyes; then
   1580                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA, 1, [ ])
   1581                SUMMARY_video_x11="${SUMMARY_video_x11} xinerama"
   1582            fi
   1583            AC_ARG_ENABLE(video-x11-xinput,
   1584AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
   1585                            , enable_video_x11_xinput=yes)
   1586            if test x$enable_video_x11_xinput = xyes; then
   1587                definitely_enable_video_x11_xinput=no
   1588                AC_CHECK_HEADER(X11/extensions/XInput2.h,
   1589                                have_xinput_h_hdr=yes,
   1590                                have_xinput_h_hdr=no,
   1591                                [#include <X11/Xlib.h>
   1592                                ])
   1593                if test x$have_xinput_h_hdr = xyes; then
   1594                    if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
   1595                        echo "-- dynamic libXi -> $xinput_lib"
   1596                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2, "$xinput_lib", [ ])
   1597                        definitely_enable_video_x11_xinput=yes
   1598                    else
   1599                        AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
   1600                        if test x$have_xinput_lib = xyes ; then
   1601                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
   1602                            definitely_enable_video_x11_xinput=yes
   1603                        fi
   1604                    fi
   1605                fi
   1606            fi
   1607            if test x$definitely_enable_video_x11_xinput = xyes; then
   1608                SUMMARY_video_x11="${SUMMARY_video_x11} xinput2"
   1609                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ])
   1610                AC_MSG_CHECKING(for xinput2 multitouch)
   1611            	have_xinput2_multitouch=no
   1612            	AC_TRY_COMPILE([
   1613              		#include <X11/Xlib.h>
   1614             		#include <X11/Xproto.h>
   1615			#include <X11/extensions/XInput2.h>
   1616            	],[
   1617int event_type = XI_TouchBegin;
   1618XITouchClassInfo *t;
   1619            	],[
   1620            	have_xinput2_multitouch=yes
   1621            	AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH)
   1622                SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch"
   1623            	])
   1624            	AC_MSG_RESULT($have_xinput2_multitouch)
   1625            fi
   1626            AC_ARG_ENABLE(video-x11-xrandr,
   1627AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
   1628                            , enable_video_x11_xrandr=yes)
   1629            if test x$enable_video_x11_xrandr = xyes; then
   1630                dnl XRRScreenResources is only present in Xrandr >= 1.2, we use that as a test.
   1631                definitely_enable_video_x11_xrandr=no
   1632                have_xrandr_h_hdr=no
   1633                AC_TRY_COMPILE([
   1634                #include <X11/Xlib.h>
   1635                #include <X11/extensions/Xrandr.h>
   1636                ],[
   1637                XRRScreenResources *res = NULL;
   1638                ],[
   1639                have_xrandr_h_hdr=yes
   1640                ])
   1641                if test x$have_xrandr_h_hdr = xyes; then
   1642                    if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
   1643                        echo "-- dynamic libXrandr -> $xrandr_lib"
   1644                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib", [ ])
   1645                        definitely_enable_video_x11_xrandr=yes
   1646                    else
   1647                        AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
   1648                        if test x$have_xrandr_lib = xyes ; then
   1649                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr"
   1650                            definitely_enable_video_x11_xrandr=yes
   1651                        fi
   1652                    fi
   1653                fi
   1654            fi
   1655            if test x$definitely_enable_video_x11_xrandr = xyes; then
   1656                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR, 1, [ ])
   1657                SUMMARY_video_x11="${SUMMARY_video_x11} xrandr"
   1658            fi
   1659            AC_ARG_ENABLE(video-x11-scrnsaver,
   1660AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
   1661                            , enable_video_x11_scrnsaver=yes)
   1662            if test x$enable_video_x11_scrnsaver = xyes; then
   1663                AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
   1664                                have_scrnsaver_h_hdr=yes,
   1665                                have_scrnsaver_h_hdr=no,
   1666                                [#include <X11/Xlib.h>
   1667                                ])
   1668                if test x$have_scrnsaver_h_hdr = xyes; then
   1669                    if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
   1670                        echo "-- dynamic libXss -> $xss_lib"
   1671                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib", [ ])
   1672                        definitely_enable_video_x11_scrnsaver=yes
   1673                    else
   1674                        AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
   1675                        if test x$have_xss_lib = xyes ; then
   1676                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
   1677                            definitely_enable_video_x11_scrnsaver=yes
   1678                        fi
   1679                    fi
   1680                fi
   1681            fi
   1682            if test x$definitely_enable_video_x11_scrnsaver = xyes; then
   1683                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSCRNSAVER, 1, [ ])
   1684                SUMMARY_video_x11="${SUMMARY_video_x11} xscrnsaver"
   1685            fi
   1686            AC_ARG_ENABLE(video-x11-xshape,
   1687AC_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default=yes]]]),
   1688                            , enable_video_x11_xshape=yes)
   1689            if test x$enable_video_x11_xshape = xyes; then
   1690                AC_CHECK_HEADER(X11/extensions/shape.h,
   1691                                have_shape_h_hdr=yes,
   1692                                have_shape_h_hdr=no,
   1693                                [#include <X11/Xlib.h>
   1694                                ])
   1695                if test x$have_shape_h_hdr = xyes; then
   1696                    AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSHAPE, 1, [ ])
   1697                    SUMMARY_video_x11="${SUMMARY_video_x11} xshape"
   1698                fi
   1699            fi
   1700            AC_ARG_ENABLE(video-x11-vm,
   1701AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
   1702                            , enable_video_x11_vm=yes)
   1703            if test x$enable_video_x11_vm = xyes; then
   1704                definitely_enable_video_x11_vm=no
   1705                AC_CHECK_HEADER(X11/extensions/xf86vmode.h,
   1706                                have_vm_h_hdr=yes,
   1707                                have_vm_h_hdr=no,
   1708                                [#include <X11/Xlib.h>
   1709                                ])
   1710                if test x$have_vm_h_hdr = xyes; then
   1711                    if test x$enable_x11_shared = xyes && test x$xvidmode_lib != x ; then
   1712                        echo "-- dynamic libXxf86vm -> $xvidmode_lib"
   1713                        AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE, "$xvidmode_lib", [ ])
   1714                        definitely_enable_video_x11_vm=yes
   1715                    else
   1716                        AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion, have_vm_lib=yes)
   1717                        if test x$have_vm_lib = xyes ; then
   1718                            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXxf86vm"
   1719                            definitely_enable_video_x11_vm=yes
   1720                        fi
   1721                    fi
   1722                fi
   1723            fi
   1724            if test x$definitely_enable_video_x11_vm = xyes; then
   1725                AC_DEFINE(SDL_VIDEO_DRIVER_X11_XVIDMODE, 1, [ ])
   1726                SUMMARY_video_x11="${SUMMARY_video_x11} xvidmode"
   1727            fi
   1728        fi
   1729    fi
   1730}
   1731
   1732dnl Set up the Vivante video driver if enabled
   1733CheckVivanteVideo()
   1734{
   1735    AC_ARG_ENABLE(video-vivante,
   1736AC_HELP_STRING([--enable-video-vivante], [use Vivante EGL video driver [[default=yes]]]),
   1737                  , enable_video_vivante=yes)
   1738    if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then
   1739        AC_MSG_CHECKING(for Vivante VDK API)
   1740        have_vivante_vdk=no
   1741        AC_TRY_COMPILE([
   1742          #define LINUX
   1743          #define EGL_API_FB
   1744          #include <gc_vdk.h>
   1745        ],[
   1746        ],[
   1747        have_vivante_vdk=yes
   1748        ])
   1749        AC_MSG_RESULT($have_vivante_vdk)
   1750
   1751        AC_MSG_CHECKING(for Vivante FB API)
   1752        have_vivante_egl=no
   1753        AC_TRY_COMPILE([
   1754          #define LINUX
   1755          #define EGL_API_FB
   1756          #include <EGL/eglvivante.h>
   1757        ],[
   1758        ],[
   1759        have_vivante_egl=yes
   1760        ])
   1761        AC_MSG_RESULT($have_vivante_egl)
   1762
   1763        if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then
   1764            AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE, 1, [ ])
   1765            EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB"
   1766            if test x$have_vivante_vdk = xyes; then
   1767                AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE_VDK, 1, [ ])
   1768                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK"
   1769            fi
   1770            SOURCES="$SOURCES $srcdir/src/video/vivante/*.c"
   1771            SUMMARY_video="${SUMMARY_video} vivante"
   1772            have_video=yes
   1773        fi
   1774    fi
   1775}
   1776
   1777dnl Set up the Haiku video driver if enabled
   1778CheckHaikuVideo()
   1779{
   1780    if test x$enable_video = xyes; then
   1781        AC_DEFINE(SDL_VIDEO_DRIVER_HAIKU, 1, [ ])
   1782        SOURCES="$SOURCES $srcdir/src/video/haiku/*.cc"
   1783        have_video=yes
   1784        SUMMARY_video="${SUMMARY_video} haiku"
   1785    fi
   1786}
   1787
   1788dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
   1789CheckCOCOA()
   1790{
   1791    AC_ARG_ENABLE(video-cocoa,
   1792AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
   1793                  , enable_video_cocoa=yes)
   1794    if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
   1795        save_CFLAGS="$CFLAGS"
   1796        dnl work around that we don't have Objective-C support in autoconf
   1797        CFLAGS="$CFLAGS -x objective-c"
   1798        AC_MSG_CHECKING(for Cocoa framework)
   1799        have_cocoa=no
   1800        AC_TRY_COMPILE([
   1801          #import <Cocoa/Cocoa.h>
   1802        ],[
   1803        ],[
   1804        have_cocoa=yes
   1805        ])
   1806        AC_MSG_RESULT($have_cocoa)
   1807        CFLAGS="$save_CFLAGS"
   1808        if test x$have_cocoa = xyes; then
   1809            AC_DEFINE(SDL_VIDEO_DRIVER_COCOA, 1, [ ])
   1810            SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
   1811            SUMMARY_video="${SUMMARY_video} cocoa"
   1812            have_video=yes
   1813        fi
   1814    fi
   1815}
   1816
   1817dnl Find DirectFB
   1818CheckDirectFB()
   1819{
   1820    AC_ARG_ENABLE(video-directfb,
   1821AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
   1822                  , enable_video_directfb=no)
   1823    if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
   1824        video_directfb=no
   1825
   1826        DIRECTFB_REQUIRED_VERSION=1.0.0
   1827        AC_PATH_PROGS(DIRECTFBCONFIG, directfb-config, no, [$prefix/bin:$PATH])
   1828        if test x$DIRECTFBCONFIG = xno; then
   1829            AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   1830            if test x$PKG_CONFIG != xno; then
   1831                if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
   1832                    DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
   1833                    DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
   1834                    DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
   1835                    video_directfb=yes
   1836                fi
   1837            fi
   1838        else
   1839            set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
   1840            NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
   1841            set -- `$DIRECTFBCONFIG --version | sed 's/\./ /g'`
   1842            HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
   1843            if test $HAVE_VERSION -ge $NEED_VERSION; then
   1844                DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
   1845                DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
   1846                DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
   1847                video_directfb=yes
   1848            fi
   1849        fi
   1850        if test x$video_directfb = xyes; then
   1851            # SuSE 11.1 installs directfb-config without directfb-devel
   1852            save_CPPFLAGS="$CPPFLAGS"
   1853            CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
   1854            AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
   1855            CPPFLAGS="$save_CPPFLAGS"
   1856            video_directfb=$have_directfb_hdr
   1857        fi
   1858        AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
   1859        AC_MSG_RESULT($video_directfb)
   1860
   1861        if test x$video_directfb = xyes; then
   1862            AC_ARG_ENABLE(directfb-shared,
   1863AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
   1864                              , enable_directfb_shared=yes)
   1865
   1866            AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB, 1, [ ])
   1867            AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB, 1, [ ])
   1868            SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
   1869            EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
   1870
   1871            AC_MSG_CHECKING(for directfb dynamic loading support)
   1872            directfb_shared=no
   1873            directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS"`]
   1874            # | sed 's/.*\/\(.*\)/\1/; q'`]
   1875AC_MSG_WARN("directfb $directfb_lib")
   1876            if test x$have_loadso != xyes && \
   1877               test x$enable_directfb_shared = xyes; then
   1878                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
   1879            fi
   1880            if test x$have_loadso = xyes && \
   1881               test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
   1882                directfb_shared=yes
   1883                echo "-- $directfb_lib_spec -> $directfb_lib"
   1884                AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib", [ ])
   1885                SUMMARY_video="${SUMMARY_video} directfb(dynamic)"
   1886            else
   1887                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
   1888                SUMMARY_video="${SUMMARY_video} directfb"
   1889            fi
   1890            AC_MSG_RESULT($directfb_shared)
   1891            SDL_CFLAGS="$SDL_CFLAGS $DIRECTFB_CFLAGS"
   1892            have_video=yes
   1893        fi
   1894    fi
   1895}
   1896
   1897dnl Find FusionSound
   1898CheckFusionSound()
   1899{
   1900    AC_ARG_ENABLE(fusionsound,
   1901AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
   1902                  , enable_fusionsound=no)
   1903    if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
   1904        fusionsound=no
   1905
   1906        FUSIONSOUND_REQUIRED_VERSION=1.1.1
   1907
   1908        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   1909        AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
   1910        if test x$PKG_CONFIG != xno; then
   1911            if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
   1912                FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
   1913                FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
   1914                fusionsound=yes
   1915            fi
   1916        fi
   1917        AC_MSG_RESULT($fusionsound)
   1918
   1919        if test x$fusionsound = xyes; then
   1920            AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND, 1, [ ])
   1921            SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
   1922            EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
   1923            
   1924            AC_ARG_ENABLE(fusionsound-shared,
   1925AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
   1926                          , enable_fusionsound_shared=yes)
   1927            fusionsound_shared=no
   1928            AC_MSG_CHECKING(for FusionSound dynamic loading support)
   1929            if test x$have_loadso != xyes && \
   1930               test x$enable_fusionsound_shared = xyes; then
   1931                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
   1932            fi
   1933            if test x$have_loadso = xyes && \
   1934               test x$enable_fusionsound_shared = xyes; then
   1935                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so", [ ])
   1936                fusionsound_shared=yes
   1937                SUMMARY_audio="${SUMMARY_audio} fusionsound(dynamic)"
   1938            else
   1939                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
   1940                SUMMARY_audio="${SUMMARY_audio} fusionsound"
   1941            fi
   1942            AC_MSG_RESULT($fusionsound_shared)
   1943            
   1944            have_audio=yes
   1945        fi
   1946    fi
   1947}
   1948
   1949dnl rcg04172001 Set up the Null video driver.
   1950CheckDummyVideo()
   1951{
   1952    AC_ARG_ENABLE(video-dummy,
   1953AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
   1954                  , enable_video_dummy=yes)
   1955    if test x$enable_video_dummy = xyes; then
   1956        AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY, 1, [ ])
   1957        SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
   1958        have_video=yes
   1959        SUMMARY_video="${SUMMARY_video} dummy"
   1960    fi
   1961}
   1962
   1963dnl Check to see if OpenGL support is desired
   1964AC_ARG_ENABLE(video-opengl,
   1965AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
   1966              , enable_video_opengl=yes)
   1967
   1968dnl Find OpenGL
   1969CheckOpenGLX11()
   1970{
   1971    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
   1972        AC_MSG_CHECKING(for OpenGL (GLX) support)
   1973        video_opengl=no
   1974        AC_TRY_COMPILE([
   1975         #include <GL/gl.h>
   1976         #include <GL/glx.h>
   1977        ],[
   1978        ],[
   1979        video_opengl=yes
   1980        ])
   1981        AC_MSG_RESULT($video_opengl)
   1982        if test x$video_opengl = xyes; then
   1983            AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
   1984            AC_DEFINE(SDL_VIDEO_OPENGL_GLX, 1, [ ])
   1985            AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
   1986            SUMMARY_video="${SUMMARY_video} opengl"
   1987        fi
   1988    fi
   1989}
   1990
   1991dnl Check to see if OpenGL ES support is desired
   1992AC_ARG_ENABLE(video-opengles,
   1993AC_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]),
   1994              , enable_video_opengles=yes)
   1995AC_ARG_ENABLE(video-opengles1,
   1996AC_HELP_STRING([--enable-video-opengles1], [include OpenGL ES 1.1 support [[default=yes]]]),
   1997              , enable_video_opengles1=yes)
   1998AC_ARG_ENABLE(video-opengles2,
   1999AC_HELP_STRING([--enable-video-opengles2], [include OpenGL ES 2.0 support [[default=yes]]]),
   2000              , enable_video_opengles2=yes)
   2001
   2002dnl Find OpenGL ES
   2003CheckOpenGLESX11()
   2004{
   2005    if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
   2006        AC_MSG_CHECKING(for EGL support)
   2007        video_opengl_egl=no
   2008        AC_TRY_COMPILE([
   2009          #define LINUX
   2010          #define EGL_API_FB
   2011          #include <EGL/egl.h>
   2012          #include <EGL/eglext.h>
   2013        ],[
   2014        ],[
   2015        video_opengl_egl=yes
   2016        ])
   2017        AC_MSG_RESULT($video_opengl_egl)
   2018        if test x$video_opengl_egl = xyes; then
   2019            AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
   2020        fi
   2021            
   2022        if test x$enable_video_opengles1 = xyes; then
   2023            AC_MSG_CHECKING(for OpenGL ES v1 headers)
   2024            video_opengles_v1=no
   2025            AC_TRY_COMPILE([
   2026             #include <GLES/gl.h>
   2027             #include <GLES/glext.h>
   2028            ],[
   2029            ],[
   2030            video_opengles_v1=yes
   2031            ])
   2032            AC_MSG_RESULT($video_opengles_v1)
   2033            if test x$video_opengles_v1 = xyes; then
   2034                AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
   2035                AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
   2036                SUMMARY_video="${SUMMARY_video} opengl_es1"
   2037            fi
   2038        fi
   2039        
   2040        if test x$enable_video_opengles2 = xyes; then
   2041            AC_MSG_CHECKING(for OpenGL ES v2 headers)
   2042            video_opengles_v2=no
   2043            AC_TRY_COMPILE([
   2044             #include <GLES2/gl2.h>
   2045             #include <GLES2/gl2ext.h>
   2046            ],[
   2047            ],[
   2048            video_opengles_v2=yes
   2049            ])
   2050            AC_MSG_RESULT($video_opengles_v2)
   2051            if test x$video_opengles_v2 = xyes; then
   2052                AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
   2053                AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
   2054                SUMMARY_video="${SUMMARY_video} opengl_es2"
   2055            fi
   2056        fi
   2057    fi
   2058}
   2059
   2060dnl Check for Windows OpenGL
   2061CheckWINDOWSGL()
   2062{
   2063    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
   2064        AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
   2065        AC_DEFINE(SDL_VIDEO_OPENGL_WGL, 1, [ ])
   2066        AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
   2067        SUMMARY_video="${SUMMARY_video} opengl"
   2068    fi
   2069}
   2070
   2071dnl Check for Windows OpenGL
   2072CheckWINDOWSGLES()
   2073{
   2074    if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
   2075
   2076        AC_MSG_CHECKING(for EGL support)
   2077        video_opengl_egl=no
   2078        AC_TRY_COMPILE([
   2079         #include <EGL/egl.h>
   2080        ],[
   2081        ],[
   2082        video_opengl_egl=yes
   2083        ])
   2084        AC_MSG_RESULT($video_opengl_egl)
   2085        if test x$video_opengl_egl = xyes; then
   2086            AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
   2087            AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
   2088            SUMMARY_video="${SUMMARY_video} opengl_es1"
   2089        fi
   2090       
   2091        AC_MSG_CHECKING(for OpenGL ES v2 headers)
   2092        video_opengles_v2=no
   2093        AC_TRY_COMPILE([
   2094         #include <GLES2/gl2.h>
   2095         #include <GLES2/gl2ext.h>
   2096        ],[
   2097        ],[
   2098        video_opengles_v2=yes
   2099        ])
   2100        AC_MSG_RESULT($video_opengles_v2)
   2101        if test x$video_opengles_v2 = xyes; then
   2102            AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
   2103            AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
   2104            AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
   2105            SUMMARY_video="${SUMMARY_video} opengl_es2"
   2106        fi
   2107    fi
   2108}
   2109
   2110dnl Check for Haiku OpenGL
   2111CheckHaikuGL()
   2112{
   2113    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
   2114        AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
   2115        AC_DEFINE(SDL_VIDEO_OPENGL_HAIKU, 1, [ ])
   2116        AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
   2117        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
   2118        SUMMARY_video="${SUMMARY_video} opengl"
   2119    fi
   2120}
   2121
   2122dnl Check for MacOS OpenGL
   2123CheckMacGL()
   2124{
   2125    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
   2126        AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
   2127        AC_DEFINE(SDL_VIDEO_OPENGL_CGL, 1, [ ])
   2128        AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
   2129        SUMMARY_video="${SUMMARY_video} opengl"
   2130    fi
   2131}
   2132
   2133dnl See if we can use the new unified event interface in Linux 2.4
   2134CheckInputEvents()
   2135{
   2136    dnl Check for Linux 2.4 unified input event interface support
   2137        AC_MSG_CHECKING(for Linux 2.4 unified input interface)
   2138        use_input_events=no
   2139        AC_TRY_COMPILE([
   2140          #include <linux/input.h>
   2141        ],[
   2142          #ifndef EVIOCGNAME
   2143          #error EVIOCGNAME() ioctl not available
   2144          #endif
   2145        ],[
   2146        use_input_events=yes
   2147        ])
   2148        AC_MSG_RESULT($use_input_events)
   2149        if test x$use_input_events = xyes; then
   2150            AC_DEFINE(SDL_INPUT_LINUXEV, 1, [ ])
   2151            SUMMARY_input="${SUMMARY_input} linuxev"
   2152        fi
   2153}
   2154
   2155dnl See if we can use the kernel kd.h header
   2156CheckInputKD()
   2157{
   2158
   2159    AC_MSG_CHECKING(for Linux kd.h)
   2160    use_input_kd=no
   2161    AC_TRY_COMPILE([
   2162      #include <linux/kd.h>
   2163      #include <linux/keyboard.h>
   2164    ],[
   2165        struct kbentry kbe;
   2166        kbe.kb_table = KG_CTRL;
   2167        ioctl(0, KDGKBENT, &kbe);
   2168    ],[
   2169    use_input_kd=yes
   2170    ])
   2171    AC_MSG_RESULT($use_input_kd)
   2172    if test x$use_input_kd = xyes; then
   2173        AC_DEFINE(SDL_INPUT_LINUXKD, 1, [ ])
   2174        SUMMARY_input="${SUMMARY_input} linuxkd"
   2175    fi
   2176}
   2177
   2178dnl See if the platform offers libudev for device enumeration and hotplugging.
   2179CheckLibUDev()
   2180{
   2181    AC_ARG_ENABLE(libudev,
   2182AC_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
   2183                        , enable_libudev=yes)
   2184    if test x$enable_libudev = xyes; then
   2185        AC_CHECK_HEADER(libudev.h,
   2186                        have_libudev_h_hdr=yes,
   2187                        have_libudev_h_hdr=no)
   2188        if test x$have_libudev_h_hdr = xyes; then
   2189            AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])
   2190        fi
   2191    fi
   2192}
   2193
   2194dnl See if the platform offers libdbus for various IPC techniques.
   2195CheckDBus()
   2196{
   2197    AC_ARG_ENABLE(dbus,
   2198AC_HELP_STRING([--enable-dbus], [enable D-Bus support [[default=yes]]]),
   2199                        , enable_dbus=yes)
   2200    if test x$enable_dbus = xyes; then
   2201        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   2202        if test x$PKG_CONFIG != xno; then
   2203            DBUS_CFLAGS=`$PKG_CONFIG --cflags dbus-1`
   2204            save_CFLAGS="$CFLAGS"
   2205            CFLAGS="$save_CFLAGS $DBUS_CFLAGS"
   2206            AC_CHECK_HEADER(dbus/dbus.h,
   2207                            have_dbus_dbus_h_hdr=yes,
   2208                            have_dbus_dbus_h_hdr=no)
   2209            CFLAGS="$save_CFLAGS"
   2210            if test x$have_dbus_dbus_h_hdr = xyes; then
   2211                AC_DEFINE(HAVE_DBUS_DBUS_H, 1, [ ])
   2212                EXTRA_CFLAGS="$EXTRA_CFLAGS $DBUS_CFLAGS"
   2213                SOURCES="$SOURCES $srcdir/src/core/linux/SDL_dbus.c"
   2214            fi
   2215        fi
   2216    fi
   2217}
   2218
   2219dnl See if the platform has libibus IME support.
   2220CheckIBus()
   2221{
   2222    AC_ARG_ENABLE(ibus,
   2223AC_HELP_STRING([--enable-ibus], [enable IBus support [[default=yes]]]),
   2224                  , enable_ibus=yes)
   2225    if test x$enable_ibus = xyes; then
   2226        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   2227        if test x$PKG_CONFIG != xno; then
   2228            IBUS_CFLAGS=`$PKG_CONFIG --cflags ibus-1.0`
   2229            save_CFLAGS="$CFLAGS"
   2230            CFLAGS="$save_CFLAGS $IBUS_CFLAGS"
   2231            AC_CHECK_HEADER(ibus-1.0/ibus.h,
   2232                            have_ibus_ibus_h_hdr=yes,
   2233                            have_ibus_ibus_h_hdr=no)
   2234            AC_CHECK_HEADER(sys/inotify.h,
   2235                            have_inotify_inotify_h_hdr=yes,
   2236                            have_inotify_inotify_h_hdr=no)
   2237            CFLAGS="$save_CFLAGS"
   2238            if test x$have_ibus_ibus_h_hdr = xyes; then
   2239                if test x$enable_dbus != xyes; then
   2240                    AC_MSG_WARN([DBus support is required for IBus.])
   2241                    have_ibus_ibus_h_hdr=no
   2242                elif test x$have_inotify_inotify_h_hdr != xyes; then
   2243                    AC_MSG_WARN([INotify support is required for IBus.])
   2244                    have_ibus_ibus_h_hdr=no
   2245                else
   2246                    AC_DEFINE(HAVE_IBUS_IBUS_H, 1, [ ])
   2247                    EXTRA_CFLAGS="$EXTRA_CFLAGS $IBUS_CFLAGS"
   2248                    SOURCES="$SOURCES $srcdir/src/core/linux/SDL_ibus.c"
   2249               fi
   2250            fi
   2251        fi
   2252    fi
   2253}
   2254
   2255dnl See if we can use the Touchscreen input library
   2256CheckTslib()
   2257{
   2258    AC_ARG_ENABLE(input-tslib,
   2259AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
   2260                  , enable_input_tslib=yes)
   2261    if test x$enable_input_tslib = xyes; then
   2262        AC_MSG_CHECKING(for Touchscreen library support)
   2263        enable_input_tslib=no
   2264        AC_TRY_COMPILE([
   2265          #include "tslib.h"
   2266        ],[
   2267        ],[
   2268        enable_input_tslib=yes
   2269        ])
   2270        AC_MSG_RESULT($enable_input_tslib)
   2271        if test x$enable_input_tslib = xyes; then
   2272            AC_DEFINE(SDL_INPUT_TSLIB, 1, [ ])
   2273            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
   2274            SUMMARY_input="${SUMMARY_input} ts"
   2275        fi
   2276    fi
   2277}
   2278
   2279dnl See what type of thread model to use on Linux and Solaris
   2280CheckPTHREAD()
   2281{
   2282    dnl Check for pthread support
   2283    AC_ARG_ENABLE(pthreads,
   2284AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
   2285                  , enable_pthreads=yes)
   2286    dnl This is used on Linux for glibc binary compatibility (Doh!)
   2287    AC_ARG_ENABLE(pthread-sem,
   2288AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
   2289                  , enable_pthread_sem=yes)
   2290    case "$host" in
   2291         *-*-androideabi*)
   2292            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
   2293            pthread_lib=""
   2294            ;;
   2295        *-*-linux*|*-*-uclinux*)
   2296            pthread_cflags="-D_REENTRANT"
   2297            pthread_lib="-lpthread"
   2298            ;;
   2299        *-*-bsdi*)
   2300            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
   2301            pthread_lib=""
   2302            ;;
   2303        *-*-darwin*)
   2304            pthread_cflags="-D_THREAD_SAFE"
   2305# causes Carbon.p complaints?
   2306#            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
   2307            ;;
   2308        *-*-freebsd*|*-*-dragonfly*)
   2309            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
   2310            pthread_lib="-pthread"
   2311            ;;
   2312        *-*-netbsd*)
   2313            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
   2314            pthread_lib="-lpthread"
   2315            ;;
   2316        *-*-openbsd*)
   2317            pthread_cflags="-D_REENTRANT"
   2318            pthread_lib="-pthread"
   2319            ;;
   2320        *-*-solaris2.9)
   2321            # From Solaris 9+, posix4's preferred name is rt.
   2322            pthread_cflags="-D_REENTRANT"
   2323            pthread_lib="-lpthread -lrt"
   2324            ;;
   2325        *-*-solaris2.10)
   2326            # Solaris 10+ merged pthread into libc.
   2327            pthread_cflags="-D_REENTRANT"
   2328            pthread_lib="-lrt"
   2329            ;;
   2330        *-*-solaris*)
   2331            # Solaris 11+ merged rt into libc.
   2332            pthread_cflags="-D_REENTRANT"
   2333            pthread_lib=""
   2334            ;;
   2335        *-*-sysv5*)
   2336            pthread_cflags="-D_REENTRANT -Kthread"
   2337            pthread_lib=""
   2338            ;;
   2339        *-*-aix*)
   2340            pthread_cflags="-D_REENTRANT -mthreads"
   2341            pthread_lib="-lpthread"
   2342            ;;
   2343        *-*-hpux11*)
   2344            pthread_cflags="-D_REENTRANT"
   2345            pthread_lib="-L/usr/lib -lpthread"
   2346            ;;
   2347        *-*-haiku*)
   2348            pthread_cflags="-D_REENTRANT"
   2349            pthread_lib=""
   2350            ;;
   2351        *)
   2352            pthread_cflags="-D_REENTRANT"
   2353            pthread_lib="-lpthread"
   2354            ;;
   2355    esac
   2356    if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
   2357        # Save the original compiler flags and libraries
   2358        ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
   2359        # Add the pthread compiler flags and libraries
   2360        CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
   2361        # Check to see if we have pthread support on this system
   2362        AC_MSG_CHECKING(for pthreads)
   2363        use_pthreads=no
   2364        AC_TRY_LINK([
   2365         #include <pthread.h>
   2366        ],[
   2367         pthread_attr_t type;
   2368         pthread_attr_init(&type);
   2369        ],[
   2370        use_pthreads=yes
   2371        ])
   2372        AC_MSG_RESULT($use_pthreads)
   2373        # Restore the compiler flags and libraries
   2374        CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
   2375
   2376        # Do futher testing if we have pthread support...
   2377        if test x$use_pthreads = xyes; then
   2378            AC_DEFINE(SDL_THREAD_PTHREAD, 1, [ ])
   2379            EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
   2380            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
   2381            SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
   2382            SDL_LIBS="$SDL_LIBS $pthread_lib"
   2383
   2384            # Save the original compiler flags and libraries
   2385            ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
   2386            # Add the pthread compiler flags and libraries
   2387            CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
   2388
   2389            # Check to see if recursive mutexes are available
   2390            AC_MSG_CHECKING(for recursive mutexes)
   2391            has_recursive_mutexes=no
   2392            if test x$has_recursive_mutexes = xno; then
   2393                AC_TRY_COMPILE([
   2394                  #include <pthread.h>
   2395                ],[
   2396                  pthread_mutexattr_t attr;
   2397                  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
   2398                ],[
   2399                has_recursive_mutexes=yes
   2400                AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX, 1, [ ])
   2401                ])
   2402            fi
   2403            if test x$has_recursive_mutexes = xno; then
   2404                AC_TRY_COMPILE([
   2405                  #include <pthread.h>
   2406                ],[
   2407                  pthread_mutexattr_t attr;
   2408                  pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
   2409                ],[
   2410                has_recursive_mutexes=yes
   2411                AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP, 1, [ ])
   2412                ])
   2413            fi
   2414            AC_MSG_RESULT($has_recursive_mutexes)
   2415
   2416            # Check to see if pthread semaphore support is missing
   2417            if test x$enable_pthread_sem = xyes; then
   2418                AC_MSG_CHECKING(for pthread semaphores)
   2419                have_pthread_sem=no
   2420                AC_TRY_COMPILE([
   2421                  #include <pthread.h>
   2422                  #include <semaphore.h>
   2423                ],[
   2424                ],[
   2425                have_pthread_sem=yes
   2426                ])
   2427                AC_MSG_RESULT($have_pthread_sem)
   2428            fi
   2429            if test x$have_pthread_sem = xyes; then
   2430                AC_MSG_CHECKING(for sem_timedwait)
   2431                have_sem_timedwait=no
   2432                AC_TRY_LINK([
   2433                  #include <pthread.h>
   2434                  #include <semaphore.h>
   2435                ],[
   2436                  sem_timedwait(NULL, NULL);
   2437                ],[
   2438                have_sem_timedwait=yes
   2439                AC_DEFINE(HAVE_SEM_TIMEDWAIT)
   2440                ])
   2441                AC_MSG_RESULT($have_sem_timedwait)
   2442            fi
   2443
   2444            AC_CHECK_HEADER(pthread_np.h, have_pthread_np_h=yes, have_pthread_np_h=no, [ #include <pthread.h> ])
   2445            if test x$have_pthread_np_h = xyes; then
   2446                AC_DEFINE(HAVE_PTHREAD_NP_H, 1, [ ])
   2447            fi
   2448
   2449            # Check to see if pthread naming is available
   2450            AC_MSG_CHECKING(for pthread_setname_np)
   2451            AC_TRY_LINK_FUNC(pthread_setname_np, [
   2452              has_pthread_setname_np=yes
   2453              AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [ ])
   2454            ],[
   2455              has_pthread_setname_np=no
   2456            ])
   2457            AC_MSG_RESULT($has_pthread_setname_np)
   2458
   2459            AC_MSG_CHECKING(for pthread_set_name_np)
   2460            AC_TRY_LINK_FUNC(pthread_set_name_np, [
   2461              has_pthread_set_name_np=yes
   2462              AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [ ])
   2463            ],[
   2464              has_pthread_set_name_np=no
   2465            ])
   2466            AC_MSG_RESULT($has_pthread_set_name_np)
   2467
   2468            # Restore the compiler flags and libraries
   2469            CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
   2470
   2471            # Basic thread creation functions
   2472            SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
   2473
   2474            # Semaphores
   2475            # We can fake these with mutexes and condition variables if necessary
   2476            if test x$have_pthread_sem = xyes; then
   2477                SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
   2478            else
   2479                SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
   2480            fi
   2481
   2482            # Mutexes
   2483            # We can fake these with semaphores if necessary
   2484            SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
   2485
   2486            # Condition variables
   2487            # We can fake these with semaphores and mutexes if necessary
   2488            SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
   2489
   2490            # Thread local storage
   2491            SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systls.c"
   2492
   2493            have_threads=yes
   2494        fi
   2495    fi
   2496}
   2497
   2498dnl Determine whether the compiler can produce Windows executables
   2499CheckWINDOWS()
   2500{
   2501    AC_MSG_CHECKING(Windows compiler)
   2502    have_win32_gcc=no
   2503    AC_TRY_COMPILE([
   2504     #include <windows.h>
   2505    ],[
   2506    ],[
   2507    have_win32_gcc=yes
   2508    ])
   2509    AC_MSG_RESULT($have_win32_gcc)
   2510    if test x$have_win32_gcc != xyes; then
   2511       AC_MSG_ERROR([
   2512*** Your compiler ($CC) does not produce Windows executables!
   2513       ])
   2514    fi
   2515
   2516    AC_MSG_CHECKING(Windows CE)
   2517    have_wince=no
   2518    AC_TRY_COMPILE([
   2519#if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
   2520#error This is not Windows CE
   2521#endif
   2522    ],[
   2523    ],[
   2524    have_wince=yes
   2525       AC_MSG_ERROR([
   2526*** Sorry, Windows CE is no longer supported.
   2527       ])
   2528    ])
   2529    AC_MSG_RESULT($have_wince)
   2530
   2531    # This fixes Windows stack alignment with newer GCC
   2532    CheckStackBoundary
   2533}
   2534
   2535dnl Find the DirectX includes and libraries
   2536CheckDIRECTX()
   2537{
   2538    AC_ARG_ENABLE(directx,
   2539AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
   2540                  , enable_directx=yes)
   2541    if test x$enable_directx = xyes; then
   2542        AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
   2543        AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes)
   2544        AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
   2545        AC_CHECK_HEADER(dsound.h, have_dsound=yes)
   2546        AC_CHECK_HEADER(dinput.h, have_dinput=yes)
   2547        AC_CHECK_HEADER(dxgi.h, have_dxgi=yes)
   2548        AC_CHECK_HEADER(xaudio2.h, have_xaudio2=yes)
   2549        AC_CHECK_HEADER(xinput.h, have_xinput=yes)
   2550
   2551        if test x$have_ddraw = xyes; then
   2552            AC_DEFINE(HAVE_DDRAW_H, 1, [ ])
   2553        fi
   2554        if test x$have_dinput = xyes; then
   2555            AC_DEFINE(HAVE_DINPUT_H, 1, [ ])
   2556        fi
   2557        if test x$have_dsound = xyes; then
   2558            AC_DEFINE(HAVE_DSOUND_H, 1, [ ])
   2559        fi
   2560        if test x$have_dxgi = xyes; then
   2561            AC_DEFINE(HAVE_DXGI_H, 1, [ ])
   2562        fi
   2563        if test x$have_xinput = xyes; then
   2564            AC_DEFINE(HAVE_XINPUT_H, 1, [ ])
   2565        fi
   2566
   2567        SUMMARY_video="${SUMMARY_video} directx"
   2568        SUMMARY_audio="${SUMMARY_audio} directx"
   2569
   2570        # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
   2571        # FIXME:  ...so force it off for now.
   2572        case "$host" in
   2573            *-*-cygwin*)
   2574            have_dinput=false
   2575            ;;
   2576        esac
   2577    fi
   2578}
   2579
   2580dnl Check for the dlfcn.h interface for dynamically loading objects
   2581CheckDLOPEN()
   2582{
   2583    AC_ARG_ENABLE(sdl-dlopen,
   2584AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
   2585                  , enable_sdl_dlopen=yes)
   2586    if test x$enable_sdl_dlopen = xyes; then
   2587        AC_MSG_CHECKING(for dlopen)
   2588        have_dlopen=no
   2589        AC_TRY_COMPILE([
   2590         #include <dlfcn.h>
   2591        ],[
   2592         void *handle = dlopen("", RTLD_NOW);
   2593         const char *loaderror = (char *) dlerror();
   2594        ],[
   2595        have_dlopen=yes
   2596        ])
   2597        AC_MSG_RESULT($have_dlopen)
   2598
   2599        if test x$have_dlopen = xyes; then
   2600            AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
   2601               AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
   2602                  AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
   2603            AC_DEFINE(SDL_LOADSO_DLOPEN, 1, [ ])
   2604            SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
   2605            have_loadso=yes
   2606        fi
   2607    fi
   2608}
   2609
   2610dnl Check for the usbhid(3) library on *BSD
   2611CheckUSBHID()
   2612{
   2613    case "$host" in
   2614        *-*-*bsd*)
   2615            if test x$enable_joystick = xyes; then
   2616                AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
   2617                if test x$have_libusbhid = xyes; then
   2618                    AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
   2619                    AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
   2620                    USB_LIBS="$USB_LIBS -lusbhid"
   2621                else
   2622                    AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
   2623                    AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
   2624                    AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
   2625                fi
   2626                    
   2627                save_CFLAGS="$CFLAGS"
   2628                CFLAGS="$CFLAGS $USB_CFLAGS"
   2629
   2630                AC_MSG_CHECKING(for usbhid)
   2631                have_usbhid=no
   2632                AC_TRY_COMPILE([
   2633                  #include <sys/types.h>
   2634                  #if defined(HAVE_USB_H)
   2635                  #include <usb.h>
   2636                  #endif
   2637                  #ifdef __DragonFly__
   2638                  # include <bus/usb/usb.h>
   2639                  # include <bus/usb/usbhid.h>
   2640                  #else
   2641                  # include <dev/usb/usb.h>
   2642                  # include <dev/usb/usbhid.h>
   2643                  #endif
   2644                  #if defined(HAVE_USBHID_H)
   2645                  #include <usbhid.h>
   2646                  #elif defined(HAVE_LIBUSB_H)
   2647                  #include <libusb.h>
   2648                  #elif defined(HAVE_LIBUSBHID_H)
   2649                  #include <libusbhid.h>
   2650                  #endif
   2651                ],[
   2652                  struct report_desc *repdesc;
   2653                  struct usb_ctl_report *repbuf;
   2654                  hid_kind_t hidkind;
   2655                ],[
   2656                have_usbhid=yes
   2657                ])
   2658                AC_MSG_RESULT($have_usbhid)
   2659
   2660                if test x$have_usbhid = xyes; then
   2661                    AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
   2662                    have_usbhid_ucr_data=no
   2663                    AC_TRY_COMPILE([
   2664                      #include <sys/types.h>
   2665                      #if defined(HAVE_USB_H)
   2666                      #include <usb.h>
   2667                      #endif
   2668                      #ifdef __DragonFly__
   2669                      # include <bus/usb/usb.h>
   2670                      # include <bus/usb/usbhid.h>
   2671                      #else
   2672                      # include <dev/usb/usb.h>
   2673                      # include <dev/usb/usbhid.h>
   2674                      #endif
   2675                      #if defined(HAVE_USBHID_H)
   2676                      #include <usbhid.h>
   2677                      #elif defined(HAVE_LIBUSB_H)
   2678                      #include <libusb.h>
   2679                      #elif defined(HAVE_LIBUSBHID_H)
   2680                      #include <libusbhid.h>
   2681                      #endif
   2682                    ],[
   2683                      struct usb_ctl_report buf;
   2684                      if (buf.ucr_data) { }
   2685                    ],[
   2686                    have_usbhid_ucr_data=yes
   2687                    ])
   2688                    if test x$have_usbhid_ucr_data = xyes; then
   2689                        USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
   2690                    fi
   2691                    AC_MSG_RESULT($have_usbhid_ucr_data)
   2692                    
   2693                    AC_MSG_CHECKING(for new usbhid API)
   2694                    have_usbhid_new=no
   2695                    AC_TRY_COMPILE([
   2696                      #include <sys/types.h>
   2697                      #if defined(HAVE_USB_H)
   2698                      #include <usb.h>
   2699                      #endif
   2700                      #ifdef __DragonFly__
   2701                      #include <bus/usb/usb.h>
   2702                      #include <bus/usb/usbhid.h>
   2703                      #else
   2704                      #include <dev/usb/usb.h>
   2705                      #include <dev/usb/usbhid.h>
   2706                      #endif
   2707                      #if defined(HAVE_USBHID_H)
   2708                      #include <usbhid.h>
   2709                      #elif defined(HAVE_LIBUSB_H)
   2710                      #include <libusb.h>
   2711                      #elif defined(HAVE_LIBUSBHID_H)
   2712                      #include <libusbhid.h>
   2713                      #endif
   2714                    ],[
   2715                      report_desc_t d;
   2716                      hid_start_parse(d, 1, 1);
   2717                    ],[
   2718                    have_usbhid_new=yes
   2719                    ])
   2720                    if test x$have_usbhid_new = xyes; then
   2721                        USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
   2722                    fi
   2723                    AC_MSG_RESULT($have_usbhid_new)
   2724
   2725                    AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
   2726                    have_machine_joystick=no
   2727                    AC_TRY_COMPILE([
   2728                      #include <machine/joystick.h>
   2729                    ],[
   2730                      struct joystick t;
   2731                    ],[
   2732                    have_machine_joystick=yes
   2733                    ])
   2734                    if test x$have_machine_joystick = xyes; then
   2735                        AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
   2736                    fi
   2737                    AC_MSG_RESULT($have_machine_joystick)
   2738
   2739                    AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
   2740                    SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
   2741                    EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
   2742                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
   2743                    have_joystick=yes
   2744                fi
   2745                CFLAGS="$save_CFLAGS"
   2746            fi
   2747        ;;
   2748    esac
   2749}
   2750
   2751dnl Check for clock_gettime()
   2752CheckClockGettime()
   2753{
   2754    AC_ARG_ENABLE(clock_gettime,
   2755AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=yes]]]),
   2756                  , enable_clock_gettime=yes)
   2757    if test x$enable_clock_gettime = xyes; then
   2758        AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
   2759        if test x$have_clock_gettime = xyes; then
   2760            AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
   2761            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
   2762        else
   2763            AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
   2764            if test x$have_clock_gettime = xyes; then
   2765               AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
   2766               EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
   2767            fi
   2768        fi
   2769    fi
   2770}
   2771
   2772dnl Check for a valid linux/version.h
   2773CheckLinuxVersion()
   2774{
   2775    AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
   2776    if test x$have_linux_version_h = xyes; then
   2777        EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
   2778    fi
   2779}
   2780
   2781dnl Check if we want to use RPATH
   2782CheckRPATH()
   2783{
   2784    AC_ARG_ENABLE(rpath,
   2785AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
   2786                  , enable_rpath=yes)
   2787}
   2788
   2789dnl Set up the configuration based on the host platform!
   2790case "$host" in
   2791    *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*)
   2792        case "$host" in
   2793            *-raspberry-linux*)
   2794                # Raspberry Pi
   2795                ARCH=linux
   2796                RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
   2797                CFLAGS="$CFLAGS $RPI_CFLAGS"
   2798                SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
   2799                EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
   2800                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L/opt/vc/lib -lbcm_host -ldl"
   2801
   2802                if test x$enable_video = xyes; then
   2803                    SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
   2804                    $as_echo "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
   2805                fi
   2806                ;;
   2807            *-*-androideabi*)
   2808                # Android
   2809                ARCH=android
   2810                ANDROID_CFLAGS="-DGL_GLEXT_PROTOTYPES"
   2811                CFLAGS="$CFLAGS $ANDROID_CFLAGS"
   2812                SDL_CFLAGS="$SDL_CFLAGS $ANDROID_CFLAGS"
   2813                EXTRA_CFLAGS="$EXTRA_CFLAGS $ANDROID_CFLAGS"
   2814                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl -lGLESv1_CM -lGLESv2 -llog -landroid"
   2815
   2816                if test x$enable_video = xyes; then
   2817                    SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c"
   2818                    $as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
   2819                    SUMMARY_video="${SUMMARY_video} android"
   2820                fi
   2821                ;;
   2822            *-*-linux*)         ARCH=linux ;;
   2823            *-*-uclinux*)       ARCH=linux ;;
   2824            *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
   2825            *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
   2826            *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
   2827            *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
   2828            *-*-bsdi*)          ARCH=bsdi ;;
   2829            *-*-freebsd*)       ARCH=freebsd ;;
   2830            *-*-dragonfly*)     ARCH=freebsd ;;
   2831            *-*-netbsd*)        ARCH=netbsd ;;
   2832            *-*-openbsd*)       ARCH=openbsd ;;
   2833            *-*-sysv5*)         ARCH=sysv5 ;;
   2834            *-*-solaris*)       ARCH=solaris ;;
   2835            *-*-hpux*)          ARCH=hpux ;;
   2836            *-*-aix*)           ARCH=aix ;;
   2837            *-*-minix*)         ARCH=minix ;;
   2838        esac
   2839        CheckVisibilityHidden
   2840        CheckDummyVideo
   2841        CheckDiskAudio
   2842        CheckDummyAudio
   2843        CheckDLOPEN
   2844        CheckOSS
   2845        CheckALSA
   2846        CheckPulseAudio
   2847        CheckARTSC
   2848        CheckESD
   2849        CheckNAS
   2850        CheckSNDIO
   2851        CheckX11
   2852        CheckDirectFB
   2853        CheckFusionSound
   2854        CheckOpenGLX11
   2855        CheckOpenGLESX11
   2856        CheckMir
   2857        CheckWayland
   2858        CheckLibUDev
   2859        CheckDBus
   2860        CheckIBus
   2861        CheckInputEvents
   2862        CheckInputKD
   2863        CheckTslib
   2864        CheckUSBHID
   2865        CheckPTHREAD
   2866        CheckClockGettime
   2867        CheckLinuxVersion
   2868        CheckRPATH
   2869        CheckVivanteVideo
   2870        # Set up files for the audio library
   2871        if test x$enable_audio = xyes; then
   2872          case $ARCH in
   2873            sysv5|solaris|hpux)
   2874                AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
   2875                SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
   2876                have_audio=yes
   2877            ;;
   2878            netbsd)  # Don't use this on OpenBSD, it's busted.
   2879                AC_DEFINE(SDL_AUDIO_DRIVER_BSD, 1, [ ])
   2880                SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
   2881                have_audio=yes
   2882            ;;
   2883            aix)
   2884                AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO, 1, [ ])
   2885                SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
   2886                have_audio=yes
   2887            ;;
   2888            android)
   2889                AC_DEFINE(SDL_AUDIO_DRIVER_ANDROID, 1, [ ])
   2890                SOURCES="$SOURCES $srcdir/src/audio/android/*.c"
   2891                SUMMARY_audio="${SUMMARY_audio} android"
   2892                have_audio=yes
   2893            ;;
   2894          esac
   2895        fi
   2896        # Set up files for the joystick library
   2897        if test x$enable_joystick = xyes; then
   2898          case $ARCH in
   2899            linux)
   2900                AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ])
   2901                SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
   2902                have_joystick=yes
   2903            ;;
   2904            android)
   2905                AC_DEFINE(SDL_JOYSTICK_ANDROID, 1, [ ])
   2906                SOURCES="$SOURCES $srcdir/src/joystick/android/*.c"
   2907                have_joystick=yes
   2908            ;;
   2909          esac
   2910        fi
   2911        # Set up files for the haptic library
   2912        if test x$enable_haptic = xyes; then
   2913           if test x$use_input_events = xyes; then
   2914             case $ARCH in
   2915               linux)
   2916                   AC_DEFINE(SDL_HAPTIC_LINUX, 1, [ ])
   2917                   SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
   2918                   have_haptic=yes
   2919               ;;
   2920             esac
   2921           fi
   2922        fi
   2923        # Set up files for the power library
   2924        if test x$enable_power = xyes; then
   2925             case $ARCH in
   2926               linux)
   2927                   AC_DEFINE(SDL_POWER_LINUX, 1, [ ])
   2928                   SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
   2929                   have_power=yes
   2930               ;;
   2931               android)
   2932                   AC_DEFINE(SDL_POWER_ANDROID, 1, [ ])
   2933                   SOURCES="$SOURCES $srcdir/src/power/android/*.c"
   2934                   have_power=yes
   2935               ;;
   2936             esac
   2937        fi
   2938        # Set up files for the filesystem library
   2939        if test x$enable_filesystem = xyes; then
   2940            AC_DEFINE(SDL_FILESYSTEM_UNIX, 1, [ ])
   2941            SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
   2942            have_filesystem=yes
   2943        fi
   2944        # Set up files for the timer library
   2945        if test x$enable_timers = xyes; then
   2946            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
   2947            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
   2948            have_timers=yes
   2949        fi
   2950        # Set up files for udev hotplugging support
   2951        if test x$enable_libudev = xyes && test x$have_libudev_h_hdr = xyes; then
   2952            SOURCES="$SOURCES $srcdir/src/core/linux/SDL_udev.c"               
   2953        fi
   2954        # Set up files for evdev input
   2955        if test x$use_input_events = xyes; then
   2956            SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev.c"
   2957        fi       
   2958        ;;
   2959    *-*-cygwin* | *-*-mingw32*)
   2960        ARCH=win32
   2961        if test "$build" != "$host"; then # cross-compiling
   2962            # Default cross-compile location
   2963            ac_default_prefix=/usr/local/cross-tools/$host
   2964        else
   2965            # Look for the location of the tools and install there
   2966            if test "$BUILD_PREFIX" != ""; then
   2967                ac_default_prefix=$BUILD_PREFIX
   2968            fi
   2969        fi
   2970        CheckDummyVideo
   2971        CheckDiskAudio
   2972        CheckDummyAudio
   2973        CheckWINDOWS
   2974        CheckWINDOWSGL
   2975        CheckWINDOWSGLES
   2976        CheckDIRECTX
   2977
   2978        # Set up the core platform files
   2979        SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
   2980
   2981        # Set up files for the video library
   2982        if test x$enable_video = xyes; then
   2983            AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS, 1, [ ])
   2984            SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
   2985            have_video=yes
   2986            AC_ARG_ENABLE(render-d3d,
   2987AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
   2988                                , enable_render_d3d=yes)
   2989            if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
   2990                AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ])
   2991            fi
   2992            if test x$enable_render_d3d = xyes -a x$have_d3d11 = xyes; then
   2993                AC_DEFINE(SDL_VIDEO_RENDER_D3D11, 1, [ ])
   2994            fi
   2995        fi
   2996        # Set up files for the audio library
   2997        if test x$enable_audio = xyes; then
   2998            AC_DEFINE(SDL_AUDIO_DRIVER_WINMM, 1, [ ])
   2999            SOURCES="$SOURCES $srcdir/src/audio/winmm/*.c"
   3000            if test x$have_dsound = xyes; then
   3001                AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
   3002                SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
   3003            fi
   3004            if test x$have_xaudio2 = xyes; then
   3005                AC_DEFINE(SDL_AUDIO_DRIVER_XAUDIO2, 1, [ ])
   3006                SOURCES="$SOURCES $srcdir/src/audio/xaudio2/*.c"
   3007            fi
   3008            have_audio=yes
   3009        fi
   3010        # Set up files for the joystick library
   3011        if test x$enable_joystick = xyes; then
   3012            if test x$have_dinput = xyes -o x$have_xinput = xyes; then
   3013                if test x$have_xinput = xyes; then
   3014                    AC_DEFINE(SDL_JOYSTICK_XINPUT, 1, [ ])
   3015                fi
   3016                if test x$have_dinput = xyes; then
   3017                    AC_DEFINE(SDL_JOYSTICK_DINPUT, 1, [ ])
   3018                    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
   3019                fi
   3020            else
   3021                AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
   3022            fi
   3023            SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
   3024            have_joystick=yes
   3025        fi
   3026        if test x$enable_haptic = xyes; then
   3027            if test x$have_dinput = xyes -o x$have_xinput = xyes; then
   3028                if test x$have_xinput = xyes; then
   3029                    AC_DEFINE(SDL_HAPTIC_XINPUT, 1, [ ])
   3030                fi
   3031                if test x$have_dinput = xyes; then
   3032                    AC_DEFINE(SDL_HAPTIC_DINPUT, 1, [ ])
   3033                fi
   3034                SOURCES="$SOURCES $srcdir/src/haptic/windows/*.c"
   3035                have_haptic=yes
   3036            fi
   3037        fi
   3038        if test x$enable_power = xyes; then
   3039            AC_DEFINE(SDL_POWER_WINDOWS, 1, [ ])
   3040            SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
   3041            have_power=yes
   3042        fi
   3043        if test x$enable_filesystem = xyes; then
   3044            AC_DEFINE(SDL_FILESYSTEM_WINDOWS, 1, [ ])
   3045            SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c"
   3046            have_filesystem=yes
   3047        fi
   3048        # Set up files for the thread library
   3049        if test x$enable_threads = xyes; then
   3050            AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ])
   3051            SOURCES="$SOURCES $srcdir/src/thread/windows/*.c"
   3052            SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
   3053            have_threads=yes
   3054        fi
   3055        # Set up files for the timer library
   3056        if test x$enable_timers = xyes; then
   3057            AC_DEFINE(SDL_TIMER_WINDOWS, 1, [ ])
   3058            SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
   3059            have_timers=yes
   3060        fi
   3061        # Set up files for the shared object loading library
   3062        if test x$enable_loadso = xyes; then
   3063            AC_DEFINE(SDL_LOADSO_WINDOWS, 1, [ ])
   3064            SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
   3065            have_loadso=yes
   3066        fi
   3067        # Set up the system libraries we need
   3068        if test -f /lib/w32api/libuuid.a; then
   3069            LIBUUID=/lib/w32api/libuuid.a
   3070        else
   3071            LIBUUID=-luuid
   3072        fi
   3073        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion $LIBUUID -XCClinker -static-libgcc"
   3074        # The Windows platform requires special setup
   3075        VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
   3076        SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
   3077        SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
   3078        SDL_LIBS="-lSDL2main $SDL_LIBS -mwindows"
   3079
   3080        # Check to see if this is a mingw or cygwin build
   3081        have_mingw32=
   3082        AC_CHECK_LIB(mingw32, main, [have_mingw32=yes])
   3083        if test x$have_mingw32 = xyes; then
   3084            SDL_LIBS="-lmingw32 $SDL_LIBS"
   3085        else
   3086            SDL_LIBS="-lcygwin $SDL_LIBS"
   3087        fi
   3088        ;;
   3089
   3090    dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
   3091    *-*-beos*)
   3092        AC_MSG_ERROR([
   3093*** BeOS support has been removed as of SDL 2.0.2.
   3094        ])
   3095        ;;
   3096
   3097    *-*-haiku*)
   3098        ARCH=haiku
   3099        ac_default_prefix=/boot/system
   3100        CheckDummyVideo
   3101        CheckDiskAudio
   3102        CheckDummyAudio
   3103        CheckHaikuVideo
   3104        CheckHaikuGL
   3105        CheckPTHREAD
   3106
   3107        # Set up files for the audio library
   3108        if test x$enable_audio = xyes; then
   3109            AC_DEFINE(SDL_AUDIO_DRIVER_HAIKU, 1, [ ])
   3110            SOURCES="$SOURCES $srcdir/src/audio/haiku/*.cc"
   3111            have_audio=yes
   3112        fi
   3113        # Set up files for the joystick library
   3114        if test x$enable_joystick = xyes; then
   3115            AC_DEFINE(SDL_JOYSTICK_HAIKU, 1, [ ])
   3116            SOURCES="$SOURCES $srcdir/src/joystick/haiku/*.cc"
   3117            have_joystick=yes
   3118        fi
   3119        # Set up files for the timer library
   3120        if test x$enable_timers = xyes; then
   3121            AC_DEFINE(SDL_TIMER_HAIKU, 1, [ ])
   3122            SOURCES="$SOURCES $srcdir/src/timer/haiku/*.c"
   3123            have_timers=yes
   3124        fi
   3125        # Set up files for the shared object loading library
   3126        if test x$enable_loadso = xyes; then
   3127            AC_DEFINE(SDL_LOADSO_HAIKU, 1, [ ])
   3128            SOURCES="$SOURCES $srcdir/src/loadso/haiku/*.c"
   3129            have_loadso=yes
   3130        fi
   3131        # Set up files for the system power library
   3132        if test x$enable_power = xyes; then
   3133            AC_DEFINE(SDL_POWER_HAIKU, 1, [ ])
   3134            SOURCES="$SOURCES $srcdir/src/power/haiku/*.c"
   3135            have_power=yes
   3136        fi
   3137        # Set up files for the system filesystem library
   3138        if test x$enable_filesystem = xyes; then
   3139            AC_DEFINE(SDL_FILESYSTEM_HAIKU, 1, [ ])
   3140            SOURCES="$SOURCES $srcdir/src/filesystem/haiku/*.cc"
   3141            have_filesystem=yes
   3142        fi
   3143        # The Haiku platform requires special setup.
   3144        SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
   3145        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
   3146        ;;
   3147    arm*-apple-darwin*)
   3148        # iOS - We are not writing anything to confdefs.h because you have to replace
   3149        # SDL_config.h for SDL_config_iphoneos.h anyway
   3150        ARCH=ios
   3151
   3152        CheckVisibilityHidden
   3153        CheckDummyVideo
   3154        CheckDiskAudio
   3155        CheckDummyAudio
   3156        CheckDLOPEN
   3157        CheckCOCOA
   3158        CheckPTHREAD
   3159
   3160
   3161        # Set up files for the audio library
   3162        if test x$enable_audio = xyes; then
   3163            SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.c"
   3164            SUMMARY_audio="${SUMMARY_audio} coreaudio"
   3165            have_audio=yes
   3166        fi
   3167        # Set up files for the joystick library
   3168        if test x$enable_joystick = xyes; then
   3169            SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
   3170            have_joystick=yes
   3171        fi
   3172        # Set up files for the haptic library
   3173        #if test x$enable_haptic = xyes; then
   3174        #    SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
   3175        #    have_haptic=yes
   3176        #    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
   3177        #fi
   3178        # Set up files for the power library
   3179        if test x$enable_power = xyes; then
   3180            SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
   3181            have_power=yes
   3182        fi
   3183        # Set up files for the filesystem library
   3184        if test x$enable_filesystem = xyes; then
   3185            SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
   3186            have_filesystem=yes
   3187        fi
   3188        # Set up files for the timer library
   3189        if test x$enable_timers = xyes; then
   3190            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
   3191            have_timers=yes
   3192        fi
   3193        # Set up additional files for the file library
   3194        if test x$enable_file = xyes; then
   3195            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
   3196        fi
   3197        # The iOS platform requires special setup.
   3198        SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
   3199        EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
   3200        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
   3201        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
   3202        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
   3203        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
   3204        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
   3205        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
   3206        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
   3207        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
   3208        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
   3209        ;;
   3210    *-*-darwin* )
   3211        # This could be either full "Mac OS X", or plain "Darwin" which is
   3212        # just the OS X kernel sans upper layers like Carbon and Cocoa.
   3213        # Next line is broken, and a few files below require Mac OS X (full)
   3214        ARCH=macosx
   3215
   3216        # Mac OS X builds with both the Carbon and OSX APIs at the moment
   3217        EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
   3218        EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
   3219
   3220        CheckVisibilityHidden
   3221        CheckDummyVideo
   3222        CheckDiskAudio
   3223        CheckDummyAudio
   3224        CheckDLOPEN
   3225        CheckCOCOA
   3226        CheckX11
   3227        CheckMacGL
   3228        CheckOpenGLX11
   3229        CheckPTHREAD
   3230
   3231        # Set up files for the audio library
   3232        if test x$enable_audio = xyes; then
   3233            AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
   3234            SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.c"
   3235            SUMMARY_audio="${SUMMARY_audio} coreaudio"
   3236            have_audio=yes
   3237        fi
   3238        # Set up files for the joystick library
   3239        if test x$enable_joystick = xyes; then
   3240            AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
   3241            SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
   3242            have_joystick=yes
   3243        fi
   3244        # Set up files for the haptic library
   3245        if test x$enable_haptic = xyes; then
   3246            AC_DEFINE(SDL_HAPTIC_IOKIT, 1, [ ])
   3247            SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
   3248            have_haptic=yes
   3249            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
   3250        fi
   3251        # Set up files for the power library
   3252        if test x$enable_power = xyes; then
   3253            AC_DEFINE(SDL_POWER_MACOSX, 1, [ ])
   3254            SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
   3255            have_power=yes
   3256        fi
   3257        # Set up files for the filesystem library
   3258        if test x$enable_filesystem = xyes; then
   3259            AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
   3260            SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
   3261            have_filesystem=yes
   3262        fi
   3263        # Set up files for the timer library
   3264        if test x$enable_timers = xyes; then
   3265            AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
   3266            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
   3267            have_timers=yes
   3268        fi
   3269        # Set up additional files for the file library
   3270        if test x$enable_file = xyes; then
   3271            SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
   3272        fi
   3273        # The Mac OS X platform requires special setup.
   3274        EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
   3275        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
   3276        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreVideo"
   3277        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
   3278        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
   3279        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
   3280        # If audio is used, add the AudioUnit framework
   3281        if test x$enable_audio = xyes; then
   3282            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
   3283        fi
   3284        ;;
   3285    *-nacl|*-pnacl)
   3286        ARCH=nacl
   3287        CheckNativeClient
   3288        CheckDummyAudio
   3289        CheckDummyVideo
   3290        CheckInputEvents
   3291        CheckPTHREAD
   3292        
   3293        # Set up files for the timer library
   3294        if test x$enable_timers = xyes; then
   3295            AC_DEFINE(SDL_TIMER_UNIX)
   3296            SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
   3297            have_timers=yes
   3298        fi
   3299        
   3300        if test x$enable_filesystem = xyes; then
   3301            AC_DEFINE(SDL_FILESYSTEM_NACL, 1, [ ])
   3302            SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c"
   3303            have_filesystem=yes
   3304        fi
   3305        
   3306        ;;
   3307    *)
   3308        AC_MSG_ERROR([
   3309*** Unsupported host:  Please add to configure.in
   3310        ])
   3311        ;;
   3312esac
   3313
   3314dnl Do this on all platforms, after everything else.
   3315CheckWarnAll
   3316CheckWarnShadow
   3317
   3318# Verify that we have all the platform specific files we need
   3319
   3320if test x$have_joystick != xyes; then
   3321    if test x$enable_joystick = xyes; then
   3322        AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
   3323    fi
   3324    SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
   3325fi
   3326if test x$have_haptic != xyes; then
   3327    if test x$enable_haptic = xyes; then
   3328        AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
   3329    fi
   3330    SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
   3331fi
   3332if test x$have_threads != xyes; then
   3333    if test x$enable_threads = xyes; then
   3334        AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
   3335    fi
   3336    SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
   3337fi
   3338if test x$have_timers != xyes; then
   3339    if test x$enable_timers = xyes; then
   3340        AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ])
   3341    fi
   3342    SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
   3343fi
   3344if test x$have_filesystem != xyes; then
   3345    if test x$enable_filesystem = xyes; then
   3346        AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
   3347    fi
   3348    SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c"
   3349fi
   3350if test x$have_loadso != xyes; then
   3351    if test x$enable_loadso = xyes; then
   3352        AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
   3353    fi
   3354    SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
   3355fi
   3356if test x$SDLMAIN_SOURCES = x; then
   3357    SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
   3358fi
   3359SDLTEST_SOURCES="$srcdir/src/test/*.c"
   3360
   3361OBJECTS=`echo $SOURCES`
   3362DEPENDS=`echo $SOURCES | tr ' ' '\n'`
   3363for EXT in asm cc m c S; do
   3364    OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
   3365    DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
   3366\\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
   3367	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
   3368done
   3369
   3370VERSION_OBJECTS=`echo $VERSION_SOURCES`
   3371VERSION_DEPENDS=`echo $VERSION_SOURCES`
   3372VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
   3373VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
   3374\\$(objects)/\\2.o: \\1/\\2.rc\\\\
   3375	\\$(WINDRES) \\$< \\$@,g"`
   3376
   3377SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
   3378SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
   3379SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
   3380SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
   3381\\$(objects)/\\2.o: \\1/\\2.c\\\\
   3382	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
   3383
   3384SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
   3385SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
   3386SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
   3387SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
   3388\\$(objects)/\\2.o: \\1/\\2.c\\\\
   3389	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
   3390
   3391# Set runtime shared library paths as needed
   3392
   3393if test "x$enable_rpath" = "xyes"; then
   3394  if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
   3395    SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
   3396  fi
   3397  if test $ARCH = solaris; then
   3398    SDL_RLD_FLAGS="-R\${libdir}"
   3399  fi
   3400else
   3401  SDL_RLD_FLAGS=""
   3402fi
   3403
   3404SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
   3405
   3406dnl Expand the cflags and libraries needed by apps using SDL
   3407AC_SUBST(SDL_CFLAGS)
   3408AC_SUBST(SDL_LIBS)
   3409AC_SUBST(SDL_STATIC_LIBS)
   3410AC_SUBST(SDL_RLD_FLAGS)
   3411if test x$enable_shared = xyes; then
   3412    ENABLE_SHARED_TRUE=
   3413    ENABLE_SHARED_FALSE="#"
   3414else
   3415    ENABLE_SHARED_TRUE="#"
   3416    ENABLE_SHARED_FALSE=
   3417fi
   3418if test x$enable_static = xyes; then
   3419    ENABLE_STATIC_TRUE=
   3420    ENABLE_STATIC_FALSE="#"
   3421else
   3422    ENABLE_STATIC_TRUE="#"
   3423    ENABLE_STATIC_FALSE=
   3424fi
   3425AC_SUBST(ENABLE_SHARED_TRUE)
   3426AC_SUBST(ENABLE_SHARED_FALSE)
   3427AC_SUBST(ENABLE_STATIC_TRUE)
   3428AC_SUBST(ENABLE_STATIC_FALSE)
   3429
   3430dnl Expand the sources and objects needed to build the library
   3431AC_SUBST(ac_aux_dir)
   3432AC_SUBST(INCLUDE)
   3433AC_SUBST(OBJECTS)
   3434AC_SUBST(VERSION_OBJECTS)
   3435AC_SUBST(SDLMAIN_OBJECTS)
   3436AC_SUBST(SDLTEST_OBJECTS)
   3437AC_SUBST(BUILD_CFLAGS)
   3438AC_SUBST(EXTRA_CFLAGS)
   3439AC_SUBST(BUILD_LDFLAGS)
   3440AC_SUBST(EXTRA_LDFLAGS)
   3441AC_SUBST(WINDRES)
   3442
   3443cat >Makefile.rules <<__EOF__
   3444
   3445# Build rules for objects
   3446-include \$(OBJECTS:.lo=.d)
   3447
   3448# Special dependency for SDL.c, since it depends on SDL_revision.h
   3449$srcdir/src/SDL.c: update-revision
   3450$DEPENDS
   3451$VERSION_DEPENDS
   3452$SDLMAIN_DEPENDS
   3453$SDLTEST_DEPENDS
   3454__EOF__
   3455
   3456AC_CONFIG_FILES([
   3457    Makefile:Makefile.in:Makefile.rules sdl2-config SDL2.spec sdl2.pc
   3458])
   3459AC_CONFIG_COMMANDS([sdl2_config],[chmod a+x sdl2-config])
   3460
   3461SUMMARY="SDL2 Configure Summary:\n"
   3462if test x$enable_shared = xyes; then
   3463    SUMMARY="${SUMMARY}Building Shared Libraries\n"
   3464fi
   3465if test x$enable_static = xyes; then
   3466    SUMMARY="${SUMMARY}Building Static Libraries\n"
   3467fi
   3468SUMMARY="${SUMMARY}Enabled modules :${SUMMARY_modules}\n"
   3469SUMMARY="${SUMMARY}Assembly Math   :${SUMMARY_math}\n" 
   3470SUMMARY="${SUMMARY}Audio drivers   :${SUMMARY_audio}\n"
   3471SUMMARY="${SUMMARY}Video drivers   :${SUMMARY_video}\n"
   3472if test x$have_x = xyes; then
   3473    SUMMARY="${SUMMARY}X11 libraries   :${SUMMARY_video_x11}\n"
   3474fi
   3475SUMMARY="${SUMMARY}Input drivers   :${SUMMARY_input}\n"
   3476if test x$enable_libudev = xyes; then
   3477    SUMMARY="${SUMMARY}Using libudev   : YES\n"
   3478else
   3479    SUMMARY="${SUMMARY}Using libudev   : NO\n"
   3480fi
   3481if test x$have_dbus_dbus_h_hdr = xyes; then
   3482    SUMMARY="${SUMMARY}Using dbus      : YES\n"
   3483else
   3484    SUMMARY="${SUMMARY}Using dbus      : NO\n"
   3485fi
   3486if test x$have_ibus_ibus_h_hdr = xyes; then
   3487    SUMMARY="${SUMMARY}Using ibus      : YES\n"
   3488else
   3489    SUMMARY="${SUMMARY}Using ibus      : NO\n"
   3490fi
   3491AC_CONFIG_COMMANDS([summary], [echo -en "$SUMMARY"], [SUMMARY="$SUMMARY"])
   3492
   3493AC_OUTPUT