configure.in
author Sam Lantinga <slouken@libsdl.org>
Sun, 26 May 2013 13:06:54 -0700
changeset 7229 2636ad0a52e4
parent 7222 2435b221d77d
child 7234 fa967628d5e9
permissions -rw-r--r--
Updated VisualC.html for SDL 2.0
     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 Set up the compiler and linker flags
    61 INCLUDE="-I$srcdir/include"
    62 if test x$srcdir != x.; then
    63     INCLUDE="-Iinclude $INCLUDE"
    64 elif test -d .hg; then
    65     AC_MSG_ERROR([
    66 *** When building from Mercurial you should configure and build in a
    67     separate directory so you don't clobber SDL_config.h, SDL_revision.h
    68 ])
    69 fi
    70 case "$host" in
    71     *-*-cygwin*)
    72         # We build SDL on cygwin without the UNIX emulation layer
    73         BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
    74         BASE_LDFLAGS="-mno-cygwin"
    75         ;;
    76     *)
    77         BASE_CFLAGS=""
    78         BASE_LDFLAGS=""
    79         ;;
    80 esac
    81 # Uncomment the following line if you want to force SDL and applications
    82 # built with it to be compiled for a particular architecture.
    83 #AX_GCC_ARCHFLAG([no], [BASE_CFLAGS="$BASE_CFLAGS $ax_cv_gcc_archflag]")
    84 BUILD_CFLAGS="$CFLAGS $CPPFLAGS -DUSING_GENERATED_CONFIG_H"
    85 # The default optimization for SDL is -O3 (Bug #31)
    86 if test "x$orig_CFLAGS" = x; then
    87     BUILD_CFLAGS=`echo $BUILD_CFLAGS | sed 's/-O2/-O3/'`
    88 fi
    89 EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
    90 BUILD_LDFLAGS="$LDFLAGS"
    91 EXTRA_LDFLAGS="$BASE_LDFLAGS"
    92 ## These are common directories to find software packages
    93 #for path in /usr/freeware /usr/pkg /usr/X11R6 /usr/local; do
    94 #    if test -d $path/include; then
    95 #        EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
    96 #    fi
    97 #    if test -d $path/lib; then
    98 #        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
    99 #    fi
   100 #done
   101 SDL_CFLAGS="$BASE_CFLAGS"
   102 SDL_LIBS="-lSDL2 $BASE_LDFLAGS"
   103 CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
   104 CFLAGS="$CFLAGS $EXTRA_CFLAGS"
   105 LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
   106 
   107 dnl set this to use on systems that use lib64 instead of lib
   108 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
   109 
   110 dnl Function to find a library in the compiler search path
   111 find_lib()
   112 {
   113     gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   114     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   115     env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
   116     if test "$cross_compiling" = yes; then
   117         host_lib_path=""
   118     else
   119         host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
   120     fi
   121     for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
   122         lib=[`ls -- $path/$1 2>/dev/null | sort | sed 's/.*\/\(.*\)/\1/; q'`]
   123         if test x$lib != x; then
   124             echo $lib
   125             return
   126         fi
   127     done
   128 }
   129 
   130 dnl Check for compiler characteristics
   131 AC_C_CONST
   132 AC_C_INLINE
   133 AC_C_VOLATILE
   134 
   135 dnl See whether we want assertions for debugging/sanity checking SDL itself.
   136 AC_ARG_ENABLE(assertions,
   137 AC_HELP_STRING([--enable-assertions],
   138                [Enable internal sanity checks (auto/disabled/release/enabled/paranoid) [[default=auto]]]),
   139               , enable_assertions=auto)
   140 case "$enable_assertions" in
   141     auto) # Use optimization settings to determine assertion level
   142         ;;
   143     disabled)
   144         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 0, [ ])
   145         ;;
   146     release)
   147         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 1, [ ])
   148         ;;
   149     enabled)
   150         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 2, [ ])
   151         ;;
   152     paranoid)
   153         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 3, [ ])
   154         ;;
   155     *)
   156         AC_MSG_ERROR([*** unknown assertion level. stop.])
   157         ;;
   158 esac
   159 
   160 dnl See whether we can use gcc style dependency tracking
   161 AC_ARG_ENABLE(dependency-tracking,
   162 AC_HELP_STRING([--enable-dependency-tracking],
   163                [Use gcc -MMD -MT dependency tracking [[default=yes]]]),
   164               , enable_dependency_tracking=yes)
   165 if test x$enable_dependency_tracking = xyes; then
   166     have_gcc_mmd_mt=no
   167     AC_MSG_CHECKING(for GCC -MMD -MT option)
   168     AC_TRY_COMPILE([
   169     #if !defined(__GNUC__) || __GNUC__ < 3
   170     #error Dependency tracking requires GCC 3.0 or newer
   171     #endif
   172     ],[
   173     ],[
   174     have_gcc_mmd_mt=yes
   175     ])
   176     AC_MSG_RESULT($have_gcc_mmd_mt)
   177 
   178     if test x$have_gcc_mmd_mt = xyes; then
   179         DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
   180     fi
   181 fi
   182 
   183 # Actually this doesn't work on OpenBSD and BeOS
   184 #AC_MSG_CHECKING(for linker option --no-undefined)
   185 #have_no_undefined=no
   186 #save_LDFLAGS="$LDFLAGS"
   187 #LDFLAGS="$LDFLAGS -Wl,--no-undefined"
   188 #AC_TRY_LINK([
   189 #],[
   190 #],[
   191 #have_no_undefined=yes
   192 #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--no-undefined"
   193 #])
   194 #LDFLAGS="$save_LDFLAGS"
   195 #AC_MSG_RESULT($have_no_undefined)
   196 
   197 dnl See whether we are allowed to use the system C library
   198 AC_ARG_ENABLE(libc,
   199 AC_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]),
   200               , enable_libc=yes)
   201 if test x$enable_libc = xyes; then
   202     AC_DEFINE(HAVE_LIBC, 1, [ ])
   203 
   204     dnl Check for C library headers
   205     AC_HEADER_STDC
   206     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)
   207 
   208     dnl Check for typedefs, structures, etc.
   209     AC_TYPE_SIZE_T
   210 
   211     dnl Check for defines
   212     AC_CHECK_DEFINE(M_PI, math.h)
   213 
   214     dnl Checks for library functions.
   215     case "$host" in
   216     *-*-cygwin* | *-*-mingw32*)
   217         ;;
   218     *)
   219         AC_FUNC_ALLOCA
   220         ;;
   221     esac
   222 
   223     AC_FUNC_MEMCMP
   224     if test x$ac_cv_func_memcmp_working = xyes; then
   225         AC_DEFINE(HAVE_MEMCMP, 1, [ ])
   226     fi
   227     AC_FUNC_STRTOD
   228     if test x$ac_cv_func_strtod = xyes; then
   229         AC_DEFINE(HAVE_STRTOD, 1, [ ])
   230     fi
   231     AC_CHECK_FUNC(mprotect,
   232         AC_TRY_COMPILE([
   233           #include <sys/types.h>
   234           #include <sys/mman.h>
   235         ],[
   236         ],[
   237         AC_DEFINE(HAVE_MPROTECT, 1, [ ])
   238         ]),
   239     )
   240     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)
   241 
   242     AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
   243     AC_CHECK_FUNCS(atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt)
   244 
   245     AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
   246     AC_CHECK_FUNCS(iconv)
   247 
   248     AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE(HAVE_SA_SIGACTION)], ,[#include <signal.h>])
   249 fi
   250 
   251 AC_CHECK_SIZEOF(void*)
   252 
   253 dnl See whether we can use gcc atomic operations on this architecture
   254 AC_ARG_ENABLE(gcc-atomics,
   255 AC_HELP_STRING([--enable-gcc-atomics],
   256                [Use gcc builtin atomics [[default=yes]]]),
   257               , enable_gcc_atomics=yes)
   258 if test x$enable_gcc_atomics = xyes; then
   259     have_gcc_atomics=no
   260     AC_MSG_CHECKING(for GCC builtin atomic operations)
   261     AC_TRY_LINK([
   262     ],[
   263     int a;
   264     void *x, *y, *z;
   265     __sync_lock_test_and_set(&a, 4);
   266     __sync_lock_test_and_set(&x, y);
   267     __sync_fetch_and_add(&a, 1);
   268     __sync_bool_compare_and_swap(&a, 5, 10);
   269     __sync_bool_compare_and_swap(&x, y, z);
   270     ],[
   271     have_gcc_atomics=yes
   272     ])
   273     AC_MSG_RESULT($have_gcc_atomics)
   274 
   275     if test x$have_gcc_atomics = xyes; then
   276         AC_DEFINE(HAVE_GCC_ATOMICS, 1, [ ])
   277     else
   278         # See if we have the minimum operation needed for GCC atomics
   279         AC_TRY_LINK([
   280         ],[
   281         int a;
   282         __sync_lock_test_and_set(&a, 1);
   283         __sync_lock_release(&a);
   284         ],[
   285         have_gcc_sync_lock_test_and_set=yes
   286         ])
   287         if test x$have_gcc_sync_lock_test_and_set = xyes; then
   288             AC_DEFINE(HAVE_GCC_SYNC_LOCK_TEST_AND_SET, 1, [ ])
   289         fi
   290     fi
   291 fi
   292 
   293 # Standard C sources
   294 SOURCES="$SOURCES $srcdir/src/*.c"
   295 SOURCES="$SOURCES $srcdir/src/atomic/*.c"
   296 SOURCES="$SOURCES $srcdir/src/audio/*.c"
   297 SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
   298 SOURCES="$SOURCES $srcdir/src/events/*.c"
   299 SOURCES="$SOURCES $srcdir/src/file/*.c"
   300 SOURCES="$SOURCES $srcdir/src/libm/*.c"
   301 SOURCES="$SOURCES $srcdir/src/render/*.c"
   302 SOURCES="$SOURCES $srcdir/src/render/*/*.c"
   303 SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
   304 SOURCES="$SOURCES $srcdir/src/thread/*.c"
   305 SOURCES="$SOURCES $srcdir/src/timer/*.c"
   306 SOURCES="$SOURCES $srcdir/src/video/*.c"
   307 
   308 dnl Enable/disable various subsystems of the SDL library
   309 
   310 AC_ARG_ENABLE(atomic,
   311 AC_HELP_STRING([--enable-atomic], [Enable the atomic operations subsystem [[default=yes]]]),
   312               , enable_atomic=yes)
   313 if test x$enable_atomic != xyes; then
   314     AC_DEFINE(SDL_ATOMIC_DISABLED, 1, [ ])
   315 fi
   316 AC_ARG_ENABLE(audio,
   317 AC_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]),
   318               , enable_audio=yes)
   319 if test x$enable_audio != xyes; then
   320     AC_DEFINE(SDL_AUDIO_DISABLED, 1, [ ])
   321 fi
   322 AC_ARG_ENABLE(video,
   323 AC_HELP_STRING([--enable-video], [Enable the video subsystem [[default=yes]]]),
   324               , enable_video=yes)
   325 if test x$enable_video != xyes; then
   326     AC_DEFINE(SDL_VIDEO_DISABLED, 1, [ ])
   327 fi
   328 AC_ARG_ENABLE(render,
   329 AC_HELP_STRING([--enable-render], [Enable the render subsystem [[default=yes]]]),
   330               , enable_render=yes)
   331 if test x$enable_render != xyes; then
   332     AC_DEFINE(SDL_RENDER_DISABLED, 1, [ ])
   333 fi
   334 AC_ARG_ENABLE(events,
   335 AC_HELP_STRING([--enable-events], [Enable the events subsystem [[default=yes]]]),
   336               , enable_events=yes)
   337 if test x$enable_events != xyes; then
   338     AC_DEFINE(SDL_EVENTS_DISABLED, 1, [ ])
   339 fi
   340 AC_ARG_ENABLE(joystick,
   341 AC_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes]]]),
   342               , enable_joystick=yes)
   343 if test x$enable_joystick != xyes; then
   344     AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
   345 else
   346     SOURCES="$SOURCES $srcdir/src/joystick/*.c"
   347 fi
   348 AC_ARG_ENABLE(haptic,
   349 AC_HELP_STRING([--enable-haptic], [Enable the haptic (force feedback) subsystem [[default=yes]]]),
   350               , enable_haptic=yes)
   351 if test x$enable_haptic != xyes; then
   352     AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
   353 else
   354     SOURCES="$SOURCES $srcdir/src/haptic/*.c"
   355 fi
   356 AC_ARG_ENABLE(power,
   357 AC_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]),
   358               , enable_power=yes)
   359 if test x$enable_power != xyes; then
   360     AC_DEFINE(SDL_POWER_DISABLED, 1, [ ])
   361 else
   362     SOURCES="$SOURCES $srcdir/src/power/*.c"
   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 rcg07142001 See if the user wants the disk writer audio driver...
   917 CheckDiskAudio()
   918 {
   919     AC_ARG_ENABLE(diskaudio,
   920 AC_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [[default=yes]]]),
   921                   , enable_diskaudio=yes)
   922     if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
   923         AC_DEFINE(SDL_AUDIO_DRIVER_DISK, 1, [ ])
   924         SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
   925     fi
   926 }
   927 
   928 dnl rcg03142006 See if the user wants the dummy audio driver...
   929 CheckDummyAudio()
   930 {
   931     AC_ARG_ENABLE(dummyaudio,
   932 AC_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=yes]]]),
   933                   , enable_dummyaudio=yes)
   934     if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then
   935         AC_DEFINE(SDL_AUDIO_DRIVER_DUMMY, 1, [ ])
   936         SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c"
   937     fi
   938 }
   939 
   940 dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
   941 dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
   942 CheckVisibilityHidden()
   943 {
   944     AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
   945     have_gcc_fvisibility=no
   946 
   947     visibility_CFLAGS="-fvisibility=hidden"
   948     save_CFLAGS="$CFLAGS"
   949     CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
   950     AC_TRY_COMPILE([
   951     #if !defined(__GNUC__) || __GNUC__ < 4
   952     #error SDL only uses visibility attributes in GCC 4 or newer
   953     #endif
   954     ],[
   955     ],[
   956     have_gcc_fvisibility=yes
   957     ])
   958     AC_MSG_RESULT($have_gcc_fvisibility)
   959     CFLAGS="$save_CFLAGS"
   960 
   961     if test x$have_gcc_fvisibility = xyes; then
   962         EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
   963     fi
   964 }
   965 
   966 dnl See if GCC's -mpreferred-stack-boundary is supported.
   967 dnl  Reference: http://bugzilla.libsdl.org/show_bug.cgi?id=1296
   968 CheckStackBoundary()
   969 {
   970     AC_MSG_CHECKING(for GCC -mpreferred-stack-boundary option)
   971     have_gcc_preferred_stack_boundary=no
   972 
   973     save_CFLAGS="$CFLAGS"
   974     CFLAGS="$save_CFLAGS -mpreferred-stack-boundary=2"
   975     AC_TRY_COMPILE([
   976     int x = 0;
   977     ],[
   978     ],[
   979     have_gcc_preferred_stack_boundary=yes
   980     ])
   981     AC_MSG_RESULT($have_gcc_preferred_stack_boundary)
   982     CFLAGS="$save_CFLAGS"
   983 
   984     if test x$have_gcc_preferred_stack_boundary = xyes; then
   985         EXTRA_CFLAGS="$EXTRA_CFLAGS -mpreferred-stack-boundary=2"
   986     fi
   987 }
   988 
   989 
   990 dnl See if GCC's -Wall is supported.
   991 CheckWarnAll()
   992 {
   993     AC_MSG_CHECKING(for GCC -Wall option)
   994     have_gcc_Wall=no
   995 
   996     save_CFLAGS="$CFLAGS"
   997     CFLAGS="$save_CFLAGS -Wall"
   998     AC_TRY_COMPILE([
   999     int x = 0;
  1000     ],[
  1001     ],[
  1002     have_gcc_Wall=yes
  1003     ])
  1004     AC_MSG_RESULT($have_gcc_Wall)
  1005     CFLAGS="$save_CFLAGS"
  1006 
  1007     if test x$have_gcc_Wall = xyes; then
  1008         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
  1009 
  1010         dnl Haiku headers use multicharacter constants all over the place. Ignore these warnings when using -Wall.
  1011         AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
  1012         need_gcc_Wno_multichar=no
  1013         case "$host" in
  1014             *-*-beos* | *-*-haiku*)
  1015                 need_gcc_Wno_multichar=yes
  1016                 ;;
  1017         esac
  1018         AC_MSG_RESULT($need_gcc_Wno_multichar)
  1019         if test x$need_gcc_Wno_multichar = xyes; then
  1020             EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar"
  1021         fi
  1022     fi
  1023 }
  1024 
  1025 
  1026 dnl Find the X11 include and library directories
  1027 CheckX11()
  1028 {
  1029 
  1030 
  1031     AC_ARG_ENABLE(video-x11,
  1032 AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
  1033                   , enable_video_x11=yes)
  1034     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
  1035         case "$host" in
  1036             *-*-darwin*)
  1037                 # This isn't necessary for X11, but fixes GLX detection
  1038                 if test "x$x_includes" = xNONE && \
  1039                    test "x$x_libraries" = xNONE && \
  1040                    test -d /usr/X11R6/include && \
  1041                    test -d /usr/X11R6/lib; then
  1042                     x_includes="/usr/X11R6/include"
  1043                     x_libraries="/usr/X11R6/lib"
  1044                 fi
  1045                 ;;
  1046         esac
  1047         AC_PATH_X
  1048         AC_PATH_XTRA
  1049         if test x$have_x = xyes; then
  1050             # Only allow dynamically loaded X11 if the X11 function pointers
  1051             # will not end up in the global namespace, which causes problems
  1052             # with other libraries calling X11 functions.
  1053             x11_symbols_private=$have_gcc_fvisibility
  1054 
  1055             AC_ARG_ENABLE(x11-shared,
  1056 AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
  1057                           , enable_x11_shared=maybe)
  1058 
  1059             case "$host" in
  1060                 *-*-darwin*)
  1061                     x11_symbols_private=yes
  1062                     x11_lib='/usr/X11R6/lib/libX11.6.dylib'
  1063                     x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
  1064                     xcursor_lib='/usr/X11R6/lib/libXcursor.1.dylib'
  1065                     xinerama_lib='/usr/X11R6/lib/libXinerama.1.dylib'
  1066                     xinput_lib='/usr/X11R6/lib/libXi.6.dylib'
  1067                     xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
  1068                     xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
  1069                     xss_lib='/usr/X11R6/lib/libXss.1.dylib'
  1070                     xvidmode_lib='/usr/X11R6/lib/libXxf86vm.1.dylib'
  1071                     ;;
  1072                 *-*-openbsd*)
  1073                     x11_lib='libX11.so'
  1074                     x11ext_lib='libXext.so'
  1075                     xcursor_lib='libXcursor.so'
  1076                     xinerama_lib='libXinerama.so'
  1077                     xinput_lib='libXi.so'
  1078                     xrandr_lib='libXrandr.so'
  1079                     xrender_lib='libXrender.so'
  1080                     xss_lib='libXss.so'
  1081                     xvidmode_lib='libXxf86vm.so'
  1082                     ;;
  1083                 *)
  1084                     x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1085                     x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1086                     xcursor_lib=[`find_lib "libXcursor.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1087                     xinerama_lib=[`find_lib "libXinerama.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1088                     xinput_lib=[`find_lib "libXi.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1089                     xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1090                     xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1091                     xss_lib=[`find_lib "libXss.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1092                     xvidmode_lib=[`find_lib "libXxf86vm.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1093                     ;;
  1094             esac
  1095 
  1096             if test x$ac_cv_func_shmat != xyes; then
  1097                 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
  1098             fi
  1099             CFLAGS="$CFLAGS $X_CFLAGS"
  1100             LDFLAGS="$LDFLAGS $X_LIBS"
  1101 
  1102             AC_DEFINE(SDL_VIDEO_DRIVER_X11, 1, [ ])
  1103             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
  1104             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
  1105 
  1106             if test x$enable_x11_shared = xmaybe; then
  1107                 enable_x11_shared=$x11_symbols_private
  1108             fi
  1109             if test x$have_loadso != xyes && \
  1110                test x$enable_x11_shared = xyes; then
  1111                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
  1112                 enable_x11_shared=no
  1113             fi
  1114             if test x$x11_symbols_private != xyes && \
  1115                test x$enable_x11_shared = xyes; then
  1116                 AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
  1117                 enable_x11_shared=no
  1118             fi
  1119 
  1120             if test x$have_loadso = xyes && \
  1121                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
  1122                 echo "-- dynamic libX11 -> $x11_lib"
  1123                 echo "-- dynamic libX11ext -> $x11ext_lib"
  1124                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib", [ ])
  1125                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib", [ ])
  1126             else
  1127                 enable_x11_shared=no
  1128                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
  1129             fi
  1130             have_video=yes
  1131 
  1132             AC_MSG_CHECKING(for const parameter to XextAddDisplay)
  1133             have_const_param_XextAddDisplay=no
  1134             AC_TRY_COMPILE([
  1135               #include <X11/Xlib.h>
  1136               #include <X11/Xproto.h>
  1137               #include <X11/extensions/Xext.h>
  1138               #include <X11/extensions/extutil.h>
  1139               extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
  1140             ],[
  1141             ],[
  1142             have_const_param_XextAddDisplay=yes
  1143             AC_DEFINE(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY)
  1144             ])
  1145             AC_MSG_RESULT($have_const_param_XextAddDisplay)
  1146 
  1147             dnl AC_CHECK_LIB(X11, XGetEventData, AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS, 1, [Have XGenericEvent]))
  1148             AC_MSG_CHECKING([for XGenericEvent])
  1149             have_XGenericEvent=no
  1150             AC_TRY_COMPILE([
  1151               	#include <X11/Xlib.h>
  1152             ],[
  1153 Display *display;
  1154 XEvent event;
  1155 XGenericEventCookie *cookie = &event.xcookie;
  1156 XNextEvent(display, &event);
  1157 XGetEventData(display, cookie);
  1158 XFreeEventData(display, cookie);
  1159             ],[
  1160                 have_XGenericEvent=yes
  1161                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS)
  1162             ])
  1163             AC_MSG_RESULT($have_XGenericEvent)
  1164 
  1165             AC_CHECK_LIB(X11, XkbKeycodeToKeysym, AC_DEFINE(SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM, 1, [Have XkbKeycodeToKeysym]))
  1166 
  1167             AC_ARG_ENABLE(video-x11-xcursor,
  1168 AC_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[default=yes]]]),
  1169                             , enable_video_x11_xcursor=yes)
  1170             if test x$enable_video_x11_xcursor = xyes; then
  1171                 definitely_enable_video_x11_xcursor=no
  1172                 AC_CHECK_HEADER(X11/Xcursor/Xcursor.h,
  1173                                 have_xcursor_h_hdr=yes,
  1174                                 have_xcursor_h_hdr=no,
  1175                                 [#include <X11/Xlib.h>
  1176                                 ])
  1177                 if test x$have_xcursor_h_hdr = xyes; then
  1178                     if test x$enable_x11_shared = xyes && test x$xcursor_lib != x ; then
  1179                         echo "-- dynamic libXcursor -> $xcursor_lib"
  1180                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR, "$xcursor_lib", [ ])
  1181                         definitely_enable_video_x11_xcursor=yes
  1182                     else
  1183                         AC_CHECK_LIB(Xcursor, XcursorImageCreate, have_xcursor_lib=yes)
  1184                         if test x$have_xcursor_lib = xyes ; then
  1185                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXcursor"
  1186                             definitely_enable_video_x11_xcursor=yes
  1187                         fi
  1188                     fi
  1189                 fi
  1190             fi
  1191             if test x$definitely_enable_video_x11_xcursor = xyes; then
  1192                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XCURSOR, 1, [ ])
  1193             fi
  1194             AC_ARG_ENABLE(video-x11-xinerama,
  1195 AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
  1196                             , enable_video_x11_xinerama=yes)
  1197             if test x$enable_video_x11_xinerama = xyes; then
  1198                 definitely_enable_video_x11_xinerama=no
  1199                 AC_CHECK_HEADER(X11/extensions/Xinerama.h,
  1200                                 have_xinerama_h_hdr=yes,
  1201                                 have_xinerama_h_hdr=no,
  1202                                 [#include <X11/Xlib.h>
  1203                                 ])
  1204                 if test x$have_xinerama_h_hdr = xyes; then
  1205                     if test x$enable_x11_shared = xyes && test x$xinerama_lib != x ; then
  1206                         echo "-- dynamic libXinerama -> $xinerama_lib"
  1207                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA, "$xinerama_lib", [ ])
  1208                         definitely_enable_video_x11_xinerama=yes
  1209                     else
  1210                         AC_CHECK_LIB(Xinerama, XineramaQueryExtension, have_xinerama_lib=yes)
  1211                         if test x$have_xinerama_lib = xyes ; then
  1212                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXinerama"
  1213                             definitely_enable_video_x11_xinerama=yes
  1214                         fi
  1215                     fi
  1216                 fi
  1217             fi
  1218             if test x$definitely_enable_video_x11_xinerama = xyes; then
  1219                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA, 1, [ ])
  1220             fi
  1221             AC_ARG_ENABLE(video-x11-xinput,
  1222 AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
  1223                             , enable_video_x11_xinput=yes)
  1224             if test x$enable_video_x11_xinput = xyes; then
  1225                 definitely_enable_video_x11_xinput=no
  1226                 AC_CHECK_HEADER(X11/extensions/XInput2.h,
  1227                                 have_xinput_h_hdr=yes,
  1228                                 have_xinput_h_hdr=no,
  1229                                 [#include <X11/Xlib.h>
  1230                                 ])
  1231                 if test x$have_xinput_h_hdr = xyes; then
  1232                     if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
  1233                         echo "-- dynamic libXi -> $xinput_lib"
  1234                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2, "$xinput_lib", [ ])
  1235                         definitely_enable_video_x11_xinput=yes
  1236                     else
  1237                         AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
  1238                         if test x$have_xinput_lib = xyes ; then
  1239                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
  1240                             definitely_enable_video_x11_xinput=yes
  1241                         fi
  1242                     fi
  1243                 fi
  1244             fi
  1245             if test x$definitely_enable_video_x11_xinput = xyes; then
  1246                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ])
  1247                 AC_MSG_CHECKING(for xinput2 multitouch)
  1248             	have_xinput2_multitouch=no
  1249             	AC_TRY_COMPILE([
  1250               		#include <X11/Xlib.h>
  1251              		#include <X11/Xproto.h>
  1252 			#include <X11/extensions/XInput2.h>
  1253             	],[
  1254 int event_type = XI_TouchBegin;
  1255 XITouchClassInfo *t;
  1256 Status 
  1257 XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f)
  1258 {
  1259     return (Status)0;
  1260 }
  1261             	],[
  1262             	have_xinput2_multitouch=yes
  1263             	AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH)
  1264             	])
  1265             	AC_MSG_RESULT($have_xinput2_multitouch)
  1266             fi
  1267             AC_ARG_ENABLE(video-x11-xrandr,
  1268 AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
  1269                             , enable_video_x11_xrandr=yes)
  1270             if test x$enable_video_x11_xrandr = xyes; then
  1271                 definitely_enable_video_x11_xrandr=no
  1272                 AC_CHECK_HEADER(X11/extensions/Xrandr.h,
  1273                                 have_xrandr_h_hdr=yes,
  1274                                 have_xrandr_h_hdr=no,
  1275                                 [#include <X11/Xlib.h>
  1276                                 ])
  1277                 if test x$have_xrandr_h_hdr = xyes; then
  1278                     if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
  1279                         echo "-- dynamic libXrandr -> $xrandr_lib"
  1280                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib", [ ])
  1281                         definitely_enable_video_x11_xrandr=yes
  1282                     else
  1283                         AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
  1284                         if test x$have_xrandr_lib = xyes ; then
  1285                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr"
  1286                             definitely_enable_video_x11_xrandr=yes
  1287                         fi
  1288                     fi
  1289                 fi
  1290             fi
  1291             if test x$definitely_enable_video_x11_xrandr = xyes; then
  1292                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR, 1, [ ])
  1293             fi
  1294             AC_ARG_ENABLE(video-x11-scrnsaver,
  1295 AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
  1296                             , enable_video_x11_scrnsaver=yes)
  1297             if test x$enable_video_x11_scrnsaver = xyes; then
  1298                 AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
  1299                                 have_scrnsaver_h_hdr=yes,
  1300                                 have_scrnsaver_h_hdr=no,
  1301                                 [#include <X11/Xlib.h>
  1302                                 ])
  1303                 if test x$have_scrnsaver_h_hdr = xyes; then
  1304                     if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
  1305                         echo "-- dynamic libXss -> $xss_lib"
  1306                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib", [ ])
  1307                         definitely_enable_video_x11_scrnsaver=yes
  1308                     else
  1309                         AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
  1310                         if test x$have_xss_lib = xyes ; then
  1311                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
  1312                             definitely_enable_video_x11_scrnsaver=yes
  1313                         fi
  1314                     fi
  1315                 fi
  1316             fi
  1317             if test x$definitely_enable_video_x11_scrnsaver = xyes; then
  1318                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSCRNSAVER, 1, [ ])
  1319             fi
  1320             AC_ARG_ENABLE(video-x11-xshape,
  1321 AC_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default=yes]]]),
  1322                             , enable_video_x11_xshape=yes)
  1323             if test x$enable_video_x11_xshape = xyes; then
  1324                 AC_CHECK_HEADER(X11/extensions/shape.h,
  1325                                 have_shape_h_hdr=yes,
  1326                                 have_shape_h_hdr=no,
  1327                                 [#include <X11/Xlib.h>
  1328                                 ])
  1329                 if test x$have_shape_h_hdr = xyes; then
  1330                     AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSHAPE, 1, [ ])
  1331                 fi
  1332             fi
  1333             AC_ARG_ENABLE(video-x11-vm,
  1334 AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
  1335                             , enable_video_x11_vm=yes)
  1336             if test x$enable_video_x11_vm = xyes; then
  1337                 definitely_enable_video_x11_vm=no
  1338                 AC_CHECK_HEADER(X11/extensions/xf86vmode.h,
  1339                                 have_vm_h_hdr=yes,
  1340                                 have_vm_h_hdr=no,
  1341                                 [#include <X11/Xlib.h>
  1342                                 ])
  1343                 if test x$have_vm_h_hdr = xyes; then
  1344                     if test x$enable_x11_shared = xyes && test x$xvidmode_lib != x ; then
  1345                         echo "-- dynamic libXxf86vm -> $xvidmode_lib"
  1346                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE, "$xvidmode_lib", [ ])
  1347                         definitely_enable_video_x11_vm=yes
  1348                     else
  1349                         AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion, have_vm_lib=yes)
  1350                         if test x$have_vm_lib = xyes ; then
  1351                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXxf86vm"
  1352                             definitely_enable_video_x11_vm=yes
  1353                         fi
  1354                     fi
  1355                 fi
  1356             fi
  1357             if test x$definitely_enable_video_x11_vm = xyes; then
  1358                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XVIDMODE, 1, [ ])
  1359             fi
  1360         fi
  1361     fi
  1362 }
  1363 
  1364 dnl Set up the BWindow video driver if enabled
  1365 CheckBWINDOW()
  1366 {
  1367     if test x$enable_video = xyes; then
  1368         AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW, 1, [ ])
  1369         SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
  1370         have_video=yes
  1371     fi
  1372 }
  1373 
  1374 dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
  1375 CheckCOCOA()
  1376 {
  1377     AC_ARG_ENABLE(video-cocoa,
  1378 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
  1379                   , enable_video_cocoa=yes)
  1380     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  1381         save_CFLAGS="$CFLAGS"
  1382         dnl work around that we don't have Objective-C support in autoconf
  1383         CFLAGS="$CFLAGS -x objective-c"
  1384         AC_MSG_CHECKING(for Cocoa framework)
  1385         have_cocoa=no
  1386         AC_TRY_COMPILE([
  1387           #import <Cocoa/Cocoa.h>
  1388         ],[
  1389         ],[
  1390         have_cocoa=yes
  1391         ])
  1392         AC_MSG_RESULT($have_cocoa)
  1393         CFLAGS="$save_CFLAGS"
  1394         if test x$have_cocoa = xyes; then
  1395             AC_DEFINE(SDL_VIDEO_DRIVER_COCOA, 1, [ ])
  1396             SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
  1397             have_video=yes
  1398         fi
  1399     fi
  1400 }
  1401 
  1402 dnl Find DirectFB
  1403 CheckDirectFB()
  1404 {
  1405     AC_ARG_ENABLE(video-directfb,
  1406 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
  1407                   , enable_video_directfb=no)
  1408     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  1409         video_directfb=no
  1410 
  1411         DIRECTFB_REQUIRED_VERSION=1.0.0
  1412         AC_PATH_PROGS(DIRECTFBCONFIG, directfb-config, no, [$prefix/bin:$PATH])
  1413         if test x$DIRECTFBCONFIG = xno; then
  1414             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1415             if test x$PKG_CONFIG != xno; then
  1416                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
  1417                     DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
  1418                     DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
  1419                     DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
  1420                     video_directfb=yes
  1421                 fi
  1422             fi
  1423         else
  1424             set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
  1425             NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1426             set -- `$DIRECTFBCONFIG --version | sed 's/\./ /g'`
  1427             HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1428             if test $HAVE_VERSION -ge $NEED_VERSION; then
  1429                 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
  1430                 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
  1431                 DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
  1432                 video_directfb=yes
  1433             fi
  1434         fi
  1435         if test x$video_directfb = xyes; then
  1436             # SuSE 11.1 installs directfb-config without directfb-devel
  1437             save_CPPFLAGS="$CPPFLAGS"
  1438             CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
  1439             AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
  1440             CPPFLAGS="$save_CPPFLAGS"
  1441             video_directfb=$have_directfb_hdr
  1442         fi
  1443         AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  1444         AC_MSG_RESULT($video_directfb)
  1445 
  1446         if test x$video_directfb = xyes; then
  1447             AC_ARG_ENABLE(directfb-shared,
  1448 AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
  1449                               , enable_directfb_shared=yes)
  1450 
  1451             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB, 1, [ ])
  1452             AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB, 1, [ ])
  1453             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  1454             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  1455 
  1456             AC_MSG_CHECKING(for directfb dynamic loading support)
  1457             directfb_shared=no
  1458             directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS"`]
  1459             # | sed 's/.*\/\(.*\)/\1/; q'`]
  1460 AC_MSG_WARN("directfb $directfb_lib")
  1461             if test x$have_loadso != xyes && \
  1462                test x$enable_directfb_shared = xyes; then
  1463                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
  1464             fi
  1465             if test x$have_loadso = xyes && \
  1466                test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
  1467                 directfb_shared=yes
  1468                 echo "-- $directfb_lib_spec -> $directfb_lib"
  1469                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib", [ ])
  1470             else
  1471                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  1472             fi
  1473             AC_MSG_RESULT($directfb_shared)
  1474             have_video=yes
  1475         fi
  1476     fi
  1477 }
  1478 
  1479 dnl Find FusionSound
  1480 CheckFusionSound()
  1481 {
  1482     AC_ARG_ENABLE(fusionsound,
  1483 AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
  1484                   , enable_fusionsound=no)
  1485     if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
  1486         fusionsound=no
  1487 
  1488         FUSIONSOUND_REQUIRED_VERSION=1.1.1
  1489 
  1490         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1491         AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
  1492         if test x$PKG_CONFIG != xno; then
  1493             if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
  1494                 FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
  1495                 FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
  1496                 fusionsound=yes
  1497             fi
  1498         fi
  1499         AC_MSG_RESULT($fusionsound)
  1500 
  1501         if test x$fusionsound = xyes; then
  1502             AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND, 1, [ ])
  1503             SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
  1504             EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
  1505             
  1506             AC_ARG_ENABLE(fusionsound-shared,
  1507 AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
  1508                           , enable_fusionsound_shared=yes)
  1509             fusionsound_shared=no
  1510             AC_MSG_CHECKING(for FusionSound dynamic loading support)
  1511             if test x$have_loadso != xyes && \
  1512                test x$enable_fusionsound_shared = xyes; then
  1513                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
  1514             fi
  1515             if test x$have_loadso = xyes && \
  1516                test x$enable_fusionsound_shared = xyes; then
  1517                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so", [ ])
  1518                 fusionsound_shared=yes
  1519             else
  1520                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
  1521             fi
  1522             AC_MSG_RESULT($fusionsound_shared)
  1523             
  1524             have_audio=yes
  1525         fi
  1526     fi
  1527 }
  1528 
  1529 dnl rcg04172001 Set up the Null video driver.
  1530 CheckDummyVideo()
  1531 {
  1532     AC_ARG_ENABLE(video-dummy,
  1533 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  1534                   , enable_video_dummy=yes)
  1535     if test x$enable_video_dummy = xyes; then
  1536         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY, 1, [ ])
  1537         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1538         have_video=yes
  1539     fi
  1540 }
  1541 
  1542 dnl Check to see if OpenGL support is desired
  1543 AC_ARG_ENABLE(video-opengl,
  1544 AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  1545               , enable_video_opengl=yes)
  1546 
  1547 dnl Find OpenGL
  1548 CheckOpenGLX11()
  1549 {
  1550     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1551         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1552         video_opengl=no
  1553         AC_TRY_COMPILE([
  1554          #include <GL/gl.h>
  1555          #include <GL/glx.h>
  1556         ],[
  1557         ],[
  1558         video_opengl=yes
  1559         ])
  1560         AC_MSG_RESULT($video_opengl)
  1561         if test x$video_opengl = xyes; then
  1562             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1563             AC_DEFINE(SDL_VIDEO_OPENGL_GLX, 1, [ ])
  1564             AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1565         fi
  1566     fi
  1567 }
  1568 
  1569 dnl Check to see if OpenGL ES support is desired
  1570 AC_ARG_ENABLE(video-opengles,
  1571 AC_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]),
  1572               , enable_video_opengles=yes)
  1573 
  1574 dnl Find OpenGL ES
  1575 CheckOpenGLESX11()
  1576 {
  1577     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  1578         AC_MSG_CHECKING(for OpenGL ES (EGL) support)
  1579         video_opengles=no
  1580         AC_TRY_COMPILE([
  1581          #include <EGL/egl.h>
  1582         ],[
  1583         ],[
  1584         video_opengles=yes
  1585         ])
  1586         AC_MSG_RESULT($video_opengles)
  1587         if test x$video_opengles = xyes; then
  1588             AC_MSG_CHECKING(for OpenGL ES v1 headers)
  1589             video_opengles_v1=no
  1590             AC_TRY_COMPILE([
  1591              #include <GLES/gl.h>
  1592              #include <GLES/glext.h>
  1593             ],[
  1594             ],[
  1595             video_opengles_v1=yes
  1596             ])
  1597             AC_MSG_RESULT($video_opengles_v1)
  1598             if test x$video_opengles_v1 = xyes; then
  1599                 AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
  1600                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
  1601             fi
  1602             AC_MSG_CHECKING(for OpenGL ES v2 headers)
  1603             video_opengles_v2=no
  1604             AC_TRY_COMPILE([
  1605              #include <GLES2/gl2.h>
  1606              #include <GLES2/gl2ext.h>
  1607             ],[
  1608             ],[
  1609             video_opengles_v2=yes
  1610             ])
  1611             AC_MSG_RESULT($video_opengles_v2)
  1612             if test x$video_opengles_v2 = xyes; then
  1613                 AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  1614                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  1615             fi
  1616         fi
  1617     fi
  1618 }
  1619 
  1620 dnl Check for Windows OpenGL
  1621 CheckWINDOWSGL()
  1622 {
  1623     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1624         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1625         AC_DEFINE(SDL_VIDEO_OPENGL_WGL, 1, [ ])
  1626         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1627     fi
  1628 }
  1629 
  1630 dnl Check for BeOS OpenGL
  1631 CheckBeGL()
  1632 {
  1633     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1634         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1635         AC_DEFINE(SDL_VIDEO_OPENGL_BGL, 1, [ ])
  1636         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1637         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1638     fi
  1639 }
  1640 
  1641 dnl Check for MacOS OpenGL
  1642 CheckMacGL()
  1643 {
  1644     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1645         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1646         AC_DEFINE(SDL_VIDEO_OPENGL_CGL, 1, [ ])
  1647         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1648         case "$host" in
  1649             *-*-darwin*)
  1650                 if test x$enable_video_cocoa = xyes; then
  1651                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
  1652                 fi
  1653         esac
  1654     fi
  1655 }
  1656 
  1657 dnl See if we can use the new unified event interface in Linux 2.4
  1658 CheckInputEvents()
  1659 {
  1660     dnl Check for Linux 2.4 unified input event interface support
  1661         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  1662         use_input_events=no
  1663         AC_TRY_COMPILE([
  1664           #include <linux/input.h>
  1665         ],[
  1666           #ifndef EVIOCGNAME
  1667           #error EVIOCGNAME() ioctl not available
  1668           #endif
  1669         ],[
  1670         use_input_events=yes
  1671         ])
  1672         AC_MSG_RESULT($use_input_events)
  1673         if test x$use_input_events = xyes; then
  1674             AC_DEFINE(SDL_INPUT_LINUXEV, 1, [ ])
  1675         fi
  1676 }
  1677 
  1678 dnl See if the platform offers libudev for device enumeration and hotplugging.
  1679 CheckLibUDev()
  1680 {
  1681     AC_ARG_ENABLE(libudev,
  1682 AC_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
  1683                         , enable_libudev=yes)
  1684     if test x$enable_libudev = xyes; then
  1685         AC_CHECK_HEADER(libudev.h,
  1686                         have_libudev_h_hdr=yes,
  1687                         have_libudev_h_hdr=no)
  1688         if test x$have_libudev_h_hdr = xyes; then
  1689             AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])
  1690         fi
  1691     fi
  1692 }
  1693 
  1694 dnl See if the platform offers libdbus for various IPC techniques.
  1695 CheckDBus()
  1696 {
  1697     AC_ARG_ENABLE(dbus,
  1698 AC_HELP_STRING([--enable-dbus], [enable D-Bus support [[default=yes]]]),
  1699                         , enable_dbus=yes)
  1700     if test x$enable_dbus = xyes; then
  1701         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1702         if test x$PKG_CONFIG != xno; then
  1703             DBUS_CFLAGS=`$PKG_CONFIG --cflags dbus-1`
  1704             save_CFLAGS="$CFLAGS"
  1705             CFLAGS="$save_CFLAGS $DBUS_CFLAGS"
  1706             AC_CHECK_HEADER(dbus/dbus.h,
  1707                             have_dbus_dbus_h_hdr=yes,
  1708                             have_dbus_dbus_h_hdr=no)
  1709             CFLAGS="$save_CFLAGS"
  1710             if test x$have_dbus_dbus_h_hdr = xyes; then
  1711                 AC_DEFINE(HAVE_DBUS_DBUS_H, 1, [ ])
  1712                 EXTRA_CFLAGS="$EXTRA_CFLAGS $DBUS_CFLAGS"
  1713             fi
  1714         fi
  1715     fi
  1716 }
  1717 
  1718 dnl See if we can use the Touchscreen input library
  1719 CheckTslib()
  1720 {
  1721     AC_ARG_ENABLE(input-tslib,
  1722 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  1723                   , enable_input_tslib=yes)
  1724     if test x$enable_input_tslib = xyes; then
  1725         AC_MSG_CHECKING(for Touchscreen library support)
  1726         enable_input_tslib=no
  1727         AC_TRY_COMPILE([
  1728           #include "tslib.h"
  1729         ],[
  1730         ],[
  1731         enable_input_tslib=yes
  1732         ])
  1733         AC_MSG_RESULT($enable_input_tslib)
  1734         if test x$enable_input_tslib = xyes; then
  1735             AC_DEFINE(SDL_INPUT_TSLIB, 1, [ ])
  1736             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  1737         fi
  1738     fi
  1739 }
  1740 
  1741 dnl See what type of thread model to use on Linux and Solaris
  1742 CheckPTHREAD()
  1743 {
  1744     dnl Check for pthread support
  1745     AC_ARG_ENABLE(pthreads,
  1746 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  1747                   , enable_pthreads=yes)
  1748     dnl This is used on Linux for glibc binary compatibility (Doh!)
  1749     AC_ARG_ENABLE(pthread-sem,
  1750 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  1751                   , enable_pthread_sem=yes)
  1752     case "$host" in
  1753         *-*-linux*|*-*-uclinux*)
  1754             pthread_cflags="-D_REENTRANT"
  1755             pthread_lib="-lpthread"
  1756             ;;
  1757         *-*-bsdi*)
  1758             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1759             pthread_lib=""
  1760             ;;
  1761         *-*-darwin*)
  1762             pthread_cflags="-D_THREAD_SAFE"
  1763 # causes Carbon.p complaints?
  1764 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1765             ;;
  1766         *-*-freebsd*|*-*-dragonfly*)
  1767             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1768             pthread_lib="-pthread"
  1769             ;;
  1770         *-*-netbsd*)
  1771             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1772             pthread_lib="-lpthread"
  1773             ;;
  1774         *-*-openbsd*)
  1775             pthread_cflags="-D_REENTRANT"
  1776             pthread_lib="-pthread"
  1777             ;;
  1778         *-*-solaris2.9)
  1779             # From Solaris 9+, posix4's preferred name is rt.
  1780             pthread_cflags="-D_REENTRANT"
  1781             pthread_lib="-lpthread -lrt"
  1782             ;;
  1783         *-*-solaris2.10)
  1784             # Solaris 10+ merged pthread into libc.
  1785             pthread_cflags="-D_REENTRANT"
  1786             pthread_lib="-lrt"
  1787             ;;
  1788         *-*-solaris*)
  1789             # Solaris 11+ merged rt into libc.
  1790             pthread_cflags="-D_REENTRANT"
  1791             pthread_lib=""
  1792             ;;
  1793         *-*-sysv5*)
  1794             pthread_cflags="-D_REENTRANT -Kthread"
  1795             pthread_lib=""
  1796             ;;
  1797         *-*-aix*)
  1798             pthread_cflags="-D_REENTRANT -mthreads"
  1799             pthread_lib="-lpthread"
  1800             ;;
  1801         *-*-hpux11*)
  1802             pthread_cflags="-D_REENTRANT"
  1803             pthread_lib="-L/usr/lib -lpthread"
  1804             ;;
  1805         *)
  1806             pthread_cflags="-D_REENTRANT"
  1807             pthread_lib="-lpthread"
  1808             ;;
  1809     esac
  1810     if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
  1811         # Save the original compiler flags and libraries
  1812         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1813         # Add the pthread compiler flags and libraries
  1814         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1815         # Check to see if we have pthread support on this system
  1816         AC_MSG_CHECKING(for pthreads)
  1817         use_pthreads=no
  1818         AC_TRY_LINK([
  1819          #include <pthread.h>
  1820         ],[
  1821          pthread_attr_t type;
  1822          pthread_attr_init(&type);
  1823         ],[
  1824         use_pthreads=yes
  1825         ])
  1826         AC_MSG_RESULT($use_pthreads)
  1827         # Restore the compiler flags and libraries
  1828         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1829 
  1830         # Do futher testing if we have pthread support...
  1831         if test x$use_pthreads = xyes; then
  1832             AC_DEFINE(SDL_THREAD_PTHREAD, 1, [ ])
  1833             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  1834             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  1835             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  1836             SDL_LIBS="$SDL_LIBS $pthread_lib"
  1837 
  1838             # Save the original compiler flags and libraries
  1839             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1840             # Add the pthread compiler flags and libraries
  1841             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1842 
  1843             # Check to see if recursive mutexes are available
  1844             AC_MSG_CHECKING(for recursive mutexes)
  1845             has_recursive_mutexes=no
  1846             if test x$has_recursive_mutexes = xno; then
  1847                 AC_TRY_COMPILE([
  1848                   #include <pthread.h>
  1849                 ],[
  1850                   pthread_mutexattr_t attr;
  1851                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  1852                 ],[
  1853                 has_recursive_mutexes=yes
  1854                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX, 1, [ ])
  1855                 ])
  1856             fi
  1857             if test x$has_recursive_mutexes = xno; then
  1858                 AC_TRY_COMPILE([
  1859                   #include <pthread.h>
  1860                 ],[
  1861                   pthread_mutexattr_t attr;
  1862                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  1863                 ],[
  1864                 has_recursive_mutexes=yes
  1865                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP, 1, [ ])
  1866                 ])
  1867             fi
  1868             AC_MSG_RESULT($has_recursive_mutexes)
  1869 
  1870             # Check to see if pthread semaphore support is missing
  1871             if test x$enable_pthread_sem = xyes; then
  1872                 AC_MSG_CHECKING(for pthread semaphores)
  1873                 have_pthread_sem=no
  1874                 AC_TRY_COMPILE([
  1875                   #include <pthread.h>
  1876                   #include <semaphore.h>
  1877                 ],[
  1878                 ],[
  1879                 have_pthread_sem=yes
  1880                 ])
  1881                 AC_MSG_RESULT($have_pthread_sem)
  1882             fi
  1883             if test x$have_pthread_sem = xyes; then
  1884                 AC_MSG_CHECKING(for sem_timedwait)
  1885                 have_sem_timedwait=no
  1886                 AC_TRY_LINK([
  1887                   #include <pthread.h>
  1888                   #include <semaphore.h>
  1889                 ],[
  1890                   sem_timedwait(NULL, NULL);
  1891                 ],[
  1892                 have_sem_timedwait=yes
  1893                 AC_DEFINE(HAVE_SEM_TIMEDWAIT)
  1894                 ])
  1895                 AC_MSG_RESULT($have_sem_timedwait)
  1896             fi
  1897 
  1898             AC_MSG_CHECKING(for pthread_spin_trylock)
  1899             AC_TRY_LINK_FUNC(pthread_spin_trylock, [
  1900               has_pthread_spin_trylock=yes
  1901               AC_DEFINE(HAVE_PTHREAD_SPINLOCK, 1, [ ])
  1902             ],[
  1903               has_pthread_spin_trylock=no
  1904             ])
  1905             AC_MSG_RESULT($has_pthread_spin_trylock)
  1906 
  1907             AC_CHECK_HEADER(pthread_np.h, have_pthread_np_h=yes, have_pthread_np_h=no, [ #include <pthread.h> ])
  1908             if test x$have_pthread_np_h = xyes; then
  1909                 AC_DEFINE(HAVE_PTHREAD_NP_H, 1, [ ])
  1910             fi
  1911 
  1912             # Check to see if pthread naming is available
  1913             AC_MSG_CHECKING(for pthread_setname_np)
  1914             AC_TRY_LINK_FUNC(pthread_setname_np, [
  1915               has_pthread_setname_np=yes
  1916               AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [ ])
  1917             ],[
  1918               has_pthread_setname_np=no
  1919             ])
  1920             AC_MSG_RESULT($has_pthread_setname_np)
  1921 
  1922             AC_MSG_CHECKING(for pthread_set_name_np)
  1923             AC_TRY_LINK_FUNC(pthread_set_name_np, [
  1924               has_pthread_set_name_np=yes
  1925               AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [ ])
  1926             ],[
  1927               has_pthread_set_name_np=no
  1928             ])
  1929             AC_MSG_RESULT($has_pthread_set_name_np)
  1930 
  1931             # Restore the compiler flags and libraries
  1932             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1933 
  1934             # Basic thread creation functions
  1935             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  1936 
  1937             # Semaphores
  1938             # We can fake these with mutexes and condition variables if necessary
  1939             if test x$have_pthread_sem = xyes; then
  1940                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  1941             else
  1942                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1943             fi
  1944 
  1945             # Mutexes
  1946             # We can fake these with semaphores if necessary
  1947             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  1948 
  1949             # Condition variables
  1950             # We can fake these with semaphores and mutexes if necessary
  1951             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  1952 
  1953             have_threads=yes
  1954         fi
  1955     fi
  1956 }
  1957 
  1958 dnl Determine whether the compiler can produce Windows executables
  1959 CheckWINDOWS()
  1960 {
  1961     AC_MSG_CHECKING(Windows compiler)
  1962     have_win32_gcc=no
  1963     AC_TRY_COMPILE([
  1964      #include <windows.h>
  1965     ],[
  1966     ],[
  1967     have_win32_gcc=yes
  1968     ])
  1969     AC_MSG_RESULT($have_win32_gcc)
  1970     if test x$have_win32_gcc != xyes; then
  1971        AC_MSG_ERROR([
  1972 *** Your compiler ($CC) does not produce Windows executables!
  1973        ])
  1974     fi
  1975 
  1976     AC_MSG_CHECKING(Windows CE)
  1977     have_wince=no
  1978     AC_TRY_COMPILE([
  1979 #if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
  1980 #error This is not Windows CE
  1981 #endif
  1982     ],[
  1983     ],[
  1984     have_wince=yes
  1985        AC_MSG_ERROR([
  1986 *** Sorry, Windows CE is no longer supported.
  1987        ])
  1988     ])
  1989     AC_MSG_RESULT($have_wince)
  1990 
  1991     # This fixes Windows stack alignment with newer GCC
  1992     CheckStackBoundary
  1993 }
  1994 
  1995 dnl Find the DirectX includes and libraries
  1996 CheckDIRECTX()
  1997 {
  1998     AC_ARG_ENABLE(directx,
  1999 AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
  2000                   , enable_directx=yes)
  2001     if test x$enable_directx = xyes; then
  2002         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  2003         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  2004         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  2005         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  2006         AC_CHECK_HEADER(xaudio2.h, have_xaudio2=yes)
  2007     fi
  2008 }
  2009 
  2010 dnl Check for the dlfcn.h interface for dynamically loading objects
  2011 CheckDLOPEN()
  2012 {
  2013     AC_ARG_ENABLE(sdl-dlopen,
  2014 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  2015                   , enable_sdl_dlopen=yes)
  2016     if test x$enable_sdl_dlopen = xyes; then
  2017         AC_MSG_CHECKING(for dlopen)
  2018         have_dlopen=no
  2019         AC_TRY_COMPILE([
  2020          #include <dlfcn.h>
  2021         ],[
  2022          #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
  2023          #error Use dlcompat for Mac OS X 10.2 compatibility
  2024          #endif
  2025         ],[
  2026         have_dlopen=yes
  2027         ])
  2028         AC_MSG_RESULT($have_dlopen)
  2029 
  2030         if test x$have_dlopen = xyes; then
  2031             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  2032                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  2033                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  2034             AC_DEFINE(SDL_LOADSO_DLOPEN, 1, [ ])
  2035             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  2036             have_loadso=yes
  2037         fi
  2038     fi
  2039 }
  2040 
  2041 dnl Check for the usbhid(3) library on *BSD
  2042 CheckUSBHID()
  2043 {
  2044     if test x$enable_joystick = xyes; then
  2045         AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  2046         if test x$have_libusbhid = xyes; then
  2047             AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  2048             AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  2049             USB_LIBS="$USB_LIBS -lusbhid"
  2050         else
  2051             AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  2052             AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  2053             AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  2054         fi
  2055             
  2056         save_CFLAGS="$CFLAGS"
  2057         CFLAGS="$CFLAGS $USB_CFLAGS"
  2058 
  2059         AC_MSG_CHECKING(for usbhid)
  2060         have_usbhid=no
  2061         AC_TRY_COMPILE([
  2062           #include <sys/types.h>
  2063           #if defined(HAVE_USB_H)
  2064           #include <usb.h>
  2065           #endif
  2066           #ifdef __DragonFly__
  2067           # include <bus/usb/usb.h>
  2068           # include <bus/usb/usbhid.h>
  2069           #else
  2070           # include <dev/usb/usb.h>
  2071           # include <dev/usb/usbhid.h>
  2072           #endif
  2073           #if defined(HAVE_USBHID_H)
  2074           #include <usbhid.h>
  2075           #elif defined(HAVE_LIBUSB_H)
  2076           #include <libusb.h>
  2077           #elif defined(HAVE_LIBUSBHID_H)
  2078           #include <libusbhid.h>
  2079           #endif
  2080         ],[
  2081           struct report_desc *repdesc;
  2082           struct usb_ctl_report *repbuf;
  2083           hid_kind_t hidkind;
  2084         ],[
  2085         have_usbhid=yes
  2086         ])
  2087         AC_MSG_RESULT($have_usbhid)
  2088 
  2089         if test x$have_usbhid = xyes; then
  2090             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  2091             have_usbhid_ucr_data=no
  2092             AC_TRY_COMPILE([
  2093               #include <sys/types.h>
  2094               #if defined(HAVE_USB_H)
  2095               #include <usb.h>
  2096               #endif
  2097               #ifdef __DragonFly__
  2098               # include <bus/usb/usb.h>
  2099               # include <bus/usb/usbhid.h>
  2100               #else
  2101               # include <dev/usb/usb.h>
  2102               # include <dev/usb/usbhid.h>
  2103               #endif
  2104               #if defined(HAVE_USBHID_H)
  2105               #include <usbhid.h>
  2106               #elif defined(HAVE_LIBUSB_H)
  2107               #include <libusb.h>
  2108               #elif defined(HAVE_LIBUSBHID_H)
  2109               #include <libusbhid.h>
  2110               #endif
  2111             ],[
  2112               struct usb_ctl_report buf;
  2113               if (buf.ucr_data) { }
  2114             ],[
  2115             have_usbhid_ucr_data=yes
  2116             ])
  2117             if test x$have_usbhid_ucr_data = xyes; then
  2118                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  2119             fi
  2120             AC_MSG_RESULT($have_usbhid_ucr_data)
  2121             
  2122             AC_MSG_CHECKING(for new usbhid API)
  2123             have_usbhid_new=no
  2124             AC_TRY_COMPILE([
  2125               #include <sys/types.h>
  2126               #if defined(HAVE_USB_H)
  2127               #include <usb.h>
  2128               #endif
  2129               #ifdef __DragonFly__
  2130               #include <bus/usb/usb.h>
  2131               #include <bus/usb/usbhid.h>
  2132               #else
  2133               #include <dev/usb/usb.h>
  2134               #include <dev/usb/usbhid.h>
  2135               #endif
  2136               #if defined(HAVE_USBHID_H)
  2137               #include <usbhid.h>
  2138               #elif defined(HAVE_LIBUSB_H)
  2139               #include <libusb.h>
  2140               #elif defined(HAVE_LIBUSBHID_H)
  2141               #include <libusbhid.h>
  2142               #endif
  2143             ],[
  2144               report_desc_t d;
  2145               hid_start_parse(d, 1, 1);
  2146             ],[
  2147             have_usbhid_new=yes
  2148             ])
  2149             if test x$have_usbhid_new = xyes; then
  2150                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  2151             fi
  2152             AC_MSG_RESULT($have_usbhid_new)
  2153 
  2154             AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  2155             have_machine_joystick=no
  2156             AC_TRY_COMPILE([
  2157               #include <machine/joystick.h>
  2158             ],[
  2159               struct joystick t;
  2160             ],[
  2161             have_machine_joystick=yes
  2162             ])
  2163             if test x$have_machine_joystick = xyes; then
  2164                 AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
  2165             fi
  2166             AC_MSG_RESULT($have_machine_joystick)
  2167 
  2168             AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
  2169             SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  2170             EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  2171             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  2172             have_joystick=yes
  2173         fi
  2174         CFLAGS="$save_CFLAGS"
  2175     fi
  2176 }
  2177 
  2178 dnl Check for clock_gettime()
  2179 CheckClockGettime()
  2180 {
  2181     AC_ARG_ENABLE(clock_gettime,
  2182 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=yes]]]),
  2183                   , enable_clock_gettime=yes)
  2184     if test x$enable_clock_gettime = xyes; then
  2185         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  2186         if test x$have_clock_gettime = xyes; then
  2187             AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  2188             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  2189         else
  2190             AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
  2191             if test x$have_clock_gettime = xyes; then
  2192                AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  2193                EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
  2194             fi
  2195         fi
  2196     fi
  2197 }
  2198 
  2199 dnl Check for a valid linux/version.h
  2200 CheckLinuxVersion()
  2201 {
  2202     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  2203     if test x$have_linux_version_h = xyes; then
  2204         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  2205     fi
  2206 }
  2207 
  2208 dnl Check if we want to use RPATH
  2209 CheckRPATH()
  2210 {
  2211     AC_ARG_ENABLE(rpath,
  2212 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  2213                   , enable_rpath=yes)
  2214 }
  2215 
  2216 dnl Set up the configuration based on the host platform!
  2217 case "$host" in
  2218     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*)
  2219         case "$host" in
  2220             *-*-linux*)         ARCH=linux ;;
  2221             *-*-uclinux*)       ARCH=linux ;;
  2222             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  2223             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  2224             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  2225             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  2226             *-*-bsdi*)          ARCH=bsdi ;;
  2227             *-*-freebsd*)       ARCH=freebsd ;;
  2228             *-*-dragonfly*)     ARCH=freebsd ;;
  2229             *-*-netbsd*)        ARCH=netbsd ;;
  2230             *-*-openbsd*)       ARCH=openbsd ;;
  2231             *-*-sysv5*)         ARCH=sysv5 ;;
  2232             *-*-solaris*)       ARCH=solaris ;;
  2233             *-*-hpux*)          ARCH=hpux ;;
  2234             *-*-aix*)           ARCH=aix ;;
  2235             *-*-minix*)         ARCH=minix ;;
  2236         esac
  2237         CheckVisibilityHidden
  2238         CheckDummyVideo
  2239         CheckDiskAudio
  2240         CheckDummyAudio
  2241         CheckDLOPEN
  2242         CheckOSS
  2243         CheckALSA
  2244         CheckPulseAudio
  2245         CheckARTSC
  2246         CheckESD
  2247         CheckNAS
  2248         CheckX11
  2249         CheckDirectFB
  2250         CheckFusionSound
  2251         CheckOpenGLX11
  2252         CheckOpenGLESX11
  2253         CheckLibUDev
  2254         CheckDBus
  2255         CheckInputEvents
  2256         CheckTslib
  2257         CheckUSBHID
  2258         CheckPTHREAD
  2259         CheckClockGettime
  2260         CheckLinuxVersion
  2261         CheckRPATH
  2262         # Set up files for the audio library
  2263         if test x$enable_audio = xyes; then
  2264           case $ARCH in
  2265             sysv5|solaris|hpux)
  2266                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
  2267                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2268                 have_audio=yes
  2269             ;;
  2270             netbsd|openbsd)
  2271                 AC_DEFINE(SDL_AUDIO_DRIVER_BSD, 1, [ ])
  2272                 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
  2273                 have_audio=yes
  2274             ;;
  2275             aix)
  2276                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO, 1, [ ])
  2277                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  2278                 have_audio=yes
  2279             ;;
  2280           esac
  2281         fi
  2282         # Set up files for the joystick library
  2283         if test x$enable_joystick = xyes; then
  2284           case $ARCH in
  2285             linux)
  2286                 AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ])
  2287                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  2288                 have_joystick=yes
  2289             ;;
  2290           esac
  2291         fi
  2292         # Set up files for the haptic library
  2293         if test x$enable_haptic = xyes; then
  2294            if test x$use_input_events = xyes; then
  2295              case $ARCH in
  2296                linux)
  2297                    AC_DEFINE(SDL_HAPTIC_LINUX, 1, [ ])
  2298                    SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  2299                    have_haptic=yes
  2300                ;;
  2301              esac
  2302            fi
  2303         fi
  2304         # Set up files for the power library
  2305         if test x$enable_power = xyes; then
  2306              case $ARCH in
  2307                linux)
  2308                    AC_DEFINE(SDL_POWER_LINUX, 1, [ ])
  2309                    SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
  2310                    have_power=yes
  2311                ;;
  2312              esac
  2313         fi
  2314         # Set up files for the timer library
  2315         if test x$enable_timers = xyes; then
  2316             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  2317             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2318             have_timers=yes
  2319         fi
  2320         ;;
  2321     *-*-cygwin* | *-*-mingw32*)
  2322         ARCH=win32
  2323         if test "$build" != "$host"; then # cross-compiling
  2324             # Default cross-compile location
  2325             ac_default_prefix=/usr/local/cross-tools/$host
  2326         else
  2327             # Look for the location of the tools and install there
  2328             if test "$BUILD_PREFIX" != ""; then
  2329                 ac_default_prefix=$BUILD_PREFIX
  2330             fi
  2331         fi
  2332         CheckDummyVideo
  2333         CheckDiskAudio
  2334         CheckDummyAudio
  2335         CheckWINDOWS
  2336         CheckWINDOWSGL
  2337         CheckDIRECTX
  2338 
  2339         # Set up the core platform files
  2340         SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
  2341 
  2342         # Set up files for the video library
  2343         if test x$enable_video = xyes; then
  2344             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS, 1, [ ])
  2345             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
  2346             have_video=yes
  2347             AC_ARG_ENABLE(render-d3d,
  2348 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2349                                 , enable_render_d3d=yes)
  2350             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2351                 AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ])
  2352             fi
  2353         fi
  2354         # Set up files for the audio library
  2355         if test x$enable_audio = xyes; then
  2356             AC_DEFINE(SDL_AUDIO_DRIVER_WINMM, 1, [ ])
  2357             SOURCES="$SOURCES $srcdir/src/audio/winmm/*.c"
  2358             if test x$have_dsound = xyes; then
  2359                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
  2360                 SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
  2361             fi
  2362             if test x$have_xaudio2 = xyes; then
  2363                 AC_DEFINE(SDL_AUDIO_DRIVER_XAUDIO2, 1, [ ])
  2364                 SOURCES="$SOURCES $srcdir/src/audio/xaudio2/*.c"
  2365             fi
  2366             have_audio=yes
  2367         fi
  2368         # Set up files for the joystick library
  2369         if test x$enable_joystick = xyes; then
  2370             if test x$have_dinput = xyes; then
  2371                 AC_DEFINE(SDL_JOYSTICK_DINPUT, 1, [ ])
  2372                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_dxjoystick.c"
  2373                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
  2374             else
  2375                 AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
  2376                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_mmjoystick.c"
  2377             fi
  2378             have_joystick=yes
  2379         fi
  2380         if test x$enable_haptic = xyes; then
  2381             if test x$have_dinput = xyes; then
  2382                 AC_DEFINE(SDL_HAPTIC_DINPUT, 1, [ ])
  2383                 SOURCES="$SOURCES $srcdir/src/haptic/windows/SDL_syshaptic.c"
  2384                 have_haptic=yes
  2385             fi
  2386         fi
  2387         if test x$enable_power = xyes; then
  2388             AC_DEFINE(SDL_POWER_WINDOWS, 1, [ ])
  2389             SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
  2390             have_power=yes
  2391         fi
  2392         # Set up files for the thread library
  2393         if test x$enable_threads = xyes; then
  2394             AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ])
  2395             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_sysmutex.c"
  2396             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_syssem.c"
  2397             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_systhread.c"
  2398             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2399             have_threads=yes
  2400         fi
  2401         # Set up files for the timer library
  2402         if test x$enable_timers = xyes; then
  2403             AC_DEFINE(SDL_TIMER_WINDOWS, 1, [ ])
  2404             SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
  2405             have_timers=yes
  2406         fi
  2407         # Set up files for the shared object loading library
  2408         if test x$enable_loadso = xyes; then
  2409             AC_DEFINE(SDL_LOADSO_WINDOWS, 1, [ ])
  2410             SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
  2411             have_loadso=yes
  2412         fi
  2413         # Set up the system libraries we need
  2414         # SDL is unicode, and unicows emulates this on Windows 98/ME
  2415         # You can get this here: http://libunicows.sourceforge.net/
  2416         #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lunicows"
  2417         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lversion -luuid"
  2418         # The Windows platform requires special setup
  2419         VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
  2420         SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
  2421         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2422         SDL_LIBS="-lmingw32 -lSDL2main $SDL_LIBS -mwindows"
  2423         ;;
  2424     *-*-beos* | *-*-haiku*)
  2425         ARCH=beos
  2426         ac_default_prefix=/boot/common
  2427         CheckDummyVideo
  2428         CheckDiskAudio
  2429         CheckDummyAudio
  2430         CheckBWINDOW
  2431         CheckBeGL
  2432         # Set up files for the audio library
  2433         if test x$enable_audio = xyes; then
  2434             AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO, 1, [ ])
  2435             SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
  2436             have_audio=yes
  2437         fi
  2438         # Set up files for the joystick library
  2439         if test x$enable_joystick = xyes; then
  2440             AC_DEFINE(SDL_JOYSTICK_BEOS, 1, [ ])
  2441             SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
  2442             have_joystick=yes
  2443         fi
  2444         # Set up files for the thread library
  2445         if test x$enable_threads = xyes; then
  2446             AC_DEFINE(SDL_THREAD_BEOS, 1, [ ])
  2447             SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
  2448             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2449             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2450             have_threads=yes
  2451         fi
  2452         # Set up files for the timer library
  2453         if test x$enable_timers = xyes; then
  2454             AC_DEFINE(SDL_TIMER_BEOS, 1, [ ])
  2455             SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
  2456             have_timers=yes
  2457         fi
  2458         # Set up files for the shared object loading library
  2459         if test x$enable_loadso = xyes; then
  2460             AC_DEFINE(SDL_LOADSO_BEOS, 1, [ ])
  2461             SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
  2462             have_loadso=yes
  2463         fi
  2464         # Set up files for the system power library
  2465         if test x$enable_power = xyes; then
  2466             AC_DEFINE(SDL_POWER_BEOS, 1, [ ])
  2467             SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
  2468             have_power=yes
  2469         fi
  2470         # The BeOS platform requires special setup.
  2471         SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
  2472         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2473         ;;
  2474     arm*-apple-darwin*)
  2475         # iOS - We are not writing anything to confdefs.h because you have to replace
  2476         # SDL_config.h for SDL_config_iphoneos.h anyway
  2477         ARCH=ios
  2478 
  2479         CheckVisibilityHidden
  2480         CheckDummyVideo
  2481         CheckDiskAudio
  2482         CheckDummyAudio
  2483         CheckDLOPEN
  2484         CheckCOCOA
  2485         CheckPTHREAD
  2486 
  2487 
  2488         # Set up files for the audio library
  2489         if test x$enable_audio = xyes; then
  2490             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.c"
  2491             have_audio=yes
  2492         fi
  2493         # Set up files for the joystick library
  2494         if test x$enable_joystick = xyes; then
  2495             SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
  2496             have_joystick=yes
  2497         fi
  2498         # Set up files for the haptic library
  2499         #if test x$enable_haptic = xyes; then
  2500         #    SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2501         #    have_haptic=yes
  2502         #    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2503         #fi
  2504         # Set up files for the power library
  2505         if test x$enable_power = xyes; then
  2506             SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
  2507             have_power=yes
  2508         fi
  2509         # Set up files for the timer library
  2510         if test x$enable_timers = xyes; then
  2511             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2512             have_timers=yes
  2513         fi
  2514         # Set up additional files for the file library
  2515         if test x$enable_file = xyes; then
  2516             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  2517         fi
  2518         # The iOS platform requires special setup.
  2519         SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
  2520         SOURCES="$SOURCES $srcdir/src/video/uikit/*.c"
  2521         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2522         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
  2523         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
  2524         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
  2525         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
  2526         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
  2527         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
  2528         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
  2529         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
  2530         ;;
  2531     *-*-darwin* )
  2532         # This could be either full "Mac OS X", or plain "Darwin" which is
  2533         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2534         # Next line is broken, and a few files below require Mac OS X (full)
  2535         ARCH=macosx
  2536 
  2537         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  2538         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  2539         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  2540 
  2541         CheckVisibilityHidden
  2542         CheckDummyVideo
  2543         CheckDiskAudio
  2544         CheckDummyAudio
  2545         CheckDLOPEN
  2546         CheckCOCOA
  2547         CheckX11
  2548         CheckMacGL
  2549         CheckOpenGLX11
  2550         CheckPTHREAD
  2551 
  2552         # Good optimization on Mac OS X, yes...
  2553         EXTRA_CFLAGS="$EXTRA_CFLAGS -falign-loops=16"
  2554 
  2555         # Need this or things might misbuild on a G3.
  2556         EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
  2557 
  2558         # Set up files for the audio library
  2559         if test x$enable_audio = xyes; then
  2560             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
  2561             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.c"
  2562             have_audio=yes
  2563         fi
  2564         # Set up files for the joystick library
  2565         if test x$enable_joystick = xyes; then
  2566             AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
  2567             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  2568             have_joystick=yes
  2569         fi
  2570         # Set up files for the haptic library
  2571         if test x$enable_haptic = xyes; then
  2572             AC_DEFINE(SDL_HAPTIC_IOKIT, 1, [ ])
  2573             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2574             have_haptic=yes
  2575             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2576         fi
  2577         # Set up files for the power library
  2578         if test x$enable_power = xyes; then
  2579             AC_DEFINE(SDL_POWER_MACOSX, 1, [ ])
  2580             SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
  2581             have_power=yes
  2582         fi
  2583         # Set up files for the timer library
  2584         if test x$enable_timers = xyes; then
  2585             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  2586             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2587             have_timers=yes
  2588         fi
  2589         # Set up additional files for the file library
  2590         if test x$enable_file = xyes; then
  2591             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  2592         fi
  2593         # The Mac OS X platform requires special setup.
  2594         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2595         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
  2596         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  2597         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  2598         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  2599         # If audio is used, add the AudioUnit framework
  2600         if test x$enable_audio = xyes; then
  2601             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
  2602         fi
  2603         ;;
  2604     *)
  2605         AC_MSG_ERROR([
  2606 *** Unsupported host:  Please add to configure.in
  2607         ])
  2608         ;;
  2609 esac
  2610 
  2611 dnl Do this on all platforms, after everything else.
  2612 CheckWarnAll
  2613 
  2614 # Verify that we have all the platform specific files we need
  2615 
  2616 if test x$have_joystick != xyes; then
  2617     if test x$enable_joystick = xyes; then
  2618         AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
  2619     fi
  2620     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2621 fi
  2622 if test x$have_haptic != xyes; then
  2623     if test x$enable_haptic = xyes; then
  2624         AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
  2625     fi
  2626     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2627 fi
  2628 if test x$have_threads != xyes; then
  2629     if test x$enable_threads = xyes; then
  2630         AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
  2631     fi
  2632     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  2633 fi
  2634 if test x$have_timers != xyes; then
  2635     if test x$enable_timers = xyes; then
  2636         AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ])
  2637     fi
  2638     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  2639 fi
  2640 if test x$have_loadso != xyes; then
  2641     if test x$enable_loadso = xyes; then
  2642         AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
  2643     fi
  2644     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  2645 fi
  2646 if test x$SDLMAIN_SOURCES = x; then
  2647     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  2648 fi
  2649 SDLTEST_SOURCES="$srcdir/src/test/*.c"
  2650 
  2651 OBJECTS=`echo $SOURCES`
  2652 DEPENDS=`echo $SOURCES | tr ' ' '\n'`
  2653 for EXT in asm cc m c S; do
  2654     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
  2655     DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
  2656 \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
  2657 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2658 done
  2659 
  2660 VERSION_OBJECTS=`echo $VERSION_SOURCES`
  2661 VERSION_DEPENDS=`echo $VERSION_SOURCES`
  2662 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  2663 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
  2664 \\$(objects)/\\2.o: \\1/\\2.rc\\\\
  2665 	\\$(WINDRES) \\$< \\$@,g"`
  2666 
  2667 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
  2668 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
  2669 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2670 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  2671 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  2672 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2673 
  2674 SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
  2675 SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
  2676 SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2677 SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  2678 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  2679 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2680 
  2681 # Set runtime shared library paths as needed
  2682 
  2683 if test "x$enable_rpath" = "xyes"; then
  2684   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
  2685     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  2686   fi
  2687   if test $ARCH = solaris; then
  2688     SDL_RLD_FLAGS="-R\${libdir}"
  2689   fi
  2690 else
  2691   SDL_RLD_FLAGS=""
  2692 fi
  2693 
  2694 SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  2695 
  2696 dnl Expand the cflags and libraries needed by apps using SDL
  2697 AC_SUBST(SDL_CFLAGS)
  2698 AC_SUBST(SDL_LIBS)
  2699 AC_SUBST(SDL_STATIC_LIBS)
  2700 AC_SUBST(SDL_RLD_FLAGS)
  2701 if test x$enable_shared = xyes; then
  2702     ENABLE_SHARED_TRUE=
  2703     ENABLE_SHARED_FALSE="#"
  2704 else
  2705     ENABLE_SHARED_TRUE="#"
  2706     ENABLE_SHARED_FALSE=
  2707 fi
  2708 if test x$enable_static = xyes; then
  2709     ENABLE_STATIC_TRUE=
  2710     ENABLE_STATIC_FALSE="#"
  2711 else
  2712     ENABLE_STATIC_TRUE="#"
  2713     ENABLE_STATIC_FALSE=
  2714 fi
  2715 AC_SUBST(ENABLE_SHARED_TRUE)
  2716 AC_SUBST(ENABLE_SHARED_FALSE)
  2717 AC_SUBST(ENABLE_STATIC_TRUE)
  2718 AC_SUBST(ENABLE_STATIC_FALSE)
  2719 
  2720 dnl Expand the sources and objects needed to build the library
  2721 AC_SUBST(ac_aux_dir)
  2722 AC_SUBST(INCLUDE)
  2723 AC_SUBST(OBJECTS)
  2724 AC_SUBST(VERSION_OBJECTS)
  2725 AC_SUBST(SDLMAIN_OBJECTS)
  2726 AC_SUBST(SDLTEST_OBJECTS)
  2727 AC_SUBST(BUILD_CFLAGS)
  2728 AC_SUBST(EXTRA_CFLAGS)
  2729 AC_SUBST(BUILD_LDFLAGS)
  2730 AC_SUBST(EXTRA_LDFLAGS)
  2731 AC_SUBST(WINDRES)
  2732 
  2733 cat >Makefile.rules <<__EOF__
  2734 
  2735 # Build rules for objects
  2736 -include \$(OBJECTS:.lo=.d)
  2737 
  2738 # Special dependency for SDL.c, since it depends on SDL_revision.h
  2739 $srcdir/src/SDL.c: update-revision
  2740 $DEPENDS
  2741 $VERSION_DEPENDS
  2742 $SDLMAIN_DEPENDS
  2743 $SDLTEST_DEPENDS
  2744 __EOF__
  2745 
  2746 AC_CONFIG_FILES([
  2747     Makefile:Makefile.in:Makefile.rules sdl2-config SDL2.spec sdl2.pc
  2748 ])
  2749 AC_OUTPUT
  2750 chmod a+x sdl2-config