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