configure.in
author Ryan C. Gordon <icculus@icculus.org>
Wed, 01 Aug 2012 21:41:54 -0400
changeset 6385 f909e1dab4e2
parent 6378 58c9e692aec5
child 6408 6fb90a109d83
permissions -rw-r--r--
OpenBSD: Add missing X11 libraries to autoconf.

Fixes Bugzilla #1551.

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