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