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