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