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