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