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