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