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