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