configure.in
author Ryan C. Gordon <icculus@icculus.org>
Tue, 11 Oct 2011 22:04:51 -0400
branchSDL-1.2
changeset 5976 081c94f2c04a
parent 5890 9c9e8744e887
child 5987 825e1072eac6
permissions -rw-r--r--
Enable -Wall by default.

Fixes Bugzilla #1284.

(But probably upsets buildbot. :) )
(transplanted from 516c5c4e7beabd27608c67cab5b0259643a9083c)
     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 dnl See if GCC's -Wall is supported.
   879 CheckWarnAll()
   880 {
   881     AC_MSG_CHECKING(for GCC -Wall option)
   882     have_gcc_Wall=no
   883 
   884     save_CFLAGS="$CFLAGS"
   885     CFLAGS="$save_CFLAGS -Wall"
   886     AC_TRY_COMPILE([
   887     int x = 0;
   888     ],[
   889     ],[
   890     have_gcc_Wall=yes
   891     ])
   892     AC_MSG_RESULT($have_gcc_Wall)
   893     CFLAGS="$save_CFLAGS"
   894 
   895     if test x$have_gcc_Wall = xyes; then
   896         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
   897     fi
   898 }
   899 
   900 
   901 dnl Do the iPod thing
   902 CheckIPod()
   903 {
   904     AC_ARG_ENABLE(ipod,
   905 AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [[default=no]]]),
   906         , enable_ipod=no)
   907 
   908     if test x$enable_ipod = xyes; then
   909         EXTRA_CFLAGS="$EXTRA_CFLAGS -DIPOD"
   910         AC_DEFINE(SDL_VIDEO_DRIVER_IPOD)
   911         SOURCES="$SOURCES $srcdir/src/video/ipod/*.c"
   912     fi
   913 }
   914 
   915 dnl Find the nanox include and library directories
   916 CheckNANOX()
   917 {
   918     AC_ARG_ENABLE(video-nanox,
   919         AC_HELP_STRING([--enable-video-nanox], [use nanox video driver [[default=no]]]),
   920         , enable_video_nanox=no)
   921 
   922     if test x$enable_video = xyes -a x$enable_video_nanox = xyes; then
   923         AC_ARG_ENABLE(nanox-debug,  
   924             AC_HELP_STRING([--enable-nanox-debug], [print debug messages [[default=no]]]),
   925             , enable_nanox_debug=no)
   926         if test x$enable_nanox_debug = xyes; then
   927             EXTRA_CFLAGS="$EXTRA_CFLAGS -DENABLE_NANOX_DEBUG"
   928         fi
   929 
   930         AC_ARG_ENABLE(nanox-share-memory,  
   931             AC_HELP_STRING([--enable-nanox-share-memory], [use share memory [[default=no]]]),
   932             , enable_nanox_share_memory=no)
   933         if test x$enable_nanox_share_memory = xyes; then
   934             EXTRA_CFLAGS="$EXTRA_CFLAGS -DNANOX_SHARE_MEMORY"
   935         fi
   936 
   937         AC_ARG_ENABLE(nanox_direct_fb, 
   938             AC_HELP_STRING([--enable-nanox-direct-fb], [use direct framebuffer access [[default=no]]]),
   939             , enable_nanox_direct_fb=no)
   940         if test x$enable_nanox_direct_fb = xyes; then
   941             EXTRA_CFLAGS="$EXTRA_CFLAGS -DENABLE_NANOX_DIRECT_FB"
   942         fi
   943 
   944         AC_DEFINE(SDL_VIDEO_DRIVER_NANOX)
   945         SOURCES="$SOURCES $srcdir/src/video/nanox/*.c"
   946         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lnano-X"
   947         have_video=yes
   948     fi
   949 }
   950 
   951 dnl Find the X11 include and library directories
   952 CheckX11()
   953 {
   954     AC_ARG_ENABLE(video-x11,
   955 AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
   956                   , enable_video_x11=yes)
   957     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
   958         case "$host" in
   959             *-*-darwin*)
   960                 # This isn't necessary for X11, but fixes GLX detection
   961                 if test "x$x_includes" = xNONE && test "x$x_libraries" = xNONE; then
   962                     x_includes="/usr/X11R6/include"
   963                     x_libraries="/usr/X11R6/lib"
   964                 fi
   965                 ;;
   966         esac
   967         AC_PATH_X
   968         AC_PATH_XTRA
   969         if test x$have_x = xyes; then
   970             # Only allow dynamically loaded X11 if the X11 function pointers
   971             # will not end up in the global namespace, which causes problems
   972             # with other libraries calling X11 functions.
   973             x11_symbols_private=$have_gcc_fvisibility
   974 
   975             AC_ARG_ENABLE(x11-shared,
   976 AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
   977                           , enable_x11_shared=maybe)
   978 
   979             case "$host" in
   980                 *-*-darwin*) # Latest Mac OS X actually ships with Xrandr/Xrender libs...
   981                     x11_symbols_private=yes
   982                     x11_lib='/usr/X11R6/lib/libX11.6.dylib'
   983                     x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
   984                     xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
   985                     xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
   986                     ;;
   987                 *-*-osf*)
   988                     x11_lib='libX11.so'
   989                     x11ext_lib='libXext.so'
   990                     ;;
   991                 *-*-irix*) # IRIX 6.5 requires that we use /usr/lib32
   992                     x11_lib='libX11.so'
   993                     x11ext_lib='libXext.so'
   994                     ;;
   995                 *)
   996                     x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   997                     x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   998                     xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
   999                     xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1000                     ;;
  1001             esac
  1002 
  1003             X_CFLAGS="$X_CFLAGS -DXTHREADS"
  1004             if test x$ac_cv_func_shmat != xyes; then
  1005                 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
  1006             fi
  1007             CFLAGS="$CFLAGS $X_CFLAGS"
  1008             LDFLAGS="$LDFLAGS $X_LIBS"
  1009 
  1010             AC_DEFINE(SDL_VIDEO_DRIVER_X11)
  1011             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
  1012             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
  1013 
  1014             if test x$enable_x11_shared = xmaybe; then
  1015                 enable_x11_shared=$x11_symbols_private
  1016             fi
  1017             if test x$have_loadso != xyes && \
  1018                test x$enable_x11_shared = xyes; then
  1019                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
  1020                 enable_x11_shared=no
  1021             fi
  1022             if test x$x11_symbols_private != xyes && \
  1023                test x$enable_x11_shared = xyes; then
  1024                 AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
  1025                 enable_x11_shared=no
  1026             fi
  1027 
  1028             if test x$have_loadso = xyes && \
  1029                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
  1030                 echo "-- dynamic libX11 -> $x11_lib"
  1031                 echo "-- dynamic libX11ext -> $x11ext_lib"
  1032                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib")
  1033                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib")
  1034             else
  1035                 enable_x11_shared=no
  1036                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
  1037             fi
  1038             have_video=yes
  1039 
  1040             AC_ARG_ENABLE(dga,
  1041 AC_HELP_STRING([--enable-dga], [allow use of X11 DGA code [[default=yes]]]),
  1042                           , enable_dga=yes)
  1043             if test x$enable_dga = xyes; then
  1044                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86dga/*.c"
  1045             fi
  1046             AC_ARG_ENABLE(video-dga,
  1047 AC_HELP_STRING([--enable-video-dga], [use DGA 2.0 video driver [[default=yes]]]),
  1048                   , enable_video_dga=yes)
  1049             if test x$enable_dga = xyes -a x$enable_video_dga = xyes; then
  1050                 AC_DEFINE(SDL_VIDEO_DRIVER_DGA)
  1051                 SOURCES="$SOURCES $srcdir/src/video/dga/*.c"
  1052             fi
  1053             AC_ARG_ENABLE(video-x11-dgamouse,
  1054 AC_HELP_STRING([--enable-video-x11-dgamouse], [use X11 DGA for mouse events [[default=yes]]]),
  1055                           , enable_video_x11_dgamouse=yes)
  1056             if test x$enable_dga = xyes -a x$enable_video_x11_dgamouse = xyes; then
  1057                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_DGAMOUSE)
  1058             fi
  1059             AC_ARG_ENABLE(video-x11-vm,
  1060 AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
  1061                           , enable_video_x11_vm=yes)
  1062             if test x$enable_video_x11_vm = xyes; then
  1063                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_VIDMODE)
  1064                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86vm/*.c"
  1065             fi
  1066             AC_ARG_ENABLE(video-x11-xv,
  1067 AC_HELP_STRING([--enable-video-x11-xv], [use X11 XvImage extension for video [[default=yes]]]),
  1068                           , enable_video_x11_xv=yes)
  1069             if test x$enable_video_x11_xv = xyes; then
  1070                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XV)
  1071                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xv/*.c"
  1072             fi
  1073             AC_ARG_ENABLE(video-x11-xinerama,
  1074 AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
  1075                             , enable_video_x11_xinerama=yes)
  1076             if test x$enable_video_x11_xinerama = xyes; then
  1077                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA)
  1078                 SOURCES="$SOURCES $srcdir/src/video/Xext/Xinerama/*.c"
  1079             fi
  1080             AC_ARG_ENABLE(video-x11-xme,
  1081 AC_HELP_STRING([--enable-video-x11-xme], [enable Xi Graphics XME for fullscreen [[default=yes]]]),
  1082                             , enable_video_x11_xme=yes)
  1083             if test x$enable_video_x11_xme = xyes; then
  1084                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XME)
  1085                 SOURCES="$SOURCES $srcdir/src/video/Xext/XME/*.c"
  1086             fi
  1087             AC_ARG_ENABLE(video-x11-xrandr,
  1088 AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
  1089                             , enable_video_x11_xrandr=yes)
  1090             if test x$enable_video_x11_xrandr = xyes; then
  1091                 definitely_enable_video_x11_xrandr=no
  1092                 AC_CHECK_HEADER(X11/extensions/Xrandr.h,
  1093                                 have_xrandr_h_hdr=yes,
  1094                                 have_xrandr_h_hdr=no,
  1095                                 [#include <X11/Xlib.h>
  1096                                 ])
  1097                 if test x$have_xrandr_h_hdr = xyes; then
  1098                     if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
  1099                         echo "-- dynamic libXrender -> $xrender_lib"
  1100                         echo "-- dynamic libXrandr -> $xrandr_lib"
  1101                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER, "$xrender_lib")
  1102                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib")
  1103                         definitely_enable_video_x11_xrandr=yes
  1104                     else
  1105                         AC_CHECK_LIB(Xrender, XRenderQueryExtension, have_xrender_lib=yes)
  1106                         AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
  1107                         if test x$have_xrender_lib = xyes && test x$have_xrandr_lib = xyes ; then
  1108                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr -lXrender"
  1109                             definitely_enable_video_x11_xrandr=yes
  1110                         fi
  1111                     fi
  1112                 fi
  1113             fi
  1114             if test x$definitely_enable_video_x11_xrandr = xyes; then
  1115                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR)
  1116             fi
  1117         fi
  1118     fi
  1119 }
  1120 
  1121 dnl Check for QNX photon video driver
  1122 CheckPHOTON()
  1123 {
  1124     AC_ARG_ENABLE(video-photon,
  1125 AC_HELP_STRING([--enable-video-photon], [use QNX Photon video driver [[default=yes]]]),
  1126                   , enable_video_photon=yes)
  1127     if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
  1128         AC_MSG_CHECKING(for QNX Photon support)
  1129         video_photon=no
  1130         AC_TRY_COMPILE([
  1131           #include <Ph.h>
  1132           #include <Pt.h>
  1133           #include <photon/Pg.h>
  1134           #include <photon/PdDirect.h>
  1135         ],[
  1136          PgDisplaySettings_t *visual;
  1137         ],[
  1138         video_photon=yes
  1139         ])
  1140         AC_MSG_RESULT($video_photon)
  1141         if test x$video_photon = xyes; then
  1142             AC_DEFINE(SDL_VIDEO_DRIVER_PHOTON)
  1143             SOURCES="$SOURCES $srcdir/src/video/photon/*.c"
  1144             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lph"
  1145             have_video=yes
  1146 
  1147             CheckOpenGLQNX
  1148         fi
  1149     fi
  1150 }
  1151 
  1152 dnl Set up the BWindow video driver if enabled
  1153 CheckBWINDOW()
  1154 {
  1155     if test x$enable_video = xyes; then
  1156         AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW)
  1157         SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
  1158         have_video=yes
  1159     fi
  1160 }
  1161 
  1162 dnl Set up the Carbon/QuickDraw video driver for Mac OS X (but not Darwin)
  1163 CheckCARBON()
  1164 {
  1165     AC_ARG_ENABLE(video-carbon,
  1166 AC_HELP_STRING([--enable-video-carbon], [use Carbon/QuickDraw video driver [[default=no]]]),
  1167                   , enable_video_carbon=no)
  1168     if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
  1169         AC_MSG_CHECKING(for Carbon framework)
  1170         have_carbon=no
  1171         AC_TRY_COMPILE([
  1172           #include <Carbon/Carbon.h>
  1173         ],[
  1174         ],[
  1175         have_carbon=yes
  1176         ])
  1177         AC_MSG_RESULT($have_carbon)
  1178         if test x$have_carbon = xyes; then
  1179             AC_DEFINE(SDL_VIDEO_DRIVER_TOOLBOX)
  1180             SOURCES="$SOURCES $srcdir/src/video/maccommon/*.c"
  1181             SOURCES="$SOURCES $srcdir/src/video/macrom/*.c"
  1182             have_video=yes
  1183         fi
  1184     fi
  1185 }
  1186 
  1187 dnl Set up the Cocoa/Quartz video driver for Mac OS X (but not Darwin)
  1188 CheckCOCOA()
  1189 {
  1190     AC_ARG_ENABLE(video-cocoa,
  1191 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa/Quartz video driver [[default=yes]]]),
  1192                   , enable_video_cocoa=yes)
  1193     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  1194         save_CFLAGS="$CFLAGS"
  1195         dnl work around that we don't have Objective-C support in autoconf
  1196         CFLAGS="$CFLAGS -x objective-c"
  1197         AC_MSG_CHECKING(for Cocoa framework)
  1198         have_cocoa=no
  1199         AC_TRY_COMPILE([
  1200           #import <Cocoa/Cocoa.h>
  1201         ],[
  1202         ],[
  1203         have_cocoa=yes
  1204         ])
  1205         AC_MSG_RESULT($have_cocoa)
  1206         CFLAGS="$save_CFLAGS"
  1207         if test x$have_cocoa = xyes; then
  1208             AC_DEFINE(SDL_VIDEO_DRIVER_QUARTZ)
  1209             SOURCES="$SOURCES $srcdir/src/video/quartz/*.m"
  1210             have_video=yes
  1211         fi
  1212     fi
  1213 }
  1214 
  1215 dnl Find the framebuffer console includes
  1216 CheckFBCON()
  1217 {
  1218     AC_ARG_ENABLE(video-fbcon,
  1219 AC_HELP_STRING([--enable-video-fbcon], [use framebuffer console video driver [[default=yes]]]),
  1220                   , enable_video_fbcon=yes)
  1221     if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
  1222         AC_MSG_CHECKING(for framebuffer console support)
  1223         video_fbcon=no
  1224         AC_TRY_COMPILE([
  1225          #include <linux/fb.h>
  1226          #include <linux/kd.h>
  1227          #include <linux/keyboard.h>
  1228         ],[
  1229         ],[
  1230         video_fbcon=yes
  1231         ])
  1232         AC_MSG_RESULT($video_fbcon)
  1233         if test x$video_fbcon = xyes; then
  1234             AC_CHECK_FUNCS(getpagesize)
  1235             AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
  1236             SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
  1237             have_video=yes
  1238         fi
  1239     fi
  1240 }
  1241 
  1242 dnl Find DirectFB
  1243 CheckDirectFB()
  1244 {
  1245     AC_ARG_ENABLE(video-directfb,
  1246 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=yes]]]),
  1247                   , enable_video_directfb=yes)
  1248     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  1249         video_directfb=no
  1250 
  1251         DIRECTFB_REQUIRED_VERSION=0.9.15
  1252 
  1253         AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
  1254         if test x$DIRECTFBCONFIG = xno; then
  1255             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1256             if test x$PKG_CONFIG != xno; then
  1257                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
  1258                     DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
  1259                     DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
  1260                     video_directfb=yes
  1261                 fi
  1262             fi
  1263         else
  1264             set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
  1265             NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1266             set -- `directfb-config --version | sed 's/\./ /g'`
  1267             HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1268             if test $HAVE_VERSION -ge $NEED_VERSION; then
  1269                 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
  1270                 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
  1271                 video_directfb=yes
  1272             fi
  1273         fi
  1274         if test x$video_directfb = xyes; then
  1275             # SuSE 11.1 installs directfb-config without directfb-devel
  1276             save_CFLAGS="$CFLAGS"
  1277             CFLAGS="$CFLAGS $DIRECTFB_CFLAGS"
  1278             AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
  1279             CFLAGS="$save_CFLAGS"
  1280             video_directfb=$have_directfb_hdr
  1281         fi
  1282         AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  1283         AC_MSG_RESULT($video_directfb)
  1284 
  1285         if test x$video_directfb = xyes; then
  1286             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
  1287             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  1288             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  1289             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  1290             have_video=yes
  1291         fi
  1292     fi
  1293 }
  1294 
  1295 dnl See if we're running on PlayStation 2 hardware
  1296 CheckPS2GS()
  1297 {
  1298     AC_ARG_ENABLE(video-ps2gs,
  1299 AC_HELP_STRING([--enable-video-ps2gs], [use PlayStation 2 GS video driver [[default=yes]]]),
  1300                   , enable_video_ps2gs=yes)
  1301     if test x$enable_video = xyes -a x$enable_video_ps2gs = xyes; then
  1302         AC_MSG_CHECKING(for PlayStation 2 GS support)
  1303         video_ps2gs=no
  1304         AC_TRY_COMPILE([
  1305          #include <linux/ps2/dev.h>
  1306          #include <linux/ps2/gs.h>
  1307         ],[
  1308         ],[
  1309         video_ps2gs=yes
  1310         ])
  1311         AC_MSG_RESULT($video_ps2gs)
  1312         if test x$video_ps2gs = xyes; then
  1313             AC_DEFINE(SDL_VIDEO_DRIVER_PS2GS)
  1314             SOURCES="$SOURCES $srcdir/src/video/ps2gs/*.c"
  1315             have_video=yes
  1316         fi
  1317     fi
  1318 }
  1319 
  1320 dnl See if we're running on PlayStation 3 Cell hardware
  1321 CheckPS3()
  1322 {
  1323   AC_ARG_ENABLE(video-ps3,
  1324                 AC_HELP_STRING([--enable-video-ps3], [use PlayStation 3 Cell driver [[default=yes]]]),
  1325                 , enable_video_ps3=yes)
  1326   if test x$enable_video = xyes -a x$enable_video_ps3 = xyes; then
  1327     AC_MSG_CHECKING(for PlayStation 3 Cell support)
  1328     video_ps3=no
  1329     AC_TRY_COMPILE([
  1330       #include <linux/fb.h>
  1331       #include <asm/ps3fb.h>
  1332       #include <libspe2.h>
  1333     ],[
  1334     ],[
  1335       video_ps3=yes
  1336     ])
  1337     AC_MSG_RESULT($video_ps3)
  1338     if test x$video_ps3 = xyes; then
  1339       AC_DEFINE(SDL_VIDEO_DRIVER_PS3)
  1340       SOURCES="$SOURCES $srcdir/src/video/ps3/*.c"
  1341       EXTRA_CFLAGS="$EXTRA_CFLAGS -I/opt/cell/sdk/usr/include"
  1342       EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lbilin_scaler_spu -lfb_writer_spu -lyuv2rgb_spu -L/opt/cell/sdk/usr/lib -lspe2"
  1343       have_video=yes
  1344     fi
  1345   fi
  1346 }
  1347 
  1348 dnl Find the GGI includes
  1349 CheckGGI()
  1350 {
  1351     AC_ARG_ENABLE(video-ggi,
  1352 AC_HELP_STRING([--enable-video-ggi], [use GGI video driver [[default=no]]]),
  1353                   , enable_video_ggi=no)
  1354     if test x$enable_video = xyes -a x$enable_video_ggi = xyes; then
  1355         AC_MSG_CHECKING(for GGI support)
  1356         video_ggi=no
  1357         AC_TRY_COMPILE([
  1358          #include <ggi/ggi.h>
  1359          #include <ggi/gii.h>
  1360         ],[
  1361         ],[
  1362         video_ggi=yes
  1363         ])
  1364         AC_MSG_RESULT($video_ggi)
  1365         if test x$video_ggi = xyes; then
  1366             AC_DEFINE(SDL_VIDEO_DRIVER_GGI)
  1367             SOURCES="$SOURCES $srcdir/src/video/ggi/*.c"
  1368             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lggi -lgii -lgg"
  1369             have_video=yes
  1370         fi
  1371     fi
  1372 }
  1373 
  1374 dnl Find the SVGAlib includes and libraries
  1375 CheckSVGA()
  1376 {
  1377     AC_ARG_ENABLE(video-svga,
  1378 AC_HELP_STRING([--enable-video-svga], [use SVGAlib video driver [[default=yes]]]),
  1379                   , enable_video_svga=yes)
  1380     if test x$enable_video = xyes -a x$enable_video_svga = xyes; then
  1381         AC_MSG_CHECKING(for SVGAlib (1.4.0+) support)
  1382         video_svga=no
  1383         AC_TRY_COMPILE([
  1384          #include <vga.h>
  1385          #include <vgamouse.h>
  1386          #include <vgakeyboard.h>
  1387         ],[
  1388          if ( SCANCODE_RIGHTWIN && SCANCODE_LEFTWIN ) {
  1389              exit(0);
  1390          }
  1391         ],[
  1392         video_svga=yes
  1393         ])
  1394         AC_MSG_RESULT($video_svga)
  1395         if test x$video_svga = xyes; then
  1396             AC_DEFINE(SDL_VIDEO_DRIVER_SVGALIB)
  1397             SOURCES="$SOURCES $srcdir/src/video/svga/*.c"
  1398             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvga"
  1399             have_video=yes
  1400         fi
  1401     fi
  1402 }
  1403 
  1404 dnl Find the VGL includes and libraries
  1405 CheckVGL()
  1406 {
  1407     AC_ARG_ENABLE(video-vgl,
  1408 AC_HELP_STRING([--enable-video-vgl], [use VGL video driver [[default=yes]]]),
  1409                   , enable_video_vgl=yes)
  1410     if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
  1411         AC_MSG_CHECKING(for libVGL support)
  1412         video_vgl=no
  1413         AC_TRY_COMPILE([
  1414          #include <sys/fbio.h>
  1415          #include <sys/consio.h>
  1416          #include <sys/kbio.h>
  1417          #include <vgl.h>
  1418         ],[
  1419          VGLBitmap bitmap;
  1420          bitmap.Type = VIDBUF32;
  1421          bitmap.PixelBytes = 4;
  1422          exit(bitmap.Bitmap);
  1423         ],[
  1424         video_vgl=yes
  1425         ])
  1426         AC_MSG_RESULT($video_vgl)
  1427         if test x$video_vgl = xyes; then
  1428             AC_DEFINE(SDL_VIDEO_DRIVER_VGL)
  1429             SOURCES="$SOURCES $srcdir/src/video/vgl/*.c"
  1430             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvgl"
  1431             have_video=yes
  1432         fi
  1433     fi
  1434 }
  1435 
  1436 dnl Set up the wscons video driver if enabled
  1437 CheckWscons()
  1438 {
  1439     AC_ARG_ENABLE(video-wscons,
  1440 AC_HELP_STRING([--enable-video-wscons], [use wscons video driver [[default=yes]]]),
  1441                   , enable_video_wscons=yes)
  1442     if test x$enable_video = xyes -a x$enable_video_wscons = xyes; then
  1443         AC_MSG_CHECKING(for wscons support)
  1444         video_wscons=no
  1445         AC_TRY_COMPILE([
  1446          #include <sys/time.h>
  1447          #include <dev/wscons/wsconsio.h>
  1448          #include <dev/wscons/wsdisplay_usl_io.h>
  1449         ],[
  1450          int wsmode = WSDISPLAYIO_MODE_DUMBFB;
  1451         ],[
  1452         video_wscons=yes
  1453         ])
  1454         AC_MSG_RESULT($video_wscons)
  1455         if test x$video_wscons = xyes; then
  1456             AC_DEFINE(SDL_VIDEO_DRIVER_WSCONS)
  1457             SOURCES="$SOURCES $srcdir/src/video/wscons/*.c"
  1458             have_video=yes
  1459         fi
  1460     fi
  1461 }
  1462 
  1463 
  1464 dnl Find the AAlib includes
  1465 CheckAAlib()
  1466 {
  1467     AC_ARG_ENABLE(video-aalib,
  1468 AC_HELP_STRING([--enable-video-aalib], [use AAlib video driver [[default=no]]]),
  1469                   , enable_video_aalib=no)
  1470     if test x$enable_video = xyes -a x$enable_video_aalib = xyes; then
  1471         AC_MSG_CHECKING(for AAlib support)
  1472         video_aalib=no
  1473         AC_TRY_COMPILE([
  1474          #include <aalib.h>
  1475         ],[
  1476         ],[
  1477         video_aalib=yes
  1478         ])
  1479         AC_MSG_RESULT($video_aalib)
  1480         if test x$video_aalib = xyes; then
  1481             AC_DEFINE(SDL_VIDEO_DRIVER_AALIB)
  1482             SOURCES="$SOURCES $srcdir/src/video/aalib/*.c"
  1483             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -laa"
  1484             have_video=yes
  1485         fi
  1486     fi
  1487 }
  1488 
  1489 dnl Find the libcaca includes
  1490 CheckCaca()
  1491 {
  1492     AC_ARG_ENABLE(video-caca,
  1493 AC_HELP_STRING([--enable-video-caca], [use libcaca video driver [[default=no]]]),
  1494                   , enable_video_caca=no)
  1495     if test x$enable_video = xyes -a x$enable_video_caca = xyes; then
  1496         video_caca=no
  1497         AC_PATH_PROG(CACACONFIG, caca-config, no)
  1498         if test x$CACACONFIG != xno; then
  1499             AC_MSG_CHECKING(for libcaca support)
  1500             CACA_CFLAGS=`$CACACONFIG --cflags`
  1501             CACA_LDFLAGS=`$CACACONFIG --libs`
  1502             save_CFLAGS="$CFLAGS"
  1503             AC_TRY_COMPILE([
  1504              #include <caca.h>
  1505             ],[
  1506             ],[
  1507              video_caca=yes
  1508             ])
  1509             CFLAGS="$save_CFLAGS"
  1510             AC_MSG_RESULT($video_caca)
  1511             if test x$video_caca = xyes; then
  1512                 AC_DEFINE(SDL_VIDEO_DRIVER_CACA)
  1513                 EXTRA_CFLAGS="$EXTRA_CFLAGS $CACA_CFLAGS"
  1514                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $CACA_LDFLAGS"
  1515                 SOURCES="$SOURCES $srcdir/src/video/caca/*.c"
  1516             fi
  1517         fi
  1518     fi
  1519 }
  1520 
  1521 dnl Set up the QTopia video driver if enabled
  1522 CheckQtopia()
  1523 {
  1524     AC_ARG_ENABLE(video-qtopia,
  1525 AC_HELP_STRING([--enable-video-qtopia], [use Qtopia video driver [[default=no]]]),
  1526                   , enable_video_qtopia=no)
  1527     if test x$enable_video = xyes -a x$enable_video_qtopia = xyes; then
  1528         AC_MSG_CHECKING(for Qtopia support)
  1529         video_qtopia=no
  1530         QTOPIA_FLAGS="-DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -I${QPEDIR}/include -I${QTDIR}/include/ -DNO_DEBUG -fno-rtti -fno-exceptions"
  1531         AC_LANG_CPLUSPLUS
  1532         OLD_CXX="$CXXFLAGS"
  1533         CXXFLAGS="$QTOPIA_FLAGS"
  1534         AC_TRY_COMPILE([
  1535          #include <qpe/qpeapplication.h>
  1536         ],[
  1537         ],[
  1538         video_qtopia=yes
  1539         ])
  1540         CXXFLAGS="$OLD_CXX"
  1541         AC_MSG_RESULT($video_qtopia)
  1542         if test x$video_qtopia = xyes; then
  1543             AC_DEFINE(SDL_VIDEO_DRIVER_QTOPIA)
  1544             SOURCES="$SOURCES $srcdir/src/video/qtopia/*.cc"
  1545             SDLMAIN_SOURCES="$srcdir/src/main/qtopia/*.cc"
  1546             EXTRA_CFLAGS="$EXTRA_CFLAGS $QTOPIA_FLAGS"
  1547             SDL_CFLAGS="$SDL_CFLAGS -DQWS -Dmain=SDL_main"
  1548             SDL_LIBS="-lSDLmain $SDL_LIBS -L${QPEDIR}/lib -L${QTDIR}/lib/ -lqpe -lqte"
  1549             have_video=yes
  1550         fi
  1551         AC_LANG_C
  1552     fi
  1553 }
  1554 
  1555 dnl Set up the PicoGUI video driver if enabled
  1556 CheckPicoGUI()
  1557 {
  1558     AC_ARG_ENABLE(video-picogui,
  1559 AC_HELP_STRING([--enable-video-picogui], [use PicoGUI video driver [[default=no]]]),
  1560                   , enable_video_picogui=no)
  1561     if test x$enable_video = xyes -a x$enable_video_picogui = xyes; then
  1562         AC_MSG_CHECKING(for PicoGUI support)
  1563         video_picogui=no
  1564         AC_TRY_COMPILE([
  1565          #include <picogui.h>
  1566         ],[
  1567         ],[
  1568         video_picogui=yes
  1569         ])
  1570         AC_MSG_RESULT($video_picogui)
  1571         if test x$video_picogui = xyes; then
  1572             AC_DEFINE(SDL_VIDEO_DRIVER_PICOGUI)
  1573             SOURCES="$SOURCES $srcdir/src/video/picogui/*.c"
  1574             SDL_LIBS="$SDL_LIBS -lpgui"
  1575             have_video=yes
  1576         fi
  1577     fi
  1578 }
  1579 
  1580 dnl Set up the Atari Bios keyboard driver
  1581 CheckAtariBiosEvent()
  1582 {
  1583     SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.c"
  1584     SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.S"
  1585 }
  1586 
  1587 dnl Set up the Atari Xbios driver
  1588 CheckAtariXbiosVideo()
  1589 {
  1590     AC_ARG_ENABLE(xbios,
  1591 AC_HELP_STRING([--enable-video-xbios], [use Atari Xbios video driver [[default=yes]]]),
  1592                   , enable_video_xbios=yes)
  1593     video_xbios=no
  1594     if test x$enable_video = xyes -a x$enable_video_xbios = xyes; then
  1595         video_xbios=yes
  1596         AC_DEFINE(SDL_VIDEO_DRIVER_XBIOS)
  1597         SOURCES="$SOURCES $srcdir/src/video/xbios/*.c"
  1598         have_video=yes
  1599     fi
  1600 }
  1601 
  1602 dnl Set up the Atari Gem driver
  1603 CheckAtariGemVideo()
  1604 {
  1605     AC_ARG_ENABLE(gem,
  1606 AC_HELP_STRING([--enable-video-gem], [use Atari Gem video driver [[default=yes]]]),
  1607                   , enable_video_gem=yes)
  1608     if test x$enable_video = xyes -a x$enable_video_gem = xyes; then
  1609         video_gem=no
  1610         AC_CHECK_HEADER(gem.h, have_gem_hdr=yes)
  1611         AC_CHECK_LIB(gem, appl_init, have_gem_lib=yes)
  1612         if test x$have_gem_hdr = xyes -a x$have_gem_lib = xyes; then
  1613             video_gem=yes
  1614             AC_DEFINE(SDL_VIDEO_DRIVER_GEM)
  1615             SOURCES="$SOURCES $srcdir/src/video/gem/*.c"
  1616             SDL_LIBS="$SDL_LIBS -lgem"
  1617             have_video=yes
  1618         fi
  1619     fi
  1620 }
  1621 
  1622 dnl rcg04172001 Set up the Null video driver.
  1623 CheckDummyVideo()
  1624 {
  1625     AC_ARG_ENABLE(video-dummy,
  1626 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  1627                   , enable_video_dummy=yes)
  1628     if test x$enable_video_dummy = xyes; then
  1629         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY)
  1630         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1631         have_video=yes
  1632     fi
  1633 }
  1634 
  1635 dnl Check to see if OpenGL support is desired
  1636 AC_ARG_ENABLE(video-opengl,
  1637 AC_HELP_STRING([--enable-video-opengl], [include OpenGL context creation [[default=yes]]]),
  1638               , enable_video_opengl=yes)
  1639 
  1640 dnl Find OpenGL
  1641 CheckOpenGLX11()
  1642 {
  1643     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1644         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1645         video_opengl=no
  1646         AC_TRY_COMPILE([
  1647          #include <GL/gl.h>
  1648          #include <GL/glx.h>
  1649          #include <GL/glu.h>
  1650         ],[
  1651         ],[
  1652         video_opengl=yes
  1653         ])
  1654         AC_MSG_RESULT($video_opengl)
  1655         if test x$video_opengl = xyes; then
  1656             AC_DEFINE(SDL_VIDEO_OPENGL)
  1657             AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
  1658         fi
  1659     fi
  1660 }
  1661 
  1662 dnl Find QNX RtP OpenGL
  1663 CheckOpenGLQNX()
  1664 {
  1665     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1666         AC_MSG_CHECKING(for OpenGL (Photon) support)
  1667         video_opengl=no
  1668         AC_TRY_COMPILE([
  1669          #include <GL/gl.h>
  1670         ],[
  1671         ],[
  1672         video_opengl=yes
  1673         ])
  1674         AC_MSG_RESULT($video_opengl)
  1675         if test x$video_opengl = xyes; then
  1676             AC_DEFINE(SDL_VIDEO_OPENGL)
  1677             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1678         fi
  1679     fi
  1680 }
  1681 
  1682 dnl Check for Win32 OpenGL
  1683 CheckWIN32GL()
  1684 {
  1685     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1686         AC_DEFINE(SDL_VIDEO_OPENGL)
  1687         AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
  1688     fi
  1689 }
  1690 
  1691 dnl Check for BeOS OpenGL
  1692 CheckBeGL()
  1693 {
  1694     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1695         AC_DEFINE(SDL_VIDEO_OPENGL)
  1696         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1697     fi
  1698 }
  1699 
  1700 dnl Check for MacOS OpenGL
  1701 CheckMacGL()
  1702 {
  1703     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1704         AC_DEFINE(SDL_VIDEO_OPENGL)
  1705         case "$host" in
  1706             *-*-darwin*)
  1707                 if test x$enable_video_cocoa = xyes; then
  1708                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
  1709                 fi
  1710                 if test x$enable_video_carbon = xyes; then
  1711                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AGL"
  1712                 fi
  1713         esac
  1714     fi
  1715 }
  1716 
  1717 dnl Check for Mesa offscreen rendering
  1718 CheckAtariOSMesa()
  1719 {
  1720     if test "x$enable_video" = "xyes" -a "x$enable_video_opengl" = "xyes"; then
  1721         AC_CHECK_HEADER(GL/osmesa.h, have_osmesa_hdr=yes)
  1722         AC_CHECK_LIB(OSMesa, OSMesaCreateContext, have_osmesa_lib=yes, have_osmesa_lib=no, -lm)
  1723 
  1724         # Static linking to -lOSMesa
  1725         AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
  1726         if test "x$OSMESA_CONFIG" = "xno" -o "x$enable_atari_ldg" = "xno"; then
  1727             # -lOSMesa is really the static library
  1728             if test "x$have_osmesa_hdr" = "xyes" -a "x$have_osmesa_lib" = "xyes"; then
  1729                 OSMESA_LIBS="-lOSMesa"
  1730             fi
  1731         else
  1732             # -lOSMesa is a loader for OSMesa.ldg
  1733             OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
  1734             OSMESA_LIBS=`$OSMESA_CONFIG --libs`
  1735         fi
  1736         AC_DEFINE(SDL_VIDEO_OPENGL)
  1737         AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA)
  1738         SDL_CFLAGS="$SDL_CFLAGS $OSMESA_CFLAGS"
  1739         SDL_LIBS="$SDL_LIBS $OSMESA_LIBS"
  1740 
  1741         AC_ARG_ENABLE(osmesa-shared,
  1742 AC_HELP_STRING([--enable-osmesa-shared], [dynamically load OSMesa OpenGL support [[default=yes]]]),
  1743                               , enable_osmesa_shared=yes)
  1744         if test "x$enable_osmesa_shared" = "xyes" -a "x$enable_atari_ldg" = "xyes"; then
  1745             # Dynamic linking
  1746             if test "x$have_osmesa_hdr" = "xyes"; then
  1747                 AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA_DYNAMIC)
  1748             fi
  1749         fi
  1750     fi
  1751 }
  1752 
  1753 AC_ARG_ENABLE(screensaver,
  1754 AC_HELP_STRING([--enable-screensaver], [enable screensaver by default while any SDL application is running [[default=no]]]),
  1755               , enable_screensaver=no)
  1756 if test x$enable_screensaver = xno; then
  1757     AC_DEFINE(SDL_VIDEO_DISABLE_SCREENSAVER)
  1758 fi
  1759 
  1760 dnl See if we can use the new unified event interface in Linux 2.4
  1761 CheckInputEvents()
  1762 {
  1763     dnl Check for Linux 2.4 unified input event interface support
  1764     AC_ARG_ENABLE(input-events,
  1765 AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [[default=yes]]]),
  1766                   , enable_input_events=yes)
  1767     if test x$enable_input_events = xyes; then
  1768         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  1769         use_input_events=no
  1770         AC_TRY_COMPILE([
  1771           #include <linux/input.h>
  1772         ],[
  1773           #ifndef EVIOCGNAME
  1774           #error EVIOCGNAME() ioctl not available
  1775           #endif
  1776         ],[
  1777         use_input_events=yes
  1778         ])
  1779         AC_MSG_RESULT($use_input_events)
  1780         if test x$use_input_events = xyes; then
  1781             AC_DEFINE(SDL_INPUT_LINUXEV)
  1782         fi
  1783     fi
  1784 }
  1785 
  1786 dnl See if we can use the Touchscreen input library
  1787 CheckTslib()
  1788 {
  1789     AC_ARG_ENABLE(input-tslib,
  1790 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  1791                   , enable_input_tslib=yes)
  1792     if test x$enable_input_tslib = xyes; then
  1793         AC_MSG_CHECKING(for Touchscreen library support)
  1794         enable_input_tslib=no
  1795         AC_TRY_COMPILE([
  1796           #include "tslib.h"
  1797         ],[
  1798         ],[
  1799         enable_input_tslib=yes
  1800         ])
  1801         AC_MSG_RESULT($enable_input_tslib)
  1802         if test x$enable_input_tslib = xyes; then
  1803             AC_DEFINE(SDL_INPUT_TSLIB)
  1804             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  1805         fi
  1806     fi
  1807 }
  1808 
  1809 dnl See if we can use GNU pth library for threads
  1810 CheckPTH()
  1811 {
  1812     dnl Check for pth support
  1813     AC_ARG_ENABLE(pth,
  1814 AC_HELP_STRING([--enable-pth], [use GNU pth library for multi-threading [[default=yes]]]),
  1815                   , enable_pth=yes)
  1816     if test x$enable_threads = xyes -a x$enable_pth = xyes; then
  1817         AC_PATH_PROG(PTH_CONFIG, pth-config, no)
  1818         if test "$PTH_CONFIG" = "no"; then
  1819             use_pth=no
  1820         else
  1821             use_pth=yes
  1822         fi
  1823         AC_MSG_CHECKING(pth)
  1824         AC_MSG_RESULT($use_pth)
  1825         if test "x$use_pth" = xyes; then
  1826             AC_DEFINE(SDL_THREAD_PTH)
  1827             SOURCES="$SOURCES $srcdir/src/thread/pth/*.c"
  1828             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1829             SDL_CFLAGS="$SDL_CFLAGS `$PTH_CONFIG --cflags`"
  1830             SDL_LIBS="$SDL_LIBS `$PTH_CONFIG --libs --all`"
  1831             have_threads=yes
  1832         fi
  1833     fi
  1834 }
  1835 
  1836 dnl See what type of thread model to use on Linux and Solaris
  1837 CheckPTHREAD()
  1838 {
  1839     dnl Check for pthread support
  1840     AC_ARG_ENABLE(pthreads,
  1841 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  1842                   , enable_pthreads=yes)
  1843     dnl This is used on Linux for glibc binary compatibility (Doh!)
  1844     AC_ARG_ENABLE(pthread-sem,
  1845 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  1846                   , enable_pthread_sem=yes)
  1847     case "$host" in
  1848         *-*-linux*|*-*-uclinux*)
  1849             pthread_cflags="-D_REENTRANT"
  1850             pthread_lib="-lpthread"
  1851             ;;
  1852         *-*-bsdi*)
  1853             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1854             pthread_lib=""
  1855             ;;
  1856         *-*-darwin*)
  1857             pthread_cflags="-D_THREAD_SAFE"
  1858 # causes Carbon.p complaints?
  1859 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1860             ;;
  1861         *-*-freebsd*|*-*-dragonfly*)
  1862             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1863             pthread_lib="-pthread"
  1864             ;;
  1865         *-*-netbsd*)
  1866             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1867             pthread_lib="-lpthread"
  1868             ;;
  1869         *-*-openbsd*)
  1870             pthread_cflags="-D_REENTRANT"
  1871             pthread_lib="-pthread"
  1872             ;;
  1873         *-*-solaris*)
  1874             pthread_cflags="-D_REENTRANT"
  1875             pthread_lib="-lpthread -lposix4"
  1876             ;;
  1877         *-*-sysv5*)
  1878             pthread_cflags="-D_REENTRANT -Kthread"
  1879             pthread_lib=""
  1880             ;;
  1881         *-*-irix*)
  1882             pthread_cflags="-D_SGI_MP_SOURCE"
  1883             pthread_lib="-lpthread"
  1884             ;;
  1885         *-*-aix*)
  1886             pthread_cflags="-D_REENTRANT -mthreads"
  1887             pthread_lib="-lpthread"
  1888             ;;
  1889         *-*-hpux11*)
  1890             pthread_cflags="-D_REENTRANT"
  1891             pthread_lib="-L/usr/lib -lpthread"
  1892             ;;
  1893         *-*-qnx*)
  1894             pthread_cflags=""
  1895             pthread_lib=""
  1896             ;;
  1897         *-*-osf*)
  1898             pthread_cflags="-D_REENTRANT"
  1899             if test x$ac_cv_prog_gcc = xyes; then
  1900                 pthread_lib="-lpthread -lrt"
  1901             else
  1902                 pthread_lib="-lpthread -lexc -lrt"
  1903             fi
  1904             ;;
  1905         *)
  1906             pthread_cflags="-D_REENTRANT"
  1907             pthread_lib="-lpthread"
  1908             ;;
  1909     esac
  1910     if test x$enable_threads = xyes -a x$enable_pthreads = xyes -a x$enable_ipod != xyes; then
  1911         # Save the original compiler flags and libraries
  1912         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1913         # Add the pthread compiler flags and libraries
  1914         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1915         # Check to see if we have pthread support on this system
  1916         AC_MSG_CHECKING(for pthreads)
  1917         use_pthreads=no
  1918         AC_TRY_LINK([
  1919          #include <pthread.h>
  1920         ],[
  1921          pthread_attr_t type;
  1922          pthread_attr_init(&type);
  1923         ],[
  1924         use_pthreads=yes
  1925         ])
  1926         AC_MSG_RESULT($use_pthreads)
  1927         # Restore the compiler flags and libraries
  1928         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1929 
  1930         # Do futher testing if we have pthread support...
  1931         if test x$use_pthreads = xyes; then
  1932             AC_DEFINE(SDL_THREAD_PTHREAD)
  1933             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  1934             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  1935             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  1936             SDL_LIBS="$SDL_LIBS $pthread_lib"
  1937 
  1938             # Save the original compiler flags and libraries
  1939             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1940             # Add the pthread compiler flags and libraries
  1941             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1942 
  1943             # Check to see if recursive mutexes are available
  1944             AC_MSG_CHECKING(for recursive mutexes)
  1945             has_recursive_mutexes=no
  1946             if test x$has_recursive_mutexes = xno; then
  1947                 AC_TRY_COMPILE([
  1948                   #include <pthread.h>
  1949                 ],[
  1950                   pthread_mutexattr_t attr;
  1951                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  1952                 ],[
  1953                 has_recursive_mutexes=yes
  1954                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX)
  1955                 ])
  1956             fi
  1957             if test x$has_recursive_mutexes = xno; then
  1958                 AC_TRY_COMPILE([
  1959                   #include <pthread.h>
  1960                 ],[
  1961                   pthread_mutexattr_t attr;
  1962                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  1963                 ],[
  1964                 has_recursive_mutexes=yes
  1965                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)
  1966                 ])
  1967             fi
  1968             AC_MSG_RESULT($has_recursive_mutexes)
  1969 
  1970             # Check to see if pthread semaphore support is missing
  1971             if test x$enable_pthread_sem = xyes; then
  1972                 AC_MSG_CHECKING(for pthread semaphores)
  1973                 have_pthread_sem=no
  1974                 AC_TRY_COMPILE([
  1975                   #include <pthread.h>
  1976                   #include <semaphore.h>
  1977                 ],[
  1978                 ],[
  1979                 have_pthread_sem=yes
  1980                 ])
  1981                 AC_MSG_RESULT($have_pthread_sem)
  1982             fi
  1983 
  1984             # Restore the compiler flags and libraries
  1985             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1986 
  1987             # Basic thread creation functions
  1988             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  1989 
  1990             # Semaphores
  1991             # We can fake these with mutexes and condition variables if necessary
  1992             if test x$have_pthread_sem = xyes; then
  1993                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  1994             else
  1995                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1996             fi
  1997 
  1998             # Mutexes
  1999             # We can fake these with semaphores if necessary
  2000             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  2001 
  2002             # Condition variables
  2003             # We can fake these with semaphores and mutexes if necessary
  2004             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  2005 
  2006             have_threads=yes
  2007         else
  2008             CheckPTH
  2009         fi
  2010     fi
  2011 }
  2012 
  2013 dnl Determine whether the compiler can produce Win32 executables
  2014 CheckWIN32()
  2015 {
  2016     AC_MSG_CHECKING(Win32 compiler)
  2017     have_win32_gcc=no
  2018     AC_TRY_COMPILE([
  2019      #include <windows.h>
  2020     ],[
  2021     ],[
  2022     have_win32_gcc=yes
  2023     ])
  2024     AC_MSG_RESULT($have_win32_gcc)
  2025     if test x$have_win32_gcc != xyes; then
  2026        AC_MSG_ERROR([
  2027 *** Your compiler ($CC) does not produce Win32 executables!
  2028        ])
  2029     fi
  2030 
  2031     dnl See if the user wants to redirect standard output to files
  2032     AC_ARG_ENABLE(stdio-redirect,
  2033 AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[default=yes]]]),
  2034                   , enable_stdio_redirect=yes)
  2035     if test x$enable_stdio_redirect != xyes; then
  2036         EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
  2037     fi
  2038 
  2039     if test x$enable_video = xyes; then
  2040         AC_DEFINE(SDL_VIDEO_DRIVER_WINDIB)
  2041         SOURCES="$SOURCES $srcdir/src/video/wincommon/*.c"
  2042         SOURCES="$SOURCES $srcdir/src/video/windib/*.c"
  2043         have_video=yes
  2044     fi
  2045 }
  2046 
  2047 dnl Find the DirectX includes and libraries
  2048 CheckDIRECTX()
  2049 {
  2050     AC_ARG_ENABLE(directx,
  2051 AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]),
  2052                   , enable_directx=yes)
  2053     if test x$enable_directx = xyes; then
  2054         have_directx=no
  2055         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  2056         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  2057         AC_CHECK_HEADER(dinput.h, use_dinput=yes)
  2058         if test x$have_ddraw = xyes -a x$have_dsound = xyes -a x$use_dinput = xyes; then
  2059             have_directx=yes
  2060         fi
  2061         if test x$enable_video = xyes -a x$have_directx = xyes; then
  2062             AC_DEFINE(SDL_VIDEO_DRIVER_DDRAW)
  2063             SOURCES="$SOURCES $srcdir/src/video/windx5/*.c"
  2064             have_video=yes
  2065         fi
  2066     fi
  2067 }
  2068 
  2069 dnl Check for the dlfcn.h interface for dynamically loading objects
  2070 CheckDLOPEN()
  2071 {
  2072     AC_ARG_ENABLE(sdl-dlopen,
  2073 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  2074                   , enable_sdl_dlopen=yes)
  2075     if test x$enable_sdl_dlopen = xyes; then
  2076         AC_MSG_CHECKING(for dlopen)
  2077         have_dlopen=no
  2078         AC_TRY_COMPILE([
  2079          #include <dlfcn.h>
  2080         ],[
  2081          #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
  2082          #error Use dlcompat for Mac OS X 10.2 compatibility
  2083          #endif
  2084         ],[
  2085         have_dlopen=yes
  2086         ])
  2087         AC_MSG_RESULT($have_dlopen)
  2088 
  2089         if test x$have_dlopen = xyes; then
  2090             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  2091                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  2092                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  2093             AC_DEFINE(SDL_LOADSO_DLOPEN)
  2094             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  2095             have_loadso=yes
  2096         fi
  2097     fi
  2098 }
  2099 
  2100 dnl Set up the Atari LDG (shared object loader)
  2101 CheckAtariLdg()
  2102 {
  2103     AC_ARG_ENABLE(atari-ldg,
  2104 AC_HELP_STRING([--enable-atari-ldg], [use Atari LDG for shared object loading [[default=yes]]]),
  2105                   , enable_atari_ldg=yes)
  2106     if test x$video_gem = xyes -a x$enable_atari_ldg = xyes; then
  2107         AC_CHECK_HEADER(ldg.h, have_ldg_hdr=yes)
  2108         AC_CHECK_LIB(ldg, ldg_open, have_ldg_lib=yes, have_ldg_lib=no, -lgem)
  2109         if test x$have_ldg_hdr = xyes -a x$have_ldg_lib = xyes; then
  2110             AC_DEFINE(SDL_LOADSO_LDG)
  2111             SOURCES="$SOURCES $srcdir/src/loadso/mint/*.c"
  2112             SDL_LIBS="$SDL_LIBS -lldg -lgem"
  2113             have_loadso=yes
  2114         fi
  2115     fi
  2116 }
  2117 
  2118 dnl Check for the usbhid(3) library on *BSD
  2119 CheckUSBHID()
  2120 {
  2121     if test x$enable_joystick = xyes; then
  2122         AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  2123         if test x$have_libusbhid = xyes; then
  2124             AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  2125             AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  2126             USB_LIBS="$USB_LIBS -lusbhid"
  2127         else
  2128             AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  2129             AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  2130             AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  2131         fi
  2132             
  2133         save_CFLAGS="$CFLAGS"
  2134         CFLAGS="$CFLAGS $USB_CFLAGS"
  2135 
  2136         AC_MSG_CHECKING(for usbhid)
  2137         have_usbhid=no
  2138         AC_TRY_COMPILE([
  2139           #include <sys/types.h>
  2140           #if defined(HAVE_USB_H)
  2141           #include <usb.h>
  2142           #endif
  2143           #ifdef __DragonFly__
  2144           # include <bus/usb/usb.h>
  2145           # include <bus/usb/usbhid.h>
  2146           #else
  2147           # include <dev/usb/usb.h>
  2148           # include <dev/usb/usbhid.h>
  2149           #endif
  2150           #if defined(HAVE_USBHID_H)
  2151           #include <usbhid.h>
  2152           #elif defined(HAVE_LIBUSB_H)
  2153           #include <libusb.h>
  2154           #elif defined(HAVE_LIBUSBHID_H)
  2155           #include <libusbhid.h>
  2156           #endif
  2157         ],[
  2158           struct report_desc *repdesc;
  2159           struct usb_ctl_report *repbuf;
  2160           hid_kind_t hidkind;
  2161         ],[
  2162         have_usbhid=yes
  2163         ])
  2164         AC_MSG_RESULT($have_usbhid)
  2165 
  2166         if test x$have_usbhid = xyes; then
  2167             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  2168             have_usbhid_ucr_data=no
  2169             AC_TRY_COMPILE([
  2170               #include <sys/types.h>
  2171               #if defined(HAVE_USB_H)
  2172               #include <usb.h>
  2173               #endif
  2174               #ifdef __DragonFly__
  2175               # include <bus/usb/usb.h>
  2176               # include <bus/usb/usbhid.h>
  2177               #else
  2178               # include <dev/usb/usb.h>
  2179               # include <dev/usb/usbhid.h>
  2180               #endif
  2181               #if defined(HAVE_USBHID_H)
  2182               #include <usbhid.h>
  2183               #elif defined(HAVE_LIBUSB_H)
  2184               #include <libusb.h>
  2185               #elif defined(HAVE_LIBUSBHID_H)
  2186               #include <libusbhid.h>
  2187               #endif
  2188             ],[
  2189               struct usb_ctl_report buf;
  2190               if (buf.ucr_data) { }
  2191             ],[
  2192             have_usbhid_ucr_data=yes
  2193             ])
  2194             if test x$have_usbhid_ucr_data = xyes; then
  2195                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  2196             fi
  2197             AC_MSG_RESULT($have_usbhid_ucr_data)
  2198             
  2199             AC_MSG_CHECKING(for new usbhid API)
  2200             have_usbhid_new=no
  2201             AC_TRY_COMPILE([
  2202               #include <sys/types.h>
  2203               #if defined(HAVE_USB_H)
  2204               #include <usb.h>
  2205               #endif
  2206               #ifdef __DragonFly__
  2207               #include <bus/usb/usb.h>
  2208               #include <bus/usb/usbhid.h>
  2209               #else
  2210               #include <dev/usb/usb.h>
  2211               #include <dev/usb/usbhid.h>
  2212               #endif
  2213               #if defined(HAVE_USBHID_H)
  2214               #include <usbhid.h>
  2215               #elif defined(HAVE_LIBUSB_H)
  2216               #include <libusb.h>
  2217               #elif defined(HAVE_LIBUSBHID_H)
  2218               #include <libusbhid.h>
  2219               #endif
  2220             ],[
  2221               report_desc_t d;
  2222               hid_start_parse(d, 1, 1);
  2223             ],[
  2224             have_usbhid_new=yes
  2225             ])
  2226             if test x$have_usbhid_new = xyes; then
  2227                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  2228             fi
  2229             AC_MSG_RESULT($have_usbhid_new)
  2230 
  2231             AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  2232             have_machine_joystick=no
  2233             AC_TRY_COMPILE([
  2234               #include <machine/joystick.h>
  2235             ],[
  2236               struct joystick t;
  2237             ],[
  2238             have_machine_joystick=yes
  2239             ])
  2240             if test x$have_machine_joystick = xyes; then
  2241                 AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H)
  2242             fi
  2243             AC_MSG_RESULT($have_machine_joystick)
  2244 
  2245             AC_DEFINE(SDL_JOYSTICK_USBHID)
  2246             SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  2247             EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  2248             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  2249             have_joystick=yes
  2250         fi
  2251         CFLAGS="$save_CFLAGS"
  2252     fi
  2253 }
  2254 
  2255 dnl Check for clock_gettime()
  2256 CheckClockGettime()
  2257 {
  2258     AC_ARG_ENABLE(clock_gettime,
  2259 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=no]]]),
  2260                   , enable_clock_gettime=no)
  2261     if test x$enable_clock_gettime = xyes; then
  2262         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  2263         if test x$have_clock_gettime = xyes; then
  2264             AC_DEFINE(HAVE_CLOCK_GETTIME)
  2265             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  2266         fi
  2267     fi
  2268 }
  2269 
  2270 dnl Check for a valid linux/version.h
  2271 CheckLinuxVersion()
  2272 {
  2273     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  2274     if test x$have_linux_version_h = xyes; then
  2275         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  2276     fi
  2277 }
  2278 
  2279 dnl Check if we want to use RPATH
  2280 CheckRPATH()
  2281 {
  2282     AC_ARG_ENABLE(rpath,
  2283 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  2284                   , enable_rpath=yes)
  2285 }
  2286 
  2287 dnl Set up the configuration based on the host platform!
  2288 case "$host" in
  2289     arm-*-elf*) # FIXME: Can we get more specific for iPodLinux?
  2290         ARCH=linux
  2291         CheckDummyVideo
  2292         CheckIPod
  2293         # Set up files for the timer library
  2294         if test x$enable_timers = xyes; then
  2295             AC_DEFINE(SDL_TIMER_UNIX)
  2296             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2297             have_timers=yes
  2298         fi
  2299         ;;
  2300     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*)
  2301         case "$host" in
  2302             *-*-linux*)         ARCH=linux ;;
  2303             *-*-uclinux*)       ARCH=linux ;;
  2304             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  2305             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  2306             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  2307             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  2308             *-*-bsdi*)          ARCH=bsdi ;;
  2309             *-*-freebsd*)       ARCH=freebsd ;;
  2310             *-*-dragonfly*)     ARCH=freebsd ;;
  2311             *-*-netbsd*)        ARCH=netbsd ;;
  2312             *-*-openbsd*)       ARCH=openbsd ;;
  2313             *-*-sysv5*)         ARCH=sysv5 ;;
  2314             *-*-solaris*)       ARCH=solaris ;;
  2315             *-*-hpux*)          ARCH=hpux ;;
  2316             *-*-irix*)          ARCH=irix ;;
  2317             *-*-aix*)           ARCH=aix ;;
  2318             *-*-osf*)           ARCH=osf ;;
  2319         esac
  2320         CheckVisibilityHidden
  2321         CheckDummyVideo
  2322         CheckDiskAudio
  2323         CheckDummyAudio
  2324         CheckDLOPEN
  2325         CheckNASM
  2326         CheckAltivec
  2327         CheckOSS
  2328         CheckDMEDIA
  2329         CheckMME
  2330         CheckALSA
  2331         CheckARTSC
  2332         CheckESD
  2333         CheckPulseAudio
  2334         CheckNAS
  2335         CheckX11
  2336         CheckNANOX
  2337         CheckFBCON
  2338         CheckDirectFB
  2339         CheckPS2GS
  2340         CheckPS3
  2341         CheckGGI
  2342         CheckSVGA
  2343         CheckVGL
  2344         CheckWscons
  2345         CheckAAlib
  2346         CheckCaca
  2347         CheckQtopia
  2348         CheckPicoGUI
  2349         CheckOpenGLX11
  2350         CheckInputEvents
  2351         CheckTslib
  2352         CheckUSBHID
  2353         CheckPTHREAD
  2354         CheckClockGettime
  2355         CheckLinuxVersion
  2356         CheckRPATH
  2357         # Set up files for the audio library
  2358         if test x$enable_audio = xyes; then
  2359           case $ARCH in
  2360             sysv5|solaris|hpux)
  2361                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
  2362                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2363                 have_audio=yes
  2364             ;;
  2365             netbsd|openbsd)
  2366                 AC_DEFINE(SDL_AUDIO_DRIVER_BSD)
  2367                 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
  2368                 have_audio=yes
  2369             ;;
  2370             aix)
  2371                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUD)
  2372                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  2373                 have_audio=yes
  2374             ;;
  2375           esac
  2376         fi
  2377         # Set up files for the joystick library
  2378         if test x$enable_joystick = xyes; then
  2379           case $ARCH in
  2380             linux)
  2381                 AC_DEFINE(SDL_JOYSTICK_LINUX)
  2382                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  2383                 have_joystick=yes
  2384             ;;
  2385           esac
  2386         fi
  2387         # Set up files for the cdrom library
  2388         if test x$enable_cdrom = xyes; then
  2389           case $ARCH in
  2390             linux|solaris)
  2391                 AC_DEFINE(SDL_CDROM_LINUX)
  2392                 SOURCES="$SOURCES $srcdir/src/cdrom/linux/*.c"
  2393                 have_cdrom=yes
  2394             ;;
  2395             *freebsd*)
  2396                 AC_DEFINE(SDL_CDROM_FREEBSD)
  2397                 SOURCES="$SOURCES $srcdir/src/cdrom/freebsd/*.c"
  2398                 have_cdrom=yes
  2399             ;;
  2400             *openbsd*|*netbsd*)
  2401                 AC_DEFINE(SDL_CDROM_OPENBSD)
  2402                 SOURCES="$SOURCES $srcdir/src/cdrom/openbsd/*.c"
  2403                 have_cdrom=yes
  2404             ;;
  2405             bsdi)
  2406                 AC_DEFINE(SDL_CDROM_BSDI)
  2407                 SOURCES="$SOURCES $srcdir/src/cdrom/bsdi/*.c"
  2408                 have_cdrom=yes
  2409             ;;
  2410             aix)
  2411                 AC_DEFINE(SDL_CDROM_AIX)
  2412                 SOURCES="$SOURCES $srcdir/src/cdrom/aix/*.c"
  2413                 have_cdrom=yes
  2414             ;;
  2415             osf)
  2416                 AC_DEFINE(SDL_CDROM_OSF)
  2417                 SOURCES="$SOURCES $srcdir/src/cdrom/osf/*.c"
  2418                 have_cdrom=yes
  2419             ;;
  2420           esac
  2421         fi
  2422         # Set up files for the thread library
  2423         if test x$enable_threads = xyes -a x$use_pthreads != xyes -a x$use_pth != xyes -a x$ARCH = xirix; then
  2424             AC_DEFINE(SDL_THREAD_SPROC)
  2425             SOURCES="$SOURCES $srcdir/src/thread/irix/*.c"
  2426             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2427             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2428             have_threads=yes
  2429         fi
  2430         # Set up files for the timer library
  2431         if test x$enable_timers = xyes; then
  2432             AC_DEFINE(SDL_TIMER_UNIX)
  2433             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2434             have_timers=yes
  2435         fi
  2436         ;;
  2437     *-*-qnx*)
  2438         ARCH=qnx
  2439         CheckDummyVideo
  2440         CheckDiskAudio
  2441         CheckDummyAudio
  2442         # CheckNASM
  2443         CheckDLOPEN
  2444         CheckNAS
  2445         CheckPHOTON
  2446         CheckX11
  2447         CheckOpenGLX11
  2448         CheckPTHREAD
  2449         # Set up files for the audio library
  2450         if test x$enable_audio = xyes; then
  2451             AC_DEFINE(SDL_AUDIO_DRIVER_QNXNTO)
  2452             SOURCES="$SOURCES $srcdir/src/audio/nto/*.c"
  2453             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
  2454             have_audio=yes
  2455         fi
  2456         # Set up files for the cdrom library
  2457         if test x$enable_cdrom = xyes; then
  2458             AC_DEFINE(SDL_CDROM_QNX)
  2459             SOURCES="$SOURCES $srcdir/src/cdrom/qnx/*.c"
  2460             have_cdrom=yes
  2461         fi
  2462         # Set up files for the timer library
  2463         if test x$enable_timers = xyes; then
  2464             AC_DEFINE(SDL_TIMER_UNIX)
  2465             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2466             have_timers=yes
  2467         fi
  2468         ;;
  2469     *-*-cygwin* | *-*-mingw32*)
  2470         ARCH=win32
  2471         if test "$build" != "$host"; then # cross-compiling
  2472             # Default cross-compile location
  2473             ac_default_prefix=/usr/local/cross-tools/i386-mingw32
  2474         else
  2475             # Look for the location of the tools and install there
  2476             if test "$BUILD_PREFIX" != ""; then
  2477                 ac_default_prefix=$BUILD_PREFIX
  2478             fi
  2479         fi
  2480         CheckDummyVideo
  2481         CheckDiskAudio
  2482         CheckDummyAudio
  2483         CheckWIN32
  2484         CheckWIN32GL
  2485         CheckDIRECTX
  2486         CheckNASM
  2487         # Set up files for the audio library
  2488         if test x$enable_audio = xyes; then
  2489             AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
  2490             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2491             if test x$have_directx = xyes; then
  2492                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2493                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2494             fi
  2495             have_audio=yes
  2496         fi
  2497         # Set up files for the joystick library
  2498         if test x$enable_joystick = xyes; then
  2499             AC_DEFINE(SDL_JOYSTICK_WINMM)
  2500             SOURCES="$SOURCES $srcdir/src/joystick/win32/*.c"
  2501             have_joystick=yes
  2502         fi
  2503         # Set up files for the cdrom library
  2504         if test x$enable_cdrom = xyes; then
  2505             AC_DEFINE(SDL_CDROM_WIN32)
  2506             SOURCES="$SOURCES $srcdir/src/cdrom/win32/*.c"
  2507             have_cdrom=yes
  2508         fi
  2509         # Set up files for the thread library
  2510         if test x$enable_threads = xyes; then
  2511             AC_DEFINE(SDL_THREAD_WIN32)
  2512             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
  2513             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
  2514             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
  2515             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2516             have_threads=yes
  2517         fi
  2518         # Set up files for the timer library
  2519         if test x$enable_timers = xyes; then
  2520             AC_DEFINE(SDL_TIMER_WIN32)
  2521             SOURCES="$SOURCES $srcdir/src/timer/win32/*.c"
  2522             have_timers=yes
  2523         fi
  2524         # Set up files for the shared object loading library
  2525         if test x$enable_loadso = xyes; then
  2526             AC_DEFINE(SDL_LOADSO_WIN32)
  2527             SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
  2528             have_loadso=yes
  2529         fi
  2530         # Set up the system libraries we need
  2531         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm"
  2532         if test x$have_directx = xyes; then
  2533             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldxguid"
  2534         fi
  2535         # The Win32 platform requires special setup
  2536         SOURCES="$SOURCES $srcdir/src/main/win32/*.rc"
  2537         SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
  2538         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2539         SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
  2540         ;;
  2541     *-wince*)
  2542         ARCH=win32
  2543         CheckDummyVideo
  2544         CheckDiskAudio
  2545         CheckDummyAudio
  2546         CheckWIN32
  2547         CheckNASM
  2548         SOURCES="$SOURCES $srcdir/src/video/gapi/*.c"
  2549         EXTRA_CFLAGS="$EXTRA_CFLAGS -D_WIN32_WCE=0x420"
  2550         if test x$enable_audio = xyes; then
  2551             AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
  2552             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2553             have_audio=yes
  2554         fi
  2555         # Set up files for the thread library
  2556         if test x$enable_threads = xyes; then
  2557             AC_DEFINE(SDL_THREAD_WIN32)
  2558             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
  2559             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
  2560             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
  2561             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2562             have_threads=yes
  2563         fi
  2564         # Set up files for the timer library
  2565         if test x$enable_timers = xyes; then
  2566             AC_DEFINE(SDL_TIMER_WINCE)
  2567             SOURCES="$SOURCES $srcdir/src/timer/wince/*.c"
  2568             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lmmtimer"
  2569             have_timers=yes
  2570         fi
  2571         # Set up files for the shared object loading library
  2572         if test x$enable_loadso = xyes; then
  2573             AC_DEFINE(SDL_LOADSO_WIN32)
  2574             SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
  2575             have_loadso=yes
  2576         fi
  2577         # Set up the system libraries we need
  2578         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl"
  2579         # The Win32 platform requires special setup
  2580         SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
  2581         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
  2582         SDL_LIBS="-lSDLmain $SDL_LIBS"
  2583         ;;
  2584     *-*-beos* | *-*-haiku*)
  2585         ARCH=beos
  2586         ac_default_prefix=/boot/develop/tools/gnupro
  2587         CheckDummyVideo
  2588         CheckDiskAudio
  2589         CheckDummyAudio
  2590         CheckNASM
  2591         CheckBWINDOW
  2592         CheckBeGL
  2593         # Set up files for the audio library
  2594         if test x$enable_audio = xyes; then
  2595             AC_DEFINE(SDL_AUDIO_DRIVER_BAUDIO)
  2596             SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
  2597             have_audio=yes
  2598         fi
  2599         # Set up files for the joystick library
  2600         if test x$enable_joystick = xyes; then
  2601             AC_DEFINE(SDL_JOYSTICK_BEOS)
  2602             SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
  2603             have_joystick=yes
  2604         fi
  2605         # Set up files for the cdrom library
  2606         if test x$enable_cdrom = xyes; then
  2607             AC_DEFINE(SDL_CDROM_BEOS)
  2608             SOURCES="$SOURCES $srcdir/src/cdrom/beos/*.cc"
  2609             have_cdrom=yes
  2610         fi
  2611         # Set up files for the thread library
  2612         if test x$enable_threads = xyes; then
  2613             AC_DEFINE(SDL_THREAD_BEOS)
  2614             SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
  2615             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2616             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2617             have_threads=yes
  2618         fi
  2619         # Set up files for the timer library
  2620         if test x$enable_timers = xyes; then
  2621             AC_DEFINE(SDL_TIMER_BEOS)
  2622             SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
  2623             have_timers=yes
  2624         fi
  2625         # Set up files for the shared object loading library
  2626         if test x$enable_loadso = xyes; then
  2627             case "$host" in
  2628                 *-*-beos*)
  2629                     AC_DEFINE(SDL_LOADSO_BEOS)
  2630                     SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
  2631                 ;;
  2632                 *-*-haiku*)
  2633                     AC_DEFINE(SDL_LOADSO_DLOPEN)
  2634                     SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  2635                 ;;
  2636             esac    
  2637             have_loadso=yes
  2638         fi
  2639         # The BeOS platform requires special setup.
  2640         SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
  2641         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2642         ;;
  2643     *-*-darwin* )
  2644         # This could be either full "Mac OS X", or plain "Darwin" which is
  2645         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2646         # Next line is broken, and a few files below require Mac OS X (full)
  2647         ARCH=macosx
  2648 
  2649         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  2650         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  2651         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  2652 
  2653         # HACK: Reset EXTRA_LDFLAGS; the only thing it contains at this point
  2654         # is -lm which is not needed under Mac OS X. But for some reasons it
  2655         # also tends to contain spurious -L switches, which we don't want to
  2656         # use here or in sdl-config. Hence we reset it.
  2657         EXTRA_LDFLAGS=""
  2658 
  2659         CheckVisibilityHidden
  2660         CheckDummyVideo
  2661         CheckDiskAudio
  2662         CheckDummyAudio
  2663         CheckDLOPEN
  2664         CheckNASM
  2665 
  2666         # Set up files for the shared object loading library
  2667         # (this needs to be done before the dynamic X11 check)
  2668         if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
  2669             AC_DEFINE(SDL_LOADSO_DLCOMPAT)
  2670             SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
  2671             have_loadso=yes
  2672         fi
  2673 
  2674         CheckCOCOA
  2675         CheckCARBON
  2676         CheckX11
  2677         CheckMacGL
  2678         CheckOpenGLX11
  2679         CheckPTHREAD
  2680         CheckAltivec
  2681 
  2682         # Need this or things might misbuild on a G3.
  2683         EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
  2684 
  2685         # Set up files for the audio library
  2686         if test x$enable_audio = xyes; then
  2687             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO)
  2688             SOURCES="$SOURCES $srcdir/src/audio/macosx/*.c"
  2689             have_audio=yes
  2690         fi
  2691         # Set up files for the joystick library
  2692         if test x$enable_joystick = xyes; then
  2693             AC_DEFINE(SDL_JOYSTICK_IOKIT)
  2694             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  2695             have_joystick=yes
  2696             need_iokit_framework=yes
  2697         fi
  2698         # Set up files for the cdrom library
  2699         if test x$enable_cdrom = xyes; then
  2700             AC_DEFINE(SDL_CDROM_MACOSX)
  2701             SOURCES="$SOURCES $srcdir/src/cdrom/macosx/*.c"
  2702             have_cdrom=yes
  2703         fi
  2704         # Set up files for the timer library
  2705         if test x$enable_timers = xyes; then
  2706             AC_DEFINE(SDL_TIMER_UNIX)
  2707             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2708             have_timers=yes
  2709         fi
  2710         # The Mac OS X platform requires special setup.
  2711         SDLMAIN_SOURCES="$srcdir/src/main/macosx/*.m"
  2712         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2713         SDL_LIBS="-lSDLmain $SDL_LIBS"
  2714         if test x$enable_video_cocoa = xyes; then
  2715             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  2716             need_iokit_framework=yes
  2717         fi
  2718         if test x$enable_video_carbon = xyes -o x$enable_video_cocoa = xyes; then
  2719             # The Cocoa backend still needs Carbon
  2720             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ApplicationServices"
  2721             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  2722         fi
  2723         # If either the audio or CD driver is used, add the AudioUnit framework
  2724         if test x$enable_audio = xyes -o x$enable_cdrom = xyes; then
  2725             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
  2726         fi
  2727         # Some subsystems reference IOKit...
  2728         if test x$need_iokit_framework = xyes; then
  2729             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  2730         fi
  2731         ;;
  2732     *-*-mint*)
  2733         ARCH=mint
  2734         CheckDummyVideo
  2735         CheckDiskAudio
  2736         CheckDummyAudio
  2737         CheckAtariBiosEvent
  2738         CheckAtariXbiosVideo
  2739         CheckAtariGemVideo
  2740         CheckAtariAudio
  2741         CheckAtariLdg
  2742         CheckAtariOSMesa
  2743         CheckPTH
  2744         # Set up files for the audio library
  2745         if test x$enable_threads = xyes -a x$enable_pth = xyes; then
  2746             if test x$enable_audio = xyes; then
  2747                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
  2748                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2749                 have_audio=yes
  2750             fi
  2751         fi
  2752         # Set up files for the joystick library
  2753         if test x$enable_joystick = xyes; then
  2754             AC_DEFINE(SDL_JOYSTICK_MINT)
  2755             SOURCES="$SOURCES $srcdir/src/joystick/mint/*.c"
  2756             have_joystick=yes
  2757         fi
  2758         # Set up files for the cdrom library
  2759         if test x$enable_cdrom = xyes; then
  2760             AC_DEFINE(SDL_CDROM_MINT)
  2761             SOURCES="$SOURCES $srcdir/src/cdrom/mint/*.c"
  2762             have_cdrom=yes
  2763         fi
  2764         # Set up files for the timer library
  2765         if test x$enable_timers = xyes; then
  2766             if test x$enable_threads = xyes -a x$enable_pth = xyes; then
  2767                 AC_DEFINE(SDL_TIMER_UNIX)
  2768                 SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2769             else
  2770                 AC_DEFINE(SDL_TIMER_MINT)
  2771                 SOURCES="$SOURCES $srcdir/src/timer/mint/*.c"
  2772                 SOURCES="$SOURCES $srcdir/src/timer/mint/*.S"
  2773             fi
  2774             have_timers=yes
  2775         fi
  2776         ;;
  2777     *-riscos)
  2778         ARCH=riscos
  2779         CheckOSS
  2780         CheckPTHREAD
  2781         # Set up files for the video library
  2782         if test x$enable_video = xyes; then
  2783             AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
  2784             SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
  2785             SOURCES="$SOURCES $srcdir/src/video/riscos/*.S"
  2786             have_video=yes
  2787         fi
  2788         # Set up files for the joystick library
  2789         if test x$enable_joystick = xyes; then
  2790             AC_DEFINE(SDL_JOYSTICK_RISCOS)
  2791             SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
  2792             have_joystick=yes
  2793         fi
  2794         # Set up files for the timer library
  2795         if test x$enable_timers = xyes; then
  2796             AC_DEFINE(SDL_TIMER_RISCOS)
  2797             SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
  2798             have_timers=yes
  2799         fi
  2800         # The RISC OS platform requires special setup.
  2801         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
  2802         ;;
  2803     *)
  2804         AC_MSG_ERROR([
  2805 *** Unsupported host:  Please add to configure.in
  2806         ])
  2807         ;;
  2808 esac
  2809 
  2810 dnl Do this on all platforms, after everything else.
  2811 CheckWarnAll
  2812 
  2813 # Verify that we have all the platform specific files we need
  2814 
  2815 if test x$enable_joystick = xyes; then
  2816   if test x$have_joystick != xyes; then
  2817     # Wants joystick subsystem, but doesn't have a platform-specific backend...
  2818     AC_DEFINE(SDL_JOYSTICK_DUMMY)
  2819     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2820   fi
  2821 fi
  2822 if test x$have_cdrom != xyes; then
  2823     if test x$enable_cdrom = xyes; then
  2824         AC_DEFINE(SDL_CDROM_DISABLED)
  2825     fi
  2826     SOURCES="$SOURCES $srcdir/src/cdrom/dummy/*.c"
  2827 fi
  2828 if test x$have_threads != xyes; then
  2829     if test x$enable_threads = xyes; then
  2830         AC_DEFINE(SDL_THREADS_DISABLED)
  2831     fi
  2832     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  2833 fi
  2834 if test x$have_timers != xyes; then
  2835     if test x$enable_timers = xyes; then
  2836         AC_DEFINE(SDL_TIMERS_DISABLED)
  2837     fi
  2838     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  2839 fi
  2840 if test x$have_loadso != xyes; then
  2841     if test x$enable_loadso = xyes; then
  2842         AC_DEFINE(SDL_LOADSO_DISABLED)
  2843     fi
  2844     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  2845 fi
  2846 if test x$SDLMAIN_SOURCES = x; then
  2847     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  2848 fi
  2849 
  2850 OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.asm,$(objects)/\1.lo,g'`
  2851 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
  2852 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
  2853 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
  2854 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'`
  2855 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  2856 
  2857 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.o,g'`
  2858 SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.o,g'`
  2859 SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2860 
  2861 # Set runtime shared library paths as needed
  2862 
  2863 if test "x$enable_rpath" = "xyes"; then
  2864   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
  2865     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  2866   fi
  2867   if test $ARCH = solaris; then
  2868     SDL_RLD_FLAGS="-R\${libdir}"
  2869   fi
  2870 else
  2871   SDL_RLD_FLAGS=""
  2872 fi
  2873 
  2874 case "$ARCH" in
  2875   macosx)
  2876     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  2877       SDL_LIBS="$SDL_LIBS -Wl,-framework,Cocoa"
  2878     fi
  2879     if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
  2880       SDL_LIBS="$SDL_LIBS -Wl,-framework,Carbon"
  2881     fi
  2882     # Evil hack to allow static linking on Mac OS X
  2883     SDL_STATIC_LIBS="\${libdir}/libSDLmain.a \${libdir}/libSDL.a $EXTRA_LDFLAGS"
  2884     ;;
  2885   *)
  2886     SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  2887     ;;
  2888 esac
  2889 
  2890 dnl Expand the cflags and libraries needed by apps using SDL
  2891 AC_SUBST(SDL_CFLAGS)
  2892 AC_SUBST(SDL_LIBS)
  2893 AC_SUBST(SDL_STATIC_LIBS)
  2894 AC_SUBST(SDL_RLD_FLAGS)
  2895 if test x$enable_shared = xyes; then
  2896     ENABLE_SHARED_TRUE=
  2897     ENABLE_SHARED_FALSE="#"
  2898 else
  2899     ENABLE_SHARED_TRUE="#"
  2900     ENABLE_SHARED_FALSE=
  2901 fi
  2902 if test x$enable_static = xyes; then
  2903     ENABLE_STATIC_TRUE=
  2904     ENABLE_STATIC_FALSE="#"
  2905 else
  2906     ENABLE_STATIC_TRUE="#"
  2907     ENABLE_STATIC_FALSE=
  2908 fi
  2909 AC_SUBST(ENABLE_SHARED_TRUE)
  2910 AC_SUBST(ENABLE_SHARED_FALSE)
  2911 AC_SUBST(ENABLE_STATIC_TRUE)
  2912 AC_SUBST(ENABLE_STATIC_FALSE)
  2913 
  2914 dnl Expand the sources and objects needed to build the library
  2915 AC_SUBST(ac_aux_dir)
  2916 AC_SUBST(INCLUDE)
  2917 AC_SUBST(SOURCES)
  2918 AC_SUBST(OBJECTS)
  2919 AC_SUBST(SDLMAIN_SOURCES)
  2920 AC_SUBST(SDLMAIN_OBJECTS)
  2921 AC_SUBST(BUILD_CFLAGS)
  2922 AC_SUBST(EXTRA_CFLAGS)
  2923 AC_SUBST(BUILD_LDFLAGS)
  2924 AC_SUBST(EXTRA_LDFLAGS)
  2925 AC_SUBST(WINDRES)
  2926 
  2927 AC_OUTPUT([
  2928     Makefile sdl-config SDL.spec SDL.qpg sdl.pc
  2929 ], [
  2930     : >build-deps
  2931     if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
  2932 ])