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