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