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