configure.in
author Sam Lantinga
Thu, 16 Feb 2006 10:11:48 +0000
changeset 1361 19418e4422cb
parent 1354 22f39393668a
child 1363 dc623bb58c9a
permissions -rw-r--r--
New configure-based build system. Still work in progress, but much improved
     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=10
    20 SDL_INTERFACE_AGE=3
    21 SDL_BINARY_AGE=10
    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 host and target build environment
    43 AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
    44 AC_CANONICAL_SYSTEM
    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 Check for tools
    53 #AC_LIBTOOL_DLOPEN
    54 AC_LIBTOOL_WIN32_DLL
    55 AC_PROG_LIBTOOL
    56 AC_PROG_CC
    57 AC_PROG_CXX
    58 AC_PROG_INSTALL
    59 
    60 dnl Check for compiler characteristics
    61 AC_C_CONST
    62 AC_C_INLINE
    63 AC_C_VOLATILE
    64 
    65 dnl See whether we are allowed to use the system C library
    66 AC_ARG_ENABLE(libc,
    67 AC_HELP_STRING([--enable-libc], [Use the system C library [default=yes]]),
    68               , enable_libc=yes)
    69 if test x$enable_libc = xyes; then
    70     AC_DEFINE(HAVE_LIBC)
    71 
    72     dnl Check for C library headers
    73     AC_HEADER_STDC
    74     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 signal.h)
    75 
    76     dnl Check for typedefs, structures, etc.
    77     AC_TYPE_SIZE_T
    78     if test x$ac_cv_header_inttypes_h = xyes -o x$ac_cv_header_stdint_h = xyes; then
    79         AC_CHECK_TYPE(int64_t)
    80         if test x$ac_cv_type_int64_t = xyes; then
    81             AC_DEFINE(SDL_HAS_64BIT_TYPE)
    82         fi
    83         have_inttypes=yes
    84     fi
    85 
    86     dnl Checks for library functions.
    87     AC_FUNC_ALLOCA
    88     AC_FUNC_MEMCMP
    89     if test x$ac_cv_func_memcmp_working = xyes; then
    90         AC_DEFINE(HAVE_MEMCMP)
    91     fi
    92     AC_FUNC_STRTOD
    93     if test x$ac_cv_func_strtod = xyes; then
    94         AC_DEFINE(HAVE_STRTOD)
    95     fi
    96     AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strcpy strncpy strcat strncat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol _i64toa _ui64toa strtoll atoi atof strcmp strncmp stricmp strcasecmp sscanf snprintf vsnprint sigaction setjmp nanosleep)
    97 fi
    98 
    99 if test x$have_inttypes != xyes; then
   100     AC_CHECK_SIZEOF(char, 1)
   101     AC_CHECK_SIZEOF(short, 2)
   102     AC_CHECK_SIZEOF(int, 4)
   103     AC_CHECK_SIZEOF(long, 4)
   104     AC_CHECK_SIZEOF(long long, 8)
   105     if test x$ac_cv_sizeof_char = x1; then
   106         AC_DEFINE(int8_t, signed char)
   107         AC_DEFINE(uint8_t, unsigned char)
   108     fi
   109     if test x$ac_cv_sizeof_short = x2; then
   110         AC_DEFINE(int16_t, signed short)
   111         AC_DEFINE(uint16_t, unsigned short)
   112     else
   113         if test x$ac_cv_sizeof_int = x2; then
   114             AC_DEFINE(int16_t, signed int)
   115             AC_DEFINE(uint16_t, unsigned int)
   116         fi
   117     fi
   118     if test x$ac_cv_sizeof_int = x4; then
   119         AC_DEFINE(int32_t, signed int)
   120         AC_DEFINE(uint32_t, unsigned int)
   121     else
   122         if test x$ac_cv_sizeof_long = x4; then
   123             AC_DEFINE(int32_t, signed long)
   124             AC_DEFINE(uint32_t, unsigned long)
   125         fi
   126     fi
   127     if test x$ac_cv_sizeof_long = x8; then
   128         AC_DEFINE(int64_t, signed long)
   129         AC_DEFINE(uint64_t, unsigned long)
   130         AC_DEFINE(SDL_HAS_64BIT_TYPE)
   131     else
   132         if test x$ac_cv_sizeof_long_long = x8; then
   133             AC_DEFINE(int64_t, signed long long)
   134             AC_DEFINE(uint64_t, unsigned long long)
   135             AC_DEFINE(SDL_HAS_64BIT_TYPE)
   136         fi
   137     fi
   138     AC_DEFINE(size_t, unsigned int)
   139     AC_DEFINE(uintptr_t, unsigned long)
   140 fi
   141 
   142 # Set up the build preprocessor flags
   143 INCLUDE="-I$srcdir/include"
   144 if test x$srcdir != x.; then
   145     INCLUDE="-Iinclude $INCLUDE"
   146 fi
   147 BUILD_CFLAGS='-D_GNU_SOURCE=1 $(INCLUDE)'
   148 
   149 # Standard C sources
   150 SOURCES="$SOURCES $srcdir/src/*.c"
   151 SOURCES="$SOURCES $srcdir/src/audio/*.c"
   152 SOURCES="$SOURCES $srcdir/src/cdrom/*.c"
   153 SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
   154 SOURCES="$SOURCES $srcdir/src/events/*.c"
   155 SOURCES="$SOURCES $srcdir/src/file/*.c"
   156 SOURCES="$SOURCES $srcdir/src/joystick/*.c"
   157 SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
   158 SOURCES="$SOURCES $srcdir/src/thread/*.c"
   159 SOURCES="$SOURCES $srcdir/src/timer/*.c"
   160 SOURCES="$SOURCES $srcdir/src/video/*.c"
   161 
   162 # Set up the build libraries needed
   163 BUILD_LIBS=""
   164 
   165 dnl Initialize the compiler and linker flags for SDL applications
   166 
   167 SDL_CFLAGS=""
   168 SDL_LIBS="-lSDL"
   169 
   170 dnl Add the math library for the new gamma correction support
   171 
   172 case "$target" in
   173     *-*-cygwin* | *-*-mingw32*)
   174         MATHLIB=""
   175         ;;
   176     *-*-beos*)
   177         MATHLIB=""
   178         ;;
   179     *-*-darwin*)
   180         MATHLIB=""
   181         ;;
   182     *)
   183         MATHLIB="-lm"
   184         ;;
   185 esac
   186 BUILD_LIBS="$BUILD_LIBS $MATHLIB"
   187 
   188 dnl Enable/disable various subsystems of the SDL library
   189 
   190 AC_ARG_ENABLE(audio,
   191 AC_HELP_STRING([--enable-audio], [Enable the audio subsystem [default=yes]]),
   192               , enable_audio=yes)
   193 if test x$enable_audio != xyes; then
   194     AC_DEFINE(SDL_AUDIO_DISABLED)
   195 fi
   196 AC_ARG_ENABLE(video,
   197 AC_HELP_STRING([--enable-video], [Enable the video subsystem [default=yes]]),
   198               , enable_video=yes)
   199 if test x$enable_video != xyes; then
   200     AC_DEFINE(SDL_VIDEO_DISABLED)
   201 fi
   202 AC_ARG_ENABLE(events,
   203 AC_HELP_STRING([--enable-events], [Enable the events subsystem [default=yes]]),
   204               , enable_events=yes)
   205 if test x$enable_events != xyes; then
   206     AC_DEFINE(SDL_EVENTS_DISABLED)
   207 fi
   208 AC_ARG_ENABLE(joystick,
   209 AC_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [default=yes]]),
   210               , enable_joystick=yes)
   211 if test x$enable_joystick != xyes; then
   212     AC_DEFINE(SDL_JOYSTICK_DISABLED)
   213 fi
   214 AC_ARG_ENABLE(cdrom,
   215 AC_HELP_STRING([--enable-cdrom], [Enable the cdrom subsystem [default=yes]]),
   216               , enable_cdrom=yes)
   217 if test x$enable_cdrom != xyes; then
   218     AC_DEFINE(SDL_CDROM_DISABLED)
   219 fi
   220 AC_ARG_ENABLE(threads,
   221 AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [default=yes]]),
   222               , enable_threads=yes)
   223 if test x$enable_threads != xyes; then
   224     AC_DEFINE(SDL_THREADS_DISABLED)
   225 fi
   226 AC_ARG_ENABLE(timers,
   227 AC_HELP_STRING([--enable-timers], [Enable the timer subsystem [default=yes]]),
   228               , enable_timers=yes)
   229 if test x$enable_timers != xyes; then
   230     AC_DEFINE(SDL_TIMERS_DISABLED)
   231 fi
   232 AC_ARG_ENABLE(file,
   233 AC_HELP_STRING([--enable-file], [Enable the file subsystem [default=yes]]),
   234               , enable_file=yes)
   235 if test x$enable_file != xyes; then
   236     AC_DEFINE(SDL_FILE_DISABLED)
   237 fi
   238 AC_ARG_ENABLE(loadso,
   239 AC_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [default=yes]]),
   240               , enable_loadso=yes)
   241 if test x$enable_loadso != xyes; then
   242     AC_DEFINE(SDL_LOADSO_DISABLED)
   243 fi
   244 AC_ARG_ENABLE(cpuinfo,
   245 AC_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [default=yes]]),
   246               , enable_cpuinfo=yes)
   247 if test x$enable_cpuinfo != xyes; then
   248     AC_DEFINE(SDL_CPUINFO_DISABLED)
   249 fi
   250 AC_ARG_ENABLE(assembly-blit,
   251 AC_HELP_STRING([--enable-asm-blit], [Enable assembly blitters [default=yes]]),
   252               , enable_asm_blit=yes)
   253 if test x$enable_asm_blit = xyes; then
   254     AC_DEFINE(SDL_ASSEMBLY_BLITTERS)
   255 fi
   256 
   257 dnl See if the OSS audio interface is supported
   258 CheckOSS()
   259 {
   260     AC_ARG_ENABLE(oss,
   261 AC_HELP_STRING([--enable-oss], [support the OSS audio API [default=yes]]),
   262                   , enable_oss=yes)
   263     if test x$enable_audio = xyes -a x$enable_oss = xyes; then
   264         AC_MSG_CHECKING(for OSS audio support)
   265         have_oss=no
   266         if test x$have_oss != xyes; then
   267             AC_TRY_COMPILE([
   268               #include <sys/soundcard.h>
   269             ],[
   270               int arg = SNDCTL_DSP_SETFRAGMENT;
   271             ],[
   272             have_oss=yes
   273             ])
   274         fi
   275         if test x$have_oss != xyes; then
   276             AC_TRY_COMPILE([
   277               #include <soundcard.h>
   278             ],[
   279               int arg = SNDCTL_DSP_SETFRAGMENT;
   280             ],[
   281             have_oss=yes
   282             AC_DEFINE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H)
   283             ])
   284         fi
   285         AC_MSG_RESULT($have_oss)
   286         if test x$have_oss = xyes; then
   287             AC_DEFINE(SDL_AUDIO_DRIVER_OSS)
   288             SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c"
   289             SOURCES="$SOURCES $srcdir/src/audio/dma/*.c"
   290             have_audio=yes
   291 
   292             # OpenBSD needs linking with ossaudio emulation library
   293             case "$target" in
   294                 *-*-openbsd*)
   295                     BUILD_LIBS="$BUILD_LIBS -lossaudio";;
   296             esac
   297         fi
   298     fi
   299 }
   300 
   301 dnl See if the ALSA audio interface is supported
   302 CheckALSA()
   303 {
   304     AC_ARG_ENABLE(alsa,
   305 AC_HELP_STRING([--enable-alsa], [support the ALSA audio API [default=yes]]),
   306                   , enable_alsa=yes)
   307     if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
   308         AM_PATH_ALSA(0.9.0, have_alsa=yes, have_alsa=no)
   309         # Restore all flags from before the ALSA detection runs
   310         CFLAGS="$alsa_save_CFLAGS"
   311         LDFLAGS="$alsa_save_LDFLAGS"
   312         LIBS="$alsa_save_LIBS"
   313         if test x$have_alsa = xyes; then
   314             AC_ARG_ENABLE(alsa-shared,
   315 AC_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [default=yes]]),
   316                           , enable_alsa_shared=yes)
   317             if test "x`echo $ALSA_LIBS | grep -- -L`" = "x"; then
   318                 if test "x`ls /lib/libasound.so.* 2> /dev/null`" != "x"; then
   319                     ALSA_LIBS="-L/lib $ALSA_LIBS"
   320                 elif test "x`ls /usr/lib/libasound.so.* 2> /dev/null`" != "x"; then
   321                     ALSA_LIBS="-L/usr/lib $ALSA_LIBS"
   322                 elif test "x`ls /usr/local/lib/libasound.so.* 2> /dev/null`" != "x"; then
   323                     ALSA_LIBS="-L/usr/local/lib $ALSA_LIBS"
   324                 fi
   325             fi
   326             alsa_lib_spec=`echo $ALSA_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libasound.so.*/'`
   327             alsa_lib=`ls $alsa_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
   328             echo "-- $alsa_lib_spec -> $alsa_lib"
   329 
   330             AC_DEFINE(SDL_AUDIO_DRIVER_ALSA)
   331             SOURCES="$SOURCES $srcdir/src/audio/alsa/*.c"
   332             BUILD_CFLAGS="$BUILD_CFLAGS $ALSA_CFLAGS"
   333             if test x$have_loadso != xyes && \
   334                test x$enable_alsa_shared = xyes; then
   335                 AC_MSG_ERROR([You must have SDL_LoadObject() support])
   336             fi
   337             if test x$have_loadso = xyes && \
   338                test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
   339                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ALSA_DYNAMIC, "$alsa_lib")
   340             else
   341                 BUILD_LIBS="$BUILD_LIBS $ALSA_LIBS"
   342             fi
   343             have_audio=yes
   344         fi
   345     fi
   346         if test x$have_alsa = xyes; then
   347             AC_ARG_ENABLE(alsa-shared,
   348 [  --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             if test x$have_loadso != xyes && \
   364                test x$enable_alsa_shared = xyes; then
   365                 AC_MSG_ERROR([You must have SDL_LoadObject() support])
   366             fi
   367             if test x$have_loadso = xyes && \
   368                test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
   369                 CFLAGS="$CFLAGS -DALSA_SUPPORT -DALSA_DYNAMIC=\$(alsa_lib) $ALSA_CFLAGS"
   370                 AC_SUBST(alsa_lib)
   371 
   372                 use_dlvsym=no
   373                 AC_CHECK_LIB(dl, dlvsym, [use_dlvsym=yes])
   374                 if test x$use_dlvsym = xyes; then
   375                     CFLAGS="$CFLAGS -DUSE_DLVSYM"
   376                 fi
   377             else
   378                 CFLAGS="$CFLAGS -DALSA_SUPPORT $ALSA_CFLAGS"
   379                 SYSTEM_LIBS="$SYSTEM_LIBS $ALSA_LIBS"
   380             fi
   381             SDL_SRCS="$SDL_SRCS `(cd $srcdir && ls audio/alsa/*.c)`"
   382         fi
   383 }
   384 
   385 dnl Check whether we want to use IRIX 6.5+ native audio or not
   386 CheckDMEDIA()
   387 {
   388     if test x$enable_audio = xyes; then
   389         AC_MSG_CHECKING(for dmedia audio support)
   390         have_dmedia=no
   391         AC_TRY_COMPILE([
   392           #include <dmedia/audio.h>
   393         ],[
   394           ALport audio_port;
   395         ],[
   396         have_dmedia=yes
   397         ])
   398         AC_MSG_RESULT($have_dmedia)
   399         # Set up files for the audio library
   400         if test x$have_dmedia = xyes; then
   401             AC_DEFINE(SDL_AUDIO_DRIVER_DMEDIA)
   402             SOURCES="$SOURCES $srcdir/src/audio/dmedia/*.c"
   403             BUILD_LIBS="$BUILD_LIBS -laudio"
   404             have_audio=yes
   405         fi
   406     fi
   407 }
   408 
   409 dnl Find the ESD includes and libraries
   410 CheckESD()
   411 {
   412     AC_ARG_ENABLE(esd,
   413 AC_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [default=yes]]),
   414                   , enable_esd=yes)
   415     if test x$enable_audio = xyes -a x$enable_esd = xyes; then
   416         AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
   417         if test x$have_esd = xyes; then
   418             AC_ARG_ENABLE(esd-shared,
   419 AC_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [default=yes]]),
   420                           , enable_esd_shared=yes)
   421             esd_lib_spec=`echo $ESD_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libesd.so.*/'`
   422             esd_lib=`ls $esd_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
   423             echo "-- $esd_lib_spec -> $esd_lib"
   424             if test x$have_loadso != xyes && \
   425                test x$enable_esd_shared = xyes; then
   426                 AC_MSG_ERROR([You must have SDL_LoadObject() support])
   427             fi
   428             if test x$have_loadso = xyes && \
   429                test x$enable_esd_shared = xyes && test x$esd_lib != x; then
   430                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ESD_DYNAMIC, "$esd_lib")
   431             fi
   432             AC_DEFINE(SDL_AUDIO_DRIVER_ESD)
   433             SOURCES="$SOURCES $srcdir/src/audio/esd/*.c"
   434             BUILD_CFLAGS="$BUILD_CFLAGS $ESD_CFLAGS"
   435             BUILD_LIBS="$BUILD_LIBS $ESD_LIBS"
   436             have_audio=yes
   437         fi
   438     fi
   439 }
   440 
   441 CheckARTSC()
   442 {
   443     AC_ARG_ENABLE(arts,
   444 AC_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [default=yes]]),
   445                   , enable_arts=yes)
   446     if test x$enable_audio = xyes -a x$enable_arts = xyes; then
   447         AC_PATH_PROG(ARTSCONFIG, artsc-config)
   448         if test x$ARTSCONFIG = x -o x$ARTSCONFIG = x'"$ARTSCONFIG"'; then
   449             : # arts isn't installed
   450         else
   451             ARTS_CFLAGS=`$ARTSCONFIG --cflags`
   452             ARTS_LIBS=`$ARTSCONFIG --libs`
   453             ARTS_PREFIX=`$ARTSCONFIG --arts-prefix`
   454             AC_MSG_CHECKING(for aRts development environment)
   455             audio_arts=no
   456             save_CFLAGS="$CFLAGS"
   457             CFLAGS="$CFLAGS $ARTS_CFLAGS"
   458             AC_TRY_COMPILE([
   459              #include <artsc.h>
   460             ],[
   461              arts_stream_t stream;
   462             ],[
   463             audio_arts=yes
   464             ])
   465             CFLAGS="$save_CFLAGS"
   466             AC_MSG_RESULT($audio_arts)
   467             if test x$audio_arts = xyes; then
   468                 AC_ARG_ENABLE(arts-shared,
   469 AC_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [default=yes]]),
   470                               , enable_arts_shared=yes)
   471                 arts_lib_spec="$ARTS_PREFIX/lib/libartsc.so.*"
   472                 arts_lib=`ls $arts_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
   473                 echo "-- $arts_lib_spec -> $arts_lib"
   474                 if test x$have_loadso != xyes && \
   475                    test x$enable_arts_shared = xyes; then
   476                     AC_MSG_ERROR([You must have SDL_LoadObject() support])
   477                 fi
   478                 if test x$have_loadso = xyes && \
   479                    test x$enable_arts_shared = xyes && test x$arts_lib != x; then
   480                     AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ARTS_DYNAMIC, "$arts_lib")
   481                 fi
   482                 AC_DEFINE(SDL_AUDIO_DRIVER_ARTS)
   483                 SOURCES="$SOURCES $srcdir/src/audio/arts/*.c"
   484                 BUILD_CFLAGS="$BUILD_CFLAGS $ARTS_CFLAGS"
   485                 BUILD_LIBS="$BUILD_LIBS $ARTS_LIBS"
   486                 have_audio=yes
   487             fi
   488         fi
   489     fi
   490 }
   491 
   492 dnl See if the NAS audio interface is supported
   493 CheckNAS()
   494 {
   495     AC_ARG_ENABLE(nas,
   496 AC_HELP_STRING([--enable-nas], [support the NAS audio API [default=yes]]),
   497                   , enable_nas=yes)
   498     if test x$enable_audio = xyes -a x$enable_nas = xyes; then
   499         AC_MSG_CHECKING(for NAS audio support)
   500         have_nas=no
   501         if test -r /usr/X11R6/include/audio/audiolib.h; then
   502             have_nas=yes
   503             NAS_CFLAGS="-I/usr/X11R6/include/"
   504             NAS_LIBS="-laudio -lXt"
   505 
   506         dnl On IRIX, the NAS includes are in a different directory,
   507         dnl and libnas must be explicitly linked in
   508 
   509         elif test -r /usr/freeware/include/nas/audiolib.h; then
   510             have_nas=yes
   511             NAS_LIBS="-lnas -lXt"
   512         fi
   513         AC_MSG_RESULT($have_nas)
   514         if test x$have_nas = xyes; then
   515             AC_DEFINE(SDL_AUDIO_DRIVER_NAS)
   516             SOURCES="$SOURCES $srcdir/src/audio/nas/*.c"
   517             BUILD_CFLAGS="$BUILD_CFLAGS $NAS_CFLAGS"
   518             BUILD_LIBS="$BUILD_LIBS $NAS_LIBS"
   519             have_audio=yes
   520         fi
   521     fi
   522 }
   523 
   524 dnl rcg07142001 See if the user wants the disk writer audio driver...
   525 CheckDiskAudio()
   526 {
   527     AC_ARG_ENABLE(diskaudio,
   528 AC_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [default=yes]]),
   529                   , enable_diskaudio=yes)
   530     if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
   531         AC_DEFINE(SDL_AUDIO_DRIVER_DISK)
   532         SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
   533     fi
   534 }
   535 
   536 dnl Set up the Atari Audio driver
   537 CheckAtariAudio()
   538 {
   539     AC_ARG_ENABLE(mintaudio,
   540 AC_HELP_STRING([--enable-mintaudio], [support Atari audio driver [default=yes]]),
   541                   , enable_mintaudio=yes)
   542     if test x$enable_audio = xyes -a x$enable_mintaudio = xyes; then
   543         mintaudio=no
   544         AC_CHECK_HEADER(mint/falcon.h, have_mint_falcon_hdr=yes)
   545         if test x$have_mint_falcon_hdr = xyes; then
   546             mintaudio=yes
   547             AC_DEFINE(SDL_AUDIO_DRIVER_MINT)
   548             SOURCES="$SOURCES $srcdir/src/audio/ming/*.c"
   549             have_audio=yes
   550         fi
   551     fi
   552 }
   553 
   554 dnl See if we can use x86 assembly blitters
   555 # NASM is available from: http://nasm.sourceforge.net
   556 CheckNASM()
   557 {
   558     dnl Make sure we are running on an x86 platform
   559     case $target in
   560         i?86*)
   561             ;;
   562         *)
   563         # Nope, bail early.
   564             return
   565             ;;
   566     esac
   567     dnl Check for NASM (for assembly blit routines)
   568     AC_ARG_ENABLE(nasm,
   569 AC_HELP_STRING([--enable-nasm], [use nasm assembly blitters on x86 [default=yes]]),
   570                   , enable_nasm=yes)
   571     if test x$enable_video = xyes -a x$enable_asm_blit = xyes -a x$enable_nasm = xyes; then
   572         AC_PATH_PROG(NASM, nasm)
   573         if test x$NASM != x -a x$NASM != x'"$NASM"'; then
   574             AC_DEFINE(SDL_HERMES_BLITTERS)
   575             SOURCES="$SOURCES $srcdir/src/hermes/*.asm"
   576             case $ARCH in
   577               win32)
   578                   NASMFLAGS="-f win32"
   579                   ;;
   580               openbsd)
   581                   NASMFLAGS="-f aoutb"
   582                   ;;
   583               *)
   584                   NASMFLAGS="-f elf"
   585                   ;;
   586             esac
   587             AC_SUBST(NASM)
   588             AC_SUBST(NASMFLAGS)
   589 
   590             case "$target" in
   591                 # this line is needed for QNX, because it's not defined the __ELF__
   592                 *-*-qnx*)
   593                      BUILD_CFLAGS="$BUILD_CFLAGS -D__ELF__";;
   594                 *-*-solaris*)
   595                      BUILD_CFLAGS="$BUILD_CFLAGS -D__ELF__";;
   596             esac
   597         fi
   598     fi
   599 }
   600 
   601 dnl Check for altivec instruction support using gas syntax
   602 CheckAltivec()
   603 {
   604     AC_ARG_ENABLE(altivec,
   605 AC_HELP_STRING([--enable-altivec], [use altivec assembly blitters on PPC [default=yes]]),
   606                   , enable_altivec=yes)
   607     if test x$enable_video = xyes -a x$enable_asm_blit = xyes -a x$enable_altivec = xyes; then
   608         have_altivec_h_hdr=no
   609         AC_CHECK_HEADER(altivec.h, have_altivec_h_hdr=yes)
   610 
   611         save_CFLAGS="$CFLAGS"
   612         have_gcc_altivec=no
   613         AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
   614         altivec_CFLAGS="-maltivec"
   615         CFLAGS="$save_CFLAGS $altivec_CFLAGS"
   616 
   617         if test x$have_altivec_h_hdr = xyes; then
   618           AC_TRY_COMPILE([
   619           #include <altivec.h>
   620           vector unsigned int vzero() {
   621               return vec_splat_u32(0);
   622           }
   623           ],[
   624           ],[
   625           have_gcc_altivec=yes
   626           ])
   627           AC_MSG_RESULT($have_gcc_altivec)
   628         else
   629           AC_TRY_COMPILE([
   630           vector unsigned int vzero() {
   631               return vec_splat_u32(0);
   632           }
   633           ],[
   634           ],[
   635           have_gcc_altivec=yes
   636           ])
   637           AC_MSG_RESULT($have_gcc_altivec)
   638         fi
   639 
   640         if test x$have_gcc_altivec = xno; then
   641             AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
   642             altivec_CFLAGS="-faltivec"
   643             CFLAGS="$save_CFLAGS $altivec_CFLAGS"
   644             if test x$have_altivec_h_hdr = xyes; then
   645               AC_TRY_COMPILE([
   646               #include <altivec.h>
   647               vector unsigned int vzero() {
   648                   return vec_splat_u32(0);
   649               }
   650               ],[
   651               ],[
   652               have_gcc_altivec=yes
   653               ])
   654               AC_MSG_RESULT($have_gcc_altivec)
   655             else
   656               AC_TRY_COMPILE([
   657               vector unsigned int vzero() {
   658                   return vec_splat_u32(0);
   659               }
   660               ],[
   661               ],[
   662               have_gcc_altivec=yes
   663               ])
   664               AC_MSG_RESULT($have_gcc_altivec)
   665             fi
   666         fi
   667         CFLAGS="$save_CFLAGS"
   668 
   669         if test x$have_gcc_altivec = xyes; then
   670             AC_DEFINE(SDL_ALTIVEC_BLITTERS)
   671             if test x$have_altivec_h_hdr = xyes; then
   672               AC_DEFINE(HAVE_ALTIVEC_H)
   673             fi
   674             BUILD_CFLAGS="$BUILD_CFLAGS $altivec_CFLAGS"
   675         fi
   676     fi
   677 }
   678 
   679 dnl Do the iPod thing
   680 CheckIPod()
   681 {
   682     AC_ARG_ENABLE(ipod,
   683 AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [default=yes on arm-elf]]),
   684         , enable_ipod=yes)
   685 
   686     if test x$enable_ipod = xyes; then
   687         BUILD_CFLAGS="$BUILD_CFLAGS -DIPOD"
   688         AC_DEFINE(SDL_VIDEO_DRIVER_IPOD)
   689         SOURCES="$SOURCES $srcdir/src/video/ipod/*.c"
   690     fi
   691 }
   692 
   693 dnl Find the nanox include and library directories
   694 CheckNANOX()
   695 {
   696     AC_ARG_ENABLE(video-nanox,
   697         AC_HELP_STRING([--enable-video-nanox], [use nanox video driver [default=no]]),
   698         , enable_video_nanox=no)
   699 
   700     if test x$enable_video = xyes -a x$enable_video_nanox = xyes; then
   701         AC_ARG_ENABLE(nanox-debug,  
   702             AC_HELP_STRING([--enable-nanox-debug], [print debug messages [default=no]]),
   703             , enable_nanox_debug=no)
   704         if test x$enable_nanox_debug = xyes; then
   705             BUILD_CFLAGS="$BUILD_CFLAGS -DENABLE_NANOX_DEBUG"
   706         fi
   707 
   708         AC_ARG_ENABLE(nanox-share-memory,  
   709             AC_HELP_STRING([--enable-nanox-share-memory], [use share memory [default=no]]),
   710             , enable_nanox_share_memory=no)
   711         if test x$enable_nanox_share_memory = xyes; then
   712             BUILD_CFLAGS="$BUILD_CFLAGS -DNANOX_SHARE_MEMORY"
   713         fi
   714 
   715         AC_ARG_ENABLE(nanox_direct_fb, 
   716             AC_HELP_STRING([--enable-nanox-direct-fb], [use direct framebuffer access [default=no]]),
   717             , enable_nanox_direct_fb=no)
   718         if test x$enable_nanox_direct_fb = xyes; then
   719             BUILD_CFLAGS="$BUILD_CFLAGS -DENABLE_NANOX_DIRECT_FB"
   720         fi
   721 
   722         AC_DEFINE(SDL_VIDEO_DRIVER_NANOX)
   723         SOURCES="$SOURCES $srcdir/src/video/nanox/*.c"
   724         BUILD_LIBS="$BUILD_LIBS -lnano-X"
   725         have_video=yes
   726     fi
   727 }
   728 
   729 dnl Find the X11 include and library directories
   730 CheckX11()
   731 {
   732     AC_ARG_ENABLE(video-x11,
   733 AC_HELP_STRING([--enable-video-x11], [use X11 video driver [default=yes]]),
   734                   , enable_video_x11=yes)
   735     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
   736         AC_PATH_X
   737         AC_PATH_XTRA
   738         if test x$have_x = xyes; then
   739             AC_ARG_ENABLE(x11-shared,
   740 AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [default=yes]]),
   741                           , enable_x11_shared=yes)
   742 
   743             case "$target" in
   744                 *-*-darwin* )
   745                     x11_lib='/usr/X11R6/lib/libX11.6.dylib'
   746                     x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
   747                     ;;
   748                 *-*-osf* )
   749                     x11_lib='libX11.so'
   750                     x11ext_lib='libXext.so'
   751                     ;;
   752                 *)
   753                     x11_lib='libX11.so.6'
   754                     x11ext_lib='libXext.so.6'
   755                     ;;
   756             esac
   757 
   758             X_CFLAGS="$X_CFLAGS -DXTHREADS"
   759             if test x$ac_cv_func_shmat != xyes; then
   760                 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
   761             fi
   762             if test x$have_loadso != xyes && \
   763                test x$enable_x11_shared = xyes; then
   764                 AC_MSG_ERROR([You must have SDL_LoadObject() support])
   765             fi
   766 
   767             if test x$have_loadso = xyes && \
   768                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
   769                 echo "-- dynamic libX11 -> $x11_lib"
   770                 echo "-- dynamic libX11ext -> $x11ext_lib"
   771                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib")
   772                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib")
   773             else
   774                 X_LIBS="$X_LIBS -lX11 -lXext"
   775             fi
   776 
   777 
   778             AC_DEFINE(SDL_VIDEO_DRIVER_X11)
   779             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
   780             BUILD_CFLAGS="$BUILD_CFLAGS $X_CFLAGS"
   781             BUILD_LIBS="$BUILD_LIBS $X_LIBS"
   782             have_video=yes
   783 
   784             AC_ARG_ENABLE(dga,
   785 AC_HELP_STRING([--enable-dga], [allow use of X11 DGA code [default=yes]]),
   786                           , enable_dga=yes)
   787             if test x$enable_dga = xyes; then
   788                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86dga/*.c"
   789             fi
   790             AC_ARG_ENABLE(video-dga,
   791 AC_HELP_STRING([--enable-video-dga], [use DGA 2.0 video driver [default=yes]]),
   792                   , enable_video_dga=yes)
   793             if test x$enable_dga = xyes -a x$enable_video_dga = xyes; then
   794                 AC_DEFINE(SDL_VIDEO_DRIVER_DGA)
   795                 SOURCES="$SOURCES $srcdir/src/video/dga/*.c"
   796             fi
   797             AC_ARG_ENABLE(video-x11-dgamouse,
   798 AC_HELP_STRING([--enable-video-x11-dgamouse], [use X11 DGA for mouse events [default=yes]]),
   799                           , enable_video_x11_dgamouse=yes)
   800             if test x$enable_dga = xyes -a x$enable_video_x11_dgamouse = xyes; then
   801                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_DGAMOUSE)
   802             fi
   803             AC_ARG_ENABLE(video-x11-vm,
   804 AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [default=yes]]),
   805                           , enable_video_x11_vm=yes)
   806             if test x$enable_video_x11_vm = xyes; then
   807                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_VIDMODE)
   808                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86vm/*.c"
   809             fi
   810             AC_ARG_ENABLE(video-x11-xv,
   811 AC_HELP_STRING([--enable-video-x11-xv], [use X11 XvImage extension for video [default=yes]]),
   812                           , enable_video_x11_xv=yes)
   813             if test x$enable_video_x11_xv = xyes; then
   814                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XV)
   815                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xv/*.c"
   816             fi
   817             AC_ARG_ENABLE(video-x11-xinerama,
   818 AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [default=yes]]),
   819                             , enable_video_x11_xinerama=yes)
   820             if test x$enable_video_x11_xinerama = xyes; then
   821                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA)
   822                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xinerama/*.c"
   823             fi
   824             AC_ARG_ENABLE(video-x11-xme,
   825 AC_HELP_STRING([--enable-video-x11-xme], [enable Xi Graphics XME for fullscreen [default=yes]]),
   826                             , enable_video_x11_xme=yes)
   827             if test x$enable_video_x11_xme = xyes; then
   828                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XME)
   829                 SOURCES="$SOURCES $srcdir/src/video/Xext/XME/*.c"
   830             fi
   831         fi
   832     fi
   833 }
   834 
   835 dnl Check for QNX photon video driver
   836 CheckPHOTON()
   837 {
   838     AC_ARG_ENABLE(video-photon,
   839 AC_HELP_STRING([--enable-video-photon], [use QNX Photon video driver [default=yes]]),
   840                   , enable_video_photon=yes)
   841     if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
   842         AC_MSG_CHECKING(for QNX Photon support)
   843         video_photon=no
   844         AC_TRY_COMPILE([
   845           #include <Ph.h>
   846           #include <Pt.h>
   847           #include <photon/Pg.h>
   848           #include <photon/PdDirect.h>
   849         ],[
   850          PgDisplaySettings_t *visual;
   851         ],[
   852         video_photon=yes
   853         ])
   854         AC_MSG_RESULT($video_photon)
   855         if test x$video_photon = xyes; then
   856             AC_DEFINE(SDL_VIDEO_DRIVER_PHOTON)
   857             SOURCES="$SOURCES $srcdir/src/video/photon/*.c"
   858             BUILD_LIBS="$BUILD_LIBS -lph"
   859             have_video=yes
   860 
   861             CheckOpenGLQNX
   862         fi
   863     fi
   864 }
   865 
   866 dnl Set up the BWindow video driver if enabled
   867 CheckBWINDOW()
   868 {
   869     if test x$enable_video = xyes; then
   870         AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW)
   871         SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
   872         have_video=yes
   873     fi
   874 }
   875 
   876 dnl Set up the Carbon/QuickDraw video driver for Mac OS X (but not Darwin)
   877 CheckCARBON()
   878 {
   879     AC_ARG_ENABLE(video-carbon,
   880 AC_HELP_STRING([--enable-video-carbon], [use Carbon/QuickDraw video driver [default=no]]),
   881                   , enable_video_carbon=no)
   882     if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
   883         AC_MSG_CHECKING(for Carbon framework)
   884         have_carbon=no
   885         AC_TRY_COMPILE([
   886           #include <Carbon/Carbon.h>
   887         ],[
   888         ],[
   889         have_carbon=yes
   890         ])
   891         AC_MSG_RESULT($have_carbon)
   892         if test x$have_carbon = xyes; then
   893             AC_DEFINE(SDL_VIDEO_DRIVER_TOOLBOX)
   894             SOURCES="$SOURCES $srcdir/src/video/maccommon/*.c"
   895             SOURCES="$SOURCES $srcdir/src/video/macrom/*.c"
   896             have_video=yes
   897         fi
   898     fi
   899 }
   900 
   901 dnl Set up the Cocoa/Quartz video driver for Mac OS X (but not Darwin)
   902 CheckCOCOA()
   903 {
   904     AC_ARG_ENABLE(video-cocoa,
   905 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa/Quartz video driver [default=yes]]),
   906                   , enable_video_cocoa=yes)
   907     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
   908         save_CFLAGS="$CFLAGS"
   909         dnl work around that we don't have Objective-C support in autoconf
   910         CFLAGS="$CFLAGS -x objective-c"
   911         AC_MSG_CHECKING(for Cocoa framework)
   912         have_cocoa=no
   913         AC_TRY_COMPILE([
   914           #import <Cocoa/Cocoa.h>
   915         ],[
   916         ],[
   917         have_cocoa=yes
   918         ])
   919         AC_MSG_RESULT($have_cocoa)
   920         CFLAGS="$save_CFLAGS"
   921         if test x$have_cocoa = xyes; then
   922             AC_DEFINE(SDL_VIDEO_DRIVER_QUARTZ)
   923             SOURCES="$SOURCES $srcdir/src/video/quartz/*.m"
   924             have_video=yes
   925         fi
   926     fi
   927 }
   928 
   929 dnl Find the framebuffer console includes
   930 CheckFBCON()
   931 {
   932     AC_ARG_ENABLE(video-fbcon,
   933 AC_HELP_STRING([--enable-video-fbcon], [use framebuffer console video driver [default=yes]]),
   934                   , enable_video_fbcon=yes)
   935     if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
   936         AC_MSG_CHECKING(for framebuffer console support)
   937         video_fbcon=no
   938         AC_TRY_COMPILE([
   939          #include <linux/fb.h>
   940          #include <linux/kd.h>
   941          #include <linux/keyboard.h>
   942         ],[
   943         ],[
   944         video_fbcon=yes
   945         ])
   946         AC_MSG_RESULT($video_fbcon)
   947         if test x$video_fbcon = xyes; then
   948             AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
   949             SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
   950             have_video=yes
   951         fi
   952     fi
   953 }
   954 
   955 dnl Find DirectFB
   956 CheckDirectFB()
   957 {
   958     AC_ARG_ENABLE(video-directfb,
   959 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [default=no]]),
   960                   , enable_video_directfb=no)
   961     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
   962         video_directfb=no
   963 
   964         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   965         if test x$PKG_CONFIG = xno ; then
   966             AC_MSG_WARN([*** pkg-config is required to build the DirectFB video driver.])
   967         else
   968             AC_MSG_CHECKING(for DirectFB support)
   969 
   970             if ! $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then
   971                 AC_MSG_ERROR([*** pkg-config too old; version 0.7 or better required.])
   972             fi
   973 
   974             DIRECTFB_REQUIRED_VERSION=0.9.15
   975 
   976             if $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb ; then
   977                 DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
   978                 DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
   979                 video_directfb=yes
   980             fi
   981         fi
   982 
   983         AC_MSG_RESULT($video_directfb)
   984         if test x$video_directfb = xyes; then
   985             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
   986             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
   987             BUILD_CFLAGS="$BUILD_CFLAGS $DIRECTFB_CFLAGS"
   988             BUILD_LIBS="$BUILD_LIBS $DIRECTFB_LIBS"
   989             have_video=yes
   990         fi
   991     fi
   992 }
   993 
   994 dnl See if we're running on PlayStation 2 hardware
   995 CheckPS2GS()
   996 {
   997     AC_ARG_ENABLE(video-ps2gs,
   998 AC_HELP_STRING([--enable-video-ps2gs], [use PlayStation 2 GS video driver [default=yes]]),
   999                   , enable_video_ps2gs=yes)
  1000     if test x$enable_video = xyes -a x$enable_video_ps2gs = xyes; then
  1001         AC_MSG_CHECKING(for PlayStation 2 GS support)
  1002         video_ps2gs=no
  1003         AC_TRY_COMPILE([
  1004          #include <linux/ps2/dev.h>
  1005          #include <linux/ps2/gs.h>
  1006         ],[
  1007         ],[
  1008         video_ps2gs=yes
  1009         ])
  1010         AC_MSG_RESULT($video_ps2gs)
  1011         if test x$video_ps2gs = xyes; then
  1012             AC_DEFINE(SDL_VIDEO_DRIVER_PS2GS)
  1013             SOURCES="$SOURCES $srcdir/src/video/ps2gs/*.c"
  1014             have_video=yes
  1015         fi
  1016     fi
  1017 }
  1018 
  1019 dnl Find the GGI includes
  1020 CheckGGI()
  1021 {
  1022     AC_ARG_ENABLE(video-ggi,
  1023 AC_HELP_STRING([--enable-video-ggi], [use GGI video driver [default=no]]),
  1024                   , enable_video_ggi=no)
  1025     if test x$enable_video = xyes -a x$enable_video_ggi = xyes; then
  1026         AC_MSG_CHECKING(for GGI support)
  1027         video_ggi=no
  1028         AC_TRY_COMPILE([
  1029          #include <ggi/ggi.h>
  1030          #include <ggi/gii.h>
  1031         ],[
  1032         ],[
  1033         video_ggi=yes
  1034         ])
  1035         AC_MSG_RESULT($video_ggi)
  1036         if test x$video_ggi = xyes; then
  1037             AC_DEFINE(SDL_VIDEO_DRIVER_GGI)
  1038             SOURCES="$SOURCES $srcdir/src/video/ggi/*.c"
  1039             BUILD_LIBS="$BUILD_LIBS -lggi -lgii -lgg"
  1040             have_video=yes
  1041         fi
  1042     fi
  1043 }
  1044 
  1045 dnl Find the SVGAlib includes and libraries
  1046 CheckSVGA()
  1047 {
  1048     AC_ARG_ENABLE(video-svga,
  1049 AC_HELP_STRING([--enable-video-svga], [use SVGAlib video driver [default=no]]),
  1050                   , enable_video_svga=no)
  1051     if test x$enable_video = xyes -a x$enable_video_svga = xyes; then
  1052         AC_MSG_CHECKING(for SVGAlib (1.4.0+) support)
  1053         video_svga=no
  1054         AC_TRY_COMPILE([
  1055          #include <vga.h>
  1056          #include <vgamouse.h>
  1057          #include <vgakeyboard.h>
  1058         ],[
  1059          if ( SCANCODE_RIGHTWIN && SCANCODE_LEFTWIN ) {
  1060              exit(0);
  1061          }
  1062         ],[
  1063         video_svga=yes
  1064         ])
  1065         AC_MSG_RESULT($video_svga)
  1066         if test x$video_svga = xyes; then
  1067             AC_DEFINE(SDL_VIDEO_DRIVER_SVGALIB)
  1068             SOURCES="$SOURCES $srcdir/src/video/svga/*.c"
  1069             BUILD_LIBS="$BUILD_LIBS -lvga"
  1070             have_video=yes
  1071         fi
  1072     fi
  1073 }
  1074 
  1075 dnl Find the VGL includes and libraries
  1076 CheckVGL()
  1077 {
  1078     AC_ARG_ENABLE(video-vgl,
  1079 AC_HELP_STRING([--enable-video-vgl], [use VGL video driver [default=no]]),
  1080                   , enable_video_vgl=no)
  1081     if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
  1082         AC_MSG_CHECKING(for libVGL support)
  1083         video_vgl=no
  1084         AC_TRY_COMPILE([
  1085          #include <sys/fbio.h>
  1086          #include <sys/consio.h>
  1087          #include <sys/kbio.h>
  1088          #include <vgl.h>
  1089         ],[
  1090          VGLBitmap bitmap;
  1091          exit(bitmap.Bitmap);
  1092         ],[
  1093         video_vgl=yes
  1094         ])
  1095         AC_MSG_RESULT($video_vgl)
  1096         if test x$video_vgl = xyes; then
  1097             AC_DEFINE(SDL_VIDEO_DRIVER_VGL)
  1098             SOURCES="$SOURCES $srcdir/src/video/vgl/*.c"
  1099             BUILD_LIBS="$BUILD_LIBS -lvgl"
  1100             have_video=yes
  1101         fi
  1102     fi
  1103 }
  1104 
  1105 dnl Set up the wscons video driver if enabled
  1106 CheckWscons()
  1107 {
  1108     AC_ARG_ENABLE(video-wscons,
  1109 AC_HELP_STRING([--enable-video-wscons], [use wscons video driver [default=yes]]),
  1110                   , enable_video_wscons=yes)
  1111     if test x$enable_video = xyes -a x$enable_video_wscons = xyes; then
  1112         AC_MSG_CHECKING(for wscons support)
  1113         video_wscons=no
  1114         AC_TRY_COMPILE([
  1115        #include <sys/time.h>
  1116        #include <dev/wscons/wsconsio.h>
  1117         ],[
  1118         ],[
  1119         video_wscons=yes
  1120         ])
  1121         AC_MSG_RESULT($video_wscons)
  1122         if test x$video_wscons = xyes; then
  1123             AC_DEFINE(SDL_VIDEO_DRIVER_WSCONS)
  1124             SOURCES="$SOURCES $srcdir/src/video/wscons/*.c"
  1125             have_video=yes
  1126         fi
  1127     fi
  1128 }
  1129 
  1130 
  1131 dnl Find the AAlib includes
  1132 CheckAAlib()
  1133 {
  1134     AC_ARG_ENABLE(video-aalib,
  1135 AC_HELP_STRING([--enable-video-aalib], [use AAlib video driver [default=no]]),
  1136                   , enable_video_aalib=no)
  1137     if test x$enable_video = xyes -a x$enable_video_aalib = xyes; then
  1138         AC_MSG_CHECKING(for AAlib support)
  1139         video_aalib=no
  1140         AC_TRY_COMPILE([
  1141          #include <aalib.h>
  1142         ],[
  1143         ],[
  1144         video_aalib=yes
  1145         ])
  1146         AC_MSG_RESULT($video_aalib)
  1147         if test x$video_aalib = xyes; then
  1148             AC_DEFINE(SDL_VIDEO_DRIVER_AALIB)
  1149             SOURCES="$SOURCES $srcdir/src/video/aalib/*.c"
  1150             BUILD_LIBS="$BUILD_LIBS -laa"
  1151             have_video=yes
  1152         fi
  1153     fi
  1154 }
  1155 
  1156 dnl Set up the QTopia video driver if enabled
  1157 CheckQtopia()
  1158 {
  1159     AC_ARG_ENABLE(video-qtopia,
  1160 AC_HELP_STRING([--enable-video-qtopia], [use Qtopia video driver [default=no]]),
  1161                   , enable_video_qtopia=no)
  1162     if test x$enable_video = xyes -a x$enable_video_qtopia = xyes; then
  1163         AC_MSG_CHECKING(for Qtopia support)
  1164         video_qtopia=no
  1165         QTOPIA_FLAGS="-DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -I${QPEDIR}/include -I${QTDIR}/include/ -DNO_DEBUG -fno-rtti -fno-exceptions"
  1166         AC_LANG_CPLUSPLUS
  1167         OLD_CXX="$CXXFLAGS"
  1168         CXXFLAGS="$QTOPIA_FLAGS"
  1169         AC_TRY_COMPILE([
  1170          #include <qpe/qpeapplication.h>
  1171         ],[
  1172         ],[
  1173         video_qtopia=yes
  1174         ])
  1175         CXXFLAGS="$OLD_CXX"
  1176         AC_MSG_RESULT($video_qtopia)
  1177         if test x$video_qtopia = xyes; then
  1178             AC_DEFINE(SDL_VIDEO_DRIVER_QTOPIA)
  1179             SOURCES="$SOURCES $srcdir/src/video/qtopia/*.cc"
  1180             BUILD_CFLAGS="$BUILD_CFLAGS $QTOPIA_FLAGS"
  1181             SDL_CFLAGS="$SDL_CFLAGS -DQWS -Dmain=SDL_main"
  1182             SDL_LIBS="-lSDLmain $SDL_LIBS -L${QPEDIR}/lib -L${QTDIR}/lib/ -lqpe -lqte"
  1183             have_video=yes
  1184         fi
  1185         AC_LANG_C
  1186     fi
  1187 }
  1188 
  1189 dnl Set up the PicoGUI video driver if enabled
  1190 CheckPicoGUI()
  1191 {
  1192     AC_ARG_ENABLE(video-picogui,
  1193 AC_HELP_STRING([--enable-video-picogui], [use PicoGUI video driver [default=no]]),
  1194                   , enable_video_picogui=no)
  1195     if test x$enable_video = xyes -a x$enable_video_picogui = xyes; then
  1196         AC_MSG_CHECKING(for PicoGUI support)
  1197         video_picogui=no
  1198         AC_TRY_COMPILE([
  1199          #include <picogui.h>
  1200         ],[
  1201         ],[
  1202         video_picogui=yes
  1203         ])
  1204         AC_MSG_RESULT($video_picogui)
  1205         if test x$video_picogui = xyes; then
  1206             AC_DEFINE(SDL_VIDEO_DRIVER_PICOGUI)
  1207             SOURCES="$SOURCES $srcdir/src/video/picogui/*.c"
  1208             SDL_LIBS="$SDL_LIBS -lpgui"
  1209             have_video=yes
  1210         fi
  1211     fi
  1212 }
  1213 
  1214 dnl Set up the Atari Bios keyboard driver
  1215 CheckAtariBiosEvent()
  1216 {
  1217     SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.c"
  1218 }
  1219 
  1220 dnl Set up the Atari Xbios driver
  1221 CheckAtariXbiosVideo()
  1222 {
  1223     AC_ARG_ENABLE(xbios,
  1224 AC_HELP_STRING([--enable-video-xbios], [use Atari Xbios video driver [default=yes]]),
  1225                   , enable_video_xbios=yes)
  1226     video_xbios=no
  1227     if test x$enable_video = xyes -a x$enable_video_xbios = xyes; then
  1228         video_xbios=yes
  1229         AC_DEFINE(SDL_VIDEO_DRIVER_XBIOS)
  1230         SOURCES="$SOURCES $srcdir/src/video/xbios/*.c"
  1231         have_video=yes
  1232     fi
  1233 }
  1234 
  1235 dnl Set up the Atari Gem driver
  1236 CheckAtariGemVideo()
  1237 {
  1238     AC_ARG_ENABLE(gem,
  1239 AC_HELP_STRING([--enable-video-gem], [use Atari Gem video driver [default=yes]]),
  1240                   , enable_video_gem=yes)
  1241     if test x$enable_video = xyes -a x$enable_video_gem = xyes; then
  1242         video_gem=no
  1243         AC_CHECK_HEADER(gem.h, have_gem_hdr=yes)
  1244         AC_CHECK_LIB(gem, appl_init, have_gem_lib=yes)
  1245         if test x$have_gem_hdr = xyes -a x$have_gem_lib = xyes; then
  1246             AC_DEFINE(SDL_VIDEO_DRIVER_GEM)
  1247             SOURCES="$SOURCES $srcdir/src/video/gem/*.c"
  1248             BUILD_LIBS="$BUILD_LIBS -lgem"
  1249             have_video=yes
  1250         fi
  1251     fi
  1252 }
  1253 
  1254 dnl rcg04172001 Set up the Null video driver.
  1255 CheckDummyVideo()
  1256 {
  1257     AC_ARG_ENABLE(video-dummy,
  1258 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [default=yes]]),
  1259                   , enable_video_dummy=yes)
  1260     if test x$enable_video_dummy = xyes; then
  1261         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY)
  1262         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1263         have_video=yes
  1264     fi
  1265 }
  1266 
  1267 dnl Check to see if OpenGL support is desired
  1268 AC_ARG_ENABLE(video-opengl,
  1269 AC_HELP_STRING([--enable-video-opengl], [include OpenGL context creation [default=yes]]),
  1270               , enable_video_opengl=yes)
  1271 
  1272 dnl Find OpenGL
  1273 CheckOpenGLX11()
  1274 {
  1275     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1276         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1277         video_opengl=no
  1278         AC_TRY_COMPILE([
  1279          #include <GL/gl.h>
  1280          #include <GL/glx.h>
  1281         ],[
  1282         ],[
  1283         video_opengl=yes
  1284         ])
  1285         AC_MSG_RESULT($video_opengl)
  1286         if test x$video_opengl = xyes; then
  1287             AC_DEFINE(SDL_VIDEO_OPENGL)
  1288             AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
  1289         fi
  1290     fi
  1291 }
  1292 
  1293 dnl Find QNX RtP OpenGL
  1294 CheckOpenGLQNX()
  1295 {
  1296     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1297         AC_MSG_CHECKING(for OpenGL (Photon) support)
  1298         video_opengl=no
  1299         AC_TRY_COMPILE([
  1300          #include <GL/gl.h>
  1301         ],[
  1302         ],[
  1303         video_opengl=yes
  1304         ])
  1305         AC_MSG_RESULT($video_opengl)
  1306         if test x$video_opengl = xyes; then
  1307             AC_DEFINE(SDL_VIDEO_OPENGL)
  1308             BUILD_LIBS="$BUILD_LIBS -lGL"
  1309         fi
  1310     fi
  1311 }
  1312 
  1313 dnl Check for Win32 OpenGL
  1314 CheckWIN32GL()
  1315 {
  1316     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1317         AC_DEFINE(SDL_VIDEO_OPENGL)
  1318         AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
  1319     fi
  1320 }
  1321 
  1322 dnl Check for BeOS OpenGL
  1323 CheckBeGL()
  1324 {
  1325     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1326         AC_DEFINE(SDL_VIDEO_OPENGL)
  1327         BUILD_LIBS="$BUILD_LIBS -lGL"
  1328     fi
  1329 }
  1330 
  1331 dnl Check for MacOS OpenGL
  1332 CheckMacGL()
  1333 {
  1334     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1335         AC_DEFINE(SDL_VIDEO_OPENGL)
  1336         case "$target" in
  1337             *-*-darwin*)
  1338                 BUILD_LIBS="$BUILD_LIBS -framework OpenGL"
  1339                 # The following is probably not available in Darwin:
  1340                 BUILD_LIBS="$BUILD_LIBS -framework AGL"
  1341         esac
  1342     fi
  1343 }
  1344 
  1345 dnl Check for Mesa offscreen rendering
  1346 CheckAtariOSMesa()
  1347 {
  1348     if test "x$enable_video" = "xyes" -a "x$enable_video_opengl" = "xyes"; then
  1349         AC_CHECK_HEADER(GL/osmesa.h, have_osmesa_hdr=yes)
  1350         AC_CHECK_LIB(OSMesa, OSMesaCreateContext, have_osmesa_lib=yes, have_osmesa_lib=no, -lm)
  1351 
  1352         # Static linking to -lOSMesa
  1353         AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
  1354         if test "x$OSMESA_CONFIG" = "xno" -o "x$enable_atari_ldg" = "xno"; then
  1355             # -lOSMesa is really the static library
  1356             if test "x$have_osmesa_hdr" = "xyes" -a "x$have_osmesa_lib" = "xyes"; then
  1357                 OSMESA_LIBS="-lOSMesa"
  1358             fi
  1359         else
  1360             # -lOSMesa is a loader for OSMesa.ldg
  1361             OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
  1362             OSMESA_LIBS=`$OSMESA_CONFIG --libs`
  1363         fi
  1364         AC_DEFINE(SDL_VIDEO_OPENGL)
  1365         AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA)
  1366         BUILD_CFLAGS="$BUILD_CFLAGS $OSMESA_CFLAGS"
  1367         BUILD_LIBS="$BUILD_LIBS $OSMESA_LIBS"
  1368 
  1369         AC_ARG_ENABLE(osmesa-shared,
  1370 AC_HELP_STRING([--enable-osmesa-shared], [dynamically load OSMesa OpenGL support [default=yes]]),
  1371                               , enable_osmesa_shared=yes)
  1372         if test "x$enable_osmesa_shared" = "xyes" -a "x$enable_atari_ldg" = "xyes"; then
  1373             # Dynamic linking
  1374             if test "x$have_osmesa_hdr" = "xyes"; then
  1375                 AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA_DYNAMIC)
  1376             fi
  1377         fi
  1378     fi
  1379 }
  1380 
  1381 dnl See if we can use the new unified event interface in Linux 2.4
  1382 CheckInputEvents()
  1383 {
  1384     dnl Check for Linux 2.4 unified input event interface support
  1385     AC_ARG_ENABLE(input-events,
  1386 AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [default=yes]]),
  1387                   , enable_input_events=yes)
  1388     if test x$enable_input_events = xyes; then
  1389         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  1390         use_input_events=no
  1391         AC_TRY_COMPILE([
  1392           #include <linux/input.h>
  1393         ],[
  1394           #ifndef EVIOCGNAME
  1395           #error EVIOCGNAME() ioctl not available
  1396           #endif
  1397         ],[
  1398         use_input_events=yes
  1399         ])
  1400         AC_MSG_RESULT($use_input_events)
  1401         if test x$use_input_events = xyes; then
  1402             AC_DEFINE(SDL_INPUT_LINUXEV)
  1403         fi
  1404     fi
  1405 }
  1406 
  1407 dnl See if we can use the Touchscreen input library
  1408 CheckTslib()
  1409 {
  1410     AC_ARG_ENABLE(input-tslib,
  1411 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [default=yes]]),
  1412                   , enable_input_tslib=yes)
  1413     if test x$enable_input_tslib = xyes; then
  1414         AC_MSG_CHECKING(for Touchscreen library support)
  1415         enable_input_tslib=no
  1416         AC_TRY_COMPILE([
  1417           #include "tslib.h"
  1418         ],[
  1419         ],[
  1420         enable_input_tslib=yes
  1421         ])
  1422         AC_MSG_RESULT($enable_input_tslib)
  1423         if test x$enable_input_tslib = xyes; then
  1424             AC_DEFINE(SDL_INPUT_TSLIB)
  1425             BUILD_LIBS="$BUILD_LIBS -lts"
  1426         fi
  1427     fi
  1428 }
  1429 
  1430 dnl See if we can use GNU pth library for threads
  1431 CheckPTH()
  1432 {
  1433     dnl Check for pth support
  1434     AC_ARG_ENABLE(pth,
  1435 AC_HELP_STRING([--enable-pth], [use GNU pth library for multi-threading [default=yes]]),
  1436                   , enable_pth=yes)
  1437     if test x$enable_threads = xyes -a x$enable_pth = xyes; then
  1438         AC_PATH_PROG(PTH_CONFIG, pth-config, no)
  1439         if test "$PTH_CONFIG" = "no"; then
  1440             use_pth=no
  1441         else
  1442             use_pth=yes
  1443         fi
  1444         AC_MSG_CHECKING(pth)
  1445         AC_MSG_RESULT($use_pth)
  1446         if test "x$use_pth" = xyes; then
  1447             AC_DEFINE(SDL_THREAD_PTH)
  1448             SOURCES="$SOURCES $srcdir/src/thread/pth/*.c"
  1449             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1450             SDL_CFLAGS="$SDL_CFLAGS `$PTH_CONFIG --cflags`"
  1451             SDL_LIBS="$SDL_LIBS `$PTH_CONFIG --libs --all`"
  1452             have_threads=yes
  1453         fi
  1454     fi
  1455 }
  1456 
  1457 dnl See what type of thread model to use on Linux and Solaris
  1458 CheckPTHREAD()
  1459 {
  1460     dnl Check for pthread support
  1461     AC_ARG_ENABLE(pthreads,
  1462 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [default=yes]]),
  1463                   , enable_pthreads=yes)
  1464     dnl This is used on Linux for glibc binary compatibility (Doh!)
  1465     AC_ARG_ENABLE(pthread-sem,
  1466 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [default=yes]]),
  1467                   , enable_pthread_sem=yes)
  1468     case "$target" in
  1469         *-*-linux*)
  1470             pthread_cflags="-D_REENTRANT"
  1471             pthread_lib="-lpthread"
  1472             ;;
  1473         *-*-bsdi*)
  1474             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1475             pthread_lib=""
  1476             ;;
  1477         *-*-darwin*)
  1478             pthread_cflags="-D_THREAD_SAFE"
  1479 # causes Carbon.p complaints?
  1480 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1481             ;;
  1482         *-*-freebsd*)
  1483             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1484             pthread_lib="-pthread"
  1485             ;;
  1486         *-*-netbsd*)
  1487             pthread_cflags="-I/usr/include -D_REENTRANT -D_THREAD_SAFE -D_POSIX_THREAD_SYSCALL_SOFT=1"
  1488             pthread_lib="-L/usr/lib -lpthread"
  1489             ;;
  1490         *-*-openbsd*)
  1491             pthread_cflags="-D_REENTRANT"
  1492             pthread_lib="-pthread"
  1493             ;;
  1494         *-*-solaris*)
  1495             pthread_cflags="-D_REENTRANT"
  1496             pthread_lib="-lpthread -lposix4"
  1497             ;;
  1498         *-*-sysv5*)
  1499             pthread_cflags="-D_REENTRANT -Kthread"
  1500             pthread_lib=""
  1501             ;;
  1502         *-*-irix*)
  1503             pthread_cflags="-D_SGI_MP_SOURCE"
  1504             pthread_lib="-lpthread"
  1505             ;;
  1506         *-*-aix*)
  1507             pthread_cflags="-D_REENTRANT -mthreads"
  1508             pthread_lib="-lpthread"
  1509             ;;
  1510         *-*-hpux11*)
  1511             pthread_cflags="-D_REENTRANT"
  1512             pthread_lib="-L/usr/lib -lpthread"
  1513             ;;
  1514         *-*-qnx*)
  1515             pthread_cflags=""
  1516             pthread_lib=""
  1517             ;;
  1518         *-*-osf*)
  1519             pthread_cflags="-D_REENTRANT"
  1520             if test x$ac_cv_prog_gcc = xyes; then
  1521                 pthread_lib="-lpthread -lrt"
  1522             else
  1523                 pthread_lib="-lpthread -lexc -lrt"
  1524             fi
  1525             ;;
  1526         *)
  1527             pthread_cflags="-D_REENTRANT"
  1528             pthread_lib="-lpthread"
  1529             ;;
  1530     esac
  1531     if test x$enable_threads = xyes -a x$enable_pthreads = xyes -a x$enable_ipod != xyes; then
  1532         # Save the original compiler flags and libraries
  1533         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1534         # Add the pthread compiler flags and libraries
  1535         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1536         # Check to see if we have pthread support on this system
  1537         AC_MSG_CHECKING(for pthreads)
  1538         use_pthreads=no
  1539         AC_TRY_LINK([
  1540          #include <pthread.h>
  1541         ],[
  1542          pthread_attr_t type;
  1543          pthread_attr_init(&type);
  1544         ],[
  1545         use_pthreads=yes
  1546         ])
  1547         AC_MSG_RESULT($use_pthreads)
  1548         # Restore the compiler flags and libraries
  1549         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1550 
  1551         # Do futher testing if we have pthread support...
  1552         if test x$use_pthreads = xyes; then
  1553             AC_DEFINE(SDL_THREAD_PTHREAD)
  1554             BUILD_CFLAGS="$BUILD_CFLAGS $pthread_cflags"
  1555             BUILD_LIBS="$BUILD_LIBS $pthread_lib"
  1556             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  1557             SDL_LIBS="$SDL_LIBS $pthread_lib"
  1558 
  1559             # Check to see if recursive mutexes are available
  1560             AC_MSG_CHECKING(for recursive mutexes)
  1561             has_recursive_mutexes=no
  1562             if test x$has_recursive_mutexes = xno; then
  1563                 AC_TRY_COMPILE([
  1564                   #include <pthread.h>
  1565                 ],[
  1566                   pthread_mutexattr_t attr;
  1567                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  1568                 ],[
  1569                 has_recursive_mutexes=yes
  1570                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX)
  1571                 ])
  1572             fi
  1573             if test x$has_recursive_mutexes = xno; then
  1574                 AC_TRY_COMPILE([
  1575                   #include <pthread.h>
  1576                 ],[
  1577                   pthread_mutexattr_t attr;
  1578                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  1579                 ],[
  1580                 has_recursive_mutexes=yes
  1581                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)
  1582                 ])
  1583             fi
  1584             AC_MSG_RESULT($has_recursive_mutexes)
  1585 
  1586             # Check to see if pthread semaphore support is missing
  1587             if test x$enable_pthread_sem = xyes; then
  1588                 AC_MSG_CHECKING(for pthread semaphores)
  1589                 have_pthread_sem=no
  1590                 AC_TRY_COMPILE([
  1591                   #include <pthread.h>
  1592                   #include <semaphore.h>
  1593                 ],[
  1594                 ],[
  1595                 have_pthread_sem=yes
  1596                 ])
  1597                 AC_MSG_RESULT($have_pthread_sem)
  1598             fi
  1599 
  1600             # Basic thread creation functions
  1601             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  1602 
  1603             # Semaphores
  1604             # We can fake these with mutexes and condition variables if necessary
  1605             if test x$have_pthread_sem = xyes; then
  1606                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  1607             else
  1608                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1609             fi
  1610 
  1611             # Mutexes
  1612             # We can fake these with semaphores if necessary
  1613             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  1614 
  1615             # Condition variables
  1616             # We can fake these with semaphores and mutexes if necessary
  1617             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  1618 
  1619             have_threads=yes
  1620         else
  1621             CheckPTH
  1622         fi
  1623     fi
  1624 }
  1625 
  1626 dnl Determine whether the compiler can produce Win32 executables
  1627 CheckWIN32()
  1628 {
  1629     AC_MSG_CHECKING(Win32 compiler)
  1630     have_win32_gcc=no
  1631     AC_TRY_COMPILE([
  1632      #include <windows.h>
  1633     ],[
  1634     ],[
  1635     have_win32_gcc=yes
  1636     ])
  1637     AC_MSG_RESULT($have_win32_gcc)
  1638     if test x$have_win32_gcc != xyes; then
  1639        AC_MSG_ERROR([
  1640 *** Your compiler ($CC) does not produce Win32 executables!
  1641        ])
  1642     fi
  1643 
  1644     dnl See if the user wants to redirect standard output to files
  1645     AC_ARG_ENABLE(stdio-redirect,
  1646 AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [default=yes]]),
  1647                   , enable_stdio_redirect=yes)
  1648     if test x$enable_stdio_redirect != xyes; then
  1649         BUILD_CFLAGS="$BUILD_CFLAGS -DNO_STDIO_REDIRECT"
  1650     fi
  1651 
  1652     if test x$enable_video = xyes; then
  1653         AC_DEFINE(SDL_VIDEO_DRIVER_WINDIB)
  1654         SOURCES="$SOURCES $srcdir/src/video/wincommon/*.c"
  1655         SOURCES="$SOURCES $srcdir/src/video/windib/*.c"
  1656         have_video=yes
  1657     fi
  1658 }
  1659 
  1660 dnl Find the DirectX includes and libraries
  1661 CheckDIRECTX()
  1662 {
  1663     AC_ARG_ENABLE(directx,
  1664 AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [default=yes]]),
  1665                   , enable_directx=yes)
  1666     if test x$enable_directx = xyes; then
  1667         have_directx=no
  1668         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  1669         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  1670         AC_CHECK_HEADER(dinput.h, use_dinput=yes)
  1671         if test x$have_ddraw = xyes -a x$have_dsound = xyes -a x$use_dinput = xyes; then
  1672             have_directx=yes
  1673         fi
  1674         if test x$enable_video = xyes -a x$have_directx = xyes; then
  1675             AC_DEFINE(SDL_VIDEO_DRIVER_DDRAW)
  1676             SOURCES="$SOURCES $srcdir/src/video/windx5/*.c"
  1677             have_video=yes
  1678         fi
  1679     fi
  1680 }
  1681 
  1682 dnl Check for the dlfcn.h interface for dynamically loading objects
  1683 CheckDLOPEN()
  1684 {
  1685     AC_ARG_ENABLE(sdl-dlopen,
  1686 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [default=yes]]),
  1687                   , enable_sdl_dlopen=yes)
  1688     if test x$enable_sdl_dlopen = xyes; then
  1689         AC_MSG_CHECKING(for dlopen)
  1690         have_dlopen=no
  1691         AC_TRY_COMPILE([
  1692          #include <dlfcn.h>
  1693         ],[
  1694         ],[
  1695         have_dlopen=yes
  1696         ])
  1697         AC_MSG_RESULT($have_dlopen)
  1698 
  1699         if test x$have_dlopen = xyes; then
  1700             AC_CHECK_LIB(c, dlopen, BUILD_LIBS="$BUILD_LIBS",
  1701                AC_CHECK_LIB(dl, dlopen, BUILD_LIBS="$BUILD_LIBS -ldl",
  1702                   AC_CHECK_LIB(ltdl, dlopen, BUILD_LIBS="$BUILD_LIBS -lltdl")))
  1703             AC_CHECK_LIB(dl, dlvsym, have_dlvsym=yes)
  1704             if test x$have_dlvsym = xyes; then
  1705                 AC_DEFINE(HAVE_DLVSYM)
  1706             fi
  1707             AC_DEFINE(SDL_LOADSO_DLOPEN)
  1708             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  1709             have_loadso=yes
  1710         fi
  1711     fi
  1712 }
  1713 
  1714 dnl Set up the Atari LDG (shared object loader)
  1715 CheckAtariLdg()
  1716 {
  1717     AC_ARG_ENABLE(atari-ldg,
  1718 AC_HELP_STRING([--enable-atari-ldg], [use Atari LDG for shared object loading [default=yes]]),
  1719                   , enable_atari_ldg=yes)
  1720     if test x$video_gem = xyes -a x$enable_atari_ldg = xyes; then
  1721         AC_CHECK_HEADER(ldg.h, have_ldg_hdr=yes)
  1722         AC_CHECK_LIB(ldg, ldg_open, have_ldg_lib=yes, have_ldg_lib=no, -lgem)
  1723         if test x$have_ldg_hdr = xyes -a x$have_ldg_lib = xyes; then
  1724             AC_DEFINE(SDL_LOADSO_LDG)
  1725             SOURCES="$SOURCES $srcdir/src/loadso/mint/*.c"
  1726             BUILD_LIBS="$BUILD_LIBS -lldg -lgem"
  1727             have_loadso=yes
  1728         fi
  1729     fi
  1730 }
  1731 
  1732 dnl Check for the usbhid(3) library on *BSD
  1733 CheckUSBHID()
  1734 {
  1735     if test x$enable_joystick = xyes; then
  1736         AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  1737         AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  1738         AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  1739         AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  1740             
  1741         AC_CHECK_LIB(usbhid, hid_init, [USB_LIBS="$USB_LIBS -lusbhid"])
  1742         AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  1743 
  1744         save_CFLAGS="$CFLAGS"
  1745         CFLAGS="$CFLAGS $USB_CFLAGS"
  1746 
  1747         AC_MSG_CHECKING(for usbhid)
  1748         have_usbhid=no
  1749         AC_TRY_COMPILE([
  1750           #include <sys/types.h>
  1751           #if defined(HAVE_USB_H)
  1752           #include <usb.h>
  1753           #endif
  1754           #include <dev/usb/usb.h>
  1755           #include <dev/usb/usbhid.h>
  1756           #if defined(HAVE_USBHID_H)
  1757           #include <usbhid.h>
  1758           #elif defined(HAVE_LIBUSB_H)
  1759           #include <libusb.h>
  1760           #elif defined(HAVE_LIBUSBHID_H)
  1761           #include <libusbhid.h>
  1762           #endif
  1763         ],[
  1764           struct report_desc *repdesc;
  1765           struct usb_ctl_report *repbuf;
  1766           hid_kind_t hidkind;
  1767         ],[
  1768         have_usbhid=yes
  1769         ])
  1770         AC_MSG_RESULT($have_usbhid)
  1771 
  1772         if test x$have_usbhid = xyes; then
  1773             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  1774             have_usbhid_ucr_data=no
  1775             AC_TRY_COMPILE([
  1776               #include <sys/types.h>
  1777               #if defined(HAVE_USB_H)
  1778               #include <usb.h>
  1779               #endif
  1780               #include <dev/usb/usb.h>
  1781               #include <dev/usb/usbhid.h>
  1782               #if defined(HAVE_USBHID_H)
  1783               #include <usbhid.h>
  1784               #elif defined(HAVE_LIBUSB_H)
  1785               #include <libusb.h>
  1786               #elif defined(HAVE_LIBUSBHID_H)
  1787               #include <libusbhid.h>
  1788               #endif
  1789             ],[
  1790               struct usb_ctl_report buf;
  1791               if (buf.ucr_data) { }
  1792             ],[
  1793             have_usbhid_ucr_data=yes
  1794             ])
  1795             if test x$have_usbhid_ucr_data = xyes; then
  1796                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  1797             fi
  1798             AC_MSG_RESULT($have_usbhid_ucr_data)
  1799             
  1800             AC_MSG_CHECKING(for new usbhid API)
  1801             have_usbhid_new=no
  1802             AC_TRY_COMPILE([
  1803               #include <sys/types.h>
  1804               #if defined(HAVE_USB_H)
  1805               #include <usb.h>
  1806               #endif
  1807               #include <dev/usb/usb.h>
  1808               #include <dev/usb/usbhid.h>
  1809               #if defined(HAVE_USBHID_H)
  1810               #include <usbhid.h>
  1811               #elif defined(HAVE_LIBUSB_H)
  1812               #include <libusb.h>
  1813               #elif defined(HAVE_LIBUSBHID_H)
  1814               #include <libusbhid.h>
  1815               #endif
  1816             ],[
  1817               report_desc_t d;
  1818               hid_start_parse(d, 1, 1);
  1819             ],[
  1820             have_usbhid_new=yes
  1821             ])
  1822             if test x$have_usbhid_new = xyes; then
  1823                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  1824             fi
  1825             AC_MSG_RESULT($have_usbhid_new)
  1826 
  1827             AC_DEFINE(SDL_JOYSTICK_USBHID)
  1828             SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  1829             BUILD_CFLAGS="$BUILD_CFLAGS $USB_CFLAGS"
  1830             BUILD_LIBS="$BUILD_CFLAGS $USB_LIBS"
  1831             have_joystick=yes
  1832         fi
  1833         CFLAGS="$save_CFLAGS"
  1834     fi
  1835 }
  1836 
  1837 dnl Check for clock_gettime()
  1838 CheckClockGettime()
  1839 {
  1840     AC_ARG_ENABLE(clock_gettime,
  1841 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [default=no]]),
  1842                   , enable_clock_gettime=no)
  1843     if test x$enable_clock_gettime = xyes; then
  1844         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  1845         if test x$have_clock_gettime = xyes; then
  1846             AC_DEFINE(HAVE_CLOCK_GETTIME)
  1847             BUILD_LIBS="$BUILD_LIBS -lrt"
  1848         fi
  1849     fi
  1850 }
  1851 
  1852 dnl Check for a valid linux/version.h
  1853 CheckLinuxVersion()
  1854 {
  1855     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  1856     if test x$have_linux_version_h = xyes; then
  1857         BUILD_CFLAGS="$BUILD_CFLAGS -DHAVE_LINUX_VERSION_H"
  1858     fi
  1859 }
  1860 
  1861 dnl Check if we want to use RPATH
  1862 CheckRPATH()
  1863 {
  1864     AC_ARG_ENABLE(rpath,
  1865 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [default=yes]]),
  1866                   , enable_rpath=yes)
  1867 }
  1868 
  1869 dnl Set up the configuration based on the target platform!
  1870 case "$target" in
  1871     arm-*-elf*) # FIXME: Can we get more specific for iPodLinux?
  1872         ARCH=linux
  1873         CheckDummyVideo
  1874         CheckIPod
  1875         # Set up files for the timer library
  1876         if test x$enable_timers = xyes; then
  1877             AC_DEFINE(SDL_TIMER_UNIX)
  1878             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  1879             have_timers=yes
  1880         fi
  1881         ;;
  1882     *-*-linux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*)
  1883         case "$target" in
  1884             *-*-linux*)         ARCH=linux ;;
  1885             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  1886             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  1887             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  1888             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  1889             *-*-bsdi*)          ARCH=bsdi ;;
  1890             *-*-freebsd*)       ARCH=freebsd ;;
  1891             *-*-netbsd*)        ARCH=netbsd ;;
  1892             *-*-openbsd*)       ARCH=openbsd ;;
  1893             *-*-sysv5*)         ARCH=sysv5 ;;
  1894             *-*-solaris*)       ARCH=solaris ;;
  1895             *-*-hpux*)          ARCH=hpux ;;
  1896             *-*-irix*)          ARCH=irix ;;
  1897             *-*-aix*)           ARCH=aix ;;
  1898             *-*-osf*)           ARCH=osf ;;
  1899         esac
  1900         CheckDummyVideo
  1901         CheckDiskAudio
  1902         CheckDLOPEN
  1903         CheckNASM
  1904         CheckAltivec
  1905         CheckOSS
  1906         CheckDMEDIA
  1907         CheckALSA
  1908         CheckARTSC
  1909         CheckESD
  1910         CheckNAS
  1911         CheckX11
  1912         CheckNANOX
  1913         CheckFBCON
  1914         CheckDirectFB
  1915         CheckPS2GS
  1916         CheckGGI
  1917         CheckSVGA
  1918         CheckVGL
  1919         CheckWscons
  1920         CheckAAlib
  1921         CheckQtopia
  1922         CheckPicoGUI
  1923         CheckOpenGLX11
  1924         CheckInputEvents
  1925         CheckTslib
  1926         CheckUSBHID
  1927         CheckPTHREAD
  1928         CheckClockGettime
  1929         CheckLinuxVersion
  1930         CheckRPATH
  1931         # Set up files for the audio library
  1932         if test x$enable_audio = xyes; then
  1933           case $ARCH in
  1934             netbsd|sysv5|solaris|hpux)
  1935                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
  1936                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  1937                 have_audio=yes
  1938             ;;
  1939             openbsd)
  1940                 AC_DEFINE(SDL_AUDIO_DRIVER_OPENBSD)
  1941                 SOURCES="$SOURCES $srcdir/src/audio/openbsd/*.c"
  1942                 have_audio=yes
  1943             ;;
  1944             aix)
  1945                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUD)
  1946                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  1947                 have_audio=yes
  1948             ;;
  1949             osf)
  1950                 AC_DEFINE(SDL_AUDIO_DRIVER_MMEAUDIO)
  1951                 SOURCES="$SOURCES $srcdir/src/audio/mme/*.c"
  1952                 BUILD_LIBS="$BUILD_LIBS -lmme"
  1953                 have_audio=yes
  1954             ;;
  1955           esac
  1956         fi
  1957         # Set up files for the joystick library
  1958         if test x$enable_joystick = xyes; then
  1959           case $ARCH in
  1960             linux)
  1961                 AC_DEFINE(SDL_JOYSTICK_LINUX)
  1962                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  1963                 have_joystick=yes
  1964             ;;
  1965           esac
  1966         fi
  1967         # Set up files for the cdrom library
  1968         if test x$enable_cdrom = xyes; then
  1969           case $ARCH in
  1970             linux|solaris)
  1971                 AC_DEFINE(SDL_CDROM_LINUX)
  1972                 SOURCES="$SOURCES $srcdir/src/cdrom/linux/*.c"
  1973                 have_cdrom=yes
  1974             ;;
  1975             *freebsd*)
  1976                 AC_DEFINE(SDL_CDROM_FREEBSD)
  1977                 SOURCES="$SOURCES $srcdir/src/cdrom/freebsd/*.c"
  1978                 have_cdrom=yes
  1979             ;;
  1980             *netbsd*|*openbsd*)
  1981                 AC_DEFINE(SDL_CDROM_OPENBSD)
  1982                 SOURCES="$SOURCES $srcdir/src/cdrom/openbsd/*.c"
  1983                 have_cdrom=yes
  1984             ;;
  1985             bsdi)
  1986                 AC_DEFINE(SDL_CDROM_BSDI)
  1987                 SOURCES="$SOURCES $srcdir/src/cdrom/bsdi/*.c"
  1988                 have_cdrom=yes
  1989             ;;
  1990             aix)
  1991                 AC_DEFINE(SDL_CDROM_AIX)
  1992                 SOURCES="$SOURCES $srcdir/src/cdrom/aix/*.c"
  1993                 have_cdrom=yes
  1994             ;;
  1995             osf)
  1996                 AC_DEFINE(SDL_CDROM_OSF)
  1997                 SOURCES="$SOURCES $srcdir/src/cdrom/osf/*.c"
  1998                 have_cdrom=yes
  1999             ;;
  2000           esac
  2001         fi
  2002         # Set up files for the thread library
  2003         if test x$enable_threads = xyes -a x$use_pthreads != xyes -a x$use_pth != xyes -a x$ARCH = xirix; then
  2004             AC_DEFINE(SDL_THREAD_SPROC)
  2005             SOURCES="$SOURCES $srcdir/src/thread/irix/*.c"
  2006             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2007             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2008             have_threads=yes
  2009         fi
  2010         # Set up files for the timer library
  2011         if test x$enable_timers = xyes; then
  2012             AC_DEFINE(SDL_TIMER_UNIX)
  2013             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2014             have_timers=yes
  2015         fi
  2016         # Do any final platform setup
  2017         case $ARCH in
  2018             netbsd)
  2019                 # NetBSD does not define "unix"
  2020                 BUILD_CFLAGS="$BUILD_CFLAGS -Dunix"
  2021             ;;
  2022             openbsd)
  2023                 # OpenBSD does not define "unix"
  2024                 BUILD_CFLAGS="$BUILD_CFLAGS -Dunix"
  2025             ;;
  2026         esac
  2027         ;;
  2028     *-*-qnx*)
  2029         ARCH=qnx
  2030         CheckDummyVideo
  2031         CheckDiskAudio
  2032         # CheckNASM
  2033         CheckDLOPEN
  2034         CheckNAS
  2035         CheckPHOTON
  2036         CheckX11
  2037         CheckOpenGLX11
  2038         CheckPTHREAD
  2039         # Set up files for the audio library
  2040         if test x$enable_audio = xyes; then
  2041             AC_DEFINE(SDL_AUDIO_DRIVER_QNXNTO)
  2042             SOURCES="$SOURCES $srcdir/src/audio/nto/*.c"
  2043             BUILD_LIBS="$BUILD_LIBS -lasound"
  2044             have_audio=yes
  2045         fi
  2046         # Set up files for the cdrom library
  2047         if test x$enable_cdrom = xyes; then
  2048             AC_DEFINE(SDL_CDROM_QNX)
  2049             SOURCES="$SOURCES $srcdir/src/cdrom/qnx/*.c"
  2050             have_cdrom=yes
  2051         fi
  2052         # Set up files for the timer library
  2053         if test x$enable_timers = xyes; then
  2054             AC_DEFINE(SDL_TIMER_UNIX)
  2055             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2056             have_timers=yes
  2057         fi
  2058         ;;
  2059     *-*-cygwin* | *-*-mingw32*)
  2060         ARCH=win32
  2061         if test "$build" != "$target"; then # cross-compiling
  2062             # Default cross-compile location
  2063             ac_default_prefix=/usr/local/cross-tools/i386-mingw32msvc
  2064         else
  2065             # Look for the location of the tools and install there
  2066             if test "$BUILD_PREFIX" != ""; then
  2067                 ac_default_prefix=$BUILD_PREFIX
  2068             fi
  2069         fi
  2070         CheckDummyVideo
  2071         CheckDiskAudio
  2072         CheckWIN32
  2073         CheckWIN32GL
  2074         CheckDIRECTX
  2075         CheckNASM
  2076         # Set up files for the audio library
  2077         if test x$enable_audio = xyes; then
  2078             AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
  2079             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2080             if test x$have_directx = xyes; then
  2081                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2082                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2083             fi
  2084             have_audio=yes
  2085         fi
  2086         # Set up files for the joystick library
  2087         if test x$enable_joystick = xyes; then
  2088             AC_DEFINE(SDL_JOYSTICK_WINMM)
  2089             SOURCES="$SOURCES $srcdir/src/joystick/win32/*.c"
  2090             have_joystick=yes
  2091         fi
  2092         # Set up files for the cdrom library
  2093         if test x$enable_cdrom = xyes; then
  2094             AC_DEFINE(SDL_CDROM_WIN32)
  2095             SOURCES="$SOURCES $srcdir/src/cdrom/win32/*.c"
  2096             have_cdrom=yes
  2097         fi
  2098         # Set up files for the thread library
  2099         if test x$enable_threads = xyes; then
  2100             AC_DEFINE(SDL_THREAD_WIN32)
  2101             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
  2102             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
  2103             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
  2104             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2105             have_threads=yes
  2106         fi
  2107         # Set up files for the timer library
  2108         if test x$enable_timers = xyes; then
  2109             AC_DEFINE(SDL_TIMER_WIN32)
  2110             SOURCES="$SOURCES $srcdir/src/timer/win32/*.c"
  2111             have_timers=yes
  2112         fi
  2113         # Set up files for the shared object loading library
  2114         if test x$enable_loadso = xyes; then
  2115             AC_DEFINE(SDL_LOADSO_WIN32)
  2116             SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
  2117             have_loadso=yes
  2118         fi
  2119         # Set up the system libraries we need
  2120         BUILD_LIBS="$BUILD_LIBS -luser32 -lgdi32 -lwinmm"
  2121         if test x$have_directx = xyes; then
  2122             BUILD_LIBS="$BUILD_LIBS -ldxguid"
  2123         fi
  2124         # The Win32 platform requires special setup
  2125         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2126         case "$target" in
  2127             *-*-cygwin*)
  2128                 BUILD_CFLAGS="$BUILD_CFLAGS -I/usr/include/mingw -DWIN32 -Uunix -mno-cygwin"
  2129                 SDL_CFLAGS="$SDL_CFLAGS -I/usr/include/mingw -DWIN32 -Uunix -mno-cygwin"
  2130                 BUILD_LIBS="$BUILD_LIBS -mno-cygwin"
  2131                 SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows -mno-cygwin"
  2132                 ;;
  2133             *-*-mingw32*)
  2134                 SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
  2135                 ;;
  2136         esac
  2137         ;;
  2138     *-*-beos*)
  2139         ARCH=beos
  2140         ac_default_prefix=/boot/develop/tools/gnupro
  2141         CheckDummyVideo
  2142         CheckDiskAudio
  2143         CheckNASM
  2144         CheckBWINDOW
  2145         CheckBeGL
  2146         # Set up files for the audio library
  2147         if test x$enable_audio = xyes; then
  2148             AC_DEFINE(SDL_AUDIO_DRIVER_BAUDIO)
  2149             SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
  2150             have_audio=yes
  2151         fi
  2152         # Set up files for the joystick library
  2153         if test x$enable_joystick = xyes; then
  2154             AC_DEFINE(SDL_JOYSTICK_BEOS)
  2155             SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
  2156             have_joystick=yes
  2157         fi
  2158         # Set up files for the cdrom library
  2159         if test x$enable_cdrom = xyes; then
  2160             AC_DEFINE(SDL_CDROM_BEOS)
  2161             SOURCES="$SOURCES $srcdir/src/cdrom/beos/*.cc"
  2162             have_cdrom=yes
  2163         fi
  2164         # Set up files for the thread library
  2165         if test x$enable_threads = xyes; then
  2166             AC_DEFINE(SDL_THREAD_BEOS)
  2167             SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
  2168             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2169             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2170             have_threads=yes
  2171         fi
  2172         # Set up files for the timer library
  2173         if test x$enable_timers = xyes; then
  2174             AC_DEFINE(SDL_TIMER_BEOS)
  2175             SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
  2176             have_timers=yes
  2177         fi
  2178         # Set up files for the shared object loading library
  2179         if test x$enable_loadso = xyes; then
  2180             AC_DEFINE(SDL_LOADSO_BEOS)
  2181             SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
  2182             have_loadso=yes
  2183         fi
  2184         # The BeOS platform requires special libraries
  2185         BUILD_LIBS="$BUILD_LIBS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2186         ;;
  2187     *-*-darwin* )
  2188         # This could be either full "Mac OS X", or plain "Darwin" which is
  2189         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2190         # Next line is broken, and a few files below require Mac OS X (full)
  2191         ARCH=macosx
  2192         CheckDummyVideo
  2193         CheckDiskAudio
  2194         CheckDLOPEN
  2195         CheckCOCOA
  2196         CheckCARBON
  2197         CheckX11
  2198         CheckMacGL
  2199         CheckOpenGLX11
  2200         CheckPTHREAD
  2201         CheckAltivec
  2202         # Set up files for the audio library
  2203         if test x$enable_audio = xyes; then
  2204             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO)
  2205             SOURCES="$SOURCES $srcdir/src/audio/macosx/*.c"
  2206             AC_DEFINE(SDL_AUDIO_DRIVER_SNDMGR)
  2207             SOURCES="$SOURCES $srcdir/src/audio/macrom/*.c"
  2208             have_audio=yes
  2209         fi
  2210         # Set up files for the joystick library
  2211         if test x$enable_joystick = xyes; then
  2212             AC_DEFINE(SDL_JOYSTICK_IOKIT)
  2213             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  2214             BUILD_LIBS="$BUILD_LIBS -framework IOKit"
  2215             have_joystick=yes
  2216         fi
  2217         # Set up files for the cdrom library
  2218         if test x$enable_cdrom = xyes; then
  2219             AC_DEFINE(SDL_CDROM_MACOSX)
  2220             SOURCES="$SOURCES $srcdir/src/cdrom/macosx/*.c"
  2221             have_cdrom=yes
  2222         fi
  2223         # Set up files for the timer library
  2224         if test x$enable_timers = xyes; then
  2225             AC_DEFINE(SDL_TIMER_UNIX)
  2226             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2227             have_timers=yes
  2228         fi
  2229         # Set up files for the shared object loading library
  2230         if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
  2231             AC_DEFINE(SDL_LOADSO_DLCOMPAT)
  2232             SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
  2233             have_loadso=yes
  2234         fi
  2235         # The MacOS X platform requires special setup.
  2236         AC_DEFINE(TARGET_API_MAC_CARBON)
  2237         BUILD_CFLAGS="$BUILD_CFLAGS -fpascal-strings -DMACOSX"
  2238         SDL_LIBS="-lSDLmain $SDL_LIBS"
  2239         if test x$enable_video_cocoa = xyes; then
  2240             BUILD_LIBS="$BUILD_LIBS -framework Cocoa"
  2241         fi
  2242         if test x$enable_video_carbon = xyes -o x$enable_video_cocoa = xyes; then
  2243             # The Cocoa backend still needs Carbon, and the YUV code QuickTime
  2244             BUILD_LIBS="$BUILD_LIBS -framework Carbon -framework QuickTime"
  2245         fi
  2246         # If either the audio or CD driver is used, add the AudioUnit framework
  2247         if test x$enable_audio = xyes -o x$enable_cdrom = xyes; then
  2248             BUILD_LIBS="$BUILD_LIBS -framework AudioToolbox -framework AudioUnit"
  2249         fi
  2250         ;;
  2251     *-*-mint*)
  2252         ARCH=mint
  2253         CheckDummyVideo
  2254         CheckDiskAudio
  2255         CheckAtariBiosEvent
  2256         CheckAtariXbiosVideo
  2257         CheckAtariGemVideo
  2258         CheckAtariAudio
  2259         CheckAtariLdg
  2260         CheckAtariOSMesa
  2261         CheckPTH
  2262         # Set up files for the audio library
  2263         if test x$enable_threads = xyes -a x$enable_pth = xyes; then
  2264             if test x$enable_audio = xyes; then
  2265                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
  2266                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2267                 have_audio=yes
  2268             fi
  2269         fi
  2270         # Set up files for the joystick library
  2271         if test x$enable_joystick = xyes; then
  2272             AC_DEFINE(SDL_JOYSTICK_MINT)
  2273             SOURCES="$SOURCES $srcdir/src/joystick/mint/*.c"
  2274             have_joystick=yes
  2275         fi
  2276         # Set up files for the cdrom library
  2277         if test x$enable_cdrom = xyes; then
  2278             AC_DEFINE(SDL_CDROM_MINT)
  2279             SOURCES="$SOURCES $srcdir/src/cdrom/mint/*.c"
  2280             have_cdrom=yes
  2281         fi
  2282         # Set up files for the timer library
  2283         if test x$enable_timers = xyes; then
  2284             if test x$enable_threads = xyes -a x$enable_pth = xyes; then
  2285                 AC_DEFINE(SDL_TIMER_UNIX)
  2286                 SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2287             else
  2288                 AC_DEFINE(SDL_TIMER_MINT)
  2289                 SOURCES="$SOURCES $srcdir/src/timer/mint/*.c"
  2290             fi
  2291             have_timers=yes
  2292         fi
  2293         # MiNT does not define "unix"
  2294         BUILD_CFLAGS="$BUILD_CFLAGS -Dunix"
  2295         ;;
  2296     *-riscos)
  2297         ARCH=riscos
  2298         CheckOSS
  2299         CheckPTHREAD
  2300         # Set up files for the video library
  2301         if test x$enable_video = xyes; then
  2302             AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
  2303             SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
  2304             have_video=yes
  2305         fi
  2306         # Set up files for the joystick library
  2307         if test x$enable_joystick = xyes; then
  2308             AC_DEFINE(SDL_JOYSTICK_RISCOS)
  2309             SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
  2310             have_joystick=yes
  2311         fi
  2312         # Set up files for the timer library
  2313         if test x$enable_timers = xyes; then
  2314             AC_DEFINE(SDL_TIMER_RISCOS)
  2315             SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
  2316             have_timers=yes
  2317         fi
  2318         # The RISC OS platform requires special setup.
  2319         BUILD_LIBS="$BUILD_LIBS -ljpeg -ltiff -lpng -lz"
  2320         ;;
  2321     *)
  2322         AC_MSG_ERROR([
  2323 *** Unsupported target:  Please add to configure.in
  2324         ])
  2325         ;;
  2326 esac
  2327 
  2328 # Verify that we have all the platform specific files we need
  2329 if test x$have_joystick != xyes; then
  2330     if test x$enable_joystick = xyes; then
  2331         AC_DEFINE(SDL_JOYSTICK_DISABLED)
  2332     fi
  2333     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2334 fi
  2335 if test x$have_cdrom != xyes; then
  2336     if test x$enable_cdrom = xyes; then
  2337         AC_DEFINE(SDL_CDROM_DISABLED)
  2338     fi
  2339     SOURCES="$SOURCES $srcdir/src/cdrom/dummy/*.c"
  2340 fi
  2341 if test x$have_threads != xyes; then
  2342     if test x$enable_threads = xyes; then
  2343         AC_DEFINE(SDL_THREADS_DISABLED)
  2344     fi
  2345     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  2346 fi
  2347 if test x$have_timers != xyes; then
  2348     if test x$enable_timers = xyes; then
  2349         AC_DEFINE(SDL_TIMERS_DISABLED)
  2350     fi
  2351     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  2352 fi
  2353 if test x$have_loadso != xyes; then
  2354     if test x$enable_loadso = xyes; then
  2355         AC_DEFINE(SDL_LOADSO_DISABLED)
  2356     fi
  2357     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  2358 fi
  2359 
  2360 OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.asm,$(objects)/\1.lo,g'`
  2361 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
  2362 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
  2363 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
  2364 
  2365 # Set runtime shared library paths as needed
  2366 
  2367 if test "x$enable_rpath" = "xyes"; then
  2368   if test $ARCH = linux -o $ARCH = freebsd -o $ARCH = bsdi; then
  2369     SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib"
  2370   fi
  2371   if test $ARCH = solaris; then
  2372     SDL_RLD_FLAGS="-R\${exec_prefix}/lib"
  2373   fi
  2374 else
  2375   SDL_RLD_FLAGS=""
  2376 fi
  2377 
  2378 case "$ARCH" in
  2379   openbsd | netbsd | bsdi)
  2380     SHARED_SYSTEM_LIBS="$SYSTEM_LIBS"
  2381     ;;
  2382   qnx)
  2383     SHARED_SYSTEM_LIBS="$SYSTEM_LIBS"
  2384     ;;
  2385   macosx)
  2386     SHARED_SYSTEM_LIBS=""
  2387     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  2388       SHARED_SYSTEM_LIBS="$SHARED_SYSTEM_LIBS -framework Cocoa"
  2389     fi
  2390     if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
  2391       SHARED_SYSTEM_LIBS="$SHARED_SYSTEM_LIBS -framework Carbon"
  2392     fi
  2393     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  2394       SHARED_SYSTEM_LIBS="$SHARED_SYSTEM_LIBS -framework OpenGL"
  2395     fi
  2396     ;;
  2397   *)
  2398     SHARED_SYSTEM_LIBS=""
  2399     ;;
  2400 esac
  2401 
  2402 case "$ARCH" in
  2403   macosx)
  2404     # Evil hack to allow static linking on Mac OS X
  2405     SDL_STATIC_LIBS="\${exec_prefix}/lib/libSDLmain.a \${exec_prefix}/lib/libSDL.a"
  2406     ;;
  2407   *)
  2408     SDL_STATIC_LIBS="$SDL_LIBS"
  2409     ;;
  2410 esac
  2411 
  2412 STATIC_SYSTEM_LIBS="$SYSTEM_LIBS"
  2413 
  2414 dnl Expand the cflags and libraries needed by apps using SDL
  2415 AC_SUBST(SDL_CFLAGS)
  2416 AC_SUBST(SDL_LIBS)
  2417 AC_SUBST(SDL_STATIC_LIBS)
  2418 AC_SUBST(SDL_RLD_FLAGS)
  2419 if test x$enable_shared = xyes; then
  2420     ENABLE_SHARED_TRUE=
  2421     ENABLE_SHARED_FALSE="#"
  2422 else
  2423     ENABLE_SHARED_TRUE="#"
  2424     ENABLE_SHARED_FALSE=
  2425 fi
  2426 if test x$enable_static = xyes; then
  2427     ENABLE_STATIC_TRUE=
  2428     ENABLE_STATIC_FALSE="#"
  2429 else
  2430     ENABLE_STATIC_TRUE="#"
  2431     ENABLE_STATIC_FALSE=
  2432 fi
  2433 AC_SUBST(ENABLE_SHARED_TRUE)
  2434 AC_SUBST(ENABLE_SHARED_FALSE)
  2435 AC_SUBST(ENABLE_STATIC_TRUE)
  2436 AC_SUBST(ENABLE_STATIC_FALSE)
  2437 
  2438 dnl Expand the libraries needed for static and dynamic linking
  2439 AC_SUBST(STATIC_SYSTEM_LIBS)
  2440 AC_SUBST(SHARED_SYSTEM_LIBS)
  2441 AC_SUBST(SYSTEM_LIBS)
  2442 
  2443 dnl Expand the sources and objects needed to build the library
  2444 AC_SUBST(ac_aux_dir)
  2445 AC_SUBST(INCLUDE)
  2446 AC_SUBST(SOURCES)
  2447 AC_SUBST(OBJECTS)
  2448 AC_SUBST(BUILD_CFLAGS)
  2449 AC_SUBST(BUILD_LIBS)
  2450 
  2451 AC_OUTPUT([
  2452     Makefile sdl-config SDL.spec SDL.qpg
  2453 ], [
  2454     : >build-deps
  2455     make depend
  2456 ])