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