configure.in
author Sam Lantinga <slouken@libsdl.org>
Fri, 29 Feb 2008 13:55:44 +0000
branchSDL-1.2
changeset 4139 568c9b3c0167
parent 4134 31c7c57af8a4
child 4164 7a4c511c980a
permissions -rw-r--r--
* Added configure option --enable-screensaver, to allow enabling the screensaver by default.
* Use XResetScreenSaver() instead of disabling screensaver entirely.

Full discussion summary from Erik on the SDL mailing list:

Current behaviour
=================

SDL changes the user's display power management settings without
permission from the user and without telling the user.

The interface that it uses to do so is DPMSDisable/DPMSEnable, which
should only ever be used by configuration utilities like KControl, never
by normal application programs, let alone by the libraries that they
use. Using an interface that is not at all intended for what SDL tries
to achieve means that it will not work as it should. Firstly, the power
management is completely disabled during the whole lifetime of the SDL
program, not only when it should be. Secondly, it makes SDL
non-reentrant, meaning that things will break when multiple SDL programs
are clients of the same X server simultaneously. Thirdly, no cleanup
mechanism ensures that the setting is restored if the client does not do
that (for example if it crashes).

In addition to that, this interface is broken on xorg,
[http://bugs.freedesktop.org/show_bug.cgi?id=13962], so what SDL tries
to do does not work at all on that implementation of the X Window
System. (The reason that the DPMSEnable works in KControl is that it
calls DPMSSetTimeout immediately after,
[http://websvn.kde.org/tags/KDE/3.5.9/kdebase/kcontrol/energy/energy.cpp?annotate=774532#l343]).


The problems that the current behaviour causes
==============================================
1. Information leak. When the user is away, someone might see what the
user has on the display when the user counts on the screensaver
preventing this. This does not even require physical access to the
workstation, it is enough to see it from a distance.
2. Draining battery. An SDL program that runs on a laptop will quickly
drain the battery while the user is away. The system will soon shut down
and require recharging before being usable again, while it should in
fact have consumed very little energy if the user's settings would have
been obeyed.
3. Wasting energy. Even if battery issues are not considered, energy as
such is wasted.
4. Display wear. The display may be worn out.


The problems that the current behaviour tries to solve
======================================================

1. Preventing screensaver while playing movies.
Many SDL applications are media players. They have reasons to prevent
screensavers from being activated while a movie is being played. When a
user clicks on the play button it can be interpreted as saying "play
this movie, but do not turn off the display while playing it, because I
will watch it even though I do not interact with the system".

2. Preventing screensaver when some input bypasses X.
Sometimes SDL uses input from another source than the X server, so
that the X server is bypassed. This obviously breaks the screensaver
handling. SDL tries to work around that.

3. Preventing screensaver when all input bypasses X.
There is something called Direct Graphics Access mode, where a
program takes control of both the display and the input devices from the
X server. This obviously means that the X server can not handle the
screensaver alone, since screensaver handling depends on input handling.
SDL does not do what it should to help the X server to handle the
screensaver. Nor does SDL take care of screeensaver handling itself. SDL
simply disables the screensaver completely.


How the problems should be solved
=================================

The correct way for an application program to prevent the screensaver
under X is to call XResetScreenSaver. This was recently discovered and
implemented by the mplayer developers,
[http://svn.mplayerhq.hu/mplayer?view=rev&revision=25637]. SDL needs to
wrap this in an API call (SDL_ResetScreenSaver) and implement it for the
other video targets (if they do not have a corresponding call, SDL
should do what it takes on that particular target, for example sending
fake key events).

1. When a movie is played, the player should reset the screensaver when
the animation is advanced to a new frame. The same applies to anything
similar, like slideshows.

2. When the X server is handling input, it must handle all input
(keyboards, mice, gamepads, ...). This is necessary, not only to be able
to handle the screensaver, but also so that it can send the events to
the correct (the currently active) client. If there is an input device
that the X server can not handle for some reason (such as lack of Plug
and Play capability), the program that handles the device as a
workaround must simulate what would happen if the X server would have
handled the device, by calling XResetScreenSaver when input is received
from the device.

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