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