configure.in
author Sam Lantinga <slouken@libsdl.org>
Wed, 10 Jul 2013 02:32:04 -0700
changeset 7391 a29895dc5e9a
parent 7388 058097637b4c
child 7433 8f118396264b
permissions -rw-r--r--
Implemented an API for thread-local storage: SDL_TLSCreate(), SDL_TLSSet(), SDL_TLSGet()
     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_DEFINE(SDL_VIDEO_DRIVER_X11, 1, [ ])
  1161             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
  1162             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
  1163 
  1164             if test x$enable_x11_shared = xmaybe; then
  1165                 enable_x11_shared=$x11_symbols_private
  1166             fi
  1167             if test x$have_loadso != xyes && \
  1168                test x$enable_x11_shared = xyes; then
  1169                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
  1170                 enable_x11_shared=no
  1171             fi
  1172             if test x$x11_symbols_private != xyes && \
  1173                test x$enable_x11_shared = xyes; then
  1174                 AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
  1175                 enable_x11_shared=no
  1176             fi
  1177 
  1178             if test x$have_loadso = xyes && \
  1179                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
  1180                 echo "-- dynamic libX11 -> $x11_lib"
  1181                 echo "-- dynamic libX11ext -> $x11ext_lib"
  1182                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib", [ ])
  1183                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib", [ ])
  1184             else
  1185                 enable_x11_shared=no
  1186                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
  1187             fi
  1188             have_video=yes
  1189 
  1190             AC_MSG_CHECKING(for const parameter to XextAddDisplay)
  1191             have_const_param_XextAddDisplay=no
  1192             AC_TRY_COMPILE([
  1193               #include <X11/Xlib.h>
  1194               #include <X11/Xproto.h>
  1195               #include <X11/extensions/Xext.h>
  1196               #include <X11/extensions/extutil.h>
  1197               extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
  1198             ],[
  1199             ],[
  1200             have_const_param_XextAddDisplay=yes
  1201             AC_DEFINE(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY)
  1202             ])
  1203             AC_MSG_RESULT($have_const_param_XextAddDisplay)
  1204 
  1205             AC_MSG_CHECKING(for const parameter to _XData32)
  1206 	    have_const_param_xdata32=no
  1207 	    AC_TRY_COMPILE([
  1208 	      #include <X11/Xlibint.h>
  1209 	      extern int _XData32(Display *dpy,register _Xconst long *data,unsigned len);
  1210 	    ],[
  1211 	    ],[
  1212 	    have_const_param_xdata32=yes
  1213 	    AC_DEFINE(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32)
  1214 	    ])
  1215 	    AC_MSG_RESULT($have_const_param_xdata32)
  1216 
  1217             dnl AC_CHECK_LIB(X11, XGetEventData, AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS, 1, [Have XGenericEvent]))
  1218             AC_MSG_CHECKING([for XGenericEvent])
  1219             have_XGenericEvent=no
  1220             AC_TRY_COMPILE([
  1221               	#include <X11/Xlib.h>
  1222             ],[
  1223 Display *display;
  1224 XEvent event;
  1225 XGenericEventCookie *cookie = &event.xcookie;
  1226 XNextEvent(display, &event);
  1227 XGetEventData(display, cookie);
  1228 XFreeEventData(display, cookie);
  1229             ],[
  1230                 have_XGenericEvent=yes
  1231                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS)
  1232             ])
  1233             AC_MSG_RESULT($have_XGenericEvent)
  1234 
  1235             AC_CHECK_LIB(X11, XkbKeycodeToKeysym, AC_DEFINE(SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM, 1, [Have XkbKeycodeToKeysym]))
  1236 
  1237             AC_ARG_ENABLE(video-x11-xcursor,
  1238 AC_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[default=yes]]]),
  1239                             , enable_video_x11_xcursor=yes)
  1240             if test x$enable_video_x11_xcursor = xyes; then
  1241                 definitely_enable_video_x11_xcursor=no
  1242                 AC_CHECK_HEADER(X11/Xcursor/Xcursor.h,
  1243                                 have_xcursor_h_hdr=yes,
  1244                                 have_xcursor_h_hdr=no,
  1245                                 [#include <X11/Xlib.h>
  1246                                 ])
  1247                 if test x$have_xcursor_h_hdr = xyes; then
  1248                     if test x$enable_x11_shared = xyes && test x$xcursor_lib != x ; then
  1249                         echo "-- dynamic libXcursor -> $xcursor_lib"
  1250                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR, "$xcursor_lib", [ ])
  1251                         definitely_enable_video_x11_xcursor=yes
  1252                     else
  1253                         AC_CHECK_LIB(Xcursor, XcursorImageCreate, have_xcursor_lib=yes)
  1254                         if test x$have_xcursor_lib = xyes ; then
  1255                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXcursor"
  1256                             definitely_enable_video_x11_xcursor=yes
  1257                         fi
  1258                     fi
  1259                 fi
  1260             fi
  1261             if test x$definitely_enable_video_x11_xcursor = xyes; then
  1262                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XCURSOR, 1, [ ])
  1263             fi
  1264             AC_ARG_ENABLE(video-x11-xinerama,
  1265 AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
  1266                             , enable_video_x11_xinerama=yes)
  1267             if test x$enable_video_x11_xinerama = xyes; then
  1268                 definitely_enable_video_x11_xinerama=no
  1269                 AC_CHECK_HEADER(X11/extensions/Xinerama.h,
  1270                                 have_xinerama_h_hdr=yes,
  1271                                 have_xinerama_h_hdr=no,
  1272                                 [#include <X11/Xlib.h>
  1273                                 ])
  1274                 if test x$have_xinerama_h_hdr = xyes; then
  1275                     if test x$enable_x11_shared = xyes && test x$xinerama_lib != x ; then
  1276                         echo "-- dynamic libXinerama -> $xinerama_lib"
  1277                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA, "$xinerama_lib", [ ])
  1278                         definitely_enable_video_x11_xinerama=yes
  1279                     else
  1280                         AC_CHECK_LIB(Xinerama, XineramaQueryExtension, have_xinerama_lib=yes)
  1281                         if test x$have_xinerama_lib = xyes ; then
  1282                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXinerama"
  1283                             definitely_enable_video_x11_xinerama=yes
  1284                         fi
  1285                     fi
  1286                 fi
  1287             fi
  1288             if test x$definitely_enable_video_x11_xinerama = xyes; then
  1289                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA, 1, [ ])
  1290             fi
  1291             AC_ARG_ENABLE(video-x11-xinput,
  1292 AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
  1293                             , enable_video_x11_xinput=yes)
  1294             if test x$enable_video_x11_xinput = xyes; then
  1295                 definitely_enable_video_x11_xinput=no
  1296                 AC_CHECK_HEADER(X11/extensions/XInput2.h,
  1297                                 have_xinput_h_hdr=yes,
  1298                                 have_xinput_h_hdr=no,
  1299                                 [#include <X11/Xlib.h>
  1300                                 ])
  1301                 if test x$have_xinput_h_hdr = xyes; then
  1302                     if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
  1303                         echo "-- dynamic libXi -> $xinput_lib"
  1304                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2, "$xinput_lib", [ ])
  1305                         definitely_enable_video_x11_xinput=yes
  1306                     else
  1307                         AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
  1308                         if test x$have_xinput_lib = xyes ; then
  1309                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
  1310                             definitely_enable_video_x11_xinput=yes
  1311                         fi
  1312                     fi
  1313                 fi
  1314             fi
  1315             if test x$definitely_enable_video_x11_xinput = xyes; then
  1316                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ])
  1317                 AC_MSG_CHECKING(for xinput2 multitouch)
  1318             	have_xinput2_multitouch=no
  1319             	AC_TRY_COMPILE([
  1320               		#include <X11/Xlib.h>
  1321              		#include <X11/Xproto.h>
  1322 			#include <X11/extensions/XInput2.h>
  1323             	],[
  1324 int event_type = XI_TouchBegin;
  1325 XITouchClassInfo *t;
  1326 Status 
  1327 XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f)
  1328 {
  1329     return (Status)0;
  1330 }
  1331             	],[
  1332             	have_xinput2_multitouch=yes
  1333             	AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH)
  1334             	])
  1335             	AC_MSG_RESULT($have_xinput2_multitouch)
  1336             fi
  1337             AC_ARG_ENABLE(video-x11-xrandr,
  1338 AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
  1339                             , enable_video_x11_xrandr=yes)
  1340             if test x$enable_video_x11_xrandr = xyes; then
  1341                 definitely_enable_video_x11_xrandr=no
  1342                 AC_CHECK_HEADER(X11/extensions/Xrandr.h,
  1343                                 have_xrandr_h_hdr=yes,
  1344                                 have_xrandr_h_hdr=no,
  1345                                 [#include <X11/Xlib.h>
  1346                                 ])
  1347                 if test x$have_xrandr_h_hdr = xyes; then
  1348                     if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
  1349                         echo "-- dynamic libXrandr -> $xrandr_lib"
  1350                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib", [ ])
  1351                         definitely_enable_video_x11_xrandr=yes
  1352                     else
  1353                         AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
  1354                         if test x$have_xrandr_lib = xyes ; then
  1355                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr"
  1356                             definitely_enable_video_x11_xrandr=yes
  1357                         fi
  1358                     fi
  1359                 fi
  1360             fi
  1361             if test x$definitely_enable_video_x11_xrandr = xyes; then
  1362                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR, 1, [ ])
  1363             fi
  1364             AC_ARG_ENABLE(video-x11-scrnsaver,
  1365 AC_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
  1366                             , enable_video_x11_scrnsaver=yes)
  1367             if test x$enable_video_x11_scrnsaver = xyes; then
  1368                 AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
  1369                                 have_scrnsaver_h_hdr=yes,
  1370                                 have_scrnsaver_h_hdr=no,
  1371                                 [#include <X11/Xlib.h>
  1372                                 ])
  1373                 if test x$have_scrnsaver_h_hdr = xyes; then
  1374                     if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
  1375                         echo "-- dynamic libXss -> $xss_lib"
  1376                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib", [ ])
  1377                         definitely_enable_video_x11_scrnsaver=yes
  1378                     else
  1379                         AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
  1380                         if test x$have_xss_lib = xyes ; then
  1381                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
  1382                             definitely_enable_video_x11_scrnsaver=yes
  1383                         fi
  1384                     fi
  1385                 fi
  1386             fi
  1387             if test x$definitely_enable_video_x11_scrnsaver = xyes; then
  1388                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSCRNSAVER, 1, [ ])
  1389             fi
  1390             AC_ARG_ENABLE(video-x11-xshape,
  1391 AC_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default=yes]]]),
  1392                             , enable_video_x11_xshape=yes)
  1393             if test x$enable_video_x11_xshape = xyes; then
  1394                 AC_CHECK_HEADER(X11/extensions/shape.h,
  1395                                 have_shape_h_hdr=yes,
  1396                                 have_shape_h_hdr=no,
  1397                                 [#include <X11/Xlib.h>
  1398                                 ])
  1399                 if test x$have_shape_h_hdr = xyes; then
  1400                     AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSHAPE, 1, [ ])
  1401                 fi
  1402             fi
  1403             AC_ARG_ENABLE(video-x11-vm,
  1404 AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
  1405                             , enable_video_x11_vm=yes)
  1406             if test x$enable_video_x11_vm = xyes; then
  1407                 definitely_enable_video_x11_vm=no
  1408                 AC_CHECK_HEADER(X11/extensions/xf86vmode.h,
  1409                                 have_vm_h_hdr=yes,
  1410                                 have_vm_h_hdr=no,
  1411                                 [#include <X11/Xlib.h>
  1412                                 ])
  1413                 if test x$have_vm_h_hdr = xyes; then
  1414                     if test x$enable_x11_shared = xyes && test x$xvidmode_lib != x ; then
  1415                         echo "-- dynamic libXxf86vm -> $xvidmode_lib"
  1416                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE, "$xvidmode_lib", [ ])
  1417                         definitely_enable_video_x11_vm=yes
  1418                     else
  1419                         AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion, have_vm_lib=yes)
  1420                         if test x$have_vm_lib = xyes ; then
  1421                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXxf86vm"
  1422                             definitely_enable_video_x11_vm=yes
  1423                         fi
  1424                     fi
  1425                 fi
  1426             fi
  1427             if test x$definitely_enable_video_x11_vm = xyes; then
  1428                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XVIDMODE, 1, [ ])
  1429             fi
  1430         fi
  1431     fi
  1432 }
  1433 
  1434 dnl Set up the BWindow video driver if enabled
  1435 CheckBWINDOW()
  1436 {
  1437     if test x$enable_video = xyes; then
  1438         AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW, 1, [ ])
  1439         SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
  1440         have_video=yes
  1441     fi
  1442 }
  1443 
  1444 dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
  1445 CheckCOCOA()
  1446 {
  1447     AC_ARG_ENABLE(video-cocoa,
  1448 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
  1449                   , enable_video_cocoa=yes)
  1450     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  1451         save_CFLAGS="$CFLAGS"
  1452         dnl work around that we don't have Objective-C support in autoconf
  1453         CFLAGS="$CFLAGS -x objective-c"
  1454         AC_MSG_CHECKING(for Cocoa framework)
  1455         have_cocoa=no
  1456         AC_TRY_COMPILE([
  1457           #import <Cocoa/Cocoa.h>
  1458         ],[
  1459         ],[
  1460         have_cocoa=yes
  1461         ])
  1462         AC_MSG_RESULT($have_cocoa)
  1463         CFLAGS="$save_CFLAGS"
  1464         if test x$have_cocoa = xyes; then
  1465             AC_DEFINE(SDL_VIDEO_DRIVER_COCOA, 1, [ ])
  1466             SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
  1467             have_video=yes
  1468         fi
  1469     fi
  1470 }
  1471 
  1472 dnl Find DirectFB
  1473 CheckDirectFB()
  1474 {
  1475     AC_ARG_ENABLE(video-directfb,
  1476 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
  1477                   , enable_video_directfb=no)
  1478     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  1479         video_directfb=no
  1480 
  1481         DIRECTFB_REQUIRED_VERSION=1.0.0
  1482         AC_PATH_PROGS(DIRECTFBCONFIG, directfb-config, no, [$prefix/bin:$PATH])
  1483         if test x$DIRECTFBCONFIG = xno; then
  1484             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1485             if test x$PKG_CONFIG != xno; then
  1486                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
  1487                     DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
  1488                     DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
  1489                     DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
  1490                     video_directfb=yes
  1491                 fi
  1492             fi
  1493         else
  1494             set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
  1495             NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1496             set -- `$DIRECTFBCONFIG --version | sed 's/\./ /g'`
  1497             HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1498             if test $HAVE_VERSION -ge $NEED_VERSION; then
  1499                 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
  1500                 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
  1501                 DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
  1502                 video_directfb=yes
  1503             fi
  1504         fi
  1505         if test x$video_directfb = xyes; then
  1506             # SuSE 11.1 installs directfb-config without directfb-devel
  1507             save_CPPFLAGS="$CPPFLAGS"
  1508             CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
  1509             AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
  1510             CPPFLAGS="$save_CPPFLAGS"
  1511             video_directfb=$have_directfb_hdr
  1512         fi
  1513         AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  1514         AC_MSG_RESULT($video_directfb)
  1515 
  1516         if test x$video_directfb = xyes; then
  1517             AC_ARG_ENABLE(directfb-shared,
  1518 AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
  1519                               , enable_directfb_shared=yes)
  1520 
  1521             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB, 1, [ ])
  1522             AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB, 1, [ ])
  1523             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  1524             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  1525 
  1526             AC_MSG_CHECKING(for directfb dynamic loading support)
  1527             directfb_shared=no
  1528             directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS"`]
  1529             # | sed 's/.*\/\(.*\)/\1/; q'`]
  1530 AC_MSG_WARN("directfb $directfb_lib")
  1531             if test x$have_loadso != xyes && \
  1532                test x$enable_directfb_shared = xyes; then
  1533                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
  1534             fi
  1535             if test x$have_loadso = xyes && \
  1536                test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
  1537                 directfb_shared=yes
  1538                 echo "-- $directfb_lib_spec -> $directfb_lib"
  1539                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib", [ ])
  1540             else
  1541                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  1542             fi
  1543             AC_MSG_RESULT($directfb_shared)
  1544             have_video=yes
  1545         fi
  1546     fi
  1547 }
  1548 
  1549 dnl Find FusionSound
  1550 CheckFusionSound()
  1551 {
  1552     AC_ARG_ENABLE(fusionsound,
  1553 AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
  1554                   , enable_fusionsound=no)
  1555     if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
  1556         fusionsound=no
  1557 
  1558         FUSIONSOUND_REQUIRED_VERSION=1.1.1
  1559 
  1560         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1561         AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
  1562         if test x$PKG_CONFIG != xno; then
  1563             if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
  1564                 FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
  1565                 FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
  1566                 fusionsound=yes
  1567             fi
  1568         fi
  1569         AC_MSG_RESULT($fusionsound)
  1570 
  1571         if test x$fusionsound = xyes; then
  1572             AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND, 1, [ ])
  1573             SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
  1574             EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
  1575             
  1576             AC_ARG_ENABLE(fusionsound-shared,
  1577 AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
  1578                           , enable_fusionsound_shared=yes)
  1579             fusionsound_shared=no
  1580             AC_MSG_CHECKING(for FusionSound dynamic loading support)
  1581             if test x$have_loadso != xyes && \
  1582                test x$enable_fusionsound_shared = xyes; then
  1583                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
  1584             fi
  1585             if test x$have_loadso = xyes && \
  1586                test x$enable_fusionsound_shared = xyes; then
  1587                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so", [ ])
  1588                 fusionsound_shared=yes
  1589             else
  1590                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
  1591             fi
  1592             AC_MSG_RESULT($fusionsound_shared)
  1593             
  1594             have_audio=yes
  1595         fi
  1596     fi
  1597 }
  1598 
  1599 dnl rcg04172001 Set up the Null video driver.
  1600 CheckDummyVideo()
  1601 {
  1602     AC_ARG_ENABLE(video-dummy,
  1603 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  1604                   , enable_video_dummy=yes)
  1605     if test x$enable_video_dummy = xyes; then
  1606         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY, 1, [ ])
  1607         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1608         have_video=yes
  1609     fi
  1610 }
  1611 
  1612 dnl Check to see if OpenGL support is desired
  1613 AC_ARG_ENABLE(video-opengl,
  1614 AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  1615               , enable_video_opengl=yes)
  1616 
  1617 dnl Find OpenGL
  1618 CheckOpenGLX11()
  1619 {
  1620     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1621         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1622         video_opengl=no
  1623         AC_TRY_COMPILE([
  1624          #include <GL/gl.h>
  1625          #include <GL/glx.h>
  1626         ],[
  1627         ],[
  1628         video_opengl=yes
  1629         ])
  1630         AC_MSG_RESULT($video_opengl)
  1631         if test x$video_opengl = xyes; then
  1632             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1633             AC_DEFINE(SDL_VIDEO_OPENGL_GLX, 1, [ ])
  1634             AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1635         fi
  1636     fi
  1637 }
  1638 
  1639 dnl Check to see if OpenGL ES support is desired
  1640 AC_ARG_ENABLE(video-opengles,
  1641 AC_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]),
  1642               , enable_video_opengles=yes)
  1643 
  1644 dnl Find OpenGL ES
  1645 CheckOpenGLESX11()
  1646 {
  1647     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  1648         AC_MSG_CHECKING(for OpenGL ES (EGL) support)
  1649         video_opengles=no
  1650         AC_TRY_COMPILE([
  1651          #include <EGL/egl.h>
  1652         ],[
  1653         ],[
  1654         video_opengles=yes
  1655         ])
  1656         AC_MSG_RESULT($video_opengles)
  1657         if test x$video_opengles = xyes; then
  1658             AC_MSG_CHECKING(for OpenGL ES v1 headers)
  1659             video_opengles_v1=no
  1660             AC_TRY_COMPILE([
  1661              #include <GLES/gl.h>
  1662              #include <GLES/glext.h>
  1663             ],[
  1664             ],[
  1665             video_opengles_v1=yes
  1666             ])
  1667             AC_MSG_RESULT($video_opengles_v1)
  1668             if test x$video_opengles_v1 = xyes; then
  1669                 AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
  1670                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
  1671             fi
  1672             AC_MSG_CHECKING(for OpenGL ES v2 headers)
  1673             video_opengles_v2=no
  1674             AC_TRY_COMPILE([
  1675              #include <GLES2/gl2.h>
  1676              #include <GLES2/gl2ext.h>
  1677             ],[
  1678             ],[
  1679             video_opengles_v2=yes
  1680             ])
  1681             AC_MSG_RESULT($video_opengles_v2)
  1682             if test x$video_opengles_v2 = xyes; then
  1683                 AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  1684                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  1685             fi
  1686         fi
  1687     fi
  1688 }
  1689 
  1690 dnl Check for Windows OpenGL
  1691 CheckWINDOWSGL()
  1692 {
  1693     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1694         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1695         AC_DEFINE(SDL_VIDEO_OPENGL_WGL, 1, [ ])
  1696         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1697     fi
  1698 }
  1699 
  1700 dnl Check for BeOS OpenGL
  1701 CheckBeGL()
  1702 {
  1703     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1704         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1705         AC_DEFINE(SDL_VIDEO_OPENGL_BGL, 1, [ ])
  1706         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1707         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1708     fi
  1709 }
  1710 
  1711 dnl Check for MacOS OpenGL
  1712 CheckMacGL()
  1713 {
  1714     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1715         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  1716         AC_DEFINE(SDL_VIDEO_OPENGL_CGL, 1, [ ])
  1717         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  1718         case "$host" in
  1719             *-*-darwin*)
  1720                 if test x$enable_video_cocoa = xyes; then
  1721                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
  1722                 fi
  1723         esac
  1724     fi
  1725 }
  1726 
  1727 dnl See if we can use the new unified event interface in Linux 2.4
  1728 CheckInputEvents()
  1729 {
  1730     dnl Check for Linux 2.4 unified input event interface support
  1731         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  1732         use_input_events=no
  1733         AC_TRY_COMPILE([
  1734           #include <linux/input.h>
  1735         ],[
  1736           #ifndef EVIOCGNAME
  1737           #error EVIOCGNAME() ioctl not available
  1738           #endif
  1739         ],[
  1740         use_input_events=yes
  1741         ])
  1742         AC_MSG_RESULT($use_input_events)
  1743         if test x$use_input_events = xyes; then
  1744             AC_DEFINE(SDL_INPUT_LINUXEV, 1, [ ])
  1745         fi
  1746 }
  1747 
  1748 dnl See if the platform offers libudev for device enumeration and hotplugging.
  1749 CheckLibUDev()
  1750 {
  1751     AC_ARG_ENABLE(libudev,
  1752 AC_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
  1753                         , enable_libudev=yes)
  1754     if test x$enable_libudev = xyes; then
  1755         AC_CHECK_HEADER(libudev.h,
  1756                         have_libudev_h_hdr=yes,
  1757                         have_libudev_h_hdr=no)
  1758         if test x$have_libudev_h_hdr = xyes; then
  1759             AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])
  1760         fi
  1761     fi
  1762 }
  1763 
  1764 dnl See if the platform offers libdbus for various IPC techniques.
  1765 CheckDBus()
  1766 {
  1767     AC_ARG_ENABLE(dbus,
  1768 AC_HELP_STRING([--enable-dbus], [enable D-Bus support [[default=yes]]]),
  1769                         , enable_dbus=yes)
  1770     if test x$enable_dbus = xyes; then
  1771         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1772         if test x$PKG_CONFIG != xno; then
  1773             DBUS_CFLAGS=`$PKG_CONFIG --cflags dbus-1`
  1774             save_CFLAGS="$CFLAGS"
  1775             CFLAGS="$save_CFLAGS $DBUS_CFLAGS"
  1776             AC_CHECK_HEADER(dbus/dbus.h,
  1777                             have_dbus_dbus_h_hdr=yes,
  1778                             have_dbus_dbus_h_hdr=no)
  1779             CFLAGS="$save_CFLAGS"
  1780             if test x$have_dbus_dbus_h_hdr = xyes; then
  1781                 AC_DEFINE(HAVE_DBUS_DBUS_H, 1, [ ])
  1782                 EXTRA_CFLAGS="$EXTRA_CFLAGS $DBUS_CFLAGS"
  1783             fi
  1784         fi
  1785     fi
  1786 }
  1787 
  1788 dnl See if we can use the Touchscreen input library
  1789 CheckTslib()
  1790 {
  1791     AC_ARG_ENABLE(input-tslib,
  1792 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  1793                   , enable_input_tslib=yes)
  1794     if test x$enable_input_tslib = xyes; then
  1795         AC_MSG_CHECKING(for Touchscreen library support)
  1796         enable_input_tslib=no
  1797         AC_TRY_COMPILE([
  1798           #include "tslib.h"
  1799         ],[
  1800         ],[
  1801         enable_input_tslib=yes
  1802         ])
  1803         AC_MSG_RESULT($enable_input_tslib)
  1804         if test x$enable_input_tslib = xyes; then
  1805             AC_DEFINE(SDL_INPUT_TSLIB, 1, [ ])
  1806             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  1807         fi
  1808     fi
  1809 }
  1810 
  1811 dnl See what type of thread model to use on Linux and Solaris
  1812 CheckPTHREAD()
  1813 {
  1814     dnl Check for pthread support
  1815     AC_ARG_ENABLE(pthreads,
  1816 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  1817                   , enable_pthreads=yes)
  1818     dnl This is used on Linux for glibc binary compatibility (Doh!)
  1819     AC_ARG_ENABLE(pthread-sem,
  1820 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  1821                   , enable_pthread_sem=yes)
  1822     case "$host" in
  1823         *-*-linux*|*-*-uclinux*)
  1824             pthread_cflags="-D_REENTRANT"
  1825             pthread_lib="-lpthread"
  1826             ;;
  1827         *-*-bsdi*)
  1828             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1829             pthread_lib=""
  1830             ;;
  1831         *-*-darwin*)
  1832             pthread_cflags="-D_THREAD_SAFE"
  1833 # causes Carbon.p complaints?
  1834 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1835             ;;
  1836         *-*-freebsd*|*-*-dragonfly*)
  1837             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1838             pthread_lib="-pthread"
  1839             ;;
  1840         *-*-netbsd*)
  1841             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1842             pthread_lib="-lpthread"
  1843             ;;
  1844         *-*-openbsd*)
  1845             pthread_cflags="-D_REENTRANT"
  1846             pthread_lib="-pthread"
  1847             ;;
  1848         *-*-solaris2.9)
  1849             # From Solaris 9+, posix4's preferred name is rt.
  1850             pthread_cflags="-D_REENTRANT"
  1851             pthread_lib="-lpthread -lrt"
  1852             ;;
  1853         *-*-solaris2.10)
  1854             # Solaris 10+ merged pthread into libc.
  1855             pthread_cflags="-D_REENTRANT"
  1856             pthread_lib="-lrt"
  1857             ;;
  1858         *-*-solaris*)
  1859             # Solaris 11+ merged rt into libc.
  1860             pthread_cflags="-D_REENTRANT"
  1861             pthread_lib=""
  1862             ;;
  1863         *-*-sysv5*)
  1864             pthread_cflags="-D_REENTRANT -Kthread"
  1865             pthread_lib=""
  1866             ;;
  1867         *-*-aix*)
  1868             pthread_cflags="-D_REENTRANT -mthreads"
  1869             pthread_lib="-lpthread"
  1870             ;;
  1871         *-*-hpux11*)
  1872             pthread_cflags="-D_REENTRANT"
  1873             pthread_lib="-L/usr/lib -lpthread"
  1874             ;;
  1875         *)
  1876             pthread_cflags="-D_REENTRANT"
  1877             pthread_lib="-lpthread"
  1878             ;;
  1879     esac
  1880     if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
  1881         # Save the original compiler flags and libraries
  1882         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1883         # Add the pthread compiler flags and libraries
  1884         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1885         # Check to see if we have pthread support on this system
  1886         AC_MSG_CHECKING(for pthreads)
  1887         use_pthreads=no
  1888         AC_TRY_LINK([
  1889          #include <pthread.h>
  1890         ],[
  1891          pthread_attr_t type;
  1892          pthread_attr_init(&type);
  1893         ],[
  1894         use_pthreads=yes
  1895         ])
  1896         AC_MSG_RESULT($use_pthreads)
  1897         # Restore the compiler flags and libraries
  1898         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1899 
  1900         # Do futher testing if we have pthread support...
  1901         if test x$use_pthreads = xyes; then
  1902             AC_DEFINE(SDL_THREAD_PTHREAD, 1, [ ])
  1903             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  1904             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  1905             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  1906             SDL_LIBS="$SDL_LIBS $pthread_lib"
  1907 
  1908             # Save the original compiler flags and libraries
  1909             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1910             # Add the pthread compiler flags and libraries
  1911             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1912 
  1913             # Check to see if recursive mutexes are available
  1914             AC_MSG_CHECKING(for recursive mutexes)
  1915             has_recursive_mutexes=no
  1916             if test x$has_recursive_mutexes = xno; then
  1917                 AC_TRY_COMPILE([
  1918                   #include <pthread.h>
  1919                 ],[
  1920                   pthread_mutexattr_t attr;
  1921                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  1922                 ],[
  1923                 has_recursive_mutexes=yes
  1924                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX, 1, [ ])
  1925                 ])
  1926             fi
  1927             if test x$has_recursive_mutexes = xno; then
  1928                 AC_TRY_COMPILE([
  1929                   #include <pthread.h>
  1930                 ],[
  1931                   pthread_mutexattr_t attr;
  1932                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  1933                 ],[
  1934                 has_recursive_mutexes=yes
  1935                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP, 1, [ ])
  1936                 ])
  1937             fi
  1938             AC_MSG_RESULT($has_recursive_mutexes)
  1939 
  1940             # Check to see if pthread semaphore support is missing
  1941             if test x$enable_pthread_sem = xyes; then
  1942                 AC_MSG_CHECKING(for pthread semaphores)
  1943                 have_pthread_sem=no
  1944                 AC_TRY_COMPILE([
  1945                   #include <pthread.h>
  1946                   #include <semaphore.h>
  1947                 ],[
  1948                 ],[
  1949                 have_pthread_sem=yes
  1950                 ])
  1951                 AC_MSG_RESULT($have_pthread_sem)
  1952             fi
  1953             if test x$have_pthread_sem = xyes; then
  1954                 AC_MSG_CHECKING(for sem_timedwait)
  1955                 have_sem_timedwait=no
  1956                 AC_TRY_LINK([
  1957                   #include <pthread.h>
  1958                   #include <semaphore.h>
  1959                 ],[
  1960                   sem_timedwait(NULL, NULL);
  1961                 ],[
  1962                 have_sem_timedwait=yes
  1963                 AC_DEFINE(HAVE_SEM_TIMEDWAIT)
  1964                 ])
  1965                 AC_MSG_RESULT($have_sem_timedwait)
  1966             fi
  1967 
  1968             AC_MSG_CHECKING(for pthread_spin_trylock)
  1969             AC_TRY_LINK_FUNC(pthread_spin_trylock, [
  1970               has_pthread_spin_trylock=yes
  1971               AC_DEFINE(HAVE_PTHREAD_SPINLOCK, 1, [ ])
  1972             ],[
  1973               has_pthread_spin_trylock=no
  1974             ])
  1975             AC_MSG_RESULT($has_pthread_spin_trylock)
  1976 
  1977             AC_CHECK_HEADER(pthread_np.h, have_pthread_np_h=yes, have_pthread_np_h=no, [ #include <pthread.h> ])
  1978             if test x$have_pthread_np_h = xyes; then
  1979                 AC_DEFINE(HAVE_PTHREAD_NP_H, 1, [ ])
  1980             fi
  1981 
  1982             # Check to see if pthread naming is available
  1983             AC_MSG_CHECKING(for pthread_setname_np)
  1984             AC_TRY_LINK_FUNC(pthread_setname_np, [
  1985               has_pthread_setname_np=yes
  1986               AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [ ])
  1987             ],[
  1988               has_pthread_setname_np=no
  1989             ])
  1990             AC_MSG_RESULT($has_pthread_setname_np)
  1991 
  1992             AC_MSG_CHECKING(for pthread_set_name_np)
  1993             AC_TRY_LINK_FUNC(pthread_set_name_np, [
  1994               has_pthread_set_name_np=yes
  1995               AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [ ])
  1996             ],[
  1997               has_pthread_set_name_np=no
  1998             ])
  1999             AC_MSG_RESULT($has_pthread_set_name_np)
  2000 
  2001             # Restore the compiler flags and libraries
  2002             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  2003 
  2004             # Basic thread creation functions
  2005             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  2006 
  2007             # Semaphores
  2008             # We can fake these with mutexes and condition variables if necessary
  2009             if test x$have_pthread_sem = xyes; then
  2010                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  2011             else
  2012                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  2013             fi
  2014 
  2015             # Mutexes
  2016             # We can fake these with semaphores if necessary
  2017             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  2018 
  2019             # Condition variables
  2020             # We can fake these with semaphores and mutexes if necessary
  2021             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  2022 
  2023             # Thread local storage
  2024             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systls.c"
  2025 
  2026             have_threads=yes
  2027         fi
  2028     fi
  2029 }
  2030 
  2031 dnl Determine whether the compiler can produce Windows executables
  2032 CheckWINDOWS()
  2033 {
  2034     AC_MSG_CHECKING(Windows compiler)
  2035     have_win32_gcc=no
  2036     AC_TRY_COMPILE([
  2037      #include <windows.h>
  2038     ],[
  2039     ],[
  2040     have_win32_gcc=yes
  2041     ])
  2042     AC_MSG_RESULT($have_win32_gcc)
  2043     if test x$have_win32_gcc != xyes; then
  2044        AC_MSG_ERROR([
  2045 *** Your compiler ($CC) does not produce Windows executables!
  2046        ])
  2047     fi
  2048 
  2049     AC_MSG_CHECKING(Windows CE)
  2050     have_wince=no
  2051     AC_TRY_COMPILE([
  2052 #if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
  2053 #error This is not Windows CE
  2054 #endif
  2055     ],[
  2056     ],[
  2057     have_wince=yes
  2058        AC_MSG_ERROR([
  2059 *** Sorry, Windows CE is no longer supported.
  2060        ])
  2061     ])
  2062     AC_MSG_RESULT($have_wince)
  2063 
  2064     # This fixes Windows stack alignment with newer GCC
  2065     CheckStackBoundary
  2066 }
  2067 
  2068 dnl Find the DirectX includes and libraries
  2069 CheckDIRECTX()
  2070 {
  2071     AC_ARG_ENABLE(directx,
  2072 AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
  2073                   , enable_directx=yes)
  2074     if test x$enable_directx = xyes; then
  2075         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  2076         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  2077         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  2078         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  2079         AC_CHECK_HEADER(xaudio2.h, have_xaudio2=yes)
  2080 
  2081         # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
  2082         # FIXME:  ...so force it off for now.
  2083         case "$host" in
  2084             *-*-cygwin*)
  2085             have_dinput=false
  2086             ;;
  2087         esac
  2088     fi
  2089 }
  2090 
  2091 dnl Check for the dlfcn.h interface for dynamically loading objects
  2092 CheckDLOPEN()
  2093 {
  2094     AC_ARG_ENABLE(sdl-dlopen,
  2095 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  2096                   , enable_sdl_dlopen=yes)
  2097     if test x$enable_sdl_dlopen = xyes; then
  2098         AC_MSG_CHECKING(for dlopen)
  2099         have_dlopen=no
  2100         AC_TRY_COMPILE([
  2101          #include <dlfcn.h>
  2102         ],[
  2103          #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
  2104          #error Use dlcompat for Mac OS X 10.2 compatibility
  2105          #endif
  2106         ],[
  2107         have_dlopen=yes
  2108         ])
  2109         AC_MSG_RESULT($have_dlopen)
  2110 
  2111         if test x$have_dlopen = xyes; then
  2112             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  2113                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  2114                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  2115             AC_DEFINE(SDL_LOADSO_DLOPEN, 1, [ ])
  2116             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  2117             have_loadso=yes
  2118         fi
  2119     fi
  2120 }
  2121 
  2122 dnl Check for the usbhid(3) library on *BSD
  2123 CheckUSBHID()
  2124 {
  2125     if test x$enable_joystick = xyes; then
  2126         AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  2127         if test x$have_libusbhid = xyes; then
  2128             AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  2129             AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  2130             USB_LIBS="$USB_LIBS -lusbhid"
  2131         else
  2132             AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  2133             AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  2134             AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  2135         fi
  2136             
  2137         save_CFLAGS="$CFLAGS"
  2138         CFLAGS="$CFLAGS $USB_CFLAGS"
  2139 
  2140         AC_MSG_CHECKING(for usbhid)
  2141         have_usbhid=no
  2142         AC_TRY_COMPILE([
  2143           #include <sys/types.h>
  2144           #if defined(HAVE_USB_H)
  2145           #include <usb.h>
  2146           #endif
  2147           #ifdef __DragonFly__
  2148           # include <bus/usb/usb.h>
  2149           # include <bus/usb/usbhid.h>
  2150           #else
  2151           # include <dev/usb/usb.h>
  2152           # include <dev/usb/usbhid.h>
  2153           #endif
  2154           #if defined(HAVE_USBHID_H)
  2155           #include <usbhid.h>
  2156           #elif defined(HAVE_LIBUSB_H)
  2157           #include <libusb.h>
  2158           #elif defined(HAVE_LIBUSBHID_H)
  2159           #include <libusbhid.h>
  2160           #endif
  2161         ],[
  2162           struct report_desc *repdesc;
  2163           struct usb_ctl_report *repbuf;
  2164           hid_kind_t hidkind;
  2165         ],[
  2166         have_usbhid=yes
  2167         ])
  2168         AC_MSG_RESULT($have_usbhid)
  2169 
  2170         if test x$have_usbhid = xyes; then
  2171             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  2172             have_usbhid_ucr_data=no
  2173             AC_TRY_COMPILE([
  2174               #include <sys/types.h>
  2175               #if defined(HAVE_USB_H)
  2176               #include <usb.h>
  2177               #endif
  2178               #ifdef __DragonFly__
  2179               # include <bus/usb/usb.h>
  2180               # include <bus/usb/usbhid.h>
  2181               #else
  2182               # include <dev/usb/usb.h>
  2183               # include <dev/usb/usbhid.h>
  2184               #endif
  2185               #if defined(HAVE_USBHID_H)
  2186               #include <usbhid.h>
  2187               #elif defined(HAVE_LIBUSB_H)
  2188               #include <libusb.h>
  2189               #elif defined(HAVE_LIBUSBHID_H)
  2190               #include <libusbhid.h>
  2191               #endif
  2192             ],[
  2193               struct usb_ctl_report buf;
  2194               if (buf.ucr_data) { }
  2195             ],[
  2196             have_usbhid_ucr_data=yes
  2197             ])
  2198             if test x$have_usbhid_ucr_data = xyes; then
  2199                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  2200             fi
  2201             AC_MSG_RESULT($have_usbhid_ucr_data)
  2202             
  2203             AC_MSG_CHECKING(for new usbhid API)
  2204             have_usbhid_new=no
  2205             AC_TRY_COMPILE([
  2206               #include <sys/types.h>
  2207               #if defined(HAVE_USB_H)
  2208               #include <usb.h>
  2209               #endif
  2210               #ifdef __DragonFly__
  2211               #include <bus/usb/usb.h>
  2212               #include <bus/usb/usbhid.h>
  2213               #else
  2214               #include <dev/usb/usb.h>
  2215               #include <dev/usb/usbhid.h>
  2216               #endif
  2217               #if defined(HAVE_USBHID_H)
  2218               #include <usbhid.h>
  2219               #elif defined(HAVE_LIBUSB_H)
  2220               #include <libusb.h>
  2221               #elif defined(HAVE_LIBUSBHID_H)
  2222               #include <libusbhid.h>
  2223               #endif
  2224             ],[
  2225               report_desc_t d;
  2226               hid_start_parse(d, 1, 1);
  2227             ],[
  2228             have_usbhid_new=yes
  2229             ])
  2230             if test x$have_usbhid_new = xyes; then
  2231                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  2232             fi
  2233             AC_MSG_RESULT($have_usbhid_new)
  2234 
  2235             AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  2236             have_machine_joystick=no
  2237             AC_TRY_COMPILE([
  2238               #include <machine/joystick.h>
  2239             ],[
  2240               struct joystick t;
  2241             ],[
  2242             have_machine_joystick=yes
  2243             ])
  2244             if test x$have_machine_joystick = xyes; then
  2245                 AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
  2246             fi
  2247             AC_MSG_RESULT($have_machine_joystick)
  2248 
  2249             AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
  2250             SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  2251             EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  2252             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  2253             have_joystick=yes
  2254         fi
  2255         CFLAGS="$save_CFLAGS"
  2256     fi
  2257 }
  2258 
  2259 dnl Check for clock_gettime()
  2260 CheckClockGettime()
  2261 {
  2262     AC_ARG_ENABLE(clock_gettime,
  2263 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=yes]]]),
  2264                   , enable_clock_gettime=yes)
  2265     if test x$enable_clock_gettime = xyes; then
  2266         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  2267         if test x$have_clock_gettime = xyes; then
  2268             AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  2269             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  2270         else
  2271             AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
  2272             if test x$have_clock_gettime = xyes; then
  2273                AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  2274                EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
  2275             fi
  2276         fi
  2277     fi
  2278 }
  2279 
  2280 dnl Check for a valid linux/version.h
  2281 CheckLinuxVersion()
  2282 {
  2283     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  2284     if test x$have_linux_version_h = xyes; then
  2285         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  2286     fi
  2287 }
  2288 
  2289 dnl Check if we want to use RPATH
  2290 CheckRPATH()
  2291 {
  2292     AC_ARG_ENABLE(rpath,
  2293 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  2294                   , enable_rpath=yes)
  2295 }
  2296 
  2297 dnl Set up the configuration based on the host platform!
  2298 case "$host" in
  2299     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*)
  2300         case "$host" in
  2301             *-*-linux*)         ARCH=linux ;;
  2302             *-*-uclinux*)       ARCH=linux ;;
  2303             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  2304             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  2305             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  2306             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  2307             *-*-bsdi*)          ARCH=bsdi ;;
  2308             *-*-freebsd*)       ARCH=freebsd ;;
  2309             *-*-dragonfly*)     ARCH=freebsd ;;
  2310             *-*-netbsd*)        ARCH=netbsd ;;
  2311             *-*-openbsd*)       ARCH=openbsd ;;
  2312             *-*-sysv5*)         ARCH=sysv5 ;;
  2313             *-*-solaris*)       ARCH=solaris ;;
  2314             *-*-hpux*)          ARCH=hpux ;;
  2315             *-*-aix*)           ARCH=aix ;;
  2316             *-*-minix*)         ARCH=minix ;;
  2317         esac
  2318         CheckVisibilityHidden
  2319         CheckDummyVideo
  2320         CheckDiskAudio
  2321         CheckDummyAudio
  2322         CheckDLOPEN
  2323         CheckOSS
  2324         CheckALSA
  2325         CheckPulseAudio
  2326         CheckARTSC
  2327         CheckESD
  2328         CheckNAS
  2329         CheckSNDIO
  2330         CheckX11
  2331         CheckDirectFB
  2332         CheckFusionSound
  2333         CheckOpenGLX11
  2334         CheckOpenGLESX11
  2335         CheckLibUDev
  2336         CheckDBus
  2337         CheckInputEvents
  2338         CheckTslib
  2339         CheckUSBHID
  2340         CheckPTHREAD
  2341         CheckClockGettime
  2342         CheckLinuxVersion
  2343         CheckRPATH
  2344         # Set up files for the audio library
  2345         if test x$enable_audio = xyes; then
  2346           case $ARCH in
  2347             sysv5|solaris|hpux)
  2348                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
  2349                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2350                 have_audio=yes
  2351             ;;
  2352             netbsd)  # Don't use this on OpenBSD, it's busted.
  2353                 AC_DEFINE(SDL_AUDIO_DRIVER_BSD, 1, [ ])
  2354                 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
  2355                 have_audio=yes
  2356             ;;
  2357             aix)
  2358                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO, 1, [ ])
  2359                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  2360                 have_audio=yes
  2361             ;;
  2362           esac
  2363         fi
  2364         # Set up files for the joystick library
  2365         if test x$enable_joystick = xyes; then
  2366           case $ARCH in
  2367             linux)
  2368                 AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ])
  2369                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  2370                 have_joystick=yes
  2371             ;;
  2372           esac
  2373         fi
  2374         # Set up files for the haptic library
  2375         if test x$enable_haptic = xyes; then
  2376            if test x$use_input_events = xyes; then
  2377              case $ARCH in
  2378                linux)
  2379                    AC_DEFINE(SDL_HAPTIC_LINUX, 1, [ ])
  2380                    SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  2381                    have_haptic=yes
  2382                ;;
  2383              esac
  2384            fi
  2385         fi
  2386         # Set up files for the power library
  2387         if test x$enable_power = xyes; then
  2388              case $ARCH in
  2389                linux)
  2390                    AC_DEFINE(SDL_POWER_LINUX, 1, [ ])
  2391                    SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
  2392                    have_power=yes
  2393                ;;
  2394              esac
  2395         fi
  2396         # Set up files for the timer library
  2397         if test x$enable_timers = xyes; then
  2398             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  2399             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2400             have_timers=yes
  2401         fi
  2402         ;;
  2403     *-*-cygwin* | *-*-mingw32*)
  2404         ARCH=win32
  2405         if test "$build" != "$host"; then # cross-compiling
  2406             # Default cross-compile location
  2407             ac_default_prefix=/usr/local/cross-tools/$host
  2408         else
  2409             # Look for the location of the tools and install there
  2410             if test "$BUILD_PREFIX" != ""; then
  2411                 ac_default_prefix=$BUILD_PREFIX
  2412             fi
  2413         fi
  2414         CheckDummyVideo
  2415         CheckDiskAudio
  2416         CheckDummyAudio
  2417         CheckWINDOWS
  2418         CheckWINDOWSGL
  2419         CheckDIRECTX
  2420 
  2421         # Set up the core platform files
  2422         SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
  2423 
  2424         # Set up files for the video library
  2425         if test x$enable_video = xyes; then
  2426             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS, 1, [ ])
  2427             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
  2428             have_video=yes
  2429             AC_ARG_ENABLE(render-d3d,
  2430 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2431                                 , enable_render_d3d=yes)
  2432             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2433                 AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ])
  2434             fi
  2435         fi
  2436         # Set up files for the audio library
  2437         if test x$enable_audio = xyes; then
  2438             AC_DEFINE(SDL_AUDIO_DRIVER_WINMM, 1, [ ])
  2439             SOURCES="$SOURCES $srcdir/src/audio/winmm/*.c"
  2440             if test x$have_dsound = xyes; then
  2441                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
  2442                 SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
  2443             fi
  2444             if test x$have_xaudio2 = xyes; then
  2445                 AC_DEFINE(SDL_AUDIO_DRIVER_XAUDIO2, 1, [ ])
  2446                 SOURCES="$SOURCES $srcdir/src/audio/xaudio2/*.c"
  2447             fi
  2448             have_audio=yes
  2449         fi
  2450         # Set up files for the joystick library
  2451         if test x$enable_joystick = xyes; then
  2452             if test x$have_dinput = xyes; then
  2453                 AC_DEFINE(SDL_JOYSTICK_DINPUT, 1, [ ])
  2454                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_dxjoystick.c"
  2455                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
  2456             else
  2457                 AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
  2458                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_mmjoystick.c"
  2459             fi
  2460             have_joystick=yes
  2461         fi
  2462         if test x$enable_haptic = xyes; then
  2463             if test x$have_dinput = xyes; then
  2464                 AC_DEFINE(SDL_HAPTIC_DINPUT, 1, [ ])
  2465                 SOURCES="$SOURCES $srcdir/src/haptic/windows/SDL_syshaptic.c"
  2466                 have_haptic=yes
  2467             fi
  2468         fi
  2469         if test x$enable_power = xyes; then
  2470             AC_DEFINE(SDL_POWER_WINDOWS, 1, [ ])
  2471             SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
  2472             have_power=yes
  2473         fi
  2474         # Set up files for the thread library
  2475         if test x$enable_threads = xyes; then
  2476             AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ])
  2477             SOURCES="$SOURCES $srcdir/src/thread/windows/*.c"
  2478             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2479             have_threads=yes
  2480         fi
  2481         # Set up files for the timer library
  2482         if test x$enable_timers = xyes; then
  2483             AC_DEFINE(SDL_TIMER_WINDOWS, 1, [ ])
  2484             SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
  2485             have_timers=yes
  2486         fi
  2487         # Set up files for the shared object loading library
  2488         if test x$enable_loadso = xyes; then
  2489             AC_DEFINE(SDL_LOADSO_WINDOWS, 1, [ ])
  2490             SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
  2491             have_loadso=yes
  2492         fi
  2493         # Set up the system libraries we need
  2494         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -XCClinker -static-libgcc"
  2495         # The Windows platform requires special setup
  2496         VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
  2497         SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
  2498         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2499         SDL_LIBS="-lmingw32 -lSDL2main $SDL_LIBS -mwindows"
  2500         ;;
  2501     *-*-beos* | *-*-haiku*)
  2502         ARCH=beos
  2503         ac_default_prefix=/boot/common
  2504         CheckDummyVideo
  2505         CheckDiskAudio
  2506         CheckDummyAudio
  2507         CheckBWINDOW
  2508         CheckBeGL
  2509         # Set up files for the audio library
  2510         if test x$enable_audio = xyes; then
  2511             AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO, 1, [ ])
  2512             SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
  2513             have_audio=yes
  2514         fi
  2515         # Set up files for the joystick library
  2516         if test x$enable_joystick = xyes; then
  2517             AC_DEFINE(SDL_JOYSTICK_BEOS, 1, [ ])
  2518             SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
  2519             have_joystick=yes
  2520         fi
  2521         # Set up files for the thread library
  2522         if test x$enable_threads = xyes; then
  2523             AC_DEFINE(SDL_THREAD_BEOS, 1, [ ])
  2524             SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
  2525             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2526             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2527             have_threads=yes
  2528         fi
  2529         # Set up files for the timer library
  2530         if test x$enable_timers = xyes; then
  2531             AC_DEFINE(SDL_TIMER_BEOS, 1, [ ])
  2532             SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
  2533             have_timers=yes
  2534         fi
  2535         # Set up files for the shared object loading library
  2536         if test x$enable_loadso = xyes; then
  2537             AC_DEFINE(SDL_LOADSO_BEOS, 1, [ ])
  2538             SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
  2539             have_loadso=yes
  2540         fi
  2541         # Set up files for the system power library
  2542         if test x$enable_power = xyes; then
  2543             AC_DEFINE(SDL_POWER_BEOS, 1, [ ])
  2544             SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
  2545             have_power=yes
  2546         fi
  2547         # The BeOS platform requires special setup.
  2548         SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
  2549         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2550         ;;
  2551     arm*-apple-darwin*)
  2552         # iOS - We are not writing anything to confdefs.h because you have to replace
  2553         # SDL_config.h for SDL_config_iphoneos.h anyway
  2554         ARCH=ios
  2555 
  2556         CheckVisibilityHidden
  2557         CheckDummyVideo
  2558         CheckDiskAudio
  2559         CheckDummyAudio
  2560         CheckDLOPEN
  2561         CheckCOCOA
  2562         CheckPTHREAD
  2563 
  2564 
  2565         # Set up files for the audio library
  2566         if test x$enable_audio = xyes; then
  2567             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.c"
  2568             have_audio=yes
  2569         fi
  2570         # Set up files for the joystick library
  2571         if test x$enable_joystick = xyes; then
  2572             SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
  2573             have_joystick=yes
  2574         fi
  2575         # Set up files for the haptic library
  2576         #if test x$enable_haptic = xyes; then
  2577         #    SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2578         #    have_haptic=yes
  2579         #    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2580         #fi
  2581         # Set up files for the power library
  2582         if test x$enable_power = xyes; then
  2583             SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
  2584             have_power=yes
  2585         fi
  2586         # Set up files for the timer library
  2587         if test x$enable_timers = xyes; then
  2588             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2589             have_timers=yes
  2590         fi
  2591         # Set up additional files for the file library
  2592         if test x$enable_file = xyes; then
  2593             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  2594         fi
  2595         # The iOS platform requires special setup.
  2596         SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
  2597         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2598         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
  2599         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
  2600         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
  2601         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
  2602         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
  2603         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
  2604         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
  2605         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
  2606         ;;
  2607     *-*-darwin* )
  2608         # This could be either full "Mac OS X", or plain "Darwin" which is
  2609         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2610         # Next line is broken, and a few files below require Mac OS X (full)
  2611         ARCH=macosx
  2612 
  2613         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  2614         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  2615         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  2616 
  2617         CheckVisibilityHidden
  2618         CheckDummyVideo
  2619         CheckDiskAudio
  2620         CheckDummyAudio
  2621         CheckDLOPEN
  2622         CheckCOCOA
  2623         CheckX11
  2624         CheckMacGL
  2625         CheckOpenGLX11
  2626         CheckPTHREAD
  2627 
  2628         # Good optimization on Mac OS X, yes...
  2629         EXTRA_CFLAGS="$EXTRA_CFLAGS -falign-loops=16"
  2630 
  2631         # Need this or things might misbuild on a G3.
  2632         EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
  2633 
  2634         # Set up files for the audio library
  2635         if test x$enable_audio = xyes; then
  2636             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
  2637             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.c"
  2638             have_audio=yes
  2639         fi
  2640         # Set up files for the joystick library
  2641         if test x$enable_joystick = xyes; then
  2642             AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
  2643             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  2644             have_joystick=yes
  2645         fi
  2646         # Set up files for the haptic library
  2647         if test x$enable_haptic = xyes; then
  2648             AC_DEFINE(SDL_HAPTIC_IOKIT, 1, [ ])
  2649             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2650             have_haptic=yes
  2651             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2652         fi
  2653         # Set up files for the power library
  2654         if test x$enable_power = xyes; then
  2655             AC_DEFINE(SDL_POWER_MACOSX, 1, [ ])
  2656             SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
  2657             have_power=yes
  2658         fi
  2659         # Set up files for the timer library
  2660         if test x$enable_timers = xyes; then
  2661             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  2662             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2663             have_timers=yes
  2664         fi
  2665         # Set up additional files for the file library
  2666         if test x$enable_file = xyes; then
  2667             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  2668         fi
  2669         # The Mac OS X platform requires special setup.
  2670         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2671         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
  2672         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  2673         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  2674         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  2675         # If audio is used, add the AudioUnit framework
  2676         if test x$enable_audio = xyes; then
  2677             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
  2678         fi
  2679         ;;
  2680     *)
  2681         AC_MSG_ERROR([
  2682 *** Unsupported host:  Please add to configure.in
  2683         ])
  2684         ;;
  2685 esac
  2686 
  2687 dnl Do this on all platforms, after everything else.
  2688 CheckWarnAll
  2689 
  2690 # Verify that we have all the platform specific files we need
  2691 
  2692 if test x$have_joystick != xyes; then
  2693     if test x$enable_joystick = xyes; then
  2694         AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
  2695     fi
  2696     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2697 fi
  2698 if test x$have_haptic != xyes; then
  2699     if test x$enable_haptic = xyes; then
  2700         AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
  2701     fi
  2702     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2703 fi
  2704 if test x$have_threads != xyes; then
  2705     if test x$enable_threads = xyes; then
  2706         AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
  2707     fi
  2708     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  2709 fi
  2710 if test x$have_timers != xyes; then
  2711     if test x$enable_timers = xyes; then
  2712         AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ])
  2713     fi
  2714     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  2715 fi
  2716 if test x$have_loadso != xyes; then
  2717     if test x$enable_loadso = xyes; then
  2718         AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
  2719     fi
  2720     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  2721 fi
  2722 if test x$SDLMAIN_SOURCES = x; then
  2723     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  2724 fi
  2725 SDLTEST_SOURCES="$srcdir/src/test/*.c"
  2726 
  2727 OBJECTS=`echo $SOURCES`
  2728 DEPENDS=`echo $SOURCES | tr ' ' '\n'`
  2729 for EXT in asm cc m c S; do
  2730     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
  2731     DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
  2732 \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
  2733 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2734 done
  2735 
  2736 VERSION_OBJECTS=`echo $VERSION_SOURCES`
  2737 VERSION_DEPENDS=`echo $VERSION_SOURCES`
  2738 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  2739 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
  2740 \\$(objects)/\\2.o: \\1/\\2.rc\\\\
  2741 	\\$(WINDRES) \\$< \\$@,g"`
  2742 
  2743 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
  2744 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
  2745 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2746 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  2747 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  2748 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2749 
  2750 SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
  2751 SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
  2752 SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2753 SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  2754 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  2755 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2756 
  2757 # Set runtime shared library paths as needed
  2758 
  2759 if test "x$enable_rpath" = "xyes"; then
  2760   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
  2761     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  2762   fi
  2763   if test $ARCH = solaris; then
  2764     SDL_RLD_FLAGS="-R\${libdir}"
  2765   fi
  2766 else
  2767   SDL_RLD_FLAGS=""
  2768 fi
  2769 
  2770 SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  2771 
  2772 dnl Expand the cflags and libraries needed by apps using SDL
  2773 AC_SUBST(SDL_CFLAGS)
  2774 AC_SUBST(SDL_LIBS)
  2775 AC_SUBST(SDL_STATIC_LIBS)
  2776 AC_SUBST(SDL_RLD_FLAGS)
  2777 if test x$enable_shared = xyes; then
  2778     ENABLE_SHARED_TRUE=
  2779     ENABLE_SHARED_FALSE="#"
  2780 else
  2781     ENABLE_SHARED_TRUE="#"
  2782     ENABLE_SHARED_FALSE=
  2783 fi
  2784 if test x$enable_static = xyes; then
  2785     ENABLE_STATIC_TRUE=
  2786     ENABLE_STATIC_FALSE="#"
  2787 else
  2788     ENABLE_STATIC_TRUE="#"
  2789     ENABLE_STATIC_FALSE=
  2790 fi
  2791 AC_SUBST(ENABLE_SHARED_TRUE)
  2792 AC_SUBST(ENABLE_SHARED_FALSE)
  2793 AC_SUBST(ENABLE_STATIC_TRUE)
  2794 AC_SUBST(ENABLE_STATIC_FALSE)
  2795 
  2796 dnl Expand the sources and objects needed to build the library
  2797 AC_SUBST(ac_aux_dir)
  2798 AC_SUBST(INCLUDE)
  2799 AC_SUBST(OBJECTS)
  2800 AC_SUBST(VERSION_OBJECTS)
  2801 AC_SUBST(SDLMAIN_OBJECTS)
  2802 AC_SUBST(SDLTEST_OBJECTS)
  2803 AC_SUBST(BUILD_CFLAGS)
  2804 AC_SUBST(EXTRA_CFLAGS)
  2805 AC_SUBST(BUILD_LDFLAGS)
  2806 AC_SUBST(EXTRA_LDFLAGS)
  2807 AC_SUBST(WINDRES)
  2808 
  2809 cat >Makefile.rules <<__EOF__
  2810 
  2811 # Build rules for objects
  2812 -include \$(OBJECTS:.lo=.d)
  2813 
  2814 # Special dependency for SDL.c, since it depends on SDL_revision.h
  2815 $srcdir/src/SDL.c: update-revision
  2816 $DEPENDS
  2817 $VERSION_DEPENDS
  2818 $SDLMAIN_DEPENDS
  2819 $SDLTEST_DEPENDS
  2820 __EOF__
  2821 
  2822 AC_CONFIG_FILES([
  2823     Makefile:Makefile.in:Makefile.rules sdl2-config SDL2.spec sdl2.pc
  2824 ])
  2825 AC_OUTPUT
  2826 chmod a+x sdl2-config