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