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