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