configure.in
author Jørgen P. Tjernø <jorgen@valvesoftware.com>
Wed, 05 Jun 2013 12:48:44 -0700
changeset 7277 1290cd7f34af
parent 7272 c502531983c7
child 7300 ee9c13257398
permissions -rw-r--r--
Mac: Fix invalid PS3 controller mapping.

PS3 controller had swapped D-Pad down & left buttons, as well as X & Y buttons.
Thanks to Alex Szpakowski for the bug report and fix.

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