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