configure.in
author Sam Lantinga <slouken@libsdl.org>
Thu, 27 Jan 2011 14:54:20 -0800
changeset 5112 39772ccf7ddd
parent 5103 797b37c0c046
child 5137 e594f07297a9
permissions -rw-r--r--
This patch fixes the issue of configure generating broken Makefile
when .cc files are used due to bad sed substitution on multiple passes:
$(objects)/SDL_BeApp.lo:
$(objects)/SDL_BeApp.lo: ./src/main/beos/SDL_BeApp.c
$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@c
$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@

Signed-off-by: Fran├žois Revol
     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             AC_ARG_ENABLE(render-x11,
  1326 AC_HELP_STRING([--enable-render-x11], [enable the X11 render driver [[default=yes]]]),
  1327                                 , enable_render_x11=yes)
  1328             if test x$enable_render_x11 = xyes; then
  1329                 AC_DEFINE(SDL_VIDEO_RENDER_X11)
  1330             fi
  1331         fi
  1332     fi
  1333 }
  1334 
  1335 dnl Check for QNX photon video driver
  1336 CheckPHOTON()
  1337 {
  1338     AC_ARG_ENABLE(video-photon,
  1339 AC_HELP_STRING([--enable-video-photon], [use QNX Photon video driver [[default=yes]]]),
  1340                   , enable_video_photon=yes)
  1341     if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
  1342         AC_MSG_CHECKING(for QNX Photon support)
  1343         video_photon=no
  1344         AC_TRY_COMPILE([
  1345           #include <Ph.h>
  1346           #include <Pt.h>
  1347           #include <photon/Pg.h>
  1348           #include <photon/PdDirect.h>
  1349         ],[
  1350          PgDisplaySettings_t *visual;
  1351         ],[
  1352         video_photon=yes
  1353         ])
  1354         AC_MSG_RESULT($video_photon)
  1355         if test x$video_photon = xyes; then
  1356             AC_DEFINE(SDL_VIDEO_DRIVER_PHOTON)
  1357             SOURCES="$SOURCES $srcdir/src/video/photon/*.c"
  1358             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lph -lphrender"
  1359             have_video=yes
  1360 
  1361             CheckOpenGLQNX
  1362         fi
  1363     fi
  1364 }
  1365 
  1366 dnl Check for QNX photon video driver
  1367 CheckQNXGF()
  1368 {
  1369     AC_ARG_ENABLE(video-qnxgf,
  1370                   AC_HELP_STRING([--enable-video-qnxgf], [use QNX GF video driver [[default=yes]]]),
  1371                   , enable_video_qnxgf=yes)
  1372     if test x$enable_video = xyes -a x$enable_video_qnxgf = xyes; then
  1373         AC_MSG_CHECKING(for QNX GF support)
  1374         video_qnxgf=no
  1375         AC_TRY_COMPILE([
  1376           #include <gf/gf.h>
  1377           #include <gf/gf3d.h>
  1378         ],[
  1379          gf_3d_config_info_t* gfinfo;
  1380         ],[
  1381         video_qnxgf=yes
  1382         ])
  1383         AC_MSG_RESULT($video_qnxgf)
  1384         if test x$video_qnxgf = xyes; then
  1385             AC_DEFINE(SDL_VIDEO_DRIVER_QNXGF)
  1386             SOURCES="$SOURCES $srcdir/src/video/qnxgf/*.c"
  1387             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lgf"
  1388 
  1389             # Add HIDDI library for HID support using GF
  1390             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lhiddi"
  1391 
  1392             have_video=yes
  1393 
  1394             CheckOpenGLESQNX
  1395         fi
  1396     fi
  1397 }
  1398 
  1399 dnl Set up the BWindow video driver if enabled
  1400 CheckBWINDOW()
  1401 {
  1402     if test x$enable_video = xyes; then
  1403         AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW)
  1404         SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
  1405         have_video=yes
  1406     fi
  1407 }
  1408 
  1409 dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
  1410 CheckCOCOA()
  1411 {
  1412     AC_ARG_ENABLE(video-cocoa,
  1413 AC_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
  1414                   , enable_video_cocoa=yes)
  1415     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  1416         save_CFLAGS="$CFLAGS"
  1417         dnl work around that we don't have Objective-C support in autoconf
  1418         CFLAGS="$CFLAGS -x objective-c"
  1419         AC_MSG_CHECKING(for Cocoa framework)
  1420         have_cocoa=no
  1421         AC_TRY_COMPILE([
  1422           #import <Cocoa/Cocoa.h>
  1423         ],[
  1424         ],[
  1425         have_cocoa=yes
  1426         ])
  1427         AC_MSG_RESULT($have_cocoa)
  1428         CFLAGS="$save_CFLAGS"
  1429         if test x$have_cocoa = xyes; then
  1430             AC_DEFINE(SDL_VIDEO_DRIVER_COCOA)
  1431             SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
  1432             have_video=yes
  1433         fi
  1434     fi
  1435 }
  1436 
  1437 dnl Find DirectFB
  1438 CheckDirectFB()
  1439 {
  1440     AC_ARG_ENABLE(video-directfb,
  1441 AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
  1442                   , enable_video_directfb=no)
  1443     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  1444         video_directfb=no
  1445 
  1446         DIRECTFB_REQUIRED_VERSION=1.0.0
  1447 
  1448         AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
  1449         if test x$DIRECTFBCONFIG = xno; then
  1450             AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1451             if test x$PKG_CONFIG != xno; then
  1452                 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
  1453                     DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
  1454                     DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
  1455                     DIRECTFB_PREFIX=`$PKG_CONFIG --variable=prefix directfb`
  1456                     video_directfb=yes
  1457                 fi
  1458             fi
  1459         else
  1460             set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
  1461             NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1462             set -- `directfb-config --version | sed 's/\./ /g'`
  1463             HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
  1464             if test $HAVE_VERSION -ge $NEED_VERSION; then
  1465                 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
  1466                 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
  1467                 DIRECTFB_PREFIX=`$DIRECTFBCONFIG --prefix`
  1468                 video_directfb=yes
  1469             fi
  1470         fi
  1471         if test x$video_directfb = xyes; then
  1472             # SuSE 11.1 installs directfb-config without directfb-devel
  1473             save_CPPFLAGS="$CPPFLAGS"
  1474             CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
  1475             AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
  1476             CPPFLAGS="$save_CPPFLAGS"
  1477             video_directfb=$have_directfb_hdr
  1478         fi
  1479         AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
  1480         AC_MSG_RESULT($video_directfb)
  1481 
  1482         if test x$video_directfb = xyes; then
  1483             AC_ARG_ENABLE(directfb-shared,
  1484 AC_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
  1485                               , enable_directfb_shared=yes)
  1486 
  1487             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
  1488             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  1489             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  1490 
  1491             AC_MSG_CHECKING(for directfb dynamic loading support)
  1492             directfb_shared=no
  1493             directfb_lib=[`find_lib "libdirectfb.so.*" "$DIRECTFB_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1494 
  1495             if test x$have_loadso != xyes && \
  1496                test x$enable_directfb_shared = xyes; then
  1497                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
  1498             fi
  1499             if test x$have_loadso = xyes && \
  1500                test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
  1501                 directfb_shared=yes
  1502                 echo "-- $directfb_lib_spec -> $directfb_lib"
  1503                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib")
  1504             else
  1505                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  1506             fi
  1507             AC_MSG_RESULT($directfb_shared)
  1508             have_video=yes
  1509         fi
  1510     fi
  1511 }
  1512 
  1513 dnl Find FusionSound
  1514 CheckFusionSound()
  1515 {
  1516     AC_ARG_ENABLE(fusionsound,
  1517 AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
  1518                   , enable_fusionsound=no)
  1519     if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
  1520         fusionsound=no
  1521 
  1522         FUSIONSOUND_REQUIRED_VERSION=1.1.1
  1523 
  1524         AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
  1525         AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
  1526         if test x$PKG_CONFIG != xno; then
  1527             if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
  1528                 FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
  1529                 FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
  1530                 fusionsound=yes
  1531             fi
  1532         fi
  1533         AC_MSG_RESULT($fusionsound)
  1534 
  1535         if test x$fusionsound = xyes; then
  1536             AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND)
  1537             SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
  1538             EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
  1539             
  1540             AC_ARG_ENABLE(fusionsound-shared,
  1541 AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
  1542                           , enable_fusionsound_shared=yes)
  1543             fusionsound_shared=no
  1544             AC_MSG_CHECKING(for FusionSound dynamic loading support)
  1545             if test x$have_loadso != xyes && \
  1546                test x$enable_fusionsound_shared = xyes; then
  1547                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
  1548             fi
  1549             if test x$have_loadso = xyes && \
  1550                test x$enable_fusionsound_shared = xyes; then
  1551                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so")
  1552                 fusionsound_shared=yes
  1553             else
  1554                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
  1555             fi
  1556             AC_MSG_RESULT($fusionsound_shared)
  1557             
  1558             have_audio=yes
  1559         fi
  1560     fi
  1561 }
  1562 
  1563 dnl rcg04172001 Set up the Null video driver.
  1564 CheckDummyVideo()
  1565 {
  1566     AC_ARG_ENABLE(video-dummy,
  1567 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  1568                   , enable_video_dummy=yes)
  1569     if test x$enable_video_dummy = xyes; then
  1570         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY)
  1571         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1572         have_video=yes
  1573     fi
  1574 }
  1575 
  1576 dnl Check to see if OpenGL support is desired
  1577 AC_ARG_ENABLE(video-opengl,
  1578 AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  1579               , enable_video_opengl=yes)
  1580 
  1581 dnl Find OpenGL
  1582 CheckOpenGLX11()
  1583 {
  1584     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1585         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1586         video_opengl=no
  1587         AC_TRY_COMPILE([
  1588          #include <GL/gl.h>
  1589          #include <GL/glx.h>
  1590         ],[
  1591         ],[
  1592         video_opengl=yes
  1593         ])
  1594         AC_MSG_RESULT($video_opengl)
  1595         if test x$video_opengl = xyes; then
  1596             AC_DEFINE(SDL_VIDEO_OPENGL)
  1597             AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
  1598             AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1599         fi
  1600     fi
  1601 }
  1602 
  1603 dnl Find QNX 6.x Software OpenGL
  1604 CheckOpenGLQNX()
  1605 {
  1606     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1607         AC_MSG_CHECKING(for QNX 6.x Photon OpenGL support)
  1608         video_opengl=no
  1609         AC_TRY_COMPILE([
  1610          #include <GL/gl.h>
  1611         ],[
  1612         ],[
  1613         video_opengl=yes
  1614         ])
  1615         AC_MSG_RESULT($video_opengl)
  1616         if test x$video_opengl = xyes; then
  1617             AC_DEFINE(SDL_VIDEO_OPENGL)
  1618             AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1619             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1620         fi
  1621     fi
  1622 }
  1623 
  1624 dnl Find QNX 6.3 and above OpenGL ES implementation
  1625 CheckOpenGLESQNX()
  1626 {
  1627     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1628         AC_MSG_CHECKING(for QNX OpenGL ES (CM) support)
  1629         video_opengl=no
  1630         AC_TRY_COMPILE([
  1631          #include <GLES/egl.h>
  1632         ],[
  1633         ],[
  1634         video_opengl=yes
  1635         ])
  1636         AC_MSG_RESULT($video_opengl)
  1637         if test x$video_opengl = xyes; then
  1638             AC_DEFINE(SDL_VIDEO_OPENGL_ES)
  1639             AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
  1640             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CM"
  1641         else
  1642             AC_MSG_CHECKING(for QNX OpenGL ES (CL) support)
  1643             video_opengl=no
  1644             AC_TRY_COMPILE([
  1645              #define COMMON_LITE
  1646              #include <GLES/egl.h>
  1647             ],[
  1648             ],[
  1649             video_opengl=yes
  1650             ])
  1651             AC_MSG_RESULT($video_opengl)
  1652             if test x$video_opengl = xyes; then
  1653                 AC_DEFINE(SDL_VIDEO_OPENGL_ES)
  1654                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
  1655                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CLS"
  1656             fi
  1657         fi
  1658     fi
  1659 }
  1660 
  1661 
  1662 dnl Check for Windows OpenGL
  1663 CheckWINDOWSGL()
  1664 {
  1665     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1666         AC_DEFINE(SDL_VIDEO_OPENGL)
  1667         AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
  1668         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1669     fi
  1670 }
  1671 
  1672 dnl Check for BeOS OpenGL
  1673 CheckBeGL()
  1674 {
  1675     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1676         AC_DEFINE(SDL_VIDEO_OPENGL)
  1677         AC_DEFINE(SDL_VIDEO_OPENGL_BGL)
  1678         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1679         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1680     fi
  1681 }
  1682 
  1683 dnl Check for MacOS OpenGL
  1684 CheckMacGL()
  1685 {
  1686     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1687         AC_DEFINE(SDL_VIDEO_OPENGL)
  1688         AC_DEFINE(SDL_VIDEO_OPENGL_CGL)
  1689         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1690         case "$host" in
  1691             *-*-darwin*)
  1692                 if test x$enable_video_cocoa = xyes; then
  1693                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
  1694                 fi
  1695         esac
  1696     fi
  1697 }
  1698 
  1699 dnl See if we can use the new unified event interface in Linux 2.4
  1700 CheckInputEvents()
  1701 {
  1702     dnl Check for Linux 2.4 unified input event interface support
  1703     AC_ARG_ENABLE(input-events,
  1704 AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [[default=yes]]]),
  1705                   , enable_input_events=yes)
  1706     if test x$enable_input_events = xyes; then
  1707         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  1708         use_input_events=no
  1709         AC_TRY_COMPILE([
  1710           #include <linux/input.h>
  1711         ],[
  1712           #ifndef EVIOCGNAME
  1713           #error EVIOCGNAME() ioctl not available
  1714           #endif
  1715         ],[
  1716         use_input_events=yes
  1717         ])
  1718         AC_MSG_RESULT($use_input_events)
  1719         if test x$use_input_events = xyes; then
  1720             AC_DEFINE(SDL_INPUT_LINUXEV)
  1721         fi
  1722     fi
  1723 }
  1724 
  1725 dnl See if we can use the Touchscreen input library
  1726 CheckTslib()
  1727 {
  1728     AC_ARG_ENABLE(input-tslib,
  1729 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  1730                   , enable_input_tslib=yes)
  1731     if test x$enable_input_tslib = xyes; then
  1732         AC_MSG_CHECKING(for Touchscreen library support)
  1733         enable_input_tslib=no
  1734         AC_TRY_COMPILE([
  1735           #include "tslib.h"
  1736         ],[
  1737         ],[
  1738         enable_input_tslib=yes
  1739         ])
  1740         AC_MSG_RESULT($enable_input_tslib)
  1741         if test x$enable_input_tslib = xyes; then
  1742             AC_DEFINE(SDL_INPUT_TSLIB)
  1743             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  1744         fi
  1745     fi
  1746 }
  1747 
  1748 dnl See what type of thread model to use on Linux and Solaris
  1749 CheckPTHREAD()
  1750 {
  1751     dnl Check for pthread support
  1752     AC_ARG_ENABLE(pthreads,
  1753 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  1754                   , enable_pthreads=yes)
  1755     dnl This is used on Linux for glibc binary compatibility (Doh!)
  1756     AC_ARG_ENABLE(pthread-sem,
  1757 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  1758                   , enable_pthread_sem=yes)
  1759     case "$host" in
  1760         *-*-linux*|*-*-uclinux*)
  1761             pthread_cflags="-D_REENTRANT"
  1762             pthread_lib="-lpthread"
  1763             ;;
  1764         *-*-bsdi*)
  1765             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1766             pthread_lib=""
  1767             ;;
  1768         *-*-darwin*)
  1769             pthread_cflags="-D_THREAD_SAFE"
  1770 # causes Carbon.p complaints?
  1771 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1772             ;;
  1773         *-*-freebsd*|*-*-dragonfly*)
  1774             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1775             pthread_lib="-pthread"
  1776             ;;
  1777         *-*-netbsd*)
  1778             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1779             pthread_lib="-lpthread"
  1780             ;;
  1781         *-*-openbsd*)
  1782             pthread_cflags="-D_REENTRANT"
  1783             pthread_lib="-pthread"
  1784             ;;
  1785         *-*-solaris*)
  1786             pthread_cflags="-D_REENTRANT"
  1787             pthread_lib="-lpthread -lposix4"
  1788             ;;
  1789         *-*-sysv5*)
  1790             pthread_cflags="-D_REENTRANT -Kthread"
  1791             pthread_lib=""
  1792             ;;
  1793         *-*-irix*)
  1794             pthread_cflags="-D_SGI_MP_SOURCE"
  1795             pthread_lib="-lpthread"
  1796             ;;
  1797         *-*-aix*)
  1798             pthread_cflags="-D_REENTRANT -mthreads"
  1799             pthread_lib="-lpthread"
  1800             ;;
  1801         *-*-hpux11*)
  1802             pthread_cflags="-D_REENTRANT"
  1803             pthread_lib="-L/usr/lib -lpthread"
  1804             ;;
  1805         *-*-qnx*)
  1806             pthread_cflags=""
  1807             pthread_lib=""
  1808             ;;
  1809         *-*-osf*)
  1810             pthread_cflags="-D_REENTRANT"
  1811             if test x$ac_cv_prog_gcc = xyes; then
  1812                 pthread_lib="-lpthread -lrt"
  1813             else
  1814                 pthread_lib="-lpthread -lexc -lrt"
  1815             fi
  1816             ;;
  1817         *)
  1818             pthread_cflags="-D_REENTRANT"
  1819             pthread_lib="-lpthread"
  1820             ;;
  1821     esac
  1822     if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
  1823         # Save the original compiler flags and libraries
  1824         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1825         # Add the pthread compiler flags and libraries
  1826         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1827         # Check to see if we have pthread support on this system
  1828         AC_MSG_CHECKING(for pthreads)
  1829         use_pthreads=no
  1830         AC_TRY_LINK([
  1831          #include <pthread.h>
  1832         ],[
  1833          pthread_attr_t type;
  1834          pthread_attr_init(&type);
  1835         ],[
  1836         use_pthreads=yes
  1837         ])
  1838         AC_MSG_RESULT($use_pthreads)
  1839         # Restore the compiler flags and libraries
  1840         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1841 
  1842         # Do futher testing if we have pthread support...
  1843         if test x$use_pthreads = xyes; then
  1844             AC_DEFINE(SDL_THREAD_PTHREAD)
  1845             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  1846             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  1847             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  1848             SDL_LIBS="$SDL_LIBS $pthread_lib"
  1849 
  1850             # Save the original compiler flags and libraries
  1851             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1852             # Add the pthread compiler flags and libraries
  1853             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1854 
  1855             # Check to see if recursive mutexes are available
  1856             AC_MSG_CHECKING(for recursive mutexes)
  1857             has_recursive_mutexes=no
  1858             if test x$has_recursive_mutexes = xno; then
  1859                 AC_TRY_COMPILE([
  1860                   #include <pthread.h>
  1861                 ],[
  1862                   pthread_mutexattr_t attr;
  1863                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  1864                 ],[
  1865                 has_recursive_mutexes=yes
  1866                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX)
  1867                 ])
  1868             fi
  1869             if test x$has_recursive_mutexes = xno; then
  1870                 AC_TRY_COMPILE([
  1871                   #include <pthread.h>
  1872                 ],[
  1873                   pthread_mutexattr_t attr;
  1874                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  1875                 ],[
  1876                 has_recursive_mutexes=yes
  1877                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)
  1878                 ])
  1879             fi
  1880             AC_MSG_RESULT($has_recursive_mutexes)
  1881 
  1882             # Check to see if pthread semaphore support is missing
  1883             if test x$enable_pthread_sem = xyes; then
  1884                 AC_MSG_CHECKING(for pthread semaphores)
  1885                 have_pthread_sem=no
  1886                 AC_TRY_COMPILE([
  1887                   #include <pthread.h>
  1888                   #include <semaphore.h>
  1889                 ],[
  1890                 ],[
  1891                 have_pthread_sem=yes
  1892                 ])
  1893                 AC_MSG_RESULT($have_pthread_sem)
  1894             fi
  1895 
  1896             # Restore the compiler flags and libraries
  1897             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1898 
  1899             # Basic thread creation functions
  1900             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  1901 
  1902             # Semaphores
  1903             # We can fake these with mutexes and condition variables if necessary
  1904             if test x$have_pthread_sem = xyes; then
  1905                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  1906             else
  1907                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1908             fi
  1909 
  1910             # Mutexes
  1911             # We can fake these with semaphores if necessary
  1912             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  1913 
  1914             # Condition variables
  1915             # We can fake these with semaphores and mutexes if necessary
  1916             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  1917 
  1918             have_threads=yes
  1919         fi
  1920     fi
  1921 }
  1922 
  1923 dnl Determine whether the compiler can produce Windows executables
  1924 CheckWINDOWS()
  1925 {
  1926     AC_MSG_CHECKING(Windows compiler)
  1927     have_win32_gcc=no
  1928     AC_TRY_COMPILE([
  1929      #include <windows.h>
  1930     ],[
  1931     ],[
  1932     have_win32_gcc=yes
  1933     ])
  1934     AC_MSG_RESULT($have_win32_gcc)
  1935     if test x$have_win32_gcc != xyes; then
  1936        AC_MSG_ERROR([
  1937 *** Your compiler ($CC) does not produce Windows executables!
  1938        ])
  1939     fi
  1940 
  1941     AC_MSG_CHECKING(Windows CE)
  1942     have_wince=no
  1943     AC_TRY_COMPILE([
  1944 #if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
  1945 #error This is not Windows CE
  1946 #endif
  1947     ],[
  1948     ],[
  1949     have_wince=yes
  1950     ])
  1951     AC_MSG_RESULT($have_wince)
  1952 
  1953     dnl See if the user wants to redirect standard output to files
  1954     AC_ARG_ENABLE(stdio-redirect,
  1955 AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Windows [[default=yes]]]),
  1956                   , enable_stdio_redirect=yes)
  1957     if test x$enable_stdio_redirect != xyes; then
  1958         EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
  1959     fi
  1960 }
  1961 
  1962 dnl Find the DirectX includes and libraries
  1963 CheckDIRECTX()
  1964 {
  1965     AC_ARG_ENABLE(directx,
  1966 AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
  1967                   , enable_directx=yes)
  1968     if test x$enable_directx = xyes; then
  1969         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  1970         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  1971         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  1972         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  1973     fi
  1974 }
  1975 
  1976 dnl Check for the dlfcn.h interface for dynamically loading objects
  1977 CheckDLOPEN()
  1978 {
  1979     AC_ARG_ENABLE(sdl-dlopen,
  1980 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  1981                   , enable_sdl_dlopen=yes)
  1982     if test x$enable_sdl_dlopen = xyes; then
  1983         AC_MSG_CHECKING(for dlopen)
  1984         have_dlopen=no
  1985         AC_TRY_COMPILE([
  1986          #include <dlfcn.h>
  1987         ],[
  1988          #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
  1989          #error Use dlcompat for Mac OS X 10.2 compatibility
  1990          #endif
  1991         ],[
  1992         have_dlopen=yes
  1993         ])
  1994         AC_MSG_RESULT($have_dlopen)
  1995 
  1996         if test x$have_dlopen = xyes; then
  1997             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  1998                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  1999                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  2000             AC_DEFINE(SDL_LOADSO_DLOPEN)
  2001             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  2002             have_loadso=yes
  2003         fi
  2004     fi
  2005 }
  2006 
  2007 dnl Check for the usbhid(3) library on *BSD
  2008 CheckUSBHID()
  2009 {
  2010     if test x$enable_joystick = xyes; then
  2011         AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  2012         if test x$have_libusbhid = xyes; then
  2013             AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  2014             AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  2015             USB_LIBS="$USB_LIBS -lusbhid"
  2016         else
  2017             AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  2018             AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  2019             AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  2020         fi
  2021             
  2022         save_CFLAGS="$CFLAGS"
  2023         CFLAGS="$CFLAGS $USB_CFLAGS"
  2024 
  2025         AC_MSG_CHECKING(for usbhid)
  2026         have_usbhid=no
  2027         AC_TRY_COMPILE([
  2028           #include <sys/types.h>
  2029           #if defined(HAVE_USB_H)
  2030           #include <usb.h>
  2031           #endif
  2032           #ifdef __DragonFly__
  2033           # include <bus/usb/usb.h>
  2034           # include <bus/usb/usbhid.h>
  2035           #else
  2036           # include <dev/usb/usb.h>
  2037           # include <dev/usb/usbhid.h>
  2038           #endif
  2039           #if defined(HAVE_USBHID_H)
  2040           #include <usbhid.h>
  2041           #elif defined(HAVE_LIBUSB_H)
  2042           #include <libusb.h>
  2043           #elif defined(HAVE_LIBUSBHID_H)
  2044           #include <libusbhid.h>
  2045           #endif
  2046         ],[
  2047           struct report_desc *repdesc;
  2048           struct usb_ctl_report *repbuf;
  2049           hid_kind_t hidkind;
  2050         ],[
  2051         have_usbhid=yes
  2052         ])
  2053         AC_MSG_RESULT($have_usbhid)
  2054 
  2055         if test x$have_usbhid = xyes; then
  2056             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  2057             have_usbhid_ucr_data=no
  2058             AC_TRY_COMPILE([
  2059               #include <sys/types.h>
  2060               #if defined(HAVE_USB_H)
  2061               #include <usb.h>
  2062               #endif
  2063               #ifdef __DragonFly__
  2064               # include <bus/usb/usb.h>
  2065               # include <bus/usb/usbhid.h>
  2066               #else
  2067               # include <dev/usb/usb.h>
  2068               # include <dev/usb/usbhid.h>
  2069               #endif
  2070               #if defined(HAVE_USBHID_H)
  2071               #include <usbhid.h>
  2072               #elif defined(HAVE_LIBUSB_H)
  2073               #include <libusb.h>
  2074               #elif defined(HAVE_LIBUSBHID_H)
  2075               #include <libusbhid.h>
  2076               #endif
  2077             ],[
  2078               struct usb_ctl_report buf;
  2079               if (buf.ucr_data) { }
  2080             ],[
  2081             have_usbhid_ucr_data=yes
  2082             ])
  2083             if test x$have_usbhid_ucr_data = xyes; then
  2084                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  2085             fi
  2086             AC_MSG_RESULT($have_usbhid_ucr_data)
  2087             
  2088             AC_MSG_CHECKING(for new usbhid API)
  2089             have_usbhid_new=no
  2090             AC_TRY_COMPILE([
  2091               #include <sys/types.h>
  2092               #if defined(HAVE_USB_H)
  2093               #include <usb.h>
  2094               #endif
  2095               #ifdef __DragonFly__
  2096               #include <bus/usb/usb.h>
  2097               #include <bus/usb/usbhid.h>
  2098               #else
  2099               #include <dev/usb/usb.h>
  2100               #include <dev/usb/usbhid.h>
  2101               #endif
  2102               #if defined(HAVE_USBHID_H)
  2103               #include <usbhid.h>
  2104               #elif defined(HAVE_LIBUSB_H)
  2105               #include <libusb.h>
  2106               #elif defined(HAVE_LIBUSBHID_H)
  2107               #include <libusbhid.h>
  2108               #endif
  2109             ],[
  2110               report_desc_t d;
  2111               hid_start_parse(d, 1, 1);
  2112             ],[
  2113             have_usbhid_new=yes
  2114             ])
  2115             if test x$have_usbhid_new = xyes; then
  2116                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  2117             fi
  2118             AC_MSG_RESULT($have_usbhid_new)
  2119 
  2120             AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  2121             have_machine_joystick=no
  2122             AC_TRY_COMPILE([
  2123               #include <machine/joystick.h>
  2124             ],[
  2125               struct joystick t;
  2126             ],[
  2127             have_machine_joystick=yes
  2128             ])
  2129             if test x$have_machine_joystick = xyes; then
  2130                 AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H)
  2131             fi
  2132             AC_MSG_RESULT($have_machine_joystick)
  2133 
  2134             AC_DEFINE(SDL_JOYSTICK_USBHID)
  2135             SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  2136             EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  2137             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  2138             have_joystick=yes
  2139         fi
  2140         CFLAGS="$save_CFLAGS"
  2141     fi
  2142 }
  2143 
  2144 dnl Check for clock_gettime()
  2145 CheckClockGettime()
  2146 {
  2147     AC_ARG_ENABLE(clock_gettime,
  2148 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=no]]]),
  2149                   , enable_clock_gettime=no)
  2150     if test x$enable_clock_gettime = xyes; then
  2151         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  2152         if test x$have_clock_gettime = xyes; then
  2153             AC_DEFINE(HAVE_CLOCK_GETTIME)
  2154             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  2155         else
  2156             AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
  2157             if test x$have_clock_gettime = xyes; then
  2158                AC_DEFINE(HAVE_CLOCK_GETTIME)
  2159                EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
  2160             fi
  2161         fi
  2162     fi
  2163 }
  2164 
  2165 dnl Check for a valid linux/version.h
  2166 CheckLinuxVersion()
  2167 {
  2168     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  2169     if test x$have_linux_version_h = xyes; then
  2170         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  2171     fi
  2172 }
  2173 
  2174 dnl Check if we want to use RPATH
  2175 CheckRPATH()
  2176 {
  2177     AC_ARG_ENABLE(rpath,
  2178 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  2179                   , enable_rpath=yes)
  2180 }
  2181 
  2182 dnl Set up the configuration based on the host platform!
  2183 case "$host" in
  2184     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*|*-*-minix*)
  2185         case "$host" in
  2186             *-*-linux*)         ARCH=linux ;;
  2187             *-*-uclinux*)       ARCH=linux ;;
  2188             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  2189             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  2190             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  2191             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  2192             *-*-bsdi*)          ARCH=bsdi ;;
  2193             *-*-freebsd*)       ARCH=freebsd ;;
  2194             *-*-dragonfly*)     ARCH=freebsd ;;
  2195             *-*-netbsd*)        ARCH=netbsd ;;
  2196             *-*-openbsd*)       ARCH=openbsd ;;
  2197             *-*-sysv5*)         ARCH=sysv5 ;;
  2198             *-*-solaris*)       ARCH=solaris ;;
  2199             *-*-hpux*)          ARCH=hpux ;;
  2200             *-*-irix*)          ARCH=irix ;;
  2201             *-*-aix*)           ARCH=aix ;;
  2202             *-*-osf*)           ARCH=osf ;;
  2203             *-*-minix*)         ARCH=minix ;;
  2204         esac
  2205         CheckVisibilityHidden
  2206         CheckDummyVideo
  2207         CheckDiskAudio
  2208         CheckDummyAudio
  2209         CheckDLOPEN
  2210         CheckOSS
  2211         CheckDMEDIA
  2212         CheckMME
  2213         CheckALSA
  2214         CheckPulseAudio
  2215         CheckARTSC
  2216         CheckESD
  2217         CheckNAS
  2218         CheckX11
  2219         CheckDirectFB
  2220         CheckFusionSound
  2221         CheckOpenGLX11
  2222         CheckInputEvents
  2223         CheckTslib
  2224         CheckUSBHID
  2225         CheckPTHREAD
  2226         CheckClockGettime
  2227         CheckLinuxVersion
  2228         CheckRPATH
  2229         # Set up files for the audio library
  2230         if test x$enable_audio = xyes; then
  2231           case $ARCH in
  2232             sysv5|solaris|hpux)
  2233                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
  2234                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2235                 have_audio=yes
  2236             ;;
  2237             netbsd|openbsd)
  2238                 AC_DEFINE(SDL_AUDIO_DRIVER_BSD)
  2239                 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
  2240                 have_audio=yes
  2241             ;;
  2242             aix)
  2243                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO)
  2244                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  2245                 have_audio=yes
  2246             ;;
  2247           esac
  2248         fi
  2249         # Set up files for the joystick library
  2250         if test x$enable_joystick = xyes; then
  2251           case $ARCH in
  2252             linux)
  2253                 AC_DEFINE(SDL_JOYSTICK_LINUX)
  2254                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  2255                 have_joystick=yes
  2256             ;;
  2257           esac
  2258         fi
  2259         # Set up files for the haptic library
  2260         if test x$enable_haptic = xyes; then
  2261            if test x$use_input_events = xyes; then
  2262              case $ARCH in
  2263                linux)
  2264                    AC_DEFINE(SDL_HAPTIC_LINUX)
  2265                    SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  2266                    have_haptic=yes
  2267                ;;
  2268              esac
  2269            fi
  2270         fi
  2271         # Set up files for the power library
  2272         if test x$enable_power = xyes; then
  2273              case $ARCH in
  2274                linux)
  2275                    AC_DEFINE(SDL_POWER_LINUX)
  2276                    SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
  2277                    have_power=yes
  2278                ;;
  2279              esac
  2280         fi
  2281         # Set up files for the thread library
  2282         if test x$enable_threads = xyes -a x$use_pthreads != xyes -a x$use_pth != xyes -a x$ARCH = xirix; then
  2283             AC_DEFINE(SDL_THREAD_SPROC)
  2284             SOURCES="$SOURCES $srcdir/src/thread/irix/*.c"
  2285             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2286             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2287             have_threads=yes
  2288         fi
  2289         # Set up files for the timer library
  2290         if test x$enable_timers = xyes; then
  2291             AC_DEFINE(SDL_TIMER_UNIX)
  2292             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2293             have_timers=yes
  2294         fi
  2295         ;;
  2296     *-*-qnx*)
  2297 
  2298         EXTRA_CFLAGS="-I/usr/include $CFLAGS"
  2299         EXTRA_LDLAGS="-L/usr/lib $LDFLAGS"
  2300 
  2301         ARCH=qnx
  2302         CheckVisibilityHidden
  2303         CheckDummyVideo
  2304         CheckDiskAudio
  2305         CheckDummyAudio
  2306         CheckDLOPEN
  2307         CheckPulseAudio
  2308         CheckESD
  2309         CheckNAS
  2310         CheckPHOTON
  2311         CheckQNXGF
  2312         CheckX11
  2313         CheckOpenGLX11
  2314         CheckPTHREAD
  2315         CheckClockGettime
  2316 
  2317 
  2318         # Set up files for the audio library
  2319         if test x$enable_audio = xyes; then
  2320             AC_DEFINE(SDL_AUDIO_DRIVER_QSA)
  2321             SOURCES="$SOURCES $srcdir/src/audio/qsa/*.c"
  2322             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
  2323             have_audio=yes
  2324         fi
  2325         # Set up files for the timer library
  2326         if test x$enable_timers = xyes; then
  2327             AC_DEFINE(SDL_TIMER_UNIX)
  2328             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2329             have_timers=yes
  2330         fi
  2331         # Set up dummy files for the joystick for now
  2332         if test x$enable_joystick = xyes; then
  2333             AC_DEFINE(SDL_JOYSTICK_DUMMY)
  2334             SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2335             have_joystick=yes
  2336         fi
  2337         # Set up dummy files for the haptic for now
  2338         if test x$enable_haptic = xyes; then
  2339             AC_DEFINE(SDL_HAPTIC_DUMMY)
  2340             SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2341             have_haptic=yes
  2342         fi
  2343         ;;
  2344     *-wince* | *-mingw32ce)
  2345         ARCH=win32
  2346         CheckDummyVideo
  2347         CheckDiskAudio
  2348         CheckDummyAudio
  2349         CheckWINDOWS
  2350         if test x$enable_video = xyes; then
  2351             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
  2352             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
  2353             have_video=yes
  2354             AC_ARG_ENABLE(render-gdi,
  2355 AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
  2356                                 , enable_render_gdi=yes)
  2357             if test x$enable_render_gdi = xyes; then
  2358                 AC_DEFINE(SDL_VIDEO_RENDER_GDI)
  2359             fi
  2360             AC_ARG_ENABLE(render-gapi,
  2361 AC_HELP_STRING([--enable-render-gapi], [enable the GAPI/RAWFRAMEBUFFER render driver [[default=yes]]]),
  2362                                 , enable_render_gapi=yes)
  2363             if test x$enable_render_gapi = xyes -a x$have_wince = xyes; then
  2364                 AC_DEFINE(SDL_VIDEO_RENDER_GAPI)
  2365             fi
  2366             AC_ARG_ENABLE(render-ddraw,
  2367 AC_HELP_STRING([--enable-render-ddraw], [enable the Mobile DirectDraw render driver [[default=yes]]]),
  2368                                 , enable_render_ddraw=yes)
  2369             if test x$enable_render_ddraw = xyes -a x$have_wince = xyes -a x$have_ddraw = xyes; then
  2370                 AC_DEFINE(SDL_VIDEO_RENDER_DDRAW)
  2371             fi
  2372             AC_ARG_ENABLE(render-d3d,
  2373 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2374                                 , enable_render_d3d=yes)
  2375             enable_render_d3d=no
  2376             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2377                 AC_DEFINE(SDL_VIDEO_RENDER_D3D)
  2378             fi
  2379         fi
  2380         # Set up files for the audio library
  2381         if test x$enable_audio = xyes; then
  2382             AC_DEFINE(SDL_AUDIO_DRIVER_WINWAVEOUT)
  2383             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2384             if test x$have_dsound = xyes; then
  2385                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2386                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2387             fi
  2388             have_audio=yes
  2389         fi
  2390         # Set up dummy files for the joystick for now
  2391         if test x$enable_joystick = xyes; then
  2392             AC_DEFINE(SDL_JOYSTICK_DUMMY)
  2393             SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2394             have_joystick=yes
  2395         fi
  2396         # Set up files for the thread library
  2397         if test x$enable_threads = xyes; then
  2398             AC_DEFINE(SDL_THREAD_WINDOWS)
  2399             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_sysmutex.c"
  2400             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_syssem.c"
  2401             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_systhread.c"
  2402             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2403             have_threads=yes
  2404         fi
  2405         # Set up files for the timer library
  2406         if test x$enable_timers = xyes; then
  2407             AC_DEFINE(SDL_TIMER_WINCE)
  2408             SOURCES="$SOURCES $srcdir/src/timer/wince/*.c"
  2409             have_timers=yes
  2410         fi
  2411         # Set up files for the shared object loading library
  2412         if test x$enable_loadso = xyes; then
  2413             AC_DEFINE(SDL_LOADSO_WINDOWS)
  2414             SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
  2415             have_loadso=yes
  2416         fi
  2417         # Set up the system libraries we need
  2418         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl -lmmtimer"
  2419 
  2420 	# mingw32ce library
  2421 	case "$host" in
  2422     	    *-mingw32ce)
  2423     		EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmingwex"
  2424     		;;
  2425     	    *)
  2426         	;;
  2427 	esac
  2428 
  2429         # The Windows platform requires special setup
  2430         SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
  2431         EXTRA_CFLAGS="$EXTRA_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
  2432         EXTRA_LDFLAGS="-lSDLmain $EXTRA_LDFLAGS"
  2433         ;;
  2434     *-*-cygwin* | *-*-mingw32*)
  2435         ARCH=win32
  2436         if test "$build" != "$host"; then # cross-compiling
  2437             # Default cross-compile location
  2438             ac_default_prefix=/usr/local/cross-tools/$host
  2439         else
  2440             # Look for the location of the tools and install there
  2441             if test "$BUILD_PREFIX" != ""; then
  2442                 ac_default_prefix=$BUILD_PREFIX
  2443             fi
  2444         fi
  2445         CheckDummyVideo
  2446         CheckDiskAudio
  2447         CheckDummyAudio
  2448         CheckWINDOWS
  2449         CheckWINDOWSGL
  2450         CheckDIRECTX
  2451 
  2452         # Set up the core platform files
  2453         SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
  2454 
  2455         # Set up files for the video library
  2456         if test x$enable_video = xyes; then
  2457             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
  2458             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
  2459             have_video=yes
  2460             AC_ARG_ENABLE(render-gdi,
  2461 AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
  2462                                 , enable_render_gdi=yes)
  2463             if test x$enable_render_gdi = xyes; then
  2464                 AC_DEFINE(SDL_VIDEO_RENDER_GDI)
  2465             fi
  2466             AC_ARG_ENABLE(render-d3d,
  2467 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2468                                 , enable_render_d3d=yes)
  2469             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2470                 AC_DEFINE(SDL_VIDEO_RENDER_D3D)
  2471             fi
  2472         fi
  2473         # Set up files for the audio library
  2474         if test x$enable_audio = xyes; then
  2475             AC_DEFINE(SDL_AUDIO_DRIVER_WINWAVEOUT)
  2476             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2477             if test x$have_dsound = xyes; then
  2478                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2479                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2480             fi
  2481             have_audio=yes
  2482         fi
  2483         # Set up files for the joystick library
  2484         if test x$enable_joystick = xyes; then
  2485             if test x$have_dinput = xyes; then
  2486                 AC_DEFINE(SDL_JOYSTICK_DINPUT)
  2487                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_dxjoystick.c"
  2488                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
  2489             else
  2490                 AC_DEFINE(SDL_JOYSTICK_WINMM)
  2491                 SOURCES="$SOURCES $srcdir/src/joystick/windows/SDL_mmjoystick.c"
  2492             fi
  2493             have_joystick=yes
  2494         fi
  2495         if test x$enable_haptic = xyes; then
  2496             if test x$have_dinput = xyes; then
  2497                 AC_DEFINE(SDL_HAPTIC_DINPUT)
  2498                 SOURCES="$SOURCES $srcdir/src/haptic/windows/SDL_syshaptic.c"
  2499                 have_haptic=yes
  2500             fi
  2501         fi
  2502         if test x$enable_power = xyes; then
  2503             AC_DEFINE(SDL_POWER_WINDOWS)
  2504             SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
  2505             have_power=yes
  2506         fi
  2507         # Set up files for the thread library
  2508         if test x$enable_threads = xyes; then
  2509             AC_DEFINE(SDL_THREAD_WINDOWS)
  2510             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_sysmutex.c"
  2511             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_syssem.c"
  2512             SOURCES="$SOURCES $srcdir/src/thread/windows/SDL_systhread.c"
  2513             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2514             have_threads=yes
  2515         fi
  2516         # Set up files for the timer library
  2517         if test x$enable_timers = xyes; then
  2518             AC_DEFINE(SDL_TIMER_WINDOWS)
  2519             SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
  2520             have_timers=yes
  2521         fi
  2522         # Set up files for the shared object loading library
  2523         if test x$enable_loadso = xyes; then
  2524             AC_DEFINE(SDL_LOADSO_WINDOWS)
  2525             SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
  2526             have_loadso=yes
  2527         fi
  2528         # Set up the system libraries we need
  2529         # SDL 1.3 is unicode, and unicows emulates this on Windows 98/ME
  2530         # You can get this here: http://libunicows.sourceforge.net/
  2531         #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lunicows"
  2532         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm -limm32 -lole32 -loleaut32 -lversion -luuid"
  2533         # The Windows platform requires special setup
  2534         VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
  2535         SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
  2536         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2537         SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
  2538         ;;
  2539     *-*-beos* | *-*-haiku*)
  2540         ARCH=beos
  2541         ac_default_prefix=/boot/develop/tools/gnupro
  2542         CheckDummyVideo
  2543         CheckDiskAudio
  2544         CheckDummyAudio
  2545         CheckBWINDOW
  2546         CheckBeGL
  2547         # Set up files for the audio library
  2548         if test x$enable_audio = xyes; then
  2549             AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO)
  2550             SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
  2551             have_audio=yes
  2552         fi
  2553         # Set up files for the joystick library
  2554         if test x$enable_joystick = xyes; then
  2555             AC_DEFINE(SDL_JOYSTICK_BEOS)
  2556             SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
  2557             have_joystick=yes
  2558         fi
  2559         # Set up files for the thread library
  2560         if test x$enable_threads = xyes; then
  2561             AC_DEFINE(SDL_THREAD_BEOS)
  2562             SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
  2563             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2564             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2565             have_threads=yes
  2566         fi
  2567         # Set up files for the timer library
  2568         if test x$enable_timers = xyes; then
  2569             AC_DEFINE(SDL_TIMER_BEOS)
  2570             SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
  2571             have_timers=yes
  2572         fi
  2573         # Set up files for the shared object loading library
  2574         if test x$enable_loadso = xyes; then
  2575             AC_DEFINE(SDL_LOADSO_BEOS)
  2576             SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
  2577             have_loadso=yes
  2578         fi
  2579         # Set up files for the system power library
  2580         if test x$enable_power = xyes; then
  2581             AC_DEFINE(SDL_POWER_BEOS)
  2582             SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
  2583             have_power=yes
  2584         fi
  2585         # The BeOS platform requires special setup.
  2586         SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
  2587         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2588         ;;
  2589     *-*-darwin* )
  2590         # This could be either full "Mac OS X", or plain "Darwin" which is
  2591         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2592         # Next line is broken, and a few files below require Mac OS X (full)
  2593         ARCH=macosx
  2594 
  2595         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  2596         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  2597         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  2598 
  2599         CheckVisibilityHidden
  2600         CheckDummyVideo
  2601         CheckDiskAudio
  2602         CheckDummyAudio
  2603         CheckDLOPEN
  2604 
  2605         # Set up files for the shared object loading library
  2606         # (this needs to be done before the dynamic X11 check)
  2607         if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
  2608             AC_DEFINE(SDL_LOADSO_DLCOMPAT)
  2609             SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
  2610             have_loadso=yes
  2611         fi
  2612 
  2613         CheckCOCOA
  2614         CheckX11
  2615         CheckMacGL
  2616         CheckOpenGLX11
  2617         CheckPTHREAD
  2618 
  2619         # Good optimization on Mac OS X, yes...
  2620         EXTRA_CFLAGS="$EXTRA_CFLAGS -falign-loops=16"
  2621 
  2622         # Need this or things might misbuild on a G3.
  2623         EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
  2624 
  2625         # Set up files for the audio library
  2626         if test x$enable_audio = xyes; then
  2627             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO)
  2628             SOURCES="$SOURCES $srcdir/src/audio/macosx/*.c"
  2629             have_audio=yes
  2630         fi
  2631         # Set up files for the joystick library
  2632         if test x$enable_joystick = xyes; then
  2633             AC_DEFINE(SDL_JOYSTICK_IOKIT)
  2634             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  2635             have_joystick=yes
  2636         fi
  2637         # Set up files for the haptic library
  2638         if test x$enable_haptic = xyes; then
  2639             AC_DEFINE(SDL_HAPTIC_IOKIT)
  2640             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2641             have_haptic=yes
  2642             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2643         fi
  2644         # Set up files for the power library
  2645         if test x$enable_power = xyes; then
  2646             AC_DEFINE(SDL_POWER_MACOSX)
  2647             SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
  2648             have_power=yes
  2649         fi
  2650         # Set up files for the timer library
  2651         if test x$enable_timers = xyes; then
  2652             AC_DEFINE(SDL_TIMER_UNIX)
  2653             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2654             have_timers=yes
  2655         fi
  2656         # Set up additional files for the file library
  2657         if test x$enable_file = xyes; then
  2658             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  2659         fi
  2660         # The Mac OS X platform requires special setup.
  2661         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2662         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
  2663         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  2664         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  2665         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  2666         # If audio is used, add the AudioUnit framework
  2667         if test x$enable_audio = xyes; then
  2668             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
  2669         fi
  2670         ;;
  2671     *)
  2672         AC_MSG_ERROR([
  2673 *** Unsupported host:  Please add to configure.in
  2674         ])
  2675         ;;
  2676 esac
  2677 
  2678 # Verify that we have all the platform specific files we need
  2679 
  2680 if test x$have_joystick != xyes; then
  2681     if test x$enable_joystick = xyes; then
  2682         AC_DEFINE(SDL_JOYSTICK_DISABLED)
  2683     fi
  2684     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2685 fi
  2686 if test x$have_haptic != xyes; then
  2687     if test x$enable_haptic = xyes; then
  2688         AC_DEFINE(SDL_HAPTIC_DISABLED)
  2689     fi
  2690     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2691 fi
  2692 if test x$have_threads != xyes; then
  2693     if test x$enable_threads = xyes; then
  2694         AC_DEFINE(SDL_THREADS_DISABLED)
  2695     fi
  2696     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  2697 fi
  2698 if test x$have_timers != xyes; then
  2699     if test x$enable_timers = xyes; then
  2700         AC_DEFINE(SDL_TIMERS_DISABLED)
  2701     fi
  2702     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  2703 fi
  2704 if test x$have_loadso != xyes; then
  2705     if test x$enable_loadso = xyes; then
  2706         AC_DEFINE(SDL_LOADSO_DISABLED)
  2707     fi
  2708     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  2709 fi
  2710 if test x$SDLMAIN_SOURCES = x; then
  2711     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  2712 fi
  2713 
  2714 OBJECTS=`echo $SOURCES`
  2715 DEPENDS=`echo $SOURCES | tr ' ' '\n'`
  2716 for EXT in asm cc m c S; do
  2717     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
  2718     DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
  2719 \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
  2720 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2721 done
  2722 DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
  2723 
  2724 VERSION_OBJECTS=`echo $VERSION_SOURCES`
  2725 VERSION_DEPENDS=`echo $VERSION_SOURCES`
  2726 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  2727 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
  2728 \\$(objects)/\\2.o: \\1/\\2.rc\\\\
  2729 	\\$(WINDRES) \\$< \\$@,g"`
  2730 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
  2731 
  2732 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
  2733 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
  2734 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2735 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  2736 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  2737 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2738 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed 's,\\$,\\\\$,g'`
  2739 
  2740 # Set runtime shared library paths as needed
  2741 
  2742 if test "x$enable_rpath" = "xyes"; then
  2743   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
  2744     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  2745   fi
  2746   if test $ARCH = solaris; then
  2747     SDL_RLD_FLAGS="-R\${libdir}"
  2748   fi
  2749 else
  2750   SDL_RLD_FLAGS=""
  2751 fi
  2752 
  2753 case "$ARCH" in
  2754   macosx)
  2755     # Evil hack to allow static linking on Mac OS X
  2756     SDL_STATIC_LIBS="\${libdir}/libSDL.a $EXTRA_LDFLAGS"
  2757     ;;
  2758   *)
  2759     SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  2760     ;;
  2761 esac
  2762 
  2763 dnl Expand the cflags and libraries needed by apps using SDL
  2764 AC_SUBST(SDL_CFLAGS)
  2765 AC_SUBST(SDL_LIBS)
  2766 AC_SUBST(SDL_STATIC_LIBS)
  2767 AC_SUBST(SDL_RLD_FLAGS)
  2768 if test x$enable_shared = xyes; then
  2769     ENABLE_SHARED_TRUE=
  2770     ENABLE_SHARED_FALSE="#"
  2771 else
  2772     ENABLE_SHARED_TRUE="#"
  2773     ENABLE_SHARED_FALSE=
  2774 fi
  2775 if test x$enable_static = xyes; then
  2776     ENABLE_STATIC_TRUE=
  2777     ENABLE_STATIC_FALSE="#"
  2778 else
  2779     ENABLE_STATIC_TRUE="#"
  2780     ENABLE_STATIC_FALSE=
  2781 fi
  2782 AC_SUBST(ENABLE_SHARED_TRUE)
  2783 AC_SUBST(ENABLE_SHARED_FALSE)
  2784 AC_SUBST(ENABLE_STATIC_TRUE)
  2785 AC_SUBST(ENABLE_STATIC_FALSE)
  2786 
  2787 dnl Expand the sources and objects needed to build the library
  2788 AC_SUBST(ac_aux_dir)
  2789 AC_SUBST(INCLUDE)
  2790 AC_SUBST(OBJECTS)
  2791 AC_SUBST(VERSION_OBJECTS)
  2792 AC_SUBST(SDLMAIN_OBJECTS)
  2793 AC_SUBST(BUILD_CFLAGS)
  2794 AC_SUBST(EXTRA_CFLAGS)
  2795 AC_SUBST(BUILD_LDFLAGS)
  2796 AC_SUBST(EXTRA_LDFLAGS)
  2797 AC_SUBST(WINDRES)
  2798 
  2799 AC_CONFIG_FILES([
  2800     Makefile sdl-config SDL.spec sdl.pc
  2801 ])
  2802 AC_CONFIG_COMMANDS([default],
  2803                    [cat >>Makefile <<__EOF__
  2804 
  2805 # Build rules for objects
  2806 -include \$(OBJECTS:.lo=.d)
  2807 $DEPENDS
  2808 $VERSION_DEPENDS
  2809 $SDLMAIN_DEPENDS
  2810 __EOF__ 
  2811 ], [
  2812 DEPENDS="$DEPENDS"
  2813 VERSION_DEPENDS="$VERSION_DEPENDS"
  2814 SDLMAIN_DEPENDS="$SDLMAIN_DEPENDS"
  2815 ])
  2816 AC_OUTPUT