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