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