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