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