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