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