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