configure.in
author Sam Lantinga <slouken@libsdl.org>
Wed, 19 Jan 2011 22:18:45 -0800
changeset 5045 1cee937d9fcc
parent 5041 3ce345cc46f8
child 5047 edaf3e364a05
permissions -rw-r--r--
Nobody has stepped up to maintain a framebuffer console driver. Bye bye! :)
     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 See if we're running on PlayStation 3 Cell hardware
  1550 CheckPS3()
  1551 {
  1552   AC_ARG_ENABLE(video-ps3,
  1553                 AC_HELP_STRING([--enable-video-ps3], [use PlayStation 3 Cell driver [[default=yes]]]),
  1554                 , enable_video_ps3=yes)
  1555   if test x$enable_video = xyes -a x$enable_video_ps3 = xyes; then 
  1556     video_ps3=no
  1557     AC_CHECK_HEADER([linux/fb.h])
  1558     AC_CHECK_HEADER([asm/ps3fb.h], [have_ps3fb_hdr=yes], [],
  1559             [#ifndef _LINUX_TYPES_H
  1560                 #include <linux/types.h>
  1561             #endif])
  1562     AC_CHECK_HEADER([libspe2.h], have_libspe2_hdr=yes)
  1563     AC_CHECK_LIB([spe2], spe_context_create, have_spe2_lib=yes)
  1564 
  1565     AC_CHECK_PROGS(SPU_GCC, [spu-gcc])
  1566     AC_CHECK_PROGS(EMBEDSPU, [embedspu])
  1567 
  1568     have_spu_libs=yes
  1569     AC_CHECK_LIB([fb_writer_spu], [main], [], [have_spu_libs=no])
  1570     AC_CHECK_LIB([yuv2rgb_spu], [main], [], [have_spu_libs=no])
  1571     AC_CHECK_LIB([bilin_scaler_spu], [main], [], [have_spu_libs=no])
  1572     if test x$have_ps3fb_hdr = xyes -a x$have_libspe2_hdr = xyes -a x$have_spe2_lib = xyes -a "$SPU_GCC" -a "$EMBEDSPU"; then
  1573         AC_DEFINE(SDL_VIDEO_DRIVER_PS3)
  1574         video_ps3=yes
  1575         have_video=yes
  1576         SOURCES="$SOURCES $srcdir/src/video/ps3/*.c"
  1577         EXTRA_CFLAGS="$EXTRA_CFLAGS -I/opt/cell/sdk/usr/include"
  1578         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L/opt/cell/sdk/usr/lib -lspe2 -lfb_writer_spu -lyuv2rgb_spu -lbilin_scaler_spu"
  1579 
  1580         if test x$have_spu_libs = xno; then 
  1581               AC_MSG_WARN([ps3libs missing, please run make ps3libs])
  1582         fi
  1583     fi
  1584     AC_MSG_CHECKING([for PlayStation 3 Cell support])
  1585     AC_MSG_RESULT([$video_ps3])
  1586   fi
  1587 }
  1588 
  1589 dnl Find the SVGAlib includes and libraries
  1590 CheckSVGA()
  1591 {
  1592     AC_ARG_ENABLE(video-svga,
  1593 AC_HELP_STRING([--enable-video-svga], [use SVGAlib video driver [[default=no]]]),
  1594                   , enable_video_svga=no)
  1595     if test x$enable_video = xyes -a x$enable_video_svga = xyes; then
  1596         AC_MSG_CHECKING(for SVGAlib (1.4.0+) support)
  1597         video_svga=no
  1598         AC_TRY_COMPILE([
  1599          #include <vga.h>
  1600          #include <vgamouse.h>
  1601          #include <vgakeyboard.h>
  1602         ],[
  1603          if ( SCANCODE_RIGHTWIN && SCANCODE_LEFTWIN ) {
  1604              exit(0);
  1605          }
  1606         ],[
  1607         video_svga=yes
  1608         ])
  1609         AC_MSG_RESULT($video_svga)
  1610         if test x$video_svga = xyes; then
  1611             AC_DEFINE(SDL_VIDEO_DRIVER_SVGALIB)
  1612             SOURCES="$SOURCES $srcdir/src/video/svga/*.c"
  1613             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvga"
  1614             have_video=yes
  1615         fi
  1616     fi
  1617 }
  1618 
  1619 dnl rcg04172001 Set up the Null video driver.
  1620 CheckDummyVideo()
  1621 {
  1622     AC_ARG_ENABLE(video-dummy,
  1623 AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  1624                   , enable_video_dummy=yes)
  1625     if test x$enable_video_dummy = xyes; then
  1626         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY)
  1627         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  1628         have_video=yes
  1629     fi
  1630 }
  1631 
  1632 dnl Check to see if OpenGL support is desired
  1633 AC_ARG_ENABLE(video-opengl,
  1634 AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  1635               , enable_video_opengl=yes)
  1636 
  1637 dnl Find OpenGL
  1638 CheckOpenGLX11()
  1639 {
  1640     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1641         AC_MSG_CHECKING(for OpenGL (GLX) support)
  1642         video_opengl=no
  1643         AC_TRY_COMPILE([
  1644          #include <GL/gl.h>
  1645          #include <GL/glx.h>
  1646          #include <GL/glu.h>
  1647         ],[
  1648         ],[
  1649         video_opengl=yes
  1650         ])
  1651         AC_MSG_RESULT($video_opengl)
  1652         if test x$video_opengl = xyes; then
  1653             AC_DEFINE(SDL_VIDEO_OPENGL)
  1654             AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
  1655             AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1656         fi
  1657     fi
  1658 }
  1659 
  1660 dnl Find QNX 6.x Software OpenGL
  1661 CheckOpenGLQNX()
  1662 {
  1663     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1664         AC_MSG_CHECKING(for QNX 6.x Photon OpenGL support)
  1665         video_opengl=no
  1666         AC_TRY_COMPILE([
  1667          #include <GL/gl.h>
  1668         ],[
  1669         ],[
  1670         video_opengl=yes
  1671         ])
  1672         AC_MSG_RESULT($video_opengl)
  1673         if test x$video_opengl = xyes; then
  1674             AC_DEFINE(SDL_VIDEO_OPENGL)
  1675             AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1676             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1677         fi
  1678     fi
  1679 }
  1680 
  1681 dnl Find QNX 6.3 and above OpenGL ES implementation
  1682 CheckOpenGLESQNX()
  1683 {
  1684     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1685         AC_MSG_CHECKING(for QNX OpenGL ES (CM) support)
  1686         video_opengl=no
  1687         AC_TRY_COMPILE([
  1688          #include <GLES/egl.h>
  1689         ],[
  1690         ],[
  1691         video_opengl=yes
  1692         ])
  1693         AC_MSG_RESULT($video_opengl)
  1694         if test x$video_opengl = xyes; then
  1695             AC_DEFINE(SDL_VIDEO_OPENGL_ES)
  1696             AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
  1697             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CM"
  1698         else
  1699             AC_MSG_CHECKING(for QNX OpenGL ES (CL) support)
  1700             video_opengl=no
  1701             AC_TRY_COMPILE([
  1702              #define COMMON_LITE
  1703              #include <GLES/egl.h>
  1704             ],[
  1705             ],[
  1706             video_opengl=yes
  1707             ])
  1708             AC_MSG_RESULT($video_opengl)
  1709             if test x$video_opengl = xyes; then
  1710                 AC_DEFINE(SDL_VIDEO_OPENGL_ES)
  1711                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
  1712                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CLS"
  1713             fi
  1714         fi
  1715     fi
  1716 }
  1717 
  1718 
  1719 dnl Check for Win32 OpenGL
  1720 CheckWIN32GL()
  1721 {
  1722     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1723         AC_DEFINE(SDL_VIDEO_OPENGL)
  1724         AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
  1725         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1726     fi
  1727 }
  1728 
  1729 dnl Check for BeOS OpenGL
  1730 CheckBeGL()
  1731 {
  1732     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1733         AC_DEFINE(SDL_VIDEO_OPENGL)
  1734         AC_DEFINE(SDL_VIDEO_OPENGL_BGL)
  1735         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1736         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  1737     fi
  1738 }
  1739 
  1740 dnl Check for MacOS OpenGL
  1741 CheckMacGL()
  1742 {
  1743     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  1744         AC_DEFINE(SDL_VIDEO_OPENGL)
  1745         AC_DEFINE(SDL_VIDEO_OPENGL_CGL)
  1746         AC_DEFINE(SDL_VIDEO_RENDER_OGL)
  1747         case "$host" in
  1748             *-*-darwin*)
  1749                 if test x$enable_video_cocoa = xyes; then
  1750                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
  1751                 fi
  1752         esac
  1753     fi
  1754 }
  1755 
  1756 dnl See if we can use the new unified event interface in Linux 2.4
  1757 CheckInputEvents()
  1758 {
  1759     dnl Check for Linux 2.4 unified input event interface support
  1760     AC_ARG_ENABLE(input-events,
  1761 AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [[default=yes]]]),
  1762                   , enable_input_events=yes)
  1763     if test x$enable_input_events = xyes; then
  1764         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  1765         use_input_events=no
  1766         AC_TRY_COMPILE([
  1767           #include <linux/input.h>
  1768         ],[
  1769           #ifndef EVIOCGNAME
  1770           #error EVIOCGNAME() ioctl not available
  1771           #endif
  1772         ],[
  1773         use_input_events=yes
  1774         ])
  1775         AC_MSG_RESULT($use_input_events)
  1776         if test x$use_input_events = xyes; then
  1777             AC_DEFINE(SDL_INPUT_LINUXEV)
  1778         fi
  1779     fi
  1780 }
  1781 
  1782 dnl See if we can use the Touchscreen input library
  1783 CheckTslib()
  1784 {
  1785     AC_ARG_ENABLE(input-tslib,
  1786 AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  1787                   , enable_input_tslib=yes)
  1788     if test x$enable_input_tslib = xyes; then
  1789         AC_MSG_CHECKING(for Touchscreen library support)
  1790         enable_input_tslib=no
  1791         AC_TRY_COMPILE([
  1792           #include "tslib.h"
  1793         ],[
  1794         ],[
  1795         enable_input_tslib=yes
  1796         ])
  1797         AC_MSG_RESULT($enable_input_tslib)
  1798         if test x$enable_input_tslib = xyes; then
  1799             AC_DEFINE(SDL_INPUT_TSLIB)
  1800             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  1801         fi
  1802     fi
  1803 }
  1804 
  1805 dnl See what type of thread model to use on Linux and Solaris
  1806 CheckPTHREAD()
  1807 {
  1808     dnl Check for pthread support
  1809     AC_ARG_ENABLE(pthreads,
  1810 AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  1811                   , enable_pthreads=yes)
  1812     dnl This is used on Linux for glibc binary compatibility (Doh!)
  1813     AC_ARG_ENABLE(pthread-sem,
  1814 AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  1815                   , enable_pthread_sem=yes)
  1816     case "$host" in
  1817         *-*-linux*|*-*-uclinux*)
  1818             pthread_cflags="-D_REENTRANT"
  1819             pthread_lib="-lpthread"
  1820             ;;
  1821         *-*-bsdi*)
  1822             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1823             pthread_lib=""
  1824             ;;
  1825         *-*-darwin*)
  1826             pthread_cflags="-D_THREAD_SAFE"
  1827 # causes Carbon.p complaints?
  1828 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1829             ;;
  1830         *-*-freebsd*|*-*-dragonfly*)
  1831             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1832             pthread_lib="-pthread"
  1833             ;;
  1834         *-*-netbsd*)
  1835             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  1836             pthread_lib="-lpthread"
  1837             ;;
  1838         *-*-openbsd*)
  1839             pthread_cflags="-D_REENTRANT"
  1840             pthread_lib="-pthread"
  1841             ;;
  1842         *-*-solaris*)
  1843             pthread_cflags="-D_REENTRANT"
  1844             pthread_lib="-lpthread -lposix4"
  1845             ;;
  1846         *-*-sysv5*)
  1847             pthread_cflags="-D_REENTRANT -Kthread"
  1848             pthread_lib=""
  1849             ;;
  1850         *-*-irix*)
  1851             pthread_cflags="-D_SGI_MP_SOURCE"
  1852             pthread_lib="-lpthread"
  1853             ;;
  1854         *-*-aix*)
  1855             pthread_cflags="-D_REENTRANT -mthreads"
  1856             pthread_lib="-lpthread"
  1857             ;;
  1858         *-*-hpux11*)
  1859             pthread_cflags="-D_REENTRANT"
  1860             pthread_lib="-L/usr/lib -lpthread"
  1861             ;;
  1862         *-*-qnx*)
  1863             pthread_cflags=""
  1864             pthread_lib=""
  1865             ;;
  1866         *-*-osf*)
  1867             pthread_cflags="-D_REENTRANT"
  1868             if test x$ac_cv_prog_gcc = xyes; then
  1869                 pthread_lib="-lpthread -lrt"
  1870             else
  1871                 pthread_lib="-lpthread -lexc -lrt"
  1872             fi
  1873             ;;
  1874         *)
  1875             pthread_cflags="-D_REENTRANT"
  1876             pthread_lib="-lpthread"
  1877             ;;
  1878     esac
  1879     if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
  1880         # Save the original compiler flags and libraries
  1881         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1882         # Add the pthread compiler flags and libraries
  1883         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1884         # Check to see if we have pthread support on this system
  1885         AC_MSG_CHECKING(for pthreads)
  1886         use_pthreads=no
  1887         AC_TRY_LINK([
  1888          #include <pthread.h>
  1889         ],[
  1890          pthread_attr_t type;
  1891          pthread_attr_init(&type);
  1892         ],[
  1893         use_pthreads=yes
  1894         ])
  1895         AC_MSG_RESULT($use_pthreads)
  1896         # Restore the compiler flags and libraries
  1897         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1898 
  1899         # Do futher testing if we have pthread support...
  1900         if test x$use_pthreads = xyes; then
  1901             AC_DEFINE(SDL_THREAD_PTHREAD)
  1902             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  1903             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  1904             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  1905             SDL_LIBS="$SDL_LIBS $pthread_lib"
  1906 
  1907             # Save the original compiler flags and libraries
  1908             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1909             # Add the pthread compiler flags and libraries
  1910             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  1911 
  1912             # Check to see if recursive mutexes are available
  1913             AC_MSG_CHECKING(for recursive mutexes)
  1914             has_recursive_mutexes=no
  1915             if test x$has_recursive_mutexes = xno; then
  1916                 AC_TRY_COMPILE([
  1917                   #include <pthread.h>
  1918                 ],[
  1919                   pthread_mutexattr_t attr;
  1920                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  1921                 ],[
  1922                 has_recursive_mutexes=yes
  1923                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX)
  1924                 ])
  1925             fi
  1926             if test x$has_recursive_mutexes = xno; then
  1927                 AC_TRY_COMPILE([
  1928                   #include <pthread.h>
  1929                 ],[
  1930                   pthread_mutexattr_t attr;
  1931                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  1932                 ],[
  1933                 has_recursive_mutexes=yes
  1934                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)
  1935                 ])
  1936             fi
  1937             AC_MSG_RESULT($has_recursive_mutexes)
  1938 
  1939             # Check to see if pthread semaphore support is missing
  1940             if test x$enable_pthread_sem = xyes; then
  1941                 AC_MSG_CHECKING(for pthread semaphores)
  1942                 have_pthread_sem=no
  1943                 AC_TRY_COMPILE([
  1944                   #include <pthread.h>
  1945                   #include <semaphore.h>
  1946                 ],[
  1947                 ],[
  1948                 have_pthread_sem=yes
  1949                 ])
  1950                 AC_MSG_RESULT($have_pthread_sem)
  1951             fi
  1952 
  1953             # Restore the compiler flags and libraries
  1954             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1955 
  1956             # Basic thread creation functions
  1957             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  1958 
  1959             # Semaphores
  1960             # We can fake these with mutexes and condition variables if necessary
  1961             if test x$have_pthread_sem = xyes; then
  1962                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  1963             else
  1964                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  1965             fi
  1966 
  1967             # Mutexes
  1968             # We can fake these with semaphores if necessary
  1969             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  1970 
  1971             # Condition variables
  1972             # We can fake these with semaphores and mutexes if necessary
  1973             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  1974 
  1975             have_threads=yes
  1976         fi
  1977     fi
  1978 }
  1979 
  1980 dnl Determine whether the compiler can produce Win32 executables
  1981 CheckWIN32()
  1982 {
  1983     AC_MSG_CHECKING(Win32 compiler)
  1984     have_win32_gcc=no
  1985     AC_TRY_COMPILE([
  1986      #include <windows.h>
  1987     ],[
  1988     ],[
  1989     have_win32_gcc=yes
  1990     ])
  1991     AC_MSG_RESULT($have_win32_gcc)
  1992     if test x$have_win32_gcc != xyes; then
  1993        AC_MSG_ERROR([
  1994 *** Your compiler ($CC) does not produce Win32 executables!
  1995        ])
  1996     fi
  1997 
  1998     AC_MSG_CHECKING(Windows CE)
  1999     have_wince=no
  2000     AC_TRY_COMPILE([
  2001 #if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
  2002 #error This is not Windows CE
  2003 #endif
  2004     ],[
  2005     ],[
  2006     have_wince=yes
  2007     ])
  2008     AC_MSG_RESULT($have_wince)
  2009 
  2010     dnl See if the user wants to redirect standard output to files
  2011     AC_ARG_ENABLE(stdio-redirect,
  2012 AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[default=yes]]]),
  2013                   , enable_stdio_redirect=yes)
  2014     if test x$enable_stdio_redirect != xyes; then
  2015         EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
  2016     fi
  2017 }
  2018 
  2019 dnl Find the DirectX includes and libraries
  2020 CheckDIRECTX()
  2021 {
  2022     AC_ARG_ENABLE(directx,
  2023 AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]),
  2024                   , enable_directx=yes)
  2025     if test x$enable_directx = xyes; then
  2026         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  2027         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  2028         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  2029         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  2030     fi
  2031 }
  2032 
  2033 dnl Check for the dlfcn.h interface for dynamically loading objects
  2034 CheckDLOPEN()
  2035 {
  2036     AC_ARG_ENABLE(sdl-dlopen,
  2037 AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  2038                   , enable_sdl_dlopen=yes)
  2039     if test x$enable_sdl_dlopen = xyes; then
  2040         AC_MSG_CHECKING(for dlopen)
  2041         have_dlopen=no
  2042         AC_TRY_COMPILE([
  2043          #include <dlfcn.h>
  2044         ],[
  2045          #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
  2046          #error Use dlcompat for Mac OS X 10.2 compatibility
  2047          #endif
  2048         ],[
  2049         have_dlopen=yes
  2050         ])
  2051         AC_MSG_RESULT($have_dlopen)
  2052 
  2053         if test x$have_dlopen = xyes; then
  2054             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  2055                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  2056                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  2057             AC_DEFINE(SDL_LOADSO_DLOPEN)
  2058             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  2059             have_loadso=yes
  2060         fi
  2061     fi
  2062 }
  2063 
  2064 dnl Check for the usbhid(3) library on *BSD
  2065 CheckUSBHID()
  2066 {
  2067     if test x$enable_joystick = xyes; then
  2068         AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  2069         if test x$have_libusbhid = xyes; then
  2070             AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  2071             AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  2072             USB_LIBS="$USB_LIBS -lusbhid"
  2073         else
  2074             AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  2075             AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  2076             AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  2077         fi
  2078             
  2079         save_CFLAGS="$CFLAGS"
  2080         CFLAGS="$CFLAGS $USB_CFLAGS"
  2081 
  2082         AC_MSG_CHECKING(for usbhid)
  2083         have_usbhid=no
  2084         AC_TRY_COMPILE([
  2085           #include <sys/types.h>
  2086           #if defined(HAVE_USB_H)
  2087           #include <usb.h>
  2088           #endif
  2089           #ifdef __DragonFly__
  2090           # include <bus/usb/usb.h>
  2091           # include <bus/usb/usbhid.h>
  2092           #else
  2093           # include <dev/usb/usb.h>
  2094           # include <dev/usb/usbhid.h>
  2095           #endif
  2096           #if defined(HAVE_USBHID_H)
  2097           #include <usbhid.h>
  2098           #elif defined(HAVE_LIBUSB_H)
  2099           #include <libusb.h>
  2100           #elif defined(HAVE_LIBUSBHID_H)
  2101           #include <libusbhid.h>
  2102           #endif
  2103         ],[
  2104           struct report_desc *repdesc;
  2105           struct usb_ctl_report *repbuf;
  2106           hid_kind_t hidkind;
  2107         ],[
  2108         have_usbhid=yes
  2109         ])
  2110         AC_MSG_RESULT($have_usbhid)
  2111 
  2112         if test x$have_usbhid = xyes; then
  2113             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  2114             have_usbhid_ucr_data=no
  2115             AC_TRY_COMPILE([
  2116               #include <sys/types.h>
  2117               #if defined(HAVE_USB_H)
  2118               #include <usb.h>
  2119               #endif
  2120               #ifdef __DragonFly__
  2121               # include <bus/usb/usb.h>
  2122               # include <bus/usb/usbhid.h>
  2123               #else
  2124               # include <dev/usb/usb.h>
  2125               # include <dev/usb/usbhid.h>
  2126               #endif
  2127               #if defined(HAVE_USBHID_H)
  2128               #include <usbhid.h>
  2129               #elif defined(HAVE_LIBUSB_H)
  2130               #include <libusb.h>
  2131               #elif defined(HAVE_LIBUSBHID_H)
  2132               #include <libusbhid.h>
  2133               #endif
  2134             ],[
  2135               struct usb_ctl_report buf;
  2136               if (buf.ucr_data) { }
  2137             ],[
  2138             have_usbhid_ucr_data=yes
  2139             ])
  2140             if test x$have_usbhid_ucr_data = xyes; then
  2141                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  2142             fi
  2143             AC_MSG_RESULT($have_usbhid_ucr_data)
  2144             
  2145             AC_MSG_CHECKING(for new usbhid API)
  2146             have_usbhid_new=no
  2147             AC_TRY_COMPILE([
  2148               #include <sys/types.h>
  2149               #if defined(HAVE_USB_H)
  2150               #include <usb.h>
  2151               #endif
  2152               #ifdef __DragonFly__
  2153               #include <bus/usb/usb.h>
  2154               #include <bus/usb/usbhid.h>
  2155               #else
  2156               #include <dev/usb/usb.h>
  2157               #include <dev/usb/usbhid.h>
  2158               #endif
  2159               #if defined(HAVE_USBHID_H)
  2160               #include <usbhid.h>
  2161               #elif defined(HAVE_LIBUSB_H)
  2162               #include <libusb.h>
  2163               #elif defined(HAVE_LIBUSBHID_H)
  2164               #include <libusbhid.h>
  2165               #endif
  2166             ],[
  2167               report_desc_t d;
  2168               hid_start_parse(d, 1, 1);
  2169             ],[
  2170             have_usbhid_new=yes
  2171             ])
  2172             if test x$have_usbhid_new = xyes; then
  2173                 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  2174             fi
  2175             AC_MSG_RESULT($have_usbhid_new)
  2176 
  2177             AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  2178             have_machine_joystick=no
  2179             AC_TRY_COMPILE([
  2180               #include <machine/joystick.h>
  2181             ],[
  2182               struct joystick t;
  2183             ],[
  2184             have_machine_joystick=yes
  2185             ])
  2186             if test x$have_machine_joystick = xyes; then
  2187                 AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H)
  2188             fi
  2189             AC_MSG_RESULT($have_machine_joystick)
  2190 
  2191             AC_DEFINE(SDL_JOYSTICK_USBHID)
  2192             SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  2193             EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  2194             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  2195             have_joystick=yes
  2196         fi
  2197         CFLAGS="$save_CFLAGS"
  2198     fi
  2199 }
  2200 
  2201 dnl Check for clock_gettime()
  2202 CheckClockGettime()
  2203 {
  2204     AC_ARG_ENABLE(clock_gettime,
  2205 AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=no]]]),
  2206                   , enable_clock_gettime=no)
  2207     if test x$enable_clock_gettime = xyes; then
  2208         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  2209         if test x$have_clock_gettime = xyes; then
  2210             AC_DEFINE(HAVE_CLOCK_GETTIME)
  2211             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  2212         else
  2213             AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
  2214             if test x$have_clock_gettime = xyes; then
  2215                AC_DEFINE(HAVE_CLOCK_GETTIME)
  2216                EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
  2217             fi
  2218         fi
  2219     fi
  2220 }
  2221 
  2222 dnl Check for a valid linux/version.h
  2223 CheckLinuxVersion()
  2224 {
  2225     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  2226     if test x$have_linux_version_h = xyes; then
  2227         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  2228     fi
  2229 }
  2230 
  2231 dnl Check if we want to use RPATH
  2232 CheckRPATH()
  2233 {
  2234     AC_ARG_ENABLE(rpath,
  2235 AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  2236                   , enable_rpath=yes)
  2237 }
  2238 
  2239 dnl Set up the configuration based on the host platform!
  2240 case "$host" in
  2241     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*|*-*-minix*)
  2242         case "$host" in
  2243             *-*-linux*)         ARCH=linux ;;
  2244             *-*-uclinux*)       ARCH=linux ;;
  2245             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  2246             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  2247             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  2248             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  2249             *-*-bsdi*)          ARCH=bsdi ;;
  2250             *-*-freebsd*)       ARCH=freebsd ;;
  2251             *-*-dragonfly*)     ARCH=freebsd ;;
  2252             *-*-netbsd*)        ARCH=netbsd ;;
  2253             *-*-openbsd*)       ARCH=openbsd ;;
  2254             *-*-sysv5*)         ARCH=sysv5 ;;
  2255             *-*-solaris*)       ARCH=solaris ;;
  2256             *-*-hpux*)          ARCH=hpux ;;
  2257             *-*-irix*)          ARCH=irix ;;
  2258             *-*-aix*)           ARCH=aix ;;
  2259             *-*-osf*)           ARCH=osf ;;
  2260             *-*-minix*)         ARCH=minix ;;
  2261         esac
  2262         CheckVisibilityHidden
  2263         CheckDummyVideo
  2264         CheckDiskAudio
  2265         CheckDummyAudio
  2266         CheckDLOPEN
  2267         CheckOSS
  2268         CheckDMEDIA
  2269         CheckMME
  2270         CheckALSA
  2271         CheckPulseAudio
  2272         CheckARTSC
  2273         CheckESD
  2274         CheckNAS
  2275         CheckX11
  2276         CheckDirectFB
  2277         CheckFusionSound
  2278         CheckPS3
  2279         CheckSVGA
  2280         CheckOpenGLX11
  2281         CheckInputEvents
  2282         CheckTslib
  2283         CheckUSBHID
  2284         CheckPTHREAD
  2285         CheckClockGettime
  2286         CheckLinuxVersion
  2287         CheckRPATH
  2288         # Set up files for the audio library
  2289         if test x$enable_audio = xyes; then
  2290           case $ARCH in
  2291             sysv5|solaris|hpux)
  2292                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
  2293                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  2294                 have_audio=yes
  2295             ;;
  2296             netbsd|openbsd)
  2297                 AC_DEFINE(SDL_AUDIO_DRIVER_BSD)
  2298                 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
  2299                 have_audio=yes
  2300             ;;
  2301             aix)
  2302                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO)
  2303                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  2304                 have_audio=yes
  2305             ;;
  2306           esac
  2307         fi
  2308         # Set up files for the joystick library
  2309         if test x$enable_joystick = xyes; then
  2310           case $ARCH in
  2311             linux)
  2312                 AC_DEFINE(SDL_JOYSTICK_LINUX)
  2313                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  2314                 have_joystick=yes
  2315             ;;
  2316           esac
  2317         fi
  2318         # Set up files for the haptic library
  2319         if test x$enable_haptic = xyes; then
  2320            if test x$use_input_events = xyes; then
  2321              case $ARCH in
  2322                linux)
  2323                    AC_DEFINE(SDL_HAPTIC_LINUX)
  2324                    SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  2325                    have_haptic=yes
  2326                ;;
  2327              esac
  2328            fi
  2329         fi
  2330         # Set up files for the power library
  2331         if test x$enable_power = xyes; then
  2332              case $ARCH in
  2333                linux)
  2334                    AC_DEFINE(SDL_POWER_LINUX)
  2335                    SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
  2336                    have_power=yes
  2337                ;;
  2338              esac
  2339         fi
  2340         # Set up files for the thread library
  2341         if test x$enable_threads = xyes -a x$use_pthreads != xyes -a x$use_pth != xyes -a x$ARCH = xirix; then
  2342             AC_DEFINE(SDL_THREAD_SPROC)
  2343             SOURCES="$SOURCES $srcdir/src/thread/irix/*.c"
  2344             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2345             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2346             have_threads=yes
  2347         fi
  2348         # Set up files for the timer library
  2349         if test x$enable_timers = xyes; then
  2350             AC_DEFINE(SDL_TIMER_UNIX)
  2351             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2352             have_timers=yes
  2353         fi
  2354         ;;
  2355     *-*-qnx*)
  2356 
  2357         EXTRA_CFLAGS="-I/usr/include $CFLAGS"
  2358         EXTRA_LDLAGS="-L/usr/lib $LDFLAGS"
  2359 
  2360         ARCH=qnx
  2361         CheckVisibilityHidden
  2362         CheckDummyVideo
  2363         CheckDiskAudio
  2364         CheckDummyAudio
  2365         CheckDLOPEN
  2366         CheckPulseAudio
  2367         CheckESD
  2368         CheckNAS
  2369         CheckPHOTON
  2370         CheckQNXGF
  2371         CheckX11
  2372         CheckOpenGLX11
  2373         CheckPTHREAD
  2374         CheckClockGettime
  2375 
  2376 
  2377         # Set up files for the audio library
  2378         if test x$enable_audio = xyes; then
  2379             AC_DEFINE(SDL_AUDIO_DRIVER_QSA)
  2380             SOURCES="$SOURCES $srcdir/src/audio/qsa/*.c"
  2381             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
  2382             have_audio=yes
  2383         fi
  2384         # Set up files for the timer library
  2385         if test x$enable_timers = xyes; then
  2386             AC_DEFINE(SDL_TIMER_UNIX)
  2387             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2388             have_timers=yes
  2389         fi
  2390         # Set up dummy files for the joystick for now
  2391         if test x$enable_joystick = xyes; then
  2392             AC_DEFINE(SDL_JOYSTICK_DUMMY)
  2393             SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2394             have_joystick=yes
  2395         fi
  2396         # Set up dummy files for the haptic for now
  2397         if test x$enable_haptic = xyes; then
  2398             AC_DEFINE(SDL_HAPTIC_DUMMY)
  2399             SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2400             have_haptic=yes
  2401         fi
  2402         ;;
  2403     *-wince* | *-mingw32ce)
  2404         ARCH=win32
  2405         CheckDummyVideo
  2406         CheckDiskAudio
  2407         CheckDummyAudio
  2408         CheckWIN32
  2409         if test x$enable_video = xyes; then
  2410             AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
  2411             SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
  2412             have_video=yes
  2413             AC_ARG_ENABLE(render-gdi,
  2414 AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
  2415                                 , enable_render_gdi=yes)
  2416             if test x$enable_render_gdi = xyes; then
  2417                 AC_DEFINE(SDL_VIDEO_RENDER_GDI)
  2418             fi
  2419             AC_ARG_ENABLE(render-gapi,
  2420 AC_HELP_STRING([--enable-render-gapi], [enable the GAPI/RAWFRAMEBUFFER render driver [[default=yes]]]),
  2421                                 , enable_render_gapi=yes)
  2422             if test x$enable_render_gapi = xyes -a x$have_wince = xyes; then
  2423                 AC_DEFINE(SDL_VIDEO_RENDER_GAPI)
  2424             fi
  2425             AC_ARG_ENABLE(render-ddraw,
  2426 AC_HELP_STRING([--enable-render-ddraw], [enable the Mobile DirectDraw render driver [[default=yes]]]),
  2427                                 , enable_render_ddraw=yes)
  2428             if test x$enable_render_ddraw = xyes -a x$have_wince = xyes -a x$have_ddraw = xyes; then
  2429                 AC_DEFINE(SDL_VIDEO_RENDER_DDRAW)
  2430             fi
  2431             AC_ARG_ENABLE(render-d3d,
  2432 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2433                                 , enable_render_d3d=yes)
  2434             enable_render_d3d=no
  2435             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2436                 AC_DEFINE(SDL_VIDEO_RENDER_D3D)
  2437             fi
  2438         fi
  2439         # Set up files for the audio library
  2440         if test x$enable_audio = xyes; then
  2441             AC_DEFINE(SDL_AUDIO_DRIVER_WINWAVEOUT)
  2442             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2443             if test x$have_dsound = xyes; then
  2444                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2445                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2446             fi
  2447             have_audio=yes
  2448         fi
  2449         # Set up dummy files for the joystick for now
  2450         if test x$enable_joystick = xyes; then
  2451             AC_DEFINE(SDL_JOYSTICK_DUMMY)
  2452             SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2453             have_joystick=yes
  2454         fi
  2455         # Set up files for the thread library
  2456         if test x$enable_threads = xyes; then
  2457             AC_DEFINE(SDL_THREAD_WIN32)
  2458             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
  2459             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
  2460             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
  2461             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2462             have_threads=yes
  2463         fi
  2464         # Set up files for the timer library
  2465         if test x$enable_timers = xyes; then
  2466             AC_DEFINE(SDL_TIMER_WINCE)
  2467             SOURCES="$SOURCES $srcdir/src/timer/wince/*.c"
  2468             have_timers=yes
  2469         fi
  2470         # Set up files for the shared object loading library
  2471         if test x$enable_loadso = xyes; then
  2472             AC_DEFINE(SDL_LOADSO_WIN32)
  2473             SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
  2474             have_loadso=yes
  2475         fi
  2476         # Set up the system libraries we need
  2477         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl -lmmtimer"
  2478 
  2479 	# mingw32ce library
  2480 	case "$host" in
  2481     	    *-mingw32ce)
  2482     		EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmingwex"
  2483     		;;
  2484     	    *)
  2485         	;;
  2486 	esac
  2487 
  2488         # The Win32 platform requires special setup
  2489         SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
  2490         EXTRA_CFLAGS="$EXTRA_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
  2491         EXTRA_LDFLAGS="-lSDLmain $EXTRA_LDFLAGS"
  2492         ;;
  2493     *-*-cygwin* | *-*-mingw32*)
  2494         ARCH=win32
  2495         if test "$build" != "$host"; then # cross-compiling
  2496             # Default cross-compile location
  2497             ac_default_prefix=/usr/local/cross-tools/$host
  2498         else
  2499             # Look for the location of the tools and install there
  2500             if test "$BUILD_PREFIX" != ""; then
  2501                 ac_default_prefix=$BUILD_PREFIX
  2502             fi
  2503         fi
  2504         CheckDummyVideo
  2505         CheckDiskAudio
  2506         CheckDummyAudio
  2507         CheckWIN32
  2508         CheckWIN32GL
  2509         CheckDIRECTX
  2510         # Set up files for the video library
  2511         if test x$enable_video = xyes; then
  2512             AC_DEFINE(SDL_VIDEO_DRIVER_WIN32)
  2513             SOURCES="$SOURCES $srcdir/src/video/win32/*.c"
  2514             have_video=yes
  2515             AC_ARG_ENABLE(render-gdi,
  2516 AC_HELP_STRING([--enable-render-gdi], [enable the GDI render driver [[default=yes]]]),
  2517                                 , enable_render_gdi=yes)
  2518             if test x$enable_render_gdi = xyes; then
  2519                 AC_DEFINE(SDL_VIDEO_RENDER_GDI)
  2520             fi
  2521             AC_ARG_ENABLE(render-d3d,
  2522 AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  2523                                 , enable_render_d3d=yes)
  2524             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  2525                 AC_DEFINE(SDL_VIDEO_RENDER_D3D)
  2526             fi
  2527         fi
  2528         # Set up files for the audio library
  2529         if test x$enable_audio = xyes; then
  2530             AC_DEFINE(SDL_AUDIO_DRIVER_WINWAVEOUT)
  2531             SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
  2532             if test x$have_dsound = xyes; then
  2533                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
  2534                 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
  2535             fi
  2536             have_audio=yes
  2537         fi
  2538         # Set up files for the joystick library
  2539         if test x$enable_joystick = xyes; then
  2540             if test x$have_dinput = xyes; then
  2541                 AC_DEFINE(SDL_JOYSTICK_DINPUT)
  2542                 SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_dxjoystick.c"
  2543                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
  2544             else
  2545                 AC_DEFINE(SDL_JOYSTICK_WINMM)
  2546                 SOURCES="$SOURCES $srcdir/src/joystick/win32/SDL_mmjoystick.c"
  2547             fi
  2548             have_joystick=yes
  2549         fi
  2550         if test x$enable_haptic = xyes; then
  2551             if test x$have_dinput = xyes; then
  2552                 AC_DEFINE(SDL_HAPTIC_DINPUT)
  2553                 SOURCES="$SOURCES $srcdir/src/haptic/win32/SDL_syshaptic.c"
  2554                 have_haptic=yes
  2555             fi
  2556         fi
  2557         if test x$enable_power = xyes; then
  2558             AC_DEFINE(SDL_POWER_WINDOWS)
  2559             SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
  2560             have_power=yes
  2561         fi
  2562         # Set up files for the thread library
  2563         if test x$enable_threads = xyes; then
  2564             AC_DEFINE(SDL_THREAD_WIN32)
  2565             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
  2566             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
  2567             SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
  2568             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2569             have_threads=yes
  2570         fi
  2571         # Set up files for the timer library
  2572         if test x$enable_timers = xyes; then
  2573             AC_DEFINE(SDL_TIMER_WIN32)
  2574             SOURCES="$SOURCES $srcdir/src/timer/win32/*.c"
  2575             have_timers=yes
  2576         fi
  2577         # Set up files for the shared object loading library
  2578         if test x$enable_loadso = xyes; then
  2579             AC_DEFINE(SDL_LOADSO_WIN32)
  2580             SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
  2581             have_loadso=yes
  2582         fi
  2583         # Set up the system libraries we need
  2584         # SDL 1.3 is unicode, and unicows emulates this on Windows 98/ME
  2585         # You can get this here: http://libunicows.sourceforge.net/
  2586         #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lunicows"
  2587         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lmsimg32 -lwinmm -limm32 -lole32 -loleaut32 -lversion -luuid"
  2588         # The Win32 platform requires special setup
  2589         VERSION_SOURCES="$srcdir/src/main/win32/*.rc"
  2590         SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
  2591         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  2592         SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
  2593         ;;
  2594     *-*-beos* | *-*-haiku*)
  2595         ARCH=beos
  2596         ac_default_prefix=/boot/develop/tools/gnupro
  2597         CheckDummyVideo
  2598         CheckDiskAudio
  2599         CheckDummyAudio
  2600         CheckBWINDOW
  2601         CheckBeGL
  2602         # Set up files for the audio library
  2603         if test x$enable_audio = xyes; then
  2604             AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO)
  2605             SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
  2606             have_audio=yes
  2607         fi
  2608         # Set up files for the joystick library
  2609         if test x$enable_joystick = xyes; then
  2610             AC_DEFINE(SDL_JOYSTICK_BEOS)
  2611             SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
  2612             have_joystick=yes
  2613         fi
  2614         # Set up files for the thread library
  2615         if test x$enable_threads = xyes; then
  2616             AC_DEFINE(SDL_THREAD_BEOS)
  2617             SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
  2618             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
  2619             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  2620             have_threads=yes
  2621         fi
  2622         # Set up files for the timer library
  2623         if test x$enable_timers = xyes; then
  2624             AC_DEFINE(SDL_TIMER_BEOS)
  2625             SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
  2626             have_timers=yes
  2627         fi
  2628         # Set up files for the shared object loading library
  2629         if test x$enable_loadso = xyes; then
  2630             AC_DEFINE(SDL_LOADSO_BEOS)
  2631             SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
  2632             have_loadso=yes
  2633         fi
  2634         # Set up files for the system power library
  2635         if test x$enable_power = xyes; then
  2636             AC_DEFINE(SDL_POWER_BEOS)
  2637             SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
  2638             have_power=yes
  2639         fi
  2640         # The BeOS platform requires special setup.
  2641         SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
  2642         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  2643         ;;
  2644     *-*-darwin* )
  2645         # This could be either full "Mac OS X", or plain "Darwin" which is
  2646         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  2647         # Next line is broken, and a few files below require Mac OS X (full)
  2648         ARCH=macosx
  2649 
  2650         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  2651         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  2652         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  2653 
  2654         CheckVisibilityHidden
  2655         CheckDummyVideo
  2656         CheckDiskAudio
  2657         CheckDummyAudio
  2658         CheckDLOPEN
  2659 
  2660         # Set up files for the shared object loading library
  2661         # (this needs to be done before the dynamic X11 check)
  2662         if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
  2663             AC_DEFINE(SDL_LOADSO_DLCOMPAT)
  2664             SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
  2665             have_loadso=yes
  2666         fi
  2667 
  2668         CheckCOCOA
  2669         CheckX11
  2670         CheckMacGL
  2671         CheckOpenGLX11
  2672         CheckPTHREAD
  2673 
  2674         # Good optimization on Mac OS X, yes...
  2675         EXTRA_CFLAGS="$EXTRA_CFLAGS -falign-loops=16"
  2676 
  2677         # Need this or things might misbuild on a G3.
  2678         EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
  2679 
  2680         # Set up files for the audio library
  2681         if test x$enable_audio = xyes; then
  2682             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO)
  2683             SOURCES="$SOURCES $srcdir/src/audio/macosx/*.c"
  2684             have_audio=yes
  2685         fi
  2686         # Set up files for the joystick library
  2687         if test x$enable_joystick = xyes; then
  2688             AC_DEFINE(SDL_JOYSTICK_IOKIT)
  2689             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  2690             have_joystick=yes
  2691         fi
  2692         # Set up files for the haptic library
  2693         if test x$enable_haptic = xyes; then
  2694             AC_DEFINE(SDL_HAPTIC_IOKIT)
  2695             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  2696             have_haptic=yes
  2697             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  2698         fi
  2699         # Set up files for the power library
  2700         if test x$enable_power = xyes; then
  2701             AC_DEFINE(SDL_POWER_MACOSX)
  2702             SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
  2703             have_power=yes
  2704         fi
  2705         # Set up files for the timer library
  2706         if test x$enable_timers = xyes; then
  2707             AC_DEFINE(SDL_TIMER_UNIX)
  2708             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  2709             have_timers=yes
  2710         fi
  2711         # Set up additional files for the file library
  2712         if test x$enable_file = xyes; then
  2713             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  2714         fi
  2715         # The Mac OS X platform requires special setup.
  2716         EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
  2717         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
  2718         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  2719         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  2720         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  2721         # If audio is used, add the AudioUnit framework
  2722         if test x$enable_audio = xyes; then
  2723             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
  2724         fi
  2725         ;;
  2726     *-riscos)
  2727         ARCH=riscos
  2728         CheckOSS
  2729         CheckPTHREAD
  2730         # Set up files for the video library
  2731         if test x$enable_video = xyes; then
  2732             AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
  2733             SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
  2734             SOURCES="$SOURCES $srcdir/src/video/riscos/*.S"
  2735             have_video=yes
  2736         fi
  2737         # Set up files for the joystick library
  2738         if test x$enable_joystick = xyes; then
  2739             AC_DEFINE(SDL_JOYSTICK_RISCOS)
  2740             SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
  2741             have_joystick=yes
  2742         fi
  2743         # Set up files for the timer library
  2744         if test x$enable_timers = xyes; then
  2745             AC_DEFINE(SDL_TIMER_RISCOS)
  2746             SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
  2747             have_timers=yes
  2748         fi
  2749         # The RISC OS platform requires special setup.
  2750         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
  2751         ;;
  2752     *)
  2753         AC_MSG_ERROR([
  2754 *** Unsupported host:  Please add to configure.in
  2755         ])
  2756         ;;
  2757 esac
  2758 
  2759 # Verify that we have all the platform specific files we need
  2760 
  2761 if test x$have_joystick != xyes; then
  2762     if test x$enable_joystick = xyes; then
  2763         AC_DEFINE(SDL_JOYSTICK_DISABLED)
  2764     fi
  2765     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  2766 fi
  2767 if test x$have_haptic != xyes; then
  2768     if test x$enable_haptic = xyes; then
  2769         AC_DEFINE(SDL_HAPTIC_DISABLED)
  2770     fi
  2771     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  2772 fi
  2773 if test x$have_threads != xyes; then
  2774     if test x$enable_threads = xyes; then
  2775         AC_DEFINE(SDL_THREADS_DISABLED)
  2776     fi
  2777     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  2778 fi
  2779 if test x$have_timers != xyes; then
  2780     if test x$enable_timers = xyes; then
  2781         AC_DEFINE(SDL_TIMERS_DISABLED)
  2782     fi
  2783     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  2784 fi
  2785 if test x$have_loadso != xyes; then
  2786     if test x$enable_loadso = xyes; then
  2787         AC_DEFINE(SDL_LOADSO_DISABLED)
  2788     fi
  2789     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  2790 fi
  2791 if test x$SDLMAIN_SOURCES = x; then
  2792     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  2793 fi
  2794 
  2795 OBJECTS=`echo $SOURCES`
  2796 DEPENDS=`echo $SOURCES`
  2797 for EXT in asm cc m c S; do
  2798     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
  2799     DEPENDS=`echo "$DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT,\\\\
  2800 \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
  2801 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2802 done
  2803 
  2804 VERSION_OBJECTS=`echo $VERSION_SOURCES`
  2805 VERSION_DEPENDS=`echo $VERSION_SOURCES`
  2806 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  2807 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
  2808 \\$(objects)/\\2.o: \\1/\\2.rc\\\\
  2809 	\\$(WINDRES) \\$< \\$@,g"`
  2810 
  2811 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
  2812 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
  2813 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.o,g'`
  2814 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  2815 \\$(objects)/\\2.o: \\1/\\2.c\\\\
  2816 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  2817 
  2818 # Set runtime shared library paths as needed
  2819 
  2820 if test "x$enable_rpath" = "xyes"; then
  2821   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
  2822     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  2823   fi
  2824   if test $ARCH = solaris; then
  2825     SDL_RLD_FLAGS="-R\${libdir}"
  2826   fi
  2827 else
  2828   SDL_RLD_FLAGS=""
  2829 fi
  2830 
  2831 case "$ARCH" in
  2832   macosx)
  2833     # Evil hack to allow static linking on Mac OS X
  2834     SDL_STATIC_LIBS="\${libdir}/libSDL.a $EXTRA_LDFLAGS"
  2835     ;;
  2836   *)
  2837     SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  2838     ;;
  2839 esac
  2840 
  2841 dnl Expand the cflags and libraries needed by apps using SDL
  2842 AC_SUBST(SDL_CFLAGS)
  2843 AC_SUBST(SDL_LIBS)
  2844 AC_SUBST(SDL_STATIC_LIBS)
  2845 AC_SUBST(SDL_RLD_FLAGS)
  2846 if test x$enable_shared = xyes; then
  2847     ENABLE_SHARED_TRUE=
  2848     ENABLE_SHARED_FALSE="#"
  2849 else
  2850     ENABLE_SHARED_TRUE="#"
  2851     ENABLE_SHARED_FALSE=
  2852 fi
  2853 if test x$enable_static = xyes; then
  2854     ENABLE_STATIC_TRUE=
  2855     ENABLE_STATIC_FALSE="#"
  2856 else
  2857     ENABLE_STATIC_TRUE="#"
  2858     ENABLE_STATIC_FALSE=
  2859 fi
  2860 AC_SUBST(ENABLE_SHARED_TRUE)
  2861 AC_SUBST(ENABLE_SHARED_FALSE)
  2862 AC_SUBST(ENABLE_STATIC_TRUE)
  2863 AC_SUBST(ENABLE_STATIC_FALSE)
  2864 
  2865 dnl Expand the sources and objects needed to build the library
  2866 AC_SUBST(ac_aux_dir)
  2867 AC_SUBST(INCLUDE)
  2868 AC_SUBST(OBJECTS)
  2869 AC_SUBST(DEPENDS)
  2870 AC_SUBST(VERSION_OBJECTS)
  2871 AC_SUBST(VERSION_DEPENDS)
  2872 AC_SUBST(SDLMAIN_OBJECTS)
  2873 AC_SUBST(SDLMAIN_DEPENDS)
  2874 AC_SUBST(BUILD_CFLAGS)
  2875 AC_SUBST(EXTRA_CFLAGS)
  2876 AC_SUBST(BUILD_LDFLAGS)
  2877 AC_SUBST(EXTRA_LDFLAGS)
  2878 AC_SUBST(WINDRES)
  2879 
  2880 AC_OUTPUT([
  2881     Makefile sdl-config SDL.spec sdl.pc
  2882 ])