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