configure.in
author Sam Lantinga <slouken@libsdl.org>
Fri, 21 Jan 2011 12:43:25 -0800
changeset 5066 3afb71c202b2
parent 5062 e8916fe9cfc8
child 5068 231dbbc3e31c
permissions -rw-r--r--
Fixed bug #945

The configure script was breaking the substitutions into multiple fragments, breaking them across the substitution for the build rules. This of course totally hosed the process.

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