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