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