configure.in
author Ryan C. Gordon <icculus@icculus.org>
Sat, 15 Sep 2012 10:59:39 -0400
changeset 6430 48d519500f7e
parent 6408 6fb90a109d83
child 6431 1f9c0e93bd96
permissions -rw-r--r--
Removed Windows CE support from SDL 2.0.

It's a long-dead platform, and we don't have any way to build for, test, or
maintain it, so there's no sense in doing acrobatics to support it.

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