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