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