ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.20
Committed: 2005-03-19T09:59:30Z (19 years, 3 months ago) by gbeauche
Branch: MAIN
Changes since 1.19: +32 -2 lines
Log Message:
Enable build with gtk2 and default to that UI if found. Otherwise, it's
still possible to select GTK1 as --with-gtk=gtk1 or --with-gtk=gtk.

File Contents

# Content
1 dnl Process this file with autoconf to produce a configure script.
2 dnl Written in 2002 by Christian Bauer
3
4 AC_INIT([SheepShaver], 2.2, [Christian.Bauer@uni-mainz.de], SheepShaver)
5 AC_CONFIG_SRCDIR(main_unix.cpp)
6 AC_PREREQ(2.52)
7 AC_CONFIG_HEADER(config.h)
8
9 dnl Canonical system information.
10 AC_CANONICAL_HOST
11 AC_CANONICAL_TARGET
12
13 dnl Some systems do not put corefiles in the currect directory, avoid saving
14 dnl cores for the configure tests since some are intended to dump core.
15 ulimit -c 0
16
17 dnl Options.
18 AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes])
19 AC_ARG_ENABLE(ppc-emulator, [ --enable-ppc-emulator use the selected PowerPC emulator [default=auto]], [WANT_EMULATED_PPC=$enableval], [WANT_EMULATED_PPC=auto])
20 AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes])
21 AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=no]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=no])
22 AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes])
23 AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes])
24 AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]],
25 [case "$withval" in
26 gtk1) WANT_GTK="gtk";;
27 gtk|gtk2) WANT_GTK="$withval";;
28 yes) WANT_GTK="gtk2 gtk";;
29 *) WANT_GTK="no";;
30 esac],
31 [WANT_GTK="gtk2 gtk"])
32 AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
33 AC_ARG_WITH(dgcc, [ --with-dgcc=COMPILER use C++ COMPILER to compile synthetic opcodes], [DYNGEN_CC=$withval])
34
35 dnl Addressing mode
36 AC_ARG_ENABLE(addressing,
37 [ --enable-addressing=AM set the addressing mode to use [default=real]],
38 [case "$enableval" in
39 real) WANT_ADDRESSING_MODE="real";;
40 direct) WANT_ADDRESSING_MODE="direct";;
41 direct,0x*) WANT_ADDRESSING_MODE="direct"; NATMEM_OFFSET=`echo "$enableval" | sed -n '/direct,\(0[[xX]][[0-9A-Fa-f]]*\([[UuLl]]\{1,2\}\)\?\)$/s//\1/p'`;;
42 esac],
43 [WANT_ADDRESSING_MODE="real"]
44 )
45
46 dnl SDL options.
47 AC_ARG_ENABLE(sdl-static, [ --enable-sdl-static use SDL static libraries for linking [default=no]], [WANT_SDL_STATIC=$enableval], [WANT_SDL_STATIC=no])
48 AC_ARG_ENABLE(sdl-video, [ --enable-sdl-video use SDL for video graphics [default=no]], [WANT_SDL_VIDEO=$enableval], [WANT_SDL_VIDEO=no])
49 AC_ARG_ENABLE(sdl-audio, [ --enable-sdl-audio use SDL for audio [default=no]], [WANT_SDL_AUDIO=$enableval], [WANT_SDL_AUDIO=no])
50
51 dnl Checks for programs.
52 AC_PROG_CC
53 AC_PROG_CPP
54 AC_PROG_CXX
55 AC_PROG_MAKE_SET
56 AC_PROG_INSTALL
57 AC_PROG_EGREP
58 AC_PATH_PROGS(FILE, [file false])
59 AC_PATH_PROG(PERL, [perl])
60
61 dnl Check for PowerPC target CPU.
62 HAVE_PPC=no
63 AC_MSG_CHECKING(for PowerPC target CPU)
64 AC_EGREP_CPP(yes,
65 [
66 #ifdef __powerpc__
67 yes
68 #endif
69 #ifdef __ppc__
70 yes
71 #endif
72 ], [AC_MSG_RESULT(yes); HAVE_PPC=yes], AC_MSG_RESULT(no))
73
74 dnl We use native CPU if possible.
75 EMULATED_PPC=yes
76 case $WANT_EMULATED_PPC in
77 auto) [[ "x$HAVE_PPC" = "xyes" ]] && EMULATED_PPC=no;;
78 no) EMULATED_PPC=no;;
79 esac
80 if [[ "x$EMULATED_PPC" = "xyes" ]]; then
81 AC_DEFINE(EMULATED_PPC, 1, [Define if using a PowerPC CPU emulator.])
82 fi
83
84 dnl We use mon if possible.
85 MONSRCS=
86 case "x$WANT_MON" in
87 x/* | x.*)
88 mon_srcdir=$WANT_MON
89 WANT_MON=yes
90 ;;
91 xyes)
92 mon_srcdir=../../../mon/src
93 ;;
94 esac
95 if [[ "x$WANT_MON" = "xyes" ]]; then
96 AC_MSG_CHECKING(for mon)
97 if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
98 AC_MSG_RESULT(yes)
99 AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".])
100 MONSRCS="$mon_srcdir/mon.cpp $mon_srcdir/mon_6502.cpp $mon_srcdir/mon_z80.cpp $mon_srcdir/mon_cmd.cpp $mon_srcdir/mon_lowmem.cpp $mon_srcdir/mon_disass.cpp $mon_srcdir/mon_ppc.cpp $mon_srcdir/disass/floatformat.c $mon_srcdir/disass/i386-dis.c $mon_srcdir/disass/m68k-dis.c $mon_srcdir/disass/m68k-opc.c"
101 CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
102 AC_CHECK_LIB(ncurses, tgetent, ,
103 AC_CHECK_LIB(termcap, tgetent, ,
104 AC_CHECK_LIB(termlib, tgetent, ,
105 AC_CHECK_LIB(terminfo, tgetent, ,
106 AC_CHECK_LIB(Hcurses, tgetent, ,
107 AC_CHECK_LIB(curses, tgetent))))))
108 AC_CHECK_LIB(readline, readline)
109 AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
110 else
111 AC_MSG_RESULT(no)
112 AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
113 WANT_MON=no
114 fi
115 fi
116 AC_SUBST(MONSRCS)
117
118 dnl Checks for libraries.
119 AC_CHECK_LIB(posix4, sem_init)
120
121 dnl Do we need SDL?
122 WANT_SDL=no
123 if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
124 WANT_SDL=yes
125 WANT_XF86_DGA=no
126 WANT_XF86_VIDMODE=no
127 WANT_FBDEV_DGA=no
128 SDL_SUPPORT="$SDL_SUPPORT video"
129 fi
130 if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then
131 WANT_SDL=yes
132 SDL_SUPPORT="$SDL_SUPPORT audio"
133 fi
134 if [[ "x$WANT_SDL" = "xyes" ]]; then
135 AC_PATH_PROG(sdl_config, "sdl-config")
136 if [[ -n "$sdl_config" ]]; then
137 case $target_os in
138 # Special treatment for Cygwin so that we can still use the POSIX layer
139 *cygwin*)
140 sdl_cflags="-I`$sdl_config --prefix`/include/SDL"
141 sdl_libs="-L`$sdl_config --exec-prefix`/lib -lSDL"
142 ;;
143 *)
144 sdl_cflags=`$sdl_config --cflags`
145 if [[ "x$WANT_SDL_STATIC" = "xyes" ]]; then
146 sdl_libs=`$sdl_config --static-libs`
147 else
148 sdl_libs=`$sdl_config --libs`
149 fi
150 ;;
151 esac
152 CFLAGS="$CFLAGS $sdl_cflags"
153 CXXFLAGS="$CXXFLAGS $sdl_cflags"
154 LIBS="$LIBS $sdl_libs"
155 else
156 WANT_SDL=no
157 WANT_SDL_VIDEO=no
158 WANT_SDL_AUDIO=no
159 fi
160 SDL_SUPPORT=`echo "$SDL_SUPPORT" | sed -e "s/^ //"`
161 else
162 SDL_SUPPORT="none"
163 fi
164
165 dnl We need X11, if not using SDL.
166 if [[ "x$WANT_SDL_VIDEO" != "xyes" ]]; then
167 AC_PATH_XTRA
168 if [[ "x$no_x" = "xyes" ]]; then
169 AC_MSG_ERROR([You need X11 to run SheepShaver.])
170 fi
171 CFLAGS="$CFLAGS $X_CFLAGS"
172 CXXFLAGS="$CXXFLAGS $X_CFLAGS"
173 LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
174 fi
175
176 dnl We need pthreads on non-PowerPC systems. Try libpthread first, then libc_r (FreeBSD), then PTL.
177 HAVE_PTHREADS=yes
178 case $EMULATED_PPC:$target_os in
179 no:linux*|no:netbsd*)
180 dnl We do have our own pthread_cancel() implementation
181 AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if you have the pthread_cancel function.])
182 ;;
183 *:*)
184 AC_CHECK_LIB(pthread, pthread_create, , [
185 AC_CHECK_LIB(c_r, pthread_create, , [
186 AC_CHECK_LIB(PTL, pthread_create, , [
187 AC_MSG_ERROR([You need pthreads to run Basilisk II.])
188 ])
189 ])
190 ])
191 AC_CHECK_FUNCS(pthread_cancel)
192 AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
193 AC_CHECK_FUNCS(pthread_mutexattr_settype)
194 AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
195 if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
196 AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.])
197 fi
198 dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
199 SEMSRC=
200 AC_CHECK_FUNCS(sem_init, , [
201 if test "x$HAVE_PTHREADS" = "xyes"; then
202 SEMSRC=posix_sem.cpp
203 fi
204 ])
205 ;;
206 esac
207
208 dnl We use XFree86 DGA if possible.
209 if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then
210 AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [
211 AC_DEFINE(ENABLE_XF86_DGA, 1, [Define if using XFree86 DGA extension.])
212 LIBS="$LIBS -lXxf86dga"
213 ], [
214 AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.])
215 WANT_XF86_DGA=no
216 ])
217 fi
218
219 dnl We use XFree86 VidMode if possible.
220 if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then
221 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [
222 AC_DEFINE(ENABLE_XF86_VIDMODE, 1, [Define if using XFree86 DGA extension.])
223 LIBS="$LIBS -lXxf86vm"
224 ], [
225 AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.])
226 WANT_XF86_VIDMODE=no
227 ])
228 fi
229
230 dnl We use GTK+ if possible.
231 UISRCS=../dummy/prefs_editor_dummy.cpp
232 case "x$WANT_GTK" in
233 xgtk2*)
234 AM_PATH_GTK_2_0(1.3.15, [
235 AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
236 CFLAGS="$CFLAGS $GTK_CFLAGS"
237 CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
238 LIBS="$LIBS $GTK_LIBS"
239 UISRCS=prefs_editor_gtk.cpp
240 WANT_GTK=gtk2
241 ], [
242 case "x${WANT_GTK}x" in
243 *gtkx)
244 AC_MSG_WARN([Could not find GTK+ 2.0, trying with GTK+ 1.2.])
245 WANT_GTK=gtk
246 ;;
247 *)
248 AC_MSG_WARN([Could not find GTK+, disabling user interface.])
249 WANT_GTK=no
250 ;;
251 esac
252 ])
253 ;;
254 esac
255 if [[ "x$WANT_GTK" = "xgtk" ]]; then
256 AM_PATH_GTK(1.2.0, [
257 AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
258 CFLAGS="$CFLAGS $GTK_CFLAGS"
259 CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
260 LIBS="$LIBS $GTK_LIBS"
261 UISRCS=prefs_editor_gtk.cpp
262 ], [
263 AC_MSG_WARN([Could not find GTK+, disabling user interface.])
264 WANT_GTK=no
265 ])
266 fi
267
268 dnl We use ESD if possible.
269 if [[ "x$WANT_ESD" = "xyes" ]]; then
270 AM_PATH_ESD(0.2.8, [
271 AC_DEFINE(ENABLE_ESD, 1, [Define is using ESD.])
272 CFLAGS="$CFLAGS $ESD_CFLAGS"
273 CXXFLAGS="$CXXFLAGS $ESD_CFLAGS"
274 LIBS="$LIBS $ESD_LIBS"
275 ], [
276 AC_MSG_WARN([Could not find ESD, disabling ESD support.])
277 WANT_ESD=no
278 ])
279 fi
280
281 dnl We use 64-bit file size support if possible.
282 AC_SYS_LARGEFILE
283
284 dnl Checks for header files.
285 AC_HEADER_STDC
286 AC_HEADER_SYS_WAIT
287 AC_CHECK_HEADERS(malloc.h)
288 AC_CHECK_HEADERS(mach/vm_map.h mach/mach_init.h sys/mman.h)
289 AC_CHECK_HEADERS(sys/time.h sys/times.h sys/socket.h)
290 AC_CHECK_HEADERS(unistd.h fcntl.h byteswap.h dirent.h)
291 AC_CHECK_HEADERS(linux/if.h, [], [], [
292 #if HAVE_SYS_SOCKET_H
293 # include <sys/socket.h>
294 #endif
295 ])
296 AC_CHECK_HEADERS(linux/if_tun.h net/if.h net/if_tun.h)
297 AC_CHECK_HEADERS(fenv.h)
298
299 dnl Checks for typedefs, structures, and compiler characteristics.
300 AC_C_BIGENDIAN
301 AC_C_CONST
302 AC_C_INLINE
303 AC_CHECK_SIZEOF(short, 2)
304 AC_CHECK_SIZEOF(int, 4)
305 AC_CHECK_SIZEOF(long, 4)
306 AC_CHECK_SIZEOF(long long, 8)
307 AC_CHECK_SIZEOF(float, 4)
308 AC_CHECK_SIZEOF(double, 8)
309 AC_CHECK_SIZEOF(void *, 4)
310 AC_TYPE_OFF_T
311 AC_CHECK_TYPE(loff_t, off_t)
312 AC_TYPE_SIZE_T
313 AC_TYPE_SIGNAL
314 AC_HEADER_TIME
315 AC_STRUCT_TM
316
317 dnl Check whether struct sigaction has sa_restorer member.
318 AC_CACHE_CHECK([whether struct sigaction has sa_restorer],
319 ac_cv_signal_sa_restorer, [
320 AC_TRY_COMPILE([
321 #include <signal.h>
322 ], [struct sigaction sa; sa.sa_restorer = 0;],
323 ac_cv_signal_sa_restorer=yes, ac_cv_signal_sa_restorer=no,
324 dnl When cross-compiling, do not assume anything.
325 ac_cv_signal_sa_restorer=no
326 )
327 ])
328 if [[ "x$ac_cv_signal_sa_restorer" = "xyes" ]]; then
329 AC_DEFINE(HAVE_SIGNAL_SA_RESTORER, 1, [Define if sa_restorer is available in struct sigaction.])
330 fi
331
332 dnl Checks for library functions.
333 AC_CHECK_FUNCS(strdup strlcpy cfmakeraw)
334 AC_CHECK_FUNCS(nanosleep)
335 AC_CHECK_FUNCS(sigaction signal)
336 AC_CHECK_FUNCS(mmap mprotect munmap)
337 AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
338 AC_CHECK_FUNCS(posix_memalign memalign valloc)
339 AC_CHECK_FUNCS(exp2f log2f exp2 log2 trunc)
340
341 dnl Darwin seems to define mach_task_self() instead of task_self().
342 AC_CHECK_FUNCS(mach_task_self task_self)
343
344 dnl We need clock_gettime() for better performance but it may drag
345 dnl libpthread in, which we don't want for native ppc mode
346 case $EMULATED_PPC:$target_os in
347 no:linux*)
348 ;;
349 *:*)
350 AC_SEARCH_LIBS(clock_gettime, [rt posix4])
351 AC_CHECK_FUNCS(clock_gettime clock_nanosleep)
352 ;;
353 esac
354
355 dnl Check for headers and functions related to pty support (sshpty.c)
356 dnl From openssh-3.2.2p1 configure.ac
357 AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
358 AC_CHECK_FUNCS(_getpty vhangup strlcpy)
359
360 case "$host" in
361 *-*-hpux10.26)
362 disable_ptmx_check=yes
363 ;;
364 *-*-linux*)
365 no_dev_ptmx=1
366 ;;
367 mips-sony-bsd|mips-sony-newsos4)
368 AC_DEFINE(HAVE_NEWS4, 1, [Define if you are on NEWS-OS (additions from openssh-3.2.2p1, for sshpty.c).])
369 ;;
370 *-*-sco3.2v4*)
371 no_dev_ptmx=1
372 ;;
373 *-*-sco3.2v5*)
374 no_dev_ptmx=1
375 ;;
376 *-*-cygwin*)
377 no_dev_ptmx=1
378 ;;
379 esac
380
381 if test -z "$no_dev_ptmx" ; then
382 if test "x$disable_ptmx_check" != "xyes" ; then
383 AC_CHECK_FILE([/dev/ptmx],
384 [
385 AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.])
386 have_dev_ptmx=1
387 ]
388 )
389 fi
390 fi
391 AC_CHECK_FILE([/dev/ptc],
392 [
393 AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.])
394 have_dev_ptc=1
395 ]
396 )
397 dnl (end of code from openssh-3.2.2p1 configure.ac)
398
399 dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
400 AC_DEFUN(AC_CHECK_FRAMEWORK, [
401 AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
402 AC_CACHE_CHECK([whether compiler supports framework $1],
403 ac_Framework, [
404 saved_LIBS="$LIBS"
405 LIBS="$LIBS -framework $1"
406 AC_TRY_LINK(
407 [$2], [int main(void) { return 0; }],
408 [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
409 )
410 ])
411 AS_IF([test AS_VAR_GET(ac_Framework) = yes],
412 [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
413 )
414 AS_VAR_POPDEF([ac_Framework])dnl
415 ])
416
417 dnl Check for some MacOS X frameworks
418 AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
419 AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
420
421 dnl Select system-dependant sources.
422 SERIALSRC=serial_unix.cpp
423 ETHERSRC=../dummy/ether_dummy.cpp
424 SCSISRC=../dummy/scsi_dummy.cpp
425 AUDIOSRC=../dummy/audio_dummy.cpp
426 EXTFSSRC=extfs_unix.cpp
427 EXTRASYSSRCS=
428 case "$target_os" in
429 linux*)
430 ETHERSRC=Linux/ether_linux.cpp
431 AUDIOSRC=audio_oss_esd.cpp
432 SCSISRC=Linux/scsi_linux.cpp
433 if [[ "x$EMULATED_PPC" = "xno" ]]; then
434 EXTRASYSSRCS="Linux/paranoia.cpp Linux/sheepthreads.c ppc_asm.S"
435 fi
436 ;;
437 netbsd*)
438 if [[ "x$EMULATED_PPC" = "xno" ]]; then
439 EXTRASYSSRCS="NetBSD/paranoia.cpp NetBSD/sheepthreads.c ppc_asm.S"
440 fi
441 ;;
442 darwin*)
443 if [[ "x$EMULATED_PPC" = "xno" ]]; then
444 EXTRASYSSRCS="Darwin/paranoia.cpp ppc_asm.S"
445 fi
446 if [[ "x$ac_cv_framework_IOKit" = "xyes" ]]; then
447 EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/sys_darwin.cpp"
448 fi
449 if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
450 EXTFSSRC=../MacOSX/extfs_macosx.mm
451 fi
452 ;;
453 cygwin*)
454 SERIALSRC="../dummy/serial_dummy.cpp"
455 ;;
456 esac
457
458 dnl SDL overrides
459 if [[ "x$WANT_SDL" = "xyes" ]]; then
460 AC_DEFINE(USE_SDL, 1, [Define to enble SDL support.])
461 fi
462 if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
463 AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support.])
464 VIDEOSRCS="../SDL/video_sdl.cpp"
465 KEYCODES="../SDL/keycodes"
466 if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
467 EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp"
468 else
469 case "$target_os" in
470 cygwin*)
471 EXTRASYSSRCS="$EXTRASYSSRCS ../Windows/clip_windows.cpp"
472 ;;
473 *)
474 EXTRASYSSRCS="$EXTRASYSSRCS ../dummy/clip_dummy.cpp"
475 ;;
476 esac
477 fi
478 else
479 VIDEOSRCS="video_x.cpp"
480 KEYCODES="keycodes"
481 EXTRASYSSRCS="$EXTRASYSSRCS clip_unix.cpp"
482 fi
483 if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then
484 AC_DEFINE(USE_SDL_AUDIO, 1, [Define to enable SDL audio support])
485 AUDIOSRC="../SDL/audio_sdl.cpp"
486 fi
487
488 SYSSRCS="$VIDEOSRCS $EXTFSSRC $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $EXTRASYSSRCS"
489
490 dnl Define a macro that translates a yesno-variable into a C macro definition
491 dnl to be put into the config.h file
492 dnl $1 -- the macro to define
493 dnl $2 -- the value to translate
494 dnl $3 -- template name
495 AC_DEFUN(AC_TRANSLATE_DEFINE, [
496 if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
497 AC_DEFINE($1, 1, $3)
498 fi
499 ])
500
501 dnl Check that the host supports TUN/TAP devices
502 AC_CACHE_CHECK([whether TUN/TAP is supported],
503 ac_cv_tun_tap_support, [
504 AC_TRY_COMPILE([
505 #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
506 #include <linux/if.h>
507 #include <linux/if_tun.h>
508 #endif
509 #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
510 #include <net/if.h>
511 #include <net/if_tun.h>
512 #endif
513 ], [
514 struct ifreq ifr;
515 memset(&ifr, 0, sizeof(ifr));
516 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
517 ],
518 ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
519 )
520 ])
521 AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
522 [Define if your system supports TUN/TAP devices.])
523
524 dnl Various checks if the system supports vm_allocate() and the like functions.
525 have_mach_vm=no
526 if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
527 "x$ac_cv_func_vm_protect" = "xyes" ]]; then
528 have_mach_vm=yes
529 fi
530 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
531 [Define if your system has a working vm_allocate()-based memory allocator.])
532
533 dnl Check that vm_allocate(), vm_protect() work
534 if [[ "x$have_mach_vm" = "xyes" ]]; then
535
536 AC_CACHE_CHECK([whether vm_protect works],
537 ac_cv_vm_protect_works, [
538 AC_LANG_SAVE
539 AC_LANG_CPLUSPLUS
540 ac_cv_vm_protect_works=yes
541 dnl First the tests that should segfault
542 for test_def in NONE_READ NONE_WRITE READ_WRITE; do
543 AC_TRY_RUN([
544 #define CONFIGURE_TEST_VM_MAP
545 #define TEST_VM_PROT_$test_def
546 #include "vm_alloc.cpp"
547 ], ac_cv_vm_protect_works=no, rm -f core,
548 dnl When cross-compiling, do not assume anything
549 ac_cv_vm_protect_works="guessing no"
550 )
551 done
552 AC_TRY_RUN([
553 #define CONFIGURE_TEST_VM_MAP
554 #define TEST_VM_PROT_RDWR_WRITE
555 #include "vm_alloc.cpp"
556 ], , ac_cv_vm_protect_works=no,
557 dnl When cross-compiling, do not assume anything
558 ac_cv_vm_protect_works="guessing no"
559 )
560 AC_LANG_RESTORE
561 ]
562 )
563
564 dnl Remove support for vm_allocate() if vm_protect() does not work
565 if [[ "x$have_mach_vm" = "xyes" ]]; then
566 case $ac_cv_vm_protect_works in
567 *yes) have_mach_vm=yes;;
568 *no) have_mach_vm=no;;
569 esac
570 fi
571 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
572 [Define if your system has a working vm_allocate()-based memory allocator.])
573
574 fi dnl HAVE_MACH_VM
575
576 dnl Various checks if the system supports mmap() and the like functions.
577 dnl ... and Mach memory allocators are not supported
578 have_mmap_vm=no
579 if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
580 "x$ac_cv_func_mprotect" = "xyes" ]]; then
581 if [[ "x$have_mach_vm" = "xno" ]]; then
582 have_mmap_vm=yes
583 fi
584 fi
585 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
586 [Define if your system has a working mmap()-based memory allocator.])
587
588 dnl Check that mmap() and associated functions work.
589 if [[ "x$have_mmap_vm" = "xyes" ]]; then
590
591 dnl Check if we have a working anonymous mmap()
592 AC_CACHE_CHECK([whether mmap supports MAP_ANON],
593 ac_cv_mmap_anon, [
594 AC_LANG_SAVE
595 AC_LANG_CPLUSPLUS
596 AC_TRY_RUN([
597 #define HAVE_MMAP_ANON
598 #define CONFIGURE_TEST_VM_MAP
599 #define TEST_VM_MMAP_ANON
600 #include "vm_alloc.cpp"
601 ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
602 dnl When cross-compiling, do not assume anything.
603 ac_cv_mmap_anon="guessing no"
604 )
605 AC_LANG_RESTORE
606 ]
607 )
608 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
609 [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
610
611 AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
612 ac_cv_mmap_anonymous, [
613 AC_LANG_SAVE
614 AC_LANG_CPLUSPLUS
615 AC_TRY_RUN([
616 #define HAVE_MMAP_ANONYMOUS
617 #define CONFIGURE_TEST_VM_MAP
618 #define TEST_VM_MMAP_ANON
619 #include "vm_alloc.cpp"
620 ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
621 dnl When cross-compiling, do not assume anything.
622 ac_cv_mmap_anonymous="guessing no"
623 )
624 AC_LANG_RESTORE
625 ]
626 )
627 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
628 [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
629
630 AC_CACHE_CHECK([whether mprotect works],
631 ac_cv_mprotect_works, [
632 AC_LANG_SAVE
633 AC_LANG_CPLUSPLUS
634 ac_cv_mprotect_works=yes
635 dnl First the tests that should segfault
636 for test_def in NONE_READ NONE_WRITE READ_WRITE; do
637 AC_TRY_RUN([
638 #define CONFIGURE_TEST_VM_MAP
639 #define TEST_VM_PROT_$test_def
640 #include "vm_alloc.cpp"
641 ], ac_cv_mprotect_works=no, rm -f core,
642 dnl When cross-compiling, do not assume anything
643 ac_cv_mprotect_works="guessing no"
644 )
645 done
646 AC_TRY_RUN([
647 #define CONFIGURE_TEST_VM_MAP
648 #define TEST_VM_PROT_RDWR_WRITE
649 #include "vm_alloc.cpp"
650 ], , ac_cv_mprotect_works=no,
651 dnl When cross-compiling, do not assume anything
652 ac_cv_mprotect_works="guessing no"
653 )
654 AC_LANG_RESTORE
655 ]
656 )
657
658 dnl Remove support for mmap() if mprotect() does not work
659 if [[ "x$have_mmap_vm" = "xyes" ]]; then
660 case $ac_cv_mprotect_works in
661 *yes) have_mmap_vm=yes;;
662 *no) have_mmap_vm=no;;
663 esac
664 fi
665 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
666 [Define if your system has a working mmap()-based memory allocator.])
667
668 fi dnl HAVE_MMAP_VM
669
670 dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
671 AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000],
672 ac_cv_pagezero_hack, [
673 ac_cv_pagezero_hack=no
674 if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then
675 ac_cv_pagezero_hack=yes
676 dnl might as well skip the test for mmap-able low memory
677 ac_cv_can_map_lm=no
678 fi
679 ])
680 AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
681 [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
682
683 dnl Check if we can mmap 0x3000 bytes from 0x0000
684 AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000],
685 ac_cv_can_map_lm, [
686 AC_LANG_SAVE
687 AC_LANG_CPLUSPLUS
688 AC_TRY_RUN([
689 #include "vm_alloc.cpp"
690 int main(void) { /* returns 0 if we could map the lowmem globals */
691 volatile char * lm = 0;
692 if (vm_init() < 0) exit(1);
693 if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
694 lm[0] = 'z';
695 if (vm_release((char *)lm, 0x2000) < 0) exit(1);
696 vm_exit(); exit(0);
697 }
698 ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
699 dnl When cross-compiling, do not assume anything.
700 ac_cv_can_map_lm="guessing no"
701 )
702 AC_LANG_RESTORE
703 ]
704 )
705
706 dnl Check signal handlers need to be reinstalled
707 AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
708 ac_cv_signal_need_reinstall, [
709 AC_LANG_SAVE
710 AC_LANG_CPLUSPLUS
711 AC_TRY_RUN([
712 #include <stdlib.h>
713 #ifdef HAVE_UNISTD_H
714 #include <unistd.h>
715 #endif
716 #include <signal.h>
717 static int handled_signal = 0;
718 RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
719 int main(void) { /* returns 0 if signals need not to be reinstalled */
720 signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
721 exit(handled_signal == 2);
722 }
723 ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
724 dnl When cross-compiling, do not assume anything.
725 ac_cv_signal_need_reinstall="guessing yes"
726 )
727 AC_LANG_RESTORE
728 ]
729 )
730 AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
731 [Define if your system requires signals to be reinstalled.])
732
733 dnl Check if sigaction handlers need to be reinstalled
734 AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
735 ac_cv_sigaction_need_reinstall, [
736 AC_LANG_SAVE
737 AC_LANG_CPLUSPLUS
738 AC_TRY_RUN([
739 #include <stdlib.h>
740 #ifdef HAVE_UNISTD_H
741 #include <unistd.h>
742 #endif
743 #include <signal.h>
744 static int handled_signal = 0;
745 RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
746 typedef RETSIGTYPE (*signal_handler)(int);
747 static signal_handler mysignal(int sig, signal_handler handler) {
748 struct sigaction old_sa;
749 struct sigaction new_sa;
750 new_sa.sa_handler = handler;
751 return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
752 }
753 int main(void) { /* returns 0 if signals need not to be reinstalled */
754 mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
755 exit(handled_signal == 2);
756 }
757 ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
758 dnl When cross-compiling, do not assume anything.
759 ac_cv_sigaction_need_reinstall="guessing yes"
760 )
761 AC_LANG_RESTORE
762 ]
763 )
764 AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
765 [Define if your system requires sigactions to be reinstalled.])
766
767 dnl Check if Mach exceptions supported.
768 AC_CACHE_CHECK([whether your system supports Mach exceptions],
769 ac_cv_have_mach_exceptions, [
770 AC_LANG_SAVE
771 AC_LANG_CPLUSPLUS
772 AC_TRY_RUN([
773 #define HAVE_MACH_EXCEPTIONS 1
774 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
775 #include "vm_alloc.cpp"
776 #include "sigsegv.cpp"
777 ],
778 ac_cv_have_mach_exceptions=yes,
779 ac_cv_have_mach_exceptions=no,
780 dnl When cross-compiling, do not assume anything.
781 ac_cv_have_mach_exceptions=no
782 )
783 AC_LANG_RESTORE
784 ]
785 )
786 if [[ "$ac_cv_have_mach_exceptions" = "yes" ]]; then
787 sigsegv_recovery=mach
788 fi
789 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
790 [Define if your system supports Mach exceptions.])
791
792 dnl Check if Windows exceptions are supported.
793 AC_CACHE_CHECK([whether your system supports Windows exceptions],
794 ac_cv_have_win32_exceptions, [
795 AC_LANG_SAVE
796 AC_LANG_CPLUSPLUS
797 AC_TRY_RUN([
798 #define HAVE_WIN32_EXCEPTIONS 1
799 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
800 #include "vm_alloc.cpp"
801 #include "sigsegv.cpp"
802 ], [
803 sigsegv_recovery=win32
804 ac_cv_have_win32_exceptions=yes
805 ],
806 ac_cv_have_win32_exceptions=no,
807 dnl When cross-compiling, do not assume anything.
808 ac_cv_have_win32_exceptions=no
809 )
810 AC_LANG_RESTORE
811 ]
812 )
813 AC_TRANSLATE_DEFINE(HAVE_WIN32_EXCEPTIONS, "$ac_cv_have_win32_exceptions",
814 [Define if your system supports Windows exceptions.])
815
816 dnl Otherwise, check if extended signals are supported.
817 if [[ -z "$sigsegv_recovery" ]]; then
818 AC_CACHE_CHECK([whether your system supports extended signal handlers],
819 ac_cv_have_extended_signals, [
820 AC_LANG_SAVE
821 AC_LANG_CPLUSPLUS
822 AC_TRY_RUN([
823 #define HAVE_SIGINFO_T 1
824 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
825 #include "vm_alloc.cpp"
826 #include "sigsegv.cpp"
827 ],
828 ac_cv_have_extended_signals=yes,
829 ac_cv_have_extended_signals=no,
830 dnl When cross-compiling, do not assume anything.
831 ac_cv_have_extended_signals=no
832 )
833 AC_LANG_RESTORE
834 ]
835 )
836 if [[ "$ac_cv_have_extended_signals" = "yes" ]]; then
837 sigsegv_recovery=siginfo
838 fi
839 AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
840 [Define if your system support extended signals.])
841 fi
842
843 dnl Otherwise, check for subterfuges.
844 if [[ -z "$sigsegv_recovery" ]]; then
845 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
846 ac_cv_have_sigcontext_hack, [
847 AC_LANG_SAVE
848 AC_LANG_CPLUSPLUS
849 AC_TRY_RUN([
850 #define HAVE_SIGCONTEXT_SUBTERFUGE 1
851 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
852 #include "vm_alloc.cpp"
853 #include "sigsegv.cpp"
854 ],
855 ac_cv_have_sigcontext_hack=yes,
856 ac_cv_have_sigcontext_hack=no,
857 dnl When cross-compiling, do not assume anything.
858 ac_cv_have_sigcontext_hack=no
859 )
860 AC_LANG_RESTORE
861 ])
862 if [[ "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
863 sigsegv_recovery=sigcontext
864 fi
865 AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
866 [Define if we know a hack to replace siginfo_t->si_addr member.])
867 fi
868
869 dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
870 AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
871 ac_cv_have_skip_instruction, [
872 AC_LANG_SAVE
873 AC_LANG_CPLUSPLUS
874 AC_TRY_RUN([
875 #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
876 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
877 #include "vm_alloc.cpp"
878 #include "sigsegv.cpp"
879 ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
880 dnl When cross-compiling, do not assume anything.
881 ac_cv_have_skip_instruction=no
882 )
883 AC_LANG_RESTORE
884 ]
885 )
886 AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
887 [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
888
889 dnl Can we do Video on SEGV Signals ?
890 CAN_VOSF=no
891 if [[ -n "$sigsegv_recovery" ]]; then
892 CAN_VOSF=yes
893 fi
894
895 dnl Enable VOSF screen updates with this feature is requested and feasible
896 if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
897 AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
898 else
899 WANT_VOSF=no
900 fi
901
902 dnl Check addressing mode to use
903 AC_MSG_CHECKING([for addressing mode to use])
904 case "$os_target" in
905 cygwin*)
906 WANT_ADDRESSING_MODE="direct,cygwin-hack"
907 NATMEM_OFFSET=
908 ;;
909 esac
910 if [[ "$EMULATED_PPC" != "yes" ]]; then
911 if [[ "$WANT_ADDRESSING_MODE" != "real" ]]; then
912 AC_MSG_WARN([Running in native PowerPC mode, force use of Real Addressing.])
913 WANT_ADDRESSING_MODE="real"
914 fi
915 fi
916 if [[ "$WANT_ADDRESSING_MODE" = "direct" ]]; then
917 if [[ -n "$NATMEM_OFFSET" ]]; then
918 NATMEM_OFFSET_DEF="-DNATMEM_OFFSET=$NATMEM_OFFSET"
919 fi
920 AC_LANG_SAVE
921 AC_LANG_CPLUSPLUS
922 cat confdefs.h > conftest.$ac_ext
923 cat >> conftest.$ac_ext << EOF
924 #include <stdio.h>
925 #include <string.h>
926 #include "vm_alloc.cpp"
927
928 int main(void)
929 {
930 if (vm_init() < 0)
931 return 1;
932
933 static const struct {
934 unsigned long base;
935 unsigned int size;
936 } ranges[[]] = {
937 { 0x00000000, 0x0003000 },
938 { 0x10000000, 0x2000000 },
939 { 0x40800000, 0x0400000 },
940 { 0x68070000, 0x0010000 },
941 { 0x69000000, 0x0080000 },
942 { 0x68ffe000, 0x0002000 },
943 { 0x5fffe000, 0x0002000 },
944 { 0x60000000, 0x0040000 },
945 };
946 const int n_ranges = sizeof(ranges)/ sizeof(ranges[[0]]);
947
948 #ifdef NATMEM_OFFSET
949 unsigned long ofs = NATMEM_OFFSET;
950 #else
951 for (unsigned long ofs = 0x10000000; ofs <= 0x90000000; ofs += 0x10000000)
952 #endif
953 for (int i = 0; i < n_ranges; i++) {
954 char *m = (char *)(ranges[[i]].base + ofs);
955 if (vm_acquire_fixed(m, ranges[[i]].size) != 0)
956 break;
957 memset(m, 0, ranges[[i]].size);
958 vm_release(m, ranges[[i]].size);
959 if (i == n_ranges - 1) {
960 if (sizeof(void *) == 8 && ofs > 0xffffffff)
961 printf("0x%lxul\n", ofs);
962 else
963 printf("0x%08x\n", ofs);
964 return 0;
965 }
966 }
967
968 vm_exit();
969 return 1;
970 }
971 EOF
972 doit='$CXX conftest.$ac_ext -o conftest.$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS $NATMEM_OFFSET_DEF >& AS_MESSAGE_LOG_FD'
973 if AC_TRY_EVAL(doit); then
974 NATMEM_OFFSET=`./conftest.$ac_exeext`
975 else
976 NATMEM_OFFSET=
977 fi
978 rm -f conftest*
979 AC_LANG_RESTORE
980
981 if [[ -z "$NATMEM_OFFSET" ]]; then
982 AC_MSG_ERROR([could not determine a sensible NATMEM_OFFSET value])
983 else
984 WANT_ADDRESSING_MODE="direct,$NATMEM_OFFSET"
985 AC_DEFINE_UNQUOTED(NATMEM_OFFSET, $NATMEM_OFFSET,
986 [Define constant offset for Mac address translation])
987 fi
988 fi
989 AC_MSG_RESULT($WANT_ADDRESSING_MODE)
990
991 dnl Platform specific binary postprocessor
992 AC_PATH_PROG(BLESS, "true")
993 if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
994 BLESS=Darwin/lowmem
995 LDFLAGS="$LDFLAGS -pagezero_size 0x3000"
996 fi
997
998 dnl Check for GCC 2.7 or higher.
999 HAVE_GCC27=no
1000 AC_MSG_CHECKING(for GCC 2.7 or higher)
1001 AC_EGREP_CPP(xyes,
1002 [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
1003 xyes
1004 #endif
1005 ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
1006
1007 dnl Check for GCC 3.0 or higher.
1008 HAVE_GCC30=no
1009 AC_MSG_CHECKING(for GCC 3.0 or higher)
1010 AC_EGREP_CPP(xyes,
1011 [#if __GNUC__ >= 3
1012 xyes
1013 #endif
1014 ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
1015
1016 dnl Check for ICC.
1017 AC_MSG_CHECKING(for ICC)
1018 HAVE_ICC=no
1019 if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
1020 HAVE_ICC=yes
1021 fi
1022 AC_MSG_RESULT($HAVE_ICC)
1023
1024 dnl Determine the generated object format
1025 AC_CACHE_CHECK([whether the compiler can generate ELF objects],
1026 ac_cv_object_format, [
1027 echo 'int i;' > conftest.$ac_ext
1028 ac_cv_object_format=no
1029 if AC_TRY_EVAL(ac_compile); then
1030 case `/usr/bin/file conftest.$ac_objext` in
1031 *"ELF"*)
1032 ac_cv_object_format=elf
1033 ;;
1034 *)
1035 ac_cv_object_format=unknown
1036 ;;
1037 esac
1038 fi
1039 rm -rf conftest*
1040 ])
1041
1042 dnl CPU emulator sources
1043 if [[ "x$EMULATED_PPC" = "xyes" ]]; then
1044 CPUSRCS="\
1045 ../kpx_cpu/src/mathlib/ieeefp.cpp \
1046 ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
1047 ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
1048 ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
1049 ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp"
1050 CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
1051
1052 dnl Enable JIT compiler, if possible
1053 if [[ "x$WANT_JIT" = "xyes" ]]; then
1054 AC_CACHE_CHECK([whether dyngen can be used],
1055 ac_cv_use_dyngen, [
1056 case $host_cpu:$ac_cv_object_format in
1057 powerpc:elf)
1058 ac_cv_use_dyngen=yes
1059 ;;
1060 x86_64:elf)
1061 ac_cv_use_dyngen=yes
1062 ;;
1063 i?86:elf)
1064 ac_cv_use_dyngen=yes
1065 ;;
1066 *:*)
1067 ac_cv_use_dyngen=no
1068 ;;
1069 esac
1070 dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
1071 if [[ -z "$DYNGEN_CC" ]]; then
1072 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1073 DYNGEN_CC=$CXX
1074 else
1075 for p in /usr/bin /usr/local/bin; do
1076 gxx="$p/g++"
1077 if [[ -x "$gxx" ]]; then
1078 DYNGEN_CC="$gxx"
1079 fi
1080 done
1081 fi
1082 fi
1083 if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include <limits>' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then
1084 ac_cv_use_dyngen=no
1085 fi
1086 ])
1087 if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1088 case $host_cpu in
1089 i?86)
1090 DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2"
1091 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1092 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0"
1093 else
1094 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
1095 fi
1096 ;;
1097 esac
1098 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000 -g0"
1099 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1100 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
1101 fi
1102 else
1103 WANT_JIT=no
1104 fi
1105 AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
1106 if [[ "x$WANT_JIT" = "xyes" ]]; then
1107 DYNGENSRCS="\
1108 ../kpx_cpu/src/cpu/jit/dyngen.c \
1109 ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
1110 CPUSRCS="\
1111 ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
1112 ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
1113 ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS"
1114 fi
1115 fi
1116 CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
1117 else
1118 WANT_JIT=no
1119 fi
1120 if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1121 AC_CACHE_CHECK([whether static data regions are executable],
1122 ac_cv_have_static_data_exec, [
1123 AC_TRY_RUN([int main(void) {
1124 #if defined(__powerpc__)
1125 static unsigned int p[8] = {0x4e800020,};
1126 asm volatile("dcbst 0,%0" : : "r" (p) : "memory");
1127 asm volatile("sync" : : : "memory");
1128 asm volatile("icbi 0,%0" : : "r" (p) : "memory");
1129 asm volatile("sync" : : : "memory");
1130 asm volatile("isync" : : : "memory");
1131 ((void (*)(void))p)();
1132 return 0;
1133 #endif
1134 return 1;
1135 }], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no,
1136 dnl When cross-compiling, do not assume anything.
1137 ac_cv_have_static_data_exec=no
1138 )
1139 ])
1140 else
1141 ac_cv_use_dyngen=no
1142 fi
1143 AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec",
1144 [Define if your system marks static data pages as executable.])
1145
1146 if [[ "x$WANT_JIT" = "xyes" ]]; then
1147 CPPFLAGS="$CPPFLAGS -DUSE_JIT"
1148 fi
1149
1150 dnl Generate Makefile.
1151 AC_SUBST(PERL)
1152 AC_SUBST(USE_DYNGEN, [$ac_cv_use_dyngen])
1153 AC_SUBST(DYNGENSRCS)
1154 AC_SUBST(DYNGEN_CC)
1155 AC_SUBST(DYNGEN_OP_FLAGS)
1156 AC_SUBST(SYSSRCS)
1157 AC_SUBST(CPUSRCS)
1158 AC_SUBST(BLESS)
1159 AC_SUBST(KEYCODES)
1160 AC_OUTPUT([
1161 Makefile
1162 ../MacOSX/Info.plist
1163 ])
1164
1165 dnl Print summary.
1166 echo
1167 echo SheepShaver configuration summary:
1168 echo
1169 echo SDL support ...................... : $SDL_SUPPORT
1170 echo XFree86 DGA support .............. : $WANT_XF86_DGA
1171 echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
1172 echo Using PowerPC emulator ........... : $EMULATED_PPC
1173 echo Enable JIT compiler .............. : $WANT_JIT
1174 echo Enable video on SEGV signals ..... : $WANT_VOSF
1175 echo ESD sound support ................ : $WANT_ESD
1176 echo GTK user interface ............... : $WANT_GTK
1177 echo mon debugger support ............. : $WANT_MON
1178 echo Addressing mode .................. : $WANT_ADDRESSING_MODE
1179 echo Bad memory access recovery type .. : $sigsegv_recovery
1180 echo
1181 echo "Configuration done. Now type \"make\"."