configure.in
author Sam Lantinga <slouken@libsdl.org>
Sun, 07 Dec 2008 23:25:39 +0000
changeset 2856 c765f5fa4a2c
parent 2820 33ddad305f3d
child 2857 5e04bdd79479
permissions -rw-r--r--
Default SSE2 off on iX86, since gcc will use it for floating point operations
even if -mfpmath=387 is set. Grr...
     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             X_CFLAGS="$X_CFLAGS -DXTHREADS"
  1064             if test x$ac_cv_func_shmat != xyes; then
  1065                 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
  1066             fi
  1067             CFLAGS="$CFLAGS $X_CFLAGS"
  1068             LDFLAGS="$LDFLAGS $X_LIBS"
  1069 
  1070             AC_DEFINE(SDL_VIDEO_DRIVER_X11)
  1071             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
  1072             SOURCES="$SOURCES $srcdir/src/video/Xext/XmuStdCmap/*.c"
  1073             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
  1074 
  1075             if test x$enable_x11_shared = xmaybe; then
  1076                 enable_x11_shared=$x11_symbols_private
  1077             fi
  1078             if test x$have_loadso != xyes && \
  1079                test x$enable_x11_shared = xyes; then
  1080                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
  1081                 enable_x11_shared=no
  1082             fi
  1083             if test x$x11_symbols_private != xyes && \
  1084                test x$enable_x11_shared = xyes; then
  1085                 AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
  1086                 enable_x11_shared=no
  1087             fi
  1088 
  1089             if test x$have_loadso = xyes && \
  1090                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
  1091                 echo "-- dynamic libX11 -> $x11_lib"
  1092                 echo "-- dynamic libX11ext -> $x11ext_lib"
  1093                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib")
  1094                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib")
  1095             else
  1096                 enable_x11_shared=no
  1097                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
  1098             fi
  1099             have_video=yes
  1100 
  1101             AC_ARG_ENABLE(video-x11-vm,
  1102 AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
  1103                           , enable_video_x11_vm=yes)
  1104             if test x$enable_video_x11_vm = xyes; then
  1105                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_VIDMODE)
  1106                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86vm/*.c"
  1107             fi
  1108             AC_ARG_ENABLE(video-x11-xv,
  1109 AC_HELP_STRING([--enable-video-x11-xv], [use X11 XvImage extension for video [[default=yes]]]),
  1110                           , enable_video_x11_xv=yes)
  1111             if test x$enable_video_x11_xv = xyes; then
  1112                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XV)
  1113                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xv/*.c"
  1114             fi
  1115             AC_ARG_ENABLE(video-x11-xinerama,
  1116 AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
  1117                             , enable_video_x11_xinerama=yes)
  1118             if test x$enable_video_x11_xinerama = xyes; then
  1119                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA)
  1120                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xinerama/*.c"
  1121             fi
  1122             AC_ARG_ENABLE(video-x11-xme,
  1123 AC_HELP_STRING([--enable-video-x11-xme], [enable Xi Graphics XME for fullscreen [[default=yes]]]),
  1124                             , enable_video_x11_xme=yes)
  1125             if test x$enable_video_x11_xme = xyes; then
  1126                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XME)
  1127                 SOURCES="$SOURCES $srcdir/src/video/Xext/XME/*.c"
  1128             fi
  1129             AC_ARG_ENABLE(video-x11-xrandr,
  1130 AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
  1131                             , enable_video_x11_xrandr=yes)
  1132             if test x$enable_video_x11_xrandr = xyes; then
  1133                 definitely_enable_video_x11_xrandr=no
  1134                 AC_CHECK_HEADER(X11/extensions/Xrandr.h,
  1135                                 have_xrandr_h_hdr=yes,
  1136                                 have_xrandr_h_hdr=no,
  1137                                 [#include <X11/Xlib.h>
  1138                                 ])
  1139                 if test x$have_xrandr_h_hdr = xyes; then
  1140                     if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
  1141                         echo "-- dynamic libXrender -> $xrender_lib"
  1142                         echo "-- dynamic libXrandr -> $xrandr_lib"
  1143                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER, "$xrender_lib")
  1144                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib")
  1145                         definitely_enable_video_x11_xrandr=yes
  1146                     else
  1147                         AC_CHECK_LIB(Xrender, XRenderQueryExtension, have_xrender_lib=yes)
  1148                         AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
  1149                         if test x$have_xrender_lib = xyes && test x$have_xrandr_lib = xyes ; then
  1150                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr -lXrender"
  1151                             definitely_enable_video_x11_xrandr=yes
  1152                         fi
  1153                     fi
  1154                 fi
  1155             fi
  1156             if test x$definitely_enable_video_x11_xrandr = xyes; then
  1157                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR)
  1158             fi
  1159             AC_ARG_ENABLE(video-x11-xinput,
  1160 AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
  1161                             , enable_video_x11_xinput=yes)
  1162             if test x$enable_video_x11_xinput = xyes; then
  1163                 definitely_enable_video_x11_xinput=no
  1164                 AC_CHECK_HEADER(X11/extensions/XInput.h,
  1165                                 have_xinput_h_hdr=yes,
  1166                                 have_xinput_h_hdr=no,
  1167                                 [#include <X11/Xlib.h>
  1168                                 ])
  1169                 if test x$have_xinput_h_hdr = xyes; then
  1170                     if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
  1171                         echo "-- dynamic libXi -> $xinput_lib"
  1172                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT, "$xinput_lib")
  1173                         definitely_enable_video_x11_xinput=yes
  1174                     else
  1175                         AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
  1176                         if test x$have_xinput_lib = xyes ; then
  1177                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
  1178                             definitely_enable_video_x11_xinput=yes
  1179                         fi
  1180                     fi
  1181                 fi
  1182             fi
  1183             if test x$definitely_enable_video_x11_xinput = xyes; then
  1184                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT)
  1185             fi
  1186             AC_ARG_ENABLE(video-x11-dpms,
  1187 AC_HELP_STRING([--enable-video-x11-dpms], [enable X11 DPMS extension [[default=yes]]]),
  1188                             , enable_video_x11_dpms=yes)
  1189             if test x$enable_video_x11_dpms = xyes; then
  1190                 AC_CHECK_HEADER(X11/extensions/dpms.h,
  1191                                 have_dpms_h_hdr=yes,
  1192                                 have_dpms_h_hdr=no,
  1193                                 [#include <X11/Xlib.h>
  1194                                 ])
  1195                 if test x$have_dpms_h_hdr = xyes; then
  1196                     AC_DEFINE(SDL_VIDEO_DRIVER_X11_DPMS)
  1197                 fi
  1198             fi
  1199 
  1200             AC_ARG_ENABLE(render-x11,
  1201 AC_HELP_STRING([--enable-render-x11], [enable the X11 render driver [[default=yes]]]),
  1202                                 , enable_render_x11=yes)
  1203             if test x$enable_render_x11 = xyes; then
  1204                 AC_DEFINE(SDL_VIDEO_RENDER_X11)
  1205             fi
  1206         fi
  1207     fi
  1208 }
  1209 
  1210 dnl Check for QNX photon video driver
  1211 CheckPHOTON()
  1212 {
  1213     AC_ARG_ENABLE(video-photon,
  1214 AC_HELP_STRING([--enable-video-photon], [use QNX Photon video driver [[default=yes]]]),
  1215                   , enable_video_photon=yes)
  1216     if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
  1217         AC_MSG_CHECKING(for QNX Photon support)
  1218         video_photon=no
  1219         AC_TRY_COMPILE([
  1220           #include <Ph.h>
  1221           #include <Pt.h>
  1222           #include <photon/Pg.h>
  1223           #include <photon/PdDirect.h>
  1224         ],[
  1225          PgDisplaySettings_t *visual;
  1226         ],[
  1227         video_photon=yes
  1228         ])
  1229         AC_MSG_RESULT($video_photon)
  1230         if test x$video_photon = xyes; then
  1231             AC_DEFINE(SDL_VIDEO_DRIVER_PHOTON)
  1232             SOURCES="$SOURCES $srcdir/src/video/photon/*.c"
  1233             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lph"
  1234             have_video=yes
  1235 
  1236             CheckOpenGLQNX
  1237         fi
  1238     fi
  1239 }
  1240 
  1241 dnl Set up the BWindow video driver if enabled
  1242 CheckBWINDOW()
  1243 {
  1244     if test x$enable_video = xyes; then
  1245         AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW)
  1246         SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
  1247         have_video=yes
  1248     fi
  1249 }
  1250 
  1251 dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
  1252 CheckCOCOA()
  1253 {
  1254     AC_ARG_ENABLE(video-cocoa,
  1255 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
  1256                   , enable_video_cocoa=yes)
  1257     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  1258         save_CFLAGS="$CFLAGS"
  1259         dnl work around that we don't have Objective-C support in autoconf
  1260         CFLAGS="$CFLAGS -x objective-c"
  1261         AC_MSG_CHECKING(for Cocoa framework)
  1262         have_cocoa=no
  1263         AC_TRY_COMPILE([
  1264           #import <Cocoa/Cocoa.h>
  1265         ],[
  1266         ],[
  1267         have_cocoa=yes
  1268         ])
  1269         AC_MSG_RESULT($have_cocoa)
  1270         CFLAGS="$save_CFLAGS"
  1271         if test x$have_cocoa = xyes; then
  1272             AC_DEFINE(SDL_VIDEO_DRIVER_COCOA)
  1273             SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
  1274             have_video=yes
  1275         fi
  1276     fi
  1277 }
  1278 
  1279 dnl Find the framebuffer console includes
  1280 CheckFBCON()
  1281 {
  1282     AC_ARG_ENABLE(video-fbcon,
  1283 AC_HELP_STRING([--enable-video-fbcon], [use framebuffer console video driver [[default=no]]]),
  1284                   , enable_video_fbcon=no)
  1285     if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
  1286         AC_MSG_CHECKING(for framebuffer console support)
  1287         video_fbcon=no
  1288         AC_TRY_COMPILE([
  1289          #include <linux/fb.h>
  1290          #include <linux/kd.h>
  1291          #include <linux/keyboard.h>
  1292         ],[
  1293         ],[
  1294         video_fbcon=yes
  1295         ])
  1296         AC_MSG_RESULT($video_fbcon)
  1297         if test x$video_fbcon = xyes; then
  1298             AC_CHECK_FUNCS(getpagesize)
  1299             AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
  1300             SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
  1301             have_video=yes
  1302         fi
  1303     fi
  1304 }
  1305 
  1306 dnl Find DirectFB
  1307 CheckDirectFB()
  1308 {
  1309     AC_ARG_ENABLE(video-directfb,
  1310 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
  1311                   , enable_video_directfb=no)
  1312     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  1313         video_directfb=no
  1314 
  1315         DIRECTFB_REQUIRED_VERSION=0.9.15
  1316 
  1317         AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
  1318         if test x$DIRECTFBCONFIG = xno; then
  1319             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1320             AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  1321             if test x$PKG_CONFIG != xno; then
  1322                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
  1323                     DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
  1324                     DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
  1325                     video_directfb=yes
  1326                 fi
  1327             fi
  1328             AC_MSG_RESULT($video_directfb)
  1329         else
  1330             AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  1331             set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
  1332             NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1333             set -- `directfb-config --version | sed 's/\./ /g'`
  1334             HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1335             if test $HAVE_VERSION -ge $NEED_VERSION; then
  1336                 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
  1337                 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
  1338                 video_directfb=yes
  1339             fi
  1340             AC_MSG_RESULT($video_directfb)
  1341         fi
  1342 
  1343         if test x$video_directfb = xyes; then
  1344             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
  1345             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  1346             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  1347             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  1348             have_video=yes
  1349         fi
  1350     fi
  1351 }
  1352 
  1353 dnl See if we're running on PlayStation 2 hardware
  1354 CheckPS2GS()
  1355 {
  1356     AC_ARG_ENABLE(video-ps2gs,
  1357 AC_HELP_STRING([--enable-video-ps2gs], [use PlayStation 2 GS video driver [[default=no]]]),
  1358                   , enable_video_ps2gs=no)
  1359     if test x$enable_video = xyes -a x$enable_video_ps2gs = xyes; then
  1360         AC_MSG_CHECKING(for PlayStation 2 GS support)
  1361         video_ps2gs=no
  1362         AC_TRY_COMPILE([
  1363          #include <linux/ps2/dev.h>
  1364          #include <linux/ps2/gs.h>
  1365         ],[
  1366         ],[
  1367         video_ps2gs=yes
  1368         ])
  1369         AC_MSG_RESULT($video_ps2gs)
  1370         if test x$video_ps2gs = xyes; then
  1371             AC_DEFINE(SDL_VIDEO_DRIVER_PS2GS)
  1372             SOURCES="$SOURCES $srcdir/src/video/ps2gs/*.c"
  1373             have_video=yes
  1374         fi
  1375     fi
  1376 }
  1377 
  1378 dnl Find the SVGAlib includes and libraries
  1379 CheckSVGA()
  1380 {
  1381     AC_ARG_ENABLE(video-svga,
  1382 AC_HELP_STRING([--enable-video-svga], [use SVGAlib video driver [[default=no]]]),
  1383                   , enable_video_svga=no)
  1384     if test x$enable_video = xyes -a x$enable_video_svga = xyes; then
  1385         AC_MSG_CHECKING(for SVGAlib (1.4.0+) support)
  1386         video_svga=no
  1387         AC_TRY_COMPILE([
  1388          #include <vga.h>
  1389          #include <vgamouse.h>
  1390          #include <vgakeyboard.h>
  1391         ],[
  1392          if ( SCANCODE_RIGHTWIN && SCANCODE_LEFTWIN ) {
  1393              exit(0);
  1394          }
  1395         ],[
  1396         video_svga=yes
  1397         ])
  1398         AC_MSG_RESULT($video_svga)
  1399         if test x$video_svga = xyes; then
  1400             AC_DEFINE(SDL_VIDEO_DRIVER_SVGALIB)
  1401             SOURCES="$SOURCES $srcdir/src/video/svga/*.c"
  1402             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvga"
  1403             have_video=yes
  1404         fi
  1405     fi
  1406 }
  1407 
  1408 dnl Find the VGL includes and libraries
  1409 CheckVGL()
  1410 {
  1411     AC_ARG_ENABLE(video-vgl,
  1412 AC_HELP_STRING([--enable-video-vgl], [use VGL video driver [[default=no]]]),
  1413                   , enable_video_vgl=no)
  1414     if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
  1415         AC_MSG_CHECKING(for libVGL support)
  1416         video_vgl=no
  1417         AC_TRY_COMPILE([
  1418          #include <sys/fbio.h>
  1419          #include <sys/consio.h>
  1420          #include <sys/kbio.h>
  1421          #include <vgl.h>
  1422         ],[
  1423          VGLBitmap bitmap;
  1424          bitmap.Type = VIDBUF32;
  1425          bitmap.PixelBytes = 4;
  1426          exit(bitmap.Bitmap);
  1427         ],[
  1428         video_vgl=yes
  1429         ])
  1430         AC_MSG_RESULT($video_vgl)
  1431         if test x$video_vgl = xyes; then
  1432             AC_DEFINE(SDL_VIDEO_DRIVER_VGL)
  1433             SOURCES="$SOURCES $srcdir/src/video/vgl/*.c"
  1434             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvgl"
  1435             have_video=yes
  1436         fi
  1437     fi
  1438 }
  1439 
  1440 dnl Set up the wscons video driver if enabled
  1441 CheckWscons()
  1442 {
  1443     AC_ARG_ENABLE(video-wscons,
  1444 AC_HELP_STRING([--enable-video-wscons], [use wscons video driver [[default=no]]]),
  1445                   , enable_video_wscons=no)
  1446     if test x$enable_video = xyes -a x$enable_video_wscons = xyes; then
  1447         AC_MSG_CHECKING(for wscons support)
  1448         video_wscons=no
  1449         AC_TRY_COMPILE([
  1450          #include <sys/time.h>
  1451          #include <dev/wscons/wsconsio.h>
  1452          #include <dev/wscons/wsdisplay_usl_io.h>
  1453         ],[
  1454          int wsmode = WSDISPLAYIO_MODE_DUMBFB;
  1455         ],[
  1456         video_wscons=yes
  1457         ])
  1458         AC_MSG_RESULT($video_wscons)
  1459         if test x$video_wscons = xyes; then
  1460             AC_DEFINE(SDL_VIDEO_DRIVER_WSCONS)
  1461             SOURCES="$SOURCES $srcdir/src/video/wscons/*.c"
  1462             have_video=yes
  1463         fi
  1464     fi
  1465 }
  1466 
  1467 dnl Set up the Atari Bios keyboard driver
  1468 CheckAtariBiosEvent()
  1469 {
  1470     SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.c"
  1471     SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.S"
  1472 }
  1473 
  1474 dnl Set up the Atari Xbios driver
  1475 CheckAtariXbiosVideo()
  1476 {
  1477     AC_ARG_ENABLE(video-xbios,
  1478 AC_HELP_STRING([--enable-video-xbios], [use Atari Xbios video driver [[default=yes]]]),
  1479                   , enable_video_xbios=yes)
  1480     video_xbios=no
  1481     if test x$enable_video = xyes -a x$enable_video_xbios = xyes; then
  1482         video_xbios=yes
  1483         AC_DEFINE(SDL_VIDEO_DRIVER_XBIOS)
  1484         SOURCES="$SOURCES $srcdir/src/video/xbios/*.c"
  1485         have_video=yes
  1486     fi
  1487 }
  1488 
  1489 dnl Set up the Atari Gem driver
  1490 CheckAtariGemVideo()
  1491 {
  1492     AC_ARG_ENABLE(video-gem,
  1493 AC_HELP_STRING([--enable-video-gem], [use Atari Gem video driver [[default=yes]]]),
  1494                   , enable_video_gem=yes)
  1495     if test x$enable_video = xyes -a x$enable_video_gem = xyes; then
  1496         video_gem=no
  1497         AC_CHECK_HEADER(gem.h, have_gem_hdr=yes)
  1498         AC_CHECK_LIB(gem, appl_init, have_gem_lib=yes)
  1499         if test x$have_gem_hdr = xyes -a x$have_gem_lib = xyes; then
  1500             video_gem=yes
  1501             AC_DEFINE(SDL_VIDEO_DRIVER_GEM)
  1502             SOURCES="$SOURCES $srcdir/src/video/gem/*.c"
  1503             SDL_LIBS="$SDL_LIBS -lgem"
  1504             have_video=yes
  1505         fi
  1506     fi
  1507 }
  1508 
  1509 dnl rcg04172001 Set up the Null video driver.
  1510 CheckDummyVideo()
  1511 {
  1512     AC_ARG_ENABLE(video-dummy,
  1513 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  1514                   , enable_video_dummy=yes)
  1515     if test x$enable_video_dummy = xyes; then
  1516         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY)
  1517         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1518         have_video=yes
  1519     fi
  1520 }
  1521 
  1522 dnl Check to see if OpenGL support is desired
  1523 AC_ARG_ENABLE(video-opengl,
  1524 AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  1525               , enable_video_opengl=yes)
  1526 
  1527 dnl Find OpenGL
  1528 CheckOpenGLX11()
  1529 {
  1530     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1531         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1532         video_opengl=no
  1533         AC_TRY_COMPILE([
  1534          #include <GL/gl.h>
  1535          #include <GL/glx.h>
  1536          #include <GL/glu.h>
  1537         ],[
  1538         ],[
  1539         video_opengl=yes
  1540         ])
  1541         AC_MSG_RESULT($video_opengl)
  1542         if test x$video_opengl = xyes; then
  1543             AC_DEFINE(SDL_VIDEO_OPENGL)
  1544             AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
  1545             AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1546         fi
  1547     fi
  1548 }
  1549 
  1550 dnl Find QNX RtP OpenGL
  1551 CheckOpenGLQNX()
  1552 {
  1553     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1554         AC_MSG_CHECKING(for OpenGL (Photon) support)
  1555         video_opengl=no
  1556         AC_TRY_COMPILE([
  1557          #include <GL/gl.h>
  1558         ],[
  1559         ],[
  1560         video_opengl=yes
  1561         ])
  1562         AC_MSG_RESULT($video_opengl)
  1563         if test x$video_opengl = xyes; then
  1564             AC_DEFINE(SDL_VIDEO_OPENGL)
  1565             AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1566             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1567         fi
  1568     fi
  1569 }
  1570 
  1571 dnl Check for Win32 OpenGL
  1572 CheckWIN32GL()
  1573 {
  1574     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1575         AC_DEFINE(SDL_VIDEO_OPENGL)
  1576         AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
  1577         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1578     fi
  1579 }
  1580 
  1581 dnl Check for BeOS OpenGL
  1582 CheckBeGL()
  1583 {
  1584     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1585         AC_DEFINE(SDL_VIDEO_OPENGL)
  1586         AC_DEFINE(SDL_VIDEO_OPENGL_BGL)
  1587         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1588         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1589     fi
  1590 }
  1591 
  1592 dnl Check for MacOS OpenGL
  1593 CheckMacGL()
  1594 {
  1595     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1596         AC_DEFINE(SDL_VIDEO_OPENGL)
  1597         AC_DEFINE(SDL_VIDEO_OPENGL_CGL)
  1598         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1599         case "$host" in
  1600             *-*-darwin*)
  1601                 if test x$enable_video_cocoa = xyes; then
  1602                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
  1603                 fi
  1604         esac
  1605     fi
  1606 }
  1607 
  1608 dnl Check for Mesa offscreen rendering
  1609 CheckAtariOSMesa()
  1610 {
  1611     if test "x$enable_video" = "xyes" -a "x$enable_video_opengl" = "xyes"; then
  1612         AC_CHECK_HEADER(GL/osmesa.h, have_osmesa_hdr=yes)
  1613         AC_CHECK_LIB(OSMesa, OSMesaCreateContext, have_osmesa_lib=yes, have_osmesa_lib=no, -lm)
  1614 
  1615         # Static linking to -lOSMesa
  1616         AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
  1617         if test "x$OSMESA_CONFIG" = "xno" -o "x$enable_atari_ldg" = "xno"; then
  1618             # -lOSMesa is really the static library
  1619             if test "x$have_osmesa_hdr" = "xyes" -a "x$have_osmesa_lib" = "xyes"; then
  1620                 OSMESA_LIBS="-lOSMesa"
  1621             fi
  1622         else
  1623             # -lOSMesa is a loader for OSMesa.ldg
  1624             OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
  1625             OSMESA_LIBS=`$OSMESA_CONFIG --libs`
  1626         fi
  1627         AC_DEFINE(SDL_VIDEO_OPENGL)
  1628         AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA)
  1629         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1630         SDL_CFLAGS="$SDL_CFLAGS $OSMESA_CFLAGS"
  1631         SDL_LIBS="$SDL_LIBS $OSMESA_LIBS"
  1632 
  1633         AC_ARG_ENABLE(osmesa-shared,
  1634 AC_HELP_STRING([--enable-osmesa-shared], [dynamically load OSMesa OpenGL support [[default=yes]]]),
  1635                               , enable_osmesa_shared=yes)
  1636         if test "x$enable_osmesa_shared" = "xyes" -a "x$enable_atari_ldg" = "xyes"; then
  1637             # Dynamic linking
  1638             if test "x$have_osmesa_hdr" = "xyes"; then
  1639                 AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA_DYNAMIC)
  1640             fi
  1641         fi
  1642     fi
  1643 }
  1644 
  1645 dnl See if we can use the new unified event interface in Linux 2.4
  1646 CheckInputEvents()
  1647 {
  1648     dnl Check for Linux 2.4 unified input event interface support
  1649     AC_ARG_ENABLE(input-events,
  1650 AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [[default=yes]]]),
  1651                   , enable_input_events=yes)
  1652     if test x$enable_input_events = xyes; then
  1653         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  1654         use_input_events=no
  1655         AC_TRY_COMPILE([
  1656           #include <linux/input.h>
  1657         ],[
  1658           #ifndef EVIOCGNAME
  1659           #error EVIOCGNAME() ioctl not available
  1660           #endif
  1661         ],[
  1662         use_input_events=yes
  1663         ])
  1664         AC_MSG_RESULT($use_input_events)
  1665         if test x$use_input_events = xyes; then
  1666             AC_DEFINE(SDL_INPUT_LINUXEV)
  1667         fi
  1668     fi
  1669 }
  1670 
  1671 dnl See if we can use the Touchscreen input library
  1672 CheckTslib()
  1673 {
  1674     AC_ARG_ENABLE(input-tslib,
  1675 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  1676                   , enable_input_tslib=yes)
  1677     if test x$enable_input_tslib = xyes; then
  1678         AC_MSG_CHECKING(for Touchscreen library support)
  1679         enable_input_tslib=no
  1680         AC_TRY_COMPILE([
  1681           #include "tslib.h"
  1682         ],[
  1683         ],[
  1684         enable_input_tslib=yes
  1685         ])
  1686         AC_MSG_RESULT($enable_input_tslib)
  1687         if test x$enable_input_tslib = xyes; then
  1688             AC_DEFINE(SDL_INPUT_TSLIB)
  1689             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  1690         fi
  1691     fi
  1692 }
  1693 
  1694 dnl See if we can use GNU pth library for threads
  1695 CheckPTH()
  1696 {
  1697     dnl Check for pth support
  1698     AC_ARG_ENABLE(pth,
  1699 AC_HELP_STRING([--enable-pth], [use GNU pth library for multi-threading [[default=yes]]]),
  1700                   , enable_pth=yes)
  1701     if test x$enable_threads = xyes -a x$enable_pth = xyes; then
  1702         AC_PATH_PROG(PTH_CONFIG, pth-config, no)
  1703         if test "$PTH_CONFIG" = "no"; then
  1704             use_pth=no
  1705         else
  1706             use_pth=yes
  1707         fi
  1708         AC_MSG_CHECKING(pth)
  1709         AC_MSG_RESULT($use_pth)
  1710         if test "x$use_pth" = xyes; then
  1711             AC_DEFINE(SDL_THREAD_PTH)
  1712             SOURCES="$SOURCES $srcdir/src/thread/pth/*.c"
  1713             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1714             SDL_CFLAGS="$SDL_CFLAGS `$PTH_CONFIG --cflags`"
  1715             SDL_LIBS="$SDL_LIBS `$PTH_CONFIG --libs --all`"
  1716             have_threads=yes
  1717         fi
  1718     fi
  1719 }
  1720 
  1721 dnl See what type of thread model to use on Linux and Solaris
  1722 CheckPTHREAD()
  1723 {
  1724     dnl Check for pthread support
  1725     AC_ARG_ENABLE(pthreads,
  1726 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  1727                   , enable_pthreads=yes)
  1728     dnl This is used on Linux for glibc binary compatibility (Doh!)
  1729     AC_ARG_ENABLE(pthread-sem,
  1730 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  1731                   , enable_pthread_sem=yes)
  1732     case "$host" in
  1733         *-*-linux*|*-*-uclinux*)
  1734             pthread_cflags="-D_REENTRANT"
  1735             pthread_lib="-lpthread"
  1736             ;;
  1737         *-*-bsdi*)
  1738             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1739             pthread_lib=""
  1740             ;;
  1741         *-*-darwin*)
  1742             pthread_cflags="-D_THREAD_SAFE"
  1743 # causes Carbon.p complaints?
  1744 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1745             ;;
  1746         *-*-freebsd*|*-*-dragonfly*)
  1747             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1748             pthread_lib="-pthread"
  1749             ;;
  1750         *-*-netbsd*)
  1751             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1752             pthread_lib="-lpthread"
  1753             ;;
  1754         *-*-openbsd*)
  1755             pthread_cflags="-D_REENTRANT"
  1756             pthread_lib="-pthread"
  1757             ;;
  1758         *-*-solaris*)
  1759             pthread_cflags="-D_REENTRANT"
  1760             pthread_lib="-lpthread -lposix4"
  1761             ;;
  1762         *-*-sysv5*)
  1763             pthread_cflags="-D_REENTRANT -Kthread"
  1764             pthread_lib=""
  1765             ;;
  1766         *-*-irix*)
  1767             pthread_cflags="-D_SGI_MP_SOURCE"
  1768             pthread_lib="-lpthread"
  1769             ;;
  1770         *-*-aix*)
  1771             pthread_cflags="-D_REENTRANT -mthreads"
  1772             pthread_lib="-lpthread"
  1773             ;;
  1774         *-*-hpux11*)
  1775             pthread_cflags="-D_REENTRANT"
  1776             pthread_lib="-L/usr/lib -lpthread"
  1777             ;;
  1778         *-*-qnx*)
  1779             pthread_cflags=""
  1780             pthread_lib=""
  1781             ;;
  1782         *-*-osf*)
  1783             pthread_cflags="-D_REENTRANT"
  1784             if test x$ac_cv_prog_gcc = xyes; then
  1785                 pthread_lib="-lpthread -lrt"
  1786             else
  1787                 pthread_lib="-lpthread -lexc -lrt"
  1788             fi
  1789             ;;
  1790         *)
  1791             pthread_cflags="-D_REENTRANT"
  1792             pthread_lib="-lpthread"
  1793             ;;
  1794     esac
  1795     if test x$enable_threads = xyes -a x$enable_pthreads = xyes -a x$enable_ipod != xyes; then
  1796         # Save the original compiler flags and libraries
  1797         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1798         # Add the pthread compiler flags and libraries
  1799         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1800         # Check to see if we have pthread support on this system
  1801         AC_MSG_CHECKING(for pthreads)
  1802         use_pthreads=no
  1803         AC_TRY_LINK([
  1804          #include <pthread.h>
  1805         ],[
  1806          pthread_attr_t type;
  1807          pthread_attr_init(&type);
  1808         ],[
  1809         use_pthreads=yes
  1810         ])
  1811         AC_MSG_RESULT($use_pthreads)
  1812         # Restore the compiler flags and libraries
  1813         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1814 
  1815         # Do futher testing if we have pthread support...
  1816         if test x$use_pthreads = xyes; then
  1817             AC_DEFINE(SDL_THREAD_PTHREAD)
  1818             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  1819             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  1820             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  1821             SDL_LIBS="$SDL_LIBS $pthread_lib"
  1822 
  1823             # Save the original compiler flags and libraries
  1824             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1825             # Add the pthread compiler flags and libraries
  1826             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1827 
  1828             # Check to see if recursive mutexes are available
  1829             AC_MSG_CHECKING(for recursive mutexes)
  1830             has_recursive_mutexes=no
  1831             if test x$has_recursive_mutexes = xno; then
  1832                 AC_TRY_COMPILE([
  1833                   #include <pthread.h>
  1834                 ],[
  1835                   pthread_mutexattr_t attr;
  1836                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  1837                 ],[
  1838                 has_recursive_mutexes=yes
  1839                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX)
  1840                 ])
  1841             fi
  1842             if test x$has_recursive_mutexes = xno; then
  1843                 AC_TRY_COMPILE([
  1844                   #include <pthread.h>
  1845                 ],[
  1846                   pthread_mutexattr_t attr;
  1847                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  1848                 ],[
  1849                 has_recursive_mutexes=yes
  1850                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)
  1851                 ])
  1852             fi
  1853             AC_MSG_RESULT($has_recursive_mutexes)
  1854 
  1855             # Check to see if pthread semaphore support is missing
  1856             if test x$enable_pthread_sem = xyes; then
  1857                 AC_MSG_CHECKING(for pthread semaphores)
  1858                 have_pthread_sem=no
  1859                 AC_TRY_COMPILE([
  1860                   #include <pthread.h>
  1861                   #include <semaphore.h>
  1862                 ],[
  1863                 ],[
  1864                 have_pthread_sem=yes
  1865                 ])
  1866                 AC_MSG_RESULT($have_pthread_sem)
  1867             fi
  1868 
  1869             # Restore the compiler flags and libraries
  1870             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1871 
  1872             # Basic thread creation functions
  1873             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  1874 
  1875             # Semaphores
  1876             # We can fake these with mutexes and condition variables if necessary
  1877             if test x$have_pthread_sem = xyes; then
  1878                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  1879             else
  1880                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1881             fi
  1882 
  1883             # Mutexes
  1884             # We can fake these with semaphores if necessary
  1885             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  1886 
  1887             # Condition variables
  1888             # We can fake these with semaphores and mutexes if necessary
  1889             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  1890 
  1891             have_threads=yes
  1892         else
  1893             CheckPTH
  1894         fi
  1895     fi
  1896 }
  1897 
  1898 dnl Determine whether the compiler can produce Win32 executables
  1899 CheckWIN32()
  1900 {
  1901     AC_MSG_CHECKING(Win32 compiler)
  1902     have_win32_gcc=no
  1903     AC_TRY_COMPILE([
  1904      #include <windows.h>
  1905     ],[
  1906     ],[
  1907     have_win32_gcc=yes
  1908     ])
  1909     AC_MSG_RESULT($have_win32_gcc)
  1910     if test x$have_win32_gcc != xyes; then
  1911        AC_MSG_ERROR([
  1912 *** Your compiler ($CC) does not produce Win32 executables!
  1913        ])
  1914     fi
  1915 
  1916     dnl See if the user wants to redirect standard output to files
  1917     AC_ARG_ENABLE(stdio-redirect,
  1918 AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[default=yes]]]),
  1919                   , enable_stdio_redirect=yes)
  1920     if test x$enable_stdio_redirect != xyes; then
  1921         EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
  1922     fi
  1923 }
  1924 
  1925 dnl Find the DirectX includes and libraries
  1926 CheckDIRECTX()
  1927 {
  1928     AC_ARG_ENABLE(directx,
  1929 AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]),
  1930                   , enable_directx=yes)
  1931     if test x$enable_directx = xyes; then
  1932         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  1933         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  1934         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  1935     fi
  1936 }
  1937 
  1938 dnl Check for the dlfcn.h interface for dynamically loading objects
  1939 CheckDLOPEN()
  1940 {
  1941     AC_ARG_ENABLE(sdl-dlopen,
  1942 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  1943                   , enable_sdl_dlopen=yes)
  1944     if test x$enable_sdl_dlopen = xyes; then
  1945         AC_MSG_CHECKING(for dlopen)
  1946         have_dlopen=no
  1947         AC_TRY_COMPILE([
  1948          #include <dlfcn.h>
  1949         ],[
  1950          #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
  1951          #error Use dlcompat for Mac OS X 10.2 compatibility
  1952          #endif
  1953         ],[
  1954         have_dlopen=yes
  1955         ])
  1956         AC_MSG_RESULT($have_dlopen)
  1957 
  1958         if test x$have_dlopen = xyes; then
  1959             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  1960                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  1961                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  1962             AC_CHECK_LIB(dl, dlvsym, have_dlvsym=yes)
  1963             if test x$have_dlvsym = xyes; then
  1964                 AC_DEFINE(HAVE_DLVSYM)
  1965             fi
  1966             AC_DEFINE(SDL_LOADSO_DLOPEN)
  1967             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  1968             have_loadso=yes
  1969         fi
  1970     fi
  1971 }
  1972 
  1973 dnl Set up the Atari LDG (shared object loader)
  1974 CheckAtariLdg()
  1975 {
  1976     AC_ARG_ENABLE(atari-ldg,
  1977 AC_HELP_STRING([--enable-atari-ldg], [use Atari LDG for shared object loading [[default=yes]]]),
  1978                   , enable_atari_ldg=yes)
  1979     if test x$video_gem = xyes -a x$enable_atari_ldg = xyes; then
  1980         AC_CHECK_HEADER(ldg.h, have_ldg_hdr=yes)
  1981         AC_CHECK_LIB(ldg, ldg_open, have_ldg_lib=yes, have_ldg_lib=no, -lgem)
  1982         if test x$have_ldg_hdr = xyes -a x$have_ldg_lib = xyes; then
  1983             AC_DEFINE(SDL_LOADSO_LDG)
  1984             SOURCES="$SOURCES $srcdir/src/loadso/mint/*.c"
  1985             SDL_LIBS="$SDL_LIBS -lldg -lgem"
  1986             have_loadso=yes
  1987         fi
  1988     fi
  1989 }
  1990 
  1991 dnl Check for the usbhid(3) library on *BSD
  1992 CheckUSBHID()
  1993 {
  1994     if test x$enable_joystick = xyes; then
  1995         AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  1996         if test x$have_libusbhid = xyes; then
  1997             AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  1998             AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  1999             USB_LIBS="$USB_LIBS -lusbhid"
  2000         else
  2001             AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  2002             AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  2003             AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  2004         fi
  2005             
  2006         save_CFLAGS="$CFLAGS"
  2007         CFLAGS="$CFLAGS $USB_CFLAGS"
  2008 
  2009         AC_MSG_CHECKING(for usbhid)
  2010         have_usbhid=no
  2011         AC_TRY_COMPILE([
  2012           #include <sys/types.h>
  2013           #if defined(HAVE_USB_H)
  2014           #include <usb.h>
  2015           #endif
  2016           #ifdef __DragonFly__
  2017           # include <bus/usb/usb.h>
  2018           # include <bus/usb/usbhid.h>
  2019           #else
  2020           # include <dev/usb/usb.h>
  2021           # include <dev/usb/usbhid.h>
  2022           #endif
  2023           #if defined(HAVE_USBHID_H)
  2024           #include <usbhid.h>
  2025           #elif defined(HAVE_LIBUSB_H)
  2026           #include <libusb.h>
  2027           #elif defined(HAVE_LIBUSBHID_H)
  2028           #include <libusbhid.h>
  2029           #endif
  2030         ],[
  2031           struct report_desc *repdesc;
  2032           struct usb_ctl_report *repbuf;
  2033           hid_kind_t hidkind;
  2034         ],[
  2035         have_usbhid=yes
  2036         ])
  2037         AC_MSG_RESULT($have_usbhid)
  2038 
  2039         if test x$have_usbhid = xyes; then
  2040             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  2041             have_usbhid_ucr_data=no
  2042             AC_TRY_COMPILE([
  2043               #include <sys/types.h>
  2044               #if defined(HAVE_USB_H)
  2045               #include <usb.h>
  2046               #endif
  2047               #ifdef __DragonFly__
  2048               # include <bus/usb/usb.h>
  2049               # include <bus/usb/usbhid.h>
  2050               #else
  2051               # include <dev/usb/usb.h>
  2052               # include <dev/usb/usbhid.h>
  2053               #endif
  2054               #if defined(HAVE_USBHID_H)
  2055               #include <usbhid.h>
  2056               #elif defined(HAVE_LIBUSB_H)
  2057               #include <libusb.h>
  2058               #elif defined(HAVE_LIBUSBHID_H)
  2059               #include <libusbhid.h>
  2060               #endif
  2061             ],[
  2062               struct usb_ctl_report buf;
  2063               if (buf.ucr_data) { }
  2064             ],[
  2065             have_usbhid_ucr_data=yes
  2066             ])
  2067             if test x$have_usbhid_ucr_data = xyes; then
  2068                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  2069             fi
  2070             AC_MSG_RESULT($have_usbhid_ucr_data)
  2071             
  2072             AC_MSG_CHECKING(for new usbhid API)
  2073             have_usbhid_new=no
  2074             AC_TRY_COMPILE([
  2075               #include <sys/types.h>
  2076               #if defined(HAVE_USB_H)
  2077               #include <usb.h>
  2078               #endif
  2079 	      #ifdef __DragonFly__
  2080               #include <bus/usb/usb.h>
  2081               #include <bus/usb/usbhid.h>
  2082 	      #else
  2083               #include <dev/usb/usb.h>
  2084               #include <dev/usb/usbhid.h>
  2085 	      #endif
  2086               #if defined(HAVE_USBHID_H)
  2087               #include <usbhid.h>
  2088               #elif defined(HAVE_LIBUSB_H)
  2089               #include <libusb.h>
  2090               #elif defined(HAVE_LIBUSBHID_H)
  2091               #include <libusbhid.h>
  2092               #endif
  2093             ],[
  2094               report_desc_t d;
  2095               hid_start_parse(d, 1, 1);
  2096             ],[
  2097             have_usbhid_new=yes
  2098             ])
  2099             if test x$have_usbhid_new = xyes; then
  2100                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  2101             fi
  2102             AC_MSG_RESULT($have_usbhid_new)
  2103 
  2104             AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  2105             have_machine_joystick=no
  2106             AC_TRY_COMPILE([
  2107               #include <machine/joystick.h>
  2108             ],[
  2109               struct joystick t;
  2110             ],[
  2111             have_machine_joystick=yes
  2112             ])
  2113             if test x$have_machine_joystick = xyes; then
  2114                 AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H)
  2115             fi
  2116             AC_MSG_RESULT($have_machine_joystick)
  2117 
  2118             AC_DEFINE(SDL_JOYSTICK_USBHID)
  2119             SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  2120             EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  2121             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  2122             have_joystick=yes
  2123         fi
  2124         CFLAGS="$save_CFLAGS"
  2125     fi
  2126 }
  2127 
  2128 dnl Check for clock_gettime()
  2129 CheckClockGettime()
  2130 {
  2131     AC_ARG_ENABLE(clock_gettime,
  2132 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=no]]]),
  2133                   , enable_clock_gettime=no)
  2134     if test x$enable_clock_gettime = xyes; then
  2135         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  2136         if test x$have_clock_gettime = xyes; then
  2137             AC_DEFINE(HAVE_CLOCK_GETTIME)
  2138             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  2139         fi
  2140     fi
  2141 }
  2142 
  2143 dnl Check for a valid linux/version.h
  2144 CheckLinuxVersion()
  2145 {
  2146     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  2147     if test x$have_linux_version_h = xyes; then
  2148         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  2149     fi
  2150 }
  2151 
  2152 dnl Check if we want to use RPATH
  2153 CheckRPATH()
  2154 {
  2155     AC_ARG_ENABLE(rpath,
  2156 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  2157                   , enable_rpath=yes)
  2158 }
  2159 
  2160 dnl Set up the configuration based on the host platform!
  2161 case "$host" in
  2162     arm-*-elf*) # FIXME: Can we get more specific for iPodLinux?
  2163         ARCH=linux
  2164         CheckDummyVideo
  2165         CheckIPod
  2166         # Set up files for the timer library
  2167         if test x$enable_timers = xyes; then
  2168             AC_DEFINE(SDL_TIMER_UNIX)
  2169             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2170             have_timers=yes
  2171         fi
  2172         ;;
  2173     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*|*-*-minix*)
  2174         case "$host" in
  2175             *-*-linux*)         ARCH=linux ;;
  2176             *-*-uclinux*)       ARCH=linux ;;
  2177             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  2178             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  2179             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  2180             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  2181             *-*-bsdi*)          ARCH=bsdi ;;
  2182             *-*-freebsd*)       ARCH=freebsd ;;
  2183             *-*-dragonfly*)     ARCH=freebsd ;;
  2184             *-*-netbsd*)        ARCH=netbsd ;;
  2185             *-*-openbsd*)       ARCH=openbsd ;;
  2186             *-*-sysv5*)         ARCH=sysv5 ;;
  2187             *-*-solaris*)       ARCH=solaris ;;
  2188             *-*-hpux*)          ARCH=hpux ;;
  2189             *-*-irix*)          ARCH=irix ;;
  2190             *-*-aix*)           ARCH=aix ;;
  2191             *-*-osf*)           ARCH=osf ;;
  2192             *-*-minix*)         ARCH=minix ;;
  2193         esac
  2194         CheckVisibilityHidden
  2195         CheckDummyVideo
  2196         CheckDiskAudio
  2197         CheckDummyAudio
  2198         CheckDLOPEN
  2199         CheckOSS
  2200         CheckDMEDIA
  2201         CheckMME
  2202         CheckALSA
  2203         CheckPulseAudio
  2204         CheckARTSC
  2205         CheckESD
  2206         CheckNAS
  2207         CheckX11
  2208         CheckNANOX
  2209         CheckFBCON
  2210         CheckDirectFB
  2211         CheckPS2GS
  2212         CheckSVGA
  2213         CheckVGL
  2214         CheckWscons
  2215         CheckOpenGLX11
  2216         CheckInputEvents
  2217         CheckTslib
  2218         CheckUSBHID
  2219         CheckPTHREAD
  2220         CheckClockGettime
  2221         CheckLinuxVersion
  2222         CheckRPATH
  2223         # Set up files for the audio library
  2224         if test x$enable_audio = xyes; then
  2225           case $ARCH in
  2226             sysv5|solaris|hpux)
  2227                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
  2228                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2229                 have_audio=yes
  2230             ;;
  2231             netbsd|openbsd)
  2232                 AC_DEFINE(SDL_AUDIO_DRIVER_BSD)
  2233                 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
  2234                 have_audio=yes
  2235             ;;
  2236             aix)
  2237                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO)
  2238                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  2239                 have_audio=yes
  2240             ;;
  2241           esac
  2242         fi
  2243         # Set up files for the joystick library
  2244         if test x$enable_joystick = xyes; then
  2245           case $ARCH in
  2246             linux)
  2247                 AC_DEFINE(SDL_JOYSTICK_LINUX)
  2248                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  2249                 have_joystick=yes
  2250             ;;
  2251           esac
  2252         fi
  2253         # Set up files for the haptic library
  2254         if test x$enable_haptic = xyes; then
  2255            if test x$use_input_events = xyes; then
  2256              case $ARCH in
  2257                linux)
  2258                    AC_DEFINE(SDL_HAPTIC_LINUX)
  2259                    SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  2260                    have_haptic=yes
  2261                ;;
  2262              esac
  2263            fi
  2264         fi
  2265         # Set up files for the cdrom library
  2266         if test x$enable_cdrom = xyes; then
  2267           case $ARCH in
  2268             linux|solaris)
  2269                 AC_DEFINE(SDL_CDROM_LINUX)
  2270                 SOURCES="$SOURCES $srcdir/src/cdrom/linux/*.c"
  2271                 have_cdrom=yes
  2272             ;;
  2273             *freebsd*)
  2274                 AC_DEFINE(SDL_CDROM_FREEBSD)
  2275                 SOURCES="$SOURCES $srcdir/src/cdrom/freebsd/*.c"
  2276                 have_cdrom=yes
  2277             ;;
  2278             *openbsd*|*netbsd*)
  2279                 AC_DEFINE(SDL_CDROM_OPENBSD)
  2280                 SOURCES="$SOURCES $srcdir/src/cdrom/openbsd/*.c"
  2281                 have_cdrom=yes
  2282             ;;
  2283             bsdi)
  2284                 AC_DEFINE(SDL_CDROM_BSDI)
  2285                 SOURCES="$SOURCES $srcdir/src/cdrom/bsdi/*.c"
  2286                 have_cdrom=yes
  2287             ;;
  2288             aix)
  2289                 AC_DEFINE(SDL_CDROM_AIX)
  2290                 SOURCES="$SOURCES $srcdir/src/cdrom/aix/*.c"
  2291                 have_cdrom=yes
  2292             ;;
  2293             osf)
  2294                 AC_DEFINE(SDL_CDROM_OSF)
  2295                 SOURCES="$SOURCES $srcdir/src/cdrom/osf/*.c"
  2296                 have_cdrom=yes
  2297             ;;
  2298           esac
  2299         fi
  2300         # Set up files for the thread library
  2301         if test x$enable_threads = xyes -a x$use_pthreads != xyes -a x$use_pth != xyes -a x$ARCH = xirix; then
  2302             AC_DEFINE(SDL_THREAD_SPROC)
  2303             SOURCES="$SOURCES $srcdir/src/thread/irix/*.c"
  2304             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2305             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2306             have_threads=yes
  2307         fi
  2308         # Set up files for the timer library
  2309         if test x$enable_timers = xyes; then
  2310             AC_DEFINE(SDL_TIMER_UNIX)
  2311             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2312             have_timers=yes
  2313         fi
  2314         ;;
  2315     *-*-qnx*)
  2316         ARCH=qnx
  2317         CheckDummyVideo
  2318         CheckDiskAudio
  2319         CheckDummyAudio
  2320         CheckDLOPEN
  2321         CheckNAS
  2322         CheckPHOTON
  2323         CheckX11
  2324         CheckOpenGLX11
  2325         CheckPTHREAD
  2326         # Set up files for the audio library
  2327         if test x$enable_audio = xyes; then
  2328             AC_DEFINE(SDL_AUDIO_DRIVER_QNXNTO)
  2329             SOURCES="$SOURCES $srcdir/src/audio/nto/*.c"
  2330             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
  2331             have_audio=yes
  2332         fi
  2333         # Set up files for the cdrom library
  2334         if test x$enable_cdrom = xyes; then
  2335             AC_DEFINE(SDL_CDROM_QNX)
  2336             SOURCES="$SOURCES $srcdir/src/cdrom/qnx/*.c"
  2337             have_cdrom=yes
  2338         fi
  2339         # Set up files for the timer library
  2340         if test x$enable_timers = xyes; then
  2341             AC_DEFINE(SDL_TIMER_UNIX)
  2342             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2343             have_timers=yes
  2344         fi
  2345         ;;
  2346     *-*-cygwin* | *-*-mingw32*)
  2347         ARCH=win32
  2348         if test "$build" != "$host"; then # cross-compiling
  2349             # Default cross-compile location
  2350             ac_default_prefix=/usr/local/cross-tools/i386-mingw32
  2351         else
  2352             # Look for the location of the tools and install there
  2353             if test "$BUILD_PREFIX" != ""; then
  2354                 ac_default_prefix=$BUILD_PREFIX
  2355             fi
  2356         fi
  2357         CheckDummyVideo
  2358         CheckDiskAudio
  2359         CheckDummyAudio
  2360         CheckWIN32
  2361         CheckWIN32GL
  2362         CheckDIRECTX
  2363         # Set up files for the video library
  2364         if test x$enable_video = xyes; then
  2365             AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
  2366             SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
  2367             have_video=yes
  2368             AC_ARG_ENABLE(render-gdi,
  2369 AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
  2370                                 , enable_render_gdi=yes)
  2371             if test x$enable_render_gdi = xyes; then
  2372                 AC_DEFINE(SDL_VIDEO_RENDER_GDI)
  2373             fi
  2374             AC_ARG_ENABLE(render-d3d,
  2375 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2376                                 , enable_render_d3d=yes)
  2377             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2378                 AC_DEFINE(SDL_VIDEO_RENDER_D3D)
  2379             fi
  2380         fi
  2381         # Set up files for the audio library
  2382         if test x$enable_audio = xyes; then
  2383             AC_DEFINE(SDL_AUDIO_DRIVER_WINWAVEOUT)
  2384             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2385             if test x$have_dsound = xyes; then
  2386                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2387                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2388             fi
  2389             have_audio=yes
  2390         fi
  2391         # Set up files for the joystick library
  2392         if test x$enable_joystick = xyes; then
  2393             if test x$have_dinput = xyes; then
  2394                 AC_DEFINE(SDL_JOYSTICK_DINPUT)
  2395                 SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_dxjoystick.c"
  2396                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8 -lole32"
  2397             else
  2398                 AC_DEFINE(SDL_JOYSTICK_WINMM)
  2399                 SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_mmjoystick.c"
  2400             fi
  2401             have_joystick=yes
  2402         fi
  2403         if test x$enable_haptic = xyes; then
  2404             if test x$have_dinput = xyes; then
  2405                 AC_DEFINE(SDL_HAPTIC_DINPUT)
  2406                 SOURCES="$SOURCES $srcdir/src/haptic/win32/SDL_syshaptic.c"
  2407                 have_haptic=yes
  2408             fi
  2409         fi
  2410         # Set up files for the cdrom library
  2411         if test x$enable_cdrom = xyes; then
  2412             AC_DEFINE(SDL_CDROM_WIN32)
  2413             SOURCES="$SOURCES $srcdir/src/cdrom/win32/*.c"
  2414             have_cdrom=yes
  2415         fi
  2416         # Set up files for the thread library
  2417         if test x$enable_threads = xyes; then
  2418             AC_DEFINE(SDL_THREAD_WIN32)
  2419             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
  2420             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
  2421             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
  2422             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2423             have_threads=yes
  2424         fi
  2425         # Set up files for the timer library
  2426         if test x$enable_timers = xyes; then
  2427             AC_DEFINE(SDL_TIMER_WIN32)
  2428             SOURCES="$SOURCES $srcdir/src/timer/win32/*.c"
  2429             have_timers=yes
  2430         fi
  2431         # Set up files for the shared object loading library
  2432         if test x$enable_loadso = xyes; then
  2433             AC_DEFINE(SDL_LOADSO_WIN32)
  2434             SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
  2435             have_loadso=yes
  2436         fi
  2437         # Set up the system libraries we need
  2438         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lunicows -luser32 -lgdi32 -lmsimg32 -lwinmm"
  2439         # The Win32 platform requires special setup
  2440         SOURCES="$SOURCES $srcdir/src/main/win32/*.rc"
  2441         SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
  2442         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2443         SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
  2444         ;;
  2445     *-*-beos*)
  2446         ARCH=beos
  2447         ac_default_prefix=/boot/develop/tools/gnupro
  2448         CheckDummyVideo
  2449         CheckDiskAudio
  2450         CheckDummyAudio
  2451         CheckBWINDOW
  2452         CheckBeGL
  2453         # Set up files for the audio library
  2454         if test x$enable_audio = xyes; then
  2455             AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO)
  2456             SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
  2457             have_audio=yes
  2458         fi
  2459         # Set up files for the joystick library
  2460         if test x$enable_joystick = xyes; then
  2461             AC_DEFINE(SDL_JOYSTICK_BEOS)
  2462             SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
  2463             have_joystick=yes
  2464         fi
  2465         # Set up files for the cdrom library
  2466         if test x$enable_cdrom = xyes; then
  2467             AC_DEFINE(SDL_CDROM_BEOS)
  2468             SOURCES="$SOURCES $srcdir/src/cdrom/beos/*.cc"
  2469             have_cdrom=yes
  2470         fi
  2471         # Set up files for the thread library
  2472         if test x$enable_threads = xyes; then
  2473             AC_DEFINE(SDL_THREAD_BEOS)
  2474             SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
  2475             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2476             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2477             have_threads=yes
  2478         fi
  2479         # Set up files for the timer library
  2480         if test x$enable_timers = xyes; then
  2481             AC_DEFINE(SDL_TIMER_BEOS)
  2482             SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
  2483             have_timers=yes
  2484         fi
  2485         # Set up files for the shared object loading library
  2486         if test x$enable_loadso = xyes; then
  2487             AC_DEFINE(SDL_LOADSO_BEOS)
  2488             SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
  2489             have_loadso=yes
  2490         fi
  2491         # The BeOS platform requires special setup.
  2492         SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
  2493         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2494         ;;
  2495     *-*-darwin* )
  2496         # This could be either full "Mac OS X", or plain "Darwin" which is
  2497         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2498         # Next line is broken, and a few files below require Mac OS X (full)
  2499         ARCH=macosx
  2500 
  2501         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  2502         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  2503         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  2504 
  2505         # HACK: Reset EXTRA_LDFLAGS; the only thing it contains at this point
  2506         # is -lm which is not needed under Mac OS X. But for some reasons it
  2507         # also tends to contain spurious -L switches, which we don't want to
  2508         # use here or in sdl-config. Hence we reset it.
  2509         EXTRA_LDFLAGS=""
  2510 
  2511         CheckVisibilityHidden
  2512         CheckDummyVideo
  2513         CheckDiskAudio
  2514         CheckDummyAudio
  2515         CheckDLOPEN
  2516 
  2517         # Set up files for the shared object loading library
  2518         # (this needs to be done before the dynamic X11 check)
  2519         if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
  2520             AC_DEFINE(SDL_LOADSO_DLCOMPAT)
  2521             SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
  2522             have_loadso=yes
  2523         fi
  2524 
  2525         CheckCOCOA
  2526         CheckX11
  2527         CheckMacGL
  2528         CheckOpenGLX11
  2529         CheckPTHREAD
  2530 
  2531         # Good optimization on Mac OS X, yes...
  2532         EXTRA_CFLAGS="$EXTRA_CFLAGS -falign-loops=16"
  2533 
  2534         # Need this or things might misbuild on a G3.
  2535         EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
  2536 
  2537         # Set up files for the audio library
  2538         if test x$enable_audio = xyes; then
  2539             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO)
  2540             SOURCES="$SOURCES $srcdir/src/audio/macosx/*.c"
  2541             AC_DEFINE(SDL_AUDIO_DRIVER_SNDMGR)
  2542             SOURCES="$SOURCES $srcdir/src/audio/macrom/*.c"
  2543             have_audio=yes
  2544         fi
  2545         # Set up files for the joystick library
  2546         if test x$enable_joystick = xyes; then
  2547             AC_DEFINE(SDL_JOYSTICK_IOKIT)
  2548             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  2549             have_joystick=yes
  2550         fi
  2551         # Set up files for the haptic library
  2552         if test x$enable_haptic = xyes; then
  2553             AC_DEFINE(SDL_HAPTIC_IOKIT)
  2554             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2555             have_haptic=yes
  2556             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2557         fi
  2558         # Set up files for the cdrom library
  2559         if test x$enable_cdrom = xyes; then
  2560             AC_DEFINE(SDL_CDROM_MACOSX)
  2561             SOURCES="$SOURCES $srcdir/src/cdrom/macosx/*.c"
  2562             have_cdrom=yes
  2563         fi
  2564         # Set up files for the timer library
  2565         if test x$enable_timers = xyes; then
  2566             AC_DEFINE(SDL_TIMER_UNIX)
  2567             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2568             have_timers=yes
  2569         fi
  2570         # The Mac OS X platform requires special setup.
  2571         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2572         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  2573         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  2574         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  2575         # If either the audio or CD driver is used, add the AudioUnit framework
  2576         if test x$enable_audio = xyes -o x$enable_cdrom = xyes; then
  2577             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -framework,AudioToolbox -Wl,-framework,AudioUnit"
  2578         fi
  2579         ;;
  2580     *-*-mint*)
  2581         ARCH=mint
  2582         CheckDummyVideo
  2583         CheckDiskAudio
  2584         CheckDummyAudio
  2585         CheckAtariBiosEvent
  2586         CheckAtariXbiosVideo
  2587         CheckAtariGemVideo
  2588         CheckAtariAudio
  2589         CheckAtariLdg
  2590         CheckAtariOSMesa
  2591         CheckPTH
  2592         # Set up files for the audio library
  2593         if test x$enable_threads = xyes -a x$enable_pth = xyes; then
  2594             if test x$enable_audio = xyes; then
  2595                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
  2596                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2597                 have_audio=yes
  2598             fi
  2599         fi
  2600         # Set up files for the joystick library
  2601         if test x$enable_joystick = xyes; then
  2602             AC_DEFINE(SDL_JOYSTICK_MINT)
  2603             SOURCES="$SOURCES $srcdir/src/joystick/mint/*.c"
  2604             have_joystick=yes
  2605         fi
  2606         # Set up files for the cdrom library
  2607         if test x$enable_cdrom = xyes; then
  2608             AC_DEFINE(SDL_CDROM_MINT)
  2609             SOURCES="$SOURCES $srcdir/src/cdrom/mint/*.c"
  2610             have_cdrom=yes
  2611         fi
  2612         # Set up files for the timer library
  2613         if test x$enable_timers = xyes; then
  2614             if test x$enable_threads = xyes -a x$enable_pth = xyes; then
  2615                 AC_DEFINE(SDL_TIMER_UNIX)
  2616                 SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2617             else
  2618                 AC_DEFINE(SDL_TIMER_MINT)
  2619                 SOURCES="$SOURCES $srcdir/src/timer/mint/*.c"
  2620                 SOURCES="$SOURCES $srcdir/src/timer/mint/*.S"
  2621             fi
  2622             have_timers=yes
  2623         fi
  2624         ;;
  2625     *-riscos)
  2626         ARCH=riscos
  2627         CheckOSS
  2628         CheckPTHREAD
  2629         # Set up files for the video library
  2630         if test x$enable_video = xyes; then
  2631             AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
  2632             SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
  2633             SOURCES="$SOURCES $srcdir/src/video/riscos/*.S"
  2634             have_video=yes
  2635         fi
  2636         # Set up files for the joystick library
  2637         if test x$enable_joystick = xyes; then
  2638             AC_DEFINE(SDL_JOYSTICK_RISCOS)
  2639             SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
  2640             have_joystick=yes
  2641         fi
  2642         # Set up files for the timer library
  2643         if test x$enable_timers = xyes; then
  2644             AC_DEFINE(SDL_TIMER_RISCOS)
  2645             SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
  2646             have_timers=yes
  2647         fi
  2648         # The RISC OS platform requires special setup.
  2649         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
  2650         ;;
  2651     *)
  2652         AC_MSG_ERROR([
  2653 *** Unsupported host:  Please add to configure.in
  2654         ])
  2655         ;;
  2656 esac
  2657 
  2658 # Verify that we have all the platform specific files we need
  2659 
  2660 if test x$enable_joystick = xyes; then
  2661   if test x$have_joystick != xyes; then
  2662     # Wants joystick subsystem, but doesn't have a platform-specific backend...
  2663     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2664   fi
  2665 fi
  2666 if test x$have_haptic != xyes; then
  2667     if test x$enable_haptic = xyes; then
  2668         AC_DEFINE(SDL_HAPTIC_DISABLED)
  2669     fi
  2670     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2671 fi
  2672 if test x$have_cdrom != xyes; then
  2673     if test x$enable_cdrom = xyes; then
  2674         AC_DEFINE(SDL_CDROM_DISABLED)
  2675     fi
  2676     SOURCES="$SOURCES $srcdir/src/cdrom/dummy/*.c"
  2677 fi
  2678 if test x$have_threads != xyes; then
  2679     if test x$enable_threads = xyes; then
  2680         AC_DEFINE(SDL_THREADS_DISABLED)
  2681     fi
  2682     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  2683 fi
  2684 if test x$have_timers != xyes; then
  2685     if test x$enable_timers = xyes; then
  2686         AC_DEFINE(SDL_TIMERS_DISABLED)
  2687     fi
  2688     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  2689 fi
  2690 if test x$have_loadso != xyes; then
  2691     if test x$enable_loadso = xyes; then
  2692         AC_DEFINE(SDL_LOADSO_DISABLED)
  2693     fi
  2694     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  2695 fi
  2696 if test x$SDLMAIN_SOURCES = x; then
  2697     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  2698 fi
  2699 
  2700 OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.asm,$(objects)/\1.lo,g'`
  2701 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
  2702 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
  2703 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
  2704 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'`
  2705 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  2706 
  2707 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.o,g'`
  2708 SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2709 
  2710 # Set runtime shared library paths as needed
  2711 
  2712 if test "x$enable_rpath" = "xyes"; then
  2713   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
  2714     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  2715   fi
  2716   if test $ARCH = solaris; then
  2717     SDL_RLD_FLAGS="-R\${libdir}"
  2718   fi
  2719 else
  2720   SDL_RLD_FLAGS=""
  2721 fi
  2722 
  2723 case "$ARCH" in
  2724   macosx)
  2725     # Evil hack to allow static linking on Mac OS X
  2726     SDL_STATIC_LIBS="\${libdir}/libSDL.a $EXTRA_LDFLAGS"
  2727     ;;
  2728   *)
  2729     SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  2730     ;;
  2731 esac
  2732 
  2733 dnl Expand the cflags and libraries needed by apps using SDL
  2734 AC_SUBST(SDL_CFLAGS)
  2735 AC_SUBST(SDL_LIBS)
  2736 AC_SUBST(SDL_STATIC_LIBS)
  2737 AC_SUBST(SDL_RLD_FLAGS)
  2738 if test x$enable_shared = xyes; then
  2739     ENABLE_SHARED_TRUE=
  2740     ENABLE_SHARED_FALSE="#"
  2741 else
  2742     ENABLE_SHARED_TRUE="#"
  2743     ENABLE_SHARED_FALSE=
  2744 fi
  2745 if test x$enable_static = xyes; then
  2746     ENABLE_STATIC_TRUE=
  2747     ENABLE_STATIC_FALSE="#"
  2748 else
  2749     ENABLE_STATIC_TRUE="#"
  2750     ENABLE_STATIC_FALSE=
  2751 fi
  2752 AC_SUBST(ENABLE_SHARED_TRUE)
  2753 AC_SUBST(ENABLE_SHARED_FALSE)
  2754 AC_SUBST(ENABLE_STATIC_TRUE)
  2755 AC_SUBST(ENABLE_STATIC_FALSE)
  2756 
  2757 dnl Expand the sources and objects needed to build the library
  2758 AC_SUBST(ac_aux_dir)
  2759 AC_SUBST(INCLUDE)
  2760 AC_SUBST(SOURCES)
  2761 AC_SUBST(OBJECTS)
  2762 AC_SUBST(SDLMAIN_SOURCES)
  2763 AC_SUBST(SDLMAIN_OBJECTS)
  2764 AC_SUBST(BUILD_CFLAGS)
  2765 AC_SUBST(EXTRA_CFLAGS)
  2766 AC_SUBST(BUILD_LDFLAGS)
  2767 AC_SUBST(EXTRA_LDFLAGS)
  2768 AC_SUBST(WINDRES)
  2769 
  2770 AC_OUTPUT([
  2771     Makefile sdl-config SDL.spec SDL.qpg sdl.pc
  2772 ], [
  2773     : >build-deps
  2774     if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
  2775 ])