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