configure.in
author Sam Lantinga <slouken@libsdl.org>
Mon, 08 Jul 2013 09:21:54 -0700
changeset 7379 b27c778a2bdb
parent 7367 d6eabafa8776
child 7380 e5830832d3f0
permissions -rw-r--r--
Make sure that srcdir has a full pathname so source indexing works.
     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=yes]]]),
   650                   , enable_oss=yes)
   651     if test x$enable_audio = xyes -a x$enable_oss = xyes; then
   652         AC_MSG_CHECKING(for OSS audio support)
   653         have_oss=no
   654         if test x$have_oss != xyes; then
   655             AC_TRY_COMPILE([
   656               #include <sys/soundcard.h>
   657             ],[
   658               int arg = SNDCTL_DSP_SETFRAGMENT;
   659             ],[
   660             have_oss=yes
   661             ])
   662         fi
   663         if test x$have_oss != xyes; then
   664             AC_TRY_COMPILE([
   665               #include <soundcard.h>
   666             ],[
   667               int arg = SNDCTL_DSP_SETFRAGMENT;
   668             ],[
   669             have_oss=yes
   670             AC_DEFINE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H, 1, [ ])
   671             ])
   672         fi
   673         AC_MSG_RESULT($have_oss)
   674         if test x$have_oss = xyes; then
   675             AC_DEFINE(SDL_AUDIO_DRIVER_OSS, 1, [ ])
   676             SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c"
   677             have_audio=yes
   678 
   679             # We may need to link with ossaudio emulation library
   680             case "$host" in
   681                 *-*-openbsd*|*-*-netbsd*)
   682                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lossaudio";;
   683             esac
   684         fi
   685     fi
   686 }
   687 
   688 dnl See if the ALSA audio interface is supported
   689 CheckALSA()
   690 {
   691     AC_ARG_ENABLE(alsa,
   692 AC_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]),
   693                   , enable_alsa=yes)
   694     if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
   695         AM_PATH_ALSA(0.9.0, have_alsa=yes, have_alsa=no)
   696         # Restore all flags from before the ALSA detection runs
   697         CFLAGS="$alsa_save_CFLAGS"
   698         LDFLAGS="$alsa_save_LDFLAGS"
   699         LIBS="$alsa_save_LIBS"
   700         if test x$have_alsa = xyes; then
   701             AC_ARG_ENABLE(alsa-shared,
   702 AC_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[default=yes]]]),
   703                           , enable_alsa_shared=yes)
   704             alsa_lib=[`find_lib "libasound.so.*" "$ALSA_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   705 
   706             AC_DEFINE(SDL_AUDIO_DRIVER_ALSA, 1, [ ])
   707             SOURCES="$SOURCES $srcdir/src/audio/alsa/*.c"
   708             EXTRA_CFLAGS="$EXTRA_CFLAGS $ALSA_CFLAGS"
   709             if test x$have_loadso != xyes && \
   710                test x$enable_alsa_shared = xyes; then
   711                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ALSA loading])
   712             fi
   713             if test x$have_loadso = xyes && \
   714                test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
   715                 echo "-- dynamic libasound -> $alsa_lib"
   716                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ALSA_DYNAMIC, "$alsa_lib", [ ])
   717             else
   718                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ALSA_LIBS"
   719             fi
   720             have_audio=yes
   721         fi
   722     fi
   723 }
   724 
   725 dnl Find the ESD includes and libraries
   726 CheckESD()
   727 {
   728     AC_ARG_ENABLE(esd,
   729 AC_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [[default=yes]]]),
   730                   , enable_esd=yes)
   731     if test x$enable_audio = xyes -a x$enable_esd = xyes; then
   732         AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
   733         if test x$have_esd = xyes; then
   734             AC_ARG_ENABLE(esd-shared,
   735 AC_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]),
   736                           , enable_esd_shared=yes)
   737             esd_lib=[`find_lib "libesd.so.*" "$ESD_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   738 
   739             AC_DEFINE(SDL_AUDIO_DRIVER_ESD, 1, [ ])
   740             SOURCES="$SOURCES $srcdir/src/audio/esd/*.c"
   741             EXTRA_CFLAGS="$EXTRA_CFLAGS $ESD_CFLAGS"
   742             if test x$have_loadso != xyes && \
   743                test x$enable_esd_shared = xyes; then
   744                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ESD loading])
   745             fi
   746             if test x$have_loadso = xyes && \
   747                test x$enable_esd_shared = xyes && test x$esd_lib != x; then
   748                 echo "-- dynamic libesd -> $esd_lib"
   749                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ESD_DYNAMIC, "$esd_lib", [ ])
   750             else
   751                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ESD_LIBS"
   752             fi
   753             have_audio=yes
   754         fi
   755     fi
   756 }
   757 
   758 dnl Find PulseAudio
   759 CheckPulseAudio()
   760 {
   761     AC_ARG_ENABLE(pulseaudio,
   762 AC_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]),
   763                   , enable_pulseaudio=yes)
   764     if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then
   765         audio_pulseaudio=no
   766 
   767         PULSEAUDIO_REQUIRED_VERSION=0.9
   768 
   769         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   770         AC_MSG_CHECKING(for PulseAudio $PULSEAUDIO_REQUIRED_VERSION support)
   771         if test x$PKG_CONFIG != xno; then
   772         if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSEAUDIO_REQUIRED_VERSION libpulse-simple; then
   773                 PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
   774                 PULSEAUDIO_LIBS=`$PKG_CONFIG --libs libpulse-simple`
   775                 audio_pulseaudio=yes
   776             fi
   777         fi
   778         AC_MSG_RESULT($audio_pulseaudio)
   779 
   780         if test x$audio_pulseaudio = xyes; then
   781             AC_ARG_ENABLE(pulseaudio-shared,
   782 AC_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]),
   783                           , enable_pulseaudio_shared=yes)
   784             pulseaudio_lib=[`find_lib "libpulse-simple.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   785 
   786             AC_DEFINE(SDL_AUDIO_DRIVER_PULSEAUDIO, 1, [ ])
   787             SOURCES="$SOURCES $srcdir/src/audio/pulseaudio/*.c"
   788             EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSEAUDIO_CFLAGS"
   789             if test x$have_loadso != xyes && \
   790                test x$enable_pulseaudio_shared = xyes; then
   791                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic PulseAudio loading])
   792             fi
   793             if test x$have_loadso = xyes && \
   794                test x$enable_pulseaudio_shared = xyes && test x$pulseaudio_lib != x; then
   795                 echo "-- dynamic libpulse-simple -> $pulseaudio_lib"
   796                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC, "$pulseaudio_lib", [ ])
   797 
   798                 case "$host" in
   799                     # On Solaris, pulseaudio must be linked deferred explicitly
   800                     # to prevent undefined symbol failures.
   801                     *-*-solaris*)
   802                         PULSEAUDIO_LIBS=`echo $PULSEAUDIO_LIBS | sed 's/\-l/-Wl,-l/g'`
   803                         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-zdeferred $PULSEAUDIO_LIBS -Wl,-znodeferred"
   804                 esac
   805             else
   806                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSEAUDIO_LIBS"
   807             fi
   808             have_audio=yes
   809         fi
   810     fi
   811 }
   812 
   813 CheckARTSC()
   814 {
   815     AC_ARG_ENABLE(arts,
   816 AC_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [[default=yes]]]),
   817                   , enable_arts=yes)
   818     if test x$enable_audio = xyes -a x$enable_arts = xyes; then
   819         AC_PATH_PROG(ARTSCONFIG, artsc-config)
   820         if test x$ARTSCONFIG = x -o x$ARTSCONFIG = x'"$ARTSCONFIG"'; then
   821             : # arts isn't installed
   822         else
   823             ARTS_CFLAGS=`$ARTSCONFIG --cflags`
   824             ARTS_LIBS=`$ARTSCONFIG --libs`
   825             AC_MSG_CHECKING(for aRts development environment)
   826             audio_arts=no
   827             save_CFLAGS="$CFLAGS"
   828             CFLAGS="$CFLAGS $ARTS_CFLAGS"
   829             AC_TRY_COMPILE([
   830              #include <artsc.h>
   831             ],[
   832              arts_stream_t stream;
   833             ],[
   834             audio_arts=yes
   835             ])
   836             CFLAGS="$save_CFLAGS"
   837             AC_MSG_RESULT($audio_arts)
   838             if test x$audio_arts = xyes; then
   839                 AC_ARG_ENABLE(arts-shared,
   840 AC_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [[default=yes]]]),
   841                               , enable_arts_shared=yes)
   842                 arts_lib=[`find_lib "libartsc.so.*" "$ARTS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   843 
   844                 AC_DEFINE(SDL_AUDIO_DRIVER_ARTS, 1, [ ])
   845                 SOURCES="$SOURCES $srcdir/src/audio/arts/*.c"
   846                 EXTRA_CFLAGS="$EXTRA_CFLAGS $ARTS_CFLAGS"
   847                 if test x$have_loadso != xyes && \
   848                    test x$enable_arts_shared = xyes; then
   849                     AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ARTS loading])
   850                 fi
   851                 if test x$have_loadso = xyes && \
   852                    test x$enable_arts_shared = xyes && test x$arts_lib != x; then
   853                     echo "-- dynamic libartsc -> $arts_lib"
   854                     AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ARTS_DYNAMIC, "$arts_lib", [ ])
   855                 else
   856                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARTS_LIBS"
   857                 fi
   858                 have_audio=yes
   859             fi
   860         fi
   861     fi
   862 }
   863 
   864 dnl See if the NAS audio interface is supported
   865 CheckNAS()
   866 {
   867     AC_ARG_ENABLE(nas,
   868 AC_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]),
   869                   , enable_nas=yes)
   870     if test x$enable_audio = xyes -a x$enable_nas = xyes; then
   871         AC_CHECK_HEADER(audio/audiolib.h, have_nas_hdr=yes)
   872         AC_CHECK_LIB(audio, AuOpenServer, have_nas_lib=yes)
   873 
   874         AC_MSG_CHECKING(for NAS audio support)
   875         have_nas=no
   876 
   877         if test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then
   878             have_nas=yes
   879             NAS_LIBS="-laudio"
   880 
   881         elif test -r /usr/X11R6/include/audio/audiolib.h; then
   882             have_nas=yes
   883             NAS_CFLAGS="-I/usr/X11R6/include/"
   884             NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
   885 
   886         fi
   887 
   888         AC_MSG_RESULT($have_nas)
   889 
   890         if test x$have_nas = xyes; then
   891             AC_ARG_ENABLE(nas-shared,
   892 AC_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [[default=yes]]]),
   893                           , enable_nas_shared=yes)
   894             nas_lib=[`find_lib "libaudio.so.*" "$NAS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   895 
   896             if test x$have_loadso != xyes && \
   897                test x$enable_nas_shared = xyes; then
   898                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic NAS loading])
   899             fi
   900             if test x$have_loadso = xyes && \
   901                test x$enable_nas_shared = xyes && test x$nas_lib != x; then
   902                 echo "-- dynamic libaudio -> $nas_lib"
   903                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_NAS_DYNAMIC, "$nas_lib", [ ])
   904             else
   905                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
   906             fi
   907 
   908             AC_DEFINE(SDL_AUDIO_DRIVER_NAS, 1, [ ])
   909             SOURCES="$SOURCES $srcdir/src/audio/nas/*.c"
   910             EXTRA_CFLAGS="$EXTRA_CFLAGS $NAS_CFLAGS"
   911             have_audio=yes
   912         fi
   913     fi
   914 }
   915 
   916 dnl See if the sndio audio interface is supported
   917 CheckSNDIO()
   918 {
   919     AC_ARG_ENABLE(sndio,
   920 AC_HELP_STRING([--enable-sndio], [support the sndio audio API [[default=yes]]]),
   921                   , enable_sndio=yes)
   922     if test x$enable_audio = xyes -a x$enable_sndio = xyes; then
   923         AC_CHECK_HEADER(sndio.h, have_sndio_hdr=yes)
   924         AC_CHECK_LIB(sndio, sio_open, have_sndio_lib=yes)
   925 
   926         AC_MSG_CHECKING(for sndio audio support)
   927         have_sndio=no
   928 
   929         if test x$have_sndio_hdr = xyes -a x$have_sndio_lib = xyes; then
   930             have_sndio=yes
   931             SNDIO_LIBS="-lsndio"
   932         fi
   933 
   934         AC_MSG_RESULT($have_sndio)
   935 
   936         if test x$have_sndio = xyes; then
   937             AC_ARG_ENABLE(sndio-shared,
   938 AC_HELP_STRING([--enable-sndio-shared], [dynamically load sndio audio support [[default=yes]]]),
   939                           , enable_sndio_shared=yes)
   940             sndio_lib=[`find_lib "libsndio.so.*" "$SNDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   941 
   942             if test x$have_loadso != xyes && \
   943                test x$enable_sndio_shared = xyes; then
   944                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic sndio loading])
   945             fi
   946             if test x$have_loadso = xyes && \
   947                test x$enable_sndio_shared = xyes && test x$sndio_lib != x; then
   948                 echo "-- dynamic libsndio -> $sndio_lib"
   949                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC, "$sndio_lib", [ ])
   950             else
   951                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SNDIO_LIBS"
   952             fi
   953 
   954             AC_DEFINE(SDL_AUDIO_DRIVER_SNDIO, 1, [ ])
   955             SOURCES="$SOURCES $srcdir/src/audio/sndio/*.c"
   956             EXTRA_CFLAGS="$EXTRA_CFLAGS $SNDIO_CFLAGS"
   957             have_audio=yes
   958         fi
   959     fi
   960 }
   961 
   962 dnl rcg07142001 See if the user wants the disk writer audio driver...
   963 CheckDiskAudio()
   964 {
   965     AC_ARG_ENABLE(diskaudio,
   966 AC_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [[default=yes]]]),
   967                   , enable_diskaudio=yes)
   968     if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
   969         AC_DEFINE(SDL_AUDIO_DRIVER_DISK, 1, [ ])
   970         SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
   971     fi
   972 }
   973 
   974 dnl rcg03142006 See if the user wants the dummy audio driver...
   975 CheckDummyAudio()
   976 {
   977     AC_ARG_ENABLE(dummyaudio,
   978 AC_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=yes]]]),
   979                   , enable_dummyaudio=yes)
   980     if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then
   981         AC_DEFINE(SDL_AUDIO_DRIVER_DUMMY, 1, [ ])
   982         SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c"
   983     fi
   984 }
   985 
   986 dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
   987 dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
   988 CheckVisibilityHidden()
   989 {
   990     AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
   991     have_gcc_fvisibility=no
   992 
   993     visibility_CFLAGS="-fvisibility=hidden"
   994     save_CFLAGS="$CFLAGS"
   995     CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
   996     AC_TRY_COMPILE([
   997     #if !defined(__GNUC__) || __GNUC__ < 4
   998     #error SDL only uses visibility attributes in GCC 4 or newer
   999     #endif
  1000     ],[
  1001     ],[
  1002     have_gcc_fvisibility=yes
  1003     ])
  1004     AC_MSG_RESULT($have_gcc_fvisibility)
  1005     CFLAGS="$save_CFLAGS"
  1006 
  1007     if test x$have_gcc_fvisibility = xyes; then
  1008         EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
  1009     fi
  1010 }
  1011 
  1012 dnl See if GCC's -mpreferred-stack-boundary is supported.
  1013 dnl  Reference: http://bugzilla.libsdl.org/show_bug.cgi?id=1296
  1014 CheckStackBoundary()
  1015 {
  1016     AC_MSG_CHECKING(for GCC -mpreferred-stack-boundary option)
  1017     have_gcc_preferred_stack_boundary=no
  1018 
  1019     save_CFLAGS="$CFLAGS"
  1020     CFLAGS="$save_CFLAGS -mpreferred-stack-boundary=2"
  1021     AC_TRY_COMPILE([
  1022     int x = 0;
  1023     ],[
  1024     ],[
  1025     have_gcc_preferred_stack_boundary=yes
  1026     ])
  1027     AC_MSG_RESULT($have_gcc_preferred_stack_boundary)
  1028     CFLAGS="$save_CFLAGS"
  1029 
  1030     if test x$have_gcc_preferred_stack_boundary = xyes; then
  1031         EXTRA_CFLAGS="$EXTRA_CFLAGS -mpreferred-stack-boundary=2"
  1032     fi
  1033 }
  1034 
  1035 
  1036 dnl See if GCC's -Wall is supported.
  1037 CheckWarnAll()
  1038 {
  1039     AC_MSG_CHECKING(for GCC -Wall option)
  1040     have_gcc_Wall=no
  1041 
  1042     save_CFLAGS="$CFLAGS"
  1043     CFLAGS="$save_CFLAGS -Wall"
  1044     AC_TRY_COMPILE([
  1045     int x = 0;
  1046     ],[
  1047     ],[
  1048     have_gcc_Wall=yes
  1049     ])
  1050     AC_MSG_RESULT($have_gcc_Wall)
  1051     CFLAGS="$save_CFLAGS"
  1052 
  1053     if test x$have_gcc_Wall = xyes; then
  1054         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
  1055 
  1056         dnl Haiku headers use multicharacter constants all over the place. Ignore these warnings when using -Wall.
  1057         AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
  1058         need_gcc_Wno_multichar=no
  1059         case "$host" in
  1060             *-*-beos* | *-*-haiku*)
  1061                 need_gcc_Wno_multichar=yes
  1062                 ;;
  1063         esac
  1064         AC_MSG_RESULT($need_gcc_Wno_multichar)
  1065         if test x$need_gcc_Wno_multichar = xyes; then
  1066             EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar"
  1067         fi
  1068     fi
  1069 }
  1070 
  1071 
  1072 dnl Find the X11 include and library directories
  1073 CheckX11()
  1074 {
  1075 
  1076 
  1077     AC_ARG_ENABLE(video-x11,
  1078 AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
  1079                   , enable_video_x11=yes)
  1080     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
  1081         case "$host" in
  1082             *-*-darwin*)
  1083                 # This isn't necessary for X11, but fixes GLX detection
  1084                 if test "x$x_includes" = xNONE && \
  1085                    test "x$x_libraries" = xNONE && \
  1086                    test -d /usr/X11R6/include && \
  1087                    test -d /usr/X11R6/lib; then
  1088                     x_includes="/usr/X11R6/include"
  1089                     x_libraries="/usr/X11R6/lib"
  1090                 fi
  1091                 ;;
  1092         esac
  1093         AC_PATH_X
  1094         AC_PATH_XTRA
  1095         if test x$have_x = xyes; then
  1096             # Only allow dynamically loaded X11 if the X11 function pointers
  1097             # will not end up in the global namespace, which causes problems
  1098             # with other libraries calling X11 functions.
  1099             x11_symbols_private=$have_gcc_fvisibility
  1100 
  1101             AC_ARG_ENABLE(x11-shared,
  1102 AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
  1103                           , enable_x11_shared=maybe)
  1104 
  1105             case "$host" in
  1106                 *-*-darwin*)
  1107                     x11_symbols_private=yes
  1108                     x11_lib='/usr/X11R6/lib/libX11.6.dylib'
  1109                     x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
  1110                     xcursor_lib='/usr/X11R6/lib/libXcursor.1.dylib'
  1111                     xinerama_lib='/usr/X11R6/lib/libXinerama.1.dylib'
  1112                     xinput_lib='/usr/X11R6/lib/libXi.6.dylib'
  1113                     xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
  1114                     xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
  1115                     xss_lib='/usr/X11R6/lib/libXss.1.dylib'
  1116                     xvidmode_lib='/usr/X11R6/lib/libXxf86vm.1.dylib'
  1117                     ;;
  1118                 *-*-openbsd*)
  1119                     x11_lib='libX11.so'
  1120                     x11ext_lib='libXext.so'
  1121                     xcursor_lib='libXcursor.so'
  1122                     xinerama_lib='libXinerama.so'
  1123                     xinput_lib='libXi.so'
  1124                     xrandr_lib='libXrandr.so'
  1125                     xrender_lib='libXrender.so'
  1126                     xss_lib='libXss.so'
  1127                     xvidmode_lib='libXxf86vm.so'
  1128                     ;;
  1129                 *)
  1130                     x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1131                     x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1132                     xcursor_lib=[`find_lib "libXcursor.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1133                     xinerama_lib=[`find_lib "libXinerama.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1134                     xinput_lib=[`find_lib "libXi.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1135                     xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1136                     xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1137                     xss_lib=[`find_lib "libXss.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1138                     xvidmode_lib=[`find_lib "libXxf86vm.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1139                     ;;
  1140             esac
  1141 
  1142             if test x$ac_cv_func_shmat != xyes; then
  1143                 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
  1144             fi
  1145             CFLAGS="$CFLAGS $X_CFLAGS"
  1146             LDFLAGS="$LDFLAGS $X_LIBS"
  1147 
  1148             AC_DEFINE(SDL_VIDEO_DRIVER_X11, 1, [ ])
  1149             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
  1150             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
  1151 
  1152             if test x$enable_x11_shared = xmaybe; then
  1153                 enable_x11_shared=$x11_symbols_private
  1154             fi
  1155             if test x$have_loadso != xyes && \
  1156                test x$enable_x11_shared = xyes; then
  1157                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
  1158                 enable_x11_shared=no
  1159             fi
  1160             if test x$x11_symbols_private != xyes && \
  1161                test x$enable_x11_shared = xyes; then
  1162                 AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
  1163                 enable_x11_shared=no
  1164             fi
  1165 
  1166             if test x$have_loadso = xyes && \
  1167                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
  1168                 echo "-- dynamic libX11 -> $x11_lib"
  1169                 echo "-- dynamic libX11ext -> $x11ext_lib"
  1170                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib", [ ])
  1171                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib", [ ])
  1172             else
  1173                 enable_x11_shared=no
  1174                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
  1175             fi
  1176             have_video=yes
  1177 
  1178             AC_MSG_CHECKING(for const parameter to XextAddDisplay)
  1179             have_const_param_XextAddDisplay=no
  1180             AC_TRY_COMPILE([
  1181               #include <X11/Xlib.h>
  1182               #include <X11/Xproto.h>
  1183               #include <X11/extensions/Xext.h>
  1184               #include <X11/extensions/extutil.h>
  1185               extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
  1186             ],[
  1187             ],[
  1188             have_const_param_XextAddDisplay=yes
  1189             AC_DEFINE(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY)
  1190             ])
  1191             AC_MSG_RESULT($have_const_param_XextAddDisplay)
  1192 
  1193             AC_MSG_CHECKING(for const parameter to _XData32)
  1194 	    have_const_param_xdata32=no
  1195 	    AC_TRY_COMPILE([
  1196 	      #include <X11/Xlibint.h>
  1197 	      extern int _XData32(Display *dpy,register _Xconst long *data,unsigned len);
  1198 	    ],[
  1199 	    ],[
  1200 	    have_const_param_xdata32=yes
  1201 	    AC_DEFINE(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32)
  1202 	    ])
  1203 	    AC_MSG_RESULT($have_const_param_xdata32)
  1204 
  1205             dnl AC_CHECK_LIB(X11, XGetEventData, AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS, 1, [Have XGenericEvent]))
  1206             AC_MSG_CHECKING([for XGenericEvent])
  1207             have_XGenericEvent=no
  1208             AC_TRY_COMPILE([
  1209               	#include <X11/Xlib.h>
  1210             ],[
  1211 Display *display;
  1212 XEvent event;
  1213 XGenericEventCookie *cookie = &event.xcookie;
  1214 XNextEvent(display, &event);
  1215 XGetEventData(display, cookie);
  1216 XFreeEventData(display, cookie);
  1217             ],[
  1218                 have_XGenericEvent=yes
  1219                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS)
  1220             ])
  1221             AC_MSG_RESULT($have_XGenericEvent)
  1222 
  1223             AC_CHECK_LIB(X11, XkbKeycodeToKeysym, AC_DEFINE(SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM, 1, [Have XkbKeycodeToKeysym]))
  1224 
  1225             AC_ARG_ENABLE(video-x11-xcursor,
  1226 AC_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[default=yes]]]),
  1227                             , enable_video_x11_xcursor=yes)
  1228             if test x$enable_video_x11_xcursor = xyes; then
  1229                 definitely_enable_video_x11_xcursor=no
  1230                 AC_CHECK_HEADER(X11/Xcursor/Xcursor.h,
  1231                                 have_xcursor_h_hdr=yes,
  1232                                 have_xcursor_h_hdr=no,
  1233                                 [#include <X11/Xlib.h>
  1234                                 ])
  1235                 if test x$have_xcursor_h_hdr = xyes; then
  1236                     if test x$enable_x11_shared = xyes && test x$xcursor_lib != x ; then
  1237                         echo "-- dynamic libXcursor -> $xcursor_lib"
  1238                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR, "$xcursor_lib", [ ])
  1239                         definitely_enable_video_x11_xcursor=yes
  1240                     else
  1241                         AC_CHECK_LIB(Xcursor, XcursorImageCreate, have_xcursor_lib=yes)
  1242                         if test x$have_xcursor_lib = xyes ; then
  1243                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXcursor"
  1244                             definitely_enable_video_x11_xcursor=yes
  1245                         fi
  1246                     fi
  1247                 fi
  1248             fi
  1249             if test x$definitely_enable_video_x11_xcursor = xyes; then
  1250                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XCURSOR, 1, [ ])
  1251             fi
  1252             AC_ARG_ENABLE(video-x11-xinerama,
  1253 AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
  1254                             , enable_video_x11_xinerama=yes)
  1255             if test x$enable_video_x11_xinerama = xyes; then
  1256                 definitely_enable_video_x11_xinerama=no
  1257                 AC_CHECK_HEADER(X11/extensions/Xinerama.h,
  1258                                 have_xinerama_h_hdr=yes,
  1259                                 have_xinerama_h_hdr=no,
  1260                                 [#include <X11/Xlib.h>
  1261                                 ])
  1262                 if test x$have_xinerama_h_hdr = xyes; then
  1263                     if test x$enable_x11_shared = xyes && test x$xinerama_lib != x ; then
  1264                         echo "-- dynamic libXinerama -> $xinerama_lib"
  1265                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA, "$xinerama_lib", [ ])
  1266                         definitely_enable_video_x11_xinerama=yes
  1267                     else
  1268                         AC_CHECK_LIB(Xinerama, XineramaQueryExtension, have_xinerama_lib=yes)
  1269                         if test x$have_xinerama_lib = xyes ; then
  1270                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXinerama"
  1271                             definitely_enable_video_x11_xinerama=yes
  1272                         fi
  1273                     fi
  1274                 fi
  1275             fi
  1276             if test x$definitely_enable_video_x11_xinerama = xyes; then
  1277                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA, 1, [ ])
  1278             fi
  1279             AC_ARG_ENABLE(video-x11-xinput,
  1280 AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
  1281                             , enable_video_x11_xinput=yes)
  1282             if test x$enable_video_x11_xinput = xyes; then
  1283                 definitely_enable_video_x11_xinput=no
  1284                 AC_CHECK_HEADER(X11/extensions/XInput2.h,
  1285                                 have_xinput_h_hdr=yes,
  1286                                 have_xinput_h_hdr=no,
  1287                                 [#include <X11/Xlib.h>
  1288                                 ])
  1289                 if test x$have_xinput_h_hdr = xyes; then
  1290                     if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
  1291                         echo "-- dynamic libXi -> $xinput_lib"
  1292                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2, "$xinput_lib", [ ])
  1293                         definitely_enable_video_x11_xinput=yes
  1294                     else
  1295                         AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
  1296                         if test x$have_xinput_lib = xyes ; then
  1297                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
  1298                             definitely_enable_video_x11_xinput=yes
  1299                         fi
  1300                     fi
  1301                 fi
  1302             fi
  1303             if test x$definitely_enable_video_x11_xinput = xyes; then
  1304                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ])
  1305                 AC_MSG_CHECKING(for xinput2 multitouch)
  1306             	have_xinput2_multitouch=no
  1307             	AC_TRY_COMPILE([
  1308               		#include <X11/Xlib.h>
  1309              		#include <X11/Xproto.h>
  1310 			#include <X11/extensions/XInput2.h>
  1311             	],[
  1312 int event_type = XI_TouchBegin;
  1313 XITouchClassInfo *t;
  1314 Status 
  1315 XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f)
  1316 {
  1317     return (Status)0;
  1318 }
  1319             	],[
  1320             	have_xinput2_multitouch=yes
  1321             	AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH)
  1322             	])
  1323             	AC_MSG_RESULT($have_xinput2_multitouch)
  1324             fi
  1325             AC_ARG_ENABLE(video-x11-xrandr,
  1326 AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
  1327                             , enable_video_x11_xrandr=yes)
  1328             if test x$enable_video_x11_xrandr = xyes; then
  1329                 definitely_enable_video_x11_xrandr=no
  1330                 AC_CHECK_HEADER(X11/extensions/Xrandr.h,
  1331                                 have_xrandr_h_hdr=yes,
  1332                                 have_xrandr_h_hdr=no,
  1333                                 [#include <X11/Xlib.h>
  1334                                 ])
  1335                 if test x$have_xrandr_h_hdr = xyes; then
  1336                     if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
  1337                         echo "-- dynamic libXrandr -> $xrandr_lib"
  1338                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib", [ ])
  1339                         definitely_enable_video_x11_xrandr=yes
  1340                     else
  1341                         AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
  1342                         if test x$have_xrandr_lib = xyes ; then
  1343                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr"
  1344                             definitely_enable_video_x11_xrandr=yes
  1345                         fi
  1346                     fi
  1347                 fi
  1348             fi
  1349             if test x$definitely_enable_video_x11_xrandr = xyes; then
  1350                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR, 1, [ ])
  1351             fi
  1352             AC_ARG_ENABLE(video-x11-scrnsaver,
  1353 AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
  1354                             , enable_video_x11_scrnsaver=yes)
  1355             if test x$enable_video_x11_scrnsaver = xyes; then
  1356                 AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
  1357                                 have_scrnsaver_h_hdr=yes,
  1358                                 have_scrnsaver_h_hdr=no,
  1359                                 [#include <X11/Xlib.h>
  1360                                 ])
  1361                 if test x$have_scrnsaver_h_hdr = xyes; then
  1362                     if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
  1363                         echo "-- dynamic libXss -> $xss_lib"
  1364                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib", [ ])
  1365                         definitely_enable_video_x11_scrnsaver=yes
  1366                     else
  1367                         AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
  1368                         if test x$have_xss_lib = xyes ; then
  1369                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
  1370                             definitely_enable_video_x11_scrnsaver=yes
  1371                         fi
  1372                     fi
  1373                 fi
  1374             fi
  1375             if test x$definitely_enable_video_x11_scrnsaver = xyes; then
  1376                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSCRNSAVER, 1, [ ])
  1377             fi
  1378             AC_ARG_ENABLE(video-x11-xshape,
  1379 AC_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default=yes]]]),
  1380                             , enable_video_x11_xshape=yes)
  1381             if test x$enable_video_x11_xshape = xyes; then
  1382                 AC_CHECK_HEADER(X11/extensions/shape.h,
  1383                                 have_shape_h_hdr=yes,
  1384                                 have_shape_h_hdr=no,
  1385                                 [#include <X11/Xlib.h>
  1386                                 ])
  1387                 if test x$have_shape_h_hdr = xyes; then
  1388                     AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSHAPE, 1, [ ])
  1389                 fi
  1390             fi
  1391             AC_ARG_ENABLE(video-x11-vm,
  1392 AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
  1393                             , enable_video_x11_vm=yes)
  1394             if test x$enable_video_x11_vm = xyes; then
  1395                 definitely_enable_video_x11_vm=no
  1396                 AC_CHECK_HEADER(X11/extensions/xf86vmode.h,
  1397                                 have_vm_h_hdr=yes,
  1398                                 have_vm_h_hdr=no,
  1399                                 [#include <X11/Xlib.h>
  1400                                 ])
  1401                 if test x$have_vm_h_hdr = xyes; then
  1402                     if test x$enable_x11_shared = xyes && test x$xvidmode_lib != x ; then
  1403                         echo "-- dynamic libXxf86vm -> $xvidmode_lib"
  1404                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE, "$xvidmode_lib", [ ])
  1405                         definitely_enable_video_x11_vm=yes
  1406                     else
  1407                         AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion, have_vm_lib=yes)
  1408                         if test x$have_vm_lib = xyes ; then
  1409                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXxf86vm"
  1410                             definitely_enable_video_x11_vm=yes
  1411                         fi
  1412                     fi
  1413                 fi
  1414             fi
  1415             if test x$definitely_enable_video_x11_vm = xyes; then
  1416                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XVIDMODE, 1, [ ])
  1417             fi
  1418         fi
  1419     fi
  1420 }
  1421 
  1422 dnl Set up the BWindow video driver if enabled
  1423 CheckBWINDOW()
  1424 {
  1425     if test x$enable_video = xyes; then
  1426         AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW, 1, [ ])
  1427         SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
  1428         have_video=yes
  1429     fi
  1430 }
  1431 
  1432 dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
  1433 CheckCOCOA()
  1434 {
  1435     AC_ARG_ENABLE(video-cocoa,
  1436 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
  1437                   , enable_video_cocoa=yes)
  1438     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  1439         save_CFLAGS="$CFLAGS"
  1440         dnl work around that we don't have Objective-C support in autoconf
  1441         CFLAGS="$CFLAGS -x objective-c"
  1442         AC_MSG_CHECKING(for Cocoa framework)
  1443         have_cocoa=no
  1444         AC_TRY_COMPILE([
  1445           #import <Cocoa/Cocoa.h>
  1446         ],[
  1447         ],[
  1448         have_cocoa=yes
  1449         ])
  1450         AC_MSG_RESULT($have_cocoa)
  1451         CFLAGS="$save_CFLAGS"
  1452         if test x$have_cocoa = xyes; then
  1453             AC_DEFINE(SDL_VIDEO_DRIVER_COCOA, 1, [ ])
  1454             SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
  1455             have_video=yes
  1456         fi
  1457     fi
  1458 }
  1459 
  1460 dnl Find DirectFB
  1461 CheckDirectFB()
  1462 {
  1463     AC_ARG_ENABLE(video-directfb,
  1464 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
  1465                   , enable_video_directfb=no)
  1466     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  1467         video_directfb=no
  1468 
  1469         DIRECTFB_REQUIRED_VERSION=1.0.0
  1470         AC_PATH_PROGS(DIRECTFBCONFIG, directfb-config, no, [$prefix/bin:$PATH])
  1471         if test x$DIRECTFBCONFIG = xno; then
  1472             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1473             if test x$PKG_CONFIG != xno; then
  1474                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
  1475                     DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
  1476                     DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
  1477                     DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
  1478                     video_directfb=yes
  1479                 fi
  1480             fi
  1481         else
  1482             set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
  1483             NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1484             set -- `$DIRECTFBCONFIG --version | sed 's/\./ /g'`
  1485             HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1486             if test $HAVE_VERSION -ge $NEED_VERSION; then
  1487                 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
  1488                 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
  1489                 DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
  1490                 video_directfb=yes
  1491             fi
  1492         fi
  1493         if test x$video_directfb = xyes; then
  1494             # SuSE 11.1 installs directfb-config without directfb-devel
  1495             save_CPPFLAGS="$CPPFLAGS"
  1496             CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
  1497             AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
  1498             CPPFLAGS="$save_CPPFLAGS"
  1499             video_directfb=$have_directfb_hdr
  1500         fi
  1501         AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  1502         AC_MSG_RESULT($video_directfb)
  1503 
  1504         if test x$video_directfb = xyes; then
  1505             AC_ARG_ENABLE(directfb-shared,
  1506 AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
  1507                               , enable_directfb_shared=yes)
  1508 
  1509             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB, 1, [ ])
  1510             AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB, 1, [ ])
  1511             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  1512             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  1513 
  1514             AC_MSG_CHECKING(for directfb dynamic loading support)
  1515             directfb_shared=no
  1516             directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS"`]
  1517             # | sed 's/.*\/\(.*\)/\1/; q'`]
  1518 AC_MSG_WARN("directfb $directfb_lib")
  1519             if test x$have_loadso != xyes && \
  1520                test x$enable_directfb_shared = xyes; then
  1521                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
  1522             fi
  1523             if test x$have_loadso = xyes && \
  1524                test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
  1525                 directfb_shared=yes
  1526                 echo "-- $directfb_lib_spec -> $directfb_lib"
  1527                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib", [ ])
  1528             else
  1529                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  1530             fi
  1531             AC_MSG_RESULT($directfb_shared)
  1532             have_video=yes
  1533         fi
  1534     fi
  1535 }
  1536 
  1537 dnl Find FusionSound
  1538 CheckFusionSound()
  1539 {
  1540     AC_ARG_ENABLE(fusionsound,
  1541 AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
  1542                   , enable_fusionsound=no)
  1543     if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
  1544         fusionsound=no
  1545 
  1546         FUSIONSOUND_REQUIRED_VERSION=1.1.1
  1547 
  1548         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1549         AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
  1550         if test x$PKG_CONFIG != xno; then
  1551             if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
  1552                 FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
  1553                 FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
  1554                 fusionsound=yes
  1555             fi
  1556         fi
  1557         AC_MSG_RESULT($fusionsound)
  1558 
  1559         if test x$fusionsound = xyes; then
  1560             AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND, 1, [ ])
  1561             SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
  1562             EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
  1563             
  1564             AC_ARG_ENABLE(fusionsound-shared,
  1565 AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
  1566                           , enable_fusionsound_shared=yes)
  1567             fusionsound_shared=no
  1568             AC_MSG_CHECKING(for FusionSound dynamic loading support)
  1569             if test x$have_loadso != xyes && \
  1570                test x$enable_fusionsound_shared = xyes; then
  1571                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
  1572             fi
  1573             if test x$have_loadso = xyes && \
  1574                test x$enable_fusionsound_shared = xyes; then
  1575                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so", [ ])
  1576                 fusionsound_shared=yes
  1577             else
  1578                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
  1579             fi
  1580             AC_MSG_RESULT($fusionsound_shared)
  1581             
  1582             have_audio=yes
  1583         fi
  1584     fi
  1585 }
  1586 
  1587 dnl rcg04172001 Set up the Null video driver.
  1588 CheckDummyVideo()
  1589 {
  1590     AC_ARG_ENABLE(video-dummy,
  1591 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  1592                   , enable_video_dummy=yes)
  1593     if test x$enable_video_dummy = xyes; then
  1594         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY, 1, [ ])
  1595         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1596         have_video=yes
  1597     fi
  1598 }
  1599 
  1600 dnl Check to see if OpenGL support is desired
  1601 AC_ARG_ENABLE(video-opengl,
  1602 AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  1603               , enable_video_opengl=yes)
  1604 
  1605 dnl Find OpenGL
  1606 CheckOpenGLX11()
  1607 {
  1608     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1609         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1610         video_opengl=no
  1611         AC_TRY_COMPILE([
  1612          #include <GL/gl.h>
  1613          #include <GL/glx.h>
  1614         ],[
  1615         ],[
  1616         video_opengl=yes
  1617         ])
  1618         AC_MSG_RESULT($video_opengl)
  1619         if test x$video_opengl = xyes; then
  1620             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1621             AC_DEFINE(SDL_VIDEO_OPENGL_GLX, 1, [ ])
  1622             AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1623         fi
  1624     fi
  1625 }
  1626 
  1627 dnl Check to see if OpenGL ES support is desired
  1628 AC_ARG_ENABLE(video-opengles,
  1629 AC_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]),
  1630               , enable_video_opengles=yes)
  1631 
  1632 dnl Find OpenGL ES
  1633 CheckOpenGLESX11()
  1634 {
  1635     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  1636         AC_MSG_CHECKING(for OpenGL ES (EGL) support)
  1637         video_opengles=no
  1638         AC_TRY_COMPILE([
  1639          #include <EGL/egl.h>
  1640         ],[
  1641         ],[
  1642         video_opengles=yes
  1643         ])
  1644         AC_MSG_RESULT($video_opengles)
  1645         if test x$video_opengles = xyes; then
  1646             AC_MSG_CHECKING(for OpenGL ES v1 headers)
  1647             video_opengles_v1=no
  1648             AC_TRY_COMPILE([
  1649              #include <GLES/gl.h>
  1650              #include <GLES/glext.h>
  1651             ],[
  1652             ],[
  1653             video_opengles_v1=yes
  1654             ])
  1655             AC_MSG_RESULT($video_opengles_v1)
  1656             if test x$video_opengles_v1 = xyes; then
  1657                 AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
  1658                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
  1659             fi
  1660             AC_MSG_CHECKING(for OpenGL ES v2 headers)
  1661             video_opengles_v2=no
  1662             AC_TRY_COMPILE([
  1663              #include <GLES2/gl2.h>
  1664              #include <GLES2/gl2ext.h>
  1665             ],[
  1666             ],[
  1667             video_opengles_v2=yes
  1668             ])
  1669             AC_MSG_RESULT($video_opengles_v2)
  1670             if test x$video_opengles_v2 = xyes; then
  1671                 AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  1672                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  1673             fi
  1674         fi
  1675     fi
  1676 }
  1677 
  1678 dnl Check for Windows OpenGL
  1679 CheckWINDOWSGL()
  1680 {
  1681     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1682         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1683         AC_DEFINE(SDL_VIDEO_OPENGL_WGL, 1, [ ])
  1684         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1685     fi
  1686 }
  1687 
  1688 dnl Check for BeOS OpenGL
  1689 CheckBeGL()
  1690 {
  1691     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1692         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1693         AC_DEFINE(SDL_VIDEO_OPENGL_BGL, 1, [ ])
  1694         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1695         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1696     fi
  1697 }
  1698 
  1699 dnl Check for MacOS OpenGL
  1700 CheckMacGL()
  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_CGL, 1, [ ])
  1705         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1706         case "$host" in
  1707             *-*-darwin*)
  1708                 if test x$enable_video_cocoa = xyes; then
  1709                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
  1710                 fi
  1711         esac
  1712     fi
  1713 }
  1714 
  1715 dnl See if we can use the new unified event interface in Linux 2.4
  1716 CheckInputEvents()
  1717 {
  1718     dnl Check for Linux 2.4 unified input event interface support
  1719         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  1720         use_input_events=no
  1721         AC_TRY_COMPILE([
  1722           #include <linux/input.h>
  1723         ],[
  1724           #ifndef EVIOCGNAME
  1725           #error EVIOCGNAME() ioctl not available
  1726           #endif
  1727         ],[
  1728         use_input_events=yes
  1729         ])
  1730         AC_MSG_RESULT($use_input_events)
  1731         if test x$use_input_events = xyes; then
  1732             AC_DEFINE(SDL_INPUT_LINUXEV, 1, [ ])
  1733         fi
  1734 }
  1735 
  1736 dnl See if the platform offers libudev for device enumeration and hotplugging.
  1737 CheckLibUDev()
  1738 {
  1739     AC_ARG_ENABLE(libudev,
  1740 AC_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
  1741                         , enable_libudev=yes)
  1742     if test x$enable_libudev = xyes; then
  1743         AC_CHECK_HEADER(libudev.h,
  1744                         have_libudev_h_hdr=yes,
  1745                         have_libudev_h_hdr=no)
  1746         if test x$have_libudev_h_hdr = xyes; then
  1747             AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])
  1748         fi
  1749     fi
  1750 }
  1751 
  1752 dnl See if the platform offers libdbus for various IPC techniques.
  1753 CheckDBus()
  1754 {
  1755     AC_ARG_ENABLE(dbus,
  1756 AC_HELP_STRING([--enable-dbus], [enable D-Bus support [[default=yes]]]),
  1757                         , enable_dbus=yes)
  1758     if test x$enable_dbus = xyes; then
  1759         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1760         if test x$PKG_CONFIG != xno; then
  1761             DBUS_CFLAGS=`$PKG_CONFIG --cflags dbus-1`
  1762             save_CFLAGS="$CFLAGS"
  1763             CFLAGS="$save_CFLAGS $DBUS_CFLAGS"
  1764             AC_CHECK_HEADER(dbus/dbus.h,
  1765                             have_dbus_dbus_h_hdr=yes,
  1766                             have_dbus_dbus_h_hdr=no)
  1767             CFLAGS="$save_CFLAGS"
  1768             if test x$have_dbus_dbus_h_hdr = xyes; then
  1769                 AC_DEFINE(HAVE_DBUS_DBUS_H, 1, [ ])
  1770                 EXTRA_CFLAGS="$EXTRA_CFLAGS $DBUS_CFLAGS"
  1771             fi
  1772         fi
  1773     fi
  1774 }
  1775 
  1776 dnl See if we can use the Touchscreen input library
  1777 CheckTslib()
  1778 {
  1779     AC_ARG_ENABLE(input-tslib,
  1780 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  1781                   , enable_input_tslib=yes)
  1782     if test x$enable_input_tslib = xyes; then
  1783         AC_MSG_CHECKING(for Touchscreen library support)
  1784         enable_input_tslib=no
  1785         AC_TRY_COMPILE([
  1786           #include "tslib.h"
  1787         ],[
  1788         ],[
  1789         enable_input_tslib=yes
  1790         ])
  1791         AC_MSG_RESULT($enable_input_tslib)
  1792         if test x$enable_input_tslib = xyes; then
  1793             AC_DEFINE(SDL_INPUT_TSLIB, 1, [ ])
  1794             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  1795         fi
  1796     fi
  1797 }
  1798 
  1799 dnl See what type of thread model to use on Linux and Solaris
  1800 CheckPTHREAD()
  1801 {
  1802     dnl Check for pthread support
  1803     AC_ARG_ENABLE(pthreads,
  1804 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  1805                   , enable_pthreads=yes)
  1806     dnl This is used on Linux for glibc binary compatibility (Doh!)
  1807     AC_ARG_ENABLE(pthread-sem,
  1808 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  1809                   , enable_pthread_sem=yes)
  1810     case "$host" in
  1811         *-*-linux*|*-*-uclinux*)
  1812             pthread_cflags="-D_REENTRANT"
  1813             pthread_lib="-lpthread"
  1814             ;;
  1815         *-*-bsdi*)
  1816             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1817             pthread_lib=""
  1818             ;;
  1819         *-*-darwin*)
  1820             pthread_cflags="-D_THREAD_SAFE"
  1821 # causes Carbon.p complaints?
  1822 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1823             ;;
  1824         *-*-freebsd*|*-*-dragonfly*)
  1825             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1826             pthread_lib="-pthread"
  1827             ;;
  1828         *-*-netbsd*)
  1829             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1830             pthread_lib="-lpthread"
  1831             ;;
  1832         *-*-openbsd*)
  1833             pthread_cflags="-D_REENTRANT"
  1834             pthread_lib="-pthread"
  1835             ;;
  1836         *-*-solaris2.9)
  1837             # From Solaris 9+, posix4's preferred name is rt.
  1838             pthread_cflags="-D_REENTRANT"
  1839             pthread_lib="-lpthread -lrt"
  1840             ;;
  1841         *-*-solaris2.10)
  1842             # Solaris 10+ merged pthread into libc.
  1843             pthread_cflags="-D_REENTRANT"
  1844             pthread_lib="-lrt"
  1845             ;;
  1846         *-*-solaris*)
  1847             # Solaris 11+ merged rt into libc.
  1848             pthread_cflags="-D_REENTRANT"
  1849             pthread_lib=""
  1850             ;;
  1851         *-*-sysv5*)
  1852             pthread_cflags="-D_REENTRANT -Kthread"
  1853             pthread_lib=""
  1854             ;;
  1855         *-*-aix*)
  1856             pthread_cflags="-D_REENTRANT -mthreads"
  1857             pthread_lib="-lpthread"
  1858             ;;
  1859         *-*-hpux11*)
  1860             pthread_cflags="-D_REENTRANT"
  1861             pthread_lib="-L/usr/lib -lpthread"
  1862             ;;
  1863         *)
  1864             pthread_cflags="-D_REENTRANT"
  1865             pthread_lib="-lpthread"
  1866             ;;
  1867     esac
  1868     if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
  1869         # Save the original compiler flags and libraries
  1870         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1871         # Add the pthread compiler flags and libraries
  1872         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1873         # Check to see if we have pthread support on this system
  1874         AC_MSG_CHECKING(for pthreads)
  1875         use_pthreads=no
  1876         AC_TRY_LINK([
  1877          #include <pthread.h>
  1878         ],[
  1879          pthread_attr_t type;
  1880          pthread_attr_init(&type);
  1881         ],[
  1882         use_pthreads=yes
  1883         ])
  1884         AC_MSG_RESULT($use_pthreads)
  1885         # Restore the compiler flags and libraries
  1886         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1887 
  1888         # Do futher testing if we have pthread support...
  1889         if test x$use_pthreads = xyes; then
  1890             AC_DEFINE(SDL_THREAD_PTHREAD, 1, [ ])
  1891             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  1892             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  1893             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  1894             SDL_LIBS="$SDL_LIBS $pthread_lib"
  1895 
  1896             # Save the original compiler flags and libraries
  1897             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1898             # Add the pthread compiler flags and libraries
  1899             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1900 
  1901             # Check to see if recursive mutexes are available
  1902             AC_MSG_CHECKING(for recursive mutexes)
  1903             has_recursive_mutexes=no
  1904             if test x$has_recursive_mutexes = xno; then
  1905                 AC_TRY_COMPILE([
  1906                   #include <pthread.h>
  1907                 ],[
  1908                   pthread_mutexattr_t attr;
  1909                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  1910                 ],[
  1911                 has_recursive_mutexes=yes
  1912                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX, 1, [ ])
  1913                 ])
  1914             fi
  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_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  1921                 ],[
  1922                 has_recursive_mutexes=yes
  1923                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP, 1, [ ])
  1924                 ])
  1925             fi
  1926             AC_MSG_RESULT($has_recursive_mutexes)
  1927 
  1928             # Check to see if pthread semaphore support is missing
  1929             if test x$enable_pthread_sem = xyes; then
  1930                 AC_MSG_CHECKING(for pthread semaphores)
  1931                 have_pthread_sem=no
  1932                 AC_TRY_COMPILE([
  1933                   #include <pthread.h>
  1934                   #include <semaphore.h>
  1935                 ],[
  1936                 ],[
  1937                 have_pthread_sem=yes
  1938                 ])
  1939                 AC_MSG_RESULT($have_pthread_sem)
  1940             fi
  1941             if test x$have_pthread_sem = xyes; then
  1942                 AC_MSG_CHECKING(for sem_timedwait)
  1943                 have_sem_timedwait=no
  1944                 AC_TRY_LINK([
  1945                   #include <pthread.h>
  1946                   #include <semaphore.h>
  1947                 ],[
  1948                   sem_timedwait(NULL, NULL);
  1949                 ],[
  1950                 have_sem_timedwait=yes
  1951                 AC_DEFINE(HAVE_SEM_TIMEDWAIT)
  1952                 ])
  1953                 AC_MSG_RESULT($have_sem_timedwait)
  1954             fi
  1955 
  1956             AC_MSG_CHECKING(for pthread_spin_trylock)
  1957             AC_TRY_LINK_FUNC(pthread_spin_trylock, [
  1958               has_pthread_spin_trylock=yes
  1959               AC_DEFINE(HAVE_PTHREAD_SPINLOCK, 1, [ ])
  1960             ],[
  1961               has_pthread_spin_trylock=no
  1962             ])
  1963             AC_MSG_RESULT($has_pthread_spin_trylock)
  1964 
  1965             AC_CHECK_HEADER(pthread_np.h, have_pthread_np_h=yes, have_pthread_np_h=no, [ #include <pthread.h> ])
  1966             if test x$have_pthread_np_h = xyes; then
  1967                 AC_DEFINE(HAVE_PTHREAD_NP_H, 1, [ ])
  1968             fi
  1969 
  1970             # Check to see if pthread naming is available
  1971             AC_MSG_CHECKING(for pthread_setname_np)
  1972             AC_TRY_LINK_FUNC(pthread_setname_np, [
  1973               has_pthread_setname_np=yes
  1974               AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [ ])
  1975             ],[
  1976               has_pthread_setname_np=no
  1977             ])
  1978             AC_MSG_RESULT($has_pthread_setname_np)
  1979 
  1980             AC_MSG_CHECKING(for pthread_set_name_np)
  1981             AC_TRY_LINK_FUNC(pthread_set_name_np, [
  1982               has_pthread_set_name_np=yes
  1983               AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [ ])
  1984             ],[
  1985               has_pthread_set_name_np=no
  1986             ])
  1987             AC_MSG_RESULT($has_pthread_set_name_np)
  1988 
  1989             # Restore the compiler flags and libraries
  1990             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1991 
  1992             # Basic thread creation functions
  1993             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  1994 
  1995             # Semaphores
  1996             # We can fake these with mutexes and condition variables if necessary
  1997             if test x$have_pthread_sem = xyes; then
  1998                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  1999             else
  2000                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  2001             fi
  2002 
  2003             # Mutexes
  2004             # We can fake these with semaphores if necessary
  2005             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  2006 
  2007             # Condition variables
  2008             # We can fake these with semaphores and mutexes if necessary
  2009             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  2010 
  2011             have_threads=yes
  2012         fi
  2013     fi
  2014 }
  2015 
  2016 dnl Determine whether the compiler can produce Windows executables
  2017 CheckWINDOWS()
  2018 {
  2019     AC_MSG_CHECKING(Windows compiler)
  2020     have_win32_gcc=no
  2021     AC_TRY_COMPILE([
  2022      #include <windows.h>
  2023     ],[
  2024     ],[
  2025     have_win32_gcc=yes
  2026     ])
  2027     AC_MSG_RESULT($have_win32_gcc)
  2028     if test x$have_win32_gcc != xyes; then
  2029        AC_MSG_ERROR([
  2030 *** Your compiler ($CC) does not produce Windows executables!
  2031        ])
  2032     fi
  2033 
  2034     AC_MSG_CHECKING(Windows CE)
  2035     have_wince=no
  2036     AC_TRY_COMPILE([
  2037 #if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
  2038 #error This is not Windows CE
  2039 #endif
  2040     ],[
  2041     ],[
  2042     have_wince=yes
  2043        AC_MSG_ERROR([
  2044 *** Sorry, Windows CE is no longer supported.
  2045        ])
  2046     ])
  2047     AC_MSG_RESULT($have_wince)
  2048 
  2049     # This fixes Windows stack alignment with newer GCC
  2050     CheckStackBoundary
  2051 }
  2052 
  2053 dnl Find the DirectX includes and libraries
  2054 CheckDIRECTX()
  2055 {
  2056     AC_ARG_ENABLE(directx,
  2057 AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
  2058                   , enable_directx=yes)
  2059     if test x$enable_directx = xyes; then
  2060         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  2061         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  2062         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  2063         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  2064         AC_CHECK_HEADER(xaudio2.h, have_xaudio2=yes)
  2065 
  2066         # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
  2067         # FIXME:  ...so force it off for now.
  2068         case "$host" in
  2069             *-*-cygwin*)
  2070             have_dinput=false
  2071             ;;
  2072         esac
  2073     fi
  2074 }
  2075 
  2076 dnl Check for the dlfcn.h interface for dynamically loading objects
  2077 CheckDLOPEN()
  2078 {
  2079     AC_ARG_ENABLE(sdl-dlopen,
  2080 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  2081                   , enable_sdl_dlopen=yes)
  2082     if test x$enable_sdl_dlopen = xyes; then
  2083         AC_MSG_CHECKING(for dlopen)
  2084         have_dlopen=no
  2085         AC_TRY_COMPILE([
  2086          #include <dlfcn.h>
  2087         ],[
  2088          #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
  2089          #error Use dlcompat for Mac OS X 10.2 compatibility
  2090          #endif
  2091         ],[
  2092         have_dlopen=yes
  2093         ])
  2094         AC_MSG_RESULT($have_dlopen)
  2095 
  2096         if test x$have_dlopen = xyes; then
  2097             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  2098                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  2099                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  2100             AC_DEFINE(SDL_LOADSO_DLOPEN, 1, [ ])
  2101             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  2102             have_loadso=yes
  2103         fi
  2104     fi
  2105 }
  2106 
  2107 dnl Check for the usbhid(3) library on *BSD
  2108 CheckUSBHID()
  2109 {
  2110     if test x$enable_joystick = xyes; then
  2111         AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  2112         if test x$have_libusbhid = xyes; then
  2113             AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  2114             AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  2115             USB_LIBS="$USB_LIBS -lusbhid"
  2116         else
  2117             AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  2118             AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  2119             AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  2120         fi
  2121             
  2122         save_CFLAGS="$CFLAGS"
  2123         CFLAGS="$CFLAGS $USB_CFLAGS"
  2124 
  2125         AC_MSG_CHECKING(for usbhid)
  2126         have_usbhid=no
  2127         AC_TRY_COMPILE([
  2128           #include <sys/types.h>
  2129           #if defined(HAVE_USB_H)
  2130           #include <usb.h>
  2131           #endif
  2132           #ifdef __DragonFly__
  2133           # include <bus/usb/usb.h>
  2134           # include <bus/usb/usbhid.h>
  2135           #else
  2136           # include <dev/usb/usb.h>
  2137           # include <dev/usb/usbhid.h>
  2138           #endif
  2139           #if defined(HAVE_USBHID_H)
  2140           #include <usbhid.h>
  2141           #elif defined(HAVE_LIBUSB_H)
  2142           #include <libusb.h>
  2143           #elif defined(HAVE_LIBUSBHID_H)
  2144           #include <libusbhid.h>
  2145           #endif
  2146         ],[
  2147           struct report_desc *repdesc;
  2148           struct usb_ctl_report *repbuf;
  2149           hid_kind_t hidkind;
  2150         ],[
  2151         have_usbhid=yes
  2152         ])
  2153         AC_MSG_RESULT($have_usbhid)
  2154 
  2155         if test x$have_usbhid = xyes; then
  2156             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  2157             have_usbhid_ucr_data=no
  2158             AC_TRY_COMPILE([
  2159               #include <sys/types.h>
  2160               #if defined(HAVE_USB_H)
  2161               #include <usb.h>
  2162               #endif
  2163               #ifdef __DragonFly__
  2164               # include <bus/usb/usb.h>
  2165               # include <bus/usb/usbhid.h>
  2166               #else
  2167               # include <dev/usb/usb.h>
  2168               # include <dev/usb/usbhid.h>
  2169               #endif
  2170               #if defined(HAVE_USBHID_H)
  2171               #include <usbhid.h>
  2172               #elif defined(HAVE_LIBUSB_H)
  2173               #include <libusb.h>
  2174               #elif defined(HAVE_LIBUSBHID_H)
  2175               #include <libusbhid.h>
  2176               #endif
  2177             ],[
  2178               struct usb_ctl_report buf;
  2179               if (buf.ucr_data) { }
  2180             ],[
  2181             have_usbhid_ucr_data=yes
  2182             ])
  2183             if test x$have_usbhid_ucr_data = xyes; then
  2184                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  2185             fi
  2186             AC_MSG_RESULT($have_usbhid_ucr_data)
  2187             
  2188             AC_MSG_CHECKING(for new usbhid API)
  2189             have_usbhid_new=no
  2190             AC_TRY_COMPILE([
  2191               #include <sys/types.h>
  2192               #if defined(HAVE_USB_H)
  2193               #include <usb.h>
  2194               #endif
  2195               #ifdef __DragonFly__
  2196               #include <bus/usb/usb.h>
  2197               #include <bus/usb/usbhid.h>
  2198               #else
  2199               #include <dev/usb/usb.h>
  2200               #include <dev/usb/usbhid.h>
  2201               #endif
  2202               #if defined(HAVE_USBHID_H)
  2203               #include <usbhid.h>
  2204               #elif defined(HAVE_LIBUSB_H)
  2205               #include <libusb.h>
  2206               #elif defined(HAVE_LIBUSBHID_H)
  2207               #include <libusbhid.h>
  2208               #endif
  2209             ],[
  2210               report_desc_t d;
  2211               hid_start_parse(d, 1, 1);
  2212             ],[
  2213             have_usbhid_new=yes
  2214             ])
  2215             if test x$have_usbhid_new = xyes; then
  2216                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  2217             fi
  2218             AC_MSG_RESULT($have_usbhid_new)
  2219 
  2220             AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  2221             have_machine_joystick=no
  2222             AC_TRY_COMPILE([
  2223               #include <machine/joystick.h>
  2224             ],[
  2225               struct joystick t;
  2226             ],[
  2227             have_machine_joystick=yes
  2228             ])
  2229             if test x$have_machine_joystick = xyes; then
  2230                 AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
  2231             fi
  2232             AC_MSG_RESULT($have_machine_joystick)
  2233 
  2234             AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
  2235             SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  2236             EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  2237             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  2238             have_joystick=yes
  2239         fi
  2240         CFLAGS="$save_CFLAGS"
  2241     fi
  2242 }
  2243 
  2244 dnl Check for clock_gettime()
  2245 CheckClockGettime()
  2246 {
  2247     AC_ARG_ENABLE(clock_gettime,
  2248 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=yes]]]),
  2249                   , enable_clock_gettime=yes)
  2250     if test x$enable_clock_gettime = xyes; then
  2251         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  2252         if test x$have_clock_gettime = xyes; then
  2253             AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  2254             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  2255         else
  2256             AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
  2257             if test x$have_clock_gettime = xyes; then
  2258                AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  2259                EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
  2260             fi
  2261         fi
  2262     fi
  2263 }
  2264 
  2265 dnl Check for a valid linux/version.h
  2266 CheckLinuxVersion()
  2267 {
  2268     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  2269     if test x$have_linux_version_h = xyes; then
  2270         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  2271     fi
  2272 }
  2273 
  2274 dnl Check if we want to use RPATH
  2275 CheckRPATH()
  2276 {
  2277     AC_ARG_ENABLE(rpath,
  2278 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  2279                   , enable_rpath=yes)
  2280 }
  2281 
  2282 dnl Set up the configuration based on the host platform!
  2283 case "$host" in
  2284     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*)
  2285         case "$host" in
  2286             *-*-linux*)         ARCH=linux ;;
  2287             *-*-uclinux*)       ARCH=linux ;;
  2288             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  2289             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  2290             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  2291             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  2292             *-*-bsdi*)          ARCH=bsdi ;;
  2293             *-*-freebsd*)       ARCH=freebsd ;;
  2294             *-*-dragonfly*)     ARCH=freebsd ;;
  2295             *-*-netbsd*)        ARCH=netbsd ;;
  2296             *-*-openbsd*)       ARCH=openbsd ;;
  2297             *-*-sysv5*)         ARCH=sysv5 ;;
  2298             *-*-solaris*)       ARCH=solaris ;;
  2299             *-*-hpux*)          ARCH=hpux ;;
  2300             *-*-aix*)           ARCH=aix ;;
  2301             *-*-minix*)         ARCH=minix ;;
  2302         esac
  2303         CheckVisibilityHidden
  2304         CheckDummyVideo
  2305         CheckDiskAudio
  2306         CheckDummyAudio
  2307         CheckDLOPEN
  2308         CheckOSS
  2309         CheckALSA
  2310         CheckPulseAudio
  2311         CheckARTSC
  2312         CheckESD
  2313         CheckNAS
  2314         CheckSNDIO
  2315         CheckX11
  2316         CheckDirectFB
  2317         CheckFusionSound
  2318         CheckOpenGLX11
  2319         CheckOpenGLESX11
  2320         CheckLibUDev
  2321         CheckDBus
  2322         CheckInputEvents
  2323         CheckTslib
  2324         CheckUSBHID
  2325         CheckPTHREAD
  2326         CheckClockGettime
  2327         CheckLinuxVersion
  2328         CheckRPATH
  2329         # Set up files for the audio library
  2330         if test x$enable_audio = xyes; then
  2331           case $ARCH in
  2332             sysv5|solaris|hpux)
  2333                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
  2334                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2335                 have_audio=yes
  2336             ;;
  2337             netbsd|openbsd)
  2338                 AC_DEFINE(SDL_AUDIO_DRIVER_BSD, 1, [ ])
  2339                 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
  2340                 have_audio=yes
  2341             ;;
  2342             aix)
  2343                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO, 1, [ ])
  2344                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  2345                 have_audio=yes
  2346             ;;
  2347           esac
  2348         fi
  2349         # Set up files for the joystick library
  2350         if test x$enable_joystick = xyes; then
  2351           case $ARCH in
  2352             linux)
  2353                 AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ])
  2354                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  2355                 have_joystick=yes
  2356             ;;
  2357           esac
  2358         fi
  2359         # Set up files for the haptic library
  2360         if test x$enable_haptic = xyes; then
  2361            if test x$use_input_events = xyes; then
  2362              case $ARCH in
  2363                linux)
  2364                    AC_DEFINE(SDL_HAPTIC_LINUX, 1, [ ])
  2365                    SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  2366                    have_haptic=yes
  2367                ;;
  2368              esac
  2369            fi
  2370         fi
  2371         # Set up files for the power library
  2372         if test x$enable_power = xyes; then
  2373              case $ARCH in
  2374                linux)
  2375                    AC_DEFINE(SDL_POWER_LINUX, 1, [ ])
  2376                    SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
  2377                    have_power=yes
  2378                ;;
  2379              esac
  2380         fi
  2381         # Set up files for the timer library
  2382         if test x$enable_timers = xyes; then
  2383             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  2384             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2385             have_timers=yes
  2386         fi
  2387         ;;
  2388     *-*-cygwin* | *-*-mingw32*)
  2389         ARCH=win32
  2390         if test "$build" != "$host"; then # cross-compiling
  2391             # Default cross-compile location
  2392             ac_default_prefix=/usr/local/cross-tools/$host
  2393         else
  2394             # Look for the location of the tools and install there
  2395             if test "$BUILD_PREFIX" != ""; then
  2396                 ac_default_prefix=$BUILD_PREFIX
  2397             fi
  2398         fi
  2399         CheckDummyVideo
  2400         CheckDiskAudio
  2401         CheckDummyAudio
  2402         CheckWINDOWS
  2403         CheckWINDOWSGL
  2404         CheckDIRECTX
  2405 
  2406         # Set up the core platform files
  2407         SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
  2408 
  2409         # Set up files for the video library
  2410         if test x$enable_video = xyes; then
  2411             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS, 1, [ ])
  2412             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
  2413             have_video=yes
  2414             AC_ARG_ENABLE(render-d3d,
  2415 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2416                                 , enable_render_d3d=yes)
  2417             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2418                 AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ])
  2419             fi
  2420         fi
  2421         # Set up files for the audio library
  2422         if test x$enable_audio = xyes; then
  2423             AC_DEFINE(SDL_AUDIO_DRIVER_WINMM, 1, [ ])
  2424             SOURCES="$SOURCES $srcdir/src/audio/winmm/*.c"
  2425             if test x$have_dsound = xyes; then
  2426                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
  2427                 SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
  2428             fi
  2429             if test x$have_xaudio2 = xyes; then
  2430                 AC_DEFINE(SDL_AUDIO_DRIVER_XAUDIO2, 1, [ ])
  2431                 SOURCES="$SOURCES $srcdir/src/audio/xaudio2/*.c"
  2432             fi
  2433             have_audio=yes
  2434         fi
  2435         # Set up files for the joystick library
  2436         if test x$enable_joystick = xyes; then
  2437             if test x$have_dinput = xyes; then
  2438                 AC_DEFINE(SDL_JOYSTICK_DINPUT, 1, [ ])
  2439                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_dxjoystick.c"
  2440                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
  2441             else
  2442                 AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
  2443                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_mmjoystick.c"
  2444             fi
  2445             have_joystick=yes
  2446         fi
  2447         if test x$enable_haptic = xyes; then
  2448             if test x$have_dinput = xyes; then
  2449                 AC_DEFINE(SDL_HAPTIC_DINPUT, 1, [ ])
  2450                 SOURCES="$SOURCES $srcdir/src/haptic/windows/SDL_syshaptic.c"
  2451                 have_haptic=yes
  2452             fi
  2453         fi
  2454         if test x$enable_power = xyes; then
  2455             AC_DEFINE(SDL_POWER_WINDOWS, 1, [ ])
  2456             SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
  2457             have_power=yes
  2458         fi
  2459         # Set up files for the thread library
  2460         if test x$enable_threads = xyes; then
  2461             AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ])
  2462             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_sysmutex.c"
  2463             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_syssem.c"
  2464             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_systhread.c"
  2465             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2466             have_threads=yes
  2467         fi
  2468         # Set up files for the timer library
  2469         if test x$enable_timers = xyes; then
  2470             AC_DEFINE(SDL_TIMER_WINDOWS, 1, [ ])
  2471             SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
  2472             have_timers=yes
  2473         fi
  2474         # Set up files for the shared object loading library
  2475         if test x$enable_loadso = xyes; then
  2476             AC_DEFINE(SDL_LOADSO_WINDOWS, 1, [ ])
  2477             SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
  2478             have_loadso=yes
  2479         fi
  2480         # Set up the system libraries we need
  2481         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -XCClinker -static-libgcc"
  2482         # The Windows platform requires special setup
  2483         VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
  2484         SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
  2485         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2486         SDL_LIBS="-lmingw32 -lSDL2main $SDL_LIBS -mwindows"
  2487         ;;
  2488     *-*-beos* | *-*-haiku*)
  2489         ARCH=beos
  2490         ac_default_prefix=/boot/common
  2491         CheckDummyVideo
  2492         CheckDiskAudio
  2493         CheckDummyAudio
  2494         CheckBWINDOW
  2495         CheckBeGL
  2496         # Set up files for the audio library
  2497         if test x$enable_audio = xyes; then
  2498             AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO, 1, [ ])
  2499             SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
  2500             have_audio=yes
  2501         fi
  2502         # Set up files for the joystick library
  2503         if test x$enable_joystick = xyes; then
  2504             AC_DEFINE(SDL_JOYSTICK_BEOS, 1, [ ])
  2505             SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
  2506             have_joystick=yes
  2507         fi
  2508         # Set up files for the thread library
  2509         if test x$enable_threads = xyes; then
  2510             AC_DEFINE(SDL_THREAD_BEOS, 1, [ ])
  2511             SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
  2512             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2513             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2514             have_threads=yes
  2515         fi
  2516         # Set up files for the timer library
  2517         if test x$enable_timers = xyes; then
  2518             AC_DEFINE(SDL_TIMER_BEOS, 1, [ ])
  2519             SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
  2520             have_timers=yes
  2521         fi
  2522         # Set up files for the shared object loading library
  2523         if test x$enable_loadso = xyes; then
  2524             AC_DEFINE(SDL_LOADSO_BEOS, 1, [ ])
  2525             SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
  2526             have_loadso=yes
  2527         fi
  2528         # Set up files for the system power library
  2529         if test x$enable_power = xyes; then
  2530             AC_DEFINE(SDL_POWER_BEOS, 1, [ ])
  2531             SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
  2532             have_power=yes
  2533         fi
  2534         # The BeOS platform requires special setup.
  2535         SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
  2536         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2537         ;;
  2538     arm*-apple-darwin*)
  2539         # iOS - We are not writing anything to confdefs.h because you have to replace
  2540         # SDL_config.h for SDL_config_iphoneos.h anyway
  2541         ARCH=ios
  2542 
  2543         CheckVisibilityHidden
  2544         CheckDummyVideo
  2545         CheckDiskAudio
  2546         CheckDummyAudio
  2547         CheckDLOPEN
  2548         CheckCOCOA
  2549         CheckPTHREAD
  2550 
  2551 
  2552         # Set up files for the audio library
  2553         if test x$enable_audio = xyes; then
  2554             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.c"
  2555             have_audio=yes
  2556         fi
  2557         # Set up files for the joystick library
  2558         if test x$enable_joystick = xyes; then
  2559             SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
  2560             have_joystick=yes
  2561         fi
  2562         # Set up files for the haptic library
  2563         #if test x$enable_haptic = xyes; then
  2564         #    SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2565         #    have_haptic=yes
  2566         #    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2567         #fi
  2568         # Set up files for the power library
  2569         if test x$enable_power = xyes; then
  2570             SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
  2571             have_power=yes
  2572         fi
  2573         # Set up files for the timer library
  2574         if test x$enable_timers = xyes; then
  2575             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2576             have_timers=yes
  2577         fi
  2578         # Set up additional files for the file library
  2579         if test x$enable_file = xyes; then
  2580             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  2581         fi
  2582         # The iOS platform requires special setup.
  2583         SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
  2584         SOURCES="$SOURCES $srcdir/src/video/uikit/*.c"
  2585         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2586         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
  2587         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
  2588         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
  2589         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
  2590         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
  2591         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
  2592         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
  2593         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
  2594         ;;
  2595     *-*-darwin* )
  2596         # This could be either full "Mac OS X", or plain "Darwin" which is
  2597         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2598         # Next line is broken, and a few files below require Mac OS X (full)
  2599         ARCH=macosx
  2600 
  2601         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  2602         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  2603         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  2604 
  2605         CheckVisibilityHidden
  2606         CheckDummyVideo
  2607         CheckDiskAudio
  2608         CheckDummyAudio
  2609         CheckDLOPEN
  2610         CheckCOCOA
  2611         CheckX11
  2612         CheckMacGL
  2613         CheckOpenGLX11
  2614         CheckPTHREAD
  2615 
  2616         # Good optimization on Mac OS X, yes...
  2617         EXTRA_CFLAGS="$EXTRA_CFLAGS -falign-loops=16"
  2618 
  2619         # Need this or things might misbuild on a G3.
  2620         EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
  2621 
  2622         # Set up files for the audio library
  2623         if test x$enable_audio = xyes; then
  2624             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
  2625             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.c"
  2626             have_audio=yes
  2627         fi
  2628         # Set up files for the joystick library
  2629         if test x$enable_joystick = xyes; then
  2630             AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
  2631             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  2632             have_joystick=yes
  2633         fi
  2634         # Set up files for the haptic library
  2635         if test x$enable_haptic = xyes; then
  2636             AC_DEFINE(SDL_HAPTIC_IOKIT, 1, [ ])
  2637             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2638             have_haptic=yes
  2639             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2640         fi
  2641         # Set up files for the power library
  2642         if test x$enable_power = xyes; then
  2643             AC_DEFINE(SDL_POWER_MACOSX, 1, [ ])
  2644             SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
  2645             have_power=yes
  2646         fi
  2647         # Set up files for the timer library
  2648         if test x$enable_timers = xyes; then
  2649             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  2650             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2651             have_timers=yes
  2652         fi
  2653         # Set up additional files for the file library
  2654         if test x$enable_file = xyes; then
  2655             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  2656         fi
  2657         # The Mac OS X platform requires special setup.
  2658         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2659         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
  2660         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  2661         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  2662         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  2663         # If audio is used, add the AudioUnit framework
  2664         if test x$enable_audio = xyes; then
  2665             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
  2666         fi
  2667         ;;
  2668     *)
  2669         AC_MSG_ERROR([
  2670 *** Unsupported host:  Please add to configure.in
  2671         ])
  2672         ;;
  2673 esac
  2674 
  2675 dnl Do this on all platforms, after everything else.
  2676 CheckWarnAll
  2677 
  2678 # Verify that we have all the platform specific files we need
  2679 
  2680 if test x$have_joystick != xyes; then
  2681     if test x$enable_joystick = xyes; then
  2682         AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
  2683     fi
  2684     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2685 fi
  2686 if test x$have_haptic != xyes; then
  2687     if test x$enable_haptic = xyes; then
  2688         AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
  2689     fi
  2690     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2691 fi
  2692 if test x$have_threads != xyes; then
  2693     if test x$enable_threads = xyes; then
  2694         AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
  2695     fi
  2696     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  2697 fi
  2698 if test x$have_timers != xyes; then
  2699     if test x$enable_timers = xyes; then
  2700         AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ])
  2701     fi
  2702     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  2703 fi
  2704 if test x$have_loadso != xyes; then
  2705     if test x$enable_loadso = xyes; then
  2706         AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
  2707     fi
  2708     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  2709 fi
  2710 if test x$SDLMAIN_SOURCES = x; then
  2711     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  2712 fi
  2713 SDLTEST_SOURCES="$srcdir/src/test/*.c"
  2714 
  2715 OBJECTS=`echo $SOURCES`
  2716 DEPENDS=`echo $SOURCES | tr ' ' '\n'`
  2717 for EXT in asm cc m c S; do
  2718     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
  2719     DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
  2720 \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
  2721 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2722 done
  2723 
  2724 VERSION_OBJECTS=`echo $VERSION_SOURCES`
  2725 VERSION_DEPENDS=`echo $VERSION_SOURCES`
  2726 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  2727 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
  2728 \\$(objects)/\\2.o: \\1/\\2.rc\\\\
  2729 	\\$(WINDRES) \\$< \\$@,g"`
  2730 
  2731 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
  2732 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
  2733 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2734 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  2735 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  2736 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2737 
  2738 SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
  2739 SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
  2740 SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2741 SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  2742 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  2743 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2744 
  2745 # Set runtime shared library paths as needed
  2746 
  2747 if test "x$enable_rpath" = "xyes"; then
  2748   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
  2749     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  2750   fi
  2751   if test $ARCH = solaris; then
  2752     SDL_RLD_FLAGS="-R\${libdir}"
  2753   fi
  2754 else
  2755   SDL_RLD_FLAGS=""
  2756 fi
  2757 
  2758 SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  2759 
  2760 dnl Expand the cflags and libraries needed by apps using SDL
  2761 AC_SUBST(SDL_CFLAGS)
  2762 AC_SUBST(SDL_LIBS)
  2763 AC_SUBST(SDL_STATIC_LIBS)
  2764 AC_SUBST(SDL_RLD_FLAGS)
  2765 if test x$enable_shared = xyes; then
  2766     ENABLE_SHARED_TRUE=
  2767     ENABLE_SHARED_FALSE="#"
  2768 else
  2769     ENABLE_SHARED_TRUE="#"
  2770     ENABLE_SHARED_FALSE=
  2771 fi
  2772 if test x$enable_static = xyes; then
  2773     ENABLE_STATIC_TRUE=
  2774     ENABLE_STATIC_FALSE="#"
  2775 else
  2776     ENABLE_STATIC_TRUE="#"
  2777     ENABLE_STATIC_FALSE=
  2778 fi
  2779 AC_SUBST(ENABLE_SHARED_TRUE)
  2780 AC_SUBST(ENABLE_SHARED_FALSE)
  2781 AC_SUBST(ENABLE_STATIC_TRUE)
  2782 AC_SUBST(ENABLE_STATIC_FALSE)
  2783 
  2784 dnl Expand the sources and objects needed to build the library
  2785 AC_SUBST(ac_aux_dir)
  2786 AC_SUBST(INCLUDE)
  2787 AC_SUBST(OBJECTS)
  2788 AC_SUBST(VERSION_OBJECTS)
  2789 AC_SUBST(SDLMAIN_OBJECTS)
  2790 AC_SUBST(SDLTEST_OBJECTS)
  2791 AC_SUBST(BUILD_CFLAGS)
  2792 AC_SUBST(EXTRA_CFLAGS)
  2793 AC_SUBST(BUILD_LDFLAGS)
  2794 AC_SUBST(EXTRA_LDFLAGS)
  2795 AC_SUBST(WINDRES)
  2796 
  2797 cat >Makefile.rules <<__EOF__
  2798 
  2799 # Build rules for objects
  2800 -include \$(OBJECTS:.lo=.d)
  2801 
  2802 # Special dependency for SDL.c, since it depends on SDL_revision.h
  2803 $srcdir/src/SDL.c: update-revision
  2804 $DEPENDS
  2805 $VERSION_DEPENDS
  2806 $SDLMAIN_DEPENDS
  2807 $SDLTEST_DEPENDS
  2808 __EOF__
  2809 
  2810 AC_CONFIG_FILES([
  2811     Makefile:Makefile.in:Makefile.rules sdl2-config SDL2.spec sdl2.pc
  2812 ])
  2813 AC_OUTPUT
  2814 chmod a+x sdl2-config