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

* 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

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

51. By Brandon Schaefer

* 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
=== modified file '.pc/applied-patches'
--- .pc/applied-patches 2014-07-01 23:03:57 +0000
+++ .pc/applied-patches 2015-06-01 21:48:23 +0000
@@ -4,3 +4,4 @@
4fix_window_resizing.diff4fix_window_resizing.diff
5fix_joystick_misc_axes.diff5fix_joystick_misc_axes.diff
6sdl-check-for-SDL_VIDEO_X11_BACKINGSTORE.patch6sdl-check-for-SDL_VIDEO_X11_BACKINGSTORE.patch
7mir-support.diff
78
=== added directory '.pc/mir-support.diff'
=== added file '.pc/mir-support.diff/configure.in'
--- .pc/mir-support.diff/configure.in 1970-01-01 00:00:00 +0000
+++ .pc/mir-support.diff/configure.in 2015-06-01 21:48:23 +0000
@@ -0,0 +1,2965 @@
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(README)
3AC_CONFIG_HEADER(include/SDL_config.h)
4AC_GNU_SOURCE
5AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
6
7dnl Set various version strings - taken gratefully from the GTk sources
8#
9# Making releases:
10# Edit include/SDL/SDL_version.h and change the version, then:
11# SDL_MICRO_VERSION += 1;
12# SDL_INTERFACE_AGE += 1;
13# SDL_BINARY_AGE += 1;
14# if any functions have been added, set SDL_INTERFACE_AGE to 0.
15# if backwards compatibility has been broken,
16# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
17#
18SDL_MAJOR_VERSION=1
19SDL_MINOR_VERSION=2
20SDL_MICRO_VERSION=15
21SDL_INTERFACE_AGE=4
22SDL_BINARY_AGE=15
23SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
24
25AC_SUBST(SDL_MAJOR_VERSION)
26AC_SUBST(SDL_MINOR_VERSION)
27AC_SUBST(SDL_MICRO_VERSION)
28AC_SUBST(SDL_INTERFACE_AGE)
29AC_SUBST(SDL_BINARY_AGE)
30AC_SUBST(SDL_VERSION)
31
32# libtool versioning
33LT_INIT([win32-dll])
34
35LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
36LT_CURRENT=`expr $SDL_MICRO_VERSION - $SDL_INTERFACE_AGE`
37LT_REVISION=$SDL_INTERFACE_AGE
38LT_AGE=`expr $SDL_BINARY_AGE - $SDL_INTERFACE_AGE`
39m4_pattern_allow([^LT_])
40
41AC_SUBST(LT_RELEASE)
42AC_SUBST(LT_CURRENT)
43AC_SUBST(LT_REVISION)
44AC_SUBST(LT_AGE)
45
46dnl Detect the canonical build and host environments
47AC_CONFIG_AUX_DIR([build-scripts])
48dnl AC_CANONICAL_HOST
49AC_C_BIGENDIAN
50if test x$ac_cv_c_bigendian = xyes; then
51 AC_DEFINE(SDL_BYTEORDER, 4321)
52else
53 AC_DEFINE(SDL_BYTEORDER, 1234)
54fi
55
56dnl Check for tools
57AC_PROG_LIBTOOL
58AC_PROG_CC
59AC_PROG_CXX
60AC_PROG_INSTALL
61AC_PROG_MAKE_SET
62AC_CHECK_TOOL(WINDRES, [windres], [:])
63
64dnl Set up the compiler and linker flags
65INCLUDE="-I$srcdir/include"
66if test x$srcdir != x.; then
67 # Remove SDL_config.h from the source directory, since it's the
68 # default one, and we want to include the one that we generate.
69 if test -f $srcdir/include/SDL_config.h; then
70 rm $srcdir/include/SDL_config.h
71 fi
72 INCLUDE="-Iinclude $INCLUDE"
73fi
74case "$host" in
75 *-*-cygwin*)
76 # We build SDL on cygwin without the UNIX emulation layer
77 BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
78 BASE_LDFLAGS="-mno-cygwin"
79 ;;
80 *)
81 BASE_CFLAGS="-D_GNU_SOURCE=1"
82 BASE_LDFLAGS=""
83 ;;
84esac
85BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
86EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
87BUILD_LDFLAGS="$LDFLAGS"
88EXTRA_LDFLAGS="$BASE_LDFLAGS"
89## These are common directories to find software packages
90#for path in /usr/freeware /usr/pkg /usr/X11R6 /usr/local; do
91# if test -d $path/include; then
92# EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
93# fi
94# if test -d $path/lib; then
95# EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
96# fi
97#done
98SDL_CFLAGS="$BASE_CFLAGS"
99SDL_LIBS="-lSDL $BASE_LDFLAGS"
100CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
101CFLAGS="$CFLAGS $EXTRA_CFLAGS"
102LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
103
104dnl set this to use on systems that use lib64 instead of lib
105base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
106
107dnl Function to find a library in the compiler search path
108find_lib()
109{
110 gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
111 gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
112 env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
113 if test "$cross_compiling" = yes; then
114 host_lib_path=""
115 else
116 host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
117 fi
118 for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
119 lib=[`ls -- $path/$1 2>/dev/null | sort | sed 's/.*\/\(.*\)/\1/; q'`]
120 if test x$lib != x; then
121 echo $lib
122 return
123 fi
124 done
125}
126
127dnl Check for compiler characteristics
128AC_C_CONST
129AC_C_INLINE
130AC_C_VOLATILE
131
132dnl See whether we are allowed to use the system C library
133AC_ARG_ENABLE(libc,
134AC_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]),
135 , enable_libc=yes)
136if test x$enable_libc = xyes; then
137 AC_DEFINE(HAVE_LIBC)
138
139 dnl Check for C library headers
140 AC_HEADER_STDC
141 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)
142
143 dnl Check for typedefs, structures, etc.
144 AC_TYPE_SIZE_T
145 if test x$ac_cv_header_inttypes_h = xyes -o x$ac_cv_header_stdint_h = xyes; then
146 AC_CHECK_TYPE(int64_t)
147 if test x$ac_cv_type_int64_t = xyes; then
148 AC_DEFINE(SDL_HAS_64BIT_TYPE)
149 fi
150 have_inttypes=yes
151 fi
152
153 dnl Checks for library functions.
154 case "$host" in
155 *-*-cygwin* | *-*-mingw32*)
156 ;;
157 *)
158 AC_FUNC_ALLOCA
159 ;;
160 esac
161
162 AC_FUNC_MEMCMP
163 if test x$ac_cv_func_memcmp_working = xyes; then
164 AC_DEFINE(HAVE_MEMCMP)
165 fi
166 AC_FUNC_STRTOD
167 if test x$ac_cv_func_strtod = xyes; then
168 AC_DEFINE(HAVE_STRTOD)
169 fi
170 AC_CHECK_FUNC(mprotect,
171 AC_TRY_COMPILE([
172 #include <sys/types.h>
173 #include <sys/mman.h>
174 ],[
175 ],[
176 AC_DEFINE(HAVE_MPROTECT)
177 ]),
178 )
179 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)
180
181 AC_CHECK_LIB(iconv, libiconv_open, [EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
182 AC_CHECK_LIB(m, pow, [EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
183
184 AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE(HAVE_SA_SIGACTION)], ,[#include <signal.h>])
185fi
186
187if test x$have_inttypes != xyes; then
188 AC_CHECK_SIZEOF(char, 1)
189 AC_CHECK_SIZEOF(short, 2)
190 AC_CHECK_SIZEOF(int, 4)
191 AC_CHECK_SIZEOF(long, 4)
192 AC_CHECK_SIZEOF(long long, 8)
193 if test x$ac_cv_sizeof_char = x1; then
194 AC_DEFINE(int8_t, signed char)
195 AC_DEFINE(uint8_t, unsigned char)
196 fi
197 if test x$ac_cv_sizeof_short = x2; then
198 AC_DEFINE(int16_t, signed short)
199 AC_DEFINE(uint16_t, unsigned short)
200 else
201 if test x$ac_cv_sizeof_int = x2; then
202 AC_DEFINE(int16_t, signed int)
203 AC_DEFINE(uint16_t, unsigned int)
204 fi
205 fi
206 if test x$ac_cv_sizeof_int = x4; then
207 AC_DEFINE(int32_t, signed int)
208 AC_DEFINE(uint32_t, unsigned int)
209 else
210 if test x$ac_cv_sizeof_long = x4; then
211 AC_DEFINE(int32_t, signed long)
212 AC_DEFINE(uint32_t, unsigned long)
213 fi
214 fi
215 if test x$ac_cv_sizeof_long = x8; then
216 AC_DEFINE(int64_t, signed long)
217 AC_DEFINE(uint64_t, unsigned long)
218 AC_DEFINE(SDL_HAS_64BIT_TYPE)
219 else
220 if test x$ac_cv_sizeof_long_long = x8; then
221 AC_DEFINE(int64_t, signed long long)
222 AC_DEFINE(uint64_t, unsigned long long)
223 AC_DEFINE(SDL_HAS_64BIT_TYPE)
224 fi
225 fi
226 AC_DEFINE(size_t, unsigned int)
227 AC_DEFINE(uintptr_t, unsigned long)
228fi
229
230# Standard C sources
231SOURCES="$SOURCES $srcdir/src/*.c"
232SOURCES="$SOURCES $srcdir/src/audio/*.c"
233SOURCES="$SOURCES $srcdir/src/cdrom/*.c"
234SOURCES="$SOURCES $srcdir/src/cpuinfo/*.c"
235SOURCES="$SOURCES $srcdir/src/events/*.c"
236SOURCES="$SOURCES $srcdir/src/file/*.c"
237SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
238SOURCES="$SOURCES $srcdir/src/thread/*.c"
239SOURCES="$SOURCES $srcdir/src/timer/*.c"
240SOURCES="$SOURCES $srcdir/src/video/*.c"
241
242dnl Enable/disable various subsystems of the SDL library
243
244AC_ARG_ENABLE(audio,
245AC_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]),
246 , enable_audio=yes)
247if test x$enable_audio != xyes; then
248 AC_DEFINE(SDL_AUDIO_DISABLED)
249fi
250AC_ARG_ENABLE(video,
251AC_HELP_STRING([--enable-video], [Enable the video subsystem [[default=yes]]]),
252 , enable_video=yes)
253if test x$enable_video != xyes; then
254 AC_DEFINE(SDL_VIDEO_DISABLED)
255fi
256AC_ARG_ENABLE(events,
257AC_HELP_STRING([--enable-events], [Enable the events subsystem [[default=yes]]]),
258 , enable_events=yes)
259if test x$enable_events != xyes; then
260 AC_DEFINE(SDL_EVENTS_DISABLED)
261fi
262AC_ARG_ENABLE(joystick,
263AC_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes]]]),
264 , enable_joystick=yes)
265if test x$enable_joystick != xyes; then
266 AC_DEFINE(SDL_JOYSTICK_DISABLED)
267else
268 SOURCES="$SOURCES $srcdir/src/joystick/*.c"
269fi
270AC_ARG_ENABLE(cdrom,
271AC_HELP_STRING([--enable-cdrom], [Enable the cdrom subsystem [[default=yes]]]),
272 , enable_cdrom=yes)
273if test x$enable_cdrom != xyes; then
274 AC_DEFINE(SDL_CDROM_DISABLED)
275fi
276AC_ARG_ENABLE(threads,
277AC_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]),
278 , enable_threads=yes)
279if test x$enable_threads != xyes; then
280 AC_DEFINE(SDL_THREADS_DISABLED)
281fi
282AC_ARG_ENABLE(timers,
283AC_HELP_STRING([--enable-timers], [Enable the timer subsystem [[default=yes]]]),
284 , enable_timers=yes)
285if test x$enable_timers != xyes; then
286 AC_DEFINE(SDL_TIMERS_DISABLED)
287fi
288AC_ARG_ENABLE(file,
289AC_HELP_STRING([--enable-file], [Enable the file subsystem [[default=yes]]]),
290 , enable_file=yes)
291if test x$enable_file != xyes; then
292 AC_DEFINE(SDL_FILE_DISABLED)
293fi
294AC_ARG_ENABLE(loadso,
295AC_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [[default=yes]]]),
296 , enable_loadso=yes)
297if test x$enable_loadso != xyes; then
298 AC_DEFINE(SDL_LOADSO_DISABLED)
299fi
300AC_ARG_ENABLE(cpuinfo,
301AC_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [[default=yes]]]),
302 , enable_cpuinfo=yes)
303if test x$enable_cpuinfo != xyes; then
304 AC_DEFINE(SDL_CPUINFO_DISABLED)
305fi
306AC_ARG_ENABLE(assembly,
307AC_HELP_STRING([--enable-assembly], [Enable assembly routines [[default=yes]]]),
308 , enable_assembly=yes)
309if test x$enable_assembly = xyes; then
310 AC_DEFINE(SDL_ASSEMBLY_ROUTINES)
311fi
312
313dnl See if the OSS audio interface is supported
314CheckOSS()
315{
316 AC_ARG_ENABLE(oss,
317AC_HELP_STRING([--enable-oss], [support the OSS audio API [[default=yes]]]),
318 , enable_oss=yes)
319 if test x$enable_audio = xyes -a x$enable_oss = xyes; then
320 AC_MSG_CHECKING(for OSS audio support)
321 have_oss=no
322 if test x$have_oss != xyes; then
323 AC_TRY_COMPILE([
324 #include <sys/soundcard.h>
325 ],[
326 int arg = SNDCTL_DSP_SETFRAGMENT;
327 ],[
328 have_oss=yes
329 ])
330 fi
331 if test x$have_oss != xyes; then
332 AC_TRY_COMPILE([
333 #include <soundcard.h>
334 ],[
335 int arg = SNDCTL_DSP_SETFRAGMENT;
336 ],[
337 have_oss=yes
338 AC_DEFINE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H)
339 ])
340 fi
341 AC_MSG_RESULT($have_oss)
342 if test x$have_oss = xyes; then
343 AC_DEFINE(SDL_AUDIO_DRIVER_OSS)
344 SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c"
345 SOURCES="$SOURCES $srcdir/src/audio/dma/*.c"
346 have_audio=yes
347
348 # We may need to link with ossaudio emulation library
349 case "$host" in
350 *-*-openbsd*|*-*-netbsd*)
351 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lossaudio";;
352 esac
353 fi
354 fi
355}
356
357dnl See if the ALSA audio interface is supported
358CheckALSA()
359{
360 AC_ARG_ENABLE(alsa,
361AC_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]),
362 , enable_alsa=yes)
363 if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
364 AM_PATH_ALSA(0.9.0, have_alsa=yes, have_alsa=no)
365 # Restore all flags from before the ALSA detection runs
366 CFLAGS="$alsa_save_CFLAGS"
367 LDFLAGS="$alsa_save_LDFLAGS"
368 LIBS="$alsa_save_LIBS"
369 if test x$have_alsa = xyes; then
370 AC_ARG_ENABLE(alsa-shared,
371AC_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[default=yes]]]),
372 , enable_alsa_shared=yes)
373 alsa_lib=[`find_lib "libasound.so.*" "$ALSA_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
374
375 AC_DEFINE(SDL_AUDIO_DRIVER_ALSA)
376 SOURCES="$SOURCES $srcdir/src/audio/alsa/*.c"
377 EXTRA_CFLAGS="$EXTRA_CFLAGS $ALSA_CFLAGS"
378 if test x$have_loadso != xyes && \
379 test x$enable_alsa_shared = xyes; then
380 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ALSA loading])
381 fi
382 if test x$have_loadso = xyes && \
383 test x$enable_alsa_shared = xyes && test x$alsa_lib != x; then
384 echo "-- dynamic libasound -> $alsa_lib"
385 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ALSA_DYNAMIC, "$alsa_lib")
386 else
387 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ALSA_LIBS"
388 fi
389 have_audio=yes
390 fi
391 fi
392}
393
394dnl Check whether we want to use IRIX 6.5+ native audio or not
395CheckDMEDIA()
396{
397 if test x$enable_audio = xyes; then
398 AC_MSG_CHECKING(for dmedia audio support)
399 have_dmedia=no
400 AC_TRY_COMPILE([
401 #include <dmedia/audio.h>
402 ],[
403 ALport audio_port;
404 ],[
405 have_dmedia=yes
406 ])
407 AC_MSG_RESULT($have_dmedia)
408 # Set up files for the audio library
409 if test x$have_dmedia = xyes; then
410 AC_DEFINE(SDL_AUDIO_DRIVER_DMEDIA)
411 SOURCES="$SOURCES $srcdir/src/audio/dmedia/*.c"
412 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -laudio"
413 have_audio=yes
414 fi
415 fi
416}
417
418dnl Check whether we want to use Tru64 UNIX native audio or not
419CheckMME()
420{
421 dnl Make sure we are running on an Tru64 UNIX
422 case $ARCH in
423 osf)
424 ;;
425 *)
426 return
427 ;;
428 esac
429 if test x$enable_audio = xyes; then
430 AC_MSG_CHECKING(for MME audio support)
431 MME_CFLAGS="-I/usr/include/mme"
432 MME_LIBS="-lmme"
433 have_mme=no
434 save_CFLAGS="$CFLAGS"
435 CFLAGS="$CFLAGS $MME_CFLAGS"
436 AC_TRY_COMPILE([
437 #include <mme_api.h>
438 ],[
439 HWAVEOUT sound;
440 ],[
441 have_mme=yes
442 ])
443 CFLAGS="$save_CFLAGS"
444 AC_MSG_RESULT($have_mme)
445 # Set up files for the audio library
446 if test x$have_mme = xyes; then
447 AC_DEFINE(SDL_AUDIO_DRIVER_MMEAUDIO)
448 SOURCES="$SOURCES $srcdir/src/audio/mme/*.c"
449 EXTRA_CFLAGS="$EXTRA_CFLAGS $MME_CFLAGS"
450 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MME_LIBS"
451 have_audio=yes
452 fi
453 fi
454}
455
456dnl Find the ESD includes and libraries
457CheckESD()
458{
459 AC_ARG_ENABLE(esd,
460AC_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [[default=yes]]]),
461 , enable_esd=yes)
462 if test x$enable_audio = xyes -a x$enable_esd = xyes; then
463 AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
464 if test x$have_esd = xyes; then
465 AC_ARG_ENABLE(esd-shared,
466AC_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]),
467 , enable_esd_shared=yes)
468 esd_lib=[`find_lib "libesd.so.*" "$ESD_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
469
470 AC_DEFINE(SDL_AUDIO_DRIVER_ESD)
471 SOURCES="$SOURCES $srcdir/src/audio/esd/*.c"
472 EXTRA_CFLAGS="$EXTRA_CFLAGS $ESD_CFLAGS"
473 if test x$have_loadso != xyes && \
474 test x$enable_esd_shared = xyes; then
475 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ESD loading])
476 fi
477 if test x$have_loadso = xyes && \
478 test x$enable_esd_shared = xyes && test x$esd_lib != x; then
479 echo "-- dynamic libesd -> $esd_lib"
480 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ESD_DYNAMIC, "$esd_lib")
481 else
482 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ESD_LIBS"
483 fi
484 have_audio=yes
485 fi
486 fi
487}
488
489dnl Find PulseAudio
490CheckPulseAudio()
491{
492 AC_ARG_ENABLE(pulseaudio,
493AC_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]),
494 , enable_pulseaudio=yes)
495 if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then
496 audio_pulse=no
497
498 PULSE_REQUIRED_VERSION=0.9
499
500 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
501 AC_MSG_CHECKING(for PulseAudio $PULSE_REQUIRED_VERSION support)
502 if test x$PKG_CONFIG != xno; then
503 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSE_REQUIRED_VERSION libpulse-simple; then
504 PULSE_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
505 PULSE_LIBS=`$PKG_CONFIG --libs libpulse-simple`
506 audio_pulse=yes
507 fi
508 fi
509 AC_MSG_RESULT($audio_pulse)
510
511 if test x$audio_pulse = xyes; then
512 AC_ARG_ENABLE(pulseaudio-shared,
513AC_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]),
514 , enable_pulseaudio_shared=yes)
515 pulse_lib=[`find_lib "libpulse-simple.so.*" "$PULSE_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
516
517 AC_DEFINE(SDL_AUDIO_DRIVER_PULSE)
518 SOURCES="$SOURCES $srcdir/src/audio/pulse/*.c"
519 EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSE_CFLAGS"
520 if test x$have_loadso != xyes && \
521 test x$enable_pulseaudio_shared = xyes; then
522 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic PulseAudio loading])
523 fi
524 if test x$have_loadso = xyes && \
525 test x$enable_pulseaudio_shared = xyes && test x$pulse_lib != x; then
526 echo "-- dynamic libpulse-simple -> $pulse_lib"
527 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSE_DYNAMIC, "$pulse_lib")
528 else
529 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSE_LIBS"
530 fi
531 have_audio=yes
532 fi
533 fi
534}
535
536CheckARTSC()
537{
538 AC_ARG_ENABLE(arts,
539AC_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [[default=yes]]]),
540 , enable_arts=yes)
541 if test x$enable_audio = xyes -a x$enable_arts = xyes; then
542 AC_PATH_PROG(ARTSCONFIG, artsc-config)
543 if test x$ARTSCONFIG = x -o x$ARTSCONFIG = x'"$ARTSCONFIG"'; then
544 : # arts isn't installed
545 else
546 ARTS_CFLAGS=`$ARTSCONFIG --cflags`
547 ARTS_LIBS=`$ARTSCONFIG --libs`
548 AC_MSG_CHECKING(for aRts development environment)
549 audio_arts=no
550 save_CFLAGS="$CFLAGS"
551 CFLAGS="$CFLAGS $ARTS_CFLAGS"
552 AC_TRY_COMPILE([
553 #include <artsc.h>
554 ],[
555 arts_stream_t stream;
556 ],[
557 audio_arts=yes
558 ])
559 CFLAGS="$save_CFLAGS"
560 AC_MSG_RESULT($audio_arts)
561 if test x$audio_arts = xyes; then
562 AC_ARG_ENABLE(arts-shared,
563AC_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [[default=yes]]]),
564 , enable_arts_shared=yes)
565 arts_lib=[`find_lib "libartsc.so.*" "$ARTS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
566
567 AC_DEFINE(SDL_AUDIO_DRIVER_ARTS)
568 SOURCES="$SOURCES $srcdir/src/audio/arts/*.c"
569 EXTRA_CFLAGS="$EXTRA_CFLAGS $ARTS_CFLAGS"
570 if test x$have_loadso != xyes && \
571 test x$enable_arts_shared = xyes; then
572 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic ARTS loading])
573 fi
574 if test x$have_loadso = xyes && \
575 test x$enable_arts_shared = xyes && test x$arts_lib != x; then
576 echo "-- dynamic libartsc -> $arts_lib"
577 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_ARTS_DYNAMIC, "$arts_lib")
578 else
579 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $ARTS_LIBS"
580 fi
581 have_audio=yes
582 fi
583 fi
584 fi
585}
586
587dnl See if the NAS audio interface is supported
588CheckNAS()
589{
590 AC_ARG_ENABLE(nas,
591AC_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]),
592 , enable_nas=yes)
593 if test x$enable_audio = xyes -a x$enable_nas = xyes; then
594 AC_CHECK_HEADER(audio/audiolib.h, have_nas_hdr=yes)
595 AC_CHECK_LIB(audio, AuOpenServer, have_nas_lib=yes)
596
597 AC_MSG_CHECKING(for NAS audio support)
598 have_nas=no
599
600 if test x$have_nas_hdr = xyes -a x$have_nas_lib = xyes; then
601 have_nas=yes
602 NAS_LIBS="-laudio"
603
604 elif test -r /usr/X11R6/include/audio/audiolib.h; then
605 have_nas=yes
606 NAS_CFLAGS="-I/usr/X11R6/include/"
607 NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
608
609 dnl On IRIX, the NAS includes are in a different directory,
610 dnl and libnas must be explicitly linked in
611
612 elif test -r /usr/freeware/include/nas/audiolib.h; then
613 have_nas=yes
614 NAS_LIBS="-lnas -lXt"
615 fi
616
617 AC_MSG_RESULT($have_nas)
618
619 if test x$have_nas = xyes; then
620 AC_ARG_ENABLE(nas-shared,
621AC_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [[default=yes]]]),
622 , enable_nas_shared=yes)
623 nas_lib=[`find_lib "libaudio.so.*" "$NAS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`]
624
625 if test x$have_loadso != xyes && \
626 test x$enable_nas_shared = xyes; then
627 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic NAS loading])
628 fi
629 if test x$have_loadso = xyes && \
630 test x$enable_nas_shared = xyes && test x$nas_lib != x; then
631 echo "-- dynamic libaudio -> $nas_lib"
632 AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_NAS_DYNAMIC, "$nas_lib")
633 else
634 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $NAS_LIBS"
635 fi
636
637 AC_DEFINE(SDL_AUDIO_DRIVER_NAS)
638 SOURCES="$SOURCES $srcdir/src/audio/nas/*.c"
639 EXTRA_CFLAGS="$EXTRA_CFLAGS $NAS_CFLAGS"
640 have_audio=yes
641 fi
642 fi
643}
644
645dnl rcg07142001 See if the user wants the disk writer audio driver...
646CheckDiskAudio()
647{
648 AC_ARG_ENABLE(diskaudio,
649AC_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [[default=yes]]]),
650 , enable_diskaudio=yes)
651 if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
652 AC_DEFINE(SDL_AUDIO_DRIVER_DISK)
653 SOURCES="$SOURCES $srcdir/src/audio/disk/*.c"
654 fi
655}
656
657dnl rcg03142006 See if the user wants the dummy audio driver...
658CheckDummyAudio()
659{
660 AC_ARG_ENABLE(dummyaudio,
661AC_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=yes]]]),
662 , enable_dummyaudio=yes)
663 if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then
664 AC_DEFINE(SDL_AUDIO_DRIVER_DUMMY)
665 SOURCES="$SOURCES $srcdir/src/audio/dummy/*.c"
666 fi
667}
668
669dnl Set up the Atari Audio driver
670CheckAtariAudio()
671{
672 AC_ARG_ENABLE(mintaudio,
673AC_HELP_STRING([--enable-mintaudio], [support Atari audio driver [[default=yes]]]),
674 , enable_mintaudio=yes)
675 if test x$enable_audio = xyes -a x$enable_mintaudio = xyes; then
676 mintaudio=no
677 AC_CHECK_HEADER(mint/falcon.h, have_mint_falcon_hdr=yes)
678 if test x$have_mint_falcon_hdr = xyes; then
679 mintaudio=yes
680 AC_DEFINE(SDL_AUDIO_DRIVER_MINT)
681 SOURCES="$SOURCES $srcdir/src/audio/mint/*.c"
682 SOURCES="$SOURCES $srcdir/src/audio/mint/*.S"
683 have_audio=yes
684 fi
685 fi
686}
687
688dnl See if we can use x86 assembly blitters
689# NASM is available from: http://nasm.sourceforge.net
690CheckNASM()
691{
692 dnl Make sure we are running on an x86 platform
693 case $host in
694 i?86*)
695 ;;
696 *)
697 # Nope, bail early.
698 return
699 ;;
700 esac
701
702 dnl Mac OS X might report itself as "i386" but generate x86_64 code.
703 dnl So see what size we think a pointer is, and bail if not 32-bit.
704 AC_CHECK_SIZEOF([void *], 4)
705 if test x$ac_cv_sizeof_void_p != x4; then
706 return
707 fi
708
709 dnl Check for NASM (for assembly blit routines)
710 AC_ARG_ENABLE(nasm,
711AC_HELP_STRING([--enable-nasm], [use nasm assembly blitters on x86 [[default=yes]]]),
712 , enable_nasm=yes)
713 if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_nasm = xyes; then
714 CompileNASM()
715 {
716 # Usage: CompileNASM <filename>
717 AC_MSG_CHECKING(to see if $NASM supports $1)
718 if $NASM $NASMFLAGS $1 -o $1.o >&AS_MESSAGE_LOG_FD 2>&1; then
719 CompileNASM_ret="yes"
720 else
721 CompileNASM_ret="no"
722 fi
723 rm -f $1 $1.o
724 AC_MSG_RESULT($CompileNASM_ret)
725 test "$CompileNASM_ret" = "yes"
726 }
727
728 if test x"$NASMFLAGS" = x; then
729 case $ARCH in
730 win32)
731 NASMFLAGS="-f win32"
732 ;;
733 macosx)
734 NASMFLAGS="-f macho"
735 ;;
736 *)
737 NASMFLAGS="-f elf32"
738 ;;
739 esac
740 fi
741
742 AC_PATH_PROG(NASM, nasm)
743 echo "%ifidn __OUTPUT_FORMAT__,elf32" > unquoted-sections
744 echo "section .note.GNU-stack noalloc noexec nowrite progbits" >> unquoted-sections
745 echo "%endif" >> unquoted-sections
746 CompileNASM unquoted-sections || NASM=""
747
748 if test "x$NASM" != x -a "x$NASM" != x'"$NASM"'; then
749 AC_DEFINE(SDL_HERMES_BLITTERS)
750 SOURCES="$SOURCES $srcdir/src/hermes/*.asm"
751 NASMFLAGS="$NASMFLAGS -I $srcdir/src/hermes/"
752
753 dnl See if hidden visibility is supported
754 echo "GLOBAL _bar:function hidden" > symbol-visibility
755 echo "_bar:" >> symbol-visibility
756 CompileNASM symbol-visibility && NASMFLAGS="$NASMFLAGS -DHIDDEN_VISIBILITY"
757
758 AC_SUBST(NASM)
759 AC_SUBST(NASMFLAGS)
760
761 case "$host" in
762 # this line is needed for QNX, because it's not defined the __ELF__
763 *-*-qnx*)
764 EXTRA_CFLAGS="$EXTRA_CFLAGS -D__ELF__";;
765 *-*-solaris*)
766 EXTRA_CFLAGS="$EXTRA_CFLAGS -D__ELF__";;
767 esac
768 fi
769 fi
770}
771
772dnl Check for altivec instruction support using gas syntax
773CheckAltivec()
774{
775 AC_ARG_ENABLE(altivec,
776AC_HELP_STRING([--enable-altivec], [use altivec assembly blitters on PPC [[default=yes]]]),
777 , enable_altivec=yes)
778 if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_altivec = xyes; then
779 save_CFLAGS="$CFLAGS"
780 have_gcc_altivec=no
781 have_altivec_h_hdr=no
782 altivec_CFLAGS="-maltivec"
783 CFLAGS="$save_CFLAGS $altivec_CFLAGS"
784
785 AC_MSG_CHECKING(for Altivec with GCC altivec.h and -maltivec option)
786 AC_TRY_COMPILE([
787 #include <altivec.h>
788 vector unsigned int vzero() {
789 return vec_splat_u32(0);
790 }
791 ],[
792 ],[
793 have_gcc_altivec=yes
794 have_altivec_h_hdr=yes
795 ])
796 AC_MSG_RESULT($have_gcc_altivec)
797
798 if test x$have_gcc_altivec = xno; then
799 AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
800 AC_TRY_COMPILE([
801 vector unsigned int vzero() {
802 return vec_splat_u32(0);
803 }
804 ],[
805 ],[
806 have_gcc_altivec=yes
807 ])
808 AC_MSG_RESULT($have_gcc_altivec)
809 fi
810
811 if test x$have_gcc_altivec = xno; then
812 AC_MSG_CHECKING(for Altivec with GCC altivec.h and -faltivec option)
813 altivec_CFLAGS="-faltivec"
814 CFLAGS="$save_CFLAGS $altivec_CFLAGS"
815 AC_TRY_COMPILE([
816 #include <altivec.h>
817 vector unsigned int vzero() {
818 return vec_splat_u32(0);
819 }
820 ],[
821 ],[
822 have_gcc_altivec=yes
823 have_altivec_h_hdr=yes
824 ])
825 AC_MSG_RESULT($have_gcc_altivec)
826 fi
827
828 if test x$have_gcc_altivec = xno; then
829 AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
830 AC_TRY_COMPILE([
831 vector unsigned int vzero() {
832 return vec_splat_u32(0);
833 }
834 ],[
835 ],[
836 have_gcc_altivec=yes
837 ])
838 AC_MSG_RESULT($have_gcc_altivec)
839 fi
840 CFLAGS="$save_CFLAGS"
841
842 if test x$have_gcc_altivec = xyes; then
843 AC_DEFINE(SDL_ALTIVEC_BLITTERS)
844 if test x$have_altivec_h_hdr = xyes; then
845 AC_DEFINE(HAVE_ALTIVEC_H)
846 fi
847 EXTRA_CFLAGS="$EXTRA_CFLAGS $altivec_CFLAGS"
848 fi
849 fi
850}
851
852dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
853dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
854CheckVisibilityHidden()
855{
856 AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
857 have_gcc_fvisibility=no
858
859 visibility_CFLAGS="-fvisibility=hidden"
860 save_CFLAGS="$CFLAGS"
861 CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
862 AC_TRY_COMPILE([
863 #if !defined(__GNUC__) || __GNUC__ < 4
864 #error SDL only uses visibility attributes in GCC 4 or newer
865 #endif
866 ],[
867 ],[
868 have_gcc_fvisibility=yes
869 ])
870 AC_MSG_RESULT($have_gcc_fvisibility)
871 CFLAGS="$save_CFLAGS"
872
873 if test x$have_gcc_fvisibility = xyes; then
874 EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
875 fi
876}
877
878dnl See if GCC's -Wall is supported.
879CheckWarnAll()
880{
881 AC_MSG_CHECKING(for GCC -Wall option)
882 have_gcc_Wall=no
883
884 save_CFLAGS="$CFLAGS"
885 CFLAGS="$save_CFLAGS -Wall"
886 AC_TRY_COMPILE([
887 int x = 0;
888 ],[
889 ],[
890 have_gcc_Wall=yes
891 ])
892 AC_MSG_RESULT($have_gcc_Wall)
893 CFLAGS="$save_CFLAGS"
894
895 if test x$have_gcc_Wall = xyes; then
896 EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
897
898 dnl Haiku headers use multicharacter constants all over the place. Ignore these warnings when using -Wall.
899 AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
900 need_gcc_Wno_multichar=no
901 case "$host" in
902 *-*-beos* | *-*-haiku*)
903 need_gcc_Wno_multichar=yes
904 ;;
905 esac
906 AC_MSG_RESULT($need_gcc_Wno_multichar)
907 if test x$need_gcc_Wno_multichar = xyes; then
908 EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-multichar"
909 fi
910 fi
911}
912
913
914dnl Do the iPod thing
915CheckIPod()
916{
917 AC_ARG_ENABLE(ipod,
918AC_HELP_STRING([--enable-ipod], [configure SDL to work with iPodLinux [[default=no]]]),
919 , enable_ipod=no)
920
921 if test x$enable_ipod = xyes; then
922 EXTRA_CFLAGS="$EXTRA_CFLAGS -DIPOD"
923 AC_DEFINE(SDL_VIDEO_DRIVER_IPOD)
924 SOURCES="$SOURCES $srcdir/src/video/ipod/*.c"
925 fi
926}
927
928dnl Find the nanox include and library directories
929CheckNANOX()
930{
931 AC_ARG_ENABLE(video-nanox,
932 AC_HELP_STRING([--enable-video-nanox], [use nanox video driver [[default=no]]]),
933 , enable_video_nanox=no)
934
935 if test x$enable_video = xyes -a x$enable_video_nanox = xyes; then
936 AC_ARG_ENABLE(nanox-debug,
937 AC_HELP_STRING([--enable-nanox-debug], [print debug messages [[default=no]]]),
938 , enable_nanox_debug=no)
939 if test x$enable_nanox_debug = xyes; then
940 EXTRA_CFLAGS="$EXTRA_CFLAGS -DENABLE_NANOX_DEBUG"
941 fi
942
943 AC_ARG_ENABLE(nanox-share-memory,
944 AC_HELP_STRING([--enable-nanox-share-memory], [use share memory [[default=no]]]),
945 , enable_nanox_share_memory=no)
946 if test x$enable_nanox_share_memory = xyes; then
947 EXTRA_CFLAGS="$EXTRA_CFLAGS -DNANOX_SHARE_MEMORY"
948 fi
949
950 AC_ARG_ENABLE(nanox_direct_fb,
951 AC_HELP_STRING([--enable-nanox-direct-fb], [use direct framebuffer access [[default=no]]]),
952 , enable_nanox_direct_fb=no)
953 if test x$enable_nanox_direct_fb = xyes; then
954 EXTRA_CFLAGS="$EXTRA_CFLAGS -DENABLE_NANOX_DIRECT_FB"
955 fi
956
957 AC_DEFINE(SDL_VIDEO_DRIVER_NANOX)
958 SOURCES="$SOURCES $srcdir/src/video/nanox/*.c"
959 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lnano-X"
960 have_video=yes
961 fi
962}
963
964dnl Find the X11 include and library directories
965CheckX11()
966{
967 AC_ARG_ENABLE(video-x11,
968AC_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]),
969 , enable_video_x11=yes)
970 if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
971 case "$host" in
972 *-*-darwin*)
973 # This isn't necessary for X11, but fixes GLX detection
974 if test "x$x_includes" = xNONE && test "x$x_libraries" = xNONE; then
975 x_includes="/usr/X11R6/include"
976 x_libraries="/usr/X11R6/lib"
977 fi
978 ;;
979 esac
980 AC_PATH_X
981 AC_PATH_XTRA
982 if test x$have_x = xyes; then
983 # Only allow dynamically loaded X11 if the X11 function pointers
984 # will not end up in the global namespace, which causes problems
985 # with other libraries calling X11 functions.
986 x11_symbols_private=$have_gcc_fvisibility
987
988 AC_ARG_ENABLE(x11-shared,
989AC_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]),
990 , enable_x11_shared=maybe)
991
992 case "$host" in
993 *-*-darwin*) # Latest Mac OS X actually ships with Xrandr/Xrender libs...
994 x11_symbols_private=yes
995 x11_lib='/usr/X11R6/lib/libX11.6.dylib'
996 x11ext_lib='/usr/X11R6/lib/libXext.6.dylib'
997 xrender_lib='/usr/X11R6/lib/libXrender.1.dylib'
998 xrandr_lib='/usr/X11R6/lib/libXrandr.2.dylib'
999 ;;
1000 *-*-osf*)
1001 x11_lib='libX11.so'
1002 x11ext_lib='libXext.so'
1003 ;;
1004 *-*-irix*) # IRIX 6.5 requires that we use /usr/lib32
1005 x11_lib='libX11.so'
1006 x11ext_lib='libXext.so'
1007 ;;
1008 *)
1009 x11_lib=[`find_lib "libX11.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
1010 x11ext_lib=[`find_lib "libXext.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
1011 xrender_lib=[`find_lib "libXrender.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
1012 xrandr_lib=[`find_lib "libXrandr.so.*" "$X_LIBS -L/usr/X11/$base_libdir -L/usr/X11R6/$base_libdir" | sed 's/.*\/\(.*\)/\1/; q'`]
1013 ;;
1014 esac
1015
1016 X_CFLAGS="$X_CFLAGS -DXTHREADS"
1017 if test x$ac_cv_func_shmat != xyes; then
1018 X_CFLAGS="$X_CFLAGS -DNO_SHARED_MEMORY"
1019 fi
1020 CFLAGS="$CFLAGS $X_CFLAGS"
1021 LDFLAGS="$LDFLAGS $X_LIBS"
1022
1023 AC_DEFINE(SDL_VIDEO_DRIVER_X11)
1024 SOURCES="$SOURCES $srcdir/src/video/x11/*.c"
1025 EXTRA_CFLAGS="$EXTRA_CFLAGS $X_CFLAGS"
1026
1027 if test x$enable_x11_shared = xmaybe; then
1028 enable_x11_shared=$x11_symbols_private
1029 fi
1030 if test x$have_loadso != xyes && \
1031 test x$enable_x11_shared = xyes; then
1032 AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic X11 loading])
1033 enable_x11_shared=no
1034 fi
1035 if test x$x11_symbols_private != xyes && \
1036 test x$enable_x11_shared = xyes; then
1037 AC_MSG_WARN([You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading])
1038 enable_x11_shared=no
1039 fi
1040
1041 if test x$have_loadso = xyes && \
1042 test x$enable_x11_shared = xyes && test x$x11_lib != x && test x$x11ext_lib != x; then
1043 echo "-- dynamic libX11 -> $x11_lib"
1044 echo "-- dynamic libX11ext -> $x11ext_lib"
1045 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC, "$x11_lib")
1046 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT, "$x11ext_lib")
1047 else
1048 enable_x11_shared=no
1049 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $X_LIBS -lX11 -lXext"
1050 fi
1051 have_video=yes
1052
1053 AC_ARG_ENABLE(dga,
1054AC_HELP_STRING([--enable-dga], [allow use of X11 DGA code [[default=yes]]]),
1055 , enable_dga=yes)
1056 if test x$enable_dga = xyes; then
1057 SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86dga/*.c"
1058 fi
1059 AC_ARG_ENABLE(video-dga,
1060AC_HELP_STRING([--enable-video-dga], [use DGA 2.0 video driver [[default=yes]]]),
1061 , enable_video_dga=yes)
1062 if test x$enable_dga = xyes -a x$enable_video_dga = xyes; then
1063 AC_DEFINE(SDL_VIDEO_DRIVER_DGA)
1064 SOURCES="$SOURCES $srcdir/src/video/dga/*.c"
1065 fi
1066 AC_ARG_ENABLE(video-x11-dgamouse,
1067AC_HELP_STRING([--enable-video-x11-dgamouse], [use X11 DGA for mouse events [[default=yes]]]),
1068 , enable_video_x11_dgamouse=yes)
1069 if test x$enable_dga = xyes -a x$enable_video_x11_dgamouse = xyes; then
1070 AC_DEFINE(SDL_VIDEO_DRIVER_X11_DGAMOUSE)
1071 fi
1072 AC_ARG_ENABLE(video-x11-vm,
1073AC_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]),
1074 , enable_video_x11_vm=yes)
1075 if test x$enable_video_x11_vm = xyes; then
1076 AC_DEFINE(SDL_VIDEO_DRIVER_X11_VIDMODE)
1077 SOURCES="$SOURCES $srcdir/src/video/Xext/Xxf86vm/*.c"
1078 fi
1079 AC_ARG_ENABLE(video-x11-xv,
1080AC_HELP_STRING([--enable-video-x11-xv], [use X11 XvImage extension for video [[default=yes]]]),
1081 , enable_video_x11_xv=yes)
1082 if test x$enable_video_x11_xv = xyes; then
1083 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XV)
1084 SOURCES="$SOURCES $srcdir/src/video/Xext/Xv/*.c"
1085 fi
1086 AC_ARG_ENABLE(video-x11-xinerama,
1087AC_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]),
1088 , enable_video_x11_xinerama=yes)
1089 if test x$enable_video_x11_xinerama = xyes; then
1090 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINERAMA)
1091 SOURCES="$SOURCES $srcdir/src/video/Xext/Xinerama/*.c"
1092 fi
1093 AC_ARG_ENABLE(video-x11-xme,
1094AC_HELP_STRING([--enable-video-x11-xme], [enable Xi Graphics XME for fullscreen [[default=yes]]]),
1095 , enable_video_x11_xme=yes)
1096 if test x$enable_video_x11_xme = xyes; then
1097 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XME)
1098 SOURCES="$SOURCES $srcdir/src/video/Xext/XME/*.c"
1099 fi
1100 AC_ARG_ENABLE(video-x11-xrandr,
1101AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]),
1102 , enable_video_x11_xrandr=yes)
1103 if test x$enable_video_x11_xrandr = xyes; then
1104 definitely_enable_video_x11_xrandr=no
1105 AC_CHECK_HEADER(X11/extensions/Xrandr.h,
1106 have_xrandr_h_hdr=yes,
1107 have_xrandr_h_hdr=no,
1108 [#include <X11/Xlib.h>
1109 ])
1110 if test x$have_xrandr_h_hdr = xyes; then
1111 if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then
1112 echo "-- dynamic libXrender -> $xrender_lib"
1113 echo "-- dynamic libXrandr -> $xrandr_lib"
1114 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER, "$xrender_lib")
1115 AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR, "$xrandr_lib")
1116 definitely_enable_video_x11_xrandr=yes
1117 else
1118 AC_CHECK_LIB(Xrender, XRenderQueryExtension, have_xrender_lib=yes)
1119 AC_CHECK_LIB(Xrandr, XRRQueryExtension, have_xrandr_lib=yes)
1120 if test x$have_xrender_lib = xyes && test x$have_xrandr_lib = xyes ; then
1121 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lXrandr -lXrender"
1122 definitely_enable_video_x11_xrandr=yes
1123 fi
1124 fi
1125 fi
1126 fi
1127 if test x$definitely_enable_video_x11_xrandr = xyes; then
1128 AC_DEFINE(SDL_VIDEO_DRIVER_X11_XRANDR)
1129 fi
1130 fi
1131 fi
1132}
1133
1134dnl Check for QNX photon video driver
1135CheckPHOTON()
1136{
1137 AC_ARG_ENABLE(video-photon,
1138AC_HELP_STRING([--enable-video-photon], [use QNX Photon video driver [[default=yes]]]),
1139 , enable_video_photon=yes)
1140 if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
1141 AC_MSG_CHECKING(for QNX Photon support)
1142 video_photon=no
1143 AC_TRY_COMPILE([
1144 #include <Ph.h>
1145 #include <Pt.h>
1146 #include <photon/Pg.h>
1147 #include <photon/PdDirect.h>
1148 ],[
1149 PgDisplaySettings_t *visual;
1150 ],[
1151 video_photon=yes
1152 ])
1153 AC_MSG_RESULT($video_photon)
1154 if test x$video_photon = xyes; then
1155 AC_DEFINE(SDL_VIDEO_DRIVER_PHOTON)
1156 SOURCES="$SOURCES $srcdir/src/video/photon/*.c"
1157 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lph"
1158 have_video=yes
1159
1160 CheckOpenGLQNX
1161 fi
1162 fi
1163}
1164
1165dnl Set up the BWindow video driver if enabled
1166CheckBWINDOW()
1167{
1168 if test x$enable_video = xyes; then
1169 AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW)
1170 SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
1171 have_video=yes
1172 fi
1173}
1174
1175dnl Set up the Carbon/QuickDraw video driver for Mac OS X (but not Darwin)
1176CheckCARBON()
1177{
1178 AC_ARG_ENABLE(video-carbon,
1179AC_HELP_STRING([--enable-video-carbon], [use Carbon/QuickDraw video driver [[default=no]]]),
1180 , enable_video_carbon=no)
1181 if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
1182 AC_MSG_CHECKING(for Carbon framework)
1183 have_carbon=no
1184 AC_TRY_COMPILE([
1185 #include <Carbon/Carbon.h>
1186 ],[
1187 ],[
1188 have_carbon=yes
1189 ])
1190 AC_MSG_RESULT($have_carbon)
1191 if test x$have_carbon = xyes; then
1192 AC_DEFINE(SDL_VIDEO_DRIVER_TOOLBOX)
1193 SOURCES="$SOURCES $srcdir/src/video/maccommon/*.c"
1194 SOURCES="$SOURCES $srcdir/src/video/macrom/*.c"
1195 have_video=yes
1196 fi
1197 fi
1198}
1199
1200dnl Set up the Cocoa/Quartz video driver for Mac OS X (but not Darwin)
1201CheckCOCOA()
1202{
1203 AC_ARG_ENABLE(video-cocoa,
1204AC_HELP_STRING([--enable-video-cocoa], [use Cocoa/Quartz video driver [[default=yes]]]),
1205 , enable_video_cocoa=yes)
1206 if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
1207 save_CFLAGS="$CFLAGS"
1208 dnl work around that we don't have Objective-C support in autoconf
1209 CFLAGS="$CFLAGS -x objective-c"
1210 AC_MSG_CHECKING(for Cocoa framework)
1211 have_cocoa=no
1212 AC_TRY_COMPILE([
1213 #import <Cocoa/Cocoa.h>
1214 ],[
1215 ],[
1216 have_cocoa=yes
1217 ])
1218 AC_MSG_RESULT($have_cocoa)
1219 CFLAGS="$save_CFLAGS"
1220 if test x$have_cocoa = xyes; then
1221 AC_DEFINE(SDL_VIDEO_DRIVER_QUARTZ)
1222 SOURCES="$SOURCES $srcdir/src/video/quartz/*.m"
1223 have_video=yes
1224 fi
1225 fi
1226}
1227
1228dnl Find the framebuffer console includes
1229CheckFBCON()
1230{
1231 AC_ARG_ENABLE(video-fbcon,
1232AC_HELP_STRING([--enable-video-fbcon], [use framebuffer console video driver [[default=yes]]]),
1233 , enable_video_fbcon=yes)
1234 if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
1235 AC_MSG_CHECKING(for framebuffer console support)
1236 video_fbcon=no
1237 AC_TRY_COMPILE([
1238 #include <linux/fb.h>
1239 #include <linux/kd.h>
1240 #include <linux/keyboard.h>
1241 ],[
1242 ],[
1243 video_fbcon=yes
1244 ])
1245 AC_MSG_RESULT($video_fbcon)
1246 if test x$video_fbcon = xyes; then
1247 AC_CHECK_FUNCS(getpagesize)
1248 AC_DEFINE(SDL_VIDEO_DRIVER_FBCON)
1249 SOURCES="$SOURCES $srcdir/src/video/fbcon/*.c"
1250 have_video=yes
1251 fi
1252 fi
1253}
1254
1255dnl Find DirectFB
1256CheckDirectFB()
1257{
1258 AC_ARG_ENABLE(video-directfb,
1259AC_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=yes]]]),
1260 , enable_video_directfb=yes)
1261 if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then
1262 video_directfb=no
1263
1264 DIRECTFB_REQUIRED_VERSION=0.9.15
1265
1266 AC_PATH_PROG(DIRECTFBCONFIG, directfb-config, no)
1267 if test x$DIRECTFBCONFIG = xno; then
1268 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1269 if test x$PKG_CONFIG != xno; then
1270 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb; then
1271 DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
1272 DIRECTFB_LIBS=`$PKG_CONFIG --libs directfb`
1273 video_directfb=yes
1274 fi
1275 fi
1276 else
1277 set -- `echo $DIRECTFB_REQUIRED_VERSION | sed 's/\./ /g'`
1278 NEED_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
1279 set -- `directfb-config --version | sed 's/\./ /g'`
1280 HAVE_VERSION=`expr $1 \* 10000 + $2 \* 100 + $3`
1281 if test $HAVE_VERSION -ge $NEED_VERSION; then
1282 DIRECTFB_CFLAGS=`$DIRECTFBCONFIG --cflags`
1283 DIRECTFB_LIBS=`$DIRECTFBCONFIG --libs`
1284 video_directfb=yes
1285 fi
1286 fi
1287 if test x$video_directfb = xyes; then
1288 # SuSE 11.1 installs directfb-config without directfb-devel
1289 save_CFLAGS="$CFLAGS"
1290 CFLAGS="$CFLAGS $DIRECTFB_CFLAGS"
1291 AC_CHECK_HEADER(directfb.h, have_directfb_hdr=yes, have_directfb_hdr=no)
1292 CFLAGS="$save_CFLAGS"
1293 video_directfb=$have_directfb_hdr
1294 fi
1295 AC_MSG_CHECKING(for DirectFB $DIRECTFB_REQUIRED_VERSION support)
1296 AC_MSG_RESULT($video_directfb)
1297
1298 if test x$video_directfb = xyes; then
1299 AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB)
1300 SOURCES="$SOURCES $srcdir/src/video/directfb/*.c"
1301 EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS"
1302 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS"
1303 have_video=yes
1304 fi
1305 fi
1306}
1307
1308dnl See if we're running on PlayStation 2 hardware
1309CheckPS2GS()
1310{
1311 AC_ARG_ENABLE(video-ps2gs,
1312AC_HELP_STRING([--enable-video-ps2gs], [use PlayStation 2 GS video driver [[default=yes]]]),
1313 , enable_video_ps2gs=yes)
1314 if test x$enable_video = xyes -a x$enable_video_ps2gs = xyes; then
1315 AC_MSG_CHECKING(for PlayStation 2 GS support)
1316 video_ps2gs=no
1317 AC_TRY_COMPILE([
1318 #include <linux/ps2/dev.h>
1319 #include <linux/ps2/gs.h>
1320 ],[
1321 ],[
1322 video_ps2gs=yes
1323 ])
1324 AC_MSG_RESULT($video_ps2gs)
1325 if test x$video_ps2gs = xyes; then
1326 AC_DEFINE(SDL_VIDEO_DRIVER_PS2GS)
1327 SOURCES="$SOURCES $srcdir/src/video/ps2gs/*.c"
1328 have_video=yes
1329 fi
1330 fi
1331}
1332
1333dnl See if we're running on PlayStation 3 Cell hardware
1334CheckPS3()
1335{
1336 AC_ARG_ENABLE(video-ps3,
1337 AC_HELP_STRING([--enable-video-ps3], [use PlayStation 3 Cell driver [[default=yes]]]),
1338 , enable_video_ps3=yes)
1339 if test x$enable_video = xyes -a x$enable_video_ps3 = xyes; then
1340 AC_MSG_CHECKING(for PlayStation 3 Cell support)
1341 video_ps3=no
1342 AC_TRY_COMPILE([
1343 #include <linux/fb.h>
1344 #include <asm/ps3fb.h>
1345 #include <libspe2.h>
1346 ],[
1347 ],[
1348 video_ps3=yes
1349 ])
1350 AC_MSG_RESULT($video_ps3)
1351 if test x$video_ps3 = xyes; then
1352 AC_DEFINE(SDL_VIDEO_DRIVER_PS3)
1353 SOURCES="$SOURCES $srcdir/src/video/ps3/*.c"
1354 EXTRA_CFLAGS="$EXTRA_CFLAGS -I/opt/cell/sdk/usr/include"
1355 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lbilin_scaler_spu -lfb_writer_spu -lyuv2rgb_spu -L/opt/cell/sdk/usr/lib -lspe2"
1356 have_video=yes
1357 fi
1358 fi
1359}
1360
1361dnl Find the GGI includes
1362CheckGGI()
1363{
1364 AC_ARG_ENABLE(video-ggi,
1365AC_HELP_STRING([--enable-video-ggi], [use GGI video driver [[default=no]]]),
1366 , enable_video_ggi=no)
1367 if test x$enable_video = xyes -a x$enable_video_ggi = xyes; then
1368 AC_MSG_CHECKING(for GGI support)
1369 video_ggi=no
1370 AC_TRY_COMPILE([
1371 #include <ggi/ggi.h>
1372 #include <ggi/gii.h>
1373 ],[
1374 ],[
1375 video_ggi=yes
1376 ])
1377 AC_MSG_RESULT($video_ggi)
1378 if test x$video_ggi = xyes; then
1379 AC_DEFINE(SDL_VIDEO_DRIVER_GGI)
1380 SOURCES="$SOURCES $srcdir/src/video/ggi/*.c"
1381 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lggi -lgii -lgg"
1382 have_video=yes
1383 fi
1384 fi
1385}
1386
1387dnl Find the SVGAlib includes and libraries
1388CheckSVGA()
1389{
1390 AC_ARG_ENABLE(video-svga,
1391AC_HELP_STRING([--enable-video-svga], [use SVGAlib video driver [[default=yes]]]),
1392 , enable_video_svga=yes)
1393 if test x$enable_video = xyes -a x$enable_video_svga = xyes; then
1394 AC_MSG_CHECKING(for SVGAlib (1.4.0+) support)
1395 video_svga=no
1396 AC_TRY_COMPILE([
1397 #include <vga.h>
1398 #include <vgamouse.h>
1399 #include <vgakeyboard.h>
1400 ],[
1401 if ( SCANCODE_RIGHTWIN && SCANCODE_LEFTWIN ) {
1402 exit(0);
1403 }
1404 ],[
1405 video_svga=yes
1406 ])
1407 AC_MSG_RESULT($video_svga)
1408 if test x$video_svga = xyes; then
1409 AC_DEFINE(SDL_VIDEO_DRIVER_SVGALIB)
1410 SOURCES="$SOURCES $srcdir/src/video/svga/*.c"
1411 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvga"
1412 have_video=yes
1413 fi
1414 fi
1415}
1416
1417dnl Find the VGL includes and libraries
1418CheckVGL()
1419{
1420 AC_ARG_ENABLE(video-vgl,
1421AC_HELP_STRING([--enable-video-vgl], [use VGL video driver [[default=yes]]]),
1422 , enable_video_vgl=yes)
1423 if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
1424 AC_MSG_CHECKING(for libVGL support)
1425 video_vgl=no
1426 AC_TRY_COMPILE([
1427 #include <sys/fbio.h>
1428 #include <sys/consio.h>
1429 #include <sys/kbio.h>
1430 #include <vgl.h>
1431 ],[
1432 VGLBitmap bitmap;
1433 bitmap.Type = VIDBUF32;
1434 bitmap.PixelBytes = 4;
1435 exit(bitmap.Bitmap);
1436 ],[
1437 video_vgl=yes
1438 ])
1439 AC_MSG_RESULT($video_vgl)
1440 if test x$video_vgl = xyes; then
1441 AC_DEFINE(SDL_VIDEO_DRIVER_VGL)
1442 SOURCES="$SOURCES $srcdir/src/video/vgl/*.c"
1443 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvgl"
1444 have_video=yes
1445 fi
1446 fi
1447}
1448
1449dnl Set up the wscons video driver if enabled
1450CheckWscons()
1451{
1452 AC_ARG_ENABLE(video-wscons,
1453AC_HELP_STRING([--enable-video-wscons], [use wscons video driver [[default=yes]]]),
1454 , enable_video_wscons=yes)
1455 if test x$enable_video = xyes -a x$enable_video_wscons = xyes; then
1456 AC_MSG_CHECKING(for wscons support)
1457 video_wscons=no
1458 AC_TRY_COMPILE([
1459 #include <sys/time.h>
1460 #include <dev/wscons/wsconsio.h>
1461 #include <dev/wscons/wsdisplay_usl_io.h>
1462 ],[
1463 int wsmode = WSDISPLAYIO_MODE_DUMBFB;
1464 ],[
1465 video_wscons=yes
1466 ])
1467 AC_MSG_RESULT($video_wscons)
1468 if test x$video_wscons = xyes; then
1469 AC_DEFINE(SDL_VIDEO_DRIVER_WSCONS)
1470 SOURCES="$SOURCES $srcdir/src/video/wscons/*.c"
1471 have_video=yes
1472 fi
1473 fi
1474}
1475
1476
1477dnl Find the AAlib includes
1478CheckAAlib()
1479{
1480 AC_ARG_ENABLE(video-aalib,
1481AC_HELP_STRING([--enable-video-aalib], [use AAlib video driver [[default=no]]]),
1482 , enable_video_aalib=no)
1483 if test x$enable_video = xyes -a x$enable_video_aalib = xyes; then
1484 AC_MSG_CHECKING(for AAlib support)
1485 video_aalib=no
1486 AC_TRY_COMPILE([
1487 #include <aalib.h>
1488 ],[
1489 ],[
1490 video_aalib=yes
1491 ])
1492 AC_MSG_RESULT($video_aalib)
1493 if test x$video_aalib = xyes; then
1494 AC_DEFINE(SDL_VIDEO_DRIVER_AALIB)
1495 SOURCES="$SOURCES $srcdir/src/video/aalib/*.c"
1496 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -laa"
1497 have_video=yes
1498 fi
1499 fi
1500}
1501
1502dnl Find the libcaca includes
1503CheckCaca()
1504{
1505 AC_ARG_ENABLE(video-caca,
1506AC_HELP_STRING([--enable-video-caca], [use libcaca video driver [[default=no]]]),
1507 , enable_video_caca=no)
1508 if test x$enable_video = xyes -a x$enable_video_caca = xyes; then
1509 video_caca=no
1510 AC_PATH_PROG(CACACONFIG, caca-config, no)
1511 if test x$CACACONFIG != xno; then
1512 AC_MSG_CHECKING(for libcaca support)
1513 CACA_CFLAGS=`$CACACONFIG --cflags`
1514 CACA_LDFLAGS=`$CACACONFIG --libs`
1515 save_CFLAGS="$CFLAGS"
1516 AC_TRY_COMPILE([
1517 #include <caca.h>
1518 ],[
1519 ],[
1520 video_caca=yes
1521 ])
1522 CFLAGS="$save_CFLAGS"
1523 AC_MSG_RESULT($video_caca)
1524 if test x$video_caca = xyes; then
1525 AC_DEFINE(SDL_VIDEO_DRIVER_CACA)
1526 EXTRA_CFLAGS="$EXTRA_CFLAGS $CACA_CFLAGS"
1527 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $CACA_LDFLAGS"
1528 SOURCES="$SOURCES $srcdir/src/video/caca/*.c"
1529 fi
1530 fi
1531 fi
1532}
1533
1534dnl Set up the QTopia video driver if enabled
1535CheckQtopia()
1536{
1537 AC_ARG_ENABLE(video-qtopia,
1538AC_HELP_STRING([--enable-video-qtopia], [use Qtopia video driver [[default=no]]]),
1539 , enable_video_qtopia=no)
1540 if test x$enable_video = xyes -a x$enable_video_qtopia = xyes; then
1541 AC_MSG_CHECKING(for Qtopia support)
1542 video_qtopia=no
1543 QTOPIA_FLAGS="-DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -I${QPEDIR}/include -I${QTDIR}/include/ -DNO_DEBUG -fno-rtti -fno-exceptions"
1544 AC_LANG_CPLUSPLUS
1545 OLD_CXX="$CXXFLAGS"
1546 CXXFLAGS="$QTOPIA_FLAGS"
1547 AC_TRY_COMPILE([
1548 #include <qpe/qpeapplication.h>
1549 ],[
1550 ],[
1551 video_qtopia=yes
1552 ])
1553 CXXFLAGS="$OLD_CXX"
1554 AC_MSG_RESULT($video_qtopia)
1555 if test x$video_qtopia = xyes; then
1556 AC_DEFINE(SDL_VIDEO_DRIVER_QTOPIA)
1557 SOURCES="$SOURCES $srcdir/src/video/qtopia/*.cc"
1558 SDLMAIN_SOURCES="$srcdir/src/main/qtopia/*.cc"
1559 SDLMAIN_LDFLAGS="-static"
1560 EXTRA_CFLAGS="$EXTRA_CFLAGS $QTOPIA_FLAGS"
1561 SDL_CFLAGS="$SDL_CFLAGS -DQWS -Dmain=SDL_main"
1562 SDL_LIBS="-lSDLmain $SDL_LIBS -L${QPEDIR}/lib -L${QTDIR}/lib/ -lqpe -lqte"
1563 have_video=yes
1564 fi
1565 AC_LANG_C
1566 fi
1567}
1568
1569dnl Set up the PicoGUI video driver if enabled
1570CheckPicoGUI()
1571{
1572 AC_ARG_ENABLE(video-picogui,
1573AC_HELP_STRING([--enable-video-picogui], [use PicoGUI video driver [[default=no]]]),
1574 , enable_video_picogui=no)
1575 if test x$enable_video = xyes -a x$enable_video_picogui = xyes; then
1576 AC_MSG_CHECKING(for PicoGUI support)
1577 video_picogui=no
1578 AC_TRY_COMPILE([
1579 #include <picogui.h>
1580 ],[
1581 ],[
1582 video_picogui=yes
1583 ])
1584 AC_MSG_RESULT($video_picogui)
1585 if test x$video_picogui = xyes; then
1586 AC_DEFINE(SDL_VIDEO_DRIVER_PICOGUI)
1587 SOURCES="$SOURCES $srcdir/src/video/picogui/*.c"
1588 SDL_LIBS="$SDL_LIBS -lpgui"
1589 have_video=yes
1590 fi
1591 fi
1592}
1593
1594dnl Set up the Atari Bios keyboard driver
1595CheckAtariBiosEvent()
1596{
1597 SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.c"
1598 SOURCES="$SOURCES $srcdir/src/video/ataricommon/*.S"
1599}
1600
1601dnl Set up the Atari Xbios driver
1602CheckAtariXbiosVideo()
1603{
1604 AC_ARG_ENABLE(xbios,
1605AC_HELP_STRING([--enable-video-xbios], [use Atari Xbios video driver [[default=yes]]]),
1606 , enable_video_xbios=yes)
1607 video_xbios=no
1608 if test x$enable_video = xyes -a x$enable_video_xbios = xyes; then
1609 video_xbios=yes
1610 AC_DEFINE(SDL_VIDEO_DRIVER_XBIOS)
1611 SOURCES="$SOURCES $srcdir/src/video/xbios/*.c"
1612 have_video=yes
1613 fi
1614}
1615
1616dnl Set up the Atari Gem driver
1617CheckAtariGemVideo()
1618{
1619 AC_ARG_ENABLE(gem,
1620AC_HELP_STRING([--enable-video-gem], [use Atari Gem video driver [[default=yes]]]),
1621 , enable_video_gem=yes)
1622 if test x$enable_video = xyes -a x$enable_video_gem = xyes; then
1623 video_gem=no
1624 AC_CHECK_HEADER(gem.h, have_gem_hdr=yes)
1625 AC_CHECK_LIB(gem, appl_init, have_gem_lib=yes)
1626 if test x$have_gem_hdr = xyes -a x$have_gem_lib = xyes; then
1627 video_gem=yes
1628 AC_DEFINE(SDL_VIDEO_DRIVER_GEM)
1629 SOURCES="$SOURCES $srcdir/src/video/gem/*.c"
1630 SDL_LIBS="$SDL_LIBS -lgem"
1631 have_video=yes
1632 fi
1633 fi
1634}
1635
1636dnl rcg04172001 Set up the Null video driver.
1637CheckDummyVideo()
1638{
1639 AC_ARG_ENABLE(video-dummy,
1640AC_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]),
1641 , enable_video_dummy=yes)
1642 if test x$enable_video_dummy = xyes; then
1643 AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY)
1644 SOURCES="$SOURCES $srcdir/src/video/dummy/*.c"
1645 have_video=yes
1646 fi
1647}
1648
1649dnl Check to see if OpenGL support is desired
1650AC_ARG_ENABLE(video-opengl,
1651AC_HELP_STRING([--enable-video-opengl], [include OpenGL context creation [[default=yes]]]),
1652 , enable_video_opengl=yes)
1653
1654dnl Find OpenGL
1655CheckOpenGLX11()
1656{
1657 if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
1658 AC_MSG_CHECKING(for OpenGL (GLX) support)
1659 video_opengl=no
1660 AC_TRY_COMPILE([
1661 #include <GL/gl.h>
1662 #include <GL/glx.h>
1663 #include <GL/glu.h>
1664 ],[
1665 ],[
1666 video_opengl=yes
1667 ])
1668 AC_MSG_RESULT($video_opengl)
1669 if test x$video_opengl = xyes; then
1670 AC_DEFINE(SDL_VIDEO_OPENGL)
1671 AC_DEFINE(SDL_VIDEO_OPENGL_GLX)
1672 fi
1673 fi
1674}
1675
1676dnl Find QNX RtP OpenGL
1677CheckOpenGLQNX()
1678{
1679 if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
1680 AC_MSG_CHECKING(for OpenGL (Photon) support)
1681 video_opengl=no
1682 AC_TRY_COMPILE([
1683 #include <GL/gl.h>
1684 ],[
1685 ],[
1686 video_opengl=yes
1687 ])
1688 AC_MSG_RESULT($video_opengl)
1689 if test x$video_opengl = xyes; then
1690 AC_DEFINE(SDL_VIDEO_OPENGL)
1691 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
1692 fi
1693 fi
1694}
1695
1696dnl Check for Win32 OpenGL
1697CheckWIN32GL()
1698{
1699 if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
1700 AC_DEFINE(SDL_VIDEO_OPENGL)
1701 AC_DEFINE(SDL_VIDEO_OPENGL_WGL)
1702 fi
1703}
1704
1705dnl Check for BeOS OpenGL
1706CheckBeGL()
1707{
1708 if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
1709 AC_DEFINE(SDL_VIDEO_OPENGL)
1710 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
1711 fi
1712}
1713
1714dnl Check for MacOS OpenGL
1715CheckMacGL()
1716{
1717 if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
1718 AC_DEFINE(SDL_VIDEO_OPENGL)
1719 case "$host" in
1720 *-*-darwin*)
1721 if test x$enable_video_cocoa = xyes; then
1722 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,OpenGL"
1723 fi
1724 if test x$enable_video_carbon = xyes; then
1725 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AGL"
1726 fi
1727 esac
1728 fi
1729}
1730
1731dnl Check for Mesa offscreen rendering
1732CheckAtariOSMesa()
1733{
1734 if test "x$enable_video" = "xyes" -a "x$enable_video_opengl" = "xyes"; then
1735 AC_CHECK_HEADER(GL/osmesa.h, have_osmesa_hdr=yes)
1736 AC_CHECK_LIB(OSMesa, OSMesaCreateContext, have_osmesa_lib=yes, have_osmesa_lib=no, -lm)
1737
1738 # Static linking to -lOSMesa
1739 AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
1740 if test "x$OSMESA_CONFIG" = "xno" -o "x$enable_atari_ldg" = "xno"; then
1741 # -lOSMesa is really the static library
1742 if test "x$have_osmesa_hdr" = "xyes" -a "x$have_osmesa_lib" = "xyes"; then
1743 OSMESA_LIBS="-lOSMesa"
1744 fi
1745 else
1746 # -lOSMesa is a loader for OSMesa.ldg
1747 OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
1748 OSMESA_LIBS=`$OSMESA_CONFIG --libs`
1749 fi
1750 AC_DEFINE(SDL_VIDEO_OPENGL)
1751 AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA)
1752 SDL_CFLAGS="$SDL_CFLAGS $OSMESA_CFLAGS"
1753 SDL_LIBS="$SDL_LIBS $OSMESA_LIBS"
1754
1755 AC_ARG_ENABLE(osmesa-shared,
1756AC_HELP_STRING([--enable-osmesa-shared], [dynamically load OSMesa OpenGL support [[default=yes]]]),
1757 , enable_osmesa_shared=yes)
1758 if test "x$enable_osmesa_shared" = "xyes" -a "x$enable_atari_ldg" = "xyes"; then
1759 # Dynamic linking
1760 if test "x$have_osmesa_hdr" = "xyes"; then
1761 AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA_DYNAMIC)
1762 fi
1763 fi
1764 fi
1765}
1766
1767AC_ARG_ENABLE(screensaver,
1768AC_HELP_STRING([--enable-screensaver], [enable screensaver by default while any SDL application is running [[default=no]]]),
1769 , enable_screensaver=no)
1770if test x$enable_screensaver = xno; then
1771 AC_DEFINE(SDL_VIDEO_DISABLE_SCREENSAVER)
1772fi
1773
1774dnl See if we can use the new unified event interface in Linux 2.4
1775CheckInputEvents()
1776{
1777 dnl Check for Linux 2.4 unified input event interface support
1778 AC_ARG_ENABLE(input-events,
1779AC_HELP_STRING([--enable-input-events], [use Linux 2.4 unified input interface [[default=yes]]]),
1780 , enable_input_events=yes)
1781 if test x$enable_input_events = xyes; then
1782 AC_MSG_CHECKING(for Linux 2.4 unified input interface)
1783 use_input_events=no
1784 AC_TRY_COMPILE([
1785 #include <linux/input.h>
1786 ],[
1787 #ifndef EVIOCGNAME
1788 #error EVIOCGNAME() ioctl not available
1789 #endif
1790 ],[
1791 use_input_events=yes
1792 ])
1793 AC_MSG_RESULT($use_input_events)
1794 if test x$use_input_events = xyes; then
1795 AC_DEFINE(SDL_INPUT_LINUXEV)
1796 fi
1797 fi
1798}
1799
1800dnl See if we can use the Touchscreen input library
1801CheckTslib()
1802{
1803 AC_ARG_ENABLE(input-tslib,
1804AC_HELP_STRING([--enable-input-tslib], [use the Touchscreen library for input [[default=yes]]]),
1805 , enable_input_tslib=yes)
1806 if test x$enable_input_tslib = xyes; then
1807 AC_MSG_CHECKING(for Touchscreen library support)
1808 enable_input_tslib=no
1809 AC_TRY_COMPILE([
1810 #include "tslib.h"
1811 ],[
1812 ],[
1813 enable_input_tslib=yes
1814 ])
1815 AC_MSG_RESULT($enable_input_tslib)
1816 if test x$enable_input_tslib = xyes; then
1817 AC_DEFINE(SDL_INPUT_TSLIB)
1818 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lts"
1819 fi
1820 fi
1821}
1822
1823dnl See if we can use GNU pth library for threads
1824CheckPTH()
1825{
1826 dnl Check for pth support
1827 AC_ARG_ENABLE(pth,
1828AC_HELP_STRING([--enable-pth], [use GNU pth library for multi-threading [[default=yes]]]),
1829 , enable_pth=yes)
1830 if test x$enable_threads = xyes -a x$enable_pth = xyes; then
1831 AC_PATH_PROG(PTH_CONFIG, pth-config, no)
1832 if test "$PTH_CONFIG" = "no"; then
1833 use_pth=no
1834 else
1835 use_pth=yes
1836 fi
1837 AC_MSG_CHECKING(pth)
1838 AC_MSG_RESULT($use_pth)
1839 if test "x$use_pth" = xyes; then
1840 AC_DEFINE(SDL_THREAD_PTH)
1841 SOURCES="$SOURCES $srcdir/src/thread/pth/*.c"
1842 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
1843 SDL_CFLAGS="$SDL_CFLAGS `$PTH_CONFIG --cflags`"
1844 SDL_LIBS="$SDL_LIBS `$PTH_CONFIG --libs --all`"
1845 have_threads=yes
1846 fi
1847 fi
1848}
1849
1850dnl See what type of thread model to use on Linux and Solaris
1851CheckPTHREAD()
1852{
1853 dnl Check for pthread support
1854 AC_ARG_ENABLE(pthreads,
1855AC_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]),
1856 , enable_pthreads=yes)
1857 dnl This is used on Linux for glibc binary compatibility (Doh!)
1858 AC_ARG_ENABLE(pthread-sem,
1859AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]),
1860 , enable_pthread_sem=yes)
1861 case "$host" in
1862 *-*-linux*|*-*-uclinux*)
1863 pthread_cflags="-D_REENTRANT"
1864 pthread_lib="-lpthread"
1865 ;;
1866 *-*-bsdi*)
1867 pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
1868 pthread_lib=""
1869 ;;
1870 *-*-darwin*)
1871 pthread_cflags="-D_THREAD_SAFE"
1872# causes Carbon.p complaints?
1873# pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
1874 ;;
1875 *-*-freebsd*|*-*-dragonfly*)
1876 pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
1877 pthread_lib="-pthread"
1878 ;;
1879 *-*-netbsd*)
1880 pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
1881 pthread_lib="-lpthread"
1882 ;;
1883 *-*-openbsd*)
1884 pthread_cflags="-D_REENTRANT"
1885 pthread_lib="-pthread"
1886 ;;
1887 *-*-solaris*)
1888 pthread_cflags="-D_REENTRANT"
1889 pthread_lib="-lpthread -lposix4"
1890 ;;
1891 *-*-sysv5*)
1892 pthread_cflags="-D_REENTRANT -Kthread"
1893 pthread_lib=""
1894 ;;
1895 *-*-irix*)
1896 pthread_cflags="-D_SGI_MP_SOURCE"
1897 pthread_lib="-lpthread"
1898 ;;
1899 *-*-aix*)
1900 pthread_cflags="-D_REENTRANT -mthreads"
1901 pthread_lib="-lpthread"
1902 ;;
1903 *-*-hpux11*)
1904 pthread_cflags="-D_REENTRANT"
1905 pthread_lib="-L/usr/lib -lpthread"
1906 ;;
1907 *-*-qnx*)
1908 pthread_cflags=""
1909 pthread_lib=""
1910 ;;
1911 *-*-osf*)
1912 pthread_cflags="-D_REENTRANT"
1913 if test x$ac_cv_prog_gcc = xyes; then
1914 pthread_lib="-lpthread -lrt"
1915 else
1916 pthread_lib="-lpthread -lexc -lrt"
1917 fi
1918 ;;
1919 *)
1920 pthread_cflags="-D_REENTRANT"
1921 pthread_lib="-lpthread"
1922 ;;
1923 esac
1924 if test x$enable_threads = xyes -a x$enable_pthreads = xyes -a x$enable_ipod != xyes; then
1925 # Save the original compiler flags and libraries
1926 ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
1927 # Add the pthread compiler flags and libraries
1928 CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
1929 # Check to see if we have pthread support on this system
1930 AC_MSG_CHECKING(for pthreads)
1931 use_pthreads=no
1932 AC_TRY_LINK([
1933 #include <pthread.h>
1934 ],[
1935 pthread_attr_t type;
1936 pthread_attr_init(&type);
1937 ],[
1938 use_pthreads=yes
1939 ])
1940 AC_MSG_RESULT($use_pthreads)
1941 # Restore the compiler flags and libraries
1942 CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
1943
1944 # Do futher testing if we have pthread support...
1945 if test x$use_pthreads = xyes; then
1946 AC_DEFINE(SDL_THREAD_PTHREAD)
1947 EXTRA_CFLAGS="$EXTRA_CFLAGS $pthread_cflags"
1948 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $pthread_lib"
1949 SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
1950 SDL_LIBS="$SDL_LIBS $pthread_lib"
1951
1952 # Save the original compiler flags and libraries
1953 ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
1954 # Add the pthread compiler flags and libraries
1955 CFLAGS="$CFLAGS $pthread_cflags"; LIBS="$LIBS $pthread_lib"
1956
1957 # Check to see if recursive mutexes are available
1958 AC_MSG_CHECKING(for recursive mutexes)
1959 has_recursive_mutexes=no
1960 if test x$has_recursive_mutexes = xno; then
1961 AC_TRY_COMPILE([
1962 #include <pthread.h>
1963 ],[
1964 pthread_mutexattr_t attr;
1965 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
1966 ],[
1967 has_recursive_mutexes=yes
1968 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX)
1969 ])
1970 fi
1971 if test x$has_recursive_mutexes = xno; then
1972 AC_TRY_COMPILE([
1973 #include <pthread.h>
1974 ],[
1975 pthread_mutexattr_t attr;
1976 pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
1977 ],[
1978 has_recursive_mutexes=yes
1979 AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)
1980 ])
1981 fi
1982 AC_MSG_RESULT($has_recursive_mutexes)
1983
1984 # Check to see if pthread semaphore support is missing
1985 if test x$enable_pthread_sem = xyes; then
1986 AC_MSG_CHECKING(for pthread semaphores)
1987 have_pthread_sem=no
1988 AC_TRY_COMPILE([
1989 #include <pthread.h>
1990 #include <semaphore.h>
1991 ],[
1992 ],[
1993 have_pthread_sem=yes
1994 ])
1995 AC_MSG_RESULT($have_pthread_sem)
1996 fi
1997 if test x$have_pthread_sem = xyes; then
1998 AC_MSG_CHECKING(for sem_timedwait)
1999 have_sem_timedwait=no
2000 AC_TRY_LINK([
2001 #include <pthread.h>
2002 #include <semaphore.h>
2003 ],[
2004 sem_timedwait(NULL, NULL);
2005 ],[
2006 have_sem_timedwait=yes
2007 AC_DEFINE(HAVE_SEM_TIMEDWAIT)
2008 ])
2009 AC_MSG_RESULT($have_sem_timedwait)
2010 fi
2011
2012 # Restore the compiler flags and libraries
2013 CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
2014
2015 # Basic thread creation functions
2016 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_systhread.c"
2017
2018 # Semaphores
2019 # We can fake these with mutexes and condition variables if necessary
2020 if test x$have_pthread_sem = xyes; then
2021 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syssem.c"
2022 else
2023 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syssem.c"
2024 fi
2025
2026 # Mutexes
2027 # We can fake these with semaphores if necessary
2028 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_sysmutex.c"
2029
2030 # Condition variables
2031 # We can fake these with semaphores and mutexes if necessary
2032 SOURCES="$SOURCES $srcdir/src/thread/pthread/SDL_syscond.c"
2033
2034 have_threads=yes
2035 else
2036 CheckPTH
2037 fi
2038 fi
2039}
2040
2041dnl Determine whether the compiler can produce Win32 executables
2042CheckWIN32()
2043{
2044 AC_MSG_CHECKING(Win32 compiler)
2045 have_win32_gcc=no
2046 AC_TRY_COMPILE([
2047 #include <windows.h>
2048 ],[
2049 ],[
2050 have_win32_gcc=yes
2051 ])
2052 AC_MSG_RESULT($have_win32_gcc)
2053 if test x$have_win32_gcc != xyes; then
2054 AC_MSG_ERROR([
2055*** Your compiler ($CC) does not produce Win32 executables!
2056 ])
2057 fi
2058
2059 dnl See if the user wants to redirect standard output to files
2060 AC_ARG_ENABLE(stdio-redirect,
2061AC_HELP_STRING([--enable-stdio-redirect], [Redirect STDIO to files on Win32 [[default=yes]]]),
2062 , enable_stdio_redirect=yes)
2063 if test x$enable_stdio_redirect != xyes; then
2064 EXTRA_CFLAGS="$EXTRA_CFLAGS -DNO_STDIO_REDIRECT"
2065 fi
2066
2067 if test x$enable_video = xyes; then
2068 AC_DEFINE(SDL_VIDEO_DRIVER_WINDIB)
2069 SOURCES="$SOURCES $srcdir/src/video/wincommon/*.c"
2070 SOURCES="$SOURCES $srcdir/src/video/windib/*.c"
2071 have_video=yes
2072 fi
2073}
2074
2075dnl Find the DirectX includes and libraries
2076CheckDIRECTX()
2077{
2078 AC_ARG_ENABLE(directx,
2079AC_HELP_STRING([--enable-directx], [use DirectX for Win32 audio/video [[default=yes]]]),
2080 , enable_directx=yes)
2081 if test x$enable_directx = xyes; then
2082 have_directx=no
2083 AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
2084 AC_CHECK_HEADER(dsound.h, have_dsound=yes)
2085 AC_CHECK_HEADER(dinput.h, use_dinput=yes)
2086 if test x$have_ddraw = xyes -a x$have_dsound = xyes -a x$use_dinput = xyes; then
2087 have_directx=yes
2088 fi
2089 if test x$enable_video = xyes -a x$have_directx = xyes; then
2090 AC_DEFINE(SDL_VIDEO_DRIVER_DDRAW)
2091 SOURCES="$SOURCES $srcdir/src/video/windx5/*.c"
2092 have_video=yes
2093 fi
2094 fi
2095}
2096
2097dnl Check for the dlfcn.h interface for dynamically loading objects
2098CheckDLOPEN()
2099{
2100 AC_ARG_ENABLE(sdl-dlopen,
2101AC_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]),
2102 , enable_sdl_dlopen=yes)
2103 if test x$enable_sdl_dlopen = xyes; then
2104 AC_MSG_CHECKING(for dlopen)
2105 have_dlopen=no
2106 AC_TRY_COMPILE([
2107 #include <dlfcn.h>
2108 ],[
2109 #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
2110 #error Use dlcompat for Mac OS X 10.2 compatibility
2111 #endif
2112 ],[
2113 have_dlopen=yes
2114 ])
2115 AC_MSG_RESULT($have_dlopen)
2116
2117 if test x$have_dlopen = xyes; then
2118 AC_CHECK_LIB(c, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS",
2119 AC_CHECK_LIB(dl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl",
2120 AC_CHECK_LIB(ltdl, dlopen, EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lltdl")))
2121 AC_DEFINE(SDL_LOADSO_DLOPEN)
2122 SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
2123 have_loadso=yes
2124 fi
2125 fi
2126}
2127
2128dnl Set up the Atari LDG (shared object loader)
2129CheckAtariLdg()
2130{
2131 AC_ARG_ENABLE(atari-ldg,
2132AC_HELP_STRING([--enable-atari-ldg], [use Atari LDG for shared object loading [[default=yes]]]),
2133 , enable_atari_ldg=yes)
2134 if test x$video_gem = xyes -a x$enable_atari_ldg = xyes; then
2135 AC_CHECK_HEADER(ldg.h, have_ldg_hdr=yes)
2136 AC_CHECK_LIB(ldg, ldg_open, have_ldg_lib=yes, have_ldg_lib=no, -lgem)
2137 if test x$have_ldg_hdr = xyes -a x$have_ldg_lib = xyes; then
2138 AC_DEFINE(SDL_LOADSO_LDG)
2139 SOURCES="$SOURCES $srcdir/src/loadso/mint/*.c"
2140 SDL_LIBS="$SDL_LIBS -lldg -lgem"
2141 have_loadso=yes
2142 fi
2143 fi
2144}
2145
2146dnl Check for the usbhid(3) library on *BSD
2147CheckUSBHID()
2148{
2149 if test x$enable_joystick = xyes; then
2150 AC_CHECK_LIB(usbhid, hid_init, have_libusbhid=yes)
2151 if test x$have_libusbhid = xyes; then
2152 AC_CHECK_HEADER(usbhid.h, [USB_CFLAGS="-DHAVE_USBHID_H"])
2153 AC_CHECK_HEADER(libusbhid.h, [USB_CFLAGS="-DHAVE_LIBUSBHID_H"])
2154 USB_LIBS="$USB_LIBS -lusbhid"
2155 else
2156 AC_CHECK_HEADER(usb.h, [USB_CFLAGS="-DHAVE_USB_H"])
2157 AC_CHECK_HEADER(libusb.h, [USB_CFLAGS="-DHAVE_LIBUSB_H"])
2158 AC_CHECK_LIB(usb, hid_init, [USB_LIBS="$USB_LIBS -lusb"])
2159 fi
2160
2161 save_CFLAGS="$CFLAGS"
2162 CFLAGS="$CFLAGS $USB_CFLAGS"
2163
2164 AC_MSG_CHECKING(for usbhid)
2165 have_usbhid=no
2166 AC_TRY_COMPILE([
2167 #include <sys/types.h>
2168 #if defined(HAVE_USB_H)
2169 #include <usb.h>
2170 #endif
2171 #ifdef __DragonFly__
2172 # include <bus/usb/usb.h>
2173 # include <bus/usb/usbhid.h>
2174 #else
2175 # include <dev/usb/usb.h>
2176 # include <dev/usb/usbhid.h>
2177 #endif
2178 #if defined(HAVE_USBHID_H)
2179 #include <usbhid.h>
2180 #elif defined(HAVE_LIBUSB_H)
2181 #include <libusb.h>
2182 #elif defined(HAVE_LIBUSBHID_H)
2183 #include <libusbhid.h>
2184 #endif
2185 ],[
2186 struct report_desc *repdesc;
2187 struct usb_ctl_report *repbuf;
2188 hid_kind_t hidkind;
2189 ],[
2190 have_usbhid=yes
2191 ])
2192 AC_MSG_RESULT($have_usbhid)
2193
2194 if test x$have_usbhid = xyes; then
2195 AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
2196 have_usbhid_ucr_data=no
2197 AC_TRY_COMPILE([
2198 #include <sys/types.h>
2199 #if defined(HAVE_USB_H)
2200 #include <usb.h>
2201 #endif
2202 #ifdef __DragonFly__
2203 # include <bus/usb/usb.h>
2204 # include <bus/usb/usbhid.h>
2205 #else
2206 # include <dev/usb/usb.h>
2207 # include <dev/usb/usbhid.h>
2208 #endif
2209 #if defined(HAVE_USBHID_H)
2210 #include <usbhid.h>
2211 #elif defined(HAVE_LIBUSB_H)
2212 #include <libusb.h>
2213 #elif defined(HAVE_LIBUSBHID_H)
2214 #include <libusbhid.h>
2215 #endif
2216 ],[
2217 struct usb_ctl_report buf;
2218 if (buf.ucr_data) { }
2219 ],[
2220 have_usbhid_ucr_data=yes
2221 ])
2222 if test x$have_usbhid_ucr_data = xyes; then
2223 USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA"
2224 fi
2225 AC_MSG_RESULT($have_usbhid_ucr_data)
2226
2227 AC_MSG_CHECKING(for new usbhid API)
2228 have_usbhid_new=no
2229 AC_TRY_COMPILE([
2230 #include <sys/types.h>
2231 #if defined(HAVE_USB_H)
2232 #include <usb.h>
2233 #endif
2234 #ifdef __DragonFly__
2235 #include <bus/usb/usb.h>
2236 #include <bus/usb/usbhid.h>
2237 #else
2238 #include <dev/usb/usb.h>
2239 #include <dev/usb/usbhid.h>
2240 #endif
2241 #if defined(HAVE_USBHID_H)
2242 #include <usbhid.h>
2243 #elif defined(HAVE_LIBUSB_H)
2244 #include <libusb.h>
2245 #elif defined(HAVE_LIBUSBHID_H)
2246 #include <libusbhid.h>
2247 #endif
2248 ],[
2249 report_desc_t d;
2250 hid_start_parse(d, 1, 1);
2251 ],[
2252 have_usbhid_new=yes
2253 ])
2254 if test x$have_usbhid_new = xyes; then
2255 USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW"
2256 fi
2257 AC_MSG_RESULT($have_usbhid_new)
2258
2259 AC_MSG_CHECKING(for struct joystick in machine/joystick.h)
2260 have_machine_joystick=no
2261 AC_TRY_COMPILE([
2262 #include <machine/joystick.h>
2263 ],[
2264 struct joystick t;
2265 ],[
2266 have_machine_joystick=yes
2267 ])
2268 if test x$have_machine_joystick = xyes; then
2269 AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H)
2270 fi
2271 AC_MSG_RESULT($have_machine_joystick)
2272
2273 AC_DEFINE(SDL_JOYSTICK_USBHID)
2274 SOURCES="$SOURCES $srcdir/src/joystick/bsd/*.c"
2275 EXTRA_CFLAGS="$EXTRA_CFLAGS $USB_CFLAGS"
2276 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS"
2277 have_joystick=yes
2278 fi
2279 CFLAGS="$save_CFLAGS"
2280 fi
2281}
2282
2283dnl Check for clock_gettime()
2284CheckClockGettime()
2285{
2286 AC_ARG_ENABLE(clock_gettime,
2287AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=no]]]),
2288 , enable_clock_gettime=no)
2289 if test x$enable_clock_gettime = xyes; then
2290 AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
2291 if test x$have_clock_gettime = xyes; then
2292 AC_DEFINE(HAVE_CLOCK_GETTIME)
2293 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
2294 fi
2295 fi
2296}
2297
2298dnl Check for a valid linux/version.h
2299CheckLinuxVersion()
2300{
2301 AC_CHECK_HEADER(linux/version.h, have_linux_version_h=yes)
2302 if test x$have_linux_version_h = xyes; then
2303 EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_LINUX_VERSION_H"
2304 fi
2305}
2306
2307dnl Check if we want to use RPATH
2308CheckRPATH()
2309{
2310 AC_ARG_ENABLE(rpath,
2311AC_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]),
2312 , enable_rpath=yes)
2313}
2314
2315dnl Set up the configuration based on the host platform!
2316case "$host" in
2317 arm-*-elf*) # FIXME: Can we get more specific for iPodLinux?
2318 ARCH=linux
2319 CheckDummyVideo
2320 CheckIPod
2321 # Set up files for the timer library
2322 if test x$enable_timers = xyes; then
2323 AC_DEFINE(SDL_TIMER_UNIX)
2324 SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
2325 have_timers=yes
2326 fi
2327 ;;
2328 *-*-linux*|*-*-uclinux*|*-*-gnu*|*-*-k*bsd*-gnu|*-*-bsdi*|*-*-freebsd*|*-*-dragonfly*|*-*-netbsd*|*-*-openbsd*|*-*-sysv5*|*-*-solaris*|*-*-hpux*|*-*-irix*|*-*-aix*|*-*-osf*)
2329 case "$host" in
2330 *-*-linux*) ARCH=linux ;;
2331 *-*-uclinux*) ARCH=linux ;;
2332 *-*-kfreebsd*-gnu) ARCH=kfreebsd-gnu ;;
2333 *-*-knetbsd*-gnu) ARCH=knetbsd-gnu ;;
2334 *-*-kopenbsd*-gnu) ARCH=kopenbsd-gnu ;;
2335 *-*-gnu*) ARCH=gnu ;; # must be last of the gnu variants
2336 *-*-bsdi*) ARCH=bsdi ;;
2337 *-*-freebsd*) ARCH=freebsd ;;
2338 *-*-dragonfly*) ARCH=freebsd ;;
2339 *-*-netbsd*) ARCH=netbsd ;;
2340 *-*-openbsd*) ARCH=openbsd ;;
2341 *-*-sysv5*) ARCH=sysv5 ;;
2342 *-*-solaris*) ARCH=solaris ;;
2343 *-*-hpux*) ARCH=hpux ;;
2344 *-*-irix*) ARCH=irix ;;
2345 *-*-aix*) ARCH=aix ;;
2346 *-*-osf*) ARCH=osf ;;
2347 esac
2348 CheckVisibilityHidden
2349 CheckDummyVideo
2350 CheckDiskAudio
2351 CheckDummyAudio
2352 CheckDLOPEN
2353 CheckNASM
2354 CheckAltivec
2355 CheckOSS
2356 CheckDMEDIA
2357 CheckMME
2358 CheckALSA
2359 CheckARTSC
2360 CheckESD
2361 CheckPulseAudio
2362 CheckNAS
2363 CheckX11
2364 CheckNANOX
2365 CheckFBCON
2366 CheckDirectFB
2367 CheckPS2GS
2368 CheckPS3
2369 CheckGGI
2370 CheckSVGA
2371 CheckVGL
2372 CheckWscons
2373 CheckAAlib
2374 CheckCaca
2375 CheckQtopia
2376 CheckPicoGUI
2377 CheckOpenGLX11
2378 CheckInputEvents
2379 CheckTslib
2380 CheckUSBHID
2381 CheckPTHREAD
2382 CheckClockGettime
2383 CheckLinuxVersion
2384 CheckRPATH
2385 # Set up files for the audio library
2386 if test x$enable_audio = xyes; then
2387 case $ARCH in
2388 sysv5|solaris|hpux)
2389 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
2390 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
2391 have_audio=yes
2392 ;;
2393 netbsd|openbsd)
2394 AC_DEFINE(SDL_AUDIO_DRIVER_BSD)
2395 SOURCES="$SOURCES $srcdir/src/audio/bsd/*.c"
2396 have_audio=yes
2397 ;;
2398 aix)
2399 AC_DEFINE(SDL_AUDIO_DRIVER_PAUD)
2400 SOURCES="$SOURCES $srcdir/src/audio/paudio/*.c"
2401 have_audio=yes
2402 ;;
2403 esac
2404 fi
2405 # Set up files for the joystick library
2406 if test x$enable_joystick = xyes; then
2407 case $ARCH in
2408 linux)
2409 AC_DEFINE(SDL_JOYSTICK_LINUX)
2410 SOURCES="$SOURCES $srcdir/src/joystick/linux/*.c"
2411 have_joystick=yes
2412 ;;
2413 esac
2414 fi
2415 # Set up files for the cdrom library
2416 if test x$enable_cdrom = xyes; then
2417 case $ARCH in
2418 linux|solaris)
2419 AC_DEFINE(SDL_CDROM_LINUX)
2420 SOURCES="$SOURCES $srcdir/src/cdrom/linux/*.c"
2421 have_cdrom=yes
2422 ;;
2423 *freebsd*)
2424 AC_DEFINE(SDL_CDROM_FREEBSD)
2425 SOURCES="$SOURCES $srcdir/src/cdrom/freebsd/*.c"
2426 have_cdrom=yes
2427 ;;
2428 *openbsd*|*netbsd*)
2429 AC_DEFINE(SDL_CDROM_OPENBSD)
2430 SOURCES="$SOURCES $srcdir/src/cdrom/openbsd/*.c"
2431 have_cdrom=yes
2432 ;;
2433 bsdi)
2434 AC_DEFINE(SDL_CDROM_BSDI)
2435 SOURCES="$SOURCES $srcdir/src/cdrom/bsdi/*.c"
2436 have_cdrom=yes
2437 ;;
2438 aix)
2439 AC_DEFINE(SDL_CDROM_AIX)
2440 SOURCES="$SOURCES $srcdir/src/cdrom/aix/*.c"
2441 have_cdrom=yes
2442 ;;
2443 osf)
2444 AC_DEFINE(SDL_CDROM_OSF)
2445 SOURCES="$SOURCES $srcdir/src/cdrom/osf/*.c"
2446 have_cdrom=yes
2447 ;;
2448 esac
2449 fi
2450 # Set up files for the thread library
2451 if test x$enable_threads = xyes -a x$use_pthreads != xyes -a x$use_pth != xyes -a x$ARCH = xirix; then
2452 AC_DEFINE(SDL_THREAD_SPROC)
2453 SOURCES="$SOURCES $srcdir/src/thread/irix/*.c"
2454 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
2455 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
2456 have_threads=yes
2457 fi
2458 # Set up files for the timer library
2459 if test x$enable_timers = xyes; then
2460 AC_DEFINE(SDL_TIMER_UNIX)
2461 SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
2462 have_timers=yes
2463 fi
2464 ;;
2465 *-*-qnx*)
2466 ARCH=qnx
2467 CheckDummyVideo
2468 CheckDiskAudio
2469 CheckDummyAudio
2470 # CheckNASM
2471 CheckDLOPEN
2472 CheckNAS
2473 CheckPHOTON
2474 CheckX11
2475 CheckOpenGLX11
2476 CheckPTHREAD
2477 # Set up files for the audio library
2478 if test x$enable_audio = xyes; then
2479 AC_DEFINE(SDL_AUDIO_DRIVER_QNXNTO)
2480 SOURCES="$SOURCES $srcdir/src/audio/nto/*.c"
2481 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lasound"
2482 have_audio=yes
2483 fi
2484 # Set up files for the cdrom library
2485 if test x$enable_cdrom = xyes; then
2486 AC_DEFINE(SDL_CDROM_QNX)
2487 SOURCES="$SOURCES $srcdir/src/cdrom/qnx/*.c"
2488 have_cdrom=yes
2489 fi
2490 # Set up files for the timer library
2491 if test x$enable_timers = xyes; then
2492 AC_DEFINE(SDL_TIMER_UNIX)
2493 SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
2494 have_timers=yes
2495 fi
2496 ;;
2497 *-*-cygwin* | *-*-mingw32*)
2498 ARCH=win32
2499 if test "$build" != "$host"; then # cross-compiling
2500 # Default cross-compile location
2501 ac_default_prefix=/usr/local/cross-tools/i386-mingw32
2502 else
2503 # Look for the location of the tools and install there
2504 if test "$BUILD_PREFIX" != ""; then
2505 ac_default_prefix=$BUILD_PREFIX
2506 fi
2507 fi
2508 CheckDummyVideo
2509 CheckDiskAudio
2510 CheckDummyAudio
2511 CheckWIN32
2512 CheckWIN32GL
2513 CheckDIRECTX
2514 CheckNASM
2515 # Set up files for the audio library
2516 if test x$enable_audio = xyes; then
2517 AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
2518 SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
2519 if test x$have_directx = xyes; then
2520 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND)
2521 SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
2522 fi
2523 have_audio=yes
2524 fi
2525 # Set up files for the joystick library
2526 if test x$enable_joystick = xyes; then
2527 AC_DEFINE(SDL_JOYSTICK_WINMM)
2528 SOURCES="$SOURCES $srcdir/src/joystick/win32/*.c"
2529 have_joystick=yes
2530 fi
2531 # Set up files for the cdrom library
2532 if test x$enable_cdrom = xyes; then
2533 AC_DEFINE(SDL_CDROM_WIN32)
2534 SOURCES="$SOURCES $srcdir/src/cdrom/win32/*.c"
2535 have_cdrom=yes
2536 fi
2537 # Set up files for the thread library
2538 if test x$enable_threads = xyes; then
2539 AC_DEFINE(SDL_THREAD_WIN32)
2540 SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
2541 SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
2542 SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
2543 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
2544 have_threads=yes
2545 fi
2546 # Set up files for the timer library
2547 if test x$enable_timers = xyes; then
2548 AC_DEFINE(SDL_TIMER_WIN32)
2549 SOURCES="$SOURCES $srcdir/src/timer/win32/*.c"
2550 have_timers=yes
2551 fi
2552 # Set up files for the shared object loading library
2553 if test x$enable_loadso = xyes; then
2554 AC_DEFINE(SDL_LOADSO_WIN32)
2555 SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
2556 have_loadso=yes
2557 fi
2558 # Set up the system libraries we need
2559 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm"
2560 if test x$have_directx = xyes; then
2561 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldxguid"
2562 fi
2563 # The Win32 platform requires special setup
2564 SOURCES="$SOURCES $srcdir/src/main/win32/*.rc"
2565 SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
2566 SDLMAIN_LDFLAGS="-static"
2567 SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
2568 SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
2569 ;;
2570 *-wince*)
2571 ARCH=win32
2572 CheckDummyVideo
2573 CheckDiskAudio
2574 CheckDummyAudio
2575 CheckWIN32
2576 CheckNASM
2577 SOURCES="$SOURCES $srcdir/src/video/gapi/*.c"
2578 EXTRA_CFLAGS="$EXTRA_CFLAGS -D_WIN32_WCE=0x420"
2579 if test x$enable_audio = xyes; then
2580 AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
2581 SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
2582 have_audio=yes
2583 fi
2584 # Set up files for the thread library
2585 if test x$enable_threads = xyes; then
2586 AC_DEFINE(SDL_THREAD_WIN32)
2587 SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
2588 SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
2589 SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
2590 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
2591 have_threads=yes
2592 fi
2593 # Set up files for the timer library
2594 if test x$enable_timers = xyes; then
2595 AC_DEFINE(SDL_TIMER_WINCE)
2596 SOURCES="$SOURCES $srcdir/src/timer/wince/*.c"
2597 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lmmtimer"
2598 have_timers=yes
2599 fi
2600 # Set up files for the shared object loading library
2601 if test x$enable_loadso = xyes; then
2602 AC_DEFINE(SDL_LOADSO_WIN32)
2603 SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
2604 have_loadso=yes
2605 fi
2606 # Set up the system libraries we need
2607 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl"
2608 # The Win32 platform requires special setup
2609 SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
2610 SDLMAIN_LDFLAGS="-static"
2611 SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
2612 SDL_LIBS="-lSDLmain $SDL_LIBS"
2613 ;;
2614 *-*-beos* | *-*-haiku*)
2615 ARCH=beos
2616 ac_default_prefix=/boot/develop/tools/gnupro
2617 CheckDummyVideo
2618 CheckDiskAudio
2619 CheckDummyAudio
2620 CheckNASM
2621 CheckBWINDOW
2622 CheckBeGL
2623 # Set up files for the audio library
2624 if test x$enable_audio = xyes; then
2625 AC_DEFINE(SDL_AUDIO_DRIVER_BAUDIO)
2626 SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
2627 have_audio=yes
2628 fi
2629 # Set up files for the joystick library
2630 if test x$enable_joystick = xyes; then
2631 AC_DEFINE(SDL_JOYSTICK_BEOS)
2632 SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
2633 have_joystick=yes
2634 fi
2635 # Set up files for the cdrom library
2636 if test x$enable_cdrom = xyes; then
2637 AC_DEFINE(SDL_CDROM_BEOS)
2638 SOURCES="$SOURCES $srcdir/src/cdrom/beos/*.cc"
2639 have_cdrom=yes
2640 fi
2641 # Set up files for the thread library
2642 if test x$enable_threads = xyes; then
2643 AC_DEFINE(SDL_THREAD_BEOS)
2644 SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
2645 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
2646 SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
2647 have_threads=yes
2648 fi
2649 # Set up files for the timer library
2650 if test x$enable_timers = xyes; then
2651 AC_DEFINE(SDL_TIMER_BEOS)
2652 SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
2653 have_timers=yes
2654 fi
2655 # Set up files for the shared object loading library
2656 if test x$enable_loadso = xyes; then
2657 case "$host" in
2658 *-*-beos*)
2659 AC_DEFINE(SDL_LOADSO_BEOS)
2660 SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
2661 ;;
2662 *-*-haiku*)
2663 AC_DEFINE(SDL_LOADSO_DLOPEN)
2664 SOURCES="$SOURCES $srcdir/src/loadso/dlopen/*.c"
2665 ;;
2666 esac
2667 have_loadso=yes
2668 fi
2669 # The BeOS platform requires special setup.
2670 SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
2671 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
2672 ;;
2673 *-*-darwin* )
2674 # This could be either full "Mac OS X", or plain "Darwin" which is
2675 # just the OS X kernel sans upper layers like Carbon and Cocoa.
2676 # Next line is broken, and a few files below require Mac OS X (full)
2677 ARCH=macosx
2678
2679 # Mac OS X builds with both the Carbon and OSX APIs at the moment
2680 EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_CARBON"
2681 EXTRA_CFLAGS="$EXTRA_CFLAGS -DTARGET_API_MAC_OSX"
2682
2683 # HACK: Reset EXTRA_LDFLAGS; the only thing it contains at this point
2684 # is -lm which is not needed under Mac OS X. But for some reasons it
2685 # also tends to contain spurious -L switches, which we don't want to
2686 # use here or in sdl-config. Hence we reset it.
2687 EXTRA_LDFLAGS=""
2688
2689 CheckVisibilityHidden
2690 CheckDummyVideo
2691 CheckDiskAudio
2692 CheckDummyAudio
2693 CheckDLOPEN
2694 CheckNASM
2695
2696 # Set up files for the shared object loading library
2697 # (this needs to be done before the dynamic X11 check)
2698 if test x$enable_loadso = xyes -a x$have_dlopen != xyes; then
2699 AC_DEFINE(SDL_LOADSO_DLCOMPAT)
2700 SOURCES="$SOURCES $srcdir/src/loadso/macosx/*.c"
2701 have_loadso=yes
2702 fi
2703
2704 CheckCOCOA
2705 CheckCARBON
2706 CheckX11
2707 CheckMacGL
2708 CheckOpenGLX11
2709 CheckPTHREAD
2710 CheckAltivec
2711
2712 # Need this or things might misbuild on a G3.
2713 EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL"
2714
2715 # Set up files for the audio library
2716 if test x$enable_audio = xyes; then
2717 AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO)
2718 SOURCES="$SOURCES $srcdir/src/audio/macosx/*.c"
2719 have_audio=yes
2720 fi
2721 # Set up files for the joystick library
2722 if test x$enable_joystick = xyes; then
2723 AC_DEFINE(SDL_JOYSTICK_IOKIT)
2724 SOURCES="$SOURCES $srcdir/src/joystick/darwin/*.c"
2725 have_joystick=yes
2726 need_iokit_framework=yes
2727 fi
2728 # Set up files for the cdrom library
2729 if test x$enable_cdrom = xyes; then
2730 AC_DEFINE(SDL_CDROM_MACOSX)
2731 SOURCES="$SOURCES $srcdir/src/cdrom/macosx/*.c"
2732 have_cdrom=yes
2733 fi
2734 # Set up files for the timer library
2735 if test x$enable_timers = xyes; then
2736 AC_DEFINE(SDL_TIMER_UNIX)
2737 SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
2738 have_timers=yes
2739 fi
2740 # The Mac OS X platform requires special setup.
2741 SDLMAIN_SOURCES="$srcdir/src/main/macosx/*.m"
2742 SDLMAIN_LDFLAGS="-static"
2743 EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
2744 SDL_LIBS="-lSDLmain $SDL_LIBS"
2745 if test x$enable_video_cocoa = xyes; then
2746 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
2747 need_iokit_framework=yes
2748 fi
2749 if test x$enable_video_carbon = xyes -o x$enable_video_cocoa = xyes; then
2750 # The Cocoa backend still needs Carbon
2751 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,ApplicationServices"
2752 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
2753 fi
2754 # If either the audio or CD driver is used, add the AudioUnit framework
2755 if test x$enable_audio = xyes -o x$enable_cdrom = xyes; then
2756 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
2757 fi
2758 # Some subsystems reference IOKit...
2759 if test x$need_iokit_framework = xyes; then
2760 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"
2761 fi
2762 ;;
2763 *-*-mint*)
2764 ARCH=mint
2765 CheckDummyVideo
2766 CheckDiskAudio
2767 CheckDummyAudio
2768 CheckAtariBiosEvent
2769 CheckAtariXbiosVideo
2770 CheckAtariGemVideo
2771 CheckAtariAudio
2772 CheckAtariLdg
2773 CheckAtariOSMesa
2774 CheckPTH
2775 # Set up files for the audio library
2776 if test x$enable_threads = xyes -a x$enable_pth = xyes; then
2777 if test x$enable_audio = xyes; then
2778 AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO)
2779 SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
2780 have_audio=yes
2781 fi
2782 fi
2783 # Set up files for the joystick library
2784 if test x$enable_joystick = xyes; then
2785 AC_DEFINE(SDL_JOYSTICK_MINT)
2786 SOURCES="$SOURCES $srcdir/src/joystick/mint/*.c"
2787 have_joystick=yes
2788 fi
2789 # Set up files for the cdrom library
2790 if test x$enable_cdrom = xyes; then
2791 AC_DEFINE(SDL_CDROM_MINT)
2792 SOURCES="$SOURCES $srcdir/src/cdrom/mint/*.c"
2793 have_cdrom=yes
2794 fi
2795 # Set up files for the timer library
2796 if test x$enable_timers = xyes; then
2797 if test x$enable_threads = xyes -a x$enable_pth = xyes; then
2798 AC_DEFINE(SDL_TIMER_UNIX)
2799 SOURCES="$SOURCES $srcdir/src/timer/unix/*.c"
2800 else
2801 AC_DEFINE(SDL_TIMER_MINT)
2802 SOURCES="$SOURCES $srcdir/src/timer/mint/*.c"
2803 SOURCES="$SOURCES $srcdir/src/timer/mint/*.S"
2804 fi
2805 have_timers=yes
2806 fi
2807 ;;
2808 *-riscos)
2809 ARCH=riscos
2810 CheckOSS
2811 CheckPTHREAD
2812 # Set up files for the video library
2813 if test x$enable_video = xyes; then
2814 AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
2815 SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
2816 SOURCES="$SOURCES $srcdir/src/video/riscos/*.S"
2817 have_video=yes
2818 fi
2819 # Set up files for the joystick library
2820 if test x$enable_joystick = xyes; then
2821 AC_DEFINE(SDL_JOYSTICK_RISCOS)
2822 SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
2823 have_joystick=yes
2824 fi
2825 # Set up files for the timer library
2826 if test x$enable_timers = xyes; then
2827 AC_DEFINE(SDL_TIMER_RISCOS)
2828 SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
2829 have_timers=yes
2830 fi
2831 # The RISC OS platform requires special setup.
2832 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
2833 ;;
2834 *)
2835 AC_MSG_ERROR([
2836*** Unsupported host: Please add to configure.in
2837 ])
2838 ;;
2839esac
2840
2841dnl Do this on all platforms, after everything else.
2842CheckWarnAll
2843
2844# Verify that we have all the platform specific files we need
2845
2846if test x$enable_joystick = xyes; then
2847 if test x$have_joystick != xyes; then
2848 # Wants joystick subsystem, but doesn't have a platform-specific backend...
2849 AC_DEFINE(SDL_JOYSTICK_DUMMY)
2850 SOURCES="$SOURCES $srcdir/src/joystick/dummy/*.c"
2851 fi
2852fi
2853if test x$have_cdrom != xyes; then
2854 if test x$enable_cdrom = xyes; then
2855 AC_DEFINE(SDL_CDROM_DISABLED)
2856 fi
2857 SOURCES="$SOURCES $srcdir/src/cdrom/dummy/*.c"
2858fi
2859if test x$have_threads != xyes; then
2860 if test x$enable_threads = xyes; then
2861 AC_DEFINE(SDL_THREADS_DISABLED)
2862 fi
2863 SOURCES="$SOURCES $srcdir/src/thread/generic/*.c"
2864fi
2865if test x$have_timers != xyes; then
2866 if test x$enable_timers = xyes; then
2867 AC_DEFINE(SDL_TIMERS_DISABLED)
2868 fi
2869 SOURCES="$SOURCES $srcdir/src/timer/dummy/*.c"
2870fi
2871if test x$have_loadso != xyes; then
2872 if test x$enable_loadso = xyes; then
2873 AC_DEFINE(SDL_LOADSO_DISABLED)
2874 fi
2875 SOURCES="$SOURCES $srcdir/src/loadso/dummy/*.c"
2876fi
2877if test x$SDLMAIN_SOURCES = x; then
2878 SDLMAIN_SOURCES="$srcdir/src/main/dummy/*.c"
2879 SDLMAIN_LDFLAGS="-static"
2880fi
2881
2882OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.asm,$(objects)/\1.lo,g'`
2883OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
2884OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
2885OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
2886OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.S,$(objects)/\1.lo,g'`
2887OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.lo,g'`
2888
2889SDLMAIN_OBJECTS=`echo $SDLMAIN_SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.cc,$(objects)/\1.lo,g'`
2890SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.m,$(objects)/\1.lo,g'`
2891SDLMAIN_OBJECTS=`echo $SDLMAIN_OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
2892
2893# Set runtime shared library paths as needed
2894
2895if test "x$enable_rpath" = "xyes"; then
2896 if test $ARCH = bsdi -o $ARCH = freebsd -o $ARCH = irix -o $ARCH = linux -o $ARCH = netbsd; then
2897 SDL_RLD_FLAGS="-Wl,-rpath,\${libdir}"
2898 fi
2899 if test $ARCH = solaris; then
2900 SDL_RLD_FLAGS="-R\${libdir}"
2901 fi
2902else
2903 SDL_RLD_FLAGS=""
2904fi
2905
2906case "$ARCH" in
2907 macosx)
2908 if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
2909 SDL_LIBS="$SDL_LIBS -Wl,-framework,Cocoa"
2910 fi
2911 if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
2912 SDL_LIBS="$SDL_LIBS -Wl,-framework,Carbon"
2913 fi
2914 # Evil hack to allow static linking on Mac OS X
2915 SDL_STATIC_LIBS="\${libdir}/libSDLmain.a \${libdir}/libSDL.a $EXTRA_LDFLAGS"
2916 ;;
2917 *)
2918 SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
2919 ;;
2920esac
2921
2922dnl Expand the cflags and libraries needed by apps using SDL
2923AC_SUBST(SDL_CFLAGS)
2924AC_SUBST(SDL_LIBS)
2925AC_SUBST(SDL_STATIC_LIBS)
2926AC_SUBST(SDL_RLD_FLAGS)
2927if test x$enable_shared = xyes; then
2928 ENABLE_SHARED_TRUE=
2929 ENABLE_SHARED_FALSE="#"
2930else
2931 ENABLE_SHARED_TRUE="#"
2932 ENABLE_SHARED_FALSE=
2933fi
2934if test x$enable_static = xyes; then
2935 ENABLE_STATIC_TRUE=
2936 ENABLE_STATIC_FALSE="#"
2937else
2938 ENABLE_STATIC_TRUE="#"
2939 ENABLE_STATIC_FALSE=
2940fi
2941AC_SUBST(ENABLE_SHARED_TRUE)
2942AC_SUBST(ENABLE_SHARED_FALSE)
2943AC_SUBST(ENABLE_STATIC_TRUE)
2944AC_SUBST(ENABLE_STATIC_FALSE)
2945
2946dnl Expand the sources and objects needed to build the library
2947AC_SUBST(ac_aux_dir)
2948AC_SUBST(INCLUDE)
2949AC_SUBST(SOURCES)
2950AC_SUBST(OBJECTS)
2951AC_SUBST(SDLMAIN_SOURCES)
2952AC_SUBST(SDLMAIN_OBJECTS)
2953AC_SUBST(SDLMAIN_LDFLAGS)
2954AC_SUBST(BUILD_CFLAGS)
2955AC_SUBST(EXTRA_CFLAGS)
2956AC_SUBST(BUILD_LDFLAGS)
2957AC_SUBST(EXTRA_LDFLAGS)
2958AC_SUBST(WINDRES)
2959
2960AC_OUTPUT([
2961 Makefile sdl-config SDL.spec SDL.qpg sdl.pc
2962], [
2963 : >build-deps
2964 if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
2965])
02966
=== added directory '.pc/mir-support.diff/include'
=== added file '.pc/mir-support.diff/include/SDL_config.h.in'
--- .pc/mir-support.diff/include/SDL_config.h.in 1970-01-01 00:00:00 +0000
+++ .pc/mir-support.diff/include/SDL_config.h.in 2015-06-01 21:48:23 +0000
@@ -0,0 +1,312 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22
23#ifndef _SDL_config_h
24#define _SDL_config_h
25
26/* This is a set of defines to configure the SDL features */
27
28/* General platform specific identifiers */
29#include "SDL_platform.h"
30
31/* Make sure that this isn't included by Visual C++ */
32#ifdef _MSC_VER
33#error You should copy include/SDL_config.h.default to include/SDL_config.h
34#endif
35
36/* C language features */
37#undef const
38#undef inline
39#undef volatile
40
41/* C datatypes */
42#undef size_t
43#undef int8_t
44#undef uint8_t
45#undef int16_t
46#undef uint16_t
47#undef int32_t
48#undef uint32_t
49#undef int64_t
50#undef uint64_t
51#undef uintptr_t
52#undef SDL_HAS_64BIT_TYPE
53
54/* Endianness */
55#undef SDL_BYTEORDER
56
57/* Comment this if you want to build without any C library requirements */
58#undef HAVE_LIBC
59#if HAVE_LIBC
60
61/* Useful headers */
62#undef HAVE_ALLOCA_H
63#undef HAVE_SYS_TYPES_H
64#undef HAVE_STDIO_H
65#undef STDC_HEADERS
66#undef HAVE_STDLIB_H
67#undef HAVE_STDARG_H
68#undef HAVE_MALLOC_H
69#undef HAVE_MEMORY_H
70#undef HAVE_STRING_H
71#undef HAVE_STRINGS_H
72#undef HAVE_INTTYPES_H
73#undef HAVE_STDINT_H
74#undef HAVE_CTYPE_H
75#undef HAVE_MATH_H
76#undef HAVE_ICONV_H
77#undef HAVE_SIGNAL_H
78#undef HAVE_ALTIVEC_H
79
80/* C library functions */
81#undef HAVE_MALLOC
82#undef HAVE_CALLOC
83#undef HAVE_REALLOC
84#undef HAVE_FREE
85#undef HAVE_ALLOCA
86#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */
87#undef HAVE_GETENV
88#undef HAVE_PUTENV
89#undef HAVE_UNSETENV
90#endif
91#undef HAVE_QSORT
92#undef HAVE_ABS
93#undef HAVE_BCOPY
94#undef HAVE_MEMSET
95#undef HAVE_MEMCPY
96#undef HAVE_MEMMOVE
97#undef HAVE_MEMCMP
98#undef HAVE_STRLEN
99#undef HAVE_STRLCPY
100#undef HAVE_STRLCAT
101#undef HAVE_STRDUP
102#undef HAVE__STRREV
103#undef HAVE__STRUPR
104#undef HAVE__STRLWR
105#undef HAVE_INDEX
106#undef HAVE_RINDEX
107#undef HAVE_STRCHR
108#undef HAVE_STRRCHR
109#undef HAVE_STRSTR
110#undef HAVE_ITOA
111#undef HAVE__LTOA
112#undef HAVE__UITOA
113#undef HAVE__ULTOA
114#undef HAVE_STRTOL
115#undef HAVE_STRTOUL
116#undef HAVE__I64TOA
117#undef HAVE__UI64TOA
118#undef HAVE_STRTOLL
119#undef HAVE_STRTOULL
120#undef HAVE_STRTOD
121#undef HAVE_ATOI
122#undef HAVE_ATOF
123#undef HAVE_STRCMP
124#undef HAVE_STRNCMP
125#undef HAVE__STRICMP
126#undef HAVE_STRCASECMP
127#undef HAVE__STRNICMP
128#undef HAVE_STRNCASECMP
129#undef HAVE_SSCANF
130#undef HAVE_SNPRINTF
131#undef HAVE_VSNPRINTF
132#undef HAVE_ICONV
133#undef HAVE_SIGACTION
134#undef HAVE_SA_SIGACTION
135#undef HAVE_SETJMP
136#undef HAVE_NANOSLEEP
137#undef HAVE_CLOCK_GETTIME
138#undef HAVE_GETPAGESIZE
139#undef HAVE_MPROTECT
140#undef HAVE_SEM_TIMEDWAIT
141
142#else
143/* We may need some replacement for stdarg.h here */
144#include <stdarg.h>
145#endif /* HAVE_LIBC */
146
147/* Allow disabling of core subsystems */
148#undef SDL_AUDIO_DISABLED
149#undef SDL_CDROM_DISABLED
150#undef SDL_CPUINFO_DISABLED
151#undef SDL_EVENTS_DISABLED
152#undef SDL_FILE_DISABLED
153#undef SDL_JOYSTICK_DISABLED
154#undef SDL_LOADSO_DISABLED
155#undef SDL_THREADS_DISABLED
156#undef SDL_TIMERS_DISABLED
157#undef SDL_VIDEO_DISABLED
158
159/* Enable various audio drivers */
160#undef SDL_AUDIO_DRIVER_ALSA
161#undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
162#undef SDL_AUDIO_DRIVER_ARTS
163#undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
164#undef SDL_AUDIO_DRIVER_BAUDIO
165#undef SDL_AUDIO_DRIVER_BSD
166#undef SDL_AUDIO_DRIVER_COREAUDIO
167#undef SDL_AUDIO_DRIVER_DART
168#undef SDL_AUDIO_DRIVER_DC
169#undef SDL_AUDIO_DRIVER_DISK
170#undef SDL_AUDIO_DRIVER_DUMMY
171#undef SDL_AUDIO_DRIVER_DMEDIA
172#undef SDL_AUDIO_DRIVER_DSOUND
173#undef SDL_AUDIO_DRIVER_PULSE
174#undef SDL_AUDIO_DRIVER_PULSE_DYNAMIC
175#undef SDL_AUDIO_DRIVER_ESD
176#undef SDL_AUDIO_DRIVER_ESD_DYNAMIC
177#undef SDL_AUDIO_DRIVER_MINT
178#undef SDL_AUDIO_DRIVER_MMEAUDIO
179#undef SDL_AUDIO_DRIVER_NAS
180#undef SDL_AUDIO_DRIVER_NAS_DYNAMIC
181#undef SDL_AUDIO_DRIVER_OSS
182#undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H
183#undef SDL_AUDIO_DRIVER_PAUD
184#undef SDL_AUDIO_DRIVER_QNXNTO
185#undef SDL_AUDIO_DRIVER_SNDMGR
186#undef SDL_AUDIO_DRIVER_SUNAUDIO
187#undef SDL_AUDIO_DRIVER_WAVEOUT
188
189/* Enable various cdrom drivers */
190#undef SDL_CDROM_AIX
191#undef SDL_CDROM_BEOS
192#undef SDL_CDROM_BSDI
193#undef SDL_CDROM_DC
194#undef SDL_CDROM_DUMMY
195#undef SDL_CDROM_FREEBSD
196#undef SDL_CDROM_LINUX
197#undef SDL_CDROM_MACOS
198#undef SDL_CDROM_MACOSX
199#undef SDL_CDROM_MINT
200#undef SDL_CDROM_OPENBSD
201#undef SDL_CDROM_OS2
202#undef SDL_CDROM_OSF
203#undef SDL_CDROM_QNX
204#undef SDL_CDROM_WIN32
205
206/* Enable various input drivers */
207#undef SDL_INPUT_LINUXEV
208#undef SDL_INPUT_TSLIB
209#undef SDL_JOYSTICK_BEOS
210#undef SDL_JOYSTICK_DC
211#undef SDL_JOYSTICK_DUMMY
212#undef SDL_JOYSTICK_IOKIT
213#undef SDL_JOYSTICK_LINUX
214#undef SDL_JOYSTICK_MACOS
215#undef SDL_JOYSTICK_MINT
216#undef SDL_JOYSTICK_OS2
217#undef SDL_JOYSTICK_RISCOS
218#undef SDL_JOYSTICK_WINMM
219#undef SDL_JOYSTICK_USBHID
220#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
221
222/* Enable various shared object loading systems */
223#undef SDL_LOADSO_BEOS
224#undef SDL_LOADSO_DLCOMPAT
225#undef SDL_LOADSO_DLOPEN
226#undef SDL_LOADSO_DUMMY
227#undef SDL_LOADSO_LDG
228#undef SDL_LOADSO_MACOS
229#undef SDL_LOADSO_OS2
230#undef SDL_LOADSO_WIN32
231
232/* Enable various threading systems */
233#undef SDL_THREAD_BEOS
234#undef SDL_THREAD_DC
235#undef SDL_THREAD_OS2
236#undef SDL_THREAD_PTH
237#undef SDL_THREAD_PTHREAD
238#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
239#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
240#undef SDL_THREAD_SPROC
241#undef SDL_THREAD_WIN32
242
243/* Enable various timer systems */
244#undef SDL_TIMER_BEOS
245#undef SDL_TIMER_DC
246#undef SDL_TIMER_DUMMY
247#undef SDL_TIMER_MACOS
248#undef SDL_TIMER_MINT
249#undef SDL_TIMER_OS2
250#undef SDL_TIMER_RISCOS
251#undef SDL_TIMER_UNIX
252#undef SDL_TIMER_WIN32
253#undef SDL_TIMER_WINCE
254
255/* Enable various video drivers */
256#undef SDL_VIDEO_DRIVER_AALIB
257#undef SDL_VIDEO_DRIVER_BWINDOW
258#undef SDL_VIDEO_DRIVER_CACA
259#undef SDL_VIDEO_DRIVER_DC
260#undef SDL_VIDEO_DRIVER_DDRAW
261#undef SDL_VIDEO_DRIVER_DGA
262#undef SDL_VIDEO_DRIVER_DIRECTFB
263#undef SDL_VIDEO_DRIVER_DRAWSPROCKET
264#undef SDL_VIDEO_DRIVER_DUMMY
265#undef SDL_VIDEO_DRIVER_FBCON
266#undef SDL_VIDEO_DRIVER_GAPI
267#undef SDL_VIDEO_DRIVER_GEM
268#undef SDL_VIDEO_DRIVER_GGI
269#undef SDL_VIDEO_DRIVER_IPOD
270#undef SDL_VIDEO_DRIVER_NANOX
271#undef SDL_VIDEO_DRIVER_OS2FS
272#undef SDL_VIDEO_DRIVER_PHOTON
273#undef SDL_VIDEO_DRIVER_PICOGUI
274#undef SDL_VIDEO_DRIVER_PS2GS
275#undef SDL_VIDEO_DRIVER_PS3
276#undef SDL_VIDEO_DRIVER_QTOPIA
277#undef SDL_VIDEO_DRIVER_QUARTZ
278#undef SDL_VIDEO_DRIVER_RISCOS
279#undef SDL_VIDEO_DRIVER_SVGALIB
280#undef SDL_VIDEO_DRIVER_TOOLBOX
281#undef SDL_VIDEO_DRIVER_VGL
282#undef SDL_VIDEO_DRIVER_WINDIB
283#undef SDL_VIDEO_DRIVER_WSCONS
284#undef SDL_VIDEO_DRIVER_X11
285#undef SDL_VIDEO_DRIVER_X11_DGAMOUSE
286#undef SDL_VIDEO_DRIVER_X11_DYNAMIC
287#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
288#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
289#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
290#undef SDL_VIDEO_DRIVER_X11_VIDMODE
291#undef SDL_VIDEO_DRIVER_X11_XINERAMA
292#undef SDL_VIDEO_DRIVER_X11_XME
293#undef SDL_VIDEO_DRIVER_X11_XRANDR
294#undef SDL_VIDEO_DRIVER_X11_XV
295#undef SDL_VIDEO_DRIVER_XBIOS
296
297/* Enable OpenGL support */
298#undef SDL_VIDEO_OPENGL
299#undef SDL_VIDEO_OPENGL_GLX
300#undef SDL_VIDEO_OPENGL_WGL
301#undef SDL_VIDEO_OPENGL_OSMESA
302#undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
303
304/* Disable screensaver */
305#undef SDL_VIDEO_DISABLE_SCREENSAVER
306
307/* Enable assembly routines */
308#undef SDL_ASSEMBLY_ROUTINES
309#undef SDL_HERMES_BLITTERS
310#undef SDL_ALTIVEC_BLITTERS
311
312#endif /* _SDL_config_h */
0313
=== added directory '.pc/mir-support.diff/src'
=== added directory '.pc/mir-support.diff/src/video'
=== added file '.pc/mir-support.diff/src/video/SDL_sysvideo.h'
--- .pc/mir-support.diff/src/video/SDL_sysvideo.h 1970-01-01 00:00:00 +0000
+++ .pc/mir-support.diff/src/video/SDL_sysvideo.h 2015-06-01 21:48:23 +0000
@@ -0,0 +1,424 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24#ifndef _SDL_sysvideo_h
25#define _SDL_sysvideo_h
26
27#include "SDL_mouse.h"
28#define SDL_PROTOTYPES_ONLY
29#include "SDL_syswm.h"
30#undef SDL_PROTOTYPES_ONLY
31
32/* This file prototypes the video driver implementation.
33 This is designed to be easily converted to C++ in the future.
34 */
35
36#if SDL_VIDEO_OPENGL
37#include "SDL_opengl.h"
38#endif /* SDL_VIDEO_OPENGL */
39
40/* The SDL video driver */
41typedef struct SDL_VideoDevice SDL_VideoDevice;
42
43/* Define the SDL video driver structure */
44#define _THIS SDL_VideoDevice *_this
45#ifndef _STATUS
46#define _STATUS SDL_status *status
47#endif
48struct SDL_VideoDevice {
49 /* * * */
50 /* The name of this video driver */
51 const char *name;
52
53 /* * * */
54 /* Initialization/Query functions */
55
56 /* Initialize the native video subsystem, filling 'vformat' with the
57 "best" display pixel format, returning 0 or -1 if there's an error.
58 */
59 int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
60
61 /* List the available video modes for the given pixel format, sorted
62 from largest to smallest.
63 */
64 SDL_Rect **(*ListModes)(_THIS, SDL_PixelFormat *format, Uint32 flags);
65
66 /* Set the requested video mode, returning a surface which will be
67 set to the SDL_VideoSurface. The width and height will already
68 be verified by ListModes(), and the video subsystem is free to
69 set the mode to a supported bit depth different from the one
70 specified -- the desired bpp will be emulated with a shadow
71 surface if necessary. If a new mode is returned, this function
72 should take care of cleaning up the current mode.
73 */
74 SDL_Surface *(*SetVideoMode)(_THIS, SDL_Surface *current,
75 int width, int height, int bpp, Uint32 flags);
76
77 /* Toggle the fullscreen mode */
78 int (*ToggleFullScreen)(_THIS, int on);
79
80 /* This is called after the video mode has been set, to get the
81 initial mouse state. It should queue events as necessary to
82 properly represent the current mouse focus and position.
83 */
84 void (*UpdateMouse)(_THIS);
85
86 /* Create a YUV video surface (possibly overlay) of the given
87 format. The hardware should be able to perform at least 2x
88 scaling on display.
89 */
90 SDL_Overlay *(*CreateYUVOverlay)(_THIS, int width, int height,
91 Uint32 format, SDL_Surface *display);
92
93 /* Sets the color entries { firstcolor .. (firstcolor+ncolors-1) }
94 of the physical palette to those in 'colors'. If the device is
95 using a software palette (SDL_HWPALETTE not set), then the
96 changes are reflected in the logical palette of the screen
97 as well.
98 The return value is 1 if all entries could be set properly
99 or 0 otherwise.
100 */
101 int (*SetColors)(_THIS, int firstcolor, int ncolors,
102 SDL_Color *colors);
103
104 /* This pointer should exist in the native video subsystem and should
105 point to an appropriate update function for the current video mode
106 */
107 void (*UpdateRects)(_THIS, int numrects, SDL_Rect *rects);
108
109 /* Reverse the effects VideoInit() -- called if VideoInit() fails
110 or if the application is shutting down the video subsystem.
111 */
112 void (*VideoQuit)(_THIS);
113
114 /* * * */
115 /* Hardware acceleration functions */
116
117 /* Information about the video hardware */
118 SDL_VideoInfo info;
119
120 /* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
121 SDL_PixelFormat* displayformatalphapixel;
122
123 /* Allocates a surface in video memory */
124 int (*AllocHWSurface)(_THIS, SDL_Surface *surface);
125
126 /* Sets the hardware accelerated blit function, if any, based
127 on the current flags of the surface (colorkey, alpha, etc.)
128 */
129 int (*CheckHWBlit)(_THIS, SDL_Surface *src, SDL_Surface *dst);
130
131 /* Fills a surface rectangle with the given color */
132 int (*FillHWRect)(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color);
133
134 /* Sets video mem colorkey and accelerated blit function */
135 int (*SetHWColorKey)(_THIS, SDL_Surface *surface, Uint32 key);
136
137 /* Sets per surface hardware alpha value */
138 int (*SetHWAlpha)(_THIS, SDL_Surface *surface, Uint8 value);
139
140 /* Returns a readable/writable surface */
141 int (*LockHWSurface)(_THIS, SDL_Surface *surface);
142 void (*UnlockHWSurface)(_THIS, SDL_Surface *surface);
143
144 /* Performs hardware flipping */
145 int (*FlipHWSurface)(_THIS, SDL_Surface *surface);
146
147 /* Frees a previously allocated video surface */
148 void (*FreeHWSurface)(_THIS, SDL_Surface *surface);
149
150 /* * * */
151 /* Gamma support */
152
153 Uint16 *gamma;
154
155 /* Set the gamma correction directly (emulated with gamma ramps) */
156 int (*SetGamma)(_THIS, float red, float green, float blue);
157
158 /* Get the gamma correction directly (emulated with gamma ramps) */
159 int (*GetGamma)(_THIS, float *red, float *green, float *blue);
160
161 /* Set the gamma ramp */
162 int (*SetGammaRamp)(_THIS, Uint16 *ramp);
163
164 /* Get the gamma ramp */
165 int (*GetGammaRamp)(_THIS, Uint16 *ramp);
166
167 /* * * */
168 /* OpenGL support */
169
170 /* Sets the dll to use for OpenGL and loads it */
171 int (*GL_LoadLibrary)(_THIS, const char *path);
172
173 /* Retrieves the address of a function in the gl library */
174 void* (*GL_GetProcAddress)(_THIS, const char *proc);
175
176 /* Get attribute information from the windowing system. */
177 int (*GL_GetAttribute)(_THIS, SDL_GLattr attrib, int* value);
178
179 /* Make the context associated with this driver current */
180 int (*GL_MakeCurrent)(_THIS);
181
182 /* Swap the current buffers in double buffer mode. */
183 void (*GL_SwapBuffers)(_THIS);
184
185 /* OpenGL functions for SDL_OPENGLBLIT */
186#if SDL_VIDEO_OPENGL
187#if !defined(__WIN32__)
188#define WINAPI
189#endif
190#define SDL_PROC(ret,func,params) ret (WINAPI *func) params;
191#include "SDL_glfuncs.h"
192#undef SDL_PROC
193
194 /* Texture id */
195 GLuint texture;
196#endif
197 int is_32bit;
198
199 /* * * */
200 /* Window manager functions */
201
202 /* Set the title and icon text */
203 void (*SetCaption)(_THIS, const char *title, const char *icon);
204
205 /* Set the window icon image */
206 void (*SetIcon)(_THIS, SDL_Surface *icon, Uint8 *mask);
207
208 /* Iconify the window.
209 This function returns 1 if there is a window manager and the
210 window was actually iconified, it returns 0 otherwise.
211 */
212 int (*IconifyWindow)(_THIS);
213
214 /* Grab or ungrab keyboard and mouse input */
215 SDL_GrabMode (*GrabInput)(_THIS, SDL_GrabMode mode);
216
217 /* Get some platform dependent window information */
218 int (*GetWMInfo)(_THIS, SDL_SysWMinfo *info);
219
220 /* * * */
221 /* Cursor manager functions */
222
223 /* Free a window manager cursor
224 This function can be NULL if CreateWMCursor is also NULL.
225 */
226 void (*FreeWMCursor)(_THIS, WMcursor *cursor);
227
228 /* If not NULL, create a black/white window manager cursor */
229 WMcursor *(*CreateWMCursor)(_THIS,
230 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
231
232 /* Show the specified cursor, or hide if cursor is NULL */
233 int (*ShowWMCursor)(_THIS, WMcursor *cursor);
234
235 /* Warp the window manager cursor to (x,y)
236 If NULL, a mouse motion event is posted internally.
237 */
238 void (*WarpWMCursor)(_THIS, Uint16 x, Uint16 y);
239
240 /* If not NULL, this is called when a mouse motion event occurs */
241 void (*MoveWMCursor)(_THIS, int x, int y);
242
243 /* Determine whether the mouse should be in relative mode or not.
244 This function is called when the input grab state or cursor
245 visibility state changes.
246 If the cursor is not visible, and the input is grabbed, the
247 driver can place the mouse in relative mode, which may result
248 in higher accuracy sampling of the pointer motion.
249 */
250 void (*CheckMouseMode)(_THIS);
251
252 /* * * */
253 /* Event manager functions */
254
255 /* Initialize keyboard mapping for this driver */
256 void (*InitOSKeymap)(_THIS);
257
258 /* Handle any queued OS events */
259 void (*PumpEvents)(_THIS);
260
261 /* * * */
262 /* Data common to all drivers */
263 SDL_Surface *screen;
264 SDL_Surface *shadow;
265 SDL_Surface *visible;
266 SDL_Palette *physpal; /* physical palette, if != logical palette */
267 SDL_Color *gammacols; /* gamma-corrected colours, or NULL */
268 char *wm_title;
269 char *wm_icon;
270 int offset_x;
271 int offset_y;
272 SDL_GrabMode input_grab;
273
274 /* Driver information flags */
275 int handles_any_size; /* Driver handles any size video mode */
276
277 /* * * */
278 /* Data used by the GL drivers */
279 struct {
280 int red_size;
281 int green_size;
282 int blue_size;
283 int alpha_size;
284 int depth_size;
285 int buffer_size;
286 int stencil_size;
287 int double_buffer;
288 int accum_red_size;
289 int accum_green_size;
290 int accum_blue_size;
291 int accum_alpha_size;
292 int stereo;
293 int multisamplebuffers;
294 int multisamplesamples;
295 int accelerated;
296 int swap_control;
297 int driver_loaded;
298 char driver_path[256];
299 void* dll_handle;
300 } gl_config;
301
302 /* * * */
303 /* Data private to this driver */
304 struct SDL_PrivateVideoData *hidden;
305 struct SDL_PrivateGLData *gl_data;
306
307 /* * * */
308 /* The function used to dispose of this structure */
309 void (*free)(_THIS);
310};
311#undef _THIS
312
313typedef struct VideoBootStrap {
314 const char *name;
315 const char *desc;
316 int (*available)(void);
317 SDL_VideoDevice *(*create)(int devindex);
318} VideoBootStrap;
319
320#if SDL_VIDEO_DRIVER_QUARTZ
321extern VideoBootStrap QZ_bootstrap;
322#endif
323#if SDL_VIDEO_DRIVER_X11
324extern VideoBootStrap X11_bootstrap;
325#endif
326#if SDL_VIDEO_DRIVER_DGA
327extern VideoBootStrap DGA_bootstrap;
328#endif
329#if SDL_VIDEO_DRIVER_NANOX
330extern VideoBootStrap NX_bootstrap;
331#endif
332#if SDL_VIDEO_DRIVER_IPOD
333extern VideoBootStrap iPod_bootstrap;
334#endif
335#if SDL_VIDEO_DRIVER_QTOPIA
336extern VideoBootStrap Qtopia_bootstrap;
337#endif
338#if SDL_VIDEO_DRIVER_WSCONS
339extern VideoBootStrap WSCONS_bootstrap;
340#endif
341#if SDL_VIDEO_DRIVER_FBCON
342extern VideoBootStrap FBCON_bootstrap;
343#endif
344#if SDL_VIDEO_DRIVER_DIRECTFB
345extern VideoBootStrap DirectFB_bootstrap;
346#endif
347#if SDL_VIDEO_DRIVER_PS2GS
348extern VideoBootStrap PS2GS_bootstrap;
349#endif
350#if SDL_VIDEO_DRIVER_PS3
351extern VideoBootStrap PS3_bootstrap;
352#endif
353#if SDL_VIDEO_DRIVER_GGI
354extern VideoBootStrap GGI_bootstrap;
355#endif
356#if SDL_VIDEO_DRIVER_VGL
357extern VideoBootStrap VGL_bootstrap;
358#endif
359#if SDL_VIDEO_DRIVER_SVGALIB
360extern VideoBootStrap SVGALIB_bootstrap;
361#endif
362#if SDL_VIDEO_DRIVER_GAPI
363extern VideoBootStrap GAPI_bootstrap;
364#endif
365#if SDL_VIDEO_DRIVER_WINDIB
366extern VideoBootStrap WINDIB_bootstrap;
367#endif
368#if SDL_VIDEO_DRIVER_DDRAW
369extern VideoBootStrap DIRECTX_bootstrap;
370#endif
371#if SDL_VIDEO_DRIVER_BWINDOW
372extern VideoBootStrap BWINDOW_bootstrap;
373#endif
374#if SDL_VIDEO_DRIVER_TOOLBOX
375extern VideoBootStrap TOOLBOX_bootstrap;
376#endif
377#if SDL_VIDEO_DRIVER_DRAWSPROCKET
378extern VideoBootStrap DSp_bootstrap;
379#endif
380#if SDL_VIDEO_DRIVER_PHOTON
381extern VideoBootStrap ph_bootstrap;
382#endif
383#if SDL_VIDEO_DRIVER_EPOC
384extern VideoBootStrap EPOC_bootstrap;
385#endif
386#if SDL_VIDEO_DRIVER_XBIOS
387extern VideoBootStrap XBIOS_bootstrap;
388#endif
389#if SDL_VIDEO_DRIVER_GEM
390extern VideoBootStrap GEM_bootstrap;
391#endif
392#if SDL_VIDEO_DRIVER_PICOGUI
393extern VideoBootStrap PG_bootstrap;
394#endif
395#if SDL_VIDEO_DRIVER_DC
396extern VideoBootStrap DC_bootstrap;
397#endif
398#if SDL_VIDEO_DRIVER_NDS
399extern VideoBootStrap NDS_bootstrap;
400#endif
401#if SDL_VIDEO_DRIVER_RISCOS
402extern VideoBootStrap RISCOS_bootstrap;
403#endif
404#if SDL_VIDEO_DRIVER_OS2FS
405extern VideoBootStrap OS2FSLib_bootstrap;
406#endif
407#if SDL_VIDEO_DRIVER_AALIB
408extern VideoBootStrap AALIB_bootstrap;
409#endif
410#if SDL_VIDEO_DRIVER_CACA
411extern VideoBootStrap CACA_bootstrap;
412#endif
413#if SDL_VIDEO_DRIVER_DUMMY
414extern VideoBootStrap DUMMY_bootstrap;
415#endif
416
417/* This is the current video device */
418extern SDL_VideoDevice *current_video;
419
420#define SDL_VideoSurface (current_video->screen)
421#define SDL_ShadowSurface (current_video->shadow)
422#define SDL_PublicSurface (current_video->visible)
423
424#endif /* _SDL_sysvideo_h */
0425
=== added file '.pc/mir-support.diff/src/video/SDL_video.c'
--- .pc/mir-support.diff/src/video/SDL_video.c 1970-01-01 00:00:00 +0000
+++ .pc/mir-support.diff/src/video/SDL_video.c 2015-06-01 21:48:23 +0000
@@ -0,0 +1,1978 @@
1/*
2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2012 Sam Lantinga
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19 Sam Lantinga
20 slouken@libsdl.org
21*/
22#include "SDL_config.h"
23
24/* The high-level video driver subsystem */
25
26#include "SDL.h"
27#include "SDL_sysvideo.h"
28#include "SDL_blit.h"
29#include "SDL_pixels_c.h"
30#include "SDL_cursor_c.h"
31#include "../events/SDL_sysevents.h"
32#include "../events/SDL_events_c.h"
33
34/* Available video drivers */
35static VideoBootStrap *bootstrap[] = {
36#if SDL_VIDEO_DRIVER_QUARTZ
37 &QZ_bootstrap,
38#endif
39#if SDL_VIDEO_DRIVER_X11
40 &X11_bootstrap,
41#endif
42#if SDL_VIDEO_DRIVER_DGA
43 &DGA_bootstrap,
44#endif
45#if SDL_VIDEO_DRIVER_NANOX
46 &NX_bootstrap,
47#endif
48#if SDL_VIDEO_DRIVER_IPOD
49 &iPod_bootstrap,
50#endif
51#if SDL_VIDEO_DRIVER_QTOPIA
52 &Qtopia_bootstrap,
53#endif
54#if SDL_VIDEO_DRIVER_WSCONS
55 &WSCONS_bootstrap,
56#endif
57#if SDL_VIDEO_DRIVER_FBCON
58 &FBCON_bootstrap,
59#endif
60#if SDL_VIDEO_DRIVER_DIRECTFB
61 &DirectFB_bootstrap,
62#endif
63#if SDL_VIDEO_DRIVER_PS2GS
64 &PS2GS_bootstrap,
65#endif
66#if SDL_VIDEO_DRIVER_PS3
67 &PS3_bootstrap,
68#endif
69#if SDL_VIDEO_DRIVER_GGI
70 &GGI_bootstrap,
71#endif
72#if SDL_VIDEO_DRIVER_VGL
73 &VGL_bootstrap,
74#endif
75#if SDL_VIDEO_DRIVER_SVGALIB
76 &SVGALIB_bootstrap,
77#endif
78#if SDL_VIDEO_DRIVER_GAPI
79 &GAPI_bootstrap,
80#endif
81#if SDL_VIDEO_DRIVER_WINDIB
82 &WINDIB_bootstrap,
83#endif
84#if SDL_VIDEO_DRIVER_DDRAW
85 &DIRECTX_bootstrap,
86#endif
87#if SDL_VIDEO_DRIVER_BWINDOW
88 &BWINDOW_bootstrap,
89#endif
90#if SDL_VIDEO_DRIVER_TOOLBOX
91 &TOOLBOX_bootstrap,
92#endif
93#if SDL_VIDEO_DRIVER_DRAWSPROCKET
94 &DSp_bootstrap,
95#endif
96#if SDL_VIDEO_DRIVER_PHOTON
97 &ph_bootstrap,
98#endif
99#if SDL_VIDEO_DRIVER_EPOC
100 &EPOC_bootstrap,
101#endif
102#if SDL_VIDEO_DRIVER_XBIOS
103 &XBIOS_bootstrap,
104#endif
105#if SDL_VIDEO_DRIVER_GEM
106 &GEM_bootstrap,
107#endif
108#if SDL_VIDEO_DRIVER_PICOGUI
109 &PG_bootstrap,
110#endif
111#if SDL_VIDEO_DRIVER_DC
112 &DC_bootstrap,
113#endif
114#if SDL_VIDEO_DRIVER_NDS
115 &NDS_bootstrap,
116#endif
117#if SDL_VIDEO_DRIVER_RISCOS
118 &RISCOS_bootstrap,
119#endif
120#if SDL_VIDEO_DRIVER_OS2FS
121 &OS2FSLib_bootstrap,
122#endif
123#if SDL_VIDEO_DRIVER_AALIB
124 &AALIB_bootstrap,
125#endif
126#if SDL_VIDEO_DRIVER_CACA
127 &CACA_bootstrap,
128#endif
129#if SDL_VIDEO_DRIVER_DUMMY
130 &DUMMY_bootstrap,
131#endif
132 NULL
133};
134
135SDL_VideoDevice *current_video = NULL;
136
137/* Various local functions */
138int SDL_VideoInit(const char *driver_name, Uint32 flags);
139void SDL_VideoQuit(void);
140void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects);
141
142static SDL_GrabMode SDL_WM_GrabInputOff(void);
143#if SDL_VIDEO_OPENGL
144static int lock_count = 0;
145#endif
146
147
148/*
149 * Initialize the video and event subsystems -- determine native pixel format
150 */
151int SDL_VideoInit (const char *driver_name, Uint32 flags)
152{
153 SDL_VideoDevice *video;
154 int index;
155 int i;
156 SDL_PixelFormat vformat;
157 Uint32 video_flags;
158
159 /* Toggle the event thread flags, based on OS requirements */
160#if defined(MUST_THREAD_EVENTS)
161 flags |= SDL_INIT_EVENTTHREAD;
162#elif defined(CANT_THREAD_EVENTS)
163 if ( (flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD ) {
164 SDL_SetError("OS doesn't support threaded events");
165 return(-1);
166 }
167#endif
168
169 /* Check to make sure we don't overwrite 'current_video' */
170 if ( current_video != NULL ) {
171 SDL_VideoQuit();
172 }
173
174 /* Select the proper video driver */
175 index = 0;
176 video = NULL;
177 if ( driver_name != NULL ) {
178#if 0 /* This will be replaced with a better driver selection API */
179 if ( SDL_strrchr(driver_name, ':') != NULL ) {
180 index = atoi(SDL_strrchr(driver_name, ':')+1);
181 }
182#endif
183 for ( i=0; bootstrap[i]; ++i ) {
184 if ( SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) {
185 if ( bootstrap[i]->available() ) {
186 video = bootstrap[i]->create(index);
187 break;
188 }
189 }
190 }
191 } else {
192 for ( i=0; bootstrap[i]; ++i ) {
193 if ( bootstrap[i]->available() ) {
194 video = bootstrap[i]->create(index);
195 if ( video != NULL ) {
196 break;
197 }
198 }
199 }
200 }
201 if ( video == NULL ) {
202 SDL_SetError("No available video device");
203 return(-1);
204 }
205 current_video = video;
206 current_video->name = bootstrap[i]->name;
207
208 /* Do some basic variable initialization */
209 video->screen = NULL;
210 video->shadow = NULL;
211 video->visible = NULL;
212 video->physpal = NULL;
213 video->gammacols = NULL;
214 video->gamma = NULL;
215 video->wm_title = NULL;
216 video->wm_icon = NULL;
217 video->offset_x = 0;
218 video->offset_y = 0;
219 SDL_memset(&video->info, 0, (sizeof video->info));
220
221 video->displayformatalphapixel = NULL;
222
223 /* Set some very sane GL defaults */
224 video->gl_config.driver_loaded = 0;
225 video->gl_config.dll_handle = NULL;
226 video->gl_config.red_size = 3;
227 video->gl_config.green_size = 3;
228 video->gl_config.blue_size = 2;
229 video->gl_config.alpha_size = 0;
230 video->gl_config.buffer_size = 0;
231 video->gl_config.depth_size = 16;
232 video->gl_config.stencil_size = 0;
233 video->gl_config.double_buffer = 1;
234 video->gl_config.accum_red_size = 0;
235 video->gl_config.accum_green_size = 0;
236 video->gl_config.accum_blue_size = 0;
237 video->gl_config.accum_alpha_size = 0;
238 video->gl_config.stereo = 0;
239 video->gl_config.multisamplebuffers = 0;
240 video->gl_config.multisamplesamples = 0;
241 video->gl_config.accelerated = -1; /* not known, don't set */
242 video->gl_config.swap_control = -1; /* not known, don't set */
243
244 /* Initialize the video subsystem */
245 SDL_memset(&vformat, 0, sizeof(vformat));
246 if ( video->VideoInit(video, &vformat) < 0 ) {
247 SDL_VideoQuit();
248 return(-1);
249 }
250
251 /* Create a zero sized video surface of the appropriate format */
252 video_flags = SDL_SWSURFACE;
253 SDL_VideoSurface = SDL_CreateRGBSurface(video_flags, 0, 0,
254 vformat.BitsPerPixel,
255 vformat.Rmask, vformat.Gmask, vformat.Bmask, 0);
256 if ( SDL_VideoSurface == NULL ) {
257 SDL_VideoQuit();
258 return(-1);
259 }
260 SDL_PublicSurface = NULL; /* Until SDL_SetVideoMode() */
261
262#if 0 /* Don't change the current palette - may be used by other programs.
263 * The application can't do anything with the display surface until
264 * a video mode has been set anyway. :)
265 */
266 /* If we have a palettized surface, create a default palette */
267 if ( SDL_VideoSurface->format->palette ) {
268 SDL_PixelFormat *vf = SDL_VideoSurface->format;
269 SDL_DitherColors(vf->palette->colors, vf->BitsPerPixel);
270 video->SetColors(video,
271 0, vf->palette->ncolors, vf->palette->colors);
272 }
273#endif
274 video->info.vfmt = SDL_VideoSurface->format;
275
276 /* Start the event loop */
277 if ( SDL_StartEventLoop(flags) < 0 ) {
278 SDL_VideoQuit();
279 return(-1);
280 }
281 SDL_CursorInit(flags & SDL_INIT_EVENTTHREAD);
282
283 /* We're ready to go! */
284 return(0);
285}
286
287char *SDL_VideoDriverName(char *namebuf, int maxlen)
288{
289 if ( current_video != NULL ) {
290 SDL_strlcpy(namebuf, current_video->name, maxlen);
291 return(namebuf);
292 }
293 return(NULL);
294}
295
296/*
297 * Get the current display surface
298 */
299SDL_Surface *SDL_GetVideoSurface(void)
300{
301 SDL_Surface *visible;
302
303 visible = NULL;
304 if ( current_video ) {
305 visible = current_video->visible;
306 }
307 return(visible);
308}
309
310/*
311 * Get the current information about the video hardware
312 */
313const SDL_VideoInfo *SDL_GetVideoInfo(void)
314{
315 const SDL_VideoInfo *info;
316
317 info = NULL;
318 if ( current_video ) {
319 info = &current_video->info;
320 }
321 return(info);
322}
323
324/*
325 * Return a pointer to an array of available screen dimensions for the
326 * given format, sorted largest to smallest. Returns NULL if there are
327 * no dimensions available for a particular format, or (SDL_Rect **)-1
328 * if any dimension is okay for the given format. If 'format' is NULL,
329 * the mode list will be for the format given by SDL_GetVideoInfo()->vfmt
330 */
331SDL_Rect ** SDL_ListModes (SDL_PixelFormat *format, Uint32 flags)
332{
333 SDL_VideoDevice *video = current_video;
334 SDL_VideoDevice *this = current_video;
335 SDL_Rect **modes;
336
337 modes = NULL;
338 if ( SDL_VideoSurface ) {
339 if ( format == NULL ) {
340 format = SDL_VideoSurface->format;
341 }
342 modes = video->ListModes(this, format, flags);
343 }
344 return(modes);
345}
346
347/*
348 * Check to see if a particular video mode is supported.
349 * It returns 0 if the requested mode is not supported under any bit depth,
350 * or returns the bits-per-pixel of the closest available mode with the
351 * given width and height. If this bits-per-pixel is different from the
352 * one used when setting the video mode, SDL_SetVideoMode() will succeed,
353 * but will emulate the requested bits-per-pixel with a shadow surface.
354 */
355static Uint8 SDL_closest_depths[4][8] = {
356 /* 8 bit closest depth ordering */
357 { 0, 8, 16, 15, 32, 24, 0, 0 },
358 /* 15,16 bit closest depth ordering */
359 { 0, 16, 15, 32, 24, 8, 0, 0 },
360 /* 24 bit closest depth ordering */
361 { 0, 24, 32, 16, 15, 8, 0, 0 },
362 /* 32 bit closest depth ordering */
363 { 0, 32, 16, 15, 24, 8, 0, 0 }
364};
365
366
367#ifdef __MACOS__ /* MPW optimization bug? */
368#define NEGATIVE_ONE 0xFFFFFFFF
369#else
370#define NEGATIVE_ONE -1
371#endif
372
373int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags)
374{
375 int table, b, i;
376 int supported;
377 SDL_PixelFormat format;
378 SDL_Rect **sizes;
379
380 /* Currently 1 and 4 bpp are not supported */
381 if ( bpp < 8 || bpp > 32 ) {
382 return(0);
383 }
384 if ( (width <= 0) || (height <= 0) ) {
385 return(0);
386 }
387
388 /* Search through the list valid of modes */
389 SDL_memset(&format, 0, sizeof(format));
390 supported = 0;
391 table = ((bpp+7)/8)-1;
392 SDL_closest_depths[table][0] = bpp;
393 SDL_closest_depths[table][7] = 0;
394 for ( b = 0; !supported && SDL_closest_depths[table][b]; ++b ) {
395 format.BitsPerPixel = SDL_closest_depths[table][b];
396 sizes = SDL_ListModes(&format, flags);
397 if ( sizes == (SDL_Rect **)0 ) {
398 /* No sizes supported at this bit-depth */
399 continue;
400 } else
401 if (sizes == (SDL_Rect **)NEGATIVE_ONE) {
402 /* Any size supported at this bit-depth */
403 supported = 1;
404 continue;
405 } else if (current_video->handles_any_size) {
406 /* Driver can center a smaller surface to simulate fullscreen */
407 for ( i=0; sizes[i]; ++i ) {
408 if ((sizes[i]->w >= width) && (sizes[i]->h >= height)) {
409 supported = 1; /* this mode can fit the centered window. */
410 break;
411 }
412 }
413 } else
414 for ( i=0; sizes[i]; ++i ) {
415 if ((sizes[i]->w == width) && (sizes[i]->h == height)) {
416 supported = 1;
417 break;
418 }
419 }
420 }
421 if ( supported ) {
422 --b;
423 return(SDL_closest_depths[table][b]);
424 } else {
425 return(0);
426 }
427}
428
429/*
430 * Get the closest non-emulated video mode to the one requested
431 */
432static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags)
433{
434 int table, b, i;
435 int supported;
436 int native_bpp;
437 SDL_PixelFormat format;
438 SDL_Rect **sizes;
439
440 /* Check parameters */
441 if ( *BitsPerPixel < 8 || *BitsPerPixel > 32 ) {
442 SDL_SetError("Invalid bits per pixel (range is {8...32})");
443 return(0);
444 }
445 if ((*w <= 0) || (*h <= 0)) {
446 SDL_SetError("Invalid width or height");
447 return(0);
448 }
449
450 /* Try the original video mode, get the closest depth */
451 native_bpp = SDL_VideoModeOK(*w, *h, *BitsPerPixel, flags);
452 if ( native_bpp == *BitsPerPixel ) {
453 return(1);
454 }
455 if ( native_bpp > 0 ) {
456 *BitsPerPixel = native_bpp;
457 return(1);
458 }
459
460 /* No exact size match at any depth, look for closest match */
461 SDL_memset(&format, 0, sizeof(format));
462 supported = 0;
463 table = ((*BitsPerPixel+7)/8)-1;
464 SDL_closest_depths[table][0] = *BitsPerPixel;
465 SDL_closest_depths[table][7] = SDL_VideoSurface->format->BitsPerPixel;
466 for ( b = 0; !supported && SDL_closest_depths[table][b]; ++b ) {
467 int best;
468
469 format.BitsPerPixel = SDL_closest_depths[table][b];
470 sizes = SDL_ListModes(&format, flags);
471 if ( sizes == (SDL_Rect **)0 ) {
472 /* No sizes supported at this bit-depth */
473 continue;
474 }
475 best=0;
476 for ( i=0; sizes[i]; ++i ) {
477 /* Mode with both dimensions bigger or equal than asked ? */
478 if ((sizes[i]->w >= *w) && (sizes[i]->h >= *h)) {
479 /* Mode with any dimension smaller or equal than current best ? */
480 if ((sizes[i]->w <= sizes[best]->w) || (sizes[i]->h <= sizes[best]->h)) {
481 /* Now choose the mode that has less pixels */
482 if ((sizes[i]->w * sizes[i]->h) <= (sizes[best]->w * sizes[best]->h)) {
483 best=i;
484 supported = 1;
485 }
486 }
487 }
488 }
489 if (supported) {
490 *w=sizes[best]->w;
491 *h=sizes[best]->h;
492 *BitsPerPixel = SDL_closest_depths[table][b];
493 }
494 }
495 if ( ! supported ) {
496 SDL_SetError("No video mode large enough for %dx%d", *w, *h);
497 }
498 return(supported);
499}
500
501/* This should probably go somewhere else -- like SDL_surface.c */
502static void SDL_ClearSurface(SDL_Surface *surface)
503{
504 Uint32 black;
505
506 black = SDL_MapRGB(surface->format, 0, 0, 0);
507 SDL_FillRect(surface, NULL, black);
508 if ((surface->flags&SDL_HWSURFACE) && (surface->flags&SDL_DOUBLEBUF)) {
509 SDL_Flip(surface);
510 SDL_FillRect(surface, NULL, black);
511 }
512 if (surface->flags&SDL_FULLSCREEN) {
513 SDL_Flip(surface);
514 }
515}
516
517/*
518 * Create a shadow surface suitable for fooling the app. :-)
519 */
520static void SDL_CreateShadowSurface(int depth)
521{
522 Uint32 Rmask, Gmask, Bmask;
523
524 /* Allocate the shadow surface */
525 if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) {
526 Rmask = (SDL_VideoSurface->format)->Rmask;
527 Gmask = (SDL_VideoSurface->format)->Gmask;
528 Bmask = (SDL_VideoSurface->format)->Bmask;
529 } else {
530 Rmask = Gmask = Bmask = 0;
531 }
532 SDL_ShadowSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,
533 SDL_VideoSurface->w, SDL_VideoSurface->h,
534 depth, Rmask, Gmask, Bmask, 0);
535 if ( SDL_ShadowSurface == NULL ) {
536 return;
537 }
538
539 /* 8-bit shadow surfaces report that they have exclusive palette */
540 if ( SDL_ShadowSurface->format->palette ) {
541 SDL_ShadowSurface->flags |= SDL_HWPALETTE;
542 if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) {
543 SDL_memcpy(SDL_ShadowSurface->format->palette->colors,
544 SDL_VideoSurface->format->palette->colors,
545 SDL_VideoSurface->format->palette->ncolors*
546 sizeof(SDL_Color));
547 } else {
548 SDL_DitherColors(
549 SDL_ShadowSurface->format->palette->colors, depth);
550 }
551 }
552
553 /* If the video surface is resizable, the shadow should say so */
554 if ( (SDL_VideoSurface->flags & SDL_RESIZABLE) == SDL_RESIZABLE ) {
555 SDL_ShadowSurface->flags |= SDL_RESIZABLE;
556 }
557 /* If the video surface has no frame, the shadow should say so */
558 if ( (SDL_VideoSurface->flags & SDL_NOFRAME) == SDL_NOFRAME ) {
559 SDL_ShadowSurface->flags |= SDL_NOFRAME;
560 }
561 /* If the video surface is fullscreen, the shadow should say so */
562 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
563 SDL_ShadowSurface->flags |= SDL_FULLSCREEN;
564 }
565 /* If the video surface is flippable, the shadow should say so */
566 if ( (SDL_VideoSurface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
567 SDL_ShadowSurface->flags |= SDL_DOUBLEBUF;
568 }
569 return;
570}
571
572#ifdef __QNXNTO__
573 #include <sys/neutrino.h>
574#endif /* __QNXNTO__ */
575
576#ifdef WIN32
577 extern int sysevents_mouse_pressed;
578#endif
579
580/*
581 * Set the requested video mode, allocating a shadow buffer if necessary.
582 */
583SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
584{
585 SDL_VideoDevice *video, *this;
586 SDL_Surface *prev_mode, *mode;
587 int video_w;
588 int video_h;
589 int video_bpp;
590 int is_opengl;
591 SDL_GrabMode saved_grab;
592
593 #ifdef WIN32
594 sysevents_mouse_pressed = 0;
595 #endif
596
597 /* Start up the video driver, if necessary..
598 WARNING: This is the only function protected this way!
599 */
600 if ( ! current_video ) {
601 if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0 ) {
602 return(NULL);
603 }
604 }
605 this = video = current_video;
606
607 /* Default to the current width and height */
608 if ( width == 0 ) {
609 width = video->info.current_w;
610 }
611 if ( height == 0 ) {
612 height = video->info.current_h;
613 }
614 /* Default to the current video bpp */
615 if ( bpp == 0 ) {
616 flags |= SDL_ANYFORMAT;
617 bpp = SDL_VideoSurface->format->BitsPerPixel;
618 }
619
620 /* Get a good video mode, the closest one possible */
621 video_w = width;
622 video_h = height;
623 video_bpp = bpp;
624 if ( ! SDL_GetVideoMode(&video_w, &video_h, &video_bpp, flags) ) {
625 return(NULL);
626 }
627
628 /* Check the requested flags */
629 /* There's no palette in > 8 bits-per-pixel mode */
630 if ( video_bpp > 8 ) {
631 flags &= ~SDL_HWPALETTE;
632 }
633#if 0
634 if ( (flags&SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
635 /* There's no windowed double-buffering */
636 flags &= ~SDL_DOUBLEBUF;
637 }
638#endif
639 if ( (flags&SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
640 /* Use hardware surfaces when double-buffering */
641 flags |= SDL_HWSURFACE;
642 }
643
644 is_opengl = ( ( flags & SDL_OPENGL ) == SDL_OPENGL );
645 if ( is_opengl ) {
646 /* These flags are for 2D video modes only */
647 flags &= ~(SDL_HWSURFACE|SDL_DOUBLEBUF);
648 }
649
650 /* Reset the keyboard here so event callbacks can run */
651 SDL_ResetKeyboard();
652 SDL_ResetMouse();
653 SDL_SetMouseRange(width, height);
654 SDL_cursorstate &= ~CURSOR_USINGSW;
655
656 /* Clean up any previous video mode */
657 if ( SDL_PublicSurface != NULL ) {
658 SDL_PublicSurface = NULL;
659 }
660 if ( SDL_ShadowSurface != NULL ) {
661 SDL_Surface *ready_to_go;
662 ready_to_go = SDL_ShadowSurface;
663 SDL_ShadowSurface = NULL;
664 SDL_FreeSurface(ready_to_go);
665 }
666 if ( video->physpal ) {
667 SDL_free(video->physpal->colors);
668 SDL_free(video->physpal);
669 video->physpal = NULL;
670 }
671 if( video->gammacols) {
672 SDL_free(video->gammacols);
673 video->gammacols = NULL;
674 }
675
676 /* Save the previous grab state and turn off grab for mode switch */
677 saved_grab = SDL_WM_GrabInputOff();
678
679 /* Try to set the video mode, along with offset and clipping */
680 prev_mode = SDL_VideoSurface;
681 SDL_LockCursor();
682 SDL_VideoSurface = NULL; /* In case it's freed by driver */
683 mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags);
684 if ( mode ) { /* Prevent resize events from mode change */
685 /* But not on OS/2 */
686#ifndef __OS2__
687 SDL_PrivateResize(mode->w, mode->h);
688#endif
689
690 /* Sam - If we asked for OpenGL mode, and didn't get it, fail */
691 if ( is_opengl && !(mode->flags & SDL_OPENGL) ) {
692 mode = NULL;
693 SDL_SetError("OpenGL not available");
694 }
695 }
696 /*
697 * rcg11292000
698 * If you try to set an SDL_OPENGL surface, and fail to find a
699 * matching visual, then the next call to SDL_SetVideoMode()
700 * will segfault, since we no longer point to a dummy surface,
701 * but rather NULL.
702 * Sam 11/29/00
703 * WARNING, we need to make sure that the previous mode hasn't
704 * already been freed by the video driver. What do we do in
705 * that case? Should we call SDL_VideoInit() again?
706 */
707 SDL_VideoSurface = (mode != NULL) ? mode : prev_mode;
708
709 if ( (mode != NULL) && (!is_opengl) ) {
710 /* Sanity check */
711 if ( (mode->w < width) || (mode->h < height) ) {
712 SDL_SetError("Video mode smaller than requested");
713 return(NULL);
714 }
715
716 /* If we have a palettized surface, create a default palette */
717 if ( mode->format->palette ) {
718 SDL_PixelFormat *vf = mode->format;
719 SDL_DitherColors(vf->palette->colors, vf->BitsPerPixel);
720 video->SetColors(this, 0, vf->palette->ncolors,
721 vf->palette->colors);
722 }
723
724 /* Clear the surface to black */
725 video->offset_x = 0;
726 video->offset_y = 0;
727 mode->offset = 0;
728 SDL_SetClipRect(mode, NULL);
729 SDL_ClearSurface(mode);
730
731 /* Now adjust the offsets to match the desired mode */
732 video->offset_x = (mode->w-width)/2;
733 video->offset_y = (mode->h-height)/2;
734 mode->offset = video->offset_y*mode->pitch +
735 video->offset_x*mode->format->BytesPerPixel;
736#ifdef DEBUG_VIDEO
737 fprintf(stderr,
738 "Requested mode: %dx%dx%d, obtained mode %dx%dx%d (offset %d)\n",
739 width, height, bpp,
740 mode->w, mode->h, mode->format->BitsPerPixel, mode->offset);
741#endif
742 mode->w = width;
743 mode->h = height;
744 SDL_SetClipRect(mode, NULL);
745 }
746 SDL_ResetCursor();
747 SDL_UnlockCursor();
748
749 /* If we failed setting a video mode, return NULL... (Uh Oh!) */
750 if ( mode == NULL ) {
751 return(NULL);
752 }
753
754 /* If there is no window manager, set the SDL_NOFRAME flag */
755 if ( ! video->info.wm_available ) {
756 mode->flags |= SDL_NOFRAME;
757 }
758
759 /* Reset the mouse cursor and grab for new video mode */
760 SDL_SetCursor(NULL);
761 if ( video->UpdateMouse ) {
762 video->UpdateMouse(this);
763 }
764 SDL_WM_GrabInput(saved_grab);
765 SDL_GetRelativeMouseState(NULL, NULL); /* Clear first large delta */
766
767#if SDL_VIDEO_OPENGL
768 /* Load GL symbols (before MakeCurrent, where we need glGetString). */
769 if ( flags & (SDL_OPENGL | SDL_OPENGLBLIT) ) {
770
771#if defined(__QNXNTO__) && (_NTO_VERSION < 630)
772#define __SDL_NOGETPROCADDR__
773#elif defined(__MINT__)
774#define __SDL_NOGETPROCADDR__
775#endif
776#ifdef __SDL_NOGETPROCADDR__
777 #define SDL_PROC(ret,func,params) video->func=func;
778#else
779 #define SDL_PROC(ret,func,params) \
780 do { \
781 video->func = SDL_GL_GetProcAddress(#func); \
782 if ( ! video->func ) { \
783 SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \
784 return(NULL); \
785 } \
786 } while ( 0 );
787
788#endif /* __SDL_NOGETPROCADDR__ */
789
790#include "SDL_glfuncs.h"
791#undef SDL_PROC
792 }
793#endif /* SDL_VIDEO_OPENGL */
794
795 /* If we're running OpenGL, make the context current */
796 if ( (video->screen->flags & SDL_OPENGL) &&
797 video->GL_MakeCurrent ) {
798 if ( video->GL_MakeCurrent(this) < 0 ) {
799 return(NULL);
800 }
801 }
802
803 /* Set up a fake SDL surface for OpenGL "blitting" */
804 if ( (flags & SDL_OPENGLBLIT) == SDL_OPENGLBLIT ) {
805 /* Load GL functions for performing the texture updates */
806#if SDL_VIDEO_OPENGL
807
808 /* Create a software surface for blitting */
809#ifdef GL_VERSION_1_2
810 /* If the implementation either supports the packed pixels
811 extension, or implements the core OpenGL 1.2 API, it will
812 support the GL_UNSIGNED_SHORT_5_6_5 texture format.
813 */
814 if ( (bpp == 16) &&
815 (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") ||
816 (SDL_atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f))
817 ) {
818 video->is_32bit = 0;
819 SDL_VideoSurface = SDL_CreateRGBSurface(
820 flags,
821 width,
822 height,
823 16,
824 31 << 11,
825 63 << 5,
826 31,
827 0
828 );
829 }
830 else
831#endif /* OpenGL 1.2 */
832 {
833 video->is_32bit = 1;
834 SDL_VideoSurface = SDL_CreateRGBSurface(
835 flags,
836 width,
837 height,
838 32,
839#if SDL_BYTEORDER == SDL_LIL_ENDIAN
840 0x000000FF,
841 0x0000FF00,
842 0x00FF0000,
843 0xFF000000
844#else
845 0xFF000000,
846 0x00FF0000,
847 0x0000FF00,
848 0x000000FF
849#endif
850 );
851 }
852 if ( ! SDL_VideoSurface ) {
853 return(NULL);
854 }
855 SDL_VideoSurface->flags = mode->flags | SDL_OPENGLBLIT;
856
857 /* Free the original video mode surface (is this safe?) */
858 SDL_FreeSurface(mode);
859
860 /* Set the surface completely opaque & white by default */
861 SDL_memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch );
862 video->glGenTextures( 1, &video->texture );
863 video->glBindTexture( GL_TEXTURE_2D, video->texture );
864 video->glTexImage2D(
865 GL_TEXTURE_2D,
866 0,
867 video->is_32bit ? GL_RGBA : GL_RGB,
868 256,
869 256,
870 0,
871 video->is_32bit ? GL_RGBA : GL_RGB,
872#ifdef GL_VERSION_1_2
873 video->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
874#else
875 GL_UNSIGNED_BYTE,
876#endif
877 NULL);
878
879 video->UpdateRects = SDL_GL_UpdateRectsLock;
880#else
881 SDL_SetError("Somebody forgot to #define SDL_VIDEO_OPENGL");
882 return(NULL);
883#endif
884 }
885
886 /* Create a shadow surface if necessary */
887 /* There are three conditions under which we create a shadow surface:
888 1. We need a particular bits-per-pixel that we didn't get.
889 2. We need a hardware palette and didn't get one.
890 3. We need a software surface and got a hardware surface.
891 */
892 if ( !(SDL_VideoSurface->flags & SDL_OPENGL) &&
893 (
894 ( !(flags&SDL_ANYFORMAT) &&
895 (SDL_VideoSurface->format->BitsPerPixel != bpp)) ||
896 ( (flags&SDL_HWPALETTE) &&
897 !(SDL_VideoSurface->flags&SDL_HWPALETTE)) ||
898 /* If the surface is in hardware, video writes are visible
899 as soon as they are performed, so we need to buffer them
900 */
901 ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) &&
902 (SDL_VideoSurface->flags&SDL_HWSURFACE)) ||
903 ( (flags&SDL_DOUBLEBUF) &&
904 (SDL_VideoSurface->flags&SDL_HWSURFACE) &&
905 !(SDL_VideoSurface->flags&SDL_DOUBLEBUF))
906 ) ) {
907 SDL_CreateShadowSurface(bpp);
908 if ( SDL_ShadowSurface == NULL ) {
909 SDL_SetError("Couldn't create shadow surface");
910 return(NULL);
911 }
912 SDL_PublicSurface = SDL_ShadowSurface;
913 } else {
914 SDL_PublicSurface = SDL_VideoSurface;
915 }
916 video->info.vfmt = SDL_VideoSurface->format;
917 video->info.current_w = SDL_VideoSurface->w;
918 video->info.current_h = SDL_VideoSurface->h;
919
920 /* We're done! */
921 return(SDL_PublicSurface);
922}
923
924/*
925 * Convert a surface into the video pixel format.
926 */
927SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface)
928{
929 Uint32 flags;
930
931 if ( ! SDL_PublicSurface ) {
932 SDL_SetError("No video mode has been set");
933 return(NULL);
934 }
935 /* Set the flags appropriate for copying to display surface */
936 if (((SDL_PublicSurface->flags&SDL_HWSURFACE) == SDL_HWSURFACE) && current_video->info.blit_hw)
937 flags = SDL_HWSURFACE;
938 else
939 flags = SDL_SWSURFACE;
940#ifdef AUTORLE_DISPLAYFORMAT
941 flags |= (surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA));
942 flags |= SDL_RLEACCELOK;
943#else
944 flags |= surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA|SDL_RLEACCELOK);
945#endif
946 return(SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags));
947}
948
949/*
950 * Convert a surface into a format that's suitable for blitting to
951 * the screen, but including an alpha channel.
952 */
953SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface)
954{
955 SDL_PixelFormat *vf;
956 SDL_PixelFormat *format;
957 SDL_Surface *converted;
958 Uint32 flags;
959 /* default to ARGB8888 */
960 Uint32 amask = 0xff000000;
961 Uint32 rmask = 0x00ff0000;
962 Uint32 gmask = 0x0000ff00;
963 Uint32 bmask = 0x000000ff;
964
965 if ( ! SDL_PublicSurface ) {
966 SDL_SetError("No video mode has been set");
967 return(NULL);
968 }
969 vf = SDL_PublicSurface->format;
970
971 switch(vf->BytesPerPixel) {
972 case 2:
973 /* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}.
974 For anything else (like ARGB4444) it doesn't matter
975 since we have no special code for it anyway */
976 if ( (vf->Rmask == 0x1f) &&
977 (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) {
978 rmask = 0xff;
979 bmask = 0xff0000;
980 }
981 break;
982
983 case 3:
984 case 4:
985 /* Keep the video format, as long as the high 8 bits are
986 unused or alpha */
987 if ( (vf->Rmask == 0xff) && (vf->Bmask == 0xff0000) ) {
988 rmask = 0xff;
989 bmask = 0xff0000;
990 } else if ( vf->Rmask == 0xFF00 && (vf->Bmask == 0xFF000000) ) {
991 amask = 0x000000FF;
992 rmask = 0x0000FF00;
993 gmask = 0x00FF0000;
994 bmask = 0xFF000000;
995 }
996 break;
997
998 default:
999 /* We have no other optimised formats right now. When/if a new
1000 optimised alpha format is written, add the converter here */
1001 break;
1002 }
1003 format = SDL_AllocFormat(32, rmask, gmask, bmask, amask);
1004 flags = SDL_PublicSurface->flags & SDL_HWSURFACE;
1005 flags |= surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
1006 converted = SDL_ConvertSurface(surface, format, flags);
1007 SDL_FreeFormat(format);
1008 return(converted);
1009}
1010
1011/*
1012 * Update a specific portion of the physical screen
1013 */
1014void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
1015{
1016 if ( screen ) {
1017 SDL_Rect rect;
1018
1019 /* Perform some checking */
1020 if ( w == 0 )
1021 w = screen->w;
1022 if ( h == 0 )
1023 h = screen->h;
1024 if ( (int)(x+w) > screen->w )
1025 return;
1026 if ( (int)(y+h) > screen->h )
1027 return;
1028
1029 /* Fill the rectangle */
1030 rect.x = (Sint16)x;
1031 rect.y = (Sint16)y;
1032 rect.w = (Uint16)w;
1033 rect.h = (Uint16)h;
1034 SDL_UpdateRects(screen, 1, &rect);
1035 }
1036}
1037void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects)
1038{
1039 int i;
1040 SDL_VideoDevice *video = current_video;
1041 SDL_VideoDevice *this = current_video;
1042
1043 if ( (screen->flags & (SDL_OPENGL | SDL_OPENGLBLIT)) == SDL_OPENGL ) {
1044 SDL_SetError("OpenGL active, use SDL_GL_SwapBuffers()");
1045 return;
1046 }
1047 if ( screen == SDL_ShadowSurface ) {
1048 /* Blit the shadow surface using saved mapping */
1049 SDL_Palette *pal = screen->format->palette;
1050 SDL_Color *saved_colors = NULL;
1051 if ( pal && !(SDL_VideoSurface->flags & SDL_HWPALETTE) ) {
1052 /* simulated 8bpp, use correct physical palette */
1053 saved_colors = pal->colors;
1054 if ( video->gammacols ) {
1055 /* gamma-corrected palette */
1056 pal->colors = video->gammacols;
1057 } else if ( video->physpal ) {
1058 /* physical palette different from logical */
1059 pal->colors = video->physpal->colors;
1060 }
1061 }
1062 if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) {
1063 SDL_LockCursor();
1064 SDL_DrawCursor(SDL_ShadowSurface);
1065 for ( i=0; i<numrects; ++i ) {
1066 SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
1067 SDL_VideoSurface, &rects[i]);
1068 }
1069 SDL_EraseCursor(SDL_ShadowSurface);
1070 SDL_UnlockCursor();
1071 } else {
1072 for ( i=0; i<numrects; ++i ) {
1073 SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
1074 SDL_VideoSurface, &rects[i]);
1075 }
1076 }
1077 if ( saved_colors ) {
1078 pal->colors = saved_colors;
1079 }
1080
1081 /* Fall through to video surface update */
1082 screen = SDL_VideoSurface;
1083 }
1084 if ( screen == SDL_VideoSurface ) {
1085 /* Update the video surface */
1086 if ( screen->offset ) {
1087 for ( i=0; i<numrects; ++i ) {
1088 rects[i].x += video->offset_x;
1089 rects[i].y += video->offset_y;
1090 }
1091 video->UpdateRects(this, numrects, rects);
1092 for ( i=0; i<numrects; ++i ) {
1093 rects[i].x -= video->offset_x;
1094 rects[i].y -= video->offset_y;
1095 }
1096 } else {
1097 video->UpdateRects(this, numrects, rects);
1098 }
1099 }
1100}
1101
1102/*
1103 * Performs hardware double buffering, if possible, or a full update if not.
1104 */
1105int SDL_Flip(SDL_Surface *screen)
1106{
1107 SDL_VideoDevice *video = current_video;
1108 /* Copy the shadow surface to the video surface */
1109 if ( screen == SDL_ShadowSurface ) {
1110 SDL_Rect rect;
1111 SDL_Palette *pal = screen->format->palette;
1112 SDL_Color *saved_colors = NULL;
1113 if ( pal && !(SDL_VideoSurface->flags & SDL_HWPALETTE) ) {
1114 /* simulated 8bpp, use correct physical palette */
1115 saved_colors = pal->colors;
1116 if ( video->gammacols ) {
1117 /* gamma-corrected palette */
1118 pal->colors = video->gammacols;
1119 } else if ( video->physpal ) {
1120 /* physical palette different from logical */
1121 pal->colors = video->physpal->colors;
1122 }
1123 }
1124
1125 rect.x = 0;
1126 rect.y = 0;
1127 rect.w = screen->w;
1128 rect.h = screen->h;
1129 if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) {
1130 SDL_LockCursor();
1131 SDL_DrawCursor(SDL_ShadowSurface);
1132 SDL_LowerBlit(SDL_ShadowSurface, &rect,
1133 SDL_VideoSurface, &rect);
1134 SDL_EraseCursor(SDL_ShadowSurface);
1135 SDL_UnlockCursor();
1136 } else {
1137 SDL_LowerBlit(SDL_ShadowSurface, &rect,
1138 SDL_VideoSurface, &rect);
1139 }
1140 if ( saved_colors ) {
1141 pal->colors = saved_colors;
1142 }
1143
1144 /* Fall through to video surface update */
1145 screen = SDL_VideoSurface;
1146 }
1147 if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
1148 SDL_VideoDevice *this = current_video;
1149 return(video->FlipHWSurface(this, SDL_VideoSurface));
1150 } else {
1151 SDL_UpdateRect(screen, 0, 0, 0, 0);
1152 }
1153 return(0);
1154}
1155
1156static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors,
1157 int firstcolor, int ncolors)
1158{
1159 SDL_Palette *pal = screen->format->palette;
1160 SDL_Palette *vidpal;
1161
1162 if ( colors != (pal->colors + firstcolor) ) {
1163 SDL_memcpy(pal->colors + firstcolor, colors,
1164 ncolors * sizeof(*colors));
1165 }
1166
1167 if ( current_video && SDL_VideoSurface ) {
1168 vidpal = SDL_VideoSurface->format->palette;
1169 if ( (screen == SDL_ShadowSurface) && vidpal ) {
1170 /*
1171 * This is a shadow surface, and the physical
1172 * framebuffer is also indexed. Propagate the
1173 * changes to its logical palette so that
1174 * updates are always identity blits
1175 */
1176 SDL_memcpy(vidpal->colors + firstcolor, colors,
1177 ncolors * sizeof(*colors));
1178 }
1179 }
1180 SDL_FormatChanged(screen);
1181}
1182
1183static int SetPalette_physical(SDL_Surface *screen,
1184 SDL_Color *colors, int firstcolor, int ncolors)
1185{
1186 SDL_VideoDevice *video = current_video;
1187 int gotall = 1;
1188
1189 if ( video->physpal ) {
1190 /* We need to copy the new colors, since we haven't
1191 * already done the copy in the logical set above.
1192 */
1193 SDL_memcpy(video->physpal->colors + firstcolor,
1194 colors, ncolors * sizeof(*colors));
1195 }
1196 if ( screen == SDL_ShadowSurface ) {
1197 if ( SDL_VideoSurface->flags & SDL_HWPALETTE ) {
1198 /*
1199 * The real screen is also indexed - set its physical
1200 * palette. The physical palette does not include the
1201 * gamma modification, we apply it directly instead,
1202 * but this only happens if we have hardware palette.
1203 */
1204 screen = SDL_VideoSurface;
1205 } else {
1206 /*
1207 * The video surface is not indexed - invalidate any
1208 * active shadow-to-video blit mappings.
1209 */
1210 if ( screen->map->dst == SDL_VideoSurface ) {
1211 SDL_InvalidateMap(screen->map);
1212 }
1213 if ( video->gamma ) {
1214 if( ! video->gammacols ) {
1215 SDL_Palette *pp = video->physpal;
1216 if(!pp)
1217 pp = screen->format->palette;
1218 video->gammacols = SDL_malloc(pp->ncolors
1219 * sizeof(SDL_Color));
1220 SDL_ApplyGamma(video->gamma,
1221 pp->colors,
1222 video->gammacols,
1223 pp->ncolors);
1224 } else {
1225 SDL_ApplyGamma(video->gamma, colors,
1226 video->gammacols
1227 + firstcolor,
1228 ncolors);
1229 }
1230 }
1231 SDL_UpdateRect(screen, 0, 0, 0, 0);
1232 }
1233 }
1234
1235 if ( screen == SDL_VideoSurface ) {
1236 SDL_Color gcolors[256];
1237
1238 if ( video->gamma ) {
1239 SDL_ApplyGamma(video->gamma, colors, gcolors, ncolors);
1240 colors = gcolors;
1241 }
1242 gotall = video->SetColors(video, firstcolor, ncolors, colors);
1243 if ( ! gotall ) {
1244 /* The video flags shouldn't have SDL_HWPALETTE, and
1245 the video driver is responsible for copying back the
1246 correct colors into the video surface palette.
1247 */
1248 ;
1249 }
1250 SDL_CursorPaletteChanged();
1251 }
1252 return gotall;
1253}
1254
1255/*
1256 * Set the physical and/or logical colormap of a surface:
1257 * Only the screen has a physical colormap. It determines what is actually
1258 * sent to the display.
1259 * The logical colormap is used to map blits to/from the surface.
1260 * 'which' is one or both of SDL_LOGPAL, SDL_PHYSPAL
1261 *
1262 * Return nonzero if all colours were set as requested, or 0 otherwise.
1263 */
1264int SDL_SetPalette(SDL_Surface *screen, int which,
1265 SDL_Color *colors, int firstcolor, int ncolors)
1266{
1267 SDL_Palette *pal;
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches