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