configure.ac
author Sam Lantinga <slouken@libsdl.org>
Fri, 13 Mar 2020 19:00:22 -0700
changeset 13619 217a7d8a5fef
parent 13609 5abd513b853d
child 13632 49320151ca4d
permissions -rw-r--r--
Fixed crash if manufacturer or product string is NULL
     1 dnl Process this file with autoconf to produce a configure script.
     2 AC_INIT(README.txt)
     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=13
    24 SDL_INTERFACE_AGE=1
    25 SDL_BINARY_AGE=13
    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 PKG_PROG_PKG_CONFIG
    60 
    61 dnl Make sure that srcdir is a full pathname
    62 case "$host" in
    63     *-*-mingw32*)
    64         # Except on msys, where make can't handle full pathnames (bug 1972)
    65         ;;
    66     *)
    67         srcdir=`cd $srcdir && pwd`
    68         ;;
    69 esac
    70 
    71 dnl Set up the compiler and linker flags
    72 INCLUDE="-I$srcdir/include -idirafter $srcdir/src/video/khronos"
    73 if test x$srcdir != x.; then
    74     INCLUDE="-Iinclude $INCLUDE"
    75 elif test -d .hg; then
    76     AC_MSG_ERROR([
    77 *** When building from Mercurial you should configure and build in a
    78     separate directory so you don't clobber SDL_config.h, SDL_revision.h
    79 ])
    80 fi
    81 BASE_CFLAGS=""
    82 BASE_LDFLAGS=""
    83 case "$host" in
    84     *-*-cygwin*)
    85         # We build SDL on cygwin without the UNIX emulation layer
    86         save_CFLAGS="$CFLAGS"
    87         have_no_cygwin=no
    88         AC_MSG_CHECKING(for GCC -mno-cygwin option)
    89         CFLAGS="$save_CFLAGS -mno-cygwin"
    90 
    91         AC_TRY_COMPILE([
    92         ],[
    93         ],[
    94         have_no_cygwin=yes
    95         ])
    96         AC_MSG_RESULT($have_no_cygwin)
    97         CFLAGS="$save_CFLAGS"
    98 
    99         if test x$have_no_cygwin = xyes; then
   100             BASE_CFLAGS="-mno-cygwin"
   101             BASE_LDFLAGS="-mno-cygwin"
   102         fi
   103         BASE_CFLAGS="$BASE_CFLAGS -I/usr/include/mingw"
   104         ;;
   105 esac
   106 # Uncomment the following line if you want to force SDL and applications
   107 # built with it to be compiled for a particular architecture.
   108 #AX_GCC_ARCHFLAG([no], [BASE_CFLAGS="$BASE_CFLAGS $ax_cv_gcc_archflag]")
   109 BUILD_CFLAGS="$CFLAGS $CPPFLAGS -DUSING_GENERATED_CONFIG_H"
   110 # The default optimization for SDL is -O3 (Bug #31)
   111 if test "x$orig_CFLAGS" = x; then
   112     BUILD_CFLAGS=`echo $BUILD_CFLAGS | sed 's/-O2/-O3/'`
   113 fi
   114 EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
   115 BUILD_LDFLAGS="$LDFLAGS"
   116 EXTRA_LDFLAGS="$BASE_LDFLAGS"
   117 ## These are common directories to find software packages
   118 #for path in /usr/freeware /usr/pkg /usr/X11R6 /usr/local; do
   119 #    if test -d $path/include; then
   120 #        EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
   121 #    fi
   122 #    if test -d $path/lib; then
   123 #        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
   124 #    fi
   125 #done
   126 SDL_CFLAGS="$BASE_CFLAGS"
   127 SDL_LIBS="-lSDL2"
   128 if test "x$BASE_LDFLAGS" != x; then
   129     SDL_LIBS="$SDL_LIBS $BASE_LDFLAGS"
   130 fi
   131 if test "x$EXTRA_CFLAGS" != x; then
   132     CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
   133     CFLAGS="$CFLAGS $EXTRA_CFLAGS"
   134 fi
   135 if test "x$EXTRA_LDFLAGS" != x; then
   136     LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
   137 fi
   138 
   139 dnl set this to use on systems that use lib64 instead of lib
   140 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
   141 
   142 dnl Function to find a library in the compiler search path
   143 find_lib()
   144 {
   145     gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   146     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   147     env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
   148     if test "$cross_compiling" = yes; then
   149         host_lib_path=""
   150     else
   151         host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
   152     fi
   153     for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
   154         lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`]
   155         if test x$lib != x; then
   156             echo $lib
   157             return
   158         fi
   159     done
   160     # Try again, this time allowing more than one version digit after the .so
   161     for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
   162         lib=[`ls -- $path/$1 2>/dev/null | sed -e 's,.*/,,' | sort | tail -1`]
   163         if test x$lib != x; then
   164             echo $lib
   165             return
   166         fi
   167     done
   168 }
   169 
   170 dnl Check for compiler characteristics
   171 AC_C_CONST
   172 AC_C_INLINE
   173 AC_C_VOLATILE
   174 
   175 dnl See whether we want assertions for debugging/sanity checking SDL itself.
   176 AC_ARG_ENABLE(assertions,
   177 AS_HELP_STRING([--enable-assertions],
   178                [Enable internal sanity checks (auto/disabled/release/enabled/paranoid) [[default=auto]]]),
   179               , enable_assertions=auto)
   180 case "$enable_assertions" in
   181     auto) # Use optimization settings to determine assertion level
   182         ;;
   183     disabled)
   184         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 0, [ ])
   185         ;;
   186     release)
   187         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 1, [ ])
   188         ;;
   189     enabled)
   190         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 2, [ ])
   191         ;;
   192     paranoid)
   193         AC_DEFINE(SDL_DEFAULT_ASSERT_LEVEL, 3, [ ])
   194         ;;
   195     *)
   196         AC_MSG_ERROR([*** unknown assertion level. stop.])
   197         ;;
   198 esac
   199 
   200 dnl See whether we can use gcc style dependency tracking
   201 AC_ARG_ENABLE(dependency-tracking,
   202 AS_HELP_STRING([--enable-dependency-tracking],
   203                [Use gcc -MMD -MT dependency tracking [[default=yes]]]),
   204               , enable_dependency_tracking=yes)
   205 if test x$enable_dependency_tracking = xyes; then
   206     have_gcc_mmd_mt=no
   207     AC_MSG_CHECKING(for GCC -MMD -MT option)
   208     AC_TRY_COMPILE([
   209     #if !defined(__GNUC__) || __GNUC__ < 3
   210     #error Dependency tracking requires GCC 3.0 or newer
   211     #endif
   212     ],[
   213     ],[
   214     have_gcc_mmd_mt=yes
   215     ])
   216     AC_MSG_RESULT($have_gcc_mmd_mt)
   217 
   218     if test x$have_gcc_mmd_mt = xyes; then
   219         DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
   220     fi
   221 fi
   222 
   223 AC_MSG_CHECKING(for linker option --no-undefined)
   224 have_no_undefined=no
   225 case "$host" in
   226     dnl Skip this on platforms where it is just simply busted.
   227     *-*-openbsd*)
   228         ;;
   229 
   230     *)
   231         save_LDFLAGS="$LDFLAGS"
   232         LDFLAGS="$LDFLAGS -Wl,--no-undefined"
   233         AC_TRY_LINK([
   234         ],[
   235         ],[
   236         have_no_undefined=yes
   237         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--no-undefined"
   238         ])
   239         LDFLAGS="$save_LDFLAGS"
   240         ;;
   241 esac
   242 AC_MSG_RESULT($have_no_undefined)
   243 
   244 AC_MSG_CHECKING(for linker option --dynamicbase)
   245 have_dynamicbase=no
   246 case "$host" in
   247     *)
   248         save_LDFLAGS="$LDFLAGS"
   249         LDFLAGS="$LDFLAGS -Wl,--dynamicbase"
   250         AC_TRY_LINK([
   251         ],[
   252         ],[
   253         have_dynamicbase=yes
   254         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--dynamicbase"
   255         ])
   256         LDFLAGS="$save_LDFLAGS"
   257         ;;
   258 esac
   259 AC_MSG_RESULT($have_dynamicbase)
   260 
   261 AC_MSG_CHECKING(for linker option --nxcompat)
   262 have_nxcompat=no
   263 case "$host" in
   264     *)
   265         save_LDFLAGS="$LDFLAGS"
   266         LDFLAGS="$LDFLAGS -Wl,--nxcompat"
   267         AC_TRY_LINK([
   268         ],[
   269         ],[
   270         have_nxcompat=yes
   271         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--nxcompat"
   272         ])
   273         LDFLAGS="$save_LDFLAGS"
   274         ;;
   275 esac
   276 AC_MSG_RESULT($have_nxcompat)
   277 
   278 AC_MSG_CHECKING(for linker option --high-entropy-va)
   279 have_high_entropy_va=no
   280 case "$host" in
   281     *)
   282         save_LDFLAGS="$LDFLAGS"
   283         LDFLAGS="$LDFLAGS -Wl,--high-entropy-va"
   284         AC_TRY_LINK([
   285         ],[
   286         ],[
   287         have_high_entropy_va=yes
   288         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--high-entropy-va"
   289         ])
   290         LDFLAGS="$save_LDFLAGS"
   291         ;;
   292 esac
   293 AC_MSG_RESULT($have_high_entropy_va)
   294 
   295 dnl See whether we are allowed to use the system C library
   296 AC_ARG_ENABLE(libc,
   297 AS_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]),
   298               , enable_libc=yes)
   299 if test x$enable_libc = xyes; then
   300     AC_DEFINE(HAVE_LIBC, 1, [ ])
   301 
   302     dnl Check for C library headers
   303     AC_HEADER_STDC
   304     AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h wchar.h inttypes.h stdint.h limits.h ctype.h math.h float.h iconv.h signal.h)
   305 
   306     dnl Check for typedefs, structures, etc.
   307     AC_TYPE_SIZE_T
   308 
   309     dnl Check for defines
   310     AC_CHECK_DEFINE(M_PI, math.h)
   311 
   312     dnl Checks for library functions.
   313     case "$host" in
   314     *-*-cygwin* | *-*-mingw32*)
   315         ;;
   316     *)
   317         AC_FUNC_ALLOCA
   318         ;;
   319     esac
   320 
   321     AC_FUNC_MEMCMP
   322     if test x$ac_cv_func_memcmp_working = xyes; then
   323         AC_DEFINE(HAVE_MEMCMP, 1, [ ])
   324     fi
   325     AC_FUNC_STRTOD
   326     if test x$ac_cv_func_strtod = xyes; then
   327         AC_DEFINE(HAVE_STRTOD, 1, [ ])
   328     fi
   329     AC_CHECK_FUNC(mprotect,
   330         AC_TRY_COMPILE([
   331           #include <sys/types.h>
   332           #include <sys/mman.h>
   333         ],[
   334         ],[
   335         AC_DEFINE(HAVE_MPROTECT, 1, [ ])
   336         ]),
   337     )
   338     AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll _Exit)
   339 
   340     AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
   341     AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf fmod fmodf log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
   342 
   343     AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
   344     AC_CHECK_FUNCS(iconv)
   345 
   346     AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE([HAVE_SA_SIGACTION], 1, [ ])], ,[#include <signal.h>])
   347 
   348     dnl Check for additional non-standard headers
   349     AC_CHECK_HEADERS(libunwind.h)
   350 fi
   351 
   352 dnl AC_CHECK_SIZEOF(void*)
   353 
   354 dnl See whether we can use gcc atomic operations on this architecture
   355 AC_ARG_ENABLE(gcc-atomics,
   356 AS_HELP_STRING([--enable-gcc-atomics],
   357                [Use gcc builtin atomics [[default=yes]]]),
   358               , enable_gcc_atomics=yes)
   359 if test x$enable_gcc_atomics = xyes; then
   360     have_gcc_atomics=no
   361     AC_MSG_CHECKING(for GCC builtin atomic operations)
   362     AC_TRY_LINK([
   363     ],[
   364     int a;
   365     void *x, *y, *z;
   366     __sync_lock_test_and_set(&a, 4);
   367     __sync_lock_test_and_set(&x, y);
   368     __sync_fetch_and_add(&a, 1);
   369     __sync_bool_compare_and_swap(&a, 5, 10);
   370     __sync_bool_compare_and_swap(&x, y, z);
   371     ],[
   372     have_gcc_atomics=yes
   373     ])
   374     AC_MSG_RESULT($have_gcc_atomics)
   375 
   376     if test x$have_gcc_atomics = xyes; then
   377         AC_DEFINE(HAVE_GCC_ATOMICS, 1, [ ])
   378     else
   379         # See if we have the minimum operation needed for GCC atomics
   380         AC_TRY_LINK([
   381         ],[
   382         int a;
   383         __sync_lock_test_and_set(&a, 1);
   384         __sync_lock_release(&a);
   385         ],[
   386         have_gcc_sync_lock_test_and_set=yes
   387         ])
   388         if test x$have_gcc_sync_lock_test_and_set = xyes; then
   389             AC_DEFINE(HAVE_GCC_SYNC_LOCK_TEST_AND_SET, 1, [ ])
   390         fi
   391     fi
   392 fi
   393 
   394 # Standard C sources
   395 SOURCES="$SOURCES $srcdir/src/*.c"
   396 SOURCES="$SOURCES $srcdir/src/atomic/*.c"
   397 SOURCES="$SOURCES $srcdir/src/audio/*.c"
   398 SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
   399 SOURCES="$SOURCES $srcdir/src/dynapi/*.c"
   400 SOURCES="$SOURCES $srcdir/src/events/*.c"
   401 SOURCES="$SOURCES $srcdir/src/file/*.c"
   402 SOURCES="$SOURCES $srcdir/src/haptic/*.c"
   403 SOURCES="$SOURCES $srcdir/src/joystick/*.c"
   404 SOURCES="$SOURCES $srcdir/src/libm/*.c"
   405 SOURCES="$SOURCES $srcdir/src/power/*.c"
   406 #SOURCES="$SOURCES $srcdir/src/filesystem/*.c"
   407 SOURCES="$SOURCES $srcdir/src/render/*.c"
   408 SOURCES="$SOURCES $srcdir/src/render/*/*.c"
   409 SOURCES="$SOURCES $srcdir/src/sensor/*.c"
   410 SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
   411 SOURCES="$SOURCES $srcdir/src/thread/*.c"
   412 SOURCES="$SOURCES $srcdir/src/timer/*.c"
   413 SOURCES="$SOURCES $srcdir/src/video/*.c"
   414 SOURCES="$SOURCES $srcdir/src/video/yuv2rgb/*.c"
   415 
   416 dnl Enable/disable various subsystems of the SDL library
   417 
   418 AC_ARG_ENABLE(atomic,
   419 AS_HELP_STRING([--enable-atomic], [Enable the atomic operations subsystem [[default=yes]]]),
   420               , enable_atomic=yes)
   421 if test x$enable_atomic != xyes; then
   422     AC_DEFINE(SDL_ATOMIC_DISABLED, 1, [ ])
   423 else
   424     SUMMARY_modules="${SUMMARY_modules} atomic"
   425 fi
   426 AC_ARG_ENABLE(audio,
   427 AS_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]),
   428               , enable_audio=yes)
   429 if test x$enable_audio != xyes; then
   430     AC_DEFINE(SDL_AUDIO_DISABLED, 1, [ ])
   431 else
   432     SUMMARY_modules="${SUMMARY_modules} audio"
   433 fi
   434 AC_ARG_ENABLE(video,
   435 AS_HELP_STRING([--enable-video], [Enable the video subsystem [[default=yes]]]),
   436               , enable_video=yes)
   437 if test x$enable_video != xyes; then
   438     AC_DEFINE(SDL_VIDEO_DISABLED, 1, [ ])
   439 else
   440     SUMMARY_modules="${SUMMARY_modules} video"
   441 fi
   442 AC_ARG_ENABLE(render,
   443 AS_HELP_STRING([--enable-render], [Enable the render subsystem [[default=yes]]]),
   444               , enable_render=yes)
   445 if test x$enable_render != xyes; then
   446     AC_DEFINE(SDL_RENDER_DISABLED, 1, [ ])
   447 else
   448     SUMMARY_modules="${SUMMARY_modules} render"
   449 fi
   450 AC_ARG_ENABLE(events,
   451 AS_HELP_STRING([--enable-events], [Enable the events subsystem [[default=yes]]]),
   452               , enable_events=yes)
   453 if test x$enable_events != xyes; then
   454     AC_DEFINE(SDL_EVENTS_DISABLED, 1, [ ])
   455 else
   456     SUMMARY_modules="${SUMMARY_modules} events"
   457 fi
   458 AC_ARG_ENABLE(joystick,
   459 AS_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes]]]),
   460               , enable_joystick=yes)
   461 if test x$enable_joystick != xyes; then
   462     AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ])
   463 else
   464     SUMMARY_modules="${SUMMARY_modules} joystick"
   465 fi
   466 AC_ARG_ENABLE(haptic,
   467 AS_HELP_STRING([--enable-haptic], [Enable the haptic (force feedback) subsystem [[default=yes]]]),
   468               , enable_haptic=yes)
   469 if test x$enable_haptic != xyes; then
   470     AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ])
   471 else
   472     SUMMARY_modules="${SUMMARY_modules} haptic"
   473 fi
   474 AC_ARG_ENABLE(sensor,
   475 AS_HELP_STRING([--enable-sensor], [Enable the sensor subsystem [[default=yes]]]),
   476               , enable_sensor=yes)
   477 if test x$enable_sensor != xyes; then
   478     AC_DEFINE(SDL_SENSOR_DISABLED, 1, [ ])
   479 else
   480     SUMMARY_modules="${SUMMARY_modules} sensor"
   481 fi
   482 AC_ARG_ENABLE(power,
   483 AS_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]),
   484               , enable_power=yes)
   485 if test x$enable_power != xyes; then
   486     AC_DEFINE(SDL_POWER_DISABLED, 1, [ ])
   487 else
   488     SUMMARY_modules="${SUMMARY_modules} power"
   489 fi
   490 AC_ARG_ENABLE(filesystem,
   491 AS_HELP_STRING([--enable-filesystem], [Enable the filesystem subsystem [[default=yes]]]),
   492               , enable_filesystem=yes)
   493 if test x$enable_filesystem != xyes; then
   494     AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
   495 else
   496     SUMMARY_modules="${SUMMARY_modules} filesystem"
   497 fi
   498 AC_ARG_ENABLE(threads,
   499 AS_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]),
   500               , enable_threads=yes)
   501 if test x$enable_threads != xyes; then
   502     AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
   503 else
   504     SUMMARY_modules="${SUMMARY_modules} threads"
   505 fi
   506 AC_ARG_ENABLE(timers,
   507 AS_HELP_STRING([--enable-timers], [Enable the timer subsystem [[default=yes]]]),
   508               , enable_timers=yes)
   509 if test x$enable_timers != xyes; then
   510     AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ])
   511 else
   512     SUMMARY_modules="${SUMMARY_modules} timers"
   513 fi
   514 AC_ARG_ENABLE(file,
   515 AS_HELP_STRING([--enable-file], [Enable the file subsystem [[default=yes]]]),
   516               , enable_file=yes)
   517 if test x$enable_file != xyes; then
   518     AC_DEFINE(SDL_FILE_DISABLED, 1, [ ])
   519 else
   520     SUMMARY_modules="${SUMMARY_modules} file"
   521 fi
   522 AC_ARG_ENABLE(loadso,
   523 AS_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [[default=yes]]]),
   524               , enable_loadso=yes)
   525 if test x$enable_loadso != xyes; then
   526     AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
   527 else
   528     SUMMARY_modules="${SUMMARY_modules} loadso"
   529 fi
   530 AC_ARG_ENABLE(cpuinfo,
   531 AS_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [[default=yes]]]),
   532               , enable_cpuinfo=yes)
   533 if test x$enable_cpuinfo != xyes; then
   534     AC_DEFINE(SDL_CPUINFO_DISABLED, 1, [ ])
   535 else
   536     SUMMARY_modules="${SUMMARY_modules} cpuinfo"
   537 fi
   538 AC_ARG_ENABLE(assembly,
   539 AS_HELP_STRING([--enable-assembly], [Enable assembly routines [[default=yes]]]),
   540               , enable_assembly=yes)
   541 if test x$enable_assembly = xyes; then
   542     SUMMARY_modules="${SUMMARY_modules} assembly"
   543 
   544     AC_DEFINE(SDL_ASSEMBLY_ROUTINES, 1, [ ])
   545 
   546     # Make sure that we don't generate floating point code that would
   547     # cause illegal instruction exceptions on older processors
   548     case "$host" in
   549         *-*-darwin*)
   550             # Don't need to worry about Apple hardware, it's all SSE capable
   551             default_ssemath=yes
   552             ;;
   553         *64-*-*)
   554             # x86 64-bit architectures all have SSE instructions
   555             default_ssemath=yes
   556             ;;
   557         *)
   558             default_ssemath=no
   559             ;;
   560     esac
   561     AC_ARG_ENABLE(ssemath,
   562 AS_HELP_STRING([--enable-ssemath], [Allow GCC to use SSE floating point math [[default=maybe]]]),
   563                   , enable_ssemath=$default_ssemath)
   564     if test x$enable_ssemath = xno; then
   565         if test x$have_gcc_sse = xyes -o x$have_gcc_sse2 = xyes -o x$have_gcc_sse3 = xyes; then
   566             EXTRA_CFLAGS="$EXTRA_CFLAGS -mfpmath=387"
   567         fi
   568     fi
   569 
   570     dnl Check for various instruction support
   571     AC_ARG_ENABLE(mmx,
   572 AS_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=yes]]]),
   573                   , enable_mmx=yes)
   574     if test x$enable_mmx = xyes; then
   575         save_CFLAGS="$CFLAGS"
   576         have_gcc_mmx=no
   577         AC_MSG_CHECKING(for GCC -mmmx option)
   578         mmx_CFLAGS="-mmmx"
   579         CFLAGS="$save_CFLAGS $mmx_CFLAGS"
   580 
   581         AC_TRY_COMPILE([
   582         #ifdef __MINGW32__
   583         #include <_mingw.h>
   584         #ifdef __MINGW64_VERSION_MAJOR
   585         #include <intrin.h>
   586         #else
   587         #include <mmintrin.h>
   588         #endif
   589         #else
   590         #include <mmintrin.h>
   591         #endif
   592         #ifndef __MMX__
   593         #error Assembler CPP flag not enabled
   594         #endif
   595         ],[
   596         ],[
   597         have_gcc_mmx=yes
   598         ])
   599         AC_MSG_RESULT($have_gcc_mmx)
   600         CFLAGS="$save_CFLAGS"
   601 
   602         if test x$have_gcc_mmx = xyes; then
   603             EXTRA_CFLAGS="$EXTRA_CFLAGS $mmx_CFLAGS"
   604             SUMMARY_math="${SUMMARY_math} mmx"
   605         fi
   606     fi
   607 
   608     AC_ARG_ENABLE(3dnow,
   609 AS_HELP_STRING([--enable-3dnow], [use 3DNow! assembly routines [[default=yes]]]),
   610                   , enable_3dnow=yes)
   611     if test x$enable_3dnow = xyes; then
   612         save_CFLAGS="$CFLAGS"
   613         have_gcc_3dnow=no
   614         AC_MSG_CHECKING(for GCC -m3dnow option)
   615         amd3dnow_CFLAGS="-m3dnow"
   616         CFLAGS="$save_CFLAGS $amd3dnow_CFLAGS"
   617 
   618         AC_TRY_LINK([
   619         #include <mm3dnow.h>
   620         #ifndef __3dNOW__
   621         #error Assembler CPP flag not enabled
   622         #endif
   623         ],[
   624         void *p = 0;
   625         _m_prefetch(p);
   626         ],[
   627         have_gcc_3dnow=yes
   628         ])
   629         AC_MSG_RESULT($have_gcc_3dnow)
   630         CFLAGS="$save_CFLAGS"
   631 
   632         if test x$have_gcc_3dnow = xyes; then
   633             EXTRA_CFLAGS="$EXTRA_CFLAGS $amd3dnow_CFLAGS"
   634             SUMMARY_math="${SUMMARY_math} 3dnow"
   635         fi
   636     fi
   637 
   638     AC_ARG_ENABLE(sse,
   639 AS_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]),
   640                   , enable_sse=yes)
   641     if test x$enable_sse = xyes; then
   642         save_CFLAGS="$CFLAGS"
   643         have_gcc_sse=no
   644         AC_MSG_CHECKING(for GCC -msse option)
   645         sse_CFLAGS="-msse"
   646         CFLAGS="$save_CFLAGS $sse_CFLAGS"
   647 
   648         AC_TRY_COMPILE([
   649         #ifdef __MINGW32__
   650         #include <_mingw.h>
   651         #ifdef __MINGW64_VERSION_MAJOR
   652         #include <intrin.h>
   653         #else
   654         #include <xmmintrin.h>
   655         #endif
   656         #else
   657         #include <xmmintrin.h>
   658         #endif
   659         #ifndef __SSE__
   660         #error Assembler CPP flag not enabled
   661         #endif
   662         ],[
   663         ],[
   664         have_gcc_sse=yes
   665         ])
   666         AC_MSG_RESULT($have_gcc_sse)
   667         CFLAGS="$save_CFLAGS"
   668 
   669         if test x$have_gcc_sse = xyes; then
   670             EXTRA_CFLAGS="$EXTRA_CFLAGS $sse_CFLAGS"
   671             SUMMARY_math="${SUMMARY_math} sse"
   672         fi
   673     fi
   674 
   675     AC_ARG_ENABLE(sse2,
   676 AS_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=maybe]]]),
   677                   , enable_sse2=$default_ssemath)
   678     if test x$enable_sse2 = xyes; then
   679         save_CFLAGS="$CFLAGS"
   680         have_gcc_sse2=no
   681         AC_MSG_CHECKING(for GCC -msse2 option)
   682         sse2_CFLAGS="-msse2"
   683         CFLAGS="$save_CFLAGS $sse2_CFLAGS"
   684 
   685         AC_TRY_COMPILE([
   686         #ifdef __MINGW32__
   687         #include <_mingw.h>
   688         #ifdef __MINGW64_VERSION_MAJOR
   689         #include <intrin.h>
   690         #else
   691         #include <emmintrin.h>
   692         #endif
   693         #else
   694         #include <emmintrin.h>
   695         #endif
   696         #ifndef __SSE2__
   697         #error Assembler CPP flag not enabled
   698         #endif
   699         ],[
   700         ],[
   701         have_gcc_sse2=yes
   702         ])
   703         AC_MSG_RESULT($have_gcc_sse2)
   704         CFLAGS="$save_CFLAGS"
   705 
   706         if test x$have_gcc_sse2 = xyes; then
   707             EXTRA_CFLAGS="$EXTRA_CFLAGS $sse2_CFLAGS"
   708             SUMMARY_math="${SUMMARY_math} sse2"
   709         fi
   710     fi
   711 
   712     AC_ARG_ENABLE(sse3,
   713 AS_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [[default=maybe]]]),
   714                   , enable_sse3=$default_ssemath)
   715     if test x$enable_sse3 = xyes; then
   716         save_CFLAGS="$CFLAGS"
   717         have_gcc_sse3=no
   718         AC_MSG_CHECKING(for GCC -msse3 option)
   719         sse3_CFLAGS="-msse3"
   720         CFLAGS="$save_CFLAGS $sse3_CFLAGS"
   721 
   722         AC_TRY_COMPILE([
   723         #ifdef __MINGW32__
   724         #include <_mingw.h>
   725         #ifdef __MINGW64_VERSION_MAJOR
   726         #include <intrin.h>
   727         #else
   728         #include <pmmintrin.h>
   729         #endif
   730         #else
   731         #include <pmmintrin.h>
   732         #endif
   733         #ifndef __SSE2__
   734         #error Assembler CPP flag not enabled
   735         #endif
   736         ],[
   737         ],[
   738         have_gcc_sse3=yes
   739         ])
   740         AC_MSG_RESULT($have_gcc_sse3)
   741         CFLAGS="$save_CFLAGS"
   742 
   743         if test x$have_gcc_sse3 = xyes; then
   744             EXTRA_CFLAGS="$EXTRA_CFLAGS $sse3_CFLAGS"
   745             SUMMARY_math="${SUMMARY_math} sse3"
   746         fi
   747     fi
   748 
   749     AC_CHECK_HEADER(immintrin.h,
   750                     have_immintrin_h_hdr=yes,
   751                     have_immintrin_h_hdr=no)
   752     if test x$have_immintrin_h_hdr = xyes; then
   753         AC_DEFINE(HAVE_IMMINTRIN_H, 1, [ ])
   754     fi
   755 
   756     AC_ARG_ENABLE(altivec,
   757 AS_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]),
   758                   , enable_altivec=yes)
   759     if test x$enable_altivec = xyes; then
   760         save_CFLAGS="$CFLAGS"
   761         have_gcc_altivec=no
   762         have_altivec_h_hdr=no
   763         altivec_CFLAGS="-maltivec"
   764         CFLAGS="$save_CFLAGS $altivec_CFLAGS"
   765 
   766         AC_MSG_CHECKING(for Altivec with GCC altivec.h and -maltivec option)
   767         AC_TRY_COMPILE([
   768         #include <altivec.h>
   769         vector unsigned int vzero() {
   770             return vec_splat_u32(0);
   771         }
   772         ],[
   773         ],[
   774         have_gcc_altivec=yes
   775         have_altivec_h_hdr=yes
   776         ])
   777         AC_MSG_RESULT($have_gcc_altivec)
   778 
   779         if test x$have_gcc_altivec = xno; then
   780             AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
   781             AC_TRY_COMPILE([
   782             vector unsigned int vzero() {
   783                 return vec_splat_u32(0);
   784             }
   785             ],[
   786             ],[
   787             have_gcc_altivec=yes
   788             ])
   789             AC_MSG_RESULT($have_gcc_altivec)
   790         fi
   791 
   792         if test x$have_gcc_altivec = xno; then
   793             AC_MSG_CHECKING(for Altivec with GCC altivec.h and -faltivec option)
   794             altivec_CFLAGS="-faltivec"
   795             CFLAGS="$save_CFLAGS $altivec_CFLAGS"
   796             AC_TRY_COMPILE([
   797             #include <altivec.h>
   798             vector unsigned int vzero() {
   799                 return vec_splat_u32(0);
   800             }
   801             ],[
   802             ],[
   803             have_gcc_altivec=yes
   804             have_altivec_h_hdr=yes
   805             ])
   806             AC_MSG_RESULT($have_gcc_altivec)
   807         fi
   808 
   809         if test x$have_gcc_altivec = xno; then
   810             AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
   811             AC_TRY_COMPILE([
   812             vector unsigned int vzero() {
   813                 return vec_splat_u32(0);
   814             }
   815             ],[
   816             ],[
   817             have_gcc_altivec=yes
   818             ])
   819             AC_MSG_RESULT($have_gcc_altivec)
   820         fi
   821         CFLAGS="$save_CFLAGS"
   822 
   823         if test x$have_gcc_altivec = xyes; then
   824             AC_DEFINE(SDL_ALTIVEC_BLITTERS, 1, [ ])
   825             if test x$have_altivec_h_hdr = xyes; then
   826               AC_DEFINE(HAVE_ALTIVEC_H, 1, [ ])
   827             fi
   828             EXTRA_CFLAGS="$EXTRA_CFLAGS $altivec_CFLAGS"
   829             SUMMARY_math="${SUMMARY_math} altivec"
   830         fi
   831     fi
   832 fi
   833 
   834 dnl See if the OSS audio interface is supported
   835 CheckOSS()
   836 {
   837     AC_ARG_ENABLE(oss,
   838 AS_HELP_STRING([--enable-oss], [support the OSS audio API [[default=maybe]]]),
   839                   , enable_oss=maybe)
   840 
   841     # OpenBSD "has" OSS, but it's not really for app use. They want you to
   842     #  use sndio instead. So on there, we default to disabled. You can force
   843     #  it on if you really want, though.
   844     if test x$enable_oss = xmaybe; then
   845         enable_oss=yes
   846         case "$host" in
   847             *-*-openbsd*)
   848                 enable_oss=no;;
   849         esac
   850     fi
   851 
   852     if test x$enable_audio = xyes -a x$enable_oss = xyes; then
   853         AC_MSG_CHECKING(for OSS audio support)
   854         have_oss=no
   855         if test x$have_oss != xyes; then
   856             AC_TRY_COMPILE([
   857               #include <sys/soundcard.h>
   858             ],[
   859               int arg = SNDCTL_DSP_SETFRAGMENT;
   860             ],[
   861             have_oss=yes
   862             ])
   863         fi
   864         if test x$have_oss != xyes; then
   865             AC_TRY_COMPILE([
   866               #include <soundcard.h>
   867             ],[
   868               int arg = SNDCTL_DSP_SETFRAGMENT;
   869             ],[
   870             have_oss=yes
   871             AC_DEFINE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H, 1, [ ])
   872             ])
   873         fi
   874         AC_MSG_RESULT($have_oss)
   875         if test x$have_oss = xyes; then
   876             SUMMARY_audio="${SUMMARY_audio} oss"
   877             AC_DEFINE(SDL_AUDIO_DRIVER_OSS, 1, [ ])
   878             SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c"
   879             have_audio=yes
   880 
   881             # We may need to link with ossaudio emulation library
   882             case "$host" in
   883                 *-*-openbsd*|*-*-netbsd*)
   884                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lossaudio";;
   885             esac
   886         fi
   887     fi
   888 }
   889 
   890 dnl See if the ALSA audio interface is supported
   891 CheckALSA()
   892 {
   893     AC_ARG_ENABLE(alsa,
   894 AS_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]),
   895                   , enable_alsa=yes)
   896     if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
   897         AM_PATH_ALSA(1.0.11, have_alsa=yes, have_alsa=no)
   898         # Restore all flags from before the ALSA detection runs
   899         CFLAGS="$alsa_save_CFLAGS"
   900         LDFLAGS="$alsa_save_LDFLAGS"
   901         LIBS="$alsa_save_LIBS"
   902         if test x$have_alsa = xyes; then
   903             AC_ARG_ENABLE(alsa-shared,
   904 AS_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[default=yes]]]),
   905                           , enable_alsa_shared=yes)
   906             alsa_lib=[`find_lib "libasound.so.*" "$ALSA_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   907 
   908             AC_DEFINE(SDL_AUDIO_DRIVER_ALSA, 1, [ ])
   909             SOURCES="$SOURCES $srcdir/src/audio/alsa/*.c"
   910             EXTRA_CFLAGS="$EXTRA_CFLAGS $ALSA_CFLAGS"
   911             if test x$have_loadso != xyes && \
   912                test x$enable_alsa_shared = xyes; then
   913                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ALSA loading])
   914             fi
   915             if test x$have_loadso = xyes && \
   916                test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
   917                 echo "-- dynamic libasound -> $alsa_lib"
   918                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ALSA_DYNAMIC, "$alsa_lib", [ ])
   919                 SUMMARY_audio="${SUMMARY_audio} alsa(dynamic)"
   920             else
   921                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ALSA_LIBS"
   922                 SUMMARY_audio="${SUMMARY_audio} alsa"
   923             fi
   924             have_audio=yes
   925         fi
   926     fi
   927 }
   928 
   929 dnl Find JACK Audio
   930 CheckJACK()
   931 {
   932     AC_ARG_ENABLE(jack,
   933 AS_HELP_STRING([--enable-jack], [use JACK audio [[default=yes]]]),
   934                   , enable_jack=yes)
   935     if test x$enable_audio = xyes -a x$enable_jack = xyes; then
   936         PKG_CHECK_MODULES([JACK], [jack >= 0.125], audio_jack=yes, audio_jack=no)
   937 
   938         if test x$audio_jack = xyes; then
   939             AC_ARG_ENABLE(jack-shared,
   940 AS_HELP_STRING([--enable-jack-shared], [dynamically load JACK audio support [[default=yes]]]),
   941                           , enable_jack_shared=yes)
   942             jack_lib=[`find_lib "libjack.so.*" "$JACK_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   943 
   944             AC_DEFINE(SDL_AUDIO_DRIVER_JACK, 1, [ ])
   945             SOURCES="$SOURCES $srcdir/src/audio/jack/*.c"
   946             EXTRA_CFLAGS="$EXTRA_CFLAGS $JACK_CFLAGS"
   947             if test x$have_loadso != xyes && \
   948                test x$enable_jack_shared = xyes; then
   949                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic JACK audio loading])
   950             fi
   951             if test x$have_loadso = xyes && \
   952                test x$enable_jack_shared = xyes && test x$jack_lib != x; then
   953                 echo "-- dynamic libjack -> $jack_lib"
   954                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_JACK_DYNAMIC, "$jack_lib", [ ])
   955                 SUMMARY_audio="${SUMMARY_audio} jack(dynamic)"
   956 
   957                 case "$host" in
   958                     # On Solaris, jack must be linked deferred explicitly
   959                     # to prevent undefined symbol failures.
   960                     *-*-solaris*)
   961                         JACK_LIBS=`echo $JACK_LIBS | sed 's/\-l/-Wl,-l/g'`
   962                         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-zdeferred $JACK_LIBS -Wl,-znodeferred"
   963                 esac
   964             else
   965                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $JACK_LIBS"
   966                 SUMMARY_audio="${SUMMARY_audio} jack"
   967             fi
   968             have_audio=yes
   969         fi
   970     fi
   971 }
   972 
   973 dnl Find the ESD includes and libraries
   974 CheckESD()
   975 {
   976     AC_ARG_ENABLE(esd,
   977 AS_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [[default=yes]]]),
   978                   , enable_esd=yes)
   979     if test x$enable_audio = xyes -a x$enable_esd = xyes; then
   980         AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
   981         if test x$have_esd = xyes; then
   982             AC_ARG_ENABLE(esd-shared,
   983 AS_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]),
   984                           , enable_esd_shared=yes)
   985             esd_lib=[`find_lib "libesd.so.*" "$ESD_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
   986 
   987             AC_DEFINE(SDL_AUDIO_DRIVER_ESD, 1, [ ])
   988             SOURCES="$SOURCES $srcdir/src/audio/esd/*.c"
   989             EXTRA_CFLAGS="$EXTRA_CFLAGS $ESD_CFLAGS"
   990             if test x$have_loadso != xyes && \
   991                test x$enable_esd_shared = xyes; then
   992                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ESD loading])
   993             fi
   994             if test x$have_loadso = xyes && \
   995                test x$enable_esd_shared = xyes && test x$esd_lib != x; then
   996                 echo "-- dynamic libesd -> $esd_lib"
   997                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ESD_DYNAMIC, "$esd_lib", [ ])
   998                 SUMMARY_audio="${SUMMARY_audio} esd(dynamic)"
   999             else
  1000                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ESD_LIBS"
  1001                 SUMMARY_audio="${SUMMARY_audio} esd"
  1002             fi
  1003             have_audio=yes
  1004         fi
  1005     fi
  1006 }
  1007 
  1008 dnl Find PulseAudio
  1009 CheckPulseAudio()
  1010 {
  1011     AC_ARG_ENABLE(pulseaudio,
  1012 AS_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]),
  1013                   , enable_pulseaudio=yes)
  1014     if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then
  1015         PKG_CHECK_MODULES([PULSEAUDIO], [libpulse-simple >= 0.9], audio_pulseaudio=yes, audio_pulseaudio=no)
  1016 
  1017         if test x$audio_pulseaudio = xyes; then
  1018             AC_ARG_ENABLE(pulseaudio-shared,
  1019 AS_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]),
  1020                           , enable_pulseaudio_shared=yes)
  1021             pulseaudio_lib=[`find_lib "libpulse-simple.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1022 
  1023             AC_DEFINE(SDL_AUDIO_DRIVER_PULSEAUDIO, 1, [ ])
  1024             SOURCES="$SOURCES $srcdir/src/audio/pulseaudio/*.c"
  1025             EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSEAUDIO_CFLAGS"
  1026             if test x$have_loadso != xyes && \
  1027                test x$enable_pulseaudio_shared = xyes; then
  1028                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic PulseAudio loading])
  1029             fi
  1030             if test x$have_loadso = xyes && \
  1031                test x$enable_pulseaudio_shared = xyes && test x$pulseaudio_lib != x; then
  1032                 echo "-- dynamic libpulse-simple -> $pulseaudio_lib"
  1033                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC, "$pulseaudio_lib", [ ])
  1034                 SUMMARY_audio="${SUMMARY_audio} pulse(dynamic)"
  1035 
  1036                 case "$host" in
  1037                     # On Solaris, pulseaudio must be linked deferred explicitly
  1038                     # to prevent undefined symbol failures.
  1039                     *-*-solaris*)
  1040                         PULSEAUDIO_LIBS=`echo $PULSEAUDIO_LIBS | sed 's/\-l/-Wl,-l/g'`
  1041                         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-zdeferred $PULSEAUDIO_LIBS -Wl,-znodeferred"
  1042                 esac
  1043             else
  1044                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSEAUDIO_LIBS"
  1045                 SUMMARY_audio="${SUMMARY_audio} pulse"
  1046             fi
  1047             have_audio=yes
  1048         fi
  1049     fi
  1050 }
  1051 
  1052 CheckARTSC()
  1053 {
  1054     AC_ARG_ENABLE(arts,
  1055 AS_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [[default=yes]]]),
  1056                   , enable_arts=yes)
  1057     if test x$enable_audio = xyes -a x$enable_arts = xyes; then
  1058         AC_PATH_PROG(ARTSCONFIG, artsc-config)
  1059         if test x$ARTSCONFIG = x -o x$ARTSCONFIG = x'"$ARTSCONFIG"'; then
  1060             : # arts isn't installed
  1061         else
  1062             ARTS_CFLAGS=`$ARTSCONFIG --cflags`
  1063             ARTS_LIBS=`$ARTSCONFIG --libs`
  1064             AC_MSG_CHECKING(for aRts development environment)
  1065             audio_arts=no
  1066             save_CFLAGS="$CFLAGS"
  1067             CFLAGS="$CFLAGS $ARTS_CFLAGS"
  1068             AC_TRY_COMPILE([
  1069              #include <artsc.h>
  1070             ],[
  1071              arts_stream_t stream;
  1072             ],[
  1073             audio_arts=yes
  1074             ])
  1075             CFLAGS="$save_CFLAGS"
  1076             AC_MSG_RESULT($audio_arts)
  1077             if test x$audio_arts = xyes; then
  1078                 AC_ARG_ENABLE(arts-shared,
  1079 AS_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [[default=yes]]]),
  1080                               , enable_arts_shared=yes)
  1081                 arts_lib=[`find_lib "libartsc.so.*" "$ARTS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1082 
  1083                 AC_DEFINE(SDL_AUDIO_DRIVER_ARTS, 1, [ ])
  1084                 SOURCES="$SOURCES $srcdir/src/audio/arts/*.c"
  1085                 EXTRA_CFLAGS="$EXTRA_CFLAGS $ARTS_CFLAGS"
  1086                 if test x$have_loadso != xyes && \
  1087                    test x$enable_arts_shared = xyes; then
  1088                     AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ARTS loading])
  1089                 fi
  1090                 if test x$have_loadso = xyes && \
  1091                    test x$enable_arts_shared = xyes && test x$arts_lib != x; then
  1092                     echo "-- dynamic libartsc -> $arts_lib"
  1093                     AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ARTS_DYNAMIC, "$arts_lib", [ ])
  1094                     SUMMARY_audio="${SUMMARY_audio} arts(dynamic)"
  1095                 else
  1096                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARTS_LIBS"
  1097                     SUMMARY_audio="${SUMMARY_audio} arts"
  1098                 fi
  1099                 have_audio=yes
  1100             fi
  1101         fi
  1102     fi
  1103 }
  1104 
  1105 dnl See if the NAS audio interface is supported
  1106 CheckNAS()
  1107 {
  1108     AC_ARG_ENABLE(nas,
  1109 AS_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]),
  1110                   , enable_nas=yes)
  1111     if test x$enable_audio = xyes -a x$enable_nas = xyes; then
  1112         AC_CHECK_HEADER(audio/audiolib.h, have_nas_hdr=yes)
  1113         AC_CHECK_LIB(audio, AuOpenServer, have_nas_lib=yes)
  1114 
  1115         AC_MSG_CHECKING(for NAS audio support)
  1116         have_nas=no
  1117 
  1118         if test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then
  1119             have_nas=yes
  1120             NAS_LIBS="-laudio"
  1121 
  1122         elif test -r /usr/X11R6/include/audio/audiolib.h; then
  1123             have_nas=yes
  1124             NAS_CFLAGS="-I/usr/X11R6/include/"
  1125             NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
  1126 
  1127         fi
  1128 
  1129         AC_MSG_RESULT($have_nas)
  1130 
  1131         if test x$have_nas = xyes; then
  1132             AC_ARG_ENABLE(nas-shared,
  1133 AS_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [[default=yes]]]),
  1134                           , enable_nas_shared=yes)
  1135             nas_lib=[`find_lib "libaudio.so.*" "$NAS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1136 
  1137             if test x$have_loadso != xyes && \
  1138                test x$enable_nas_shared = xyes; then
  1139                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic NAS loading])
  1140             fi
  1141             if test x$have_loadso = xyes && \
  1142                test x$enable_nas_shared = xyes && test x$nas_lib != x; then
  1143                 echo "-- dynamic libaudio -> $nas_lib"
  1144                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_NAS_DYNAMIC, "$nas_lib", [ ])
  1145                 SUMMARY_audio="${SUMMARY_audio} nas(dynamic)"
  1146             else
  1147                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
  1148                 SUMMARY_audio="${SUMMARY_audio} nas"
  1149             fi
  1150 
  1151             AC_DEFINE(SDL_AUDIO_DRIVER_NAS, 1, [ ])
  1152             SOURCES="$SOURCES $srcdir/src/audio/nas/*.c"
  1153             EXTRA_CFLAGS="$EXTRA_CFLAGS $NAS_CFLAGS"
  1154             have_audio=yes
  1155         fi
  1156     fi
  1157 }
  1158 
  1159 dnl See if the sndio audio interface is supported
  1160 CheckSNDIO()
  1161 {
  1162     AC_ARG_ENABLE(sndio,
  1163 AS_HELP_STRING([--enable-sndio], [support the sndio audio API [[default=yes]]]),
  1164                   , enable_sndio=yes)
  1165     if test x$enable_audio = xyes -a x$enable_sndio = xyes; then
  1166         AC_CHECK_HEADER(sndio.h, have_sndio_hdr=yes)
  1167         AC_CHECK_LIB(sndio, sio_open, have_sndio_lib=yes)
  1168 
  1169         AC_MSG_CHECKING(for sndio audio support)
  1170         have_sndio=no
  1171 
  1172         if test x$have_sndio_hdr = xyes -a x$have_sndio_lib = xyes; then
  1173             have_sndio=yes
  1174             SNDIO_LIBS="-lsndio"
  1175         fi
  1176 
  1177         AC_MSG_RESULT($have_sndio)
  1178 
  1179         if test x$have_sndio = xyes; then
  1180             AC_ARG_ENABLE(sndio-shared,
  1181 AS_HELP_STRING([--enable-sndio-shared], [dynamically load sndio audio support [[default=yes]]]),
  1182                           , enable_sndio_shared=yes)
  1183             sndio_lib=[`find_lib "libsndio.so.*" "$SNDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1184 
  1185             if test x$have_loadso != xyes && \
  1186                test x$enable_sndio_shared = xyes; then
  1187                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic sndio loading])
  1188             fi
  1189             if test x$have_loadso = xyes && \
  1190                test x$enable_sndio_shared = xyes && test x$sndio_lib != x; then
  1191                 echo "-- dynamic libsndio -> $sndio_lib"
  1192                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC, "$sndio_lib", [ ])
  1193                 SUMMARY_audio="${SUMMARY_audio} sndio(dynamic)"
  1194             else
  1195                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SNDIO_LIBS"
  1196                 SUMMARY_audio="${SUMMARY_audio} sndio"
  1197             fi
  1198 
  1199             AC_DEFINE(SDL_AUDIO_DRIVER_SNDIO, 1, [ ])
  1200             SOURCES="$SOURCES $srcdir/src/audio/sndio/*.c"
  1201             EXTRA_CFLAGS="$EXTRA_CFLAGS $SNDIO_CFLAGS"
  1202             have_audio=yes
  1203         fi
  1204     fi
  1205 }
  1206 
  1207 dnl Find FusionSound
  1208 CheckFusionSound()
  1209 {
  1210     AC_ARG_ENABLE(fusionsound,
  1211 AS_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
  1212                   , enable_fusionsound=no)
  1213     if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
  1214         PKG_CHECK_MODULES([FUSIONSOUND], [fusionsound >= 1.1.1], fusionsound=yes, fusionsound=no)
  1215 
  1216         if test x$fusionsound = xyes; then
  1217             AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND, 1, [ ])
  1218             SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
  1219             EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
  1220             
  1221             AC_ARG_ENABLE(fusionsound-shared,
  1222 AS_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
  1223                           , enable_fusionsound_shared=yes)
  1224             fusionsound_shared=no
  1225             AC_MSG_CHECKING(for FusionSound dynamic loading support)
  1226             if test x$have_loadso != xyes && \
  1227                test x$enable_fusionsound_shared = xyes; then
  1228                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
  1229             fi
  1230             if test x$have_loadso = xyes && \
  1231                test x$enable_fusionsound_shared = xyes; then
  1232                 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so", [ ])
  1233                 fusionsound_shared=yes
  1234                 SUMMARY_audio="${SUMMARY_audio} fusionsound(dynamic)"
  1235             else
  1236                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
  1237                 SUMMARY_audio="${SUMMARY_audio} fusionsound"
  1238             fi
  1239             AC_MSG_RESULT($fusionsound_shared)
  1240             
  1241             have_audio=yes
  1242         fi
  1243     fi
  1244 }
  1245 
  1246 dnl rcg07142001 See if the user wants the disk writer audio driver...
  1247 CheckDiskAudio()
  1248 {
  1249     AC_ARG_ENABLE(diskaudio,
  1250 AS_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [[default=yes]]]),
  1251                   , enable_diskaudio=yes)
  1252     if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
  1253         AC_DEFINE(SDL_AUDIO_DRIVER_DISK, 1, [ ])
  1254         SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
  1255         SUMMARY_audio="${SUMMARY_audio} disk"
  1256     fi
  1257 }
  1258 
  1259 dnl rcg03142006 See if the user wants the dummy audio driver...
  1260 CheckDummyAudio()
  1261 {
  1262     AC_ARG_ENABLE(dummyaudio,
  1263 AS_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=yes]]]),
  1264                   , enable_dummyaudio=yes)
  1265     if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then
  1266         AC_DEFINE(SDL_AUDIO_DRIVER_DUMMY, 1, [ ])
  1267         SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c"
  1268         SUMMARY_audio="${SUMMARY_audio} dummy"
  1269     fi
  1270 }
  1271 
  1272 dnl See if libsamplerate is available
  1273 CheckLibSampleRate()
  1274 {
  1275     AC_ARG_ENABLE(libsamplerate,
  1276 AS_HELP_STRING([--enable-libsamplerate], [use libsamplerate for audio rate conversion [[default=yes]]]),
  1277                   , enable_libsamplerate=yes)
  1278     if test x$enable_libsamplerate = xyes; then
  1279         AC_CHECK_HEADER(samplerate.h,
  1280                         have_samplerate_h_hdr=yes,
  1281                         have_samplerate_h_hdr=no)
  1282         if test x$have_samplerate_h_hdr = xyes; then
  1283             AC_DEFINE(HAVE_LIBSAMPLERATE_H, 1, [ ])
  1284 
  1285             AC_ARG_ENABLE(libsamplerate-shared,
  1286 AS_HELP_STRING([--enable-libsamplerate-shared], [dynamically load libsamplerate [[default=yes]]]),
  1287                           , enable_libsamplerate_shared=yes)
  1288 
  1289             samplerate_lib=[`find_lib "libsamplerate.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
  1290 
  1291             if test x$have_loadso != xyes && \
  1292                test x$enable_libsamplerate_shared = xyes; then
  1293                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic libsamplerate loading])
  1294             fi
  1295             if test x$have_loadso = xyes && \
  1296                test x$enable_libsamplerate_shared = xyes && test x$samplerate_lib != x; then
  1297                 echo "-- dynamic libsamplerate -> $samplerate_lib"
  1298                 AC_DEFINE_UNQUOTED(SDL_LIBSAMPLERATE_DYNAMIC, "$samplerate_lib", [ ])
  1299             else
  1300                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lsamplerate"
  1301             fi
  1302         fi
  1303     fi
  1304 }
  1305 
  1306 dnl Check for ARM instruction support using gas syntax
  1307 CheckARM()
  1308 {
  1309     AC_ARG_ENABLE(arm-simd,
  1310 AC_HELP_STRING([--enable-arm-simd], [use SIMD assembly blitters on ARM [[default=yes]]]),
  1311                   enable_arm_simd=$enableval, enable_arm_simd=yes)
  1312     if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_arm_simd = xyes; then
  1313         save_CFLAGS="$CFLAGS"
  1314         have_arm_simd=no
  1315         CFLAGS="-x assembler-with-cpp $CFLAGS"
  1316         
  1317         AC_MSG_CHECKING(for ARM SIMD)
  1318         AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  1319         .text
  1320         .arch armv6
  1321         .object_arch armv4
  1322         .arm
  1323         .altmacro
  1324         #ifndef __ARM_EABI__
  1325         #error EABI is required (to be sure that calling conventions are compatible)
  1326         #endif
  1327         pld [r0]
  1328         uqadd8 r0, r0, r0
  1329         ]])], have_arm_simd=yes)
  1330         AC_MSG_RESULT($have_arm_simd)
  1331         
  1332         CFLAGS="$save_CFLAGS"
  1333         
  1334         if test x$have_arm_simd = xyes; then
  1335             AC_DEFINE(SDL_ARM_SIMD_BLITTERS)
  1336 dnl            SOURCES="$SOURCES $srcdir/src/video/arm/pixman-arm-simd*.c"
  1337             SOURCES="$SOURCES $srcdir/src/video/arm/pixman-arm-simd*.S"
  1338             WARN_ABOUT_ARM_SIMD_ASM_MIT="yes"
  1339         fi
  1340     fi
  1341 }
  1342 
  1343 dnl Check for ARM NEON instruction support using gas syntax
  1344 CheckNEON()
  1345 {
  1346     AC_ARG_ENABLE(arm-neon,
  1347 AC_HELP_STRING([--enable-arm-neon], [use NEON assembly blitters on ARM [[default=no]]]),
  1348                   enable_arm_neon=$enableval, enable_arm_neon=no)
  1349     if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_arm_neon = xyes; then
  1350         save_CFLAGS="$CFLAGS"
  1351         have_arm_neon=no
  1352         CFLAGS="-x assembler-with-cpp $CFLAGS"
  1353         
  1354         AC_MSG_CHECKING(for ARM NEON)
  1355         AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  1356         .text
  1357         .fpu neon
  1358         .arch armv7a
  1359         .object_arch armv4
  1360         .eabi_attribute 10, 0
  1361         .arm
  1362         .altmacro
  1363         #ifndef __ARM_EABI__
  1364         #error EABI is required (to be sure that calling conventions are compatible)
  1365         #endif
  1366         pld [r0]
  1367         vmovn.u16 d0, q0
  1368         ]])], have_arm_neon=yes)
  1369         AC_MSG_RESULT($have_arm_neon)
  1370         
  1371         CFLAGS="$save_CFLAGS"
  1372         
  1373         if test x$have_arm_neon = xyes; then
  1374             AC_DEFINE(SDL_ARM_NEON_BLITTERS)
  1375 dnl            SOURCES="$SOURCES $srcdir/src/video/arm/pixman-arm-neon*.c"
  1376             SOURCES="$SOURCES $srcdir/src/video/arm/pixman-arm-neon*.S"
  1377             WARN_ABOUT_ARM_NEON_ASM_MIT="yes"
  1378         fi
  1379     fi
  1380 }
  1381 
  1382 dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
  1383 dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
  1384 CheckVisibilityHidden()
  1385 {
  1386     AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
  1387     have_gcc_fvisibility=no
  1388 
  1389     visibility_CFLAGS="-fvisibility=hidden"
  1390     save_CFLAGS="$CFLAGS"
  1391     CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
  1392     AC_TRY_COMPILE([
  1393     #if !defined(__GNUC__) || __GNUC__ < 4
  1394     #error SDL only uses visibility attributes in GCC 4 or newer
  1395     #endif
  1396     ],[
  1397     ],[
  1398     have_gcc_fvisibility=yes
  1399     ])
  1400     AC_MSG_RESULT($have_gcc_fvisibility)
  1401     CFLAGS="$save_CFLAGS"
  1402 
  1403     if test x$have_gcc_fvisibility = xyes; then
  1404         EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
  1405     fi
  1406 }
  1407 
  1408 dnl See if GCC's -fno-strict-aliasingis supported.
  1409 dnl  Reference: https://bugzilla.libsdl.org/show_bug.cgi?id=4254
  1410 CheckNoStrictAliasing()
  1411 {
  1412     AC_MSG_CHECKING(for GCC -fno-strict-aliasing option)
  1413     have_gcc_no_strict_aliasing=no
  1414 
  1415     save_CFLAGS="$CFLAGS"
  1416     CFLAGS="$save_CFLAGS -fno-strict-aliasing"
  1417     AC_TRY_COMPILE([
  1418     int x = 0;
  1419     ],[
  1420     ],[
  1421     have_gcc_no_strict_aliasing=yes
  1422     ])
  1423     AC_MSG_RESULT($have_gcc_no_strict_aliasing)
  1424     CFLAGS="$save_CFLAGS"
  1425 
  1426     if test x$have_gcc_no_strict_aliasing = xyes; then
  1427         EXTRA_CFLAGS="$EXTRA_CFLAGS -fno-strict-aliasing"
  1428     fi
  1429 }
  1430 
  1431 dnl See if GCC's -mpreferred-stack-boundary is supported.
  1432 dnl  Reference: http://bugzilla.libsdl.org/show_bug.cgi?id=1296
  1433 CheckStackBoundary()
  1434 {
  1435     AC_MSG_CHECKING(for GCC -mpreferred-stack-boundary option)
  1436     have_gcc_preferred_stack_boundary=no
  1437 
  1438     save_CFLAGS="$CFLAGS"
  1439     CFLAGS="$save_CFLAGS -mpreferred-stack-boundary=2"
  1440     AC_TRY_COMPILE([
  1441     int x = 0;
  1442     ],[
  1443     ],[
  1444     have_gcc_preferred_stack_boundary=yes
  1445     ])
  1446     AC_MSG_RESULT($have_gcc_preferred_stack_boundary)
  1447     CFLAGS="$save_CFLAGS"
  1448 
  1449     if test x$have_gcc_preferred_stack_boundary = xyes; then
  1450         EXTRA_CFLAGS="$EXTRA_CFLAGS -mpreferred-stack-boundary=2"
  1451     fi
  1452 }
  1453 
  1454 dnl See if GCC's -Wdeclaration-after-statement is supported.
  1455 dnl  This lets us catch things that would fail on a C89 compiler when using
  1456 dnl  a modern GCC.
  1457 CheckDeclarationAfterStatement()
  1458 {
  1459     AC_MSG_CHECKING(for GCC -Wdeclaration-after-statement option)
  1460     have_gcc_declaration_after_statement=no
  1461 
  1462     save_CFLAGS="$CFLAGS"
  1463     CFLAGS="$save_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement"
  1464     AC_TRY_COMPILE([
  1465     int x = 0;
  1466     ],[
  1467     ],[
  1468     have_gcc_declaration_after_statement=yes
  1469     ])
  1470     AC_MSG_RESULT($have_gcc_declaration_after_statement)
  1471     CFLAGS="$save_CFLAGS"
  1472 
  1473     if test x$have_gcc_declaration_after_statement = xyes; then
  1474         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement"
  1475     fi
  1476 }
  1477 
  1478 dnl See if GCC's -Wall is supported.
  1479 CheckWarnAll()
  1480 {
  1481     AC_MSG_CHECKING(for GCC -Wall option)
  1482     have_gcc_Wall=no
  1483 
  1484     save_CFLAGS="$CFLAGS"
  1485     CFLAGS="$save_CFLAGS -Wall"
  1486     AC_TRY_COMPILE([
  1487     int x = 0;
  1488     ],[
  1489     ],[
  1490     have_gcc_Wall=yes
  1491     ])
  1492     AC_MSG_RESULT($have_gcc_Wall)
  1493     CFLAGS="$save_CFLAGS"
  1494 
  1495     if test x$have_gcc_Wall = xyes; then
  1496         EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
  1497 
  1498         dnl Haiku headers use multicharacter constants all over the place. Ignore these warnings when using -Wall.
  1499         AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
  1500         need_gcc_Wno_multichar=no
  1501         case "$host" in
  1502             *-*-haiku*)
  1503                 need_gcc_Wno_multichar=yes
  1504                 ;;
  1505         esac
  1506         AC_MSG_RESULT($need_gcc_Wno_multichar)
  1507         if test x$need_gcc_Wno_multichar = xyes; then
  1508             EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar"
  1509         fi
  1510     fi
  1511 }
  1512 
  1513 dnl Check for Wayland
  1514 CheckWayland()
  1515 {
  1516     AC_ARG_ENABLE(video-wayland,
  1517 AS_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]),
  1518                   ,enable_video_wayland=yes)
  1519 
  1520     AC_ARG_ENABLE(video-wayland-qt-touch,
  1521 AS_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for Wayland video driver [[default=yes]]]),
  1522                   ,enable_video_wayland_qt_touch=yes)
  1523 
  1524     if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
  1525         AC_MSG_CHECKING(for Wayland support)
  1526         video_wayland=no
  1527         if  test x$video_opengl_egl = xyes && \
  1528             test x$video_opengles_v2 = xyes; then
  1529             if $PKG_CONFIG --exists wayland-client wayland-scanner wayland-protocols wayland-egl wayland-cursor egl xkbcommon ; then
  1530                 WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon`
  1531                 WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon`
  1532                 WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
  1533                 video_wayland=yes
  1534             fi
  1535         fi
  1536         AC_MSG_RESULT($video_wayland)
  1537 
  1538         if test x$video_wayland = xyes; then
  1539             AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND, 1, [ ])
  1540             if test x$enable_video_wayland_qt_touch = xyes; then
  1541                 AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH, 1, [ ])
  1542             fi
  1543 
  1544             WAYLAND_SOURCES="$srcdir/src/video/wayland/*.c"
  1545             SOURCES="$SOURCES $WAYLAND_SOURCES"
  1546             EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)"
  1547             AC_ARG_ENABLE(wayland-shared,
  1548 AS_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[default=maybe]]]),
  1549                           , enable_wayland_shared=maybe)
  1550 
  1551             dnl FIXME: Do BSD and OS X need special cases?
  1552             case "$host" in
  1553                 *)
  1554                     wayland_client_lib=[`find_lib "libwayland-client.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1555                     wayland_egl_lib=[`find_lib "libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1556                     if test x$wayland_egl_lib = x; then
  1557                         dnl This works in Ubuntu 13.10, maybe others
  1558                         wayland_egl_lib=[`find_lib "mesa-egl/libwayland-egl.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1559                     fi
  1560                     wayland_cursor_lib=[`find_lib "libwayland-cursor.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1561                     xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$WAYLAND_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
  1562                     ;;
  1563             esac
  1564 
  1565             if test x$enable_wayland_shared = xmaybe; then
  1566                 enable_wayland_shared=yes
  1567             fi
  1568             if test x$have_loadso != xyes && \
  1569                test x$enable_wayland_shared = xyes; then
  1570                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Wayland loading])
  1571                 enable_wayland_shared=no
  1572             fi
  1573             if test x$have_loadso = xyes && \
  1574                test x$enable_wayland_shared = xyes && \
  1575                test x$wayland_client_lib != x && \
  1576                test x$wayland_egl_lib != x && \
  1577                test x$wayland_cursor_lib != x && \
  1578                test x$xkbcommon_lib != x; then
  1579                 echo "-- dynamic libwayland-client -> $wayland_client_lib"
  1580                 echo "-- dynamic libwayland-egl -> $wayland_egl_lib"
  1581                 echo "-- dynamic libwayland-cursor -> $wayland_cursor_lib"
  1582                 echo "-- dynamic libxkbcommon -> $xkbcommon_lib"
  1583                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC, "$wayland_client_lib", [ ])
  1584                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL, "$wayland_egl_lib", [ ])
  1585                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR, "$wayland_cursor_lib", [ ])
  1586                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ])
  1587                 SUMMARY_video="${SUMMARY_video} wayland(dynamic)"
  1588             else
  1589                 enable_wayland_shared=no
  1590                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
  1591                 SUMMARY_video="${SUMMARY_video} wayland"
  1592             fi
  1593             have_video=yes
  1594         fi
  1595     fi
  1596 }
  1597 
  1598 
  1599 dnl Check for Native Client stuff
  1600 CheckNativeClient()
  1601 {
  1602         AC_TRY_COMPILE([
  1603           #if !defined(__native_client__)
  1604           #error "NO NACL"
  1605           #endif
  1606         ],[
  1607         ],[
  1608         AC_DEFINE(SDL_VIDEO_DRIVER_NACL, 1, [ ])
  1609         AC_DEFINE(SDL_AUDIO_DRIVER_NACL, 1, [ ])
  1610         AC_DEFINE(HAVE_POW, 1, [ ])
  1611         AC_DEFINE(HAVE_OPENGLES2, 1, [ ])
  1612         AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  1613         AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  1614 
  1615         SDL_LIBS="-lppapi_simple -lppapi_gles2 $SDL_LIBS"
  1616 
  1617         SDLMAIN_SOURCES="$srcdir/src/main/nacl/*.c"
  1618         SOURCES="$SOURCES $srcdir/src/audio/nacl/*.c"
  1619         SUMMARY_audio="${SUMMARY_audio} nacl"
  1620         SOURCES="$SOURCES $srcdir/src/video/nacl/*.c"
  1621         SUMMARY_video="${SUMMARY_video} nacl opengles2"
  1622         ])
  1623 }
  1624 
  1625 
  1626 CheckRPI()
  1627 {
  1628     AC_ARG_ENABLE(video-rpi,
  1629 AS_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=yes]]]),
  1630                   , enable_video_rpi=yes)
  1631     if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then
  1632         PKG_CHECK_MODULES([RPI], [bcm_host brcmegl], video_rpi=yes, video_rpi=no)
  1633 
  1634         if test x$video_rpi = xno; then
  1635             if test x$ARCH = xnetbsd; then
  1636                 RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
  1637                 RPI_LIBS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
  1638             else
  1639                 RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
  1640                 RPI_LIBS="-Wl,-rpath,/opt/vc/lib -L/opt/vc/lib -lbcm_host"
  1641             fi
  1642         fi
  1643 
  1644         # Save the original compiler flags and libraries
  1645         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  1646 
  1647         # Add the Raspberry Pi compiler flags and libraries
  1648         CFLAGS="$CFLAGS $RPI_CFLAGS"; LIBS="$LIBS $RPI_LIBS"
  1649 
  1650         AC_MSG_CHECKING(for Raspberry Pi)
  1651         have_video_rpi=no
  1652         AC_TRY_LINK([
  1653           #include <bcm_host.h>
  1654         ],[
  1655           bcm_host_init();
  1656         ],[
  1657         have_video_rpi=yes
  1658         ],[
  1659         ])
  1660         AC_MSG_RESULT($have_video_rpi)
  1661 
  1662         # Restore the compiler flags and libraries
  1663         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  1664         
  1665         if test x$have_video_rpi = xyes; then
  1666             CFLAGS="$CFLAGS $RPI_CFLAGS"
  1667             SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
  1668             EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
  1669             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $RPI_LIBS"
  1670             SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
  1671             AC_DEFINE(SDL_VIDEO_DRIVER_RPI, 1, [ ])
  1672             SUMMARY_video="${SUMMARY_video} rpi"
  1673         fi
  1674     fi
  1675 }
  1676 
  1677 dnl Find the X11 include and library directories
  1678 CheckX11()
  1679 {
  1680     AC_ARG_ENABLE(video-x11,
  1681 AS_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
  1682                   , enable_video_x11=yes)
  1683     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
  1684         case "$host" in
  1685             *-*-darwin*)
  1686                 # This isn't necessary for X11, but fixes GLX detection
  1687                 if test "x$x_includes" = xNONE && \
  1688                    test "x$x_libraries" = xNONE && \
  1689                    test -d /opt/X11/include && \
  1690                    test -d /opt/X11/lib; then
  1691                     x_includes="/opt/X11/include"
  1692                     x_libraries="/opt/X11/lib"
  1693                 fi
  1694                 ;;
  1695         esac
  1696         AC_PATH_X
  1697         AC_PATH_XTRA
  1698         if test x$have_x = xyes; then
  1699             AC_ARG_ENABLE(x11-shared,
  1700 AS_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
  1701                           , enable_x11_shared=maybe)
  1702 
  1703             case "$host" in
  1704                 *-*-darwin*)
  1705                     # Apple now puts this in /opt/X11
  1706                     x11_lib='/opt/X11/lib/libX11.6.dylib'
  1707                     x11ext_lib='/opt/X11/lib/libXext.6.dylib'
  1708                     xcursor_lib='/opt/X11/lib/libXcursor.1.dylib'
  1709                     xinerama_lib='/opt/X11/lib/libXinerama.1.dylib'
  1710                     xinput_lib='/opt/X11/lib/libXi.6.dylib'
  1711                     xrandr_lib='/opt/X11/lib/libXrandr.2.dylib'
  1712                     xrender_lib='/opt/X11/lib/libXrender.1.dylib'
  1713                     xss_lib='/opt/X11/lib/libXss.1.dylib'
  1714                     xvidmode_lib='/opt/X11/lib/libXxf86vm.1.dylib'
  1715                     ;;
  1716                 *-*-openbsd*)
  1717                     x11_lib='libX11.so'
  1718                     x11ext_lib='libXext.so'
  1719                     xcursor_lib='libXcursor.so'
  1720                     xinerama_lib='libXinerama.so'
  1721                     xinput_lib='libXi.so'
  1722                     xrandr_lib='libXrandr.so'
  1723                     xrender_lib='libXrender.so'
  1724                     xss_lib='libXss.so'
  1725                     xvidmode_lib='libXxf86vm.so'
  1726                     ;;
  1727                 *)
  1728                     x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1729                     x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1730                     xcursor_lib=[`find_lib "libXcursor.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1731                     xinerama_lib=[`find_lib "libXinerama.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1732                     xinput_lib=[`find_lib "libXi.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1733                     xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1734                     xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1735                     xss_lib=[`find_lib "libXss.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1736                     xvidmode_lib=[`find_lib "libXxf86vm.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
  1737                     ;;
  1738             esac
  1739 
  1740             if test x$ac_cv_func_shmat != xyes; then
  1741                 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
  1742             fi
  1743             CFLAGS="$CFLAGS $X_CFLAGS"
  1744             LDFLAGS="$LDFLAGS $X_LIBS"
  1745 
  1746             AC_CHECK_HEADER(X11/extensions/Xext.h,
  1747                             have_xext_h_hdr=yes,
  1748                             have_xext_h_hdr=no,
  1749                             [#include <X11/Xlib.h>
  1750                              #include <X11/Xproto.h>
  1751                             ])
  1752             if test x$have_xext_h_hdr != xyes; then
  1753                AC_MSG_ERROR([
  1754 *** Missing Xext.h, maybe you need to install the libxext-dev package?
  1755                ])
  1756             fi
  1757 
  1758             AC_DEFINE(SDL_VIDEO_DRIVER_X11, 1, [ ])
  1759             SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
  1760             EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
  1761 
  1762             # Needed so SDL applications can include SDL_syswm.h
  1763             SDL_CFLAGS="$SDL_CFLAGS $X_CFLAGS"
  1764 
  1765             if test x$enable_x11_shared = xmaybe; then
  1766                 enable_x11_shared=yes
  1767             fi
  1768             if test x$have_loadso != xyes && \
  1769                test x$enable_x11_shared = xyes; then
  1770                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
  1771                 enable_x11_shared=no
  1772             fi
  1773             if test x$have_loadso = xyes && \
  1774                test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
  1775                 echo "-- dynamic libX11 -> $x11_lib"
  1776                 echo "-- dynamic libX11ext -> $x11ext_lib"
  1777                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib", [ ])
  1778                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib", [ ])
  1779                 SUMMARY_video="${SUMMARY_video} x11(dynamic)"
  1780             else
  1781                 enable_x11_shared=no
  1782                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
  1783                 SUMMARY_video="${SUMMARY_video} x11"
  1784             fi
  1785             have_video=yes
  1786 
  1787             AC_MSG_CHECKING(for const parameter to XextAddDisplay)
  1788             have_const_param_XextAddDisplay=no
  1789             AC_TRY_COMPILE([
  1790               #include <X11/Xlib.h>
  1791               #include <X11/Xproto.h>
  1792               #include <X11/extensions/Xext.h>
  1793               #include <X11/extensions/extutil.h>
  1794               extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
  1795             ],[
  1796             ],[
  1797             have_const_param_XextAddDisplay=yes
  1798             AC_DEFINE([SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY], 1, [ ])
  1799             ])
  1800             AC_MSG_RESULT($have_const_param_XextAddDisplay)
  1801 
  1802             dnl AC_CHECK_LIB(X11, XGetEventData, AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS, 1, [Have XGenericEvent]))
  1803             AC_MSG_CHECKING([for XGenericEvent])
  1804             have_XGenericEvent=no
  1805             AC_TRY_COMPILE([
  1806                 #include <X11/Xlib.h>
  1807             ],[
  1808 Display *display;
  1809 XEvent event;
  1810 XGenericEventCookie *cookie = &event.xcookie;
  1811 XNextEvent(display, &event);
  1812 XGetEventData(display, cookie);
  1813 XFreeEventData(display, cookie);
  1814             ],[
  1815                 have_XGenericEvent=yes
  1816                 AC_DEFINE([SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS], 1, [ ])
  1817             ])
  1818             AC_MSG_RESULT($have_XGenericEvent)
  1819 
  1820             AC_CHECK_LIB(X11, XkbKeycodeToKeysym, AC_DEFINE(SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM, 1, [Have XkbKeycodeToKeysym]))
  1821 
  1822             AC_ARG_ENABLE(video-x11-xcursor,
  1823 AS_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[default=yes]]]),
  1824                             , enable_video_x11_xcursor=yes)
  1825             if test x$enable_video_x11_xcursor = xyes; then
  1826                 definitely_enable_video_x11_xcursor=no
  1827                 AC_CHECK_HEADER(X11/Xcursor/Xcursor.h,
  1828                                 have_xcursor_h_hdr=yes,
  1829                                 have_xcursor_h_hdr=no,
  1830                                 [#include <X11/Xlib.h>
  1831                                 ])
  1832                 if test x$have_xcursor_h_hdr = xyes; then
  1833                     if test x$enable_x11_shared = xyes && test x$xcursor_lib != x ; then
  1834                         echo "-- dynamic libXcursor -> $xcursor_lib"
  1835                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR, "$xcursor_lib", [ ])
  1836                         definitely_enable_video_x11_xcursor=yes
  1837                     else
  1838                         AC_CHECK_LIB(Xcursor, XcursorImageCreate, have_xcursor_lib=yes)
  1839                         if test x$have_xcursor_lib = xyes ; then
  1840                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXcursor"
  1841                             definitely_enable_video_x11_xcursor=yes
  1842                         fi
  1843                     fi
  1844                 fi
  1845             fi
  1846             if test x$definitely_enable_video_x11_xcursor = xyes; then
  1847                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XCURSOR, 1, [ ])
  1848                 SUMMARY_video_x11="${SUMMARY_video_x11} xcursor"
  1849             fi
  1850             AC_ARG_ENABLE(video-x11-xdbe,
  1851 AS_HELP_STRING([--enable-video-x11-xdbe], [enable X11 Xdbe support [[default=yes]]]),
  1852                             , enable_video_x11_xdbe=yes)
  1853             if test x$enable_video_x11_xdbe = xyes; then
  1854                 AC_CHECK_HEADER(X11/extensions/Xdbe.h,
  1855                                 have_dbe_h_hdr=yes,
  1856                                 have_dbe_h_hdr=no,
  1857                                 [#include <X11/Xlib.h>
  1858                                 ])
  1859                 if test x$have_dbe_h_hdr = xyes; then
  1860                     AC_DEFINE(SDL_VIDEO_DRIVER_X11_XDBE, 1, [ ])
  1861                     SUMMARY_video_x11="${SUMMARY_video_x11} xdbe"
  1862                 fi
  1863             fi
  1864             AC_ARG_ENABLE(video-x11-xinerama,
  1865 AS_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
  1866                             , enable_video_x11_xinerama=yes)
  1867             if test x$enable_video_x11_xinerama = xyes; then
  1868                 definitely_enable_video_x11_xinerama=no
  1869                 AC_CHECK_HEADER(X11/extensions/Xinerama.h,
  1870                                 have_xinerama_h_hdr=yes,
  1871                                 have_xinerama_h_hdr=no,
  1872                                 [#include <X11/Xlib.h>
  1873                                 ])
  1874                 if test x$have_xinerama_h_hdr = xyes; then
  1875                     if test x$enable_x11_shared = xyes && test x$xinerama_lib != x ; then
  1876                         echo "-- dynamic libXinerama -> $xinerama_lib"
  1877                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA, "$xinerama_lib", [ ])
  1878                         definitely_enable_video_x11_xinerama=yes
  1879                     else
  1880                         AC_CHECK_LIB(Xinerama, XineramaQueryExtension, have_xinerama_lib=yes)
  1881                         if test x$have_xinerama_lib = xyes ; then
  1882                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXinerama"
  1883                             definitely_enable_video_x11_xinerama=yes
  1884                         fi
  1885                     fi
  1886                 fi
  1887             fi
  1888             if test x$definitely_enable_video_x11_xinerama = xyes; then
  1889                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA, 1, [ ])
  1890                 SUMMARY_video_x11="${SUMMARY_video_x11} xinerama"
  1891             fi
  1892             AC_ARG_ENABLE(video-x11-xinput,
  1893 AS_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]),
  1894                             , enable_video_x11_xinput=yes)
  1895             if test x$enable_video_x11_xinput = xyes; then
  1896                 definitely_enable_video_x11_xinput=no
  1897                 AC_CHECK_HEADER(X11/extensions/XInput2.h,
  1898                                 have_xinput_h_hdr=yes,
  1899                                 have_xinput_h_hdr=no,
  1900                                 [#include <X11/Xlib.h>
  1901                                 ])
  1902                 if test x$have_xinput_h_hdr = xyes; then
  1903                     if test x$enable_x11_shared = xyes && test x$xinput_lib != x ; then
  1904                         echo "-- dynamic libXi -> $xinput_lib"
  1905                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2, "$xinput_lib", [ ])
  1906                         definitely_enable_video_x11_xinput=yes
  1907                     else
  1908                         AC_CHECK_LIB(Xi, XOpenDevice, have_xinput_lib=yes)
  1909                         if test x$have_xinput_lib = xyes ; then
  1910                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXi"
  1911                             definitely_enable_video_x11_xinput=yes
  1912                         fi
  1913                     fi
  1914                 fi
  1915             fi
  1916             if test x$definitely_enable_video_x11_xinput = xyes; then
  1917                 SUMMARY_video_x11="${SUMMARY_video_x11} xinput2"
  1918                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ])
  1919                 AC_MSG_CHECKING(for xinput2 multitouch)
  1920                 have_xinput2_multitouch=no
  1921                 AC_TRY_COMPILE([
  1922                     #include <X11/Xlib.h>
  1923                     #include <X11/Xproto.h>
  1924                     #include <X11/extensions/XInput2.h>
  1925                     ],[
  1926 int event_type = XI_TouchBegin;
  1927 XITouchClassInfo *t;
  1928                     ],[
  1929                     have_xinput2_multitouch=yes
  1930                     AC_DEFINE([SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH], 1, [])
  1931                     SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch"
  1932                     ])
  1933                 AC_MSG_RESULT($have_xinput2_multitouch)
  1934             fi
  1935             AC_ARG_ENABLE(video-x11-xrandr,
  1936 AS_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
  1937                             , enable_video_x11_xrandr=yes)
  1938             if test x$enable_video_x11_xrandr = xyes; then
  1939                 dnl XRRScreenResources is only present in Xrandr >= 1.2, we use that as a test.
  1940                 definitely_enable_video_x11_xrandr=no
  1941                 have_xrandr_h_hdr=no
  1942                 AC_TRY_COMPILE([
  1943                 #include <X11/Xlib.h>
  1944                 #include <X11/extensions/Xrandr.h>
  1945                 ],[
  1946                 XRRScreenResources *res = NULL;
  1947                 ],[
  1948                 have_xrandr_h_hdr=yes
  1949                 ])
  1950                 if test x$have_xrandr_h_hdr = xyes; then
  1951                     if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
  1952                         echo "-- dynamic libXrandr -> $xrandr_lib"
  1953                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib", [ ])
  1954                         definitely_enable_video_x11_xrandr=yes
  1955                     else
  1956                         AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
  1957                         if test x$have_xrandr_lib = xyes ; then
  1958                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr"
  1959                             definitely_enable_video_x11_xrandr=yes
  1960                         fi
  1961                     fi
  1962                 fi
  1963             fi
  1964             if test x$definitely_enable_video_x11_xrandr = xyes; then
  1965                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR, 1, [ ])
  1966                 SUMMARY_video_x11="${SUMMARY_video_x11} xrandr"
  1967             fi
  1968             AC_ARG_ENABLE(video-x11-scrnsaver,
  1969 AS_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]),
  1970                             , enable_video_x11_scrnsaver=yes)
  1971             if test x$enable_video_x11_scrnsaver = xyes; then
  1972                 AC_CHECK_HEADER(X11/extensions/scrnsaver.h,
  1973                                 have_scrnsaver_h_hdr=yes,
  1974                                 have_scrnsaver_h_hdr=no,
  1975                                 [#include <X11/Xlib.h>
  1976                                 ])
  1977                 if test x$have_scrnsaver_h_hdr = xyes; then
  1978                     if test x$enable_x11_shared = xyes && test x$xss_lib != x ; then
  1979                         echo "-- dynamic libXss -> $xss_lib"
  1980                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS, "$xss_lib", [ ])
  1981                         definitely_enable_video_x11_scrnsaver=yes
  1982                     else
  1983                         AC_CHECK_LIB(Xss, XScreenSaverSuspend, have_xss_lib=yes)
  1984                         if test x$have_xss_lib = xyes ; then
  1985                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXss"
  1986                             definitely_enable_video_x11_scrnsaver=yes
  1987                         fi
  1988                     fi
  1989                 fi
  1990             fi
  1991             if test x$definitely_enable_video_x11_scrnsaver = xyes; then
  1992                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSCRNSAVER, 1, [ ])
  1993                 SUMMARY_video_x11="${SUMMARY_video_x11} xscrnsaver"
  1994             fi
  1995             AC_ARG_ENABLE(video-x11-xshape,
  1996 AS_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default=yes]]]),
  1997                             , enable_video_x11_xshape=yes)
  1998             if test x$enable_video_x11_xshape = xyes; then
  1999                 AC_CHECK_HEADER(X11/extensions/shape.h,
  2000                                 have_shape_h_hdr=yes,
  2001                                 have_shape_h_hdr=no,
  2002                                 [#include <X11/Xlib.h>
  2003                                 ])
  2004                 if test x$have_shape_h_hdr = xyes; then
  2005                     AC_DEFINE(SDL_VIDEO_DRIVER_X11_XSHAPE, 1, [ ])
  2006                     SUMMARY_video_x11="${SUMMARY_video_x11} xshape"
  2007                 fi
  2008             fi
  2009             AC_ARG_ENABLE(video-x11-vm,
  2010 AS_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
  2011                             , enable_video_x11_vm=yes)
  2012             if test x$enable_video_x11_vm = xyes; then
  2013                 definitely_enable_video_x11_vm=no
  2014                 AC_CHECK_HEADER(X11/extensions/xf86vmode.h,
  2015                                 have_vm_h_hdr=yes,
  2016                                 have_vm_h_hdr=no,
  2017                                 [#include <X11/Xlib.h>
  2018                                 ])
  2019                 if test x$have_vm_h_hdr = xyes; then
  2020                     if test x$enable_x11_shared = xyes && test x$xvidmode_lib != x ; then
  2021                         echo "-- dynamic libXxf86vm -> $xvidmode_lib"
  2022                         AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE, "$xvidmode_lib", [ ])
  2023                         definitely_enable_video_x11_vm=yes
  2024                     else
  2025                         AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryVersion, have_vm_lib=yes)
  2026                         if test x$have_vm_lib = xyes ; then
  2027                             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXxf86vm"
  2028                             definitely_enable_video_x11_vm=yes
  2029                         fi
  2030                     fi
  2031                 fi
  2032             fi
  2033             if test x$definitely_enable_video_x11_vm = xyes; then
  2034                 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XVIDMODE, 1, [ ])
  2035                 SUMMARY_video_x11="${SUMMARY_video_x11} xvidmode"
  2036             fi
  2037         fi
  2038     else
  2039         # Prevent Mesa from including X11 headers
  2040         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11"
  2041     fi
  2042 }
  2043 
  2044 dnl Set up the Vivante video driver if enabled
  2045 CheckVivanteVideo()
  2046 {
  2047     AC_ARG_ENABLE(video-vivante,
  2048 AS_HELP_STRING([--enable-video-vivante], [use Vivante EGL video driver [[default=yes]]]),
  2049                   , enable_video_vivante=yes)
  2050     if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then
  2051         AC_MSG_CHECKING(for Vivante VDK API)
  2052         have_vivante_vdk=no
  2053         AC_TRY_COMPILE([
  2054           #define LINUX
  2055           #define EGL_API_FB
  2056           #include <gc_vdk.h>
  2057         ],[
  2058         ],[
  2059         have_vivante_vdk=yes
  2060         ])
  2061         AC_MSG_RESULT($have_vivante_vdk)
  2062 
  2063         AC_MSG_CHECKING(for Vivante FB API)
  2064         have_vivante_egl=no
  2065         AC_TRY_COMPILE([
  2066           #define LINUX
  2067           #define EGL_API_FB
  2068           #include <EGL/eglvivante.h>
  2069         ],[
  2070         ],[
  2071         have_vivante_egl=yes
  2072         ])
  2073         AC_MSG_RESULT($have_vivante_egl)
  2074 
  2075         if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then
  2076             AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE, 1, [ ])
  2077             EXTRA_CFLAGS="$EXTRA_CFLAGS -DLINUX -DEGL_API_FB"
  2078             if test x$have_vivante_vdk = xyes; then
  2079                 AC_DEFINE(SDL_VIDEO_DRIVER_VIVANTE_VDK, 1, [ ])
  2080                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lVDK"
  2081             fi
  2082             SOURCES="$SOURCES $srcdir/src/video/vivante/*.c"
  2083             SUMMARY_video="${SUMMARY_video} vivante"
  2084             have_video=yes
  2085         fi
  2086     fi
  2087 }
  2088 
  2089 dnl Set up the Haiku video driver if enabled
  2090 CheckHaikuVideo()
  2091 {
  2092     if test x$enable_video = xyes; then
  2093         AC_DEFINE(SDL_VIDEO_DRIVER_HAIKU, 1, [ ])
  2094         SOURCES="$SOURCES $srcdir/src/video/haiku/*.cc"
  2095         have_video=yes
  2096         SUMMARY_video="${SUMMARY_video} haiku"
  2097     fi
  2098 }
  2099 
  2100 dnl Set up the Cocoa video driver for Mac OS X (but not Darwin)
  2101 CheckCOCOA()
  2102 {
  2103     AC_ARG_ENABLE(video-cocoa,
  2104 AS_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]),
  2105                   , enable_video_cocoa=yes)
  2106     if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
  2107         save_CFLAGS="$CFLAGS"
  2108         dnl Work around that we don't have Objective-C support in autoconf
  2109         CFLAGS="$CFLAGS -x objective-c"
  2110         AC_MSG_CHECKING(for Cocoa framework)
  2111         have_cocoa=no
  2112         AC_TRY_COMPILE([
  2113           #import <Cocoa/Cocoa.h>
  2114         ],[
  2115         ],[
  2116         have_cocoa=yes
  2117         ])
  2118         AC_MSG_RESULT($have_cocoa)
  2119         CFLAGS="$save_CFLAGS"
  2120         if test x$have_cocoa = xyes; then
  2121             AC_DEFINE(SDL_VIDEO_DRIVER_COCOA, 1, [ ])
  2122             SOURCES="$SOURCES $srcdir/src/video/cocoa/*.m"
  2123             SUMMARY_video="${SUMMARY_video} cocoa"
  2124             have_video=yes
  2125         fi
  2126     fi
  2127 }
  2128 
  2129 CheckMETAL()
  2130 {
  2131     AC_ARG_ENABLE(video-metal,
  2132 AC_HELP_STRING([--enable-video-metal], [include Metal support [[default=yes]]]),
  2133               , enable_video_metal=yes)
  2134     AC_ARG_ENABLE(render-metal,
  2135 AS_HELP_STRING([--enable-render-metal], [enable the Metal render driver [[default=yes]]]),
  2136                                 , enable_render_metal=yes)
  2137     if test x$enable_video = xyes -a x$enable_video_metal = xyes; then
  2138         save_CFLAGS="$CFLAGS"
  2139         dnl Work around that we don't have Objective-C support in autoconf
  2140         CFLAGS="$CFLAGS -x objective-c"
  2141         AC_MSG_CHECKING(for Metal framework)
  2142         have_metal=no
  2143         AC_TRY_COMPILE([
  2144           #import <Cocoa/Cocoa.h>
  2145           #import <Metal/Metal.h>
  2146           #import <QuartzCore/CAMetalLayer.h>
  2147 
  2148           #if !TARGET_CPU_X86_64
  2149           #error Metal doesn't work on this configuration
  2150           #endif
  2151         ],[
  2152         ],[
  2153         have_metal=yes
  2154         ])
  2155         CFLAGS="$save_CFLAGS"
  2156         AC_MSG_RESULT($have_metal)
  2157         if test x$have_metal = xyes; then
  2158             AC_DEFINE(SDL_VIDEO_METAL, 1, [ ])
  2159             if test x$enable_render = xyes -a x$enable_render_metal = xyes; then
  2160                 AC_DEFINE(SDL_VIDEO_RENDER_METAL, 1, [ ])
  2161                 SOURCES="$SOURCES $srcdir/src/render/metal/*.m"
  2162             fi
  2163             SUMMARY_video="${SUMMARY_video} metal"
  2164         else
  2165             enable_video_metal=no
  2166             enable_render_metal=no
  2167         fi
  2168     fi
  2169 }
  2170 
  2171 
  2172 dnl Find DirectFB
  2173 CheckDirectFB()
  2174 {
  2175     AC_ARG_ENABLE(video-directfb,
  2176 AS_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]),
  2177                   , enable_video_directfb=no)
  2178     if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
  2179         PKG_CHECK_MODULES([DIRECTFB], [directfb >= 1.0.0], video_directfb=yes, video_directfb=no)
  2180 
  2181         if test x$video_directfb = xyes; then
  2182             # SuSE 11.1 installs directfb-config without directfb-devel
  2183             save_CPPFLAGS="$CPPFLAGS"
  2184             CPPFLAGS="$CPPFLAGS $DIRECTFB_CFLAGS"
  2185             AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
  2186             CPPFLAGS="$save_CPPFLAGS"
  2187             video_directfb=$have_directfb_hdr
  2188         fi
  2189 
  2190         if test x$video_directfb = xyes; then
  2191             AC_ARG_ENABLE(directfb-shared,
  2192 AS_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]),
  2193                               , enable_directfb_shared=yes)
  2194 
  2195             AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB, 1, [ ])
  2196             AC_DEFINE(SDL_VIDEO_RENDER_DIRECTFB, 1, [ ])
  2197             SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
  2198             EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
  2199 
  2200             AC_MSG_CHECKING(for directfb dynamic loading support)
  2201             directfb_shared=no
  2202             directfb_lib=[`find_lib "libdirectfb*.so.*" "$DIRECTFB_LIBS"`]
  2203             # | sed 's/.*\/\(.*\)/\1/; q'`]
  2204 AC_MSG_WARN("directfb $directfb_lib")
  2205             if test x$have_loadso != xyes && \
  2206                test x$enable_directfb_shared = xyes; then
  2207                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading])
  2208             fi
  2209             if test x$have_loadso = xyes && \
  2210                test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then
  2211                 directfb_shared=yes
  2212                 echo "-- $directfb_lib_spec -> $directfb_lib"
  2213                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib", [ ])
  2214                 SUMMARY_video="${SUMMARY_video} directfb(dynamic)"
  2215             else
  2216                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
  2217                 SUMMARY_video="${SUMMARY_video} directfb"
  2218             fi
  2219             AC_MSG_RESULT($directfb_shared)
  2220             SDL_CFLAGS="$SDL_CFLAGS $DIRECTFB_CFLAGS"
  2221             have_video=yes
  2222         fi
  2223     fi
  2224 }
  2225 
  2226 dnl Find KMSDRM
  2227 CheckKMSDRM()
  2228 {
  2229     AC_ARG_ENABLE(video-kmsdrm,
  2230 AS_HELP_STRING([--enable-video-kmsdrm], [use KMSDRM video driver [[default=no]]]),
  2231                   , enable_video_kmsdrm=no)
  2232 
  2233     if test x$enable_video = xyes -a x$enable_video_kmsdrm = xyes; then
  2234         video_kmsdrm=no
  2235 
  2236         PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.4.46], libdrm_avail=yes, libdrm_avail=no)
  2237         PKG_CHECK_MODULES([LIBGBM], [gbm >= 9.0.0], libgbm_avail=yes, libgbm_avail=no)
  2238 
  2239         if test x$libdrm_avail = xyes -a x$libgbm_avail = xyes; then
  2240             video_kmsdrm=yes
  2241         fi
  2242 
  2243         if test x$video_kmsdrm = xyes; then
  2244             AC_ARG_ENABLE(kmsdrm-shared,
  2245 AS_HELP_STRING([--enable-kmsdrm-shared], [dynamically load kmsdrm support [[default=yes]]]),
  2246                 , enable_kmsdrm_shared=yes)
  2247 
  2248             AC_DEFINE(SDL_VIDEO_DRIVER_KMSDRM, 1, [ ])
  2249             SOURCES="$SOURCES $srcdir/src/video/kmsdrm/*.c"
  2250             EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBDRM_CFLAGS $LIBGBM_CFLAGS"
  2251 
  2252             AC_MSG_CHECKING(for kmsdrm dynamic loading support)
  2253             kmsdrm_shared=no
  2254             drm_lib=[`find_lib "libdrm.so.*" "$DRM_LIBS"`]
  2255             gbm_lib=[`find_lib "libgbm.so.*" "$DRM_LIBS"`]
  2256             if test x$have_loadso != xyes && \
  2257                test x$enable_kmsdrm_shared = xyes; then
  2258                 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic kmsdrm loading])
  2259             fi
  2260             if test x$have_loadso = xyes && \
  2261                test x$enable_kmsdrm_shared = xyes && test x$drm_lib != x && test x$gbm_lib != x; then
  2262                 kmsdrm_shared=yes
  2263                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC, "$drm_lib", [ ])
  2264                 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM, "$gbm_lib", [ ])
  2265                 AC_DEFINE_UNQUOTED(HAVE_KMSDRM_SHARED, "TRUE", [ ])
  2266                 SUMMARY_video="${SUMMARY_video} kmsdrm(dynamic)"
  2267             else
  2268                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBDRM_LIBS $LIBGBM_LIBS"
  2269                 SUMMARY_video="${SUMMARY_video} kmsdrm"
  2270             fi
  2271             AC_MSG_RESULT($kmsdrm_shared)
  2272             have_video=yes
  2273         fi
  2274     fi
  2275 }
  2276 
  2277 dnl rcg04172001 Set up the Null video driver.
  2278 CheckDummyVideo()
  2279 {
  2280     AC_ARG_ENABLE(video-dummy,
  2281 AS_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
  2282                   , enable_video_dummy=yes)
  2283     if test x$enable_video_dummy = xyes; then
  2284         AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY, 1, [ ])
  2285         SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
  2286         have_video=yes
  2287         SUMMARY_video="${SUMMARY_video} dummy"
  2288     fi
  2289 }
  2290 
  2291 dnl Set up the QNX video driver if enabled
  2292 CheckQNXVideo()
  2293 {
  2294     if test x$enable_video = xyes; then
  2295         AC_DEFINE(SDL_VIDEO_DRIVER_QNX, 1, [ ])
  2296         SOURCES="$SOURCES $srcdir/src/video/qnx/*.c"
  2297         have_video=yes
  2298         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lscreen -lEGL -lGLESv2"
  2299         SUMMARY_video="${SUMMARY_video} qnx"
  2300     fi
  2301 }
  2302 
  2303 dnl Set up the QNX audio driver if enabled
  2304 CheckQNXAudio()
  2305 {
  2306     if test x$enable_audio = xyes; then
  2307         AC_DEFINE(SDL_AUDIO_DRIVER_QSA, 1, [ ])
  2308         SOURCES="$SOURCES $srcdir/src/audio/qsa/*.c"
  2309         have_audio=yes
  2310         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
  2311         SUMMARY_audio="${SUMMARY_audio} qsa"
  2312     fi
  2313 }
  2314 
  2315 dnl Check to see if OpenGL support is desired
  2316 AC_ARG_ENABLE(video-opengl,
  2317 AS_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]),
  2318               , enable_video_opengl=yes)
  2319 
  2320 dnl Find OpenGL
  2321 CheckOpenGLX11()
  2322 {
  2323     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  2324         AC_MSG_CHECKING(for OpenGL (GLX) support)
  2325         video_opengl=no
  2326         AC_TRY_COMPILE([
  2327          #include <GL/gl.h>
  2328          #include <GL/glx.h>
  2329         ],[
  2330         ],[
  2331         video_opengl=yes
  2332         ])
  2333         AC_MSG_RESULT($video_opengl)
  2334         if test x$video_opengl = xyes; then
  2335             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2336             AC_DEFINE(SDL_VIDEO_OPENGL_GLX, 1, [ ])
  2337             AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  2338             SUMMARY_video="${SUMMARY_video} opengl"
  2339         fi
  2340     fi
  2341 }
  2342 
  2343 dnl Check to see if OpenGL ES support is desired
  2344 AC_ARG_ENABLE(video-opengles,
  2345 AS_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]),
  2346               , enable_video_opengles=yes)
  2347 AC_ARG_ENABLE(video-opengles1,
  2348 AS_HELP_STRING([--enable-video-opengles1], [include OpenGL ES 1.1 support [[default=yes]]]),
  2349               , enable_video_opengles1=yes)
  2350 AC_ARG_ENABLE(video-opengles2,
  2351 AS_HELP_STRING([--enable-video-opengles2], [include OpenGL ES 2.0 support [[default=yes]]]),
  2352               , enable_video_opengles2=yes)
  2353 
  2354 dnl Find OpenGL ES
  2355 CheckOpenGLESX11()
  2356 {
  2357     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  2358         AC_MSG_CHECKING(for EGL support)
  2359         video_opengl_egl=no
  2360         AC_TRY_COMPILE([
  2361           #define LINUX
  2362           #define EGL_API_FB
  2363           #define MESA_EGL_NO_X11_HEADERS
  2364           #include <EGL/egl.h>
  2365           #include <EGL/eglext.h>
  2366         ],[
  2367         ],[
  2368         video_opengl_egl=yes
  2369         ])
  2370         AC_MSG_RESULT($video_opengl_egl)
  2371         if test x$video_opengl_egl = xyes; then
  2372             AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
  2373         fi
  2374         
  2375         if test x$enable_video_opengles1 = xyes; then
  2376             AC_MSG_CHECKING(for OpenGL ES v1 headers)
  2377             video_opengles_v1=no
  2378             AC_TRY_COMPILE([
  2379              #include <GLES/gl.h>
  2380              #include <GLES/glext.h>
  2381             ],[
  2382             ],[
  2383             video_opengles_v1=yes
  2384             ])
  2385             AC_MSG_RESULT($video_opengles_v1)
  2386             if test x$video_opengles_v1 = xyes; then
  2387                 AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
  2388                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
  2389                 SUMMARY_video="${SUMMARY_video} opengl_es1"
  2390             fi
  2391         fi
  2392         
  2393         if test x$enable_video_opengles2 = xyes; then
  2394             AC_MSG_CHECKING(for OpenGL ES v2 headers)
  2395             video_opengles_v2=no
  2396             AC_TRY_COMPILE([
  2397              #include <GLES2/gl2.h>
  2398              #include <GLES2/gl2ext.h>
  2399             ],[
  2400             ],[
  2401             video_opengles_v2=yes
  2402             ])
  2403             AC_MSG_RESULT($video_opengles_v2)
  2404             if test x$video_opengles_v2 = xyes; then
  2405                 AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  2406                 AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  2407                 SUMMARY_video="${SUMMARY_video} opengl_es2"
  2408             fi
  2409         fi
  2410     fi
  2411 }
  2412 
  2413 dnl Check for Windows OpenGL
  2414 CheckWINDOWSGL()
  2415 {
  2416     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  2417         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2418         AC_DEFINE(SDL_VIDEO_OPENGL_WGL, 1, [ ])
  2419         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  2420         SUMMARY_video="${SUMMARY_video} opengl"
  2421     fi
  2422 }
  2423 
  2424 dnl Check for Windows OpenGL
  2425 CheckWINDOWSGLES()
  2426 {
  2427     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  2428 
  2429         AC_MSG_CHECKING(for EGL support)
  2430         video_opengl_egl=no
  2431         AC_TRY_COMPILE([
  2432          #include <EGL/egl.h>
  2433         ],[
  2434         ],[
  2435         video_opengl_egl=yes
  2436         ])
  2437         AC_MSG_RESULT($video_opengl_egl)
  2438         if test x$video_opengl_egl = xyes; then
  2439             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2440             AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
  2441             SUMMARY_video="${SUMMARY_video} opengl_es1"
  2442         fi
  2443        
  2444         AC_MSG_CHECKING(for OpenGL ES v2 headers)
  2445         video_opengles_v2=no
  2446         AC_TRY_COMPILE([
  2447          #include <GLES2/gl2.h>
  2448          #include <GLES2/gl2ext.h>
  2449         ],[
  2450         ],[
  2451         video_opengles_v2=yes
  2452         ])
  2453         AC_MSG_RESULT($video_opengles_v2)
  2454         if test x$video_opengles_v2 = xyes; then
  2455             AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2456             AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  2457             AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  2458             SUMMARY_video="${SUMMARY_video} opengl_es2"
  2459         fi
  2460     fi
  2461 }
  2462 
  2463 dnl Check for Haiku OpenGL
  2464 CheckHaikuGL()
  2465 {
  2466     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  2467         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2468         AC_DEFINE(SDL_VIDEO_OPENGL_HAIKU, 1, [ ])
  2469         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  2470         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
  2471         SUMMARY_video="${SUMMARY_video} opengl"
  2472     fi
  2473 }
  2474 
  2475 dnl Check for MacOS OpenGL
  2476 CheckMacGL()
  2477 {
  2478     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
  2479         AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
  2480         AC_DEFINE(SDL_VIDEO_OPENGL_CGL, 1, [ ])
  2481         AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
  2482         SUMMARY_video="${SUMMARY_video} opengl"
  2483     fi
  2484 }
  2485 
  2486 dnl Check for MacOS OpenGLES
  2487 CheckMacGLES()
  2488 {
  2489     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  2490         video_opengl_egl=yes
  2491         AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
  2492         video_opengles_v2=yes
  2493         AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  2494         AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  2495         SUMMARY_video="${SUMMARY_video} opengl_es2"
  2496     fi
  2497 }
  2498 
  2499 CheckEmscriptenGLES()
  2500 {
  2501     if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then
  2502         AC_MSG_CHECKING(for EGL support)
  2503         video_opengl_egl=no
  2504         AC_TRY_COMPILE([
  2505          #include <EGL/egl.h>
  2506         ],[
  2507         ],[
  2508         video_opengl_egl=yes
  2509         ])
  2510         AC_MSG_RESULT($video_opengl_egl)
  2511         if test x$video_opengl_egl = xyes; then
  2512             AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ])
  2513         fi
  2514 
  2515         AC_MSG_CHECKING(for OpenGL ES v2 headers)
  2516         video_opengles_v2=no
  2517         AC_TRY_COMPILE([
  2518          #include <GLES2/gl2.h>
  2519          #include <GLES2/gl2ext.h>
  2520         ],[
  2521         ],[
  2522         video_opengles_v2=yes
  2523         ])
  2524         AC_MSG_RESULT($video_opengles_v2)
  2525         if test x$video_opengles_v2 = xyes; then
  2526             AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  2527             AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  2528             SUMMARY_video="${SUMMARY_video} opengl_es2"
  2529         fi
  2530     fi
  2531 }
  2532 
  2533 dnl Check to see if Vulkan support is desired
  2534 AC_ARG_ENABLE(video-vulkan,
  2535 AS_HELP_STRING([--enable-video-vulkan], [include Vulkan support [[default=yes]]]),
  2536               , enable_video_vulkan=yes)
  2537 
  2538 dnl Find Vulkan Header
  2539 CheckVulkan()
  2540 {
  2541     if test x$enable_video = xyes -a x$enable_video_vulkan = xyes; then
  2542         case "$host" in
  2543             *-*-android*)
  2544                 AC_TRY_COMPILE([
  2545                   #if defined(__ARM_ARCH) && __ARM_ARCH < 7
  2546                   #error Vulkan doesn't work on this configuration
  2547                   #endif
  2548                 ],[
  2549                 ],[
  2550                 ],[
  2551                     enable_video_vulkan=no
  2552                 ])
  2553                 ;;
  2554             *-*-darwin*)
  2555                 save_CFLAGS="$CFLAGS"
  2556                 dnl Work around that we don't have Objective-C support in autoconf
  2557                 CFLAGS="$CFLAGS -x objective-c"
  2558                 AC_TRY_COMPILE([
  2559                   #include <Cocoa/Cocoa.h>
  2560                   #include <Metal/Metal.h>
  2561                   #include <QuartzCore/CAMetalLayer.h>
  2562 
  2563                   #if !TARGET_CPU_X86_64
  2564                   #error Vulkan doesn't work on this configuration
  2565                   #endif
  2566                 ],[
  2567                 ],[
  2568                 ],[
  2569                     enable_video_vulkan=no
  2570                 ])
  2571                 CFLAGS="$save_CFLAGS"
  2572                 ;;
  2573             *)
  2574                 ;;
  2575         esac
  2576         if test x$enable_video_vulkan = xno; then
  2577             # For reasons I am totally unable to see, I get an undefined macro error if
  2578             # I put this in the AC_TRY_COMPILE.
  2579             AC_MSG_WARN([Vulkan does not work on this configuration.])
  2580         fi
  2581     fi
  2582     if test x$enable_video_vulkan = xyes; then
  2583         AC_DEFINE(SDL_VIDEO_VULKAN, 1, [ ])
  2584         SUMMARY_video="${SUMMARY_video} vulkan"
  2585     fi
  2586 }
  2587 
  2588 dnl See if we can use the new unified event interface in Linux 2.4
  2589 CheckInputEvents()
  2590 {
  2591     dnl Check for Linux 2.4 unified input event interface support
  2592         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
  2593         use_input_events=no
  2594         AC_TRY_COMPILE([
  2595           #include <linux/input.h>
  2596         ],[
  2597           #ifndef EVIOCGNAME
  2598           #error EVIOCGNAME() ioctl not available
  2599           #endif
  2600         ],[
  2601         use_input_events=yes
  2602         ])
  2603         AC_MSG_RESULT($use_input_events)
  2604         if test x$use_input_events = xyes; then
  2605             AC_DEFINE(SDL_INPUT_LINUXEV, 1, [ ])
  2606             SUMMARY_input="${SUMMARY_input} linuxev"
  2607         fi
  2608 }
  2609 
  2610 dnl See if we can use the kernel kd.h header
  2611 CheckInputKD()
  2612 {
  2613 
  2614     AC_MSG_CHECKING(for Linux kd.h)
  2615     use_input_kd=no
  2616     AC_TRY_COMPILE([
  2617       #include <linux/kd.h>
  2618       #include <linux/keyboard.h>
  2619     ],[
  2620         struct kbentry kbe;
  2621         kbe.kb_table = KG_CTRL;
  2622         ioctl(0, KDGKBENT, &kbe);
  2623     ],[
  2624     use_input_kd=yes
  2625     ])
  2626     AC_MSG_RESULT($use_input_kd)
  2627     if test x$use_input_kd = xyes; then
  2628         AC_DEFINE(SDL_INPUT_LINUXKD, 1, [ ])
  2629         SUMMARY_input="${SUMMARY_input} linuxkd"
  2630     fi
  2631 }
  2632 
  2633 dnl See if the platform offers libudev for device enumeration and hotplugging.
  2634 CheckLibUDev()
  2635 {
  2636     AC_ARG_ENABLE(libudev,
  2637 AS_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]),
  2638                         , enable_libudev=yes)
  2639     if test x$enable_libudev = xyes; then
  2640         AC_CHECK_HEADER(libudev.h,
  2641                         have_libudev_h_hdr=yes,
  2642                         have_libudev_h_hdr=no)
  2643         if test x$have_libudev_h_hdr = xyes; then
  2644             AC_DEFINE(HAVE_LIBUDEV_H, 1, [ ])
  2645 
  2646             udev_lib=[`find_lib "libudev.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
  2647             if test x$udev_lib != x; then
  2648                 echo "-- dynamic udev -> $udev_lib"
  2649                 AC_DEFINE_UNQUOTED(SDL_UDEV_DYNAMIC, "$udev_lib", [ ])
  2650             fi
  2651         fi
  2652     fi
  2653 }
  2654 
  2655 dnl See if the platform offers libdbus for various IPC techniques.
  2656 CheckDBus()
  2657 {
  2658     AC_ARG_ENABLE(dbus,
  2659 AS_HELP_STRING([--enable-dbus], [enable D-Bus support [[default=yes]]]),
  2660                         , enable_dbus=yes)
  2661     if test x$enable_dbus = xyes; then
  2662         PKG_CHECK_MODULES([DBUS], [dbus-1], have_dbus=yes, have_dbus=no)
  2663         save_CFLAGS="$CFLAGS"
  2664         CFLAGS="$save_CFLAGS $DBUS_CFLAGS"
  2665         AC_CHECK_HEADER(dbus/dbus.h,
  2666                         have_dbus_dbus_h_hdr=yes,
  2667                         have_dbus_dbus_h_hdr=no)
  2668         CFLAGS="$save_CFLAGS"
  2669         if test x$have_dbus_dbus_h_hdr = xyes; then
  2670             AC_DEFINE(HAVE_DBUS_DBUS_H, 1, [ ])
  2671             EXTRA_CFLAGS="$EXTRA_CFLAGS $DBUS_CFLAGS"
  2672             SOURCES="$SOURCES $srcdir/src/core/linux/SDL_dbus.c"
  2673         fi
  2674     fi
  2675 }
  2676 
  2677 dnl See if the platform wanna IME support.
  2678 CheckIME()
  2679 {
  2680     AC_ARG_ENABLE(ime,
  2681 AS_HELP_STRING([--enable-ime], [enable IME support [[default=yes]]]),
  2682                   , enable_ime=yes)
  2683     if test x$enable_ime = xyes; then
  2684         AC_DEFINE(SDL_USE_IME, 1, [ ])
  2685         SOURCES="$SOURCES $srcdir/src/core/linux/SDL_ime.c"
  2686     fi
  2687 }
  2688 
  2689 dnl See if the platform has libibus IME support.
  2690 CheckIBus()
  2691 {
  2692     AC_ARG_ENABLE(ibus,
  2693 AS_HELP_STRING([--enable-ibus], [enable IBus support [[default=yes]]]),
  2694                   , enable_ibus=yes)
  2695     if test x$enable_ibus = xyes; then
  2696         PKG_CHECK_MODULES([IBUS], [ibus-1.0], have_ibus=yes, have_ibus=no)
  2697         save_CFLAGS="$CFLAGS"
  2698         CFLAGS="$save_CFLAGS $IBUS_CFLAGS"
  2699         AC_CHECK_HEADER(ibus-1.0/ibus.h,
  2700                         have_ibus_ibus_h_hdr=yes,
  2701                         have_ibus_ibus_h_hdr=no)
  2702         AC_CHECK_HEADER(sys/inotify.h,
  2703                         have_inotify_inotify_h_hdr=yes,
  2704                         have_inotify_inotify_h_hdr=no)
  2705         CFLAGS="$save_CFLAGS"
  2706         if test x$have_ibus_ibus_h_hdr = xyes; then
  2707             if test x$enable_ime != xyes; then
  2708                 AC_MSG_WARN([IME support is required for IBus.])
  2709                 have_ibus_ibus_h_hdr=no
  2710             elif test x$enable_dbus != xyes; then
  2711                 AC_MSG_WARN([DBus support is required for IBus.])
  2712                 have_ibus_ibus_h_hdr=no
  2713             elif test x$have_inotify_inotify_h_hdr != xyes; then
  2714                 AC_MSG_WARN([INotify support is required for IBus.])
  2715                 have_ibus_ibus_h_hdr=no
  2716             else
  2717                 AC_DEFINE(HAVE_IBUS_IBUS_H, 1, [ ])
  2718                 EXTRA_CFLAGS="$EXTRA_CFLAGS $IBUS_CFLAGS"
  2719                 SOURCES="$SOURCES $srcdir/src/core/linux/SDL_ibus.c"
  2720             fi
  2721         fi
  2722     fi
  2723 }
  2724 
  2725 dnl See if the platform has fcitx IME support.
  2726 CheckFcitx()
  2727 {
  2728     AC_ARG_ENABLE(fcitx,
  2729 AS_HELP_STRING([--enable-fcitx], [enable fcitx support [[default=yes]]]),
  2730                   , enable_fcitx=yes)
  2731     if test x$enable_fcitx = xyes; then
  2732         PKG_CHECK_MODULES([FCITX], [fcitx], have_fcitx=yes, have_fcitx=no)
  2733         CFLAGS="$CFLAGS $FCITX_CFLAGS"
  2734         AC_CHECK_HEADER(fcitx/frontend.h,
  2735                         have_fcitx_frontend_h_hdr=yes,
  2736                         have_fcitx_frontend_h_hdr=no)
  2737         CFLAGS="$save_CFLAGS"
  2738         if test x$have_fcitx_frontend_h_hdr = xyes; then
  2739             if test x$enable_ime != xyes; then
  2740                 AC_MSG_WARN([IME support is required for fcitx.])
  2741                 have_fcitx_frontend_h_hdr=no
  2742             elif test x$enable_dbus != xyes; then
  2743                 AC_MSG_WARN([DBus support is required for fcitx.])
  2744                 have_fcitx_frontend_h_hdr=no
  2745             else
  2746                 AC_DEFINE(HAVE_FCITX_FRONTEND_H, 1, [ ])
  2747                 EXTRA_CFLAGS="$EXTRA_CFLAGS $FCITX_CFLAGS"
  2748                 SOURCES="$SOURCES $srcdir/src/core/linux/SDL_fcitx.c"
  2749             fi
  2750         fi
  2751     fi
  2752 }
  2753 
  2754 dnl See if we can use the Touchscreen input library
  2755 CheckTslib()
  2756 {
  2757     AC_ARG_ENABLE(input-tslib,
  2758 AS_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
  2759                   , enable_input_tslib=yes)
  2760     if test x$enable_input_tslib = xyes; then
  2761         AC_MSG_CHECKING(for Touchscreen library support)
  2762         enable_input_tslib=no
  2763         AC_TRY_COMPILE([
  2764           #include "tslib.h"
  2765         ],[
  2766         ],[
  2767         enable_input_tslib=yes
  2768         ])
  2769         AC_MSG_RESULT($enable_input_tslib)
  2770         if test x$enable_input_tslib = xyes; then
  2771             AC_DEFINE(SDL_INPUT_TSLIB, 1, [ ])
  2772             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
  2773             SUMMARY_input="${SUMMARY_input} ts"
  2774         fi
  2775     fi
  2776 }
  2777 
  2778 dnl See what type of thread model to use on Linux and Solaris
  2779 CheckPTHREAD()
  2780 {
  2781     dnl Check for pthread support
  2782     AC_ARG_ENABLE(pthreads,
  2783 AS_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
  2784                   , enable_pthreads=yes)
  2785     dnl This is used on Linux for glibc binary compatibility (Doh!)
  2786     AC_ARG_ENABLE(pthread-sem,
  2787 AS_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
  2788                   , enable_pthread_sem=yes)
  2789     case "$host" in
  2790          *-*-android*)
  2791             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2792             pthread_lib=""
  2793             ;;
  2794         *-*-linux*|*-*-uclinux*)
  2795             pthread_cflags="-D_REENTRANT"
  2796             pthread_lib="-lpthread"
  2797             ;;
  2798         *-*-bsdi*)
  2799             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2800             pthread_lib=""
  2801             ;;
  2802         *-*-darwin*)
  2803             pthread_cflags="-D_THREAD_SAFE"
  2804 # causes Carbon.p complaints?
  2805 #            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2806             ;;
  2807         *-*-freebsd*|*-*-dragonfly*)
  2808             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2809             pthread_lib="-pthread"
  2810             ;;
  2811         *-*-netbsd*)
  2812             pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
  2813             pthread_lib="-lpthread"
  2814             ;;
  2815         *-*-openbsd*)
  2816             pthread_cflags="-D_REENTRANT"
  2817             pthread_lib="-pthread"
  2818             ;;
  2819         *-*-solaris2.9)
  2820             # From Solaris 9+, posix4's preferred name is rt.
  2821             pthread_cflags="-D_REENTRANT"
  2822             pthread_lib="-lpthread -lrt"
  2823             ;;
  2824         *-*-solaris2.10)
  2825             # Solaris 10+ merged pthread into libc.
  2826             pthread_cflags="-D_REENTRANT"
  2827             pthread_lib="-lrt"
  2828             ;;
  2829         *-*-solaris*)
  2830             # Solaris 11+ merged rt into libc.
  2831             pthread_cflags="-D_REENTRANT"
  2832             pthread_lib=""
  2833             ;;
  2834         *-*-sysv5*)
  2835             pthread_cflags="-D_REENTRANT -Kthread"
  2836             pthread_lib=""
  2837             ;;
  2838         *-*-aix*)
  2839             pthread_cflags="-D_REENTRANT -mthreads"
  2840             pthread_lib="-lpthread"
  2841             ;;
  2842         *-*-hpux11*)
  2843             pthread_cflags="-D_REENTRANT"
  2844             pthread_lib="-L/usr/lib -lpthread"
  2845             ;;
  2846         *-*-haiku*)
  2847             pthread_cflags="-D_REENTRANT"
  2848             pthread_lib=""
  2849             ;;
  2850         *-*-nto*)
  2851             pthread_cflags="-D_REENTRANT"
  2852             pthread_lib=""
  2853             ;;
  2854         *)
  2855             pthread_cflags="-D_REENTRANT"
  2856             pthread_lib="-lpthread"
  2857             ;;
  2858     esac
  2859     if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
  2860         # Save the original compiler flags and libraries
  2861         ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  2862         # Add the pthread compiler flags and libraries
  2863         CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  2864         # Check to see if we have pthread support on this system
  2865         AC_MSG_CHECKING(for pthreads)
  2866         use_pthreads=no
  2867         AC_TRY_LINK([
  2868          #include <pthread.h>
  2869         ],[
  2870          pthread_attr_t type;
  2871          pthread_attr_init(&type);
  2872         ],[
  2873         use_pthreads=yes
  2874         ])
  2875         AC_MSG_RESULT($use_pthreads)
  2876         # Restore the compiler flags and libraries
  2877         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  2878 
  2879         # Do futher testing if we have pthread support...
  2880         if test x$use_pthreads = xyes; then
  2881             AC_DEFINE(SDL_THREAD_PTHREAD, 1, [ ])
  2882             EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
  2883             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
  2884             SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
  2885 
  2886             # Save the original compiler flags and libraries
  2887             ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
  2888             # Add the pthread compiler flags and libraries
  2889             CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
  2890 
  2891             # Check to see if recursive mutexes are available
  2892             AC_MSG_CHECKING(for recursive mutexes)
  2893             has_recursive_mutexes=no
  2894             if test x$has_recursive_mutexes = xno; then
  2895                 AC_TRY_LINK([
  2896                   #define _GNU_SOURCE 1
  2897                   #include <pthread.h>
  2898                 ],[
  2899                   pthread_mutexattr_t attr;
  2900                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  2901                 ],[
  2902                 has_recursive_mutexes=yes
  2903                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX, 1, [ ])
  2904                 ])
  2905             fi
  2906             if test x$has_recursive_mutexes = xno; then
  2907                 AC_TRY_LINK([
  2908                   #define _GNU_SOURCE 1
  2909                   #include <pthread.h>
  2910                 ],[
  2911                   pthread_mutexattr_t attr;
  2912                   pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  2913                 ],[
  2914                 has_recursive_mutexes=yes
  2915                 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP, 1, [ ])
  2916                 ])
  2917             fi
  2918             AC_MSG_RESULT($has_recursive_mutexes)
  2919 
  2920             # Check to see if pthread semaphore support is missing
  2921             if test x$enable_pthread_sem = xyes; then
  2922                 AC_MSG_CHECKING(for pthread semaphores)
  2923                 have_pthread_sem=no
  2924                 AC_TRY_COMPILE([
  2925                   #include <pthread.h>
  2926                   #include <semaphore.h>
  2927                 ],[
  2928                 ],[
  2929                 have_pthread_sem=yes
  2930                 ])
  2931                 AC_MSG_RESULT($have_pthread_sem)
  2932             fi
  2933             if test x$have_pthread_sem = xyes; then
  2934                 AC_MSG_CHECKING(for sem_timedwait)
  2935                 have_sem_timedwait=no
  2936                 AC_TRY_LINK([
  2937                   #include <pthread.h>
  2938                   #include <semaphore.h>
  2939                 ],[
  2940                   sem_timedwait(NULL, NULL);
  2941                 ],[
  2942                 have_sem_timedwait=yes
  2943                 AC_DEFINE([HAVE_SEM_TIMEDWAIT], 1, [ ])
  2944                 ])
  2945                 AC_MSG_RESULT($have_sem_timedwait)
  2946             fi
  2947 
  2948             AC_CHECK_HEADER(pthread_np.h, have_pthread_np_h=yes, have_pthread_np_h=no, [ #include <pthread.h> ])
  2949             if test x$have_pthread_np_h = xyes; then
  2950                 AC_DEFINE(HAVE_PTHREAD_NP_H, 1, [ ])
  2951             fi
  2952 
  2953             # Check to see if pthread naming is available
  2954             AC_MSG_CHECKING(for pthread_setname_np)
  2955             AC_TRY_LINK_FUNC(pthread_setname_np, [
  2956               has_pthread_setname_np=yes
  2957               AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [ ])
  2958             ],[
  2959               has_pthread_setname_np=no
  2960             ])
  2961             AC_MSG_RESULT($has_pthread_setname_np)
  2962 
  2963             AC_MSG_CHECKING(for pthread_set_name_np)
  2964             AC_TRY_LINK_FUNC(pthread_set_name_np, [
  2965               has_pthread_set_name_np=yes
  2966               AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [ ])
  2967             ],[
  2968               has_pthread_set_name_np=no
  2969             ])
  2970             AC_MSG_RESULT($has_pthread_set_name_np)
  2971 
  2972             # Restore the compiler flags and libraries
  2973             CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
  2974 
  2975             # Basic thread creation functions
  2976             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
  2977 
  2978             # Semaphores
  2979             # We can fake these with mutexes and condition variables if necessary
  2980             if test x$have_pthread_sem = xyes; then
  2981                 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
  2982             else
  2983                 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
  2984             fi
  2985 
  2986             # Mutexes
  2987             # We can fake these with semaphores if necessary
  2988             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
  2989 
  2990             # Condition variables
  2991             # We can fake these with semaphores and mutexes if necessary
  2992             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
  2993 
  2994             # Thread local storage
  2995             SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systls.c"
  2996 
  2997             have_threads=yes
  2998         fi
  2999     fi
  3000 }
  3001 
  3002 dnl Determine whether the compiler can produce Windows executables
  3003 CheckWINDOWS()
  3004 {
  3005     AC_MSG_CHECKING(Windows compiler)
  3006     have_win32_gcc=no
  3007     AC_TRY_COMPILE([
  3008      #include <windows.h>
  3009     ],[
  3010     ],[
  3011     have_win32_gcc=yes
  3012     ])
  3013     AC_MSG_RESULT($have_win32_gcc)
  3014     if test x$have_win32_gcc != xyes; then
  3015        AC_MSG_ERROR([
  3016 *** Your compiler ($CC) does not produce Windows executables!
  3017        ])
  3018     fi
  3019 
  3020     AC_MSG_CHECKING(Windows CE)
  3021     have_wince=no
  3022     AC_TRY_COMPILE([
  3023 #if !defined(_WIN32_WCE) && !defined(__MINGW32CE__)
  3024 #error This is not Windows CE
  3025 #endif
  3026     ],[
  3027     ],[
  3028     have_wince=yes
  3029        AC_MSG_ERROR([
  3030 *** Sorry, Windows CE is no longer supported.
  3031        ])
  3032     ])
  3033     AC_MSG_RESULT($have_wince)
  3034 
  3035     # This fixes Windows stack alignment with newer GCC
  3036     CheckStackBoundary
  3037 }
  3038 
  3039 dnl Find the DirectX includes and libraries
  3040 CheckDIRECTX()
  3041 {
  3042     AC_ARG_ENABLE(directx,
  3043 AS_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]),
  3044                   , enable_directx=yes)
  3045     if test x$enable_directx = xyes; then
  3046         AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
  3047         AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes)
  3048         AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
  3049         AC_CHECK_HEADER(dsound.h, have_dsound=yes)
  3050         AC_CHECK_HEADER(dinput.h, have_dinput=yes)
  3051         AC_CHECK_HEADER(dxgi.h, have_dxgi=yes)
  3052         AC_CHECK_HEADER(xinput.h, have_xinput=yes)
  3053         AC_TRY_COMPILE([
  3054 #include <windows.h>
  3055 #include <xinput.h>
  3056 XINPUT_GAMEPAD_EX x1;
  3057         ],[],[have_xinput_gamepadex=yes])
  3058         AC_TRY_COMPILE([
  3059 #include <windows.h>
  3060 #include <xinput.h>
  3061 XINPUT_STATE_EX s1;
  3062         ],[],[have_xinput_stateex=yes])
  3063 
  3064         if test x$have_ddraw = xyes; then
  3065             AC_DEFINE(HAVE_DDRAW_H, 1, [ ])
  3066         fi
  3067         if test x$have_dinput = xyes; then
  3068             AC_DEFINE(HAVE_DINPUT_H, 1, [ ])
  3069         fi
  3070         if test x$have_dsound = xyes; then
  3071             AC_DEFINE(HAVE_DSOUND_H, 1, [ ])
  3072         fi
  3073         if test x$have_dxgi = xyes; then
  3074             AC_DEFINE(HAVE_DXGI_H, 1, [ ])
  3075         fi
  3076         if test x$have_xinput = xyes; then
  3077             AC_DEFINE(HAVE_XINPUT_H, 1, [ ])
  3078         fi
  3079         if test x$have_xinput_gamepadex = xyes; then
  3080             AC_DEFINE(HAVE_XINPUT_GAMEPAD_EX, 1, [ ])
  3081         fi
  3082         if test x$have_xinput_stateex = xyes; then
  3083             AC_DEFINE(HAVE_XINPUT_STATE_EX, 1, [ ])
  3084         fi
  3085 
  3086         # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
  3087         # FIXME:  ...so force it off for now.
  3088         case "$host" in
  3089             *-*-cygwin*)
  3090             have_dinput=false
  3091             ;;
  3092         esac
  3093     fi
  3094 
  3095     AC_CHECK_HEADER(mmdeviceapi.h, have_wasapi=yes)
  3096     if test x$have_wasapi = xyes; then
  3097         AC_DEFINE(HAVE_MMDEVICEAPI_H,1,[])
  3098     fi
  3099     AC_CHECK_HEADER(audioclient.h,,have_wasapi=no)
  3100     if test x$have_wasapi = xyes; then
  3101         AC_DEFINE(HAVE_AUDIOCLIENT_H,1,[])
  3102     fi
  3103 
  3104     AC_ARG_ENABLE(wasapi,
  3105 AS_HELP_STRING([--enable-wasapi], [use the Windows WASAPI audio driver [[default=yes]]]),
  3106                                 , enable_wasapi=yes)
  3107 }
  3108 
  3109 dnl Check for the dlfcn.h interface for dynamically loading objects
  3110 CheckDLOPEN()
  3111 {
  3112     AC_ARG_ENABLE(sdl-dlopen,
  3113 AS_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
  3114                   , enable_sdl_dlopen=yes)
  3115     if test x$enable_sdl_dlopen = xyes; then
  3116         AC_MSG_CHECKING(for dlopen)
  3117         have_dlopen=no
  3118         AC_TRY_COMPILE([
  3119          #include <dlfcn.h>
  3120         ],[
  3121          void *handle = dlopen("", RTLD_NOW);
  3122          const char *loaderror = (char *) dlerror();
  3123         ],[
  3124         have_dlopen=yes
  3125         ])
  3126         AC_MSG_RESULT($have_dlopen)
  3127 
  3128         if test x$have_dlopen = xyes; then
  3129             AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
  3130                AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
  3131                   AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
  3132             AC_DEFINE(SDL_LOADSO_DLOPEN, 1, [ ])
  3133             SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
  3134             have_loadso=yes
  3135         fi
  3136     fi
  3137 }
  3138 
  3139 dnl Check for the usbhid(3) library on *BSD
  3140 CheckUSBHID()
  3141 {
  3142     case "$host" in
  3143         *-*-*bsd*)
  3144             if test x$enable_joystick = xyes; then
  3145                 AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
  3146                 if test x$have_libusbhid = xyes; then
  3147                     AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
  3148                     AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
  3149                     USB_LIBS="$USB_LIBS -lusbhid"
  3150                 else
  3151                     AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
  3152                     AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
  3153                     AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
  3154                 fi
  3155                 
  3156                 save_CFLAGS="$CFLAGS"
  3157                 CFLAGS="$CFLAGS $USB_CFLAGS"
  3158 
  3159                 AC_MSG_CHECKING(for usbhid)
  3160                 have_usbhid=no
  3161                 AC_TRY_COMPILE([
  3162                   #include <sys/types.h>
  3163                   #if defined(HAVE_USB_H)
  3164                   #include <usb.h>
  3165                   #endif
  3166                   #ifdef __DragonFly__
  3167                   # include <bus/usb/usb.h>
  3168                   # include <bus/usb/usbhid.h>
  3169                   #else
  3170                   # include <dev/usb/usb.h>
  3171                   # include <dev/usb/usbhid.h>
  3172                   #endif
  3173                   #if defined(HAVE_USBHID_H)
  3174                   #include <usbhid.h>
  3175                   #elif defined(HAVE_LIBUSB_H)
  3176                   #include <libusb.h>
  3177                   #elif defined(HAVE_LIBUSBHID_H)
  3178                   #include <libusbhid.h>
  3179                   #endif
  3180                 ],[
  3181                   struct report_desc *repdesc;
  3182                   struct usb_ctl_report *repbuf;
  3183                   hid_kind_t hidkind;
  3184                 ],[
  3185                 have_usbhid=yes
  3186                 ])
  3187                 AC_MSG_RESULT($have_usbhid)
  3188 
  3189                 if test x$have_usbhid = xyes; then
  3190                     AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
  3191                     have_usbhid_ucr_data=no
  3192                     AC_TRY_COMPILE([
  3193                       #include <sys/types.h>
  3194                       #if defined(HAVE_USB_H)
  3195                       #include <usb.h>
  3196                       #endif
  3197                       #ifdef __DragonFly__
  3198                       # include <bus/usb/usb.h>
  3199                       # include <bus/usb/usbhid.h>
  3200                       #else
  3201                       # include <dev/usb/usb.h>
  3202                       # include <dev/usb/usbhid.h>
  3203                       #endif
  3204                       #if defined(HAVE_USBHID_H)
  3205                       #include <usbhid.h>
  3206                       #elif defined(HAVE_LIBUSB_H)
  3207                       #include <libusb.h>
  3208                       #elif defined(HAVE_LIBUSBHID_H)
  3209                       #include <libusbhid.h>
  3210                       #endif
  3211                     ],[
  3212                       struct usb_ctl_report buf;
  3213                       if (buf.ucr_data) { }
  3214                     ],[
  3215                     have_usbhid_ucr_data=yes
  3216                     ])
  3217                     if test x$have_usbhid_ucr_data = xyes; then
  3218                         USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
  3219                     fi
  3220                     AC_MSG_RESULT($have_usbhid_ucr_data)
  3221                     
  3222                     AC_MSG_CHECKING(for new usbhid API)
  3223                     have_usbhid_new=no
  3224                     AC_TRY_COMPILE([
  3225                       #include <sys/types.h>
  3226                       #if defined(HAVE_USB_H)
  3227                       #include <usb.h>
  3228                       #endif
  3229                       #ifdef __DragonFly__
  3230                       #include <bus/usb/usb.h>
  3231                       #include <bus/usb/usbhid.h>
  3232                       #else
  3233                       #include <dev/usb/usb.h>
  3234                       #include <dev/usb/usbhid.h>
  3235                       #endif
  3236                       #if defined(HAVE_USBHID_H)
  3237                       #include <usbhid.h>
  3238                       #elif defined(HAVE_LIBUSB_H)
  3239                       #include <libusb.h>
  3240                       #elif defined(HAVE_LIBUSBHID_H)
  3241                       #include <libusbhid.h>
  3242                       #endif
  3243                     ],[
  3244                       report_desc_t d;
  3245                       hid_start_parse(d, 1, 1);
  3246                     ],[
  3247                     have_usbhid_new=yes
  3248                     ])
  3249                     if test x$have_usbhid_new = xyes; then
  3250                         USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
  3251                     fi
  3252                     AC_MSG_RESULT($have_usbhid_new)
  3253 
  3254                     AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
  3255                     have_machine_joystick=no
  3256                     AC_TRY_COMPILE([
  3257                       #include <machine/joystick.h>
  3258                     ],[
  3259                       struct joystick t;
  3260                     ],[
  3261                     have_machine_joystick=yes
  3262                     ])
  3263                     if test x$have_machine_joystick = xyes; then
  3264                         AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ])
  3265                     fi
  3266                     AC_MSG_RESULT($have_machine_joystick)
  3267 
  3268                     AC_DEFINE(SDL_JOYSTICK_USBHID, 1, [ ])
  3269                     SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
  3270                     EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
  3271                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
  3272                     have_joystick=yes
  3273                 fi
  3274                 CFLAGS="$save_CFLAGS"
  3275             fi
  3276         ;;
  3277     esac
  3278 }
  3279 
  3280 dnl Check for HIDAPI joystick drivers
  3281 CheckHIDAPI()
  3282 {
  3283     # The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers,
  3284     # so we'll just use libusb when it's available.
  3285     case "$host" in
  3286         # libusb does not support iOS
  3287         arm*-apple-darwin* | *-ios-* )
  3288             skiplibusb=yes
  3289             ;;
  3290         # On the other hand, *BSD specifically uses libusb only
  3291         *-*-*bsd* )
  3292             onlylibusb=yes
  3293             ;;
  3294     esac
  3295 
  3296     AC_ARG_ENABLE(hidapi,
  3297 AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=no]]]),
  3298                   , enable_hidapi=no)
  3299     if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then
  3300         if test x$skiplibusb = xyes; then
  3301             hidapi_support=yes
  3302         else
  3303             PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no)
  3304             save_CFLAGS="$CFLAGS"
  3305             CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS"
  3306             AC_CHECK_HEADER(libusb.h, have_libusb_h=yes)
  3307             CFLAGS="$save_CFLAGS"
  3308             if test x$have_libusb_h = xyes; then
  3309                 hidapi_support=yes
  3310             elif test x$onlylibusb = xyes; then
  3311                 hidapi_support=no
  3312             else
  3313                 hidapi_support=yes
  3314             fi
  3315         fi
  3316 
  3317         if test x$hidapi_support = xyes; then
  3318             AC_DEFINE(SDL_JOYSTICK_HIDAPI, 1, [ ])
  3319             EXTRA_CFLAGS="$EXTRA_CFLAGS -I$srcdir/src/hidapi/hidapi"
  3320             SOURCES="$SOURCES $srcdir/src/joystick/hidapi/*.c"
  3321             SOURCES="$SOURCES $srcdir/src/hidapi/SDL_hidapi.c"
  3322 
  3323             if test x$have_libusb_h = xyes; then
  3324                 EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
  3325                 if test x$onlylibusb = xyes; then
  3326                     SOURCES="$SOURCES $srcdir/src/hidapi/libusb/hid.c"
  3327                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
  3328                 else
  3329                     if test x$have_loadso != xyes; then
  3330                         AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic libusb loading])
  3331                     fi
  3332                     # libusb is loaded dynamically, so don't add it to LDFLAGS
  3333                     libusb_lib=""
  3334                     case "$host" in
  3335                         *-*-darwin* )
  3336                             libusb_lib="libusb-1.0.0.dylib"
  3337                             ;;
  3338                         *-*-cygwin* | *-*-mingw32* )
  3339                             libusb_lib="libusb-1.0.dll"
  3340                             ;;
  3341                     esac
  3342                     if test x$libusb_lib = x; then
  3343                         libusb_lib=[`find_lib "libusb-1.0.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
  3344                     fi
  3345                     AC_DEFINE_UNQUOTED(SDL_LIBUSB_DYNAMIC, "$libusb_lib", [ ])
  3346                 fi
  3347             fi
  3348         fi
  3349 
  3350         AC_MSG_CHECKING(for hidapi support)
  3351         AC_MSG_RESULT($hidapi_support)
  3352     fi
  3353 }
  3354 
  3355 dnl Check for clock_gettime()
  3356 CheckClockGettime()
  3357 {
  3358     AC_ARG_ENABLE(clock_gettime,
  3359 AS_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=yes]]]),
  3360                   , enable_clock_gettime=yes)
  3361     if test x$enable_clock_gettime = xyes; then
  3362         AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
  3363         if test x$have_clock_gettime = xyes; then
  3364             AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  3365             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
  3366         else
  3367             AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
  3368             if test x$have_clock_gettime = xyes; then
  3369                AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
  3370                EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
  3371             fi
  3372         fi
  3373     fi
  3374 }
  3375 
  3376 dnl Check for a valid linux/version.h
  3377 CheckLinuxVersion()
  3378 {
  3379     AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
  3380     if test x$have_linux_version_h = xyes; then
  3381         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
  3382     fi
  3383 }
  3384 
  3385 dnl Check if we want to use RPATH
  3386 CheckRPATH()
  3387 {
  3388     AC_ARG_ENABLE(rpath,
  3389 AS_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
  3390                   , enable_rpath=yes)
  3391 }
  3392 
  3393 dnl Check if we want to use custom signals to fake iOS/Android's backgrounding
  3394 dnl  events. These could be useful if you're building a custom embedded
  3395 dnl  environment, etc, but most people don't need this.
  3396 CheckEventSignals()
  3397 {
  3398     AC_ARG_ENABLE(backgrounding-signal,
  3399 AS_HELP_STRING([--enable-backgrounding-signal], [number to use for magic backgrounding signal or 'no' [[default=no]]]),
  3400                   , enable_backgrounding_signal=no)
  3401     if test x$enable_backgrounding_signal != xno; then
  3402         EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_BACKGROUNDING_SIGNAL=$enable_backgrounding_signal"
  3403     fi
  3404 
  3405     AC_ARG_ENABLE(foregrounding-signal,
  3406 AS_HELP_STRING([--enable-foregrounding-signal], [number to use for magic foregrounding signal or 'no' [[default=no]]]),
  3407                   , enable_foregrounding_signal=no)
  3408     if test x$enable_foregrounding_signal != xno; then
  3409         EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_FOREGROUNDING_SIGNAL=$enable_foregrounding_signal"
  3410     fi
  3411 }
  3412 
  3413 
  3414 
  3415 dnl Do this on all platforms, before everything else (other things might want to override it).
  3416 CheckWarnAll
  3417 CheckNoStrictAliasing
  3418 
  3419 dnl Do this for every platform, but for some it doesn't mean anything, but better to catch it here anyhow.
  3420 CheckEventSignals
  3421 
  3422 dnl Set up the configuration based on the host platform!
  3423 case "$host" in
  3424     *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-aix*|*-*-minix*|*-*-nto*)
  3425         case "$host" in
  3426             *-*-android*)
  3427                 # Android
  3428                 ARCH=android
  3429                 ANDROID_CFLAGS="-DGL_GLEXT_PROTOTYPES"
  3430                 CFLAGS="$CFLAGS $ANDROID_CFLAGS"
  3431                 SDL_CFLAGS="$SDL_CFLAGS $ANDROID_CFLAGS"
  3432                 EXTRA_CFLAGS="$EXTRA_CFLAGS $ANDROID_CFLAGS"
  3433                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl -lGLESv1_CM -lGLESv2 -llog -landroid"
  3434                 SDLMAIN_SOURCES="$srcdir/src/main/android/*.c"
  3435 
  3436                 if test x$enable_video = xyes; then
  3437                     SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c"
  3438                     # FIXME: confdefs? Not AC_DEFINE?
  3439                     $as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
  3440                     SUMMARY_video="${SUMMARY_video} android"
  3441                 fi
  3442                 ;;
  3443             *-*-linux*)         ARCH=linux ;;
  3444             *-*-uclinux*)       ARCH=linux ;;
  3445             *-*-kfreebsd*-gnu)  ARCH=kfreebsd-gnu ;;
  3446             *-*-knetbsd*-gnu)   ARCH=knetbsd-gnu ;;
  3447             *-*-kopenbsd*-gnu)  ARCH=kopenbsd-gnu ;;
  3448             *-*-gnu*)           ARCH=gnu ;; # must be last of the gnu variants
  3449             *-*-bsdi*)          ARCH=bsdi ;;
  3450             *-*-freebsd*)       ARCH=freebsd ;;
  3451             *-*-dragonfly*)     ARCH=freebsd ;;
  3452             *-*-netbsd*)        ARCH=netbsd ;;
  3453             *-*-openbsd*)       ARCH=openbsd ;;
  3454             *-*-sysv5*)         ARCH=sysv5 ;;
  3455             *-*-solaris*)       ARCH=solaris ;;
  3456             *-*-hpux*)          ARCH=hpux ;;
  3457             *-*-aix*)           ARCH=aix ;;
  3458             *-*-minix*)         ARCH=minix ;;
  3459             *-*-nto*)           ARCH=nto
  3460                 CheckQNXVideo
  3461                 ;;
  3462         esac
  3463         CheckVisibilityHidden
  3464         CheckDeclarationAfterStatement
  3465         CheckDummyVideo
  3466         CheckDiskAudio
  3467         CheckDummyAudio
  3468         CheckDLOPEN
  3469         CheckARM
  3470         CheckNEON
  3471         CheckOSS
  3472         CheckALSA
  3473         CheckPulseAudio
  3474         CheckJACK
  3475         CheckARTSC
  3476         CheckESD
  3477         CheckNAS
  3478         CheckSNDIO
  3479         CheckFusionSound
  3480         CheckLibSampleRate
  3481         # Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
  3482         CheckRPI
  3483         CheckX11
  3484         CheckDirectFB
  3485         CheckKMSDRM
  3486         CheckOpenGLX11
  3487         CheckOpenGLESX11
  3488         CheckVulkan
  3489         CheckWayland
  3490         CheckInputEvents
  3491         CheckLibUDev
  3492         CheckDBus
  3493         CheckIME
  3494         CheckIBus
  3495         CheckFcitx
  3496         case $ARCH in
  3497           linux)
  3498               CheckInputKD
  3499           ;;
  3500         esac
  3501         CheckTslib
  3502         CheckUSBHID
  3503         CheckHIDAPI
  3504         CheckPTHREAD
  3505         CheckClockGettime
  3506         CheckLinuxVersion
  3507         CheckRPATH
  3508         CheckVivanteVideo
  3509 
  3510         # Set up files for the audio library
  3511         if test x$enable_audio = xyes; then
  3512           case $ARCH in
  3513             sysv5|solaris|hpux)
  3514                 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
  3515                 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
  3516                 SUMMARY_audio="${SUMMARY_audio} sun"
  3517                 have_audio=yes
  3518             ;;
  3519             netbsd)  # Don't use this on OpenBSD, it's busted.
  3520                 AC_DEFINE(SDL_AUDIO_DRIVER_NETBSD, 1, [ ])
  3521                 SOURCES="$SOURCES $srcdir/src/audio/netbsd/*.c"
  3522                 SUMMARY_audio="${SUMMARY_audio} netbsd"
  3523                 have_audio=yes
  3524             ;;
  3525             aix)
  3526                 AC_DEFINE(SDL_AUDIO_DRIVER_PAUDIO, 1, [ ])
  3527                 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
  3528                 SUMMARY_audio="${SUMMARY_audio} paudio"
  3529                 have_audio=yes
  3530             ;;
  3531             android)
  3532                 AC_DEFINE(SDL_AUDIO_DRIVER_ANDROID, 1, [ ])
  3533                 SOURCES="$SOURCES $srcdir/src/audio/android/*.c"
  3534                 SUMMARY_audio="${SUMMARY_audio} android"
  3535                 have_audio=yes
  3536             ;;
  3537             nto)
  3538                 CheckQNXAudio
  3539             ;;
  3540           esac
  3541         fi
  3542         # Set up files for the joystick library
  3543         if test x$enable_joystick = xyes; then
  3544           case $ARCH in
  3545             linux)
  3546                 AC_DEFINE(SDL_JOYSTICK_LINUX, 1, [ ])
  3547                 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
  3548                 SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c"
  3549                 have_joystick=yes
  3550             ;;
  3551             android)
  3552                 AC_DEFINE(SDL_JOYSTICK_ANDROID, 1, [ ])
  3553                 SOURCES="$SOURCES $srcdir/src/joystick/android/*.c"
  3554                 SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c"
  3555                 have_joystick=yes
  3556             ;;
  3557           esac
  3558         fi
  3559         # Set up files for the haptic library
  3560         if test x$enable_haptic = xyes; then
  3561           case $ARCH in
  3562             linux)
  3563                 if test x$use_input_events = xyes; then
  3564                     AC_DEFINE(SDL_HAPTIC_LINUX, 1, [ ])
  3565                     SOURCES="$SOURCES $srcdir/src/haptic/linux/*.c"
  3566                     have_haptic=yes
  3567                 fi
  3568             ;;
  3569             android)
  3570                 AC_DEFINE(SDL_HAPTIC_ANDROID, 1, [ ])
  3571                 SOURCES="$SOURCES $srcdir/src/haptic/android/*.c"
  3572                 have_haptic=yes
  3573             ;;
  3574           esac
  3575         fi
  3576         # Set up files for the sensor library
  3577         if test x$enable_sensor = xyes; then
  3578           case $ARCH in
  3579             android)
  3580                 AC_DEFINE(SDL_SENSOR_ANDROID, 1, [ ])
  3581                 SOURCES="$SOURCES $srcdir/src/sensor/android/*.c"
  3582                 have_sensor=yes
  3583             ;;
  3584           esac
  3585         fi
  3586         # Set up files for the power library
  3587         if test x$enable_power = xyes; then
  3588              case $ARCH in
  3589                linux)
  3590                    AC_DEFINE(SDL_POWER_LINUX, 1, [ ])
  3591                    SOURCES="$SOURCES $srcdir/src/power/linux/*.c"
  3592                    have_power=yes
  3593                ;;
  3594                android)
  3595                    AC_DEFINE(SDL_POWER_ANDROID, 1, [ ])
  3596                    SOURCES="$SOURCES $srcdir/src/power/android/*.c"
  3597                    have_power=yes
  3598                ;;
  3599              esac
  3600         fi
  3601         # Set up files for the filesystem library
  3602         if test x$enable_filesystem = xyes; then
  3603              case $ARCH in
  3604                android)
  3605                    AC_DEFINE(SDL_FILESYSTEM_ANDROID, 1, [ ])
  3606                    SOURCES="$SOURCES $srcdir/src/filesystem/android/*.c"
  3607                    have_filesystem=yes
  3608                ;;
  3609                *)
  3610                    AC_DEFINE(SDL_FILESYSTEM_UNIX, 1, [ ])
  3611                    SOURCES="$SOURCES $srcdir/src/filesystem/unix/*.c"
  3612                    have_filesystem=yes
  3613                ;;
  3614              esac
  3615         fi
  3616         # Set up files for the timer library
  3617         if test x$enable_timers = xyes; then
  3618             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  3619             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  3620             have_timers=yes
  3621         fi
  3622         # Set up files for udev hotplugging support
  3623         if test x$enable_libudev = xyes && test x$have_libudev_h_hdr = xyes; then
  3624             SOURCES="$SOURCES $srcdir/src/core/linux/SDL_udev.c"               
  3625         fi
  3626         # Set up files for evdev input
  3627         if test x$use_input_events = xyes; then
  3628             SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev*.c"
  3629         fi       
  3630         # Set up other core UNIX files
  3631         SOURCES="$SOURCES $srcdir/src/core/linux/SDL_threadprio.c"
  3632         SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
  3633         ;;
  3634     *-*-cygwin* | *-*-mingw32*)
  3635         ARCH=win32
  3636         if test "$build" != "$host"; then # cross-compiling
  3637             # Default cross-compile location
  3638             ac_default_prefix=/usr/local/cross-tools/$host
  3639         else
  3640             # Look for the location of the tools and install there
  3641             if test "$BUILD_PREFIX" != ""; then
  3642                 ac_default_prefix=$BUILD_PREFIX
  3643             fi
  3644         fi
  3645         CheckDeclarationAfterStatement
  3646         CheckDummyVideo
  3647         CheckDiskAudio
  3648         CheckDummyAudio
  3649         CheckWINDOWS
  3650         CheckWINDOWSGL
  3651         CheckWINDOWSGLES
  3652         CheckVulkan
  3653         CheckDIRECTX
  3654         CheckHIDAPI
  3655 
  3656         # Set up the core platform files
  3657         SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
  3658 
  3659         # Set up files for the video library
  3660         if test x$enable_video = xyes; then
  3661             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS, 1, [ ])
  3662             SOURCES="$SOURCES $srcdir/src/video/windows/*.c"
  3663             have_video=yes
  3664             AC_ARG_ENABLE(render-d3d,
  3665 AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]),
  3666                                 , enable_render_d3d=yes)
  3667             if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then
  3668                 AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ])
  3669                 SUMMARY_video="${SUMMARY_video} d3d9"
  3670             fi
  3671             if test x$enable_render_d3d = xyes -a x$have_d3d11 = xyes; then
  3672                 AC_DEFINE(SDL_VIDEO_RENDER_D3D11, 1, [ ])
  3673                 SUMMARY_video="${SUMMARY_video} d3d11"
  3674             fi
  3675         fi
  3676         # Set up files for the audio library
  3677         if test x$enable_audio = xyes; then
  3678             AC_DEFINE(SDL_AUDIO_DRIVER_WINMM, 1, [ ])
  3679             SUMMARY_audio="${SUMMARY_audio} winmm"
  3680             SOURCES="$SOURCES $srcdir/src/audio/winmm/*.c"
  3681             if test x$have_dsound = xyes; then
  3682                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
  3683                 SUMMARY_audio="${SUMMARY_audio} directsound"
  3684                 SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
  3685             fi
  3686             if test x$have_wasapi = xyes -a x$enable_wasapi = xyes; then
  3687                 AC_DEFINE(SDL_AUDIO_DRIVER_WASAPI, 1, [ ])
  3688                 SUMMARY_audio="${SUMMARY_audio} wasapi"
  3689                 SOURCES="$SOURCES $srcdir/src/audio/wasapi/*.c"
  3690             fi
  3691             have_audio=yes
  3692         fi
  3693         # Set up files for the joystick library
  3694         if test x$enable_joystick = xyes; then
  3695             if test x$have_dinput = xyes -o x$have_xinput = xyes; then
  3696                 if test x$have_xinput = xyes; then
  3697                     AC_DEFINE(SDL_JOYSTICK_XINPUT, 1, [ ])
  3698                 fi
  3699                 if test x$have_dinput = xyes; then
  3700                     AC_DEFINE(SDL_JOYSTICK_DINPUT, 1, [ ])
  3701                     EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8"
  3702                 fi
  3703             else
  3704                 AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ])
  3705             fi
  3706             SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c"
  3707             have_joystick=yes
  3708         fi
  3709         if test x$enable_haptic = xyes; then
  3710             if test x$have_dinput = xyes -o x$have_xinput = xyes; then
  3711                 if test x$have_xinput = xyes; then
  3712                     AC_DEFINE(SDL_HAPTIC_XINPUT, 1, [ ])
  3713                 fi
  3714                 if test x$have_dinput = xyes; then
  3715                     AC_DEFINE(SDL_HAPTIC_DINPUT, 1, [ ])
  3716                 fi
  3717                 SOURCES="$SOURCES $srcdir/src/haptic/windows/*.c"
  3718                 have_haptic=yes
  3719             fi
  3720         fi
  3721         if test x$enable_power = xyes; then
  3722             AC_DEFINE(SDL_POWER_WINDOWS, 1, [ ])
  3723             SOURCES="$SOURCES $srcdir/src/power/windows/SDL_syspower.c"
  3724             have_power=yes
  3725         fi
  3726         if test x$enable_filesystem = xyes; then
  3727             AC_DEFINE(SDL_FILESYSTEM_WINDOWS, 1, [ ])
  3728             SOURCES="$SOURCES $srcdir/src/filesystem/windows/SDL_sysfilesystem.c"
  3729             have_filesystem=yes
  3730         fi
  3731         # Set up files for the thread library
  3732         if test x$enable_threads = xyes; then
  3733             AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ])
  3734             SOURCES="$SOURCES $srcdir/src/thread/windows/*.c"
  3735             SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
  3736             have_threads=yes
  3737         fi
  3738         # Set up files for the timer library
  3739         if test x$enable_timers = xyes; then
  3740             AC_DEFINE(SDL_TIMER_WINDOWS, 1, [ ])
  3741             SOURCES="$SOURCES $srcdir/src/timer/windows/*.c"
  3742             have_timers=yes
  3743         fi
  3744         # Set up files for the shared object loading library
  3745         if test x$enable_loadso = xyes; then
  3746             AC_DEFINE(SDL_LOADSO_WINDOWS, 1, [ ])
  3747             SOURCES="$SOURCES $srcdir/src/loadso/windows/*.c"
  3748             have_loadso=yes
  3749         fi
  3750         # Set up the system libraries we need
  3751         if test -f /lib/w32api/libuuid.a; then
  3752             LIBUUID=/lib/w32api/libuuid.a
  3753         else
  3754             LIBUUID=-luuid
  3755         fi
  3756         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion $LIBUUID -static-libgcc"
  3757         # The Windows platform requires special setup
  3758         VERSION_SOURCES="$srcdir/src/main/windows/*.rc"
  3759         SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c"
  3760         SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
  3761         SDL_LIBS="-lSDL2main $SDL_LIBS -mwindows"
  3762 
  3763         # Check to see if this is a mingw or cygwin build
  3764         have_mingw32=
  3765         AC_CHECK_LIB(mingw32, main, [have_mingw32=yes])
  3766         if test x$have_mingw32 = xyes; then
  3767             SDL_LIBS="-lmingw32 $SDL_LIBS"
  3768         else
  3769             SDL_LIBS="-lcygwin $SDL_LIBS"
  3770         fi
  3771         ;;
  3772 
  3773     dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
  3774     *-*-beos*)
  3775         AC_MSG_ERROR([
  3776 *** BeOS support has been removed as of SDL 2.0.2.
  3777         ])
  3778         ;;
  3779 
  3780     *-*-haiku*)
  3781         ARCH=haiku
  3782         ac_default_prefix=/boot/system
  3783         CheckDummyVideo
  3784         CheckDiskAudio
  3785         CheckDummyAudio
  3786         CheckDLOPEN
  3787         CheckHaikuVideo
  3788         CheckHaikuGL
  3789         CheckPTHREAD
  3790 
  3791         # Set up files for the audio library
  3792         if test x$enable_audio = xyes; then
  3793             AC_DEFINE(SDL_AUDIO_DRIVER_HAIKU, 1, [ ])
  3794             SOURCES="$SOURCES $srcdir/src/audio/haiku/*.cc"
  3795             SUMMARY_audio="${SUMMARY_audio} haiku"
  3796             have_audio=yes
  3797         fi
  3798         # Set up files for the joystick library
  3799         if test x$enable_joystick = xyes; then
  3800             AC_DEFINE(SDL_JOYSTICK_HAIKU, 1, [ ])
  3801             SOURCES="$SOURCES $srcdir/src/joystick/haiku/*.cc"
  3802             have_joystick=yes
  3803         fi
  3804         # Set up files for the timer library
  3805         if test x$enable_timers = xyes; then
  3806             AC_DEFINE(SDL_TIMER_HAIKU, 1, [ ])
  3807             SOURCES="$SOURCES $srcdir/src/timer/haiku/*.c"
  3808             have_timers=yes
  3809         fi
  3810         # Set up files for the system power library
  3811         if test x$enable_power = xyes; then
  3812             AC_DEFINE(SDL_POWER_HAIKU, 1, [ ])
  3813             SOURCES="$SOURCES $srcdir/src/power/haiku/*.c"
  3814             have_power=yes
  3815         fi
  3816         # Set up files for the system filesystem library
  3817         if test x$enable_filesystem = xyes; then
  3818             AC_DEFINE(SDL_FILESYSTEM_HAIKU, 1, [ ])
  3819             SOURCES="$SOURCES $srcdir/src/filesystem/haiku/*.cc"
  3820             have_filesystem=yes
  3821         fi
  3822         # The Haiku platform requires special setup.
  3823         SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
  3824         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
  3825         # Haiku's x86 spins use libstdc++.r4.so (for binary compat?), but
  3826         #  other spins, like x86-64, use a more standard "libstdc++.so.*"
  3827         AC_CHECK_FILE("/boot/system/lib/libstdc++.r4.so", EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++.r4", EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++")
  3828         ;;
  3829     arm*-apple-darwin*|*-ios-*)
  3830         ARCH=ios
  3831 
  3832         CheckVisibilityHidden
  3833         CheckDeclarationAfterStatement
  3834         CheckDummyVideo
  3835         CheckDiskAudio
  3836         CheckDummyAudio
  3837         CheckDLOPEN
  3838         CheckMETAL
  3839         CheckVulkan
  3840         CheckPTHREAD
  3841 
  3842         # Set up files for the audio library
  3843         if test x$enable_audio = xyes; then
  3844             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
  3845             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
  3846             SUMMARY_audio="${SUMMARY_audio} coreaudio"
  3847             have_audio=yes
  3848         fi
  3849         # Set up files for the joystick library
  3850         if test x$enable_joystick = xyes; then
  3851             AC_DEFINE(SDL_JOYSTICK_MFI, 1, [ ])
  3852             SOURCES="$SOURCES $srcdir/src/joystick/iphoneos/*.m"
  3853             SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c"
  3854             have_joystick=yes
  3855         fi
  3856         # Set up files for the haptic library
  3857         #if test x$enable_haptic = xyes; then
  3858         #    SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  3859         #    have_haptic=yes
  3860         #    EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  3861         #fi
  3862         # Set up files for the sensor library
  3863         if test x$enable_sensor = xyes; then
  3864             AC_DEFINE(SDL_SENSOR_COREMOTION, 1, [ ])
  3865             SOURCES="$SOURCES $srcdir/src/sensor/coremotion/*.m"
  3866             have_sensor=yes
  3867         fi
  3868         # Set up files for the power library
  3869         if test x$enable_power = xyes; then
  3870             AC_DEFINE(SDL_POWER_UIKIT, 1, [ ])
  3871             SOURCES="$SOURCES $srcdir/src/power/uikit/*.m"
  3872             have_power=yes
  3873         fi
  3874         # Set up files for the filesystem library
  3875         if test x$enable_filesystem = xyes; then
  3876             SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
  3877             have_filesystem=yes
  3878         fi
  3879         # Set up additional files for the file library
  3880         if test x$enable_file = xyes; then
  3881             AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
  3882             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  3883         fi
  3884         # Set up files for the timer library
  3885         if test x$enable_timers = xyes; then
  3886             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  3887             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  3888             have_timers=yes
  3889         fi
  3890         # Set up other core UNIX files
  3891         SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
  3892         # The iOS platform requires special setup.
  3893         AC_DEFINE(SDL_VIDEO_DRIVER_UIKIT, 1, [ ])
  3894         AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ])
  3895         AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ])
  3896         AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES, 1, [ ])
  3897         AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES2, 1, [ ])
  3898         SOURCES="$SOURCES $srcdir/src/video/uikit/*.m"
  3899         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm -liconv -lobjc"
  3900         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AVFoundation"
  3901         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox"
  3902         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio"
  3903         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreGraphics"
  3904         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreMotion"
  3905         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Foundation"
  3906         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,GameController"
  3907         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGLES"
  3908         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuartzCore"
  3909         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,UIKit"
  3910 
  3911         if test x$enable_video_metal = xyes -o x$enable_video_vulkan = xyes; then
  3912             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Metal"
  3913         fi
  3914         ;;
  3915     *-*-darwin* )
  3916         # This could be either full "Mac OS X", or plain "Darwin" which is
  3917         # just the OS X kernel sans upper layers like Carbon and Cocoa.
  3918         # Next line is broken, and a few files below require Mac OS X (full)
  3919         ARCH=macosx
  3920 
  3921         # Mac OS X builds with both the Carbon and OSX APIs at the moment
  3922         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
  3923         EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
  3924 
  3925         CheckVisibilityHidden
  3926         CheckDeclarationAfterStatement
  3927         CheckDummyVideo
  3928         CheckDiskAudio
  3929         CheckDummyAudio
  3930         CheckDLOPEN
  3931         CheckCOCOA
  3932         CheckMETAL
  3933         CheckX11
  3934         CheckMacGL
  3935         CheckMacGLES
  3936         CheckOpenGLX11
  3937         CheckVulkan
  3938         CheckPTHREAD
  3939         CheckHIDAPI
  3940 
  3941         # Set up files for the audio library
  3942         if test x$enable_audio = xyes; then
  3943             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
  3944             SOURCES="$SOURCES $srcdir/src/audio/coreaudio/*.m"
  3945             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox"
  3946             SUMMARY_audio="${SUMMARY_audio} coreaudio"
  3947             have_audio=yes
  3948         fi
  3949         # Set up files for the joystick library
  3950         if test x$enable_joystick = xyes; then
  3951             AC_DEFINE(SDL_JOYSTICK_IOKIT, 1, [ ])
  3952             SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
  3953             have_joystick=yes
  3954         fi
  3955         # Set up files for the haptic library
  3956         if test x$enable_haptic = xyes; then
  3957             AC_DEFINE(SDL_HAPTIC_IOKIT, 1, [ ])
  3958             SOURCES="$SOURCES $srcdir/src/haptic/darwin/*.c"
  3959             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ForceFeedback"
  3960             have_haptic=yes
  3961         fi
  3962         # Set up files for the power library
  3963         if test x$enable_power = xyes; then
  3964             AC_DEFINE(SDL_POWER_MACOSX, 1, [ ])
  3965             SOURCES="$SOURCES $srcdir/src/power/macosx/*.c"
  3966             have_power=yes
  3967         fi
  3968         # Set up files for the filesystem library
  3969         if test x$enable_filesystem = xyes; then
  3970             AC_DEFINE(SDL_FILESYSTEM_COCOA, 1, [ ])
  3971             SOURCES="$SOURCES $srcdir/src/filesystem/cocoa/*.m"
  3972             have_filesystem=yes
  3973         fi
  3974         # Set up files for the timer library
  3975         if test x$enable_timers = xyes; then
  3976             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  3977             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  3978             have_timers=yes
  3979         fi
  3980         # Set up additional files for the file library
  3981         if test x$enable_file = xyes; then
  3982             SOURCES="$SOURCES $srcdir/src/file/cocoa/*.m"
  3983         fi
  3984         # Set up other core UNIX files
  3985         SOURCES="$SOURCES $srcdir/src/core/unix/*.c"
  3986         # The Mac OS X platform requires special setup.
  3987         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
  3988         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreVideo"
  3989         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
  3990         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
  3991         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
  3992 
  3993         if test x$enable_video_metal = xyes -o x$enable_video_vulkan = xyes; then
  3994             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-weak_framework,QuartzCore -Wl,-weak_framework,Metal"
  3995         fi
  3996         ;;
  3997     *-nacl|*-pnacl)
  3998         ARCH=nacl
  3999         CheckNativeClient
  4000         CheckDummyAudio
  4001         CheckDummyVideo
  4002         CheckInputEvents
  4003         CheckPTHREAD
  4004 
  4005         # Set up files for the timer library
  4006         if test x$enable_timers = xyes; then
  4007             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  4008             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  4009             have_timers=yes
  4010         fi
  4011         
  4012         if test x$enable_filesystem = xyes; then
  4013             AC_DEFINE(SDL_FILESYSTEM_NACL, 1, [ ])
  4014             SOURCES="$SOURCES $srcdir/src/filesystem/nacl/*.c"
  4015             have_filesystem=yes
  4016         fi
  4017         ;;
  4018     *-*-emscripten* )
  4019         if test x$enable_video = xyes; then
  4020             AC_DEFINE(SDL_VIDEO_DRIVER_EMSCRIPTEN, 1, [ ])
  4021             SOURCES="$SOURCES $srcdir/src/video/emscripten/*.c"
  4022             have_video=yes
  4023             SUMMARY_video="${SUMMARY_video} emscripten"
  4024         fi
  4025 
  4026         if test x$enable_audio = xyes; then
  4027             AC_DEFINE(SDL_AUDIO_DRIVER_EMSCRIPTEN, 1, [ ])
  4028             SOURCES="$SOURCES $srcdir/src/audio/emscripten/*.c"
  4029             have_audio=yes
  4030             SUMMARY_audio="${SUMMARY_audio} emscripten"
  4031         fi
  4032 
  4033         CheckVisibilityHidden
  4034         CheckDeclarationAfterStatement
  4035         CheckDummyVideo
  4036         CheckDiskAudio
  4037         CheckDummyAudio
  4038         CheckDLOPEN
  4039         CheckClockGettime
  4040         CheckEmscriptenGLES
  4041 
  4042          # Set up files for the power library
  4043         if test x$enable_power = xyes; then
  4044             AC_DEFINE(SDL_POWER_EMSCRIPTEN, 1, [ ])
  4045             SOURCES="$SOURCES $srcdir/src/power/emscripten/*.c"
  4046             have_power=yes
  4047         fi
  4048         
  4049         # Set up files for the power library
  4050         if test x$enable_joystick = xyes; then
  4051             AC_DEFINE(SDL_JOYSTICK_EMSCRIPTEN, 1, [ ])
  4052             SOURCES="$SOURCES $srcdir/src/joystick/emscripten/*.c"
  4053             have_joystick=yes
  4054         fi
  4055 
  4056         # Set up files for the filesystem library
  4057         if test x$enable_filesystem = xyes; then
  4058             AC_DEFINE(SDL_FILESYSTEM_EMSCRIPTEN, 1, [ ])
  4059             SOURCES="$SOURCES $srcdir/src/filesystem/emscripten/*.c"
  4060             have_filesystem=yes
  4061         fi
  4062         # Set up files for the timer library
  4063         if test x$enable_timers = xyes; then
  4064             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  4065             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  4066             have_timers=yes
  4067         fi
  4068         ;;
  4069     *-*-riscos*)
  4070         ARCH=riscos
  4071         CheckVisibilityHidden
  4072         CheckDeclarationAfterStatement
  4073         CheckDummyVideo
  4074         CheckDiskAudio
  4075         CheckDummyAudio
  4076         CheckDLOPEN
  4077         CheckOSS
  4078         CheckPTHREAD
  4079         CheckClockGettime
  4080 
  4081         # Set up files for the timer library
  4082         if test x$enable_timers = xyes; then
  4083             AC_DEFINE(SDL_TIMER_UNIX, 1, [ ])
  4084             SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
  4085             have_timers=yes
  4086         fi
  4087         ;;
  4088     *)
  4089         AC_MSG_ERROR([
  4090 *** Unsupported host:  Please add to configure.ac
  4091         ])
  4092         ;;
  4093 esac
  4094 
  4095 # Check whether to install sdl2-config
  4096 AC_MSG_CHECKING(whether to install sdl2-config)
  4097 AC_ARG_ENABLE([sdl2-config],
  4098     AS_HELP_STRING([--enable-sdl2-config], [Install sdl2-config [default=yes]]),
  4099     [case "${enableval}" in
  4100         yes) enable_sdl2_config="TRUE" ;;
  4101         no) enable_sdl2_config="FALSE" ;;
  4102         *) AC_MSG_ERROR([bad value '${enableval}' for --enable-sdl2-config]) ;;
  4103     esac], [enable_sdl2_config="TRUE"])
  4104 if test "$enable_sdl2_config" = "TRUE"; then
  4105     AC_MSG_RESULT(yes)
  4106 else
  4107     AC_MSG_RESULT(no)
  4108 fi
  4109 AC_SUBST([INSTALL_SDL2_CONFIG], [$enable_sdl2_config])
  4110 
  4111 # Verify that we have all the platform specific files we need
  4112 
  4113 if test x$have_joystick != xyes; then
  4114     if test x$enable_joystick = xyes; then
  4115         AC_DEFINE(SDL_JOYSTICK_DUMMY, 1, [ ])
  4116     fi
  4117     SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
  4118 fi
  4119 if test x$have_haptic != xyes; then
  4120     if test x$enable_haptic = xyes; then
  4121         AC_DEFINE(SDL_HAPTIC_DUMMY, 1, [ ])
  4122     fi
  4123     SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c"
  4124 fi
  4125 if test x$have_sensor != xyes; then
  4126     if test x$enable_sensor = xyes; then
  4127         AC_DEFINE(SDL_SENSOR_DUMMY, 1, [ ])
  4128     fi
  4129     SOURCES="$SOURCES $srcdir/src/sensor/dummy/*.c"
  4130 fi
  4131 if test x$have_threads != xyes; then
  4132     if test x$enable_threads = xyes; then
  4133         AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ])
  4134     fi
  4135     SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
  4136 fi
  4137 if test x$have_timers != xyes; then
  4138     if test x$enable_timers = xyes; then
  4139         AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ])
  4140     fi
  4141     SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
  4142 fi
  4143 if test x$have_filesystem != xyes; then
  4144     if test x$enable_filesystem = xyes; then
  4145         AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
  4146     fi
  4147     SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c"
  4148 fi
  4149 if test x$have_loadso != xyes; then
  4150     if test x$enable_loadso = xyes; then
  4151         AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ])
  4152     fi
  4153     SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
  4154 fi
  4155 if test x$SDLMAIN_SOURCES = x; then
  4156     SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
  4157 fi
  4158 SDLTEST_SOURCES="$srcdir/src/test/*.c"
  4159 
  4160 if test x$video_wayland = xyes; then
  4161     WAYLAND_PROTOCOLS=`cd $srcdir/wayland-protocols ; for p in *.xml ; do echo -n "\$p" |sed 's,\\.xml\$, ,g' ; done`
  4162     WAYLAND_PROTOCOLS_SOURCES=`for p in $WAYLAND_PROTOCOLS ; do echo -n "\\$(gen)/\$p-protocol.c " ; done`
  4163     WAYLAND_PROTOCOLS_HEADERS=`for p in $WAYLAND_PROTOCOLS ; do echo -n "\\$(gen)/\$p-client-protocol.h " ; done`
  4164     GEN_SOURCES="$GEN_SOURCES $WAYLAND_PROTOCOLS_SOURCES"
  4165     GEN_HEADERS="$GEN_HEADERS $WAYLAND_PROTOCOLS_HEADERS"
  4166 
  4167     WAYLAND_PROTOCOLS_DEPENDS=`for p in $WAYLAND_PROTOCOLS ; do\
  4168         echo ;\
  4169         echo "\\$(gen)/\$p-client-protocol.h: \\$(srcdir)/wayland-protocols/\$p.xml" ;\
  4170         echo "	@\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\
  4171         echo "	\\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) client-header \\$< \\$@" ;\
  4172         echo ;\
  4173         echo "\\$(gen)/\$p-protocol.c: \\$(srcdir)/wayland-protocols/\$p.xml" ;\
  4174         echo "	@\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\
  4175         echo "	\\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) code \\$< \\$@" ;\
  4176         echo ;\
  4177         echo "\\$(objects)/\$p-protocol.lo: \\$(gen)/\$p-protocol.c \\$(gen)/\$p-client-protocol.h" ;\
  4178         echo "	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@" ;\
  4179         done ;\
  4180         echo ;\
  4181         for s in $WAYLAND_SOURCES ; do echo -n "\$s:" ; for p in $WAYLAND_PROTOCOLS ; do echo -n " \\$(gen)/\$p-client-protocol.h" ; done ; echo ; done ; echo`
  4182 fi
  4183 
  4184 OBJECTS=`echo $SOURCES`
  4185 DEPENDS=`echo $SOURCES | tr ' ' '\n'`
  4186 for EXT in asm cc m c S; do
  4187     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
  4188     DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
  4189 \\$(objects)/\\2.lo: \\1/\\2.$EXT \\$(objects)/.created\\\\
  4190 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  4191 done
  4192 
  4193 GEN_OBJECTS=`echo "$GEN_SOURCES" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
  4194 
  4195 VERSION_OBJECTS=`echo $VERSION_SOURCES`
  4196 VERSION_DEPENDS=`echo $VERSION_SOURCES`
  4197 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
  4198 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.rc,\\\\
  4199 \\$(objects)/\\2.o: \\1/\\2.rc \\$(objects)/.created\\\\
  4200 	\\$(WINDRES) \\$< \\$@,g"`
  4201 
  4202 SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES`
  4203 SDLMAIN_DEPENDS=`echo $SDLMAIN_SOURCES`
  4204 SDLMAIN_OBJECTS=`echo "$SDLMAIN_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
  4205 SDLMAIN_DEPENDS=`echo "$SDLMAIN_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  4206 \\$(objects)/\\2.lo: \\1/\\2.c \\$(objects)/.created\\\\
  4207 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  4208 
  4209 SDLTEST_OBJECTS=`echo $SDLTEST_SOURCES`
  4210 SDLTEST_DEPENDS=`echo $SDLTEST_SOURCES`
  4211 SDLTEST_OBJECTS=`echo "$SDLTEST_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
  4212 SDLTEST_DEPENDS=`echo "$SDLTEST_DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.c,\\\\
  4213 \\$(objects)/\\2.lo: \\1/\\2.c \\$(objects)/.created\\\\
  4214 	\\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
  4215 
  4216 # Set runtime shared library paths as needed
  4217 
  4218 if test "x$enable_rpath" = "xyes"; then
  4219   if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = linux -o $ARCH = netbsd; then
  4220     SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
  4221 
  4222     AC_MSG_CHECKING(for linker option --enable-new-dtags)
  4223     have_enable_new_dtags=no
  4224     save_LDFLAGS="$LDFLAGS"
  4225     LDFLAGS="$LDFLAGS -Wl,--enable-new-dtags"
  4226     AC_TRY_LINK([
  4227     ],[
  4228     ],[
  4229     have_enable_new_dtags=yes
  4230     SDL_RLD_FLAGS="$SDL_RLD_FLAGS -Wl,--enable-new-dtags"
  4231     ])
  4232     LDFLAGS="$save_LDFLAGS"
  4233     AC_MSG_RESULT($have_enable_new_dtags)
  4234   fi
  4235   if test $ARCH = solaris; then
  4236     SDL_RLD_FLAGS="-R\${libdir}"
  4237   fi
  4238 else
  4239   SDL_RLD_FLAGS=""
  4240 fi
  4241 
  4242 SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
  4243 
  4244 dnl Expand the cflags and libraries needed by apps using SDL
  4245 AC_SUBST(SDL_CFLAGS)
  4246 AC_SUBST(SDL_LIBS)
  4247 AC_SUBST(SDL_STATIC_LIBS)
  4248 AC_SUBST(SDL_RLD_FLAGS)
  4249 if test x$enable_shared = xyes; then
  4250     ENABLE_SHARED_TRUE=
  4251     ENABLE_SHARED_FALSE="#"
  4252 else
  4253     ENABLE_SHARED_TRUE="#"
  4254     ENABLE_SHARED_FALSE=
  4255 fi
  4256 if test x$enable_static = xyes; then
  4257     ENABLE_STATIC_TRUE=
  4258     ENABLE_STATIC_FALSE="#"
  4259 else
  4260     ENABLE_STATIC_TRUE="#"
  4261     ENABLE_STATIC_FALSE=
  4262 fi
  4263 AC_SUBST(ENABLE_SHARED_TRUE)
  4264 AC_SUBST(ENABLE_SHARED_FALSE)
  4265 AC_SUBST(ENABLE_STATIC_TRUE)
  4266 AC_SUBST(ENABLE_STATIC_FALSE)
  4267 
  4268 dnl Expand the sources and objects needed to build the library
  4269 AC_SUBST(ac_aux_dir)
  4270 AC_SUBST(INCLUDE)
  4271 AC_SUBST(OBJECTS)
  4272 AC_SUBST(GEN_HEADERS)
  4273 AC_SUBST(GEN_OBJECTS)
  4274 AC_SUBST(VERSION_OBJECTS)
  4275 AC_SUBST(SDLMAIN_OBJECTS)
  4276 AC_SUBST(SDLTEST_OBJECTS)
  4277 AC_SUBST(BUILD_CFLAGS)
  4278 AC_SUBST(EXTRA_CFLAGS)
  4279 AC_SUBST(BUILD_LDFLAGS)
  4280 AC_SUBST(EXTRA_LDFLAGS)
  4281 AC_SUBST(WINDRES)
  4282 AC_SUBST(WAYLAND_SCANNER)
  4283 
  4284 cat >Makefile.rules <<__EOF__
  4285 
  4286 # Build rules for objects
  4287 -include \$(OBJECTS:.lo=.d)
  4288 
  4289 # Special dependency for SDL.c, since it depends on SDL_revision.h
  4290 $srcdir/src/SDL.c: update-revision
  4291 $DEPENDS
  4292 $VERSION_DEPENDS
  4293 $SDLMAIN_DEPENDS
  4294 $SDLTEST_DEPENDS
  4295 $WAYLAND_PROTOCOLS_DEPENDS
  4296 __EOF__
  4297 
  4298 AC_CONFIG_FILES([
  4299     Makefile:Makefile.in:Makefile.rules sdl2-config sdl2-config.cmake sdl2-config-version.cmake SDL2.spec sdl2.pc
  4300 ])
  4301 AC_CONFIG_COMMANDS([sdl2_config],[chmod a+x sdl2-config])
  4302 
  4303 SUMMARY="SDL2 Configure Summary:\n"
  4304 if test x$enable_shared = xyes; then
  4305     SUMMARY="${SUMMARY}Building Shared Libraries\n"
  4306 fi
  4307 if test x$enable_static = xyes; then
  4308     SUMMARY="${SUMMARY}Building Static Libraries\n"
  4309 fi
  4310 SUMMARY="${SUMMARY}Enabled modules :${SUMMARY_modules}\n"
  4311 SUMMARY="${SUMMARY}Assembly Math   :${SUMMARY_math}\n" 
  4312 SUMMARY="${SUMMARY}Audio drivers   :${SUMMARY_audio}\n"
  4313 SUMMARY="${SUMMARY}Video drivers   :${SUMMARY_video}\n"
  4314 if test x$have_x = xyes; then
  4315     SUMMARY="${SUMMARY}X11 libraries   :${SUMMARY_video_x11}\n"
  4316 fi
  4317 SUMMARY="${SUMMARY}Input drivers   :${SUMMARY_input}\n"
  4318 if test x$have_samplerate_h_hdr = xyes; then
  4319     SUMMARY="${SUMMARY}Using libsamplerate : YES\n"
  4320 else
  4321     SUMMARY="${SUMMARY}Using libsamplerate : NO\n"
  4322 fi
  4323 if test x$have_libudev_h_hdr = xyes; then
  4324     SUMMARY="${SUMMARY}Using libudev       : YES\n"
  4325 else
  4326     SUMMARY="${SUMMARY}Using libudev       : NO\n"
  4327 fi
  4328 if test x$have_dbus_dbus_h_hdr = xyes; then
  4329     SUMMARY="${SUMMARY}Using dbus          : YES\n"
  4330 else
  4331     SUMMARY="${SUMMARY}Using dbus          : NO\n"
  4332 fi
  4333 if test x$enable_ime = xyes; then
  4334     SUMMARY="${SUMMARY}Using ime           : YES\n"
  4335 else
  4336     SUMMARY="${SUMMARY}Using ime           : NO\n"
  4337 fi
  4338 if test x$have_ibus_ibus_h_hdr = xyes; then
  4339     SUMMARY="${SUMMARY}Using ibus          : YES\n"
  4340 else
  4341     SUMMARY="${SUMMARY}Using ibus          : NO\n"
  4342 fi
  4343 if test x$have_fcitx_frontend_h_hdr = xyes; then
  4344     SUMMARY="${SUMMARY}Using fcitx         : YES\n"
  4345 else
  4346     SUMMARY="${SUMMARY}Using fcitx         : NO\n"
  4347 fi
  4348 
  4349 if test x$WARN_ABOUT_ARM_SIMD_ASM_MIT = xyes; then
  4350     SUMMARY="${SUMMARY}\nSDL is being built with ARM SIMD optimizations, which\n"
  4351     SUMMARY="${SUMMARY}uses code licensed under the MIT license. If this is a\n"
  4352     SUMMARY="${SUMMARY}problem, please disable that code by rerunning the\n"
  4353     SUMMARY="${SUMMARY}configure script with:\n"
  4354     SUMMARY="${SUMMARY}\n    --disable-arm-simd\n"
  4355 fi
  4356 
  4357 if test x$WARN_ABOUT_ARM_NEON_ASM_MIT = xyes; then
  4358     SUMMARY="${SUMMARY}\nSDL is being built with ARM NEON optimizations, which\n"
  4359     SUMMARY="${SUMMARY}uses code licensed under the MIT license. If this is a\n"
  4360     SUMMARY="${SUMMARY}problem, please disable that code by rerunning the\n"
  4361     SUMMARY="${SUMMARY}configure script with:\n"
  4362     SUMMARY="${SUMMARY}\n    --disable-arm-neon\n"
  4363 fi
  4364 
  4365 AC_CONFIG_COMMANDS([summary], [echo -en "$SUMMARY"], [SUMMARY="$SUMMARY"])
  4366 
  4367 AC_OUTPUT