configure.in
author Ryan C. Gordon <icculus@icculus.org>
Tue, 11 Dec 2012 11:07:48 -0500
changeset 6729 fdaeea9e7567
parent 6688 ba31830f0912
child 6734 7fdaee2be782
permissions -rw-r--r--
Removed old Linux joystick API (/dev/js*).

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