Merge lp:~brandontschaefer/libsdl/add-mir-support-v2 into lp:ubuntu/wily/libsdl1.2

Proposed by Brandon Schaefer
Status: Needs review
Proposed branch: lp:~brandontschaefer/libsdl/add-mir-support-v2
Merge into: lp:ubuntu/wily/libsdl1.2
Diff against target: 9066 lines (+8851/-2)
26 files modified
.pc/applied-patches (+1/-0)
.pc/mir-support.diff/configure.in (+2965/-0)
.pc/mir-support.diff/include/SDL_config.h.in (+312/-0)
.pc/mir-support.diff/src/video/SDL_sysvideo.h (+424/-0)
.pc/mir-support.diff/src/video/SDL_video.c (+1978/-0)
configure.in (+38/-0)
debian/changelog (+6/-0)
debian/control (+8/-2)
debian/patches/mir-support.diff (+1632/-0)
debian/patches/series (+1/-0)
debian/rules (+4/-0)
include/SDL_config.h.in (+1/-0)
src/video/SDL_sysvideo.h (+3/-0)
src/video/SDL_video.c (+3/-0)
src/video/mir/SDL_mirbuffer.c (+58/-0)
src/video/mir/SDL_mirbuffer.h (+32/-0)
src/video/mir/SDL_mirevents.c (+264/-0)
src/video/mir/SDL_mirevents.h (+33/-0)
src/video/mir/SDL_mirgl.c (+218/-0)
src/video/mir/SDL_mirgl.h (+55/-0)
src/video/mir/SDL_mirhw.c (+46/-0)
src/video/mir/SDL_mirhw.h (+36/-0)
src/video/mir/SDL_mirmouse.c (+62/-0)
src/video/mir/SDL_mirmouse.h (+37/-0)
src/video/mir/SDL_mirvideo.c (+590/-0)
src/video/mir/SDL_mirvideo.h (+44/-0)
To merge this branch: bzr merge lp:~brandontschaefer/libsdl/add-mir-support-v2
Reviewer Review Type Date Requested Status
VCS imports Pending
Review via email: mp+260774@code.launchpad.net

This proposal supersedes a proposal from 2015-06-01.

Commit message

Add support for Mir under libsdl1.2 for only i386/amd64 (no gles1/2 support in libsdl1.2).

Description of the change

Add support for Mir under libsdl1.2 for only i386/amd64 (no gles1/2 support in libsdl1.2).

This patch adds support for Software rendering and Opengl on the desktop for mir in sdl1.2.

*Note* This is written for the new libmir 0.13.1. This uses new event 2.0 and buffering system.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

The diff is a lot larger then the actual patch... since the patch touches (lightly) on a few large files. They get include in the .pc/mir-support/ files. The main patch is around ~1.7k

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Wow that's annoying proposing to a tree that has .pc/applied-patches

Reviewers should just be aware to ignore most of the diff (.pc/*).

Unmerged revisions

53. By Brandon Schaefer on 2015-06-01

* I should not ignore key_repeat rather, if we are not a KEY_UP action
  assume its a KEY_DOWN event.

52. By Brandon Schaefer on 2015-06-01

* Make sure we depend on the version of mir this is written for

51. By Brandon Schaefer on 2015-05-29

* Add video driver backend support for Mir (i386/amd64)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2014-07-01 23:03:57 +0000
3+++ .pc/applied-patches 2015-06-01 21:48:23 +0000
4@@ -4,3 +4,4 @@
5 fix_window_resizing.diff
6 fix_joystick_misc_axes.diff
7 sdl-check-for-SDL_VIDEO_X11_BACKINGSTORE.patch
8+mir-support.diff
9
10=== added directory '.pc/mir-support.diff'
11=== added file '.pc/mir-support.diff/configure.in'
12--- .pc/mir-support.diff/configure.in 1970-01-01 00:00:00 +0000
13+++ .pc/mir-support.diff/configure.in 2015-06-01 21:48:23 +0000
14@@ -0,0 +1,2965 @@
15+dnl Process this file with autoconf to produce a configure script.
16+AC_INIT(README)
17+AC_CONFIG_HEADER(include/SDL_config.h)
18+AC_GNU_SOURCE
19+AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
20+
21+dnl Set various version strings - taken gratefully from the GTk sources
22+#
23+# Making releases:
24+# Edit include/SDL/SDL_version.h and change the version, then:
25+# SDL_MICRO_VERSION += 1;
26+# SDL_INTERFACE_AGE += 1;
27+# SDL_BINARY_AGE += 1;
28+# if any functions have been added, set SDL_INTERFACE_AGE to 0.
29+# if backwards compatibility has been broken,
30+# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
31+#
32+SDL_MAJOR_VERSION=1
33+SDL_MINOR_VERSION=2
34+SDL_MICRO_VERSION=15
35+SDL_INTERFACE_AGE=4
36+SDL_BINARY_AGE=15
37+SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
38+
39+AC_SUBST(SDL_MAJOR_VERSION)
40+AC_SUBST(SDL_MINOR_VERSION)
41+AC_SUBST(SDL_MICRO_VERSION)
42+AC_SUBST(SDL_INTERFACE_AGE)
43+AC_SUBST(SDL_BINARY_AGE)
44+AC_SUBST(SDL_VERSION)
45+
46+# libtool versioning
47+LT_INIT([win32-dll])
48+
49+LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
50+LT_CURRENT=`expr $SDL_MICRO_VERSION - $SDL_INTERFACE_AGE`
51+LT_REVISION=$SDL_INTERFACE_AGE
52+LT_AGE=`expr $SDL_BINARY_AGE - $SDL_INTERFACE_AGE`
53+m4_pattern_allow([^LT_])
54+
55+AC_SUBST(LT_RELEASE)
56+AC_SUBST(LT_CURRENT)
57+AC_SUBST(LT_REVISION)
58+AC_SUBST(LT_AGE)
59+
60+dnl Detect the canonical build and host environments
61+AC_CONFIG_AUX_DIR([build-scripts])
62+dnl AC_CANONICAL_HOST
63+AC_C_BIGENDIAN
64+if test x$ac_cv_c_bigendian = xyes; then
65+ AC_DEFINE(SDL_BYTEORDER, 4321)
66+else
67+ AC_DEFINE(SDL_BYTEORDER, 1234)
68+fi
69+
70+dnl Check for tools
71+AC_PROG_LIBTOOL
72+AC_PROG_CC
73+AC_PROG_CXX
74+AC_PROG_INSTALL
75+AC_PROG_MAKE_SET
76+AC_CHECK_TOOL(WINDRES, [windres], [:])
77+
78+dnl Set up the compiler and linker flags
79+INCLUDE="-I$srcdir/include"
80+if test x$srcdir != x.; then
81+ # Remove SDL_config.h from the source directory, since it's the
82+ # default one, and we want to include the one that we generate.
83+ if test -f $srcdir/include/SDL_config.h; then
84+ rm $srcdir/include/SDL_config.h
85+ fi
86+ INCLUDE="-Iinclude $INCLUDE"
87+fi
88+case "$host" in
89+ *-*-cygwin*)
90+ # We build SDL on cygwin without the UNIX emulation layer
91+ BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
92+ BASE_LDFLAGS="-mno-cygwin"
93+ ;;
94+ *)
95+ BASE_CFLAGS="-D_GNU_SOURCE=1"
96+ BASE_LDFLAGS=""
97+ ;;
98+esac
99+BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
100+EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
101+BUILD_LDFLAGS="$LDFLAGS"
102+EXTRA_LDFLAGS="$BASE_LDFLAGS"
103+## These are common directories to find software packages
104+#for path in /usr/freeware /usr/pkg /usr/X11R6 /usr/local; do
105+# if test -d $path/include; then
106+# EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
107+# fi
108+# if test -d $path/lib; then
109+# EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
110+# fi
111+#done
112+SDL_CFLAGS="$BASE_CFLAGS"
113+SDL_LIBS="-lSDL $BASE_LDFLAGS"
114+CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
115+CFLAGS="$CFLAGS $EXTRA_CFLAGS"
116+LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
117+
118+dnl set this to use on systems that use lib64 instead of lib
119+base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
120+
121+dnl Function to find a library in the compiler search path
122+find_lib()
123+{
124+ gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
125+ gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
126+ env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
127+ if test "$cross_compiling" = yes; then
128+ host_lib_path=""
129+ else
130+ host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
131+ fi
132+ for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
133+ lib=[`ls -- $path/$1 2>/dev/null | sort | sed 's/.*\/\(.*\)/\1/; q'`]
134+ if test x$lib != x; then
135+ echo $lib
136+ return
137+ fi
138+ done
139+}
140+
141+dnl Check for compiler characteristics
142+AC_C_CONST
143+AC_C_INLINE
144+AC_C_VOLATILE
145+
146+dnl See whether we are allowed to use the system C library
147+AC_ARG_ENABLE(libc,
148+AC_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]),
149+ , enable_libc=yes)
150+if test x$enable_libc = xyes; then
151+ AC_DEFINE(HAVE_LIBC)
152+
153+ dnl Check for C library headers
154+ AC_HEADER_STDC
155+ 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)
156+
157+ dnl Check for typedefs, structures, etc.
158+ AC_TYPE_SIZE_T
159+ if test x$ac_cv_header_inttypes_h = xyes -o x$ac_cv_header_stdint_h = xyes; then
160+ AC_CHECK_TYPE(int64_t)
161+ if test x$ac_cv_type_int64_t = xyes; then
162+ AC_DEFINE(SDL_HAS_64BIT_TYPE)
163+ fi
164+ have_inttypes=yes
165+ fi
166+
167+ dnl Checks for library functions.
168+ case "$host" in
169+ *-*-cygwin* | *-*-mingw32*)
170+ ;;
171+ *)
172+ AC_FUNC_ALLOCA
173+ ;;
174+ esac
175+
176+ AC_FUNC_MEMCMP
177+ if test x$ac_cv_func_memcmp_working = xyes; then
178+ AC_DEFINE(HAVE_MEMCMP)
179+ fi
180+ AC_FUNC_STRTOD
181+ if test x$ac_cv_func_strtod = xyes; then
182+ AC_DEFINE(HAVE_STRTOD)
183+ fi
184+ AC_CHECK_FUNC(mprotect,
185+ AC_TRY_COMPILE([
186+ #include <sys/types.h>
187+ #include <sys/mman.h>
188+ ],[
189+ ],[
190+ AC_DEFINE(HAVE_MPROTECT)
191+ ]),
192+ )
193+ AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf iconv sigaction setjmp nanosleep)
194+
195+ AC_CHECK_LIB(iconv, libiconv_open, [EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
196+ AC_CHECK_LIB(m, pow, [EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
197+
198+ AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE(HAVE_SA_SIGACTION)], ,[#include <signal.h>])
199+fi
200+
201+if test x$have_inttypes != xyes; then
202+ AC_CHECK_SIZEOF(char, 1)
203+ AC_CHECK_SIZEOF(short, 2)
204+ AC_CHECK_SIZEOF(int, 4)
205+ AC_CHECK_SIZEOF(long, 4)
206+ AC_CHECK_SIZEOF(long long, 8)
207+ if test x$ac_cv_sizeof_char = x1; then
208+ AC_DEFINE(int8_t, signed char)
209+ AC_DEFINE(uint8_t, unsigned char)
210+ fi
211+ if test x$ac_cv_sizeof_short = x2; then
212+ AC_DEFINE(int16_t, signed short)
213+ AC_DEFINE(uint16_t, unsigned short)
214+ else
215+ if test x$ac_cv_sizeof_int = x2; then
216+ AC_DEFINE(int16_t, signed int)
217+ AC_DEFINE(uint16_t, unsigned int)
218+ fi
219+ fi
220+ if test x$ac_cv_sizeof_int = x4; then
221+ AC_DEFINE(int32_t, signed int)
222+ AC_DEFINE(uint32_t, unsigned int)
223+ else
224+ if test x$ac_cv_sizeof_long = x4; then
225+ AC_DEFINE(int32_t, signed long)
226+ AC_DEFINE(uint32_t, unsigned long)
227+ fi
228+ fi
229+ if test x$ac_cv_sizeof_long = x8; then
230+ AC_DEFINE(int64_t, signed long)
231+ AC_DEFINE(uint64_t, unsigned long)
232+ AC_DEFINE(SDL_HAS_64BIT_TYPE)
233+ else
234+ if test x$ac_cv_sizeof_long_long = x8; then
235+ AC_DEFINE(int64_t, signed long long)
236+ AC_DEFINE(uint64_t, unsigned long long)
237+ AC_DEFINE(SDL_HAS_64BIT_TYPE)
238+ fi
239+ fi
240+ AC_DEFINE(size_t, unsigned int)
241+ AC_DEFINE(uintptr_t, unsigned long)
242+fi
243+
244+# Standard C sources
245+SOURCES="$SOURCES $srcdir/src/*.c"
246+SOURCES="$SOURCES $srcdir/src/audio/*.c"
247+SOURCES="$SOURCES $srcdir/src/cdrom/*.c"
248+SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
249+SOURCES="$SOURCES $srcdir/src/events/*.c"
250+SOURCES="$SOURCES $srcdir/src/file/*.c"
251+SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
252+SOURCES="$SOURCES $srcdir/src/thread/*.c"
253+SOURCES="$SOURCES $srcdir/src/timer/*.c"
254+SOURCES="$SOURCES $srcdir/src/video/*.c"
255+
256+dnl Enable/disable various subsystems of the SDL library
257+
258+AC_ARG_ENABLE(audio,
259+AC_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]),
260+ , enable_audio=yes)
261+if test x$enable_audio != xyes; then
262+ AC_DEFINE(SDL_AUDIO_DISABLED)
263+fi
264+AC_ARG_ENABLE(video,
265+AC_HELP_STRING([--enable-video], [Enable the video subsystem [[default=yes]]]),
266+ , enable_video=yes)
267+if test x$enable_video != xyes; then
268+ AC_DEFINE(SDL_VIDEO_DISABLED)
269+fi
270+AC_ARG_ENABLE(events,
271+AC_HELP_STRING([--enable-events], [Enable the events subsystem [[default=yes]]]),
272+ , enable_events=yes)
273+if test x$enable_events != xyes; then
274+ AC_DEFINE(SDL_EVENTS_DISABLED)
275+fi
276+AC_ARG_ENABLE(joystick,
277+AC_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes]]]),
278+ , enable_joystick=yes)
279+if test x$enable_joystick != xyes; then
280+ AC_DEFINE(SDL_JOYSTICK_DISABLED)
281+else
282+ SOURCES="$SOURCES $srcdir/src/joystick/*.c"
283+fi
284+AC_ARG_ENABLE(cdrom,
285+AC_HELP_STRING([--enable-cdrom], [Enable the cdrom subsystem [[default=yes]]]),
286+ , enable_cdrom=yes)
287+if test x$enable_cdrom != xyes; then
288+ AC_DEFINE(SDL_CDROM_DISABLED)
289+fi
290+AC_ARG_ENABLE(threads,
291+AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]),
292+ , enable_threads=yes)
293+if test x$enable_threads != xyes; then
294+ AC_DEFINE(SDL_THREADS_DISABLED)
295+fi
296+AC_ARG_ENABLE(timers,
297+AC_HELP_STRING([--enable-timers], [Enable the timer subsystem [[default=yes]]]),
298+ , enable_timers=yes)
299+if test x$enable_timers != xyes; then
300+ AC_DEFINE(SDL_TIMERS_DISABLED)
301+fi
302+AC_ARG_ENABLE(file,
303+AC_HELP_STRING([--enable-file], [Enable the file subsystem [[default=yes]]]),
304+ , enable_file=yes)
305+if test x$enable_file != xyes; then
306+ AC_DEFINE(SDL_FILE_DISABLED)
307+fi
308+AC_ARG_ENABLE(loadso,
309+AC_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [[default=yes]]]),
310+ , enable_loadso=yes)
311+if test x$enable_loadso != xyes; then
312+ AC_DEFINE(SDL_LOADSO_DISABLED)
313+fi
314+AC_ARG_ENABLE(cpuinfo,
315+AC_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [[default=yes]]]),
316+ , enable_cpuinfo=yes)
317+if test x$enable_cpuinfo != xyes; then
318+ AC_DEFINE(SDL_CPUINFO_DISABLED)
319+fi
320+AC_ARG_ENABLE(assembly,
321+AC_HELP_STRING([--enable-assembly], [Enable assembly routines [[default=yes]]]),
322+ , enable_assembly=yes)
323+if test x$enable_assembly = xyes; then
324+ AC_DEFINE(SDL_ASSEMBLY_ROUTINES)
325+fi
326+
327+dnl See if the OSS audio interface is supported
328+CheckOSS()
329+{
330+ AC_ARG_ENABLE(oss,
331+AC_HELP_STRING([--enable-oss], [support the OSS audio API [[default=yes]]]),
332+ , enable_oss=yes)
333+ if test x$enable_audio = xyes -a x$enable_oss = xyes; then
334+ AC_MSG_CHECKING(for OSS audio support)
335+ have_oss=no
336+ if test x$have_oss != xyes; then
337+ AC_TRY_COMPILE([
338+ #include <sys/soundcard.h>
339+ ],[
340+ int arg = SNDCTL_DSP_SETFRAGMENT;
341+ ],[
342+ have_oss=yes
343+ ])
344+ fi
345+ if test x$have_oss != xyes; then
346+ AC_TRY_COMPILE([
347+ #include <soundcard.h>
348+ ],[
349+ int arg = SNDCTL_DSP_SETFRAGMENT;
350+ ],[
351+ have_oss=yes
352+ AC_DEFINE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H)
353+ ])
354+ fi
355+ AC_MSG_RESULT($have_oss)
356+ if test x$have_oss = xyes; then
357+ AC_DEFINE(SDL_AUDIO_DRIVER_OSS)
358+ SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c"
359+ SOURCES="$SOURCES $srcdir/src/audio/dma/*.c"
360+ have_audio=yes
361+
362+ # We may need to link with ossaudio emulation library
363+ case "$host" in
364+ *-*-openbsd*|*-*-netbsd*)
365+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lossaudio";;
366+ esac
367+ fi
368+ fi
369+}
370+
371+dnl See if the ALSA audio interface is supported
372+CheckALSA()
373+{
374+ AC_ARG_ENABLE(alsa,
375+AC_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]),
376+ , enable_alsa=yes)
377+ if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
378+ AM_PATH_ALSA(0.9.0, have_alsa=yes, have_alsa=no)
379+ # Restore all flags from before the ALSA detection runs
380+ CFLAGS="$alsa_save_CFLAGS"
381+ LDFLAGS="$alsa_save_LDFLAGS"
382+ LIBS="$alsa_save_LIBS"
383+ if test x$have_alsa = xyes; then
384+ AC_ARG_ENABLE(alsa-shared,
385+AC_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[default=yes]]]),
386+ , enable_alsa_shared=yes)
387+ alsa_lib=[`find_lib "libasound.so.*" "$ALSA_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
388+
389+ AC_DEFINE(SDL_AUDIO_DRIVER_ALSA)
390+ SOURCES="$SOURCES $srcdir/src/audio/alsa/*.c"
391+ EXTRA_CFLAGS="$EXTRA_CFLAGS $ALSA_CFLAGS"
392+ if test x$have_loadso != xyes && \
393+ test x$enable_alsa_shared = xyes; then
394+ AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ALSA loading])
395+ fi
396+ if test x$have_loadso = xyes && \
397+ test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
398+ echo "-- dynamic libasound -> $alsa_lib"
399+ AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ALSA_DYNAMIC, "$alsa_lib")
400+ else
401+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ALSA_LIBS"
402+ fi
403+ have_audio=yes
404+ fi
405+ fi
406+}
407+
408+dnl Check whether we want to use IRIX 6.5+ native audio or not
409+CheckDMEDIA()
410+{
411+ if test x$enable_audio = xyes; then
412+ AC_MSG_CHECKING(for dmedia audio support)
413+ have_dmedia=no
414+ AC_TRY_COMPILE([
415+ #include <dmedia/audio.h>
416+ ],[
417+ ALport audio_port;
418+ ],[
419+ have_dmedia=yes
420+ ])
421+ AC_MSG_RESULT($have_dmedia)
422+ # Set up files for the audio library
423+ if test x$have_dmedia = xyes; then
424+ AC_DEFINE(SDL_AUDIO_DRIVER_DMEDIA)
425+ SOURCES="$SOURCES $srcdir/src/audio/dmedia/*.c"
426+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -laudio"
427+ have_audio=yes
428+ fi
429+ fi
430+}
431+
432+dnl Check whether we want to use Tru64 UNIX native audio or not
433+CheckMME()
434+{
435+ dnl Make sure we are running on an Tru64 UNIX
436+ case $ARCH in
437+ osf)
438+ ;;
439+ *)
440+ return
441+ ;;
442+ esac
443+ if test x$enable_audio = xyes; then
444+ AC_MSG_CHECKING(for MME audio support)
445+ MME_CFLAGS="-I/usr/include/mme"
446+ MME_LIBS="-lmme"
447+ have_mme=no
448+ save_CFLAGS="$CFLAGS"
449+ CFLAGS="$CFLAGS $MME_CFLAGS"
450+ AC_TRY_COMPILE([
451+ #include <mme_api.h>
452+ ],[
453+ HWAVEOUT sound;
454+ ],[
455+ have_mme=yes
456+ ])
457+ CFLAGS="$save_CFLAGS"
458+ AC_MSG_RESULT($have_mme)
459+ # Set up files for the audio library
460+ if test x$have_mme = xyes; then
461+ AC_DEFINE(SDL_AUDIO_DRIVER_MMEAUDIO)
462+ SOURCES="$SOURCES $srcdir/src/audio/mme/*.c"
463+ EXTRA_CFLAGS="$EXTRA_CFLAGS $MME_CFLAGS"
464+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MME_LIBS"
465+ have_audio=yes
466+ fi
467+ fi
468+}
469+
470+dnl Find the ESD includes and libraries
471+CheckESD()
472+{
473+ AC_ARG_ENABLE(esd,
474+AC_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [[default=yes]]]),
475+ , enable_esd=yes)
476+ if test x$enable_audio = xyes -a x$enable_esd = xyes; then
477+ AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
478+ if test x$have_esd = xyes; then
479+ AC_ARG_ENABLE(esd-shared,
480+AC_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]),
481+ , enable_esd_shared=yes)
482+ esd_lib=[`find_lib "libesd.so.*" "$ESD_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
483+
484+ AC_DEFINE(SDL_AUDIO_DRIVER_ESD)
485+ SOURCES="$SOURCES $srcdir/src/audio/esd/*.c"
486+ EXTRA_CFLAGS="$EXTRA_CFLAGS $ESD_CFLAGS"
487+ if test x$have_loadso != xyes && \
488+ test x$enable_esd_shared = xyes; then
489+ AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ESD loading])
490+ fi
491+ if test x$have_loadso = xyes && \
492+ test x$enable_esd_shared = xyes && test x$esd_lib != x; then
493+ echo "-- dynamic libesd -> $esd_lib"
494+ AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ESD_DYNAMIC, "$esd_lib")
495+ else
496+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ESD_LIBS"
497+ fi
498+ have_audio=yes
499+ fi
500+ fi
501+}
502+
503+dnl Find PulseAudio
504+CheckPulseAudio()
505+{
506+ AC_ARG_ENABLE(pulseaudio,
507+AC_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]),
508+ , enable_pulseaudio=yes)
509+ if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then
510+ audio_pulse=no
511+
512+ PULSE_REQUIRED_VERSION=0.9
513+
514+ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
515+ AC_MSG_CHECKING(for PulseAudio $PULSE_REQUIRED_VERSION support)
516+ if test x$PKG_CONFIG != xno; then
517+ if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSE_REQUIRED_VERSION libpulse-simple; then
518+ PULSE_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
519+ PULSE_LIBS=`$PKG_CONFIG --libs libpulse-simple`
520+ audio_pulse=yes
521+ fi
522+ fi
523+ AC_MSG_RESULT($audio_pulse)
524+
525+ if test x$audio_pulse = xyes; then
526+ AC_ARG_ENABLE(pulseaudio-shared,
527+AC_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]),
528+ , enable_pulseaudio_shared=yes)
529+ pulse_lib=[`find_lib "libpulse-simple.so.*" "$PULSE_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
530+
531+ AC_DEFINE(SDL_AUDIO_DRIVER_PULSE)
532+ SOURCES="$SOURCES $srcdir/src/audio/pulse/*.c"
533+ EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSE_CFLAGS"
534+ if test x$have_loadso != xyes && \
535+ test x$enable_pulseaudio_shared = xyes; then
536+ AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic PulseAudio loading])
537+ fi
538+ if test x$have_loadso = xyes && \
539+ test x$enable_pulseaudio_shared = xyes && test x$pulse_lib != x; then
540+ echo "-- dynamic libpulse-simple -> $pulse_lib"
541+ AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSE_DYNAMIC, "$pulse_lib")
542+ else
543+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSE_LIBS"
544+ fi
545+ have_audio=yes
546+ fi
547+ fi
548+}
549+
550+CheckARTSC()
551+{
552+ AC_ARG_ENABLE(arts,
553+AC_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [[default=yes]]]),
554+ , enable_arts=yes)
555+ if test x$enable_audio = xyes -a x$enable_arts = xyes; then
556+ AC_PATH_PROG(ARTSCONFIG, artsc-config)
557+ if test x$ARTSCONFIG = x -o x$ARTSCONFIG = x'"$ARTSCONFIG"'; then
558+ : # arts isn't installed
559+ else
560+ ARTS_CFLAGS=`$ARTSCONFIG --cflags`
561+ ARTS_LIBS=`$ARTSCONFIG --libs`
562+ AC_MSG_CHECKING(for aRts development environment)
563+ audio_arts=no
564+ save_CFLAGS="$CFLAGS"
565+ CFLAGS="$CFLAGS $ARTS_CFLAGS"
566+ AC_TRY_COMPILE([
567+ #include <artsc.h>
568+ ],[
569+ arts_stream_t stream;
570+ ],[
571+ audio_arts=yes
572+ ])
573+ CFLAGS="$save_CFLAGS"
574+ AC_MSG_RESULT($audio_arts)
575+ if test x$audio_arts = xyes; then
576+ AC_ARG_ENABLE(arts-shared,
577+AC_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [[default=yes]]]),
578+ , enable_arts_shared=yes)
579+ arts_lib=[`find_lib "libartsc.so.*" "$ARTS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
580+
581+ AC_DEFINE(SDL_AUDIO_DRIVER_ARTS)
582+ SOURCES="$SOURCES $srcdir/src/audio/arts/*.c"
583+ EXTRA_CFLAGS="$EXTRA_CFLAGS $ARTS_CFLAGS"
584+ if test x$have_loadso != xyes && \
585+ test x$enable_arts_shared = xyes; then
586+ AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ARTS loading])
587+ fi
588+ if test x$have_loadso = xyes && \
589+ test x$enable_arts_shared = xyes && test x$arts_lib != x; then
590+ echo "-- dynamic libartsc -> $arts_lib"
591+ AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ARTS_DYNAMIC, "$arts_lib")
592+ else
593+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARTS_LIBS"
594+ fi
595+ have_audio=yes
596+ fi
597+ fi
598+ fi
599+}
600+
601+dnl See if the NAS audio interface is supported
602+CheckNAS()
603+{
604+ AC_ARG_ENABLE(nas,
605+AC_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]),
606+ , enable_nas=yes)
607+ if test x$enable_audio = xyes -a x$enable_nas = xyes; then
608+ AC_CHECK_HEADER(audio/audiolib.h, have_nas_hdr=yes)
609+ AC_CHECK_LIB(audio, AuOpenServer, have_nas_lib=yes)
610+
611+ AC_MSG_CHECKING(for NAS audio support)
612+ have_nas=no
613+
614+ if test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then
615+ have_nas=yes
616+ NAS_LIBS="-laudio"
617+
618+ elif test -r /usr/X11R6/include/audio/audiolib.h; then
619+ have_nas=yes
620+ NAS_CFLAGS="-I/usr/X11R6/include/"
621+ NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
622+
623+ dnl On IRIX, the NAS includes are in a different directory,
624+ dnl and libnas must be explicitly linked in
625+
626+ elif test -r /usr/freeware/include/nas/audiolib.h; then
627+ have_nas=yes
628+ NAS_LIBS="-lnas -lXt"
629+ fi
630+
631+ AC_MSG_RESULT($have_nas)
632+
633+ if test x$have_nas = xyes; then
634+ AC_ARG_ENABLE(nas-shared,
635+AC_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [[default=yes]]]),
636+ , enable_nas_shared=yes)
637+ nas_lib=[`find_lib "libaudio.so.*" "$NAS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
638+
639+ if test x$have_loadso != xyes && \
640+ test x$enable_nas_shared = xyes; then
641+ AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic NAS loading])
642+ fi
643+ if test x$have_loadso = xyes && \
644+ test x$enable_nas_shared = xyes && test x$nas_lib != x; then
645+ echo "-- dynamic libaudio -> $nas_lib"
646+ AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_NAS_DYNAMIC, "$nas_lib")
647+ else
648+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
649+ fi
650+
651+ AC_DEFINE(SDL_AUDIO_DRIVER_NAS)
652+ SOURCES="$SOURCES $srcdir/src/audio/nas/*.c"
653+ EXTRA_CFLAGS="$EXTRA_CFLAGS $NAS_CFLAGS"
654+ have_audio=yes
655+ fi
656+ fi
657+}
658+
659+dnl rcg07142001 See if the user wants the disk writer audio driver...
660+CheckDiskAudio()
661+{
662+ AC_ARG_ENABLE(diskaudio,
663+AC_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [[default=yes]]]),
664+ , enable_diskaudio=yes)
665+ if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
666+ AC_DEFINE(SDL_AUDIO_DRIVER_DISK)
667+ SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
668+ fi
669+}
670+
671+dnl rcg03142006 See if the user wants the dummy audio driver...
672+CheckDummyAudio()
673+{
674+ AC_ARG_ENABLE(dummyaudio,
675+AC_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=yes]]]),
676+ , enable_dummyaudio=yes)
677+ if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then
678+ AC_DEFINE(SDL_AUDIO_DRIVER_DUMMY)
679+ SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c"
680+ fi
681+}
682+
683+dnl Set up the Atari Audio driver
684+CheckAtariAudio()
685+{
686+ AC_ARG_ENABLE(mintaudio,
687+AC_HELP_STRING([--enable-mintaudio], [support Atari audio driver [[default=yes]]]),
688+ , enable_mintaudio=yes)
689+ if test x$enable_audio = xyes -a x$enable_mintaudio = xyes; then
690+ mintaudio=no
691+ AC_CHECK_HEADER(mint/falcon.h, have_mint_falcon_hdr=yes)
692+ if test x$have_mint_falcon_hdr = xyes; then
693+ mintaudio=yes
694+ AC_DEFINE(SDL_AUDIO_DRIVER_MINT)
695+ SOURCES="$SOURCES $srcdir/src/audio/mint/*.c"
696+ SOURCES="$SOURCES $srcdir/src/audio/mint/*.S"
697+ have_audio=yes
698+ fi
699+ fi
700+}
701+
702+dnl See if we can use x86 assembly blitters
703+# NASM is available from: http://nasm.sourceforge.net
704+CheckNASM()
705+{
706+ dnl Make sure we are running on an x86 platform
707+ case $host in
708+ i?86*)
709+ ;;
710+ *)
711+ # Nope, bail early.
712+ return
713+ ;;
714+ esac
715+
716+ dnl Mac OS X might report itself as "i386" but generate x86_64 code.
717+ dnl So see what size we think a pointer is, and bail if not 32-bit.
718+ AC_CHECK_SIZEOF([void *], 4)
719+ if test x$ac_cv_sizeof_void_p != x4; then
720+ return
721+ fi
722+
723+ dnl Check for NASM (for assembly blit routines)
724+ AC_ARG_ENABLE(nasm,
725+AC_HELP_STRING([--enable-nasm], [use nasm assembly blitters on x86 [[default=yes]]]),
726+ , enable_nasm=yes)
727+ if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_nasm = xyes; then
728+ CompileNASM()
729+ {
730+ # Usage: CompileNASM <filename>
731+ AC_MSG_CHECKING(to see if $NASM supports $1)
732+ if $NASM $NASMFLAGS $1 -o $1.o >&AS_MESSAGE_LOG_FD 2>&1; then
733+ CompileNASM_ret="yes"
734+ else
735+ CompileNASM_ret="no"
736+ fi
737+ rm -f $1 $1.o
738+ AC_MSG_RESULT($CompileNASM_ret)
739+ test "$CompileNASM_ret" = "yes"
740+ }
741+
742+ if test x"$NASMFLAGS" = x; then
743+ case $ARCH in
744+ win32)
745+ NASMFLAGS="-f win32"
746+ ;;
747+ macosx)
748+ NASMFLAGS="-f macho"
749+ ;;
750+ *)
751+ NASMFLAGS="-f elf32"
752+ ;;
753+ esac
754+ fi
755+
756+ AC_PATH_PROG(NASM, nasm)
757+ echo "%ifidn __OUTPUT_FORMAT__,elf32" > unquoted-sections
758+ echo "section .note.GNU-stack noalloc noexec nowrite progbits" >> unquoted-sections
759+ echo "%endif" >> unquoted-sections
760+ CompileNASM unquoted-sections || NASM=""
761+
762+ if test "x$NASM" != x -a "x$NASM" != x'"$NASM"'; then
763+ AC_DEFINE(SDL_HERMES_BLITTERS)
764+ SOURCES="$SOURCES $srcdir/src/hermes/*.asm"
765+ NASMFLAGS="$NASMFLAGS -I $srcdir/src/hermes/"
766+
767+ dnl See if hidden visibility is supported
768+ echo "GLOBAL _bar:function hidden" > symbol-visibility
769+ echo "_bar:" >> symbol-visibility
770+ CompileNASM symbol-visibility && NASMFLAGS="$NASMFLAGS -DHIDDEN_VISIBILITY"
771+
772+ AC_SUBST(NASM)
773+ AC_SUBST(NASMFLAGS)
774+
775+ case "$host" in
776+ # this line is needed for QNX, because it's not defined the __ELF__
777+ *-*-qnx*)
778+ EXTRA_CFLAGS="$EXTRA_CFLAGS -D__ELF__";;
779+ *-*-solaris*)
780+ EXTRA_CFLAGS="$EXTRA_CFLAGS -D__ELF__";;
781+ esac
782+ fi
783+ fi
784+}
785+
786+dnl Check for altivec instruction support using gas syntax
787+CheckAltivec()
788+{
789+ AC_ARG_ENABLE(altivec,
790+AC_HELP_STRING([--enable-altivec], [use altivec assembly blitters on PPC [[default=yes]]]),
791+ , enable_altivec=yes)
792+ if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_altivec = xyes; then
793+ save_CFLAGS="$CFLAGS"
794+ have_gcc_altivec=no
795+ have_altivec_h_hdr=no
796+ altivec_CFLAGS="-maltivec"
797+ CFLAGS="$save_CFLAGS $altivec_CFLAGS"
798+
799+ AC_MSG_CHECKING(for Altivec with GCC altivec.h and -maltivec option)
800+ AC_TRY_COMPILE([
801+ #include <altivec.h>
802+ vector unsigned int vzero() {
803+ return vec_splat_u32(0);
804+ }
805+ ],[
806+ ],[
807+ have_gcc_altivec=yes
808+ have_altivec_h_hdr=yes
809+ ])
810+ AC_MSG_RESULT($have_gcc_altivec)
811+
812+ if test x$have_gcc_altivec = xno; then
813+ AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
814+ AC_TRY_COMPILE([
815+ vector unsigned int vzero() {
816+ return vec_splat_u32(0);
817+ }
818+ ],[
819+ ],[
820+ have_gcc_altivec=yes
821+ ])
822+ AC_MSG_RESULT($have_gcc_altivec)
823+ fi
824+
825+ if test x$have_gcc_altivec = xno; then
826+ AC_MSG_CHECKING(for Altivec with GCC altivec.h and -faltivec option)
827+ altivec_CFLAGS="-faltivec"
828+ CFLAGS="$save_CFLAGS $altivec_CFLAGS"
829+ AC_TRY_COMPILE([
830+ #include <altivec.h>
831+ vector unsigned int vzero() {
832+ return vec_splat_u32(0);
833+ }
834+ ],[
835+ ],[
836+ have_gcc_altivec=yes
837+ have_altivec_h_hdr=yes
838+ ])
839+ AC_MSG_RESULT($have_gcc_altivec)
840+ fi
841+
842+ if test x$have_gcc_altivec = xno; then
843+ AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
844+ AC_TRY_COMPILE([
845+ vector unsigned int vzero() {
846+ return vec_splat_u32(0);
847+ }
848+ ],[
849+ ],[
850+ have_gcc_altivec=yes
851+ ])
852+ AC_MSG_RESULT($have_gcc_altivec)
853+ fi
854+ CFLAGS="$save_CFLAGS"
855+
856+ if test x$have_gcc_altivec = xyes; then
857+ AC_DEFINE(SDL_ALTIVEC_BLITTERS)
858+ if test x$have_altivec_h_hdr = xyes; then
859+ AC_DEFINE(HAVE_ALTIVEC_H)
860+ fi
861+ EXTRA_CFLAGS="$EXTRA_CFLAGS $altivec_CFLAGS"
862+ fi
863+ fi
864+}
865+
866+dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
867+dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
868+CheckVisibilityHidden()
869+{
870+ AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
871+ have_gcc_fvisibility=no
872+
873+ visibility_CFLAGS="-fvisibility=hidden"
874+ save_CFLAGS="$CFLAGS"
875+ CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
876+ AC_TRY_COMPILE([
877+ #if !defined(__GNUC__) || __GNUC__ < 4
878+ #error SDL only uses visibility attributes in GCC 4 or newer
879+ #endif
880+ ],[
881+ ],[
882+ have_gcc_fvisibility=yes
883+ ])
884+ AC_MSG_RESULT($have_gcc_fvisibility)
885+ CFLAGS="$save_CFLAGS"
886+
887+ if test x$have_gcc_fvisibility = xyes; then
888+ EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
889+ fi
890+}
891+
892+dnl See if GCC's -Wall is supported.
893+CheckWarnAll()
894+{
895+ AC_MSG_CHECKING(for GCC -Wall option)
896+ have_gcc_Wall=no
897+
898+ save_CFLAGS="$CFLAGS"
899+ CFLAGS="$save_CFLAGS -Wall"
900+ AC_TRY_COMPILE([
901+ int x = 0;
902+ ],[
903+ ],[
904+ have_gcc_Wall=yes
905+ ])
906+ AC_MSG_RESULT($have_gcc_Wall)
907+ CFLAGS="$save_CFLAGS"
908+
909+ if test x$have_gcc_Wall = xyes; then
910+ EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
911+
912+ dnl Haiku headers use multicharacter constants all over the place. Ignore these warnings when using -Wall.
913+ AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
914+ need_gcc_Wno_multichar=no
915+ case "$host" in
916+ *-*-beos* | *-*-haiku*)
917+ need_gcc_Wno_multichar=yes
918+ ;;
919+ esac
920+ AC_MSG_RESULT($need_gcc_Wno_multichar)
921+ if test x$need_gcc_Wno_multichar = xyes; then
922+ EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar"
923+ fi
924+ fi
925+}
926+
927+
928+dnl Do the iPod thing
929+CheckIPod()
930+{
931+ AC_ARG_ENABLE(ipod,
932+AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [[default=no]]]),
933+ , enable_ipod=no)
934+
935+ if test x$enable_ipod = xyes; then
936+ EXTRA_CFLAGS="$EXTRA_CFLAGS -DIPOD"
937+ AC_DEFINE(SDL_VIDEO_DRIVER_IPOD)
938+ SOURCES="$SOURCES $srcdir/src/video/ipod/*.c"
939+ fi
940+}
941+
942+dnl Find the nanox include and library directories
943+CheckNANOX()
944+{
945+ AC_ARG_ENABLE(video-nanox,
946+ AC_HELP_STRING([--enable-video-nanox], [use nanox video driver [[default=no]]]),
947+ , enable_video_nanox=no)
948+
949+ if test x$enable_video = xyes -a x$enable_video_nanox = xyes; then
950+ AC_ARG_ENABLE(nanox-debug,
951+ AC_HELP_STRING([--enable-nanox-debug], [print debug messages [[default=no]]]),
952+ , enable_nanox_debug=no)
953+ if test x$enable_nanox_debug = xyes; then
954+ EXTRA_CFLAGS="$EXTRA_CFLAGS -DENABLE_NANOX_DEBUG"
955+ fi
956+
957+ AC_ARG_ENABLE(nanox-share-memory,
958+ AC_HELP_STRING([--enable-nanox-share-memory], [use share memory [[default=no]]]),
959+ , enable_nanox_share_memory=no)
960+ if test x$enable_nanox_share_memory = xyes; then
961+ EXTRA_CFLAGS="$EXTRA_CFLAGS -DNANOX_SHARE_MEMORY"
962+ fi
963+
964+ AC_ARG_ENABLE(nanox_direct_fb,
965+ AC_HELP_STRING([--enable-nanox-direct-fb], [use direct framebuffer access [[default=no]]]),
966+ , enable_nanox_direct_fb=no)
967+ if test x$enable_nanox_direct_fb = xyes; then
968+ EXTRA_CFLAGS="$EXTRA_CFLAGS -DENABLE_NANOX_DIRECT_FB"
969+ fi
970+
971+ AC_DEFINE(SDL_VIDEO_DRIVER_NANOX)
972+ SOURCES="$SOURCES $srcdir/src/video/nanox/*.c"
973+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lnano-X"
974+ have_video=yes
975+ fi
976+}
977+
978+dnl Find the X11 include and library directories
979+CheckX11()
980+{
981+ AC_ARG_ENABLE(video-x11,
982+AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
983+ , enable_video_x11=yes)
984+ if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
985+ case "$host" in
986+ *-*-darwin*)
987+ # This isn't necessary for X11, but fixes GLX detection
988+ if test "x$x_includes" = xNONE && test "x$x_libraries" = xNONE; then
989+ x_includes="/usr/X11R6/include"
990+ x_libraries="/usr/X11R6/lib"
991+ fi
992+ ;;
993+ esac
994+ AC_PATH_X
995+ AC_PATH_XTRA
996+ if test x$have_x = xyes; then
997+ # Only allow dynamically loaded X11 if the X11 function pointers
998+ # will not end up in the global namespace, which causes problems
999+ # with other libraries calling X11 functions.
1000+ x11_symbols_private=$have_gcc_fvisibility
1001+
1002+ AC_ARG_ENABLE(x11-shared,
1003+AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
1004+ , enable_x11_shared=maybe)
1005+
1006+ case "$host" in
1007+ *-*-darwin*) # Latest Mac OS X actually ships with Xrandr/Xrender libs...
1008+ x11_symbols_private=yes
1009+ x11_lib='/usr/X11R6/lib/libX11.6.dylib'
1010+ x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
1011+ xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
1012+ xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
1013+ ;;
1014+ *-*-osf*)
1015+ x11_lib='libX11.so'
1016+ x11ext_lib='libXext.so'
1017+ ;;
1018+ *-*-irix*) # IRIX 6.5 requires that we use /usr/lib32
1019+ x11_lib='libX11.so'
1020+ x11ext_lib='libXext.so'
1021+ ;;
1022+ *)
1023+ x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
1024+ x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
1025+ xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
1026+ xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
1027+ ;;
1028+ esac
1029+
1030+ X_CFLAGS="$X_CFLAGS -DXTHREADS"
1031+ if test x$ac_cv_func_shmat != xyes; then
1032+ X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
1033+ fi
1034+ CFLAGS="$CFLAGS $X_CFLAGS"
1035+ LDFLAGS="$LDFLAGS $X_LIBS"
1036+
1037+ AC_DEFINE(SDL_VIDEO_DRIVER_X11)
1038+ SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
1039+ EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
1040+
1041+ if test x$enable_x11_shared = xmaybe; then
1042+ enable_x11_shared=$x11_symbols_private
1043+ fi
1044+ if test x$have_loadso != xyes && \
1045+ test x$enable_x11_shared = xyes; then
1046+ AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
1047+ enable_x11_shared=no
1048+ fi
1049+ if test x$x11_symbols_private != xyes && \
1050+ test x$enable_x11_shared = xyes; then
1051+ AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
1052+ enable_x11_shared=no
1053+ fi
1054+
1055+ if test x$have_loadso = xyes && \
1056+ test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
1057+ echo "-- dynamic libX11 -> $x11_lib"
1058+ echo "-- dynamic libX11ext -> $x11ext_lib"
1059+ AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib")
1060+ AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib")
1061+ else
1062+ enable_x11_shared=no
1063+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
1064+ fi
1065+ have_video=yes
1066+
1067+ AC_ARG_ENABLE(dga,
1068+AC_HELP_STRING([--enable-dga], [allow use of X11 DGA code [[default=yes]]]),
1069+ , enable_dga=yes)
1070+ if test x$enable_dga = xyes; then
1071+ SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86dga/*.c"
1072+ fi
1073+ AC_ARG_ENABLE(video-dga,
1074+AC_HELP_STRING([--enable-video-dga], [use DGA 2.0 video driver [[default=yes]]]),
1075+ , enable_video_dga=yes)
1076+ if test x$enable_dga = xyes -a x$enable_video_dga = xyes; then
1077+ AC_DEFINE(SDL_VIDEO_DRIVER_DGA)
1078+ SOURCES="$SOURCES $srcdir/src/video/dga/*.c"
1079+ fi
1080+ AC_ARG_ENABLE(video-x11-dgamouse,
1081+AC_HELP_STRING([--enable-video-x11-dgamouse], [use X11 DGA for mouse events [[default=yes]]]),
1082+ , enable_video_x11_dgamouse=yes)
1083+ if test x$enable_dga = xyes -a x$enable_video_x11_dgamouse = xyes; then
1084+ AC_DEFINE(SDL_VIDEO_DRIVER_X11_DGAMOUSE)
1085+ fi
1086+ AC_ARG_ENABLE(video-x11-vm,
1087+AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
1088+ , enable_video_x11_vm=yes)
1089+ if test x$enable_video_x11_vm = xyes; then
1090+ AC_DEFINE(SDL_VIDEO_DRIVER_X11_VIDMODE)
1091+ SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86vm/*.c"
1092+ fi
1093+ AC_ARG_ENABLE(video-x11-xv,
1094+AC_HELP_STRING([--enable-video-x11-xv], [use X11 XvImage extension for video [[default=yes]]]),
1095+ , enable_video_x11_xv=yes)
1096+ if test x$enable_video_x11_xv = xyes; then
1097+ AC_DEFINE(SDL_VIDEO_DRIVER_X11_XV)
1098+ SOURCES="$SOURCES $srcdir/src/video/Xext/Xv/*.c"
1099+ fi
1100+ AC_ARG_ENABLE(video-x11-xinerama,
1101+AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
1102+ , enable_video_x11_xinerama=yes)
1103+ if test x$enable_video_x11_xinerama = xyes; then
1104+ AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA)
1105+ SOURCES="$SOURCES $srcdir/src/video/Xext/Xinerama/*.c"
1106+ fi
1107+ AC_ARG_ENABLE(video-x11-xme,
1108+AC_HELP_STRING([--enable-video-x11-xme], [enable Xi Graphics XME for fullscreen [[default=yes]]]),
1109+ , enable_video_x11_xme=yes)
1110+ if test x$enable_video_x11_xme = xyes; then
1111+ AC_DEFINE(SDL_VIDEO_DRIVER_X11_XME)
1112+ SOURCES="$SOURCES $srcdir/src/video/Xext/XME/*.c"
1113+ fi
1114+ AC_ARG_ENABLE(video-x11-xrandr,
1115+AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
1116+ , enable_video_x11_xrandr=yes)
1117+ if test x$enable_video_x11_xrandr = xyes; then
1118+ definitely_enable_video_x11_xrandr=no
1119+ AC_CHECK_HEADER(X11/extensions/Xrandr.h,
1120+ have_xrandr_h_hdr=yes,
1121+ have_xrandr_h_hdr=no,
1122+ [#include <X11/Xlib.h>
1123+ ])
1124+ if test x$have_xrandr_h_hdr = xyes; then
1125+ if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
1126+ echo "-- dynamic libXrender -> $xrender_lib"
1127+ echo "-- dynamic libXrandr -> $xrandr_lib"
1128+ AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER, "$xrender_lib")
1129+ AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib")
1130+ definitely_enable_video_x11_xrandr=yes
1131+ else
1132+ AC_CHECK_LIB(Xrender, XRenderQueryExtension, have_xrender_lib=yes)
1133+ AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
1134+ if test x$have_xrender_lib = xyes && test x$have_xrandr_lib = xyes ; then
1135+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr -lXrender"
1136+ definitely_enable_video_x11_xrandr=yes
1137+ fi
1138+ fi
1139+ fi
1140+ fi
1141+ if test x$definitely_enable_video_x11_xrandr = xyes; then
1142+ AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR)
1143+ fi
1144+ fi
1145+ fi
1146+}
1147+
1148+dnl Check for QNX photon video driver
1149+CheckPHOTON()
1150+{
1151+ AC_ARG_ENABLE(video-photon,
1152+AC_HELP_STRING([--enable-video-photon], [use QNX Photon video driver [[default=yes]]]),
1153+ , enable_video_photon=yes)
1154+ if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
1155+ AC_MSG_CHECKING(for QNX Photon support)
1156+ video_photon=no
1157+ AC_TRY_COMPILE([
1158+ #include <Ph.h>
1159+ #include <Pt.h>
1160+ #include <photon/Pg.h>
1161+ #include <photon/PdDirect.h>
1162+ ],[
1163+ PgDisplaySettings_t *visual;
1164+ ],[
1165+ video_photon=yes
1166+ ])
1167+ AC_MSG_RESULT($video_photon)
1168+ if test x$video_photon = xyes; then
1169+ AC_DEFINE(SDL_VIDEO_DRIVER_PHOTON)
1170+ SOURCES="$SOURCES $srcdir/src/video/photon/*.c"
1171+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lph"
1172+ have_video=yes
1173+
1174+ CheckOpenGLQNX
1175+ fi
1176+ fi
1177+}
1178+
1179+dnl Set up the BWindow video driver if enabled
1180+CheckBWINDOW()
1181+{
1182+ if test x$enable_video = xyes; then
1183+ AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW)
1184+ SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
1185+ have_video=yes
1186+ fi
1187+}
1188+
1189+dnl Set up the Carbon/QuickDraw video driver for Mac OS X (but not Darwin)
1190+CheckCARBON()
1191+{
1192+ AC_ARG_ENABLE(video-carbon,
1193+AC_HELP_STRING([--enable-video-carbon], [use Carbon/QuickDraw video driver [[default=no]]]),
1194+ , enable_video_carbon=no)
1195+ if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
1196+ AC_MSG_CHECKING(for Carbon framework)
1197+ have_carbon=no
1198+ AC_TRY_COMPILE([
1199+ #include <Carbon/Carbon.h>
1200+ ],[
1201+ ],[
1202+ have_carbon=yes
1203+ ])
1204+ AC_MSG_RESULT($have_carbon)
1205+ if test x$have_carbon = xyes; then
1206+ AC_DEFINE(SDL_VIDEO_DRIVER_TOOLBOX)
1207+ SOURCES="$SOURCES $srcdir/src/video/maccommon/*.c"
1208+ SOURCES="$SOURCES $srcdir/src/video/macrom/*.c"
1209+ have_video=yes
1210+ fi
1211+ fi
1212+}
1213+
1214+dnl Set up the Cocoa/Quartz video driver for Mac OS X (but not Darwin)
1215+CheckCOCOA()
1216+{
1217+ AC_ARG_ENABLE(video-cocoa,
1218+AC_HELP_STRING([--enable-video-cocoa], [use Cocoa/Quartz video driver [[default=yes]]]),
1219+ , enable_video_cocoa=yes)
1220+ if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
1221+ save_CFLAGS="$CFLAGS"
1222+ dnl work around that we don't have Objective-C support in autoconf
1223+ CFLAGS="$CFLAGS -x objective-c"
1224+ AC_MSG_CHECKING(for Cocoa framework)
1225+ have_cocoa=no
1226+ AC_TRY_COMPILE([
1227+ #import <Cocoa/Cocoa.h>
1228+ ],[
1229+ ],[
1230+ have_cocoa=yes
1231+ ])
1232+ AC_MSG_RESULT($have_cocoa)
1233+ CFLAGS="$save_CFLAGS"
1234+ if test x$have_cocoa = xyes; then
1235+ AC_DEFINE(SDL_VIDEO_DRIVER_QUARTZ)
1236+ SOURCES="$SOURCES $srcdir/src/video/quartz/*.m"
1237+ have_video=yes
1238+ fi
1239+ fi
1240+}
1241+
1242+dnl Find the framebuffer console includes
1243+CheckFBCON()
1244+{
1245+ AC_ARG_ENABLE(video-fbcon,
1246+AC_HELP_STRING([--enable-video-fbcon], [use framebuffer console video driver [[default=yes]]]),
1247+ , enable_video_fbcon=yes)
1248+ if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
1249+ AC_MSG_CHECKING(for framebuffer console support)
1250+ video_fbcon=no
1251+ AC_TRY_COMPILE([
1252+ #include <linux/fb.h>
1253+ #include <linux/kd.h>
1254+ #include <linux/keyboard.h>
1255+ ],[
1256+ ],[
1257+ video_fbcon=yes
1258+ ])
1259+ AC_MSG_RESULT($video_fbcon)
1260+ if test x$video_fbcon = xyes; then
1261+ AC_CHECK_FUNCS(getpagesize)
1262+ AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
1263+ SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
1264+ have_video=yes
1265+ fi
1266+ fi
1267+}
1268+
1269+dnl Find DirectFB
1270+CheckDirectFB()
1271+{
1272+ AC_ARG_ENABLE(video-directfb,
1273+AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=yes]]]),
1274+ , enable_video_directfb=yes)
1275+ if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
1276+ video_directfb=no
1277+
1278+ DIRECTFB_REQUIRED_VERSION=0.9.15
1279+
1280+ AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
1281+ if test x$DIRECTFBCONFIG = xno; then
1282+ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1283+ if test x$PKG_CONFIG != xno; then
1284+ if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
1285+ DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
1286+ DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
1287+ video_directfb=yes
1288+ fi
1289+ fi
1290+ else
1291+ set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
1292+ NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
1293+ set -- `directfb-config --version | sed 's/\./ /g'`
1294+ HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
1295+ if test $HAVE_VERSION -ge $NEED_VERSION; then
1296+ DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
1297+ DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
1298+ video_directfb=yes
1299+ fi
1300+ fi
1301+ if test x$video_directfb = xyes; then
1302+ # SuSE 11.1 installs directfb-config without directfb-devel
1303+ save_CFLAGS="$CFLAGS"
1304+ CFLAGS="$CFLAGS $DIRECTFB_CFLAGS"
1305+ AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
1306+ CFLAGS="$save_CFLAGS"
1307+ video_directfb=$have_directfb_hdr
1308+ fi
1309+ AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
1310+ AC_MSG_RESULT($video_directfb)
1311+
1312+ if test x$video_directfb = xyes; then
1313+ AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
1314+ SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
1315+ EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
1316+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
1317+ have_video=yes
1318+ fi
1319+ fi
1320+}
1321+
1322+dnl See if we're running on PlayStation 2 hardware
1323+CheckPS2GS()
1324+{
1325+ AC_ARG_ENABLE(video-ps2gs,
1326+AC_HELP_STRING([--enable-video-ps2gs], [use PlayStation 2 GS video driver [[default=yes]]]),
1327+ , enable_video_ps2gs=yes)
1328+ if test x$enable_video = xyes -a x$enable_video_ps2gs = xyes; then
1329+ AC_MSG_CHECKING(for PlayStation 2 GS support)
1330+ video_ps2gs=no
1331+ AC_TRY_COMPILE([
1332+ #include <linux/ps2/dev.h>
1333+ #include <linux/ps2/gs.h>
1334+ ],[
1335+ ],[
1336+ video_ps2gs=yes
1337+ ])
1338+ AC_MSG_RESULT($video_ps2gs)
1339+ if test x$video_ps2gs = xyes; then
1340+ AC_DEFINE(SDL_VIDEO_DRIVER_PS2GS)
1341+ SOURCES="$SOURCES $srcdir/src/video/ps2gs/*.c"
1342+ have_video=yes
1343+ fi
1344+ fi
1345+}
1346+
1347+dnl See if we're running on PlayStation 3 Cell hardware
1348+CheckPS3()
1349+{
1350+ AC_ARG_ENABLE(video-ps3,
1351+ AC_HELP_STRING([--enable-video-ps3], [use PlayStation 3 Cell driver [[default=yes]]]),
1352+ , enable_video_ps3=yes)
1353+ if test x$enable_video = xyes -a x$enable_video_ps3 = xyes; then
1354+ AC_MSG_CHECKING(for PlayStation 3 Cell support)
1355+ video_ps3=no
1356+ AC_TRY_COMPILE([
1357+ #include <linux/fb.h>
1358+ #include <asm/ps3fb.h>
1359+ #include <libspe2.h>
1360+ ],[
1361+ ],[
1362+ video_ps3=yes
1363+ ])
1364+ AC_MSG_RESULT($video_ps3)
1365+ if test x$video_ps3 = xyes; then
1366+ AC_DEFINE(SDL_VIDEO_DRIVER_PS3)
1367+ SOURCES="$SOURCES $srcdir/src/video/ps3/*.c"
1368+ EXTRA_CFLAGS="$EXTRA_CFLAGS -I/opt/cell/sdk/usr/include"
1369+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lbilin_scaler_spu -lfb_writer_spu -lyuv2rgb_spu -L/opt/cell/sdk/usr/lib -lspe2"
1370+ have_video=yes
1371+ fi
1372+ fi
1373+}
1374+
1375+dnl Find the GGI includes
1376+CheckGGI()
1377+{
1378+ AC_ARG_ENABLE(video-ggi,
1379+AC_HELP_STRING([--enable-video-ggi], [use GGI video driver [[default=no]]]),
1380+ , enable_video_ggi=no)
1381+ if test x$enable_video = xyes -a x$enable_video_ggi = xyes; then
1382+ AC_MSG_CHECKING(for GGI support)
1383+ video_ggi=no
1384+ AC_TRY_COMPILE([
1385+ #include <ggi/ggi.h>
1386+ #include <ggi/gii.h>
1387+ ],[
1388+ ],[
1389+ video_ggi=yes
1390+ ])
1391+ AC_MSG_RESULT($video_ggi)
1392+ if test x$video_ggi = xyes; then
1393+ AC_DEFINE(SDL_VIDEO_DRIVER_GGI)
1394+ SOURCES="$SOURCES $srcdir/src/video/ggi/*.c"
1395+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lggi -lgii -lgg"
1396+ have_video=yes
1397+ fi
1398+ fi
1399+}
1400+
1401+dnl Find the SVGAlib includes and libraries
1402+CheckSVGA()
1403+{
1404+ AC_ARG_ENABLE(video-svga,
1405+AC_HELP_STRING([--enable-video-svga], [use SVGAlib video driver [[default=yes]]]),
1406+ , enable_video_svga=yes)
1407+ if test x$enable_video = xyes -a x$enable_video_svga = xyes; then
1408+ AC_MSG_CHECKING(for SVGAlib (1.4.0+) support)
1409+ video_svga=no
1410+ AC_TRY_COMPILE([
1411+ #include <vga.h>
1412+ #include <vgamouse.h>
1413+ #include <vgakeyboard.h>
1414+ ],[
1415+ if ( SCANCODE_RIGHTWIN && SCANCODE_LEFTWIN ) {
1416+ exit(0);
1417+ }
1418+ ],[
1419+ video_svga=yes
1420+ ])
1421+ AC_MSG_RESULT($video_svga)
1422+ if test x$video_svga = xyes; then
1423+ AC_DEFINE(SDL_VIDEO_DRIVER_SVGALIB)
1424+ SOURCES="$SOURCES $srcdir/src/video/svga/*.c"
1425+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvga"
1426+ have_video=yes
1427+ fi
1428+ fi
1429+}
1430+
1431+dnl Find the VGL includes and libraries
1432+CheckVGL()
1433+{
1434+ AC_ARG_ENABLE(video-vgl,
1435+AC_HELP_STRING([--enable-video-vgl], [use VGL video driver [[default=yes]]]),
1436+ , enable_video_vgl=yes)
1437+ if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
1438+ AC_MSG_CHECKING(for libVGL support)
1439+ video_vgl=no
1440+ AC_TRY_COMPILE([
1441+ #include <sys/fbio.h>
1442+ #include <sys/consio.h>
1443+ #include <sys/kbio.h>
1444+ #include <vgl.h>
1445+ ],[
1446+ VGLBitmap bitmap;
1447+ bitmap.Type = VIDBUF32;
1448+ bitmap.PixelBytes = 4;
1449+ exit(bitmap.Bitmap);
1450+ ],[
1451+ video_vgl=yes
1452+ ])
1453+ AC_MSG_RESULT($video_vgl)
1454+ if test x$video_vgl = xyes; then
1455+ AC_DEFINE(SDL_VIDEO_DRIVER_VGL)
1456+ SOURCES="$SOURCES $srcdir/src/video/vgl/*.c"
1457+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvgl"
1458+ have_video=yes
1459+ fi
1460+ fi
1461+}
1462+
1463+dnl Set up the wscons video driver if enabled
1464+CheckWscons()
1465+{
1466+ AC_ARG_ENABLE(video-wscons,
1467+AC_HELP_STRING([--enable-video-wscons], [use wscons video driver [[default=yes]]]),
1468+ , enable_video_wscons=yes)
1469+ if test x$enable_video = xyes -a x$enable_video_wscons = xyes; then
1470+ AC_MSG_CHECKING(for wscons support)
1471+ video_wscons=no
1472+ AC_TRY_COMPILE([
1473+ #include <sys/time.h>
1474+ #include <dev/wscons/wsconsio.h>
1475+ #include <dev/wscons/wsdisplay_usl_io.h>
1476+ ],[
1477+ int wsmode = WSDISPLAYIO_MODE_DUMBFB;
1478+ ],[
1479+ video_wscons=yes
1480+ ])
1481+ AC_MSG_RESULT($video_wscons)
1482+ if test x$video_wscons = xyes; then
1483+ AC_DEFINE(SDL_VIDEO_DRIVER_WSCONS)
1484+ SOURCES="$SOURCES $srcdir/src/video/wscons/*.c"
1485+ have_video=yes
1486+ fi
1487+ fi
1488+}
1489+
1490+
1491+dnl Find the AAlib includes
1492+CheckAAlib()
1493+{
1494+ AC_ARG_ENABLE(video-aalib,
1495+AC_HELP_STRING([--enable-video-aalib], [use AAlib video driver [[default=no]]]),
1496+ , enable_video_aalib=no)
1497+ if test x$enable_video = xyes -a x$enable_video_aalib = xyes; then
1498+ AC_MSG_CHECKING(for AAlib support)
1499+ video_aalib=no
1500+ AC_TRY_COMPILE([
1501+ #include <aalib.h>
1502+ ],[
1503+ ],[
1504+ video_aalib=yes
1505+ ])
1506+ AC_MSG_RESULT($video_aalib)
1507+ if test x$video_aalib = xyes; then
1508+ AC_DEFINE(SDL_VIDEO_DRIVER_AALIB)
1509+ SOURCES="$SOURCES $srcdir/src/video/aalib/*.c"
1510+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -laa"
1511+ have_video=yes
1512+ fi
1513+ fi
1514+}
1515+
1516+dnl Find the libcaca includes
1517+CheckCaca()
1518+{
1519+ AC_ARG_ENABLE(video-caca,
1520+AC_HELP_STRING([--enable-video-caca], [use libcaca video driver [[default=no]]]),
1521+ , enable_video_caca=no)
1522+ if test x$enable_video = xyes -a x$enable_video_caca = xyes; then
1523+ video_caca=no
1524+ AC_PATH_PROG(CACACONFIG, caca-config, no)
1525+ if test x$CACACONFIG != xno; then
1526+ AC_MSG_CHECKING(for libcaca support)
1527+ CACA_CFLAGS=`$CACACONFIG --cflags`
1528+ CACA_LDFLAGS=`$CACACONFIG --libs`
1529+ save_CFLAGS="$CFLAGS"
1530+ AC_TRY_COMPILE([
1531+ #include <caca.h>
1532+ ],[
1533+ ],[
1534+ video_caca=yes
1535+ ])
1536+ CFLAGS="$save_CFLAGS"
1537+ AC_MSG_RESULT($video_caca)
1538+ if test x$video_caca = xyes; then
1539+ AC_DEFINE(SDL_VIDEO_DRIVER_CACA)
1540+ EXTRA_CFLAGS="$EXTRA_CFLAGS $CACA_CFLAGS"
1541+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $CACA_LDFLAGS"
1542+ SOURCES="$SOURCES $srcdir/src/video/caca/*.c"
1543+ fi
1544+ fi
1545+ fi
1546+}
1547+
1548+dnl Set up the QTopia video driver if enabled
1549+CheckQtopia()
1550+{
1551+ AC_ARG_ENABLE(video-qtopia,
1552+AC_HELP_STRING([--enable-video-qtopia], [use Qtopia video driver [[default=no]]]),
1553+ , enable_video_qtopia=no)
1554+ if test x$enable_video = xyes -a x$enable_video_qtopia = xyes; then
1555+ AC_MSG_CHECKING(for Qtopia support)
1556+ video_qtopia=no
1557+ QTOPIA_FLAGS="-DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -I${QPEDIR}/include -I${QTDIR}/include/ -DNO_DEBUG -fno-rtti -fno-exceptions"
1558+ AC_LANG_CPLUSPLUS
1559+ OLD_CXX="$CXXFLAGS"
1560+ CXXFLAGS="$QTOPIA_FLAGS"
1561+ AC_TRY_COMPILE([
1562+ #include <qpe/qpeapplication.h>
1563+ ],[
1564+ ],[
1565+ video_qtopia=yes
1566+ ])
1567+ CXXFLAGS="$OLD_CXX"
1568+ AC_MSG_RESULT($video_qtopia)
1569+ if test x$video_qtopia = xyes; then
1570+ AC_DEFINE(SDL_VIDEO_DRIVER_QTOPIA)
1571+ SOURCES="$SOURCES $srcdir/src/video/qtopia/*.cc"
1572+ SDLMAIN_SOURCES="$srcdir/src/main/qtopia/*.cc"
1573+ SDLMAIN_LDFLAGS="-static"
1574+ EXTRA_CFLAGS="$EXTRA_CFLAGS $QTOPIA_FLAGS"
1575+ SDL_CFLAGS="$SDL_CFLAGS -DQWS -Dmain=SDL_main"
1576+ SDL_LIBS="-lSDLmain $SDL_LIBS -L${QPEDIR}/lib -L${QTDIR}/lib/ -lqpe -lqte"
1577+ have_video=yes
1578+ fi
1579+ AC_LANG_C
1580+ fi
1581+}
1582+
1583+dnl Set up the PicoGUI video driver if enabled
1584+CheckPicoGUI()
1585+{
1586+ AC_ARG_ENABLE(video-picogui,
1587+AC_HELP_STRING([--enable-video-picogui], [use PicoGUI video driver [[default=no]]]),
1588+ , enable_video_picogui=no)
1589+ if test x$enable_video = xyes -a x$enable_video_picogui = xyes; then
1590+ AC_MSG_CHECKING(for PicoGUI support)
1591+ video_picogui=no
1592+ AC_TRY_COMPILE([
1593+ #include <picogui.h>
1594+ ],[
1595+ ],[
1596+ video_picogui=yes
1597+ ])
1598+ AC_MSG_RESULT($video_picogui)
1599+ if test x$video_picogui = xyes; then
1600+ AC_DEFINE(SDL_VIDEO_DRIVER_PICOGUI)
1601+ SOURCES="$SOURCES $srcdir/src/video/picogui/*.c"
1602+ SDL_LIBS="$SDL_LIBS -lpgui"
1603+ have_video=yes
1604+ fi
1605+ fi
1606+}
1607+
1608+dnl Set up the Atari Bios keyboard driver
1609+CheckAtariBiosEvent()
1610+{
1611+ SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.c"
1612+ SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.S"
1613+}
1614+
1615+dnl Set up the Atari Xbios driver
1616+CheckAtariXbiosVideo()
1617+{
1618+ AC_ARG_ENABLE(xbios,
1619+AC_HELP_STRING([--enable-video-xbios], [use Atari Xbios video driver [[default=yes]]]),
1620+ , enable_video_xbios=yes)
1621+ video_xbios=no
1622+ if test x$enable_video = xyes -a x$enable_video_xbios = xyes; then
1623+ video_xbios=yes
1624+ AC_DEFINE(SDL_VIDEO_DRIVER_XBIOS)
1625+ SOURCES="$SOURCES $srcdir/src/video/xbios/*.c"
1626+ have_video=yes
1627+ fi
1628+}
1629+
1630+dnl Set up the Atari Gem driver
1631+CheckAtariGemVideo()
1632+{
1633+ AC_ARG_ENABLE(gem,
1634+AC_HELP_STRING([--enable-video-gem], [use Atari Gem video driver [[default=yes]]]),
1635+ , enable_video_gem=yes)
1636+ if test x$enable_video = xyes -a x$enable_video_gem = xyes; then
1637+ video_gem=no
1638+ AC_CHECK_HEADER(gem.h, have_gem_hdr=yes)
1639+ AC_CHECK_LIB(gem, appl_init, have_gem_lib=yes)
1640+ if test x$have_gem_hdr = xyes -a x$have_gem_lib = xyes; then
1641+ video_gem=yes
1642+ AC_DEFINE(SDL_VIDEO_DRIVER_GEM)
1643+ SOURCES="$SOURCES $srcdir/src/video/gem/*.c"
1644+ SDL_LIBS="$SDL_LIBS -lgem"
1645+ have_video=yes
1646+ fi
1647+ fi
1648+}
1649+
1650+dnl rcg04172001 Set up the Null video driver.
1651+CheckDummyVideo()
1652+{
1653+ AC_ARG_ENABLE(video-dummy,
1654+AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
1655+ , enable_video_dummy=yes)
1656+ if test x$enable_video_dummy = xyes; then
1657+ AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY)
1658+ SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
1659+ have_video=yes
1660+ fi
1661+}
1662+
1663+dnl Check to see if OpenGL support is desired
1664+AC_ARG_ENABLE(video-opengl,
1665+AC_HELP_STRING([--enable-video-opengl], [include OpenGL context creation [[default=yes]]]),
1666+ , enable_video_opengl=yes)
1667+
1668+dnl Find OpenGL
1669+CheckOpenGLX11()
1670+{
1671+ if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
1672+ AC_MSG_CHECKING(for OpenGL (GLX) support)
1673+ video_opengl=no
1674+ AC_TRY_COMPILE([
1675+ #include <GL/gl.h>
1676+ #include <GL/glx.h>
1677+ #include <GL/glu.h>
1678+ ],[
1679+ ],[
1680+ video_opengl=yes
1681+ ])
1682+ AC_MSG_RESULT($video_opengl)
1683+ if test x$video_opengl = xyes; then
1684+ AC_DEFINE(SDL_VIDEO_OPENGL)
1685+ AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
1686+ fi
1687+ fi
1688+}
1689+
1690+dnl Find QNX RtP OpenGL
1691+CheckOpenGLQNX()
1692+{
1693+ if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
1694+ AC_MSG_CHECKING(for OpenGL (Photon) support)
1695+ video_opengl=no
1696+ AC_TRY_COMPILE([
1697+ #include <GL/gl.h>
1698+ ],[
1699+ ],[
1700+ video_opengl=yes
1701+ ])
1702+ AC_MSG_RESULT($video_opengl)
1703+ if test x$video_opengl = xyes; then
1704+ AC_DEFINE(SDL_VIDEO_OPENGL)
1705+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
1706+ fi
1707+ fi
1708+}
1709+
1710+dnl Check for Win32 OpenGL
1711+CheckWIN32GL()
1712+{
1713+ if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
1714+ AC_DEFINE(SDL_VIDEO_OPENGL)
1715+ AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
1716+ fi
1717+}
1718+
1719+dnl Check for BeOS OpenGL
1720+CheckBeGL()
1721+{
1722+ if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
1723+ AC_DEFINE(SDL_VIDEO_OPENGL)
1724+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
1725+ fi
1726+}
1727+
1728+dnl Check for MacOS OpenGL
1729+CheckMacGL()
1730+{
1731+ if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
1732+ AC_DEFINE(SDL_VIDEO_OPENGL)
1733+ case "$host" in
1734+ *-*-darwin*)
1735+ if test x$enable_video_cocoa = xyes; then
1736+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
1737+ fi
1738+ if test x$enable_video_carbon = xyes; then
1739+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AGL"
1740+ fi
1741+ esac
1742+ fi
1743+}
1744+
1745+dnl Check for Mesa offscreen rendering
1746+CheckAtariOSMesa()
1747+{
1748+ if test "x$enable_video" = "xyes" -a "x$enable_video_opengl" = "xyes"; then
1749+ AC_CHECK_HEADER(GL/osmesa.h, have_osmesa_hdr=yes)
1750+ AC_CHECK_LIB(OSMesa, OSMesaCreateContext, have_osmesa_lib=yes, have_osmesa_lib=no, -lm)
1751+
1752+ # Static linking to -lOSMesa
1753+ AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
1754+ if test "x$OSMESA_CONFIG" = "xno" -o "x$enable_atari_ldg" = "xno"; then
1755+ # -lOSMesa is really the static library
1756+ if test "x$have_osmesa_hdr" = "xyes" -a "x$have_osmesa_lib" = "xyes"; then
1757+ OSMESA_LIBS="-lOSMesa"
1758+ fi
1759+ else
1760+ # -lOSMesa is a loader for OSMesa.ldg
1761+ OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
1762+ OSMESA_LIBS=`$OSMESA_CONFIG --libs`
1763+ fi
1764+ AC_DEFINE(SDL_VIDEO_OPENGL)
1765+ AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA)
1766+ SDL_CFLAGS="$SDL_CFLAGS $OSMESA_CFLAGS"
1767+ SDL_LIBS="$SDL_LIBS $OSMESA_LIBS"
1768+
1769+ AC_ARG_ENABLE(osmesa-shared,
1770+AC_HELP_STRING([--enable-osmesa-shared], [dynamically load OSMesa OpenGL support [[default=yes]]]),
1771+ , enable_osmesa_shared=yes)
1772+ if test "x$enable_osmesa_shared" = "xyes" -a "x$enable_atari_ldg" = "xyes"; then
1773+ # Dynamic linking
1774+ if test "x$have_osmesa_hdr" = "xyes"; then
1775+ AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA_DYNAMIC)
1776+ fi
1777+ fi
1778+ fi
1779+}
1780+
1781+AC_ARG_ENABLE(screensaver,
1782+AC_HELP_STRING([--enable-screensaver], [enable screensaver by default while any SDL application is running [[default=no]]]),
1783+ , enable_screensaver=no)
1784+if test x$enable_screensaver = xno; then
1785+ AC_DEFINE(SDL_VIDEO_DISABLE_SCREENSAVER)
1786+fi
1787+
1788+dnl See if we can use the new unified event interface in Linux 2.4
1789+CheckInputEvents()
1790+{
1791+ dnl Check for Linux 2.4 unified input event interface support
1792+ AC_ARG_ENABLE(input-events,
1793+AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [[default=yes]]]),
1794+ , enable_input_events=yes)
1795+ if test x$enable_input_events = xyes; then
1796+ AC_MSG_CHECKING(for Linux 2.4 unified input interface)
1797+ use_input_events=no
1798+ AC_TRY_COMPILE([
1799+ #include <linux/input.h>
1800+ ],[
1801+ #ifndef EVIOCGNAME
1802+ #error EVIOCGNAME() ioctl not available
1803+ #endif
1804+ ],[
1805+ use_input_events=yes
1806+ ])
1807+ AC_MSG_RESULT($use_input_events)
1808+ if test x$use_input_events = xyes; then
1809+ AC_DEFINE(SDL_INPUT_LINUXEV)
1810+ fi
1811+ fi
1812+}
1813+
1814+dnl See if we can use the Touchscreen input library
1815+CheckTslib()
1816+{
1817+ AC_ARG_ENABLE(input-tslib,
1818+AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
1819+ , enable_input_tslib=yes)
1820+ if test x$enable_input_tslib = xyes; then
1821+ AC_MSG_CHECKING(for Touchscreen library support)
1822+ enable_input_tslib=no
1823+ AC_TRY_COMPILE([
1824+ #include "tslib.h"
1825+ ],[
1826+ ],[
1827+ enable_input_tslib=yes
1828+ ])
1829+ AC_MSG_RESULT($enable_input_tslib)
1830+ if test x$enable_input_tslib = xyes; then
1831+ AC_DEFINE(SDL_INPUT_TSLIB)
1832+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
1833+ fi
1834+ fi
1835+}
1836+
1837+dnl See if we can use GNU pth library for threads
1838+CheckPTH()
1839+{
1840+ dnl Check for pth support
1841+ AC_ARG_ENABLE(pth,
1842+AC_HELP_STRING([--enable-pth], [use GNU pth library for multi-threading [[default=yes]]]),
1843+ , enable_pth=yes)
1844+ if test x$enable_threads = xyes -a x$enable_pth = xyes; then
1845+ AC_PATH_PROG(PTH_CONFIG, pth-config, no)
1846+ if test "$PTH_CONFIG" = "no"; then
1847+ use_pth=no
1848+ else
1849+ use_pth=yes
1850+ fi
1851+ AC_MSG_CHECKING(pth)
1852+ AC_MSG_RESULT($use_pth)
1853+ if test "x$use_pth" = xyes; then
1854+ AC_DEFINE(SDL_THREAD_PTH)
1855+ SOURCES="$SOURCES $srcdir/src/thread/pth/*.c"
1856+ SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
1857+ SDL_CFLAGS="$SDL_CFLAGS `$PTH_CONFIG --cflags`"
1858+ SDL_LIBS="$SDL_LIBS `$PTH_CONFIG --libs --all`"
1859+ have_threads=yes
1860+ fi
1861+ fi
1862+}
1863+
1864+dnl See what type of thread model to use on Linux and Solaris
1865+CheckPTHREAD()
1866+{
1867+ dnl Check for pthread support
1868+ AC_ARG_ENABLE(pthreads,
1869+AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
1870+ , enable_pthreads=yes)
1871+ dnl This is used on Linux for glibc binary compatibility (Doh!)
1872+ AC_ARG_ENABLE(pthread-sem,
1873+AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
1874+ , enable_pthread_sem=yes)
1875+ case "$host" in
1876+ *-*-linux*|*-*-uclinux*)
1877+ pthread_cflags="-D_REENTRANT"
1878+ pthread_lib="-lpthread"
1879+ ;;
1880+ *-*-bsdi*)
1881+ pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
1882+ pthread_lib=""
1883+ ;;
1884+ *-*-darwin*)
1885+ pthread_cflags="-D_THREAD_SAFE"
1886+# causes Carbon.p complaints?
1887+# pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
1888+ ;;
1889+ *-*-freebsd*|*-*-dragonfly*)
1890+ pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
1891+ pthread_lib="-pthread"
1892+ ;;
1893+ *-*-netbsd*)
1894+ pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
1895+ pthread_lib="-lpthread"
1896+ ;;
1897+ *-*-openbsd*)
1898+ pthread_cflags="-D_REENTRANT"
1899+ pthread_lib="-pthread"
1900+ ;;
1901+ *-*-solaris*)
1902+ pthread_cflags="-D_REENTRANT"
1903+ pthread_lib="-lpthread -lposix4"
1904+ ;;
1905+ *-*-sysv5*)
1906+ pthread_cflags="-D_REENTRANT -Kthread"
1907+ pthread_lib=""
1908+ ;;
1909+ *-*-irix*)
1910+ pthread_cflags="-D_SGI_MP_SOURCE"
1911+ pthread_lib="-lpthread"
1912+ ;;
1913+ *-*-aix*)
1914+ pthread_cflags="-D_REENTRANT -mthreads"
1915+ pthread_lib="-lpthread"
1916+ ;;
1917+ *-*-hpux11*)
1918+ pthread_cflags="-D_REENTRANT"
1919+ pthread_lib="-L/usr/lib -lpthread"
1920+ ;;
1921+ *-*-qnx*)
1922+ pthread_cflags=""
1923+ pthread_lib=""
1924+ ;;
1925+ *-*-osf*)
1926+ pthread_cflags="-D_REENTRANT"
1927+ if test x$ac_cv_prog_gcc = xyes; then
1928+ pthread_lib="-lpthread -lrt"
1929+ else
1930+ pthread_lib="-lpthread -lexc -lrt"
1931+ fi
1932+ ;;
1933+ *)
1934+ pthread_cflags="-D_REENTRANT"
1935+ pthread_lib="-lpthread"
1936+ ;;
1937+ esac
1938+ if test x$enable_threads = xyes -a x$enable_pthreads = xyes -a x$enable_ipod != xyes; then
1939+ # Save the original compiler flags and libraries
1940+ ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
1941+ # Add the pthread compiler flags and libraries
1942+ CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
1943+ # Check to see if we have pthread support on this system
1944+ AC_MSG_CHECKING(for pthreads)
1945+ use_pthreads=no
1946+ AC_TRY_LINK([
1947+ #include <pthread.h>
1948+ ],[
1949+ pthread_attr_t type;
1950+ pthread_attr_init(&type);
1951+ ],[
1952+ use_pthreads=yes
1953+ ])
1954+ AC_MSG_RESULT($use_pthreads)
1955+ # Restore the compiler flags and libraries
1956+ CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
1957+
1958+ # Do futher testing if we have pthread support...
1959+ if test x$use_pthreads = xyes; then
1960+ AC_DEFINE(SDL_THREAD_PTHREAD)
1961+ EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
1962+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
1963+ SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
1964+ SDL_LIBS="$SDL_LIBS $pthread_lib"
1965+
1966+ # Save the original compiler flags and libraries
1967+ ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
1968+ # Add the pthread compiler flags and libraries
1969+ CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
1970+
1971+ # Check to see if recursive mutexes are available
1972+ AC_MSG_CHECKING(for recursive mutexes)
1973+ has_recursive_mutexes=no
1974+ if test x$has_recursive_mutexes = xno; then
1975+ AC_TRY_COMPILE([
1976+ #include <pthread.h>
1977+ ],[
1978+ pthread_mutexattr_t attr;
1979+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
1980+ ],[
1981+ has_recursive_mutexes=yes
1982+ AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX)
1983+ ])
1984+ fi
1985+ if test x$has_recursive_mutexes = xno; then
1986+ AC_TRY_COMPILE([
1987+ #include <pthread.h>
1988+ ],[
1989+ pthread_mutexattr_t attr;
1990+ pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
1991+ ],[
1992+ has_recursive_mutexes=yes
1993+ AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)
1994+ ])
1995+ fi
1996+ AC_MSG_RESULT($has_recursive_mutexes)
1997+
1998+ # Check to see if pthread semaphore support is missing
1999+ if test x$enable_pthread_sem = xyes; then
2000+ AC_MSG_CHECKING(for pthread semaphores)
2001+ have_pthread_sem=no
2002+ AC_TRY_COMPILE([
2003+ #include <pthread.h>
2004+ #include <semaphore.h>
2005+ ],[
2006+ ],[
2007+ have_pthread_sem=yes
2008+ ])
2009+ AC_MSG_RESULT($have_pthread_sem)
2010+ fi
2011+ if test x$have_pthread_sem = xyes; then
2012+ AC_MSG_CHECKING(for sem_timedwait)
2013+ have_sem_timedwait=no
2014+ AC_TRY_LINK([
2015+ #include <pthread.h>
2016+ #include <semaphore.h>
2017+ ],[
2018+ sem_timedwait(NULL, NULL);
2019+ ],[
2020+ have_sem_timedwait=yes
2021+ AC_DEFINE(HAVE_SEM_TIMEDWAIT)
2022+ ])
2023+ AC_MSG_RESULT($have_sem_timedwait)
2024+ fi
2025+
2026+ # Restore the compiler flags and libraries
2027+ CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
2028+
2029+ # Basic thread creation functions
2030+ SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
2031+
2032+ # Semaphores
2033+ # We can fake these with mutexes and condition variables if necessary
2034+ if test x$have_pthread_sem = xyes; then
2035+ SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
2036+ else
2037+ SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
2038+ fi
2039+
2040+ # Mutexes
2041+ # We can fake these with semaphores if necessary
2042+ SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
2043+
2044+ # Condition variables
2045+ # We can fake these with semaphores and mutexes if necessary
2046+ SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
2047+
2048+ have_threads=yes
2049+ else
2050+ CheckPTH
2051+ fi
2052+ fi
2053+}
2054+
2055+dnl Determine whether the compiler can produce Win32 executables
2056+CheckWIN32()
2057+{
2058+ AC_MSG_CHECKING(Win32 compiler)
2059+ have_win32_gcc=no
2060+ AC_TRY_COMPILE([
2061+ #include <windows.h>
2062+ ],[
2063+ ],[
2064+ have_win32_gcc=yes
2065+ ])
2066+ AC_MSG_RESULT($have_win32_gcc)
2067+ if test x$have_win32_gcc != xyes; then
2068+ AC_MSG_ERROR([
2069+*** Your compiler ($CC) does not produce Win32 executables!
2070+ ])
2071+ fi
2072+
2073+ dnl See if the user wants to redirect standard output to files
2074+ AC_ARG_ENABLE(stdio-redirect,
2075+AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[default=yes]]]),
2076+ , enable_stdio_redirect=yes)
2077+ if test x$enable_stdio_redirect != xyes; then
2078+ EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
2079+ fi
2080+
2081+ if test x$enable_video = xyes; then
2082+ AC_DEFINE(SDL_VIDEO_DRIVER_WINDIB)
2083+ SOURCES="$SOURCES $srcdir/src/video/wincommon/*.c"
2084+ SOURCES="$SOURCES $srcdir/src/video/windib/*.c"
2085+ have_video=yes
2086+ fi
2087+}
2088+
2089+dnl Find the DirectX includes and libraries
2090+CheckDIRECTX()
2091+{
2092+ AC_ARG_ENABLE(directx,
2093+AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]),
2094+ , enable_directx=yes)
2095+ if test x$enable_directx = xyes; then
2096+ have_directx=no
2097+ AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
2098+ AC_CHECK_HEADER(dsound.h, have_dsound=yes)
2099+ AC_CHECK_HEADER(dinput.h, use_dinput=yes)
2100+ if test x$have_ddraw = xyes -a x$have_dsound = xyes -a x$use_dinput = xyes; then
2101+ have_directx=yes
2102+ fi
2103+ if test x$enable_video = xyes -a x$have_directx = xyes; then
2104+ AC_DEFINE(SDL_VIDEO_DRIVER_DDRAW)
2105+ SOURCES="$SOURCES $srcdir/src/video/windx5/*.c"
2106+ have_video=yes
2107+ fi
2108+ fi
2109+}
2110+
2111+dnl Check for the dlfcn.h interface for dynamically loading objects
2112+CheckDLOPEN()
2113+{
2114+ AC_ARG_ENABLE(sdl-dlopen,
2115+AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
2116+ , enable_sdl_dlopen=yes)
2117+ if test x$enable_sdl_dlopen = xyes; then
2118+ AC_MSG_CHECKING(for dlopen)
2119+ have_dlopen=no
2120+ AC_TRY_COMPILE([
2121+ #include <dlfcn.h>
2122+ ],[
2123+ #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
2124+ #error Use dlcompat for Mac OS X 10.2 compatibility
2125+ #endif
2126+ ],[
2127+ have_dlopen=yes
2128+ ])
2129+ AC_MSG_RESULT($have_dlopen)
2130+
2131+ if test x$have_dlopen = xyes; then
2132+ AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
2133+ AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
2134+ AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
2135+ AC_DEFINE(SDL_LOADSO_DLOPEN)
2136+ SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
2137+ have_loadso=yes
2138+ fi
2139+ fi
2140+}
2141+
2142+dnl Set up the Atari LDG (shared object loader)
2143+CheckAtariLdg()
2144+{
2145+ AC_ARG_ENABLE(atari-ldg,
2146+AC_HELP_STRING([--enable-atari-ldg], [use Atari LDG for shared object loading [[default=yes]]]),
2147+ , enable_atari_ldg=yes)
2148+ if test x$video_gem = xyes -a x$enable_atari_ldg = xyes; then
2149+ AC_CHECK_HEADER(ldg.h, have_ldg_hdr=yes)
2150+ AC_CHECK_LIB(ldg, ldg_open, have_ldg_lib=yes, have_ldg_lib=no, -lgem)
2151+ if test x$have_ldg_hdr = xyes -a x$have_ldg_lib = xyes; then
2152+ AC_DEFINE(SDL_LOADSO_LDG)
2153+ SOURCES="$SOURCES $srcdir/src/loadso/mint/*.c"
2154+ SDL_LIBS="$SDL_LIBS -lldg -lgem"
2155+ have_loadso=yes
2156+ fi
2157+ fi
2158+}
2159+
2160+dnl Check for the usbhid(3) library on *BSD
2161+CheckUSBHID()
2162+{
2163+ if test x$enable_joystick = xyes; then
2164+ AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
2165+ if test x$have_libusbhid = xyes; then
2166+ AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
2167+ AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
2168+ USB_LIBS="$USB_LIBS -lusbhid"
2169+ else
2170+ AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
2171+ AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
2172+ AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
2173+ fi
2174+
2175+ save_CFLAGS="$CFLAGS"
2176+ CFLAGS="$CFLAGS $USB_CFLAGS"
2177+
2178+ AC_MSG_CHECKING(for usbhid)
2179+ have_usbhid=no
2180+ AC_TRY_COMPILE([
2181+ #include <sys/types.h>
2182+ #if defined(HAVE_USB_H)
2183+ #include <usb.h>
2184+ #endif
2185+ #ifdef __DragonFly__
2186+ # include <bus/usb/usb.h>
2187+ # include <bus/usb/usbhid.h>
2188+ #else
2189+ # include <dev/usb/usb.h>
2190+ # include <dev/usb/usbhid.h>
2191+ #endif
2192+ #if defined(HAVE_USBHID_H)
2193+ #include <usbhid.h>
2194+ #elif defined(HAVE_LIBUSB_H)
2195+ #include <libusb.h>
2196+ #elif defined(HAVE_LIBUSBHID_H)
2197+ #include <libusbhid.h>
2198+ #endif
2199+ ],[
2200+ struct report_desc *repdesc;
2201+ struct usb_ctl_report *repbuf;
2202+ hid_kind_t hidkind;
2203+ ],[
2204+ have_usbhid=yes
2205+ ])
2206+ AC_MSG_RESULT($have_usbhid)
2207+
2208+ if test x$have_usbhid = xyes; then
2209+ AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
2210+ have_usbhid_ucr_data=no
2211+ AC_TRY_COMPILE([
2212+ #include <sys/types.h>
2213+ #if defined(HAVE_USB_H)
2214+ #include <usb.h>
2215+ #endif
2216+ #ifdef __DragonFly__
2217+ # include <bus/usb/usb.h>
2218+ # include <bus/usb/usbhid.h>
2219+ #else
2220+ # include <dev/usb/usb.h>
2221+ # include <dev/usb/usbhid.h>
2222+ #endif
2223+ #if defined(HAVE_USBHID_H)
2224+ #include <usbhid.h>
2225+ #elif defined(HAVE_LIBUSB_H)
2226+ #include <libusb.h>
2227+ #elif defined(HAVE_LIBUSBHID_H)
2228+ #include <libusbhid.h>
2229+ #endif
2230+ ],[
2231+ struct usb_ctl_report buf;
2232+ if (buf.ucr_data) { }
2233+ ],[
2234+ have_usbhid_ucr_data=yes
2235+ ])
2236+ if test x$have_usbhid_ucr_data = xyes; then
2237+ USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
2238+ fi
2239+ AC_MSG_RESULT($have_usbhid_ucr_data)
2240+
2241+ AC_MSG_CHECKING(for new usbhid API)
2242+ have_usbhid_new=no
2243+ AC_TRY_COMPILE([
2244+ #include <sys/types.h>
2245+ #if defined(HAVE_USB_H)
2246+ #include <usb.h>
2247+ #endif
2248+ #ifdef __DragonFly__
2249+ #include <bus/usb/usb.h>
2250+ #include <bus/usb/usbhid.h>
2251+ #else
2252+ #include <dev/usb/usb.h>
2253+ #include <dev/usb/usbhid.h>
2254+ #endif
2255+ #if defined(HAVE_USBHID_H)
2256+ #include <usbhid.h>
2257+ #elif defined(HAVE_LIBUSB_H)
2258+ #include <libusb.h>
2259+ #elif defined(HAVE_LIBUSBHID_H)
2260+ #include <libusbhid.h>
2261+ #endif
2262+ ],[
2263+ report_desc_t d;
2264+ hid_start_parse(d, 1, 1);
2265+ ],[
2266+ have_usbhid_new=yes
2267+ ])
2268+ if test x$have_usbhid_new = xyes; then
2269+ USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
2270+ fi
2271+ AC_MSG_RESULT($have_usbhid_new)
2272+
2273+ AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
2274+ have_machine_joystick=no
2275+ AC_TRY_COMPILE([
2276+ #include <machine/joystick.h>
2277+ ],[
2278+ struct joystick t;
2279+ ],[
2280+ have_machine_joystick=yes
2281+ ])
2282+ if test x$have_machine_joystick = xyes; then
2283+ AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H)
2284+ fi
2285+ AC_MSG_RESULT($have_machine_joystick)
2286+
2287+ AC_DEFINE(SDL_JOYSTICK_USBHID)
2288+ SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
2289+ EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
2290+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
2291+ have_joystick=yes
2292+ fi
2293+ CFLAGS="$save_CFLAGS"
2294+ fi
2295+}
2296+
2297+dnl Check for clock_gettime()
2298+CheckClockGettime()
2299+{
2300+ AC_ARG_ENABLE(clock_gettime,
2301+AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=no]]]),
2302+ , enable_clock_gettime=no)
2303+ if test x$enable_clock_gettime = xyes; then
2304+ AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
2305+ if test x$have_clock_gettime = xyes; then
2306+ AC_DEFINE(HAVE_CLOCK_GETTIME)
2307+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
2308+ fi
2309+ fi
2310+}
2311+
2312+dnl Check for a valid linux/version.h
2313+CheckLinuxVersion()
2314+{
2315+ AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
2316+ if test x$have_linux_version_h = xyes; then
2317+ EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
2318+ fi
2319+}
2320+
2321+dnl Check if we want to use RPATH
2322+CheckRPATH()
2323+{
2324+ AC_ARG_ENABLE(rpath,
2325+AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
2326+ , enable_rpath=yes)
2327+}
2328+
2329+dnl Set up the configuration based on the host platform!
2330+case "$host" in
2331+ arm-*-elf*) # FIXME: Can we get more specific for iPodLinux?
2332+ ARCH=linux
2333+ CheckDummyVideo
2334+ CheckIPod
2335+ # Set up files for the timer library
2336+ if test x$enable_timers = xyes; then
2337+ AC_DEFINE(SDL_TIMER_UNIX)
2338+ SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
2339+ have_timers=yes
2340+ fi
2341+ ;;
2342+ *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*)
2343+ case "$host" in
2344+ *-*-linux*) ARCH=linux ;;
2345+ *-*-uclinux*) ARCH=linux ;;
2346+ *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;;
2347+ *-*-knetbsd*-gnu) ARCH=knetbsd-gnu ;;
2348+ *-*-kopenbsd*-gnu) ARCH=kopenbsd-gnu ;;
2349+ *-*-gnu*) ARCH=gnu ;; # must be last of the gnu variants
2350+ *-*-bsdi*) ARCH=bsdi ;;
2351+ *-*-freebsd*) ARCH=freebsd ;;
2352+ *-*-dragonfly*) ARCH=freebsd ;;
2353+ *-*-netbsd*) ARCH=netbsd ;;
2354+ *-*-openbsd*) ARCH=openbsd ;;
2355+ *-*-sysv5*) ARCH=sysv5 ;;
2356+ *-*-solaris*) ARCH=solaris ;;
2357+ *-*-hpux*) ARCH=hpux ;;
2358+ *-*-irix*) ARCH=irix ;;
2359+ *-*-aix*) ARCH=aix ;;
2360+ *-*-osf*) ARCH=osf ;;
2361+ esac
2362+ CheckVisibilityHidden
2363+ CheckDummyVideo
2364+ CheckDiskAudio
2365+ CheckDummyAudio
2366+ CheckDLOPEN
2367+ CheckNASM
2368+ CheckAltivec
2369+ CheckOSS
2370+ CheckDMEDIA
2371+ CheckMME
2372+ CheckALSA
2373+ CheckARTSC
2374+ CheckESD
2375+ CheckPulseAudio
2376+ CheckNAS
2377+ CheckX11
2378+ CheckNANOX
2379+ CheckFBCON
2380+ CheckDirectFB
2381+ CheckPS2GS
2382+ CheckPS3
2383+ CheckGGI
2384+ CheckSVGA
2385+ CheckVGL
2386+ CheckWscons
2387+ CheckAAlib
2388+ CheckCaca
2389+ CheckQtopia
2390+ CheckPicoGUI
2391+ CheckOpenGLX11
2392+ CheckInputEvents
2393+ CheckTslib
2394+ CheckUSBHID
2395+ CheckPTHREAD
2396+ CheckClockGettime
2397+ CheckLinuxVersion
2398+ CheckRPATH
2399+ # Set up files for the audio library
2400+ if test x$enable_audio = xyes; then
2401+ case $ARCH in
2402+ sysv5|solaris|hpux)
2403+ AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
2404+ SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
2405+ have_audio=yes
2406+ ;;
2407+ netbsd|openbsd)
2408+ AC_DEFINE(SDL_AUDIO_DRIVER_BSD)
2409+ SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
2410+ have_audio=yes
2411+ ;;
2412+ aix)
2413+ AC_DEFINE(SDL_AUDIO_DRIVER_PAUD)
2414+ SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
2415+ have_audio=yes
2416+ ;;
2417+ esac
2418+ fi
2419+ # Set up files for the joystick library
2420+ if test x$enable_joystick = xyes; then
2421+ case $ARCH in
2422+ linux)
2423+ AC_DEFINE(SDL_JOYSTICK_LINUX)
2424+ SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
2425+ have_joystick=yes
2426+ ;;
2427+ esac
2428+ fi
2429+ # Set up files for the cdrom library
2430+ if test x$enable_cdrom = xyes; then
2431+ case $ARCH in
2432+ linux|solaris)
2433+ AC_DEFINE(SDL_CDROM_LINUX)
2434+ SOURCES="$SOURCES $srcdir/src/cdrom/linux/*.c"
2435+ have_cdrom=yes
2436+ ;;
2437+ *freebsd*)
2438+ AC_DEFINE(SDL_CDROM_FREEBSD)
2439+ SOURCES="$SOURCES $srcdir/src/cdrom/freebsd/*.c"
2440+ have_cdrom=yes
2441+ ;;
2442+ *openbsd*|*netbsd*)
2443+ AC_DEFINE(SDL_CDROM_OPENBSD)
2444+ SOURCES="$SOURCES $srcdir/src/cdrom/openbsd/*.c"
2445+ have_cdrom=yes
2446+ ;;
2447+ bsdi)
2448+ AC_DEFINE(SDL_CDROM_BSDI)
2449+ SOURCES="$SOURCES $srcdir/src/cdrom/bsdi/*.c"
2450+ have_cdrom=yes
2451+ ;;
2452+ aix)
2453+ AC_DEFINE(SDL_CDROM_AIX)
2454+ SOURCES="$SOURCES $srcdir/src/cdrom/aix/*.c"
2455+ have_cdrom=yes
2456+ ;;
2457+ osf)
2458+ AC_DEFINE(SDL_CDROM_OSF)
2459+ SOURCES="$SOURCES $srcdir/src/cdrom/osf/*.c"
2460+ have_cdrom=yes
2461+ ;;
2462+ esac
2463+ fi
2464+ # Set up files for the thread library
2465+ if test x$enable_threads = xyes -a x$use_pthreads != xyes -a x$use_pth != xyes -a x$ARCH = xirix; then
2466+ AC_DEFINE(SDL_THREAD_SPROC)
2467+ SOURCES="$SOURCES $srcdir/src/thread/irix/*.c"
2468+ SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
2469+ SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
2470+ have_threads=yes
2471+ fi
2472+ # Set up files for the timer library
2473+ if test x$enable_timers = xyes; then
2474+ AC_DEFINE(SDL_TIMER_UNIX)
2475+ SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
2476+ have_timers=yes
2477+ fi
2478+ ;;
2479+ *-*-qnx*)
2480+ ARCH=qnx
2481+ CheckDummyVideo
2482+ CheckDiskAudio
2483+ CheckDummyAudio
2484+ # CheckNASM
2485+ CheckDLOPEN
2486+ CheckNAS
2487+ CheckPHOTON
2488+ CheckX11
2489+ CheckOpenGLX11
2490+ CheckPTHREAD
2491+ # Set up files for the audio library
2492+ if test x$enable_audio = xyes; then
2493+ AC_DEFINE(SDL_AUDIO_DRIVER_QNXNTO)
2494+ SOURCES="$SOURCES $srcdir/src/audio/nto/*.c"
2495+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
2496+ have_audio=yes
2497+ fi
2498+ # Set up files for the cdrom library
2499+ if test x$enable_cdrom = xyes; then
2500+ AC_DEFINE(SDL_CDROM_QNX)
2501+ SOURCES="$SOURCES $srcdir/src/cdrom/qnx/*.c"
2502+ have_cdrom=yes
2503+ fi
2504+ # Set up files for the timer library
2505+ if test x$enable_timers = xyes; then
2506+ AC_DEFINE(SDL_TIMER_UNIX)
2507+ SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
2508+ have_timers=yes
2509+ fi
2510+ ;;
2511+ *-*-cygwin* | *-*-mingw32*)
2512+ ARCH=win32
2513+ if test "$build" != "$host"; then # cross-compiling
2514+ # Default cross-compile location
2515+ ac_default_prefix=/usr/local/cross-tools/i386-mingw32
2516+ else
2517+ # Look for the location of the tools and install there
2518+ if test "$BUILD_PREFIX" != ""; then
2519+ ac_default_prefix=$BUILD_PREFIX
2520+ fi
2521+ fi
2522+ CheckDummyVideo
2523+ CheckDiskAudio
2524+ CheckDummyAudio
2525+ CheckWIN32
2526+ CheckWIN32GL
2527+ CheckDIRECTX
2528+ CheckNASM
2529+ # Set up files for the audio library
2530+ if test x$enable_audio = xyes; then
2531+ AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
2532+ SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
2533+ if test x$have_directx = xyes; then
2534+ AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
2535+ SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
2536+ fi
2537+ have_audio=yes
2538+ fi
2539+ # Set up files for the joystick library
2540+ if test x$enable_joystick = xyes; then
2541+ AC_DEFINE(SDL_JOYSTICK_WINMM)
2542+ SOURCES="$SOURCES $srcdir/src/joystick/win32/*.c"
2543+ have_joystick=yes
2544+ fi
2545+ # Set up files for the cdrom library
2546+ if test x$enable_cdrom = xyes; then
2547+ AC_DEFINE(SDL_CDROM_WIN32)
2548+ SOURCES="$SOURCES $srcdir/src/cdrom/win32/*.c"
2549+ have_cdrom=yes
2550+ fi
2551+ # Set up files for the thread library
2552+ if test x$enable_threads = xyes; then
2553+ AC_DEFINE(SDL_THREAD_WIN32)
2554+ SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
2555+ SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
2556+ SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
2557+ SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
2558+ have_threads=yes
2559+ fi
2560+ # Set up files for the timer library
2561+ if test x$enable_timers = xyes; then
2562+ AC_DEFINE(SDL_TIMER_WIN32)
2563+ SOURCES="$SOURCES $srcdir/src/timer/win32/*.c"
2564+ have_timers=yes
2565+ fi
2566+ # Set up files for the shared object loading library
2567+ if test x$enable_loadso = xyes; then
2568+ AC_DEFINE(SDL_LOADSO_WIN32)
2569+ SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
2570+ have_loadso=yes
2571+ fi
2572+ # Set up the system libraries we need
2573+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm"
2574+ if test x$have_directx = xyes; then
2575+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldxguid"
2576+ fi
2577+ # The Win32 platform requires special setup
2578+ SOURCES="$SOURCES $srcdir/src/main/win32/*.rc"
2579+ SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
2580+ SDLMAIN_LDFLAGS="-static"
2581+ SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
2582+ SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
2583+ ;;
2584+ *-wince*)
2585+ ARCH=win32
2586+ CheckDummyVideo
2587+ CheckDiskAudio
2588+ CheckDummyAudio
2589+ CheckWIN32
2590+ CheckNASM
2591+ SOURCES="$SOURCES $srcdir/src/video/gapi/*.c"
2592+ EXTRA_CFLAGS="$EXTRA_CFLAGS -D_WIN32_WCE=0x420"
2593+ if test x$enable_audio = xyes; then
2594+ AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
2595+ SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
2596+ have_audio=yes
2597+ fi
2598+ # Set up files for the thread library
2599+ if test x$enable_threads = xyes; then
2600+ AC_DEFINE(SDL_THREAD_WIN32)
2601+ SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
2602+ SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
2603+ SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
2604+ SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
2605+ have_threads=yes
2606+ fi
2607+ # Set up files for the timer library
2608+ if test x$enable_timers = xyes; then
2609+ AC_DEFINE(SDL_TIMER_WINCE)
2610+ SOURCES="$SOURCES $srcdir/src/timer/wince/*.c"
2611+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lmmtimer"
2612+ have_timers=yes
2613+ fi
2614+ # Set up files for the shared object loading library
2615+ if test x$enable_loadso = xyes; then
2616+ AC_DEFINE(SDL_LOADSO_WIN32)
2617+ SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
2618+ have_loadso=yes
2619+ fi
2620+ # Set up the system libraries we need
2621+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl"
2622+ # The Win32 platform requires special setup
2623+ SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
2624+ SDLMAIN_LDFLAGS="-static"
2625+ SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
2626+ SDL_LIBS="-lSDLmain $SDL_LIBS"
2627+ ;;
2628+ *-*-beos* | *-*-haiku*)
2629+ ARCH=beos
2630+ ac_default_prefix=/boot/develop/tools/gnupro
2631+ CheckDummyVideo
2632+ CheckDiskAudio
2633+ CheckDummyAudio
2634+ CheckNASM
2635+ CheckBWINDOW
2636+ CheckBeGL
2637+ # Set up files for the audio library
2638+ if test x$enable_audio = xyes; then
2639+ AC_DEFINE(SDL_AUDIO_DRIVER_BAUDIO)
2640+ SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
2641+ have_audio=yes
2642+ fi
2643+ # Set up files for the joystick library
2644+ if test x$enable_joystick = xyes; then
2645+ AC_DEFINE(SDL_JOYSTICK_BEOS)
2646+ SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
2647+ have_joystick=yes
2648+ fi
2649+ # Set up files for the cdrom library
2650+ if test x$enable_cdrom = xyes; then
2651+ AC_DEFINE(SDL_CDROM_BEOS)
2652+ SOURCES="$SOURCES $srcdir/src/cdrom/beos/*.cc"
2653+ have_cdrom=yes
2654+ fi
2655+ # Set up files for the thread library
2656+ if test x$enable_threads = xyes; then
2657+ AC_DEFINE(SDL_THREAD_BEOS)
2658+ SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
2659+ SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
2660+ SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
2661+ have_threads=yes
2662+ fi
2663+ # Set up files for the timer library
2664+ if test x$enable_timers = xyes; then
2665+ AC_DEFINE(SDL_TIMER_BEOS)
2666+ SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
2667+ have_timers=yes
2668+ fi
2669+ # Set up files for the shared object loading library
2670+ if test x$enable_loadso = xyes; then
2671+ case "$host" in
2672+ *-*-beos*)
2673+ AC_DEFINE(SDL_LOADSO_BEOS)
2674+ SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
2675+ ;;
2676+ *-*-haiku*)
2677+ AC_DEFINE(SDL_LOADSO_DLOPEN)
2678+ SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
2679+ ;;
2680+ esac
2681+ have_loadso=yes
2682+ fi
2683+ # The BeOS platform requires special setup.
2684+ SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
2685+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
2686+ ;;
2687+ *-*-darwin* )
2688+ # This could be either full "Mac OS X", or plain "Darwin" which is
2689+ # just the OS X kernel sans upper layers like Carbon and Cocoa.
2690+ # Next line is broken, and a few files below require Mac OS X (full)
2691+ ARCH=macosx
2692+
2693+ # Mac OS X builds with both the Carbon and OSX APIs at the moment
2694+ EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
2695+ EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
2696+
2697+ # HACK: Reset EXTRA_LDFLAGS; the only thing it contains at this point
2698+ # is -lm which is not needed under Mac OS X. But for some reasons it
2699+ # also tends to contain spurious -L switches, which we don't want to
2700+ # use here or in sdl-config. Hence we reset it.
2701+ EXTRA_LDFLAGS=""
2702+
2703+ CheckVisibilityHidden
2704+ CheckDummyVideo
2705+ CheckDiskAudio
2706+ CheckDummyAudio
2707+ CheckDLOPEN
2708+ CheckNASM
2709+
2710+ # Set up files for the shared object loading library
2711+ # (this needs to be done before the dynamic X11 check)
2712+ if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
2713+ AC_DEFINE(SDL_LOADSO_DLCOMPAT)
2714+ SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
2715+ have_loadso=yes
2716+ fi
2717+
2718+ CheckCOCOA
2719+ CheckCARBON
2720+ CheckX11
2721+ CheckMacGL
2722+ CheckOpenGLX11
2723+ CheckPTHREAD
2724+ CheckAltivec
2725+
2726+ # Need this or things might misbuild on a G3.
2727+ EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
2728+
2729+ # Set up files for the audio library
2730+ if test x$enable_audio = xyes; then
2731+ AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO)
2732+ SOURCES="$SOURCES $srcdir/src/audio/macosx/*.c"
2733+ have_audio=yes
2734+ fi
2735+ # Set up files for the joystick library
2736+ if test x$enable_joystick = xyes; then
2737+ AC_DEFINE(SDL_JOYSTICK_IOKIT)
2738+ SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
2739+ have_joystick=yes
2740+ need_iokit_framework=yes
2741+ fi
2742+ # Set up files for the cdrom library
2743+ if test x$enable_cdrom = xyes; then
2744+ AC_DEFINE(SDL_CDROM_MACOSX)
2745+ SOURCES="$SOURCES $srcdir/src/cdrom/macosx/*.c"
2746+ have_cdrom=yes
2747+ fi
2748+ # Set up files for the timer library
2749+ if test x$enable_timers = xyes; then
2750+ AC_DEFINE(SDL_TIMER_UNIX)
2751+ SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
2752+ have_timers=yes
2753+ fi
2754+ # The Mac OS X platform requires special setup.
2755+ SDLMAIN_SOURCES="$srcdir/src/main/macosx/*.m"
2756+ SDLMAIN_LDFLAGS="-static"
2757+ EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
2758+ SDL_LIBS="-lSDLmain $SDL_LIBS"
2759+ if test x$enable_video_cocoa = xyes; then
2760+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
2761+ need_iokit_framework=yes
2762+ fi
2763+ if test x$enable_video_carbon = xyes -o x$enable_video_cocoa = xyes; then
2764+ # The Cocoa backend still needs Carbon
2765+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ApplicationServices"
2766+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
2767+ fi
2768+ # If either the audio or CD driver is used, add the AudioUnit framework
2769+ if test x$enable_audio = xyes -o x$enable_cdrom = xyes; then
2770+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
2771+ fi
2772+ # Some subsystems reference IOKit...
2773+ if test x$need_iokit_framework = xyes; then
2774+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
2775+ fi
2776+ ;;
2777+ *-*-mint*)
2778+ ARCH=mint
2779+ CheckDummyVideo
2780+ CheckDiskAudio
2781+ CheckDummyAudio
2782+ CheckAtariBiosEvent
2783+ CheckAtariXbiosVideo
2784+ CheckAtariGemVideo
2785+ CheckAtariAudio
2786+ CheckAtariLdg
2787+ CheckAtariOSMesa
2788+ CheckPTH
2789+ # Set up files for the audio library
2790+ if test x$enable_threads = xyes -a x$enable_pth = xyes; then
2791+ if test x$enable_audio = xyes; then
2792+ AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
2793+ SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
2794+ have_audio=yes
2795+ fi
2796+ fi
2797+ # Set up files for the joystick library
2798+ if test x$enable_joystick = xyes; then
2799+ AC_DEFINE(SDL_JOYSTICK_MINT)
2800+ SOURCES="$SOURCES $srcdir/src/joystick/mint/*.c"
2801+ have_joystick=yes
2802+ fi
2803+ # Set up files for the cdrom library
2804+ if test x$enable_cdrom = xyes; then
2805+ AC_DEFINE(SDL_CDROM_MINT)
2806+ SOURCES="$SOURCES $srcdir/src/cdrom/mint/*.c"
2807+ have_cdrom=yes
2808+ fi
2809+ # Set up files for the timer library
2810+ if test x$enable_timers = xyes; then
2811+ if test x$enable_threads = xyes -a x$enable_pth = xyes; then
2812+ AC_DEFINE(SDL_TIMER_UNIX)
2813+ SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
2814+ else
2815+ AC_DEFINE(SDL_TIMER_MINT)
2816+ SOURCES="$SOURCES $srcdir/src/timer/mint/*.c"
2817+ SOURCES="$SOURCES $srcdir/src/timer/mint/*.S"
2818+ fi
2819+ have_timers=yes
2820+ fi
2821+ ;;
2822+ *-riscos)
2823+ ARCH=riscos
2824+ CheckOSS
2825+ CheckPTHREAD
2826+ # Set up files for the video library
2827+ if test x$enable_video = xyes; then
2828+ AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
2829+ SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
2830+ SOURCES="$SOURCES $srcdir/src/video/riscos/*.S"
2831+ have_video=yes
2832+ fi
2833+ # Set up files for the joystick library
2834+ if test x$enable_joystick = xyes; then
2835+ AC_DEFINE(SDL_JOYSTICK_RISCOS)
2836+ SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
2837+ have_joystick=yes
2838+ fi
2839+ # Set up files for the timer library
2840+ if test x$enable_timers = xyes; then
2841+ AC_DEFINE(SDL_TIMER_RISCOS)
2842+ SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
2843+ have_timers=yes
2844+ fi
2845+ # The RISC OS platform requires special setup.
2846+ EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
2847+ ;;
2848+ *)
2849+ AC_MSG_ERROR([
2850+*** Unsupported host: Please add to configure.in
2851+ ])
2852+ ;;
2853+esac
2854+
2855+dnl Do this on all platforms, after everything else.
2856+CheckWarnAll
2857+
2858+# Verify that we have all the platform specific files we need
2859+
2860+if test x$enable_joystick = xyes; then
2861+ if test x$have_joystick != xyes; then
2862+ # Wants joystick subsystem, but doesn't have a platform-specific backend...
2863+ AC_DEFINE(SDL_JOYSTICK_DUMMY)
2864+ SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
2865+ fi
2866+fi
2867+if test x$have_cdrom != xyes; then
2868+ if test x$enable_cdrom = xyes; then
2869+ AC_DEFINE(SDL_CDROM_DISABLED)
2870+ fi
2871+ SOURCES="$SOURCES $srcdir/src/cdrom/dummy/*.c"
2872+fi
2873+if test x$have_threads != xyes; then
2874+ if test x$enable_threads = xyes; then
2875+ AC_DEFINE(SDL_THREADS_DISABLED)
2876+ fi
2877+ SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
2878+fi
2879+if test x$have_timers != xyes; then
2880+ if test x$enable_timers = xyes; then
2881+ AC_DEFINE(SDL_TIMERS_DISABLED)
2882+ fi
2883+ SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
2884+fi
2885+if test x$have_loadso != xyes; then
2886+ if test x$enable_loadso = xyes; then
2887+ AC_DEFINE(SDL_LOADSO_DISABLED)
2888+ fi
2889+ SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
2890+fi
2891+if test x$SDLMAIN_SOURCES = x; then
2892+ SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
2893+ SDLMAIN_LDFLAGS="-static"
2894+fi
2895+
2896+OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.asm,$(objects)/\1.lo,g'`
2897+OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
2898+OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
2899+OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
2900+OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'`
2901+OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.lo,g'`
2902+
2903+SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
2904+SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
2905+SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
2906+
2907+# Set runtime shared library paths as needed
2908+
2909+if test "x$enable_rpath" = "xyes"; then
2910+ if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
2911+ SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
2912+ fi
2913+ if test $ARCH = solaris; then
2914+ SDL_RLD_FLAGS="-R\${libdir}"
2915+ fi
2916+else
2917+ SDL_RLD_FLAGS=""
2918+fi
2919+
2920+case "$ARCH" in
2921+ macosx)
2922+ if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
2923+ SDL_LIBS="$SDL_LIBS -Wl,-framework,Cocoa"
2924+ fi
2925+ if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
2926+ SDL_LIBS="$SDL_LIBS -Wl,-framework,Carbon"
2927+ fi
2928+ # Evil hack to allow static linking on Mac OS X
2929+ SDL_STATIC_LIBS="\${libdir}/libSDLmain.a \${libdir}/libSDL.a $EXTRA_LDFLAGS"
2930+ ;;
2931+ *)
2932+ SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
2933+ ;;
2934+esac
2935+
2936+dnl Expand the cflags and libraries needed by apps using SDL
2937+AC_SUBST(SDL_CFLAGS)
2938+AC_SUBST(SDL_LIBS)
2939+AC_SUBST(SDL_STATIC_LIBS)
2940+AC_SUBST(SDL_RLD_FLAGS)
2941+if test x$enable_shared = xyes; then
2942+ ENABLE_SHARED_TRUE=
2943+ ENABLE_SHARED_FALSE="#"
2944+else
2945+ ENABLE_SHARED_TRUE="#"
2946+ ENABLE_SHARED_FALSE=
2947+fi
2948+if test x$enable_static = xyes; then
2949+ ENABLE_STATIC_TRUE=
2950+ ENABLE_STATIC_FALSE="#"
2951+else
2952+ ENABLE_STATIC_TRUE="#"
2953+ ENABLE_STATIC_FALSE=
2954+fi
2955+AC_SUBST(ENABLE_SHARED_TRUE)
2956+AC_SUBST(ENABLE_SHARED_FALSE)
2957+AC_SUBST(ENABLE_STATIC_TRUE)
2958+AC_SUBST(ENABLE_STATIC_FALSE)
2959+
2960+dnl Expand the sources and objects needed to build the library
2961+AC_SUBST(ac_aux_dir)
2962+AC_SUBST(INCLUDE)
2963+AC_SUBST(SOURCES)
2964+AC_SUBST(OBJECTS)
2965+AC_SUBST(SDLMAIN_SOURCES)
2966+AC_SUBST(SDLMAIN_OBJECTS)
2967+AC_SUBST(SDLMAIN_LDFLAGS)
2968+AC_SUBST(BUILD_CFLAGS)
2969+AC_SUBST(EXTRA_CFLAGS)
2970+AC_SUBST(BUILD_LDFLAGS)
2971+AC_SUBST(EXTRA_LDFLAGS)
2972+AC_SUBST(WINDRES)
2973+
2974+AC_OUTPUT([
2975+ Makefile sdl-config SDL.spec SDL.qpg sdl.pc
2976+], [
2977+ : >build-deps
2978+ if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
2979+])
2980
2981=== added directory '.pc/mir-support.diff/include'
2982=== added file '.pc/mir-support.diff/include/SDL_config.h.in'
2983--- .pc/mir-support.diff/include/SDL_config.h.in 1970-01-01 00:00:00 +0000
2984+++ .pc/mir-support.diff/include/SDL_config.h.in 2015-06-01 21:48:23 +0000
2985@@ -0,0 +1,312 @@
2986+/*
2987+ SDL - Simple DirectMedia Layer
2988+ Copyright (C) 1997-2012 Sam Lantinga
2989+
2990+ This library is free software; you can redistribute it and/or
2991+ modify it under the terms of the GNU Lesser General Public
2992+ License as published by the Free Software Foundation; either
2993+ version 2.1 of the License, or (at your option) any later version.
2994+
2995+ This library is distributed in the hope that it will be useful,
2996+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2997+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2998+ Lesser General Public License for more details.
2999+
3000+ You should have received a copy of the GNU Lesser General Public
3001+ License along with this library; if not, write to the Free Software
3002+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3003+
3004+ Sam Lantinga
3005+ slouken@libsdl.org
3006+*/
3007+
3008+#ifndef _SDL_config_h
3009+#define _SDL_config_h
3010+
3011+/* This is a set of defines to configure the SDL features */
3012+
3013+/* General platform specific identifiers */
3014+#include "SDL_platform.h"
3015+
3016+/* Make sure that this isn't included by Visual C++ */
3017+#ifdef _MSC_VER
3018+#error You should copy include/SDL_config.h.default to include/SDL_config.h
3019+#endif
3020+
3021+/* C language features */
3022+#undef const
3023+#undef inline
3024+#undef volatile
3025+
3026+/* C datatypes */
3027+#undef size_t
3028+#undef int8_t
3029+#undef uint8_t
3030+#undef int16_t
3031+#undef uint16_t
3032+#undef int32_t
3033+#undef uint32_t
3034+#undef int64_t
3035+#undef uint64_t
3036+#undef uintptr_t
3037+#undef SDL_HAS_64BIT_TYPE
3038+
3039+/* Endianness */
3040+#undef SDL_BYTEORDER
3041+
3042+/* Comment this if you want to build without any C library requirements */
3043+#undef HAVE_LIBC
3044+#if HAVE_LIBC
3045+
3046+/* Useful headers */
3047+#undef HAVE_ALLOCA_H
3048+#undef HAVE_SYS_TYPES_H
3049+#undef HAVE_STDIO_H
3050+#undef STDC_HEADERS
3051+#undef HAVE_STDLIB_H
3052+#undef HAVE_STDARG_H
3053+#undef HAVE_MALLOC_H
3054+#undef HAVE_MEMORY_H
3055+#undef HAVE_STRING_H
3056+#undef HAVE_STRINGS_H
3057+#undef HAVE_INTTYPES_H
3058+#undef HAVE_STDINT_H
3059+#undef HAVE_CTYPE_H
3060+#undef HAVE_MATH_H
3061+#undef HAVE_ICONV_H
3062+#undef HAVE_SIGNAL_H
3063+#undef HAVE_ALTIVEC_H
3064+
3065+/* C library functions */
3066+#undef HAVE_MALLOC
3067+#undef HAVE_CALLOC
3068+#undef HAVE_REALLOC
3069+#undef HAVE_FREE
3070+#undef HAVE_ALLOCA
3071+#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */
3072+#undef HAVE_GETENV
3073+#undef HAVE_PUTENV
3074+#undef HAVE_UNSETENV
3075+#endif
3076+#undef HAVE_QSORT
3077+#undef HAVE_ABS
3078+#undef HAVE_BCOPY
3079+#undef HAVE_MEMSET
3080+#undef HAVE_MEMCPY
3081+#undef HAVE_MEMMOVE
3082+#undef HAVE_MEMCMP
3083+#undef HAVE_STRLEN
3084+#undef HAVE_STRLCPY
3085+#undef HAVE_STRLCAT
3086+#undef HAVE_STRDUP
3087+#undef HAVE__STRREV
3088+#undef HAVE__STRUPR
3089+#undef HAVE__STRLWR
3090+#undef HAVE_INDEX
3091+#undef HAVE_RINDEX
3092+#undef HAVE_STRCHR
3093+#undef HAVE_STRRCHR
3094+#undef HAVE_STRSTR
3095+#undef HAVE_ITOA
3096+#undef HAVE__LTOA
3097+#undef HAVE__UITOA
3098+#undef HAVE__ULTOA
3099+#undef HAVE_STRTOL
3100+#undef HAVE_STRTOUL
3101+#undef HAVE__I64TOA
3102+#undef HAVE__UI64TOA
3103+#undef HAVE_STRTOLL
3104+#undef HAVE_STRTOULL
3105+#undef HAVE_STRTOD
3106+#undef HAVE_ATOI
3107+#undef HAVE_ATOF
3108+#undef HAVE_STRCMP
3109+#undef HAVE_STRNCMP
3110+#undef HAVE__STRICMP
3111+#undef HAVE_STRCASECMP
3112+#undef HAVE__STRNICMP
3113+#undef HAVE_STRNCASECMP
3114+#undef HAVE_SSCANF
3115+#undef HAVE_SNPRINTF
3116+#undef HAVE_VSNPRINTF
3117+#undef HAVE_ICONV
3118+#undef HAVE_SIGACTION
3119+#undef HAVE_SA_SIGACTION
3120+#undef HAVE_SETJMP
3121+#undef HAVE_NANOSLEEP
3122+#undef HAVE_CLOCK_GETTIME
3123+#undef HAVE_GETPAGESIZE
3124+#undef HAVE_MPROTECT
3125+#undef HAVE_SEM_TIMEDWAIT
3126+
3127+#else
3128+/* We may need some replacement for stdarg.h here */
3129+#include <stdarg.h>
3130+#endif /* HAVE_LIBC */
3131+
3132+/* Allow disabling of core subsystems */
3133+#undef SDL_AUDIO_DISABLED
3134+#undef SDL_CDROM_DISABLED
3135+#undef SDL_CPUINFO_DISABLED
3136+#undef SDL_EVENTS_DISABLED
3137+#undef SDL_FILE_DISABLED
3138+#undef SDL_JOYSTICK_DISABLED
3139+#undef SDL_LOADSO_DISABLED
3140+#undef SDL_THREADS_DISABLED
3141+#undef SDL_TIMERS_DISABLED
3142+#undef SDL_VIDEO_DISABLED
3143+
3144+/* Enable various audio drivers */
3145+#undef SDL_AUDIO_DRIVER_ALSA
3146+#undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
3147+#undef SDL_AUDIO_DRIVER_ARTS
3148+#undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
3149+#undef SDL_AUDIO_DRIVER_BAUDIO
3150+#undef SDL_AUDIO_DRIVER_BSD
3151+#undef SDL_AUDIO_DRIVER_COREAUDIO
3152+#undef SDL_AUDIO_DRIVER_DART
3153+#undef SDL_AUDIO_DRIVER_DC
3154+#undef SDL_AUDIO_DRIVER_DISK
3155+#undef SDL_AUDIO_DRIVER_DUMMY
3156+#undef SDL_AUDIO_DRIVER_DMEDIA
3157+#undef SDL_AUDIO_DRIVER_DSOUND
3158+#undef SDL_AUDIO_DRIVER_PULSE
3159+#undef SDL_AUDIO_DRIVER_PULSE_DYNAMIC
3160+#undef SDL_AUDIO_DRIVER_ESD
3161+#undef SDL_AUDIO_DRIVER_ESD_DYNAMIC
3162+#undef SDL_AUDIO_DRIVER_MINT
3163+#undef SDL_AUDIO_DRIVER_MMEAUDIO
3164+#undef SDL_AUDIO_DRIVER_NAS
3165+#undef SDL_AUDIO_DRIVER_NAS_DYNAMIC
3166+#undef SDL_AUDIO_DRIVER_OSS
3167+#undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H
3168+#undef SDL_AUDIO_DRIVER_PAUD
3169+#undef SDL_AUDIO_DRIVER_QNXNTO
3170+#undef SDL_AUDIO_DRIVER_SNDMGR
3171+#undef SDL_AUDIO_DRIVER_SUNAUDIO
3172+#undef SDL_AUDIO_DRIVER_WAVEOUT
3173+
3174+/* Enable various cdrom drivers */
3175+#undef SDL_CDROM_AIX
3176+#undef SDL_CDROM_BEOS
3177+#undef SDL_CDROM_BSDI
3178+#undef SDL_CDROM_DC
3179+#undef SDL_CDROM_DUMMY
3180+#undef SDL_CDROM_FREEBSD
3181+#undef SDL_CDROM_LINUX
3182+#undef SDL_CDROM_MACOS
3183+#undef SDL_CDROM_MACOSX
3184+#undef SDL_CDROM_MINT
3185+#undef SDL_CDROM_OPENBSD
3186+#undef SDL_CDROM_OS2
3187+#undef SDL_CDROM_OSF
3188+#undef SDL_CDROM_QNX
3189+#undef SDL_CDROM_WIN32
3190+
3191+/* Enable various input drivers */
3192+#undef SDL_INPUT_LINUXEV
3193+#undef SDL_INPUT_TSLIB
3194+#undef SDL_JOYSTICK_BEOS
3195+#undef SDL_JOYSTICK_DC
3196+#undef SDL_JOYSTICK_DUMMY
3197+#undef SDL_JOYSTICK_IOKIT
3198+#undef SDL_JOYSTICK_LINUX
3199+#undef SDL_JOYSTICK_MACOS
3200+#undef SDL_JOYSTICK_MINT
3201+#undef SDL_JOYSTICK_OS2
3202+#undef SDL_JOYSTICK_RISCOS
3203+#undef SDL_JOYSTICK_WINMM
3204+#undef SDL_JOYSTICK_USBHID
3205+#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
3206+
3207+/* Enable various shared object loading systems */
3208+#undef SDL_LOADSO_BEOS
3209+#undef SDL_LOADSO_DLCOMPAT
3210+#undef SDL_LOADSO_DLOPEN
3211+#undef SDL_LOADSO_DUMMY
3212+#undef SDL_LOADSO_LDG
3213+#undef SDL_LOADSO_MACOS
3214+#undef SDL_LOADSO_OS2
3215+#undef SDL_LOADSO_WIN32
3216+
3217+/* Enable various threading systems */
3218+#undef SDL_THREAD_BEOS
3219+#undef SDL_THREAD_DC
3220+#undef SDL_THREAD_OS2
3221+#undef SDL_THREAD_PTH
3222+#undef SDL_THREAD_PTHREAD
3223+#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
3224+#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
3225+#undef SDL_THREAD_SPROC
3226+#undef SDL_THREAD_WIN32
3227+
3228+/* Enable various timer systems */
3229+#undef SDL_TIMER_BEOS
3230+#undef SDL_TIMER_DC
3231+#undef SDL_TIMER_DUMMY
3232+#undef SDL_TIMER_MACOS
3233+#undef SDL_TIMER_MINT
3234+#undef SDL_TIMER_OS2
3235+#undef SDL_TIMER_RISCOS
3236+#undef SDL_TIMER_UNIX
3237+#undef SDL_TIMER_WIN32
3238+#undef SDL_TIMER_WINCE
3239+
3240+/* Enable various video drivers */
3241+#undef SDL_VIDEO_DRIVER_AALIB
3242+#undef SDL_VIDEO_DRIVER_BWINDOW
3243+#undef SDL_VIDEO_DRIVER_CACA
3244+#undef SDL_VIDEO_DRIVER_DC
3245+#undef SDL_VIDEO_DRIVER_DDRAW
3246+#undef SDL_VIDEO_DRIVER_DGA
3247+#undef SDL_VIDEO_DRIVER_DIRECTFB
3248+#undef SDL_VIDEO_DRIVER_DRAWSPROCKET
3249+#undef SDL_VIDEO_DRIVER_DUMMY
3250+#undef SDL_VIDEO_DRIVER_FBCON
3251+#undef SDL_VIDEO_DRIVER_GAPI
3252+#undef SDL_VIDEO_DRIVER_GEM
3253+#undef SDL_VIDEO_DRIVER_GGI
3254+#undef SDL_VIDEO_DRIVER_IPOD
3255+#undef SDL_VIDEO_DRIVER_NANOX
3256+#undef SDL_VIDEO_DRIVER_OS2FS
3257+#undef SDL_VIDEO_DRIVER_PHOTON
3258+#undef SDL_VIDEO_DRIVER_PICOGUI
3259+#undef SDL_VIDEO_DRIVER_PS2GS
3260+#undef SDL_VIDEO_DRIVER_PS3
3261+#undef SDL_VIDEO_DRIVER_QTOPIA
3262+#undef SDL_VIDEO_DRIVER_QUARTZ
3263+#undef SDL_VIDEO_DRIVER_RISCOS
3264+#undef SDL_VIDEO_DRIVER_SVGALIB
3265+#undef SDL_VIDEO_DRIVER_TOOLBOX
3266+#undef SDL_VIDEO_DRIVER_VGL
3267+#undef SDL_VIDEO_DRIVER_WINDIB
3268+#undef SDL_VIDEO_DRIVER_WSCONS
3269+#undef SDL_VIDEO_DRIVER_X11
3270+#undef SDL_VIDEO_DRIVER_X11_DGAMOUSE
3271+#undef SDL_VIDEO_DRIVER_X11_DYNAMIC
3272+#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
3273+#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
3274+#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
3275+#undef SDL_VIDEO_DRIVER_X11_VIDMODE
3276+#undef SDL_VIDEO_DRIVER_X11_XINERAMA
3277+#undef SDL_VIDEO_DRIVER_X11_XME
3278+#undef SDL_VIDEO_DRIVER_X11_XRANDR
3279+#undef SDL_VIDEO_DRIVER_X11_XV
3280+#undef SDL_VIDEO_DRIVER_XBIOS
3281+
3282+/* Enable OpenGL support */
3283+#undef SDL_VIDEO_OPENGL
3284+#undef SDL_VIDEO_OPENGL_GLX
3285+#undef SDL_VIDEO_OPENGL_WGL
3286+#undef SDL_VIDEO_OPENGL_OSMESA
3287+#undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
3288+
3289+/* Disable screensaver */
3290+#undef SDL_VIDEO_DISABLE_SCREENSAVER
3291+
3292+/* Enable assembly routines */
3293+#undef SDL_ASSEMBLY_ROUTINES
3294+#undef SDL_HERMES_BLITTERS
3295+#undef SDL_ALTIVEC_BLITTERS
3296+
3297+#endif /* _SDL_config_h */
3298
3299=== added directory '.pc/mir-support.diff/src'
3300=== added directory '.pc/mir-support.diff/src/video'
3301=== added file '.pc/mir-support.diff/src/video/SDL_sysvideo.h'
3302--- .pc/mir-support.diff/src/video/SDL_sysvideo.h 1970-01-01 00:00:00 +0000
3303+++ .pc/mir-support.diff/src/video/SDL_sysvideo.h 2015-06-01 21:48:23 +0000
3304@@ -0,0 +1,424 @@
3305+/*
3306+ SDL - Simple DirectMedia Layer
3307+ Copyright (C) 1997-2012 Sam Lantinga
3308+
3309+ This library is free software; you can redistribute it and/or
3310+ modify it under the terms of the GNU Lesser General Public
3311+ License as published by the Free Software Foundation; either
3312+ version 2.1 of the License, or (at your option) any later version.
3313+
3314+ This library is distributed in the hope that it will be useful,
3315+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3316+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3317+ Lesser General Public License for more details.
3318+
3319+ You should have received a copy of the GNU Lesser General Public
3320+ License along with this library; if not, write to the Free Software
3321+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3322+
3323+ Sam Lantinga
3324+ slouken@libsdl.org
3325+*/
3326+#include "SDL_config.h"
3327+
3328+#ifndef _SDL_sysvideo_h
3329+#define _SDL_sysvideo_h
3330+
3331+#include "SDL_mouse.h"
3332+#define SDL_PROTOTYPES_ONLY
3333+#include "SDL_syswm.h"
3334+#undef SDL_PROTOTYPES_ONLY
3335+
3336+/* This file prototypes the video driver implementation.
3337+ This is designed to be easily converted to C++ in the future.
3338+ */
3339+
3340+#if SDL_VIDEO_OPENGL
3341+#include "SDL_opengl.h"
3342+#endif /* SDL_VIDEO_OPENGL */
3343+
3344+/* The SDL video driver */
3345+typedef struct SDL_VideoDevice SDL_VideoDevice;
3346+
3347+/* Define the SDL video driver structure */
3348+#define _THIS SDL_VideoDevice *_this
3349+#ifndef _STATUS
3350+#define _STATUS SDL_status *status
3351+#endif
3352+struct SDL_VideoDevice {
3353+ /* * * */
3354+ /* The name of this video driver */
3355+ const char *name;
3356+
3357+ /* * * */
3358+ /* Initialization/Query functions */
3359+
3360+ /* Initialize the native video subsystem, filling 'vformat' with the
3361+ "best" display pixel format, returning 0 or -1 if there's an error.
3362+ */
3363+ int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
3364+
3365+ /* List the available video modes for the given pixel format, sorted
3366+ from largest to smallest.
3367+ */
3368+ SDL_Rect **(*ListModes)(_THIS, SDL_PixelFormat *format, Uint32 flags);
3369+
3370+ /* Set the requested video mode, returning a surface which will be
3371+ set to the SDL_VideoSurface. The width and height will already
3372+ be verified by ListModes(), and the video subsystem is free to
3373+ set the mode to a supported bit depth different from the one
3374+ specified -- the desired bpp will be emulated with a shadow
3375+ surface if necessary. If a new mode is returned, this function
3376+ should take care of cleaning up the current mode.
3377+ */
3378+ SDL_Surface *(*SetVideoMode)(_THIS, SDL_Surface *current,
3379+ int width, int height, int bpp, Uint32 flags);
3380+
3381+ /* Toggle the fullscreen mode */
3382+ int (*ToggleFullScreen)(_THIS, int on);
3383+
3384+ /* This is called after the video mode has been set, to get the
3385+ initial mouse state. It should queue events as necessary to
3386+ properly represent the current mouse focus and position.
3387+ */
3388+ void (*UpdateMouse)(_THIS);
3389+
3390+ /* Create a YUV video surface (possibly overlay) of the given
3391+ format. The hardware should be able to perform at least 2x
3392+ scaling on display.
3393+ */
3394+ SDL_Overlay *(*CreateYUVOverlay)(_THIS, int width, int height,
3395+ Uint32 format, SDL_Surface *display);
3396+
3397+ /* Sets the color entries { firstcolor .. (firstcolor+ncolors-1) }
3398+ of the physical palette to those in 'colors'. If the device is
3399+ using a software palette (SDL_HWPALETTE not set), then the
3400+ changes are reflected in the logical palette of the screen
3401+ as well.
3402+ The return value is 1 if all entries could be set properly
3403+ or 0 otherwise.
3404+ */
3405+ int (*SetColors)(_THIS, int firstcolor, int ncolors,
3406+ SDL_Color *colors);
3407+
3408+ /* This pointer should exist in the native video subsystem and should
3409+ point to an appropriate update function for the current video mode
3410+ */
3411+ void (*UpdateRects)(_THIS, int numrects, SDL_Rect *rects);
3412+
3413+ /* Reverse the effects VideoInit() -- called if VideoInit() fails
3414+ or if the application is shutting down the video subsystem.
3415+ */
3416+ void (*VideoQuit)(_THIS);
3417+
3418+ /* * * */
3419+ /* Hardware acceleration functions */
3420+
3421+ /* Information about the video hardware */
3422+ SDL_VideoInfo info;
3423+
3424+ /* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
3425+ SDL_PixelFormat* displayformatalphapixel;
3426+
3427+ /* Allocates a surface in video memory */
3428+ int (*AllocHWSurface)(_THIS, SDL_Surface *surface);
3429+
3430+ /* Sets the hardware accelerated blit function, if any, based
3431+ on the current flags of the surface (colorkey, alpha, etc.)
3432+ */
3433+ int (*CheckHWBlit)(_THIS, SDL_Surface *src, SDL_Surface *dst);
3434+
3435+ /* Fills a surface rectangle with the given color */
3436+ int (*FillHWRect)(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color);
3437+
3438+ /* Sets video mem colorkey and accelerated blit function */
3439+ int (*SetHWColorKey)(_THIS, SDL_Surface *surface, Uint32 key);
3440+
3441+ /* Sets per surface hardware alpha value */
3442+ int (*SetHWAlpha)(_THIS, SDL_Surface *surface, Uint8 value);
3443+
3444+ /* Returns a readable/writable surface */
3445+ int (*LockHWSurface)(_THIS, SDL_Surface *surface);
3446+ void (*UnlockHWSurface)(_THIS, SDL_Surface *surface);
3447+
3448+ /* Performs hardware flipping */
3449+ int (*FlipHWSurface)(_THIS, SDL_Surface *surface);
3450+
3451+ /* Frees a previously allocated video surface */
3452+ void (*FreeHWSurface)(_THIS, SDL_Surface *surface);
3453+
3454+ /* * * */
3455+ /* Gamma support */
3456+
3457+ Uint16 *gamma;
3458+
3459+ /* Set the gamma correction directly (emulated with gamma ramps) */
3460+ int (*SetGamma)(_THIS, float red, float green, float blue);
3461+
3462+ /* Get the gamma correction directly (emulated with gamma ramps) */
3463+ int (*GetGamma)(_THIS, float *red, float *green, float *blue);
3464+
3465+ /* Set the gamma ramp */
3466+ int (*SetGammaRamp)(_THIS, Uint16 *ramp);
3467+
3468+ /* Get the gamma ramp */
3469+ int (*GetGammaRamp)(_THIS, Uint16 *ramp);
3470+
3471+ /* * * */
3472+ /* OpenGL support */
3473+
3474+ /* Sets the dll to use for OpenGL and loads it */
3475+ int (*GL_LoadLibrary)(_THIS, const char *path);
3476+
3477+ /* Retrieves the address of a function in the gl library */
3478+ void* (*GL_GetProcAddress)(_THIS, const char *proc);
3479+
3480+ /* Get attribute information from the windowing system. */
3481+ int (*GL_GetAttribute)(_THIS, SDL_GLattr attrib, int* value);
3482+
3483+ /* Make the context associated with this driver current */
3484+ int (*GL_MakeCurrent)(_THIS);
3485+
3486+ /* Swap the current buffers in double buffer mode. */
3487+ void (*GL_SwapBuffers)(_THIS);
3488+
3489+ /* OpenGL functions for SDL_OPENGLBLIT */
3490+#if SDL_VIDEO_OPENGL
3491+#if !defined(__WIN32__)
3492+#define WINAPI
3493+#endif
3494+#define SDL_PROC(ret,func,params) ret (WINAPI *func) params;
3495+#include "SDL_glfuncs.h"
3496+#undef SDL_PROC
3497+
3498+ /* Texture id */
3499+ GLuint texture;
3500+#endif
3501+ int is_32bit;
3502+
3503+ /* * * */
3504+ /* Window manager functions */
3505+
3506+ /* Set the title and icon text */
3507+ void (*SetCaption)(_THIS, const char *title, const char *icon);
3508+
3509+ /* Set the window icon image */
3510+ void (*SetIcon)(_THIS, SDL_Surface *icon, Uint8 *mask);
3511+
3512+ /* Iconify the window.
3513+ This function returns 1 if there is a window manager and the
3514+ window was actually iconified, it returns 0 otherwise.
3515+ */
3516+ int (*IconifyWindow)(_THIS);
3517+
3518+ /* Grab or ungrab keyboard and mouse input */
3519+ SDL_GrabMode (*GrabInput)(_THIS, SDL_GrabMode mode);
3520+
3521+ /* Get some platform dependent window information */
3522+ int (*GetWMInfo)(_THIS, SDL_SysWMinfo *info);
3523+
3524+ /* * * */
3525+ /* Cursor manager functions */
3526+
3527+ /* Free a window manager cursor
3528+ This function can be NULL if CreateWMCursor is also NULL.
3529+ */
3530+ void (*FreeWMCursor)(_THIS, WMcursor *cursor);
3531+
3532+ /* If not NULL, create a black/white window manager cursor */
3533+ WMcursor *(*CreateWMCursor)(_THIS,
3534+ Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
3535+
3536+ /* Show the specified cursor, or hide if cursor is NULL */
3537+ int (*ShowWMCursor)(_THIS, WMcursor *cursor);
3538+
3539+ /* Warp the window manager cursor to (x,y)
3540+ If NULL, a mouse motion event is posted internally.
3541+ */
3542+ void (*WarpWMCursor)(_THIS, Uint16 x, Uint16 y);
3543+
3544+ /* If not NULL, this is called when a mouse motion event occurs */
3545+ void (*MoveWMCursor)(_THIS, int x, int y);
3546+
3547+ /* Determine whether the mouse should be in relative mode or not.
3548+ This function is called when the input grab state or cursor
3549+ visibility state changes.
3550+ If the cursor is not visible, and the input is grabbed, the
3551+ driver can place the mouse in relative mode, which may result
3552+ in higher accuracy sampling of the pointer motion.
3553+ */
3554+ void (*CheckMouseMode)(_THIS);
3555+
3556+ /* * * */
3557+ /* Event manager functions */
3558+
3559+ /* Initialize keyboard mapping for this driver */
3560+ void (*InitOSKeymap)(_THIS);
3561+
3562+ /* Handle any queued OS events */
3563+ void (*PumpEvents)(_THIS);
3564+
3565+ /* * * */
3566+ /* Data common to all drivers */
3567+ SDL_Surface *screen;
3568+ SDL_Surface *shadow;
3569+ SDL_Surface *visible;
3570+ SDL_Palette *physpal; /* physical palette, if != logical palette */
3571+ SDL_Color *gammacols; /* gamma-corrected colours, or NULL */
3572+ char *wm_title;
3573+ char *wm_icon;
3574+ int offset_x;
3575+ int offset_y;
3576+ SDL_GrabMode input_grab;
3577+
3578+ /* Driver information flags */
3579+ int handles_any_size; /* Driver handles any size video mode */
3580+
3581+ /* * * */
3582+ /* Data used by the GL drivers */
3583+ struct {
3584+ int red_size;
3585+ int green_size;
3586+ int blue_size;
3587+ int alpha_size;
3588+ int depth_size;
3589+ int buffer_size;
3590+ int stencil_size;
3591+ int double_buffer;
3592+ int accum_red_size;
3593+ int accum_green_size;
3594+ int accum_blue_size;
3595+ int accum_alpha_size;
3596+ int stereo;
3597+ int multisamplebuffers;
3598+ int multisamplesamples;
3599+ int accelerated;
3600+ int swap_control;
3601+ int driver_loaded;
3602+ char driver_path[256];
3603+ void* dll_handle;
3604+ } gl_config;
3605+
3606+ /* * * */
3607+ /* Data private to this driver */
3608+ struct SDL_PrivateVideoData *hidden;
3609+ struct SDL_PrivateGLData *gl_data;
3610+
3611+ /* * * */
3612+ /* The function used to dispose of this structure */
3613+ void (*free)(_THIS);
3614+};
3615+#undef _THIS
3616+
3617+typedef struct VideoBootStrap {
3618+ const char *name;
3619+ const char *desc;
3620+ int (*available)(void);
3621+ SDL_VideoDevice *(*create)(int devindex);
3622+} VideoBootStrap;
3623+
3624+#if SDL_VIDEO_DRIVER_QUARTZ
3625+extern VideoBootStrap QZ_bootstrap;
3626+#endif
3627+#if SDL_VIDEO_DRIVER_X11
3628+extern VideoBootStrap X11_bootstrap;
3629+#endif
3630+#if SDL_VIDEO_DRIVER_DGA
3631+extern VideoBootStrap DGA_bootstrap;
3632+#endif
3633+#if SDL_VIDEO_DRIVER_NANOX
3634+extern VideoBootStrap NX_bootstrap;
3635+#endif
3636+#if SDL_VIDEO_DRIVER_IPOD
3637+extern VideoBootStrap iPod_bootstrap;
3638+#endif
3639+#if SDL_VIDEO_DRIVER_QTOPIA
3640+extern VideoBootStrap Qtopia_bootstrap;
3641+#endif
3642+#if SDL_VIDEO_DRIVER_WSCONS
3643+extern VideoBootStrap WSCONS_bootstrap;
3644+#endif
3645+#if SDL_VIDEO_DRIVER_FBCON
3646+extern VideoBootStrap FBCON_bootstrap;
3647+#endif
3648+#if SDL_VIDEO_DRIVER_DIRECTFB
3649+extern VideoBootStrap DirectFB_bootstrap;
3650+#endif
3651+#if SDL_VIDEO_DRIVER_PS2GS
3652+extern VideoBootStrap PS2GS_bootstrap;
3653+#endif
3654+#if SDL_VIDEO_DRIVER_PS3
3655+extern VideoBootStrap PS3_bootstrap;
3656+#endif
3657+#if SDL_VIDEO_DRIVER_GGI
3658+extern VideoBootStrap GGI_bootstrap;
3659+#endif
3660+#if SDL_VIDEO_DRIVER_VGL
3661+extern VideoBootStrap VGL_bootstrap;
3662+#endif
3663+#if SDL_VIDEO_DRIVER_SVGALIB
3664+extern VideoBootStrap SVGALIB_bootstrap;
3665+#endif
3666+#if SDL_VIDEO_DRIVER_GAPI
3667+extern VideoBootStrap GAPI_bootstrap;
3668+#endif
3669+#if SDL_VIDEO_DRIVER_WINDIB
3670+extern VideoBootStrap WINDIB_bootstrap;
3671+#endif
3672+#if SDL_VIDEO_DRIVER_DDRAW
3673+extern VideoBootStrap DIRECTX_bootstrap;
3674+#endif
3675+#if SDL_VIDEO_DRIVER_BWINDOW
3676+extern VideoBootStrap BWINDOW_bootstrap;
3677+#endif
3678+#if SDL_VIDEO_DRIVER_TOOLBOX
3679+extern VideoBootStrap TOOLBOX_bootstrap;
3680+#endif
3681+#if SDL_VIDEO_DRIVER_DRAWSPROCKET
3682+extern VideoBootStrap DSp_bootstrap;
3683+#endif
3684+#if SDL_VIDEO_DRIVER_PHOTON
3685+extern VideoBootStrap ph_bootstrap;
3686+#endif
3687+#if SDL_VIDEO_DRIVER_EPOC
3688+extern VideoBootStrap EPOC_bootstrap;
3689+#endif
3690+#if SDL_VIDEO_DRIVER_XBIOS
3691+extern VideoBootStrap XBIOS_bootstrap;
3692+#endif
3693+#if SDL_VIDEO_DRIVER_GEM
3694+extern VideoBootStrap GEM_bootstrap;
3695+#endif
3696+#if SDL_VIDEO_DRIVER_PICOGUI
3697+extern VideoBootStrap PG_bootstrap;
3698+#endif
3699+#if SDL_VIDEO_DRIVER_DC
3700+extern VideoBootStrap DC_bootstrap;
3701+#endif
3702+#if SDL_VIDEO_DRIVER_NDS
3703+extern VideoBootStrap NDS_bootstrap;
3704+#endif
3705+#if SDL_VIDEO_DRIVER_RISCOS
3706+extern VideoBootStrap RISCOS_bootstrap;
3707+#endif
3708+#if SDL_VIDEO_DRIVER_OS2FS
3709+extern VideoBootStrap OS2FSLib_bootstrap;
3710+#endif
3711+#if SDL_VIDEO_DRIVER_AALIB
3712+extern VideoBootStrap AALIB_bootstrap;
3713+#endif
3714+#if SDL_VIDEO_DRIVER_CACA
3715+extern VideoBootStrap CACA_bootstrap;
3716+#endif
3717+#if SDL_VIDEO_DRIVER_DUMMY
3718+extern VideoBootStrap DUMMY_bootstrap;
3719+#endif
3720+
3721+/* This is the current video device */
3722+extern SDL_VideoDevice *current_video;
3723+
3724+#define SDL_VideoSurface (current_video->screen)
3725+#define SDL_ShadowSurface (current_video->shadow)
3726+#define SDL_PublicSurface (current_video->visible)
3727+
3728+#endif /* _SDL_sysvideo_h */
3729
3730=== added file '.pc/mir-support.diff/src/video/SDL_video.c'
3731--- .pc/mir-support.diff/src/video/SDL_video.c 1970-01-01 00:00:00 +0000
3732+++ .pc/mir-support.diff/src/video/SDL_video.c 2015-06-01 21:48:23 +0000
3733@@ -0,0 +1,1978 @@
3734+/*
3735+ SDL - Simple DirectMedia Layer
3736+ Copyright (C) 1997-2012 Sam Lantinga
3737+
3738+ This library is free software; you can redistribute it and/or
3739+ modify it under the terms of the GNU Lesser General Public
3740+ License as published by the Free Software Foundation; either
3741+ version 2.1 of the License, or (at your option) any later version.
3742+
3743+ This library is distributed in the hope that it will be useful,
3744+ but WITHOUT ANY WARRANTY; without even the implied warranty of
3745+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3746+ Lesser General Public License for more details.
3747+
3748+ You should have received a copy of the GNU Lesser General Public
3749+ License along with this library; if not, write to the Free Software
3750+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3751+
3752+ Sam Lantinga
3753+ slouken@libsdl.org
3754+*/
3755+#include "SDL_config.h"
3756+
3757+/* The high-level video driver subsystem */
3758+
3759+#include "SDL.h"
3760+#include "SDL_sysvideo.h"
3761+#include "SDL_blit.h"
3762+#include "SDL_pixels_c.h"
3763+#include "SDL_cursor_c.h"
3764+#include "../events/SDL_sysevents.h"
3765+#include "../events/SDL_events_c.h"
3766+
3767+/* Available video drivers */
3768+static VideoBootStrap *bootstrap[] = {
3769+#if SDL_VIDEO_DRIVER_QUARTZ
3770+ &QZ_bootstrap,
3771+#endif
3772+#if SDL_VIDEO_DRIVER_X11
3773+ &X11_bootstrap,
3774+#endif
3775+#if SDL_VIDEO_DRIVER_DGA
3776+ &DGA_bootstrap,
3777+#endif
3778+#if SDL_VIDEO_DRIVER_NANOX
3779+ &NX_bootstrap,
3780+#endif
3781+#if SDL_VIDEO_DRIVER_IPOD
3782+ &iPod_bootstrap,
3783+#endif
3784+#if SDL_VIDEO_DRIVER_QTOPIA
3785+ &Qtopia_bootstrap,
3786+#endif
3787+#if SDL_VIDEO_DRIVER_WSCONS
3788+ &WSCONS_bootstrap,
3789+#endif
3790+#if SDL_VIDEO_DRIVER_FBCON
3791+ &FBCON_bootstrap,
3792+#endif
3793+#if SDL_VIDEO_DRIVER_DIRECTFB
3794+ &DirectFB_bootstrap,
3795+#endif
3796+#if SDL_VIDEO_DRIVER_PS2GS
3797+ &PS2GS_bootstrap,
3798+#endif
3799+#if SDL_VIDEO_DRIVER_PS3
3800+ &PS3_bootstrap,
3801+#endif
3802+#if SDL_VIDEO_DRIVER_GGI
3803+ &GGI_bootstrap,
3804+#endif
3805+#if SDL_VIDEO_DRIVER_VGL
3806+ &VGL_bootstrap,
3807+#endif
3808+#if SDL_VIDEO_DRIVER_SVGALIB
3809+ &SVGALIB_bootstrap,
3810+#endif
3811+#if SDL_VIDEO_DRIVER_GAPI
3812+ &GAPI_bootstrap,
3813+#endif
3814+#if SDL_VIDEO_DRIVER_WINDIB
3815+ &WINDIB_bootstrap,
3816+#endif
3817+#if SDL_VIDEO_DRIVER_DDRAW
3818+ &DIRECTX_bootstrap,
3819+#endif
3820+#if SDL_VIDEO_DRIVER_BWINDOW
3821+ &BWINDOW_bootstrap,
3822+#endif
3823+#if SDL_VIDEO_DRIVER_TOOLBOX
3824+ &TOOLBOX_bootstrap,
3825+#endif
3826+#if SDL_VIDEO_DRIVER_DRAWSPROCKET
3827+ &DSp_bootstrap,
3828+#endif
3829+#if SDL_VIDEO_DRIVER_PHOTON
3830+ &ph_bootstrap,
3831+#endif
3832+#if SDL_VIDEO_DRIVER_EPOC
3833+ &EPOC_bootstrap,
3834+#endif
3835+#if SDL_VIDEO_DRIVER_XBIOS
3836+ &XBIOS_bootstrap,
3837+#endif
3838+#if SDL_VIDEO_DRIVER_GEM
3839+ &GEM_bootstrap,
3840+#endif
3841+#if SDL_VIDEO_DRIVER_PICOGUI
3842+ &PG_bootstrap,
3843+#endif
3844+#if SDL_VIDEO_DRIVER_DC
3845+ &DC_bootstrap,
3846+#endif
3847+#if SDL_VIDEO_DRIVER_NDS
3848+ &NDS_bootstrap,
3849+#endif
3850+#if SDL_VIDEO_DRIVER_RISCOS
3851+ &RISCOS_bootstrap,
3852+#endif
3853+#if SDL_VIDEO_DRIVER_OS2FS
3854+ &OS2FSLib_bootstrap,
3855+#endif
3856+#if SDL_VIDEO_DRIVER_AALIB
3857+ &AALIB_bootstrap,
3858+#endif
3859+#if SDL_VIDEO_DRIVER_CACA
3860+ &CACA_bootstrap,
3861+#endif
3862+#if SDL_VIDEO_DRIVER_DUMMY
3863+ &DUMMY_bootstrap,
3864+#endif
3865+ NULL
3866+};
3867+
3868+SDL_VideoDevice *current_video = NULL;
3869+
3870+/* Various local functions */
3871+int SDL_VideoInit(const char *driver_name, Uint32 flags);
3872+void SDL_VideoQuit(void);
3873+void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects);
3874+
3875+static SDL_GrabMode SDL_WM_GrabInputOff(void);
3876+#if SDL_VIDEO_OPENGL
3877+static int lock_count = 0;
3878+#endif
3879+
3880+
3881+/*
3882+ * Initialize the video and event subsystems -- determine native pixel format
3883+ */
3884+int SDL_VideoInit (const char *driver_name, Uint32 flags)
3885+{
3886+ SDL_VideoDevice *video;
3887+ int index;
3888+ int i;
3889+ SDL_PixelFormat vformat;
3890+ Uint32 video_flags;
3891+
3892+ /* Toggle the event thread flags, based on OS requirements */
3893+#if defined(MUST_THREAD_EVENTS)
3894+ flags |= SDL_INIT_EVENTTHREAD;
3895+#elif defined(CANT_THREAD_EVENTS)
3896+ if ( (flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD ) {
3897+ SDL_SetError("OS doesn't support threaded events");
3898+ return(-1);
3899+ }
3900+#endif
3901+
3902+ /* Check to make sure we don't overwrite 'current_video' */
3903+ if ( current_video != NULL ) {
3904+ SDL_VideoQuit();
3905+ }
3906+
3907+ /* Select the proper video driver */
3908+ index = 0;
3909+ video = NULL;
3910+ if ( driver_name != NULL ) {
3911+#if 0 /* This will be replaced with a better driver selection API */
3912+ if ( SDL_strrchr(driver_name, ':') != NULL ) {
3913+ index = atoi(SDL_strrchr(driver_name, ':')+1);
3914+ }
3915+#endif
3916+ for ( i=0; bootstrap[i]; ++i ) {
3917+ if ( SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
3918+ if ( bootstrap[i]->available() ) {
3919+ video = bootstrap[i]->create(index);
3920+ break;
3921+ }
3922+ }
3923+ }
3924+ } else {
3925+ for ( i=0; bootstrap[i]; ++i ) {
3926+ if ( bootstrap[i]->available() ) {
3927+ video = bootstrap[i]->create(index);
3928+ if ( video != NULL ) {
3929+ break;
3930+ }
3931+ }
3932+ }
3933+ }
3934+ if ( video == NULL ) {
3935+ SDL_SetError("No available video device");
3936+ return(-1);
3937+ }
3938+ current_video = video;
3939+ current_video->name = bootstrap[i]->name;
3940+
3941+ /* Do some basic variable initialization */
3942+ video->screen = NULL;
3943+ video->shadow = NULL;
3944+ video->visible = NULL;
3945+ video->physpal = NULL;
3946+ video->gammacols = NULL;
3947+ video->gamma = NULL;
3948+ video->wm_title = NULL;
3949+ video->wm_icon = NULL;
3950+ video->offset_x = 0;
3951+ video->offset_y = 0;
3952+ SDL_memset(&video->info, 0, (sizeof video->info));
3953+
3954+ video->displayformatalphapixel = NULL;
3955+
3956+ /* Set some very sane GL defaults */
3957+ video->gl_config.driver_loaded = 0;
3958+ video->gl_config.dll_handle = NULL;
3959+ video->gl_config.red_size = 3;
3960+ video->gl_config.green_size = 3;
3961+ video->gl_config.blue_size = 2;
3962+ video->gl_config.alpha_size = 0;
3963+ video->gl_config.buffer_size = 0;
3964+ video->gl_config.depth_size = 16;
3965+ video->gl_config.stencil_size = 0;
3966+ video->gl_config.double_buffer = 1;
3967+ video->gl_config.accum_red_size = 0;
3968+ video->gl_config.accum_green_size = 0;
3969+ video->gl_config.accum_blue_size = 0;
3970+ video->gl_config.accum_alpha_size = 0;
3971+ video->gl_config.stereo = 0;
3972+ video->gl_config.multisamplebuffers = 0;
3973+ video->gl_config.multisamplesamples = 0;
3974+ video->gl_config.accelerated = -1; /* not known, don't set */
3975+ video->gl_config.swap_control = -1; /* not known, don't set */
3976+
3977+ /* Initialize the video subsystem */
3978+ SDL_memset(&vformat, 0, sizeof(vformat));
3979+ if ( video->VideoInit(video, &vformat) < 0 ) {
3980+ SDL_VideoQuit();
3981+ return(-1);
3982+ }
3983+
3984+ /* Create a zero sized video surface of the appropriate format */
3985+ video_flags = SDL_SWSURFACE;
3986+ SDL_VideoSurface = SDL_CreateRGBSurface(video_flags, 0, 0,
3987+ vformat.BitsPerPixel,
3988+ vformat.Rmask, vformat.Gmask, vformat.Bmask, 0);
3989+ if ( SDL_VideoSurface == NULL ) {
3990+ SDL_VideoQuit();
3991+ return(-1);
3992+ }
3993+ SDL_PublicSurface = NULL; /* Until SDL_SetVideoMode() */
3994+
3995+#if 0 /* Don't change the current palette - may be used by other programs.
3996+ * The application can't do anything with the display surface until
3997+ * a video mode has been set anyway. :)
3998+ */
3999+ /* If we have a palettized surface, create a default palette */
4000+ if ( SDL_VideoSurface->format->palette ) {
4001+ SDL_PixelFormat *vf = SDL_VideoSurface->format;
4002+ SDL_DitherColors(vf->palette->colors, vf->BitsPerPixel);
4003+ video->SetColors(video,
4004+ 0, vf->palette->ncolors, vf->palette->colors);
4005+ }
4006+#endif
4007+ video->info.vfmt = SDL_VideoSurface->format;
4008+
4009+ /* Start the event loop */
4010+ if ( SDL_StartEventLoop(flags) < 0 ) {
4011+ SDL_VideoQuit();
4012+ return(-1);
4013+ }
4014+ SDL_CursorInit(flags & SDL_INIT_EVENTTHREAD);
4015+
4016+ /* We're ready to go! */
4017+ return(0);
4018+}
4019+
4020+char *SDL_VideoDriverName(char *namebuf, int maxlen)
4021+{
4022+ if ( current_video != NULL ) {
4023+ SDL_strlcpy(namebuf, current_video->name, maxlen);
4024+ return(namebuf);
4025+ }
4026+ return(NULL);
4027+}
4028+
4029+/*
4030+ * Get the current display surface
4031+ */
4032+SDL_Surface *SDL_GetVideoSurface(void)
4033+{
4034+ SDL_Surface *visible;
4035+
4036+ visible = NULL;
4037+ if ( current_video ) {
4038+ visible = current_video->visible;
4039+ }
4040+ return(visible);
4041+}
4042+
4043+/*
4044+ * Get the current information about the video hardware
4045+ */
4046+const SDL_VideoInfo *SDL_GetVideoInfo(void)
4047+{
4048+ const SDL_VideoInfo *info;
4049+
4050+ info = NULL;
4051+ if ( current_video ) {
4052+ info = &current_video->info;
4053+ }
4054+ return(info);
4055+}
4056+
4057+/*
4058+ * Return a pointer to an array of available screen dimensions for the
4059+ * given format, sorted largest to smallest. Returns NULL if there are
4060+ * no dimensions available for a particular format, or (SDL_Rect **)-1
4061+ * if any dimension is okay for the given format. If 'format' is NULL,
4062+ * the mode list will be for the format given by SDL_GetVideoInfo()->vfmt
4063+ */
4064+SDL_Rect ** SDL_ListModes (SDL_PixelFormat *format, Uint32 flags)
4065+{
4066+ SDL_VideoDevice *video = current_video;
4067+ SDL_VideoDevice *this = current_video;
4068+ SDL_Rect **modes;
4069+
4070+ modes = NULL;
4071+ if ( SDL_VideoSurface ) {
4072+ if ( format == NULL ) {
4073+ format = SDL_VideoSurface->format;
4074+ }
4075+ modes = video->ListModes(this, format, flags);
4076+ }
4077+ return(modes);
4078+}
4079+
4080+/*
4081+ * Check to see if a particular video mode is supported.
4082+ * It returns 0 if the requested mode is not supported under any bit depth,
4083+ * or returns the bits-per-pixel of the closest available mode with the
4084+ * given width and height. If this bits-per-pixel is different from the
4085+ * one used when setting the video mode, SDL_SetVideoMode() will succeed,
4086+ * but will emulate the requested bits-per-pixel with a shadow surface.
4087+ */
4088+static Uint8 SDL_closest_depths[4][8] = {
4089+ /* 8 bit closest depth ordering */
4090+ { 0, 8, 16, 15, 32, 24, 0, 0 },
4091+ /* 15,16 bit closest depth ordering */
4092+ { 0, 16, 15, 32, 24, 8, 0, 0 },
4093+ /* 24 bit closest depth ordering */
4094+ { 0, 24, 32, 16, 15, 8, 0, 0 },
4095+ /* 32 bit closest depth ordering */
4096+ { 0, 32, 16, 15, 24, 8, 0, 0 }
4097+};
4098+
4099+
4100+#ifdef __MACOS__ /* MPW optimization bug? */
4101+#define NEGATIVE_ONE 0xFFFFFFFF
4102+#else
4103+#define NEGATIVE_ONE -1
4104+#endif
4105+
4106+int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags)
4107+{
4108+ int table, b, i;
4109+ int supported;
4110+ SDL_PixelFormat format;
4111+ SDL_Rect **sizes;
4112+
4113+ /* Currently 1 and 4 bpp are not supported */
4114+ if ( bpp < 8 || bpp > 32 ) {
4115+ return(0);
4116+ }
4117+ if ( (width <= 0) || (height <= 0) ) {
4118+ return(0);
4119+ }
4120+
4121+ /* Search through the list valid of modes */
4122+ SDL_memset(&format, 0, sizeof(format));
4123+ supported = 0;
4124+ table = ((bpp+7)/8)-1;
4125+ SDL_closest_depths[table][0] = bpp;
4126+ SDL_closest_depths[table][7] = 0;
4127+ for ( b = 0; !supported && SDL_closest_depths[table][b]; ++b ) {
4128+ format.BitsPerPixel = SDL_closest_depths[table][b];
4129+ sizes = SDL_ListModes(&format, flags);
4130+ if ( sizes == (SDL_Rect **)0 ) {
4131+ /* No sizes supported at this bit-depth */
4132+ continue;
4133+ } else
4134+ if (sizes == (SDL_Rect **)NEGATIVE_ONE) {
4135+ /* Any size supported at this bit-depth */
4136+ supported = 1;
4137+ continue;
4138+ } else if (current_video->handles_any_size) {
4139+ /* Driver can center a smaller surface to simulate fullscreen */
4140+ for ( i=0; sizes[i]; ++i ) {
4141+ if ((sizes[i]->w >= width) && (sizes[i]->h >= height)) {
4142+ supported = 1; /* this mode can fit the centered window. */
4143+ break;
4144+ }
4145+ }
4146+ } else
4147+ for ( i=0; sizes[i]; ++i ) {
4148+ if ((sizes[i]->w == width) && (sizes[i]->h == height)) {
4149+ supported = 1;
4150+ break;
4151+ }
4152+ }
4153+ }
4154+ if ( supported ) {
4155+ --b;
4156+ return(SDL_closest_depths[table][b]);
4157+ } else {
4158+ return(0);
4159+ }
4160+}
4161+
4162+/*
4163+ * Get the closest non-emulated video mode to the one requested
4164+ */
4165+static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags)
4166+{
4167+ int table, b, i;
4168+ int supported;
4169+ int native_bpp;
4170+ SDL_PixelFormat format;
4171+ SDL_Rect **sizes;
4172+
4173+ /* Check parameters */
4174+ if ( *BitsPerPixel < 8 || *BitsPerPixel > 32 ) {
4175+ SDL_SetError("Invalid bits per pixel (range is {8...32})");
4176+ return(0);
4177+ }
4178+ if ((*w <= 0) || (*h <= 0)) {
4179+ SDL_SetError("Invalid width or height");
4180+ return(0);
4181+ }
4182+
4183+ /* Try the original video mode, get the closest depth */
4184+ native_bpp = SDL_VideoModeOK(*w, *h, *BitsPerPixel, flags);
4185+ if ( native_bpp == *BitsPerPixel ) {
4186+ return(1);
4187+ }
4188+ if ( native_bpp > 0 ) {
4189+ *BitsPerPixel = native_bpp;
4190+ return(1);
4191+ }
4192+
4193+ /* No exact size match at any depth, look for closest match */
4194+ SDL_memset(&format, 0, sizeof(format));
4195+ supported = 0;
4196+ table = ((*BitsPerPixel+7)/8)-1;
4197+ SDL_closest_depths[table][0] = *BitsPerPixel;
4198+ SDL_closest_depths[table][7] = SDL_VideoSurface->format->BitsPerPixel;
4199+ for ( b = 0; !supported && SDL_closest_depths[table][b]; ++b ) {
4200+ int best;
4201+
4202+ format.BitsPerPixel = SDL_closest_depths[table][b];
4203+ sizes = SDL_ListModes(&format, flags);
4204+ if ( sizes == (SDL_Rect **)0 ) {
4205+ /* No sizes supported at this bit-depth */
4206+ continue;
4207+ }
4208+ best=0;
4209+ for ( i=0; sizes[i]; ++i ) {
4210+ /* Mode with both dimensions bigger or equal than asked ? */
4211+ if ((sizes[i]->w >= *w) && (sizes[i]->h >= *h)) {
4212+ /* Mode with any dimension smaller or equal than current best ? */
4213+ if ((sizes[i]->w <= sizes[best]->w) || (sizes[i]->h <= sizes[best]->h)) {
4214+ /* Now choose the mode that has less pixels */
4215+ if ((sizes[i]->w * sizes[i]->h) <= (sizes[best]->w * sizes[best]->h)) {
4216+ best=i;
4217+ supported = 1;
4218+ }
4219+ }
4220+ }
4221+ }
4222+ if (supported) {
4223+ *w=sizes[best]->w;
4224+ *h=sizes[best]->h;
4225+ *BitsPerPixel = SDL_closest_depths[table][b];
4226+ }
4227+ }
4228+ if ( ! supported ) {
4229+ SDL_SetError("No video mode large enough for %dx%d", *w, *h);
4230+ }
4231+ return(supported);
4232+}
4233+
4234+/* This should probably go somewhere else -- like SDL_surface.c */
4235+static void SDL_ClearSurface(SDL_Surface *surface)
4236+{
4237+ Uint32 black;
4238+
4239+ black = SDL_MapRGB(surface->format, 0, 0, 0);
4240+ SDL_FillRect(surface, NULL, black);
4241+ if ((surface->flags&SDL_HWSURFACE) && (surface->flags&SDL_DOUBLEBUF)) {
4242+ SDL_Flip(surface);
4243+ SDL_FillRect(surface, NULL, black);
4244+ }
4245+ if (surface->flags&SDL_FULLSCREEN) {
4246+ SDL_Flip(surface);
4247+ }
4248+}
4249+
4250+/*
4251+ * Create a shadow surface suitable for fooling the app. :-)
4252+ */
4253+static void SDL_CreateShadowSurface(int depth)
4254+{
4255+ Uint32 Rmask, Gmask, Bmask;
4256+
4257+ /* Allocate the shadow surface */
4258+ if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) {
4259+ Rmask = (SDL_VideoSurface->format)->Rmask;
4260+ Gmask = (SDL_VideoSurface->format)->Gmask;
4261+ Bmask = (SDL_VideoSurface->format)->Bmask;
4262+ } else {
4263+ Rmask = Gmask = Bmask = 0;
4264+ }
4265+ SDL_ShadowSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,
4266+ SDL_VideoSurface->w, SDL_VideoSurface->h,
4267+ depth, Rmask, Gmask, Bmask, 0);
4268+ if ( SDL_ShadowSurface == NULL ) {
4269+ return;
4270+ }
4271+
4272+ /* 8-bit shadow surfaces report that they have exclusive palette */
4273+ if ( SDL_ShadowSurface->format->palette ) {
4274+ SDL_ShadowSurface->flags |= SDL_HWPALETTE;
4275+ if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) {
4276+ SDL_memcpy(SDL_ShadowSurface->format->palette->colors,
4277+ SDL_VideoSurface->format->palette->colors,
4278+ SDL_VideoSurface->format->palette->ncolors*
4279+ sizeof(SDL_Color));
4280+ } else {
4281+ SDL_DitherColors(
4282+ SDL_ShadowSurface->format->palette->colors, depth);
4283+ }
4284+ }
4285+
4286+ /* If the video surface is resizable, the shadow should say so */
4287+ if ( (SDL_VideoSurface->flags & SDL_RESIZABLE) == SDL_RESIZABLE ) {
4288+ SDL_ShadowSurface->flags |= SDL_RESIZABLE;
4289+ }
4290+ /* If the video surface has no frame, the shadow should say so */
4291+ if ( (SDL_VideoSurface->flags & SDL_NOFRAME) == SDL_NOFRAME ) {
4292+ SDL_ShadowSurface->flags |= SDL_NOFRAME;
4293+ }
4294+ /* If the video surface is fullscreen, the shadow should say so */
4295+ if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
4296+ SDL_ShadowSurface->flags |= SDL_FULLSCREEN;
4297+ }
4298+ /* If the video surface is flippable, the shadow should say so */
4299+ if ( (SDL_VideoSurface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
4300+ SDL_ShadowSurface->flags |= SDL_DOUBLEBUF;
4301+ }
4302+ return;
4303+}
4304+
4305+#ifdef __QNXNTO__
4306+ #include <sys/neutrino.h>
4307+#endif /* __QNXNTO__ */
4308+
4309+#ifdef WIN32
4310+ extern int sysevents_mouse_pressed;
4311+#endif
4312+
4313+/*
4314+ * Set the requested video mode, allocating a shadow buffer if necessary.
4315+ */
4316+SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
4317+{
4318+ SDL_VideoDevice *video, *this;
4319+ SDL_Surface *prev_mode, *mode;
4320+ int video_w;
4321+ int video_h;
4322+ int video_bpp;
4323+ int is_opengl;
4324+ SDL_GrabMode saved_grab;
4325+
4326+ #ifdef WIN32
4327+ sysevents_mouse_pressed = 0;
4328+ #endif
4329+
4330+ /* Start up the video driver, if necessary..
4331+ WARNING: This is the only function protected this way!
4332+ */
4333+ if ( ! current_video ) {
4334+ if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0 ) {
4335+ return(NULL);
4336+ }
4337+ }
4338+ this = video = current_video;
4339+
4340+ /* Default to the current width and height */
4341+ if ( width == 0 ) {
4342+ width = video->info.current_w;
4343+ }
4344+ if ( height == 0 ) {
4345+ height = video->info.current_h;
4346+ }
4347+ /* Default to the current video bpp */
4348+ if ( bpp == 0 ) {
4349+ flags |= SDL_ANYFORMAT;
4350+ bpp = SDL_VideoSurface->format->BitsPerPixel;
4351+ }
4352+
4353+ /* Get a good video mode, the closest one possible */
4354+ video_w = width;
4355+ video_h = height;
4356+ video_bpp = bpp;
4357+ if ( ! SDL_GetVideoMode(&video_w, &video_h, &video_bpp, flags) ) {
4358+ return(NULL);
4359+ }
4360+
4361+ /* Check the requested flags */
4362+ /* There's no palette in > 8 bits-per-pixel mode */
4363+ if ( video_bpp > 8 ) {
4364+ flags &= ~SDL_HWPALETTE;
4365+ }
4366+#if 0
4367+ if ( (flags&SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
4368+ /* There's no windowed double-buffering */
4369+ flags &= ~SDL_DOUBLEBUF;
4370+ }
4371+#endif
4372+ if ( (flags&SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
4373+ /* Use hardware surfaces when double-buffering */
4374+ flags |= SDL_HWSURFACE;
4375+ }
4376+
4377+ is_opengl = ( ( flags & SDL_OPENGL ) == SDL_OPENGL );
4378+ if ( is_opengl ) {
4379+ /* These flags are for 2D video modes only */
4380+ flags &= ~(SDL_HWSURFACE|SDL_DOUBLEBUF);
4381+ }
4382+
4383+ /* Reset the keyboard here so event callbacks can run */
4384+ SDL_ResetKeyboard();
4385+ SDL_ResetMouse();
4386+ SDL_SetMouseRange(width, height);
4387+ SDL_cursorstate &= ~CURSOR_USINGSW;
4388+
4389+ /* Clean up any previous video mode */
4390+ if ( SDL_PublicSurface != NULL ) {
4391+ SDL_PublicSurface = NULL;
4392+ }
4393+ if ( SDL_ShadowSurface != NULL ) {
4394+ SDL_Surface *ready_to_go;
4395+ ready_to_go = SDL_ShadowSurface;
4396+ SDL_ShadowSurface = NULL;
4397+ SDL_FreeSurface(ready_to_go);
4398+ }
4399+ if ( video->physpal ) {
4400+ SDL_free(video->physpal->colors);
4401+ SDL_free(video->physpal);
4402+ video->physpal = NULL;
4403+ }
4404+ if( video->gammacols) {
4405+ SDL_free(video->gammacols);
4406+ video->gammacols = NULL;
4407+ }
4408+
4409+ /* Save the previous grab state and turn off grab for mode switch */
4410+ saved_grab = SDL_WM_GrabInputOff();
4411+
4412+ /* Try to set the video mode, along with offset and clipping */
4413+ prev_mode = SDL_VideoSurface;
4414+ SDL_LockCursor();
4415+ SDL_VideoSurface = NULL; /* In case it's freed by driver */
4416+ mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags);
4417+ if ( mode ) { /* Prevent resize events from mode change */
4418+ /* But not on OS/2 */
4419+#ifndef __OS2__
4420+ SDL_PrivateResize(mode->w, mode->h);
4421+#endif
4422+
4423+ /* Sam - If we asked for OpenGL mode, and didn't get it, fail */
4424+ if ( is_opengl && !(mode->flags & SDL_OPENGL) ) {
4425+ mode = NULL;
4426+ SDL_SetError("OpenGL not available");
4427+ }
4428+ }
4429+ /*
4430+ * rcg11292000
4431+ * If you try to set an SDL_OPENGL surface, and fail to find a
4432+ * matching visual, then the next call to SDL_SetVideoMode()
4433+ * will segfault, since we no longer point to a dummy surface,
4434+ * but rather NULL.
4435+ * Sam 11/29/00
4436+ * WARNING, we need to make sure that the previous mode hasn't
4437+ * already been freed by the video driver. What do we do in
4438+ * that case? Should we call SDL_VideoInit() again?
4439+ */
4440+ SDL_VideoSurface = (mode != NULL) ? mode : prev_mode;
4441+
4442+ if ( (mode != NULL) && (!is_opengl) ) {
4443+ /* Sanity check */
4444+ if ( (mode->w < width) || (mode->h < height) ) {
4445+ SDL_SetError("Video mode smaller than requested");
4446+ return(NULL);
4447+ }
4448+
4449+ /* If we have a palettized surface, create a default palette */
4450+ if ( mode->format->palette ) {
4451+ SDL_PixelFormat *vf = mode->format;
4452+ SDL_DitherColors(vf->palette->colors, vf->BitsPerPixel);
4453+ video->SetColors(this, 0, vf->palette->ncolors,
4454+ vf->palette->colors);
4455+ }
4456+
4457+ /* Clear the surface to black */
4458+ video->offset_x = 0;
4459+ video->offset_y = 0;
4460+ mode->offset = 0;
4461+ SDL_SetClipRect(mode, NULL);
4462+ SDL_ClearSurface(mode);
4463+
4464+ /* Now adjust the offsets to match the desired mode */
4465+ video->offset_x = (mode->w-width)/2;
4466+ video->offset_y = (mode->h-height)/2;
4467+ mode->offset = video->offset_y*mode->pitch +
4468+ video->offset_x*mode->format->BytesPerPixel;
4469+#ifdef DEBUG_VIDEO
4470+ fprintf(stderr,
4471+ "Requested mode: %dx%dx%d, obtained mode %dx%dx%d (offset %d)\n",
4472+ width, height, bpp,
4473+ mode->w, mode->h, mode->format->BitsPerPixel, mode->offset);
4474+#endif
4475+ mode->w = width;
4476+ mode->h = height;
4477+ SDL_SetClipRect(mode, NULL);
4478+ }
4479+ SDL_ResetCursor();
4480+ SDL_UnlockCursor();
4481+
4482+ /* If we failed setting a video mode, return NULL... (Uh Oh!) */
4483+ if ( mode == NULL ) {
4484+ return(NULL);
4485+ }
4486+
4487+ /* If there is no window manager, set the SDL_NOFRAME flag */
4488+ if ( ! video->info.wm_available ) {
4489+ mode->flags |= SDL_NOFRAME;
4490+ }
4491+
4492+ /* Reset the mouse cursor and grab for new video mode */
4493+ SDL_SetCursor(NULL);
4494+ if ( video->UpdateMouse ) {
4495+ video->UpdateMouse(this);
4496+ }
4497+ SDL_WM_GrabInput(saved_grab);
4498+ SDL_GetRelativeMouseState(NULL, NULL); /* Clear first large delta */
4499+
4500+#if SDL_VIDEO_OPENGL
4501+ /* Load GL symbols (before MakeCurrent, where we need glGetString). */
4502+ if ( flags & (SDL_OPENGL | SDL_OPENGLBLIT) ) {
4503+
4504+#if defined(__QNXNTO__) && (_NTO_VERSION < 630)
4505+#define __SDL_NOGETPROCADDR__
4506+#elif defined(__MINT__)
4507+#define __SDL_NOGETPROCADDR__
4508+#endif
4509+#ifdef __SDL_NOGETPROCADDR__
4510+ #define SDL_PROC(ret,func,params) video->func=func;
4511+#else
4512+ #define SDL_PROC(ret,func,params) \
4513+ do { \
4514+ video->func = SDL_GL_GetProcAddress(#func); \
4515+ if ( ! video->func ) { \
4516+ SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
4517+ return(NULL); \
4518+ } \
4519+ } while ( 0 );
4520+
4521+#endif /* __SDL_NOGETPROCADDR__ */
4522+
4523+#include "SDL_glfuncs.h"
4524+#undef SDL_PROC
4525+ }
4526+#endif /* SDL_VIDEO_OPENGL */
4527+
4528+ /* If we're running OpenGL, make the context current */
4529+ if ( (video->screen->flags & SDL_OPENGL) &&
4530+ video->GL_MakeCurrent ) {
4531+ if ( video->GL_MakeCurrent(this) < 0 ) {
4532+ return(NULL);
4533+ }
4534+ }
4535+
4536+ /* Set up a fake SDL surface for OpenGL "blitting" */
4537+ if ( (flags & SDL_OPENGLBLIT) == SDL_OPENGLBLIT ) {
4538+ /* Load GL functions for performing the texture updates */
4539+#if SDL_VIDEO_OPENGL
4540+
4541+ /* Create a software surface for blitting */
4542+#ifdef GL_VERSION_1_2
4543+ /* If the implementation either supports the packed pixels
4544+ extension, or implements the core OpenGL 1.2 API, it will
4545+ support the GL_UNSIGNED_SHORT_5_6_5 texture format.
4546+ */
4547+ if ( (bpp == 16) &&
4548+ (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") ||
4549+ (SDL_atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f))
4550+ ) {
4551+ video->is_32bit = 0;
4552+ SDL_VideoSurface = SDL_CreateRGBSurface(
4553+ flags,
4554+ width,
4555+ height,
4556+ 16,
4557+ 31 << 11,
4558+ 63 << 5,
4559+ 31,
4560+ 0
4561+ );
4562+ }
4563+ else
4564+#endif /* OpenGL 1.2 */
4565+ {
4566+ video->is_32bit = 1;
4567+ SDL_VideoSurface = SDL_CreateRGBSurface(
4568+ flags,
4569+ width,
4570+ height,
4571+ 32,
4572+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
4573+ 0x000000FF,
4574+ 0x0000FF00,
4575+ 0x00FF0000,
4576+ 0xFF000000
4577+#else
4578+ 0xFF000000,
4579+ 0x00FF0000,
4580+ 0x0000FF00,
4581+ 0x000000FF
4582+#endif
4583+ );
4584+ }
4585+ if ( ! SDL_VideoSurface ) {
4586+ return(NULL);
4587+ }
4588+ SDL_VideoSurface->flags = mode->flags | SDL_OPENGLBLIT;
4589+
4590+ /* Free the original video mode surface (is this safe?) */
4591+ SDL_FreeSurface(mode);
4592+
4593+ /* Set the surface completely opaque & white by default */
4594+ SDL_memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch );
4595+ video->glGenTextures( 1, &video->texture );
4596+ video->glBindTexture( GL_TEXTURE_2D, video->texture );
4597+ video->glTexImage2D(
4598+ GL_TEXTURE_2D,
4599+ 0,
4600+ video->is_32bit ? GL_RGBA : GL_RGB,
4601+ 256,
4602+ 256,
4603+ 0,
4604+ video->is_32bit ? GL_RGBA : GL_RGB,
4605+#ifdef GL_VERSION_1_2
4606+ video->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
4607+#else
4608+ GL_UNSIGNED_BYTE,
4609+#endif
4610+ NULL);
4611+
4612+ video->UpdateRects = SDL_GL_UpdateRectsLock;
4613+#else
4614+ SDL_SetError("Somebody forgot to #define SDL_VIDEO_OPENGL");
4615+ return(NULL);
4616+#endif
4617+ }
4618+
4619+ /* Create a shadow surface if necessary */
4620+ /* There are three conditions under which we create a shadow surface:
4621+ 1. We need a particular bits-per-pixel that we didn't get.
4622+ 2. We need a hardware palette and didn't get one.
4623+ 3. We need a software surface and got a hardware surface.
4624+ */
4625+ if ( !(SDL_VideoSurface->flags & SDL_OPENGL) &&
4626+ (
4627+ ( !(flags&SDL_ANYFORMAT) &&
4628+ (SDL_VideoSurface->format->BitsPerPixel != bpp)) ||
4629+ ( (flags&SDL_HWPALETTE) &&
4630+ !(SDL_VideoSurface->flags&SDL_HWPALETTE)) ||
4631+ /* If the surface is in hardware, video writes are visible
4632+ as soon as they are performed, so we need to buffer them
4633+ */
4634+ ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) &&
4635+ (SDL_VideoSurface->flags&SDL_HWSURFACE)) ||
4636+ ( (flags&SDL_DOUBLEBUF) &&
4637+ (SDL_VideoSurface->flags&SDL_HWSURFACE) &&
4638+ !(SDL_VideoSurface->flags&SDL_DOUBLEBUF))
4639+ ) ) {
4640+ SDL_CreateShadowSurface(bpp);
4641+ if ( SDL_ShadowSurface == NULL ) {
4642+ SDL_SetError("Couldn't create shadow surface");
4643+ return(NULL);
4644+ }
4645+ SDL_PublicSurface = SDL_ShadowSurface;
4646+ } else {
4647+ SDL_PublicSurface = SDL_VideoSurface;
4648+ }
4649+ video->info.vfmt = SDL_VideoSurface->format;
4650+ video->info.current_w = SDL_VideoSurface->w;
4651+ video->info.current_h = SDL_VideoSurface->h;
4652+
4653+ /* We're done! */
4654+ return(SDL_PublicSurface);
4655+}
4656+
4657+/*
4658+ * Convert a surface into the video pixel format.
4659+ */
4660+SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface)
4661+{
4662+ Uint32 flags;
4663+
4664+ if ( ! SDL_PublicSurface ) {
4665+ SDL_SetError("No video mode has been set");
4666+ return(NULL);
4667+ }
4668+ /* Set the flags appropriate for copying to display surface */
4669+ if (((SDL_PublicSurface->flags&SDL_HWSURFACE) == SDL_HWSURFACE) && current_video->info.blit_hw)
4670+ flags = SDL_HWSURFACE;
4671+ else
4672+ flags = SDL_SWSURFACE;
4673+#ifdef AUTORLE_DISPLAYFORMAT
4674+ flags |= (surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA));
4675+ flags |= SDL_RLEACCELOK;
4676+#else
4677+ flags |= surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA|SDL_RLEACCELOK);
4678+#endif
4679+ return(SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags));
4680+}
4681+
4682+/*
4683+ * Convert a surface into a format that's suitable for blitting to
4684+ * the screen, but including an alpha channel.
4685+ */
4686+SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface)
4687+{
4688+ SDL_PixelFormat *vf;
4689+ SDL_PixelFormat *format;
4690+ SDL_Surface *converted;
4691+ Uint32 flags;
4692+ /* default to ARGB8888 */
4693+ Uint32 amask = 0xff000000;
4694+ Uint32 rmask = 0x00ff0000;
4695+ Uint32 gmask = 0x0000ff00;
4696+ Uint32 bmask = 0x000000ff;
4697+
4698+ if ( ! SDL_PublicSurface ) {
4699+ SDL_SetError("No video mode has been set");
4700+ return(NULL);
4701+ }
4702+ vf = SDL_PublicSurface->format;
4703+
4704+ switch(vf->BytesPerPixel) {
4705+ case 2:
4706+ /* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}.
4707+ For anything else (like ARGB4444) it doesn't matter
4708+ since we have no special code for it anyway */
4709+ if ( (vf->Rmask == 0x1f) &&
4710+ (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) {
4711+ rmask = 0xff;
4712+ bmask = 0xff0000;
4713+ }
4714+ break;
4715+
4716+ case 3:
4717+ case 4:
4718+ /* Keep the video format, as long as the high 8 bits are
4719+ unused or alpha */
4720+ if ( (vf->Rmask == 0xff) && (vf->Bmask == 0xff0000) ) {
4721+ rmask = 0xff;
4722+ bmask = 0xff0000;
4723+ } else if ( vf->Rmask == 0xFF00 && (vf->Bmask == 0xFF000000) ) {
4724+ amask = 0x000000FF;
4725+ rmask = 0x0000FF00;
4726+ gmask = 0x00FF0000;
4727+ bmask = 0xFF000000;
4728+ }
4729+ break;
4730+
4731+ default:
4732+ /* We have no other optimised formats right now. When/if a new
4733+ optimised alpha format is written, add the converter here */
4734+ break;
4735+ }
4736+ format = SDL_AllocFormat(32, rmask, gmask, bmask, amask);
4737+ flags = SDL_PublicSurface->flags & SDL_HWSURFACE;
4738+ flags |= surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
4739+ converted = SDL_ConvertSurface(surface, format, flags);
4740+ SDL_FreeFormat(format);
4741+ return(converted);
4742+}
4743+
4744+/*
4745+ * Update a specific portion of the physical screen
4746+ */
4747+void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
4748+{
4749+ if ( screen ) {
4750+ SDL_Rect rect;
4751+
4752+ /* Perform some checking */
4753+ if ( w == 0 )
4754+ w = screen->w;
4755+ if ( h == 0 )
4756+ h = screen->h;
4757+ if ( (int)(x+w) > screen->w )
4758+ return;
4759+ if ( (int)(y+h) > screen->h )
4760+ return;
4761+
4762+ /* Fill the rectangle */
4763+ rect.x = (Sint16)x;
4764+ rect.y = (Sint16)y;
4765+ rect.w = (Uint16)w;
4766+ rect.h = (Uint16)h;
4767+ SDL_UpdateRects(screen, 1, &rect);
4768+ }
4769+}
4770+void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects)
4771+{
4772+ int i;
4773+ SDL_VideoDevice *video = current_video;
4774+ SDL_VideoDevice *this = current_video;
4775+
4776+ if ( (screen->flags & (SDL_OPENGL | SDL_OPENGLBLIT)) == SDL_OPENGL ) {
4777+ SDL_SetError("OpenGL active, use SDL_GL_SwapBuffers()");
4778+ return;
4779+ }
4780+ if ( screen == SDL_ShadowSurface ) {
4781+ /* Blit the shadow surface using saved mapping */
4782+ SDL_Palette *pal = screen->format->palette;
4783+ SDL_Color *saved_colors = NULL;
4784+ if ( pal && !(SDL_VideoSurface->flags & SDL_HWPALETTE) ) {
4785+ /* simulated 8bpp, use correct physical palette */
4786+ saved_colors = pal->colors;
4787+ if ( video->gammacols ) {
4788+ /* gamma-corrected palette */
4789+ pal->colors = video->gammacols;
4790+ } else if ( video->physpal ) {
4791+ /* physical palette different from logical */
4792+ pal->colors = video->physpal->colors;
4793+ }
4794+ }
4795+ if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) {
4796+ SDL_LockCursor();
4797+ SDL_DrawCursor(SDL_ShadowSurface);
4798+ for ( i=0; i<numrects; ++i ) {
4799+ SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
4800+ SDL_VideoSurface, &rects[i]);
4801+ }
4802+ SDL_EraseCursor(SDL_ShadowSurface);
4803+ SDL_UnlockCursor();
4804+ } else {
4805+ for ( i=0; i<numrects; ++i ) {
4806+ SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
4807+ SDL_VideoSurface, &rects[i]);
4808+ }
4809+ }
4810+ if ( saved_colors ) {
4811+ pal->colors = saved_colors;
4812+ }
4813+
4814+ /* Fall through to video surface update */
4815+ screen = SDL_VideoSurface;
4816+ }
4817+ if ( screen == SDL_VideoSurface ) {
4818+ /* Update the video surface */
4819+ if ( screen->offset ) {
4820+ for ( i=0; i<numrects; ++i ) {
4821+ rects[i].x += video->offset_x;
4822+ rects[i].y += video->offset_y;
4823+ }
4824+ video->UpdateRects(this, numrects, rects);
4825+ for ( i=0; i<numrects; ++i ) {
4826+ rects[i].x -= video->offset_x;
4827+ rects[i].y -= video->offset_y;
4828+ }
4829+ } else {
4830+ video->UpdateRects(this, numrects, rects);
4831+ }
4832+ }
4833+}
4834+
4835+/*
4836+ * Performs hardware double buffering, if possible, or a full update if not.
4837+ */
4838+int SDL_Flip(SDL_Surface *screen)
4839+{
4840+ SDL_VideoDevice *video = current_video;
4841+ /* Copy the shadow surface to the video surface */
4842+ if ( screen == SDL_ShadowSurface ) {
4843+ SDL_Rect rect;
4844+ SDL_Palette *pal = screen->format->palette;
4845+ SDL_Color *saved_colors = NULL;
4846+ if ( pal && !(SDL_VideoSurface->flags & SDL_HWPALETTE) ) {
4847+ /* simulated 8bpp, use correct physical palette */
4848+ saved_colors = pal->colors;
4849+ if ( video->gammacols ) {
4850+ /* gamma-corrected palette */
4851+ pal->colors = video->gammacols;
4852+ } else if ( video->physpal ) {
4853+ /* physical palette different from logical */
4854+ pal->colors = video->physpal->colors;
4855+ }
4856+ }
4857+
4858+ rect.x = 0;
4859+ rect.y = 0;
4860+ rect.w = screen->w;
4861+ rect.h = screen->h;
4862+ if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) {
4863+ SDL_LockCursor();
4864+ SDL_DrawCursor(SDL_ShadowSurface);
4865+ SDL_LowerBlit(SDL_ShadowSurface, &rect,
4866+ SDL_VideoSurface, &rect);
4867+ SDL_EraseCursor(SDL_ShadowSurface);
4868+ SDL_UnlockCursor();
4869+ } else {
4870+ SDL_LowerBlit(SDL_ShadowSurface, &rect,
4871+ SDL_VideoSurface, &rect);
4872+ }
4873+ if ( saved_colors ) {
4874+ pal->colors = saved_colors;
4875+ }
4876+
4877+ /* Fall through to video surface update */
4878+ screen = SDL_VideoSurface;
4879+ }
4880+ if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
4881+ SDL_VideoDevice *this = current_video;
4882+ return(video->FlipHWSurface(this, SDL_VideoSurface));
4883+ } else {
4884+ SDL_UpdateRect(screen, 0, 0, 0, 0);
4885+ }
4886+ return(0);
4887+}
4888+
4889+static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors,
4890+ int firstcolor, int ncolors)
4891+{
4892+ SDL_Palette *pal = screen->format->palette;
4893+ SDL_Palette *vidpal;
4894+
4895+ if ( colors != (pal->colors + firstcolor) ) {
4896+ SDL_memcpy(pal->colors + firstcolor, colors,
4897+ ncolors * sizeof(*colors));
4898+ }
4899+
4900+ if ( current_video && SDL_VideoSurface ) {
4901+ vidpal = SDL_VideoSurface->format->palette;
4902+ if ( (screen == SDL_ShadowSurface) && vidpal ) {
4903+ /*
4904+ * This is a shadow surface, and the physical
4905+ * framebuffer is also indexed. Propagate the
4906+ * changes to its logical palette so that
4907+ * updates are always identity blits
4908+ */
4909+ SDL_memcpy(vidpal->colors + firstcolor, colors,
4910+ ncolors * sizeof(*colors));
4911+ }
4912+ }
4913+ SDL_FormatChanged(screen);
4914+}
4915+
4916+static int SetPalette_physical(SDL_Surface *screen,
4917+ SDL_Color *colors, int firstcolor, int ncolors)
4918+{
4919+ SDL_VideoDevice *video = current_video;
4920+ int gotall = 1;
4921+
4922+ if ( video->physpal ) {
4923+ /* We need to copy the new colors, since we haven't
4924+ * already done the copy in the logical set above.
4925+ */
4926+ SDL_memcpy(video->physpal->colors + firstcolor,
4927+ colors, ncolors * sizeof(*colors));
4928+ }
4929+ if ( screen == SDL_ShadowSurface ) {
4930+ if ( SDL_VideoSurface->flags & SDL_HWPALETTE ) {
4931+ /*
4932+ * The real screen is also indexed - set its physical
4933+ * palette. The physical palette does not include the
4934+ * gamma modification, we apply it directly instead,
4935+ * but this only happens if we have hardware palette.
4936+ */
4937+ screen = SDL_VideoSurface;
4938+ } else {
4939+ /*
4940+ * The video surface is not indexed - invalidate any
4941+ * active shadow-to-video blit mappings.
4942+ */
4943+ if ( screen->map->dst == SDL_VideoSurface ) {
4944+ SDL_InvalidateMap(screen->map);
4945+ }
4946+ if ( video->gamma ) {
4947+ if( ! video->gammacols ) {
4948+ SDL_Palette *pp = video->physpal;
4949+ if(!pp)
4950+ pp = screen->format->palette;
4951+ video->gammacols = SDL_malloc(pp->ncolors
4952+ * sizeof(SDL_Color));
4953+ SDL_ApplyGamma(video->gamma,
4954+ pp->colors,
4955+ video->gammacols,
4956+ pp->ncolors);
4957+ } else {
4958+ SDL_ApplyGamma(video->gamma, colors,
4959+ video->gammacols
4960+ + firstcolor,
4961+ ncolors);
4962+ }
4963+ }
4964+ SDL_UpdateRect(screen, 0, 0, 0, 0);
4965+ }
4966+ }
4967+
4968+ if ( screen == SDL_VideoSurface ) {
4969+ SDL_Color gcolors[256];
4970+
4971+ if ( video->gamma ) {
4972+ SDL_ApplyGamma(video->gamma, colors, gcolors, ncolors);
4973+ colors = gcolors;
4974+ }
4975+ gotall = video->SetColors(video, firstcolor, ncolors, colors);
4976+ if ( ! gotall ) {
4977+ /* The video flags shouldn't have SDL_HWPALETTE, and
4978+ the video driver is responsible for copying back the
4979+ correct colors into the video surface palette.
4980+ */
4981+ ;
4982+ }
4983+ SDL_CursorPaletteChanged();
4984+ }
4985+ return gotall;
4986+}
4987+
4988+/*
4989+ * Set the physical and/or logical colormap of a surface:
4990+ * Only the screen has a physical colormap. It determines what is actually
4991+ * sent to the display.
4992+ * The logical colormap is used to map blits to/from the surface.
4993+ * 'which' is one or both of SDL_LOGPAL, SDL_PHYSPAL
4994+ *
4995+ * Return nonzero if all colours were set as requested, or 0 otherwise.
4996+ */
4997+int SDL_SetPalette(SDL_Surface *screen, int which,
4998+ SDL_Color *colors, int firstcolor, int ncolors)
4999+{
5000+ SDL_Palette *pal;
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches