ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.42
Committed: 2005-12-04T16:26:57Z (18 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.41: +7 -0 lines
Log Message:
Better IRIX support: add audio & slirp networking. Fix configure to use -lm
when searching for C99 functions (roundf() et al.).

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.3, [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 Invite Cygwin users to build within the Windows/ directory
18 case $target_os in
19 *cygwin* | *mingw32*)
20 AC_MSG_ERROR([You can only build the Windows version from its directory, Cygwin/X11 is not supported.])
21 ;;
22 esac
23
24 dnl Options.
25 AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes])
26 AC_ARG_ENABLE(ppc-emulator, [ --enable-ppc-emulator use the selected PowerPC emulator [default=auto]], [WANT_EMULATED_PPC=$enableval], [WANT_EMULATED_PPC=auto])
27 AC_ARG_ENABLE(fbdev-dga, [ --enable-fbdev-dga use direct frame buffer access via /dev/fb0 [default=yes]], [WANT_FBDEV_DGA=$enableval], [WANT_FBDEV_DGA=yes])
28 AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes])
29 AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=yes]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=yes])
30 AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes])
31 AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes])
32 AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]],
33 [case "$withval" in
34 gtk1) WANT_GTK="gtk";;
35 gtk|gtk2) WANT_GTK="$withval";;
36 yes) WANT_GTK="gtk2 gtk";;
37 *) WANT_GTK="no";;
38 esac],
39 [WANT_GTK="gtk2 gtk"])
40 AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
41 AC_ARG_WITH(dgcc, [ --with-dgcc=COMPILER use C++ COMPILER to compile synthetic opcodes], [DYNGEN_CC=$withval])
42
43 dnl Addressing mode
44 AC_ARG_ENABLE(addressing,
45 [ --enable-addressing=AM set the addressing mode to use [default=real]],
46 [case "$enableval" in
47 real) WANT_ADDRESSING_MODE="real";;
48 direct) WANT_ADDRESSING_MODE="direct";;
49 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'`;;
50 esac],
51 [WANT_ADDRESSING_MODE="real"]
52 )
53
54 dnl SDL options.
55 AC_ARG_ENABLE(sdl-static, [ --enable-sdl-static use SDL static libraries for linking [default=no]], [WANT_SDL_STATIC=$enableval], [WANT_SDL_STATIC=no])
56 AC_ARG_ENABLE(sdl-video, [ --enable-sdl-video use SDL for video graphics [default=no]], [WANT_SDL_VIDEO=$enableval], [WANT_SDL_VIDEO=no])
57 AC_ARG_ENABLE(sdl-audio, [ --enable-sdl-audio use SDL for audio [default=no]], [WANT_SDL_AUDIO=$enableval], [WANT_SDL_AUDIO=no])
58
59 dnl Checks for programs.
60 AC_PROG_CC
61 AC_PROG_CPP
62 AC_PROG_CXX
63 AC_PROG_MAKE_SET
64 AC_PROG_INSTALL
65 AC_PROG_EGREP
66 AC_PATH_PROGS(FILE, [file false])
67 AC_PATH_PROG(PERL, [perl])
68
69 dnl Check for PowerPC target CPU.
70 HAVE_PPC=no
71 AC_MSG_CHECKING(for PowerPC target CPU)
72 AC_EGREP_CPP(yes,
73 [
74 #ifdef __powerpc__
75 yes
76 #endif
77 #ifdef __ppc__
78 yes
79 #endif
80 ], [AC_MSG_RESULT(yes); HAVE_PPC=yes], AC_MSG_RESULT(no))
81
82 dnl We use native CPU if possible.
83 EMULATED_PPC=yes
84 case $WANT_EMULATED_PPC in
85 auto) [[ "x$HAVE_PPC" = "xyes" ]] && EMULATED_PPC=no;;
86 no) EMULATED_PPC=no;;
87 esac
88 if [[ "x$EMULATED_PPC" = "xyes" ]]; then
89 AC_DEFINE(EMULATED_PPC, 1, [Define if using a PowerPC CPU emulator.])
90 fi
91
92 dnl We use mon if possible.
93 MONSRCS=
94 case "x$WANT_MON" in
95 x/* | x.*)
96 mon_srcdir=$WANT_MON
97 WANT_MON=yes
98 ;;
99 xyes)
100 mon_srcdir=../../../mon/src
101 ;;
102 esac
103 if [[ "x$WANT_MON" = "xyes" ]]; then
104 AC_MSG_CHECKING(for mon)
105 if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
106 AC_MSG_RESULT(yes)
107 AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".])
108 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"
109 CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
110 AC_CHECK_LIB(ncurses, tgetent, ,
111 AC_CHECK_LIB(termcap, tgetent, ,
112 AC_CHECK_LIB(termlib, tgetent, ,
113 AC_CHECK_LIB(terminfo, tgetent, ,
114 AC_CHECK_LIB(Hcurses, tgetent, ,
115 AC_CHECK_LIB(curses, tgetent))))))
116 AC_CHECK_LIB(readline, readline)
117 AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
118 else
119 AC_MSG_RESULT(no)
120 AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
121 WANT_MON=no
122 fi
123 fi
124 AC_SUBST(MONSRCS)
125
126 dnl Checks for libraries.
127 AC_CHECK_LIB(posix4, sem_init)
128 AC_CHECK_LIB(m, cos)
129
130 dnl Do we need SDL?
131 WANT_SDL=no
132 if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
133 WANT_SDL=yes
134 WANT_XF86_DGA=no
135 WANT_XF86_VIDMODE=no
136 WANT_FBDEV_DGA=no
137 SDL_SUPPORT="$SDL_SUPPORT video"
138 fi
139 if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then
140 WANT_SDL=yes
141 SDL_SUPPORT="$SDL_SUPPORT audio"
142 fi
143 if [[ "x$WANT_SDL" = "xyes" ]]; then
144 AC_PATH_PROG(sdl_config, "sdl-config")
145 if [[ -n "$sdl_config" ]]; then
146 sdl_cflags=`$sdl_config --cflags`
147 if [[ "x$WANT_SDL_STATIC" = "xyes" ]]; then
148 sdl_libs=`$sdl_config --static-libs`
149 else
150 sdl_libs=`$sdl_config --libs`
151 fi
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 dnl XXX remove when no pthreads case is merged
188 AC_MSG_ERROR([You need pthreads to run SheepShaver.])
189 HAVE_PTHREADS=no
190 ])
191 ])
192 ])
193 AC_CHECK_FUNCS(pthread_cancel)
194 AC_CHECK_FUNCS(pthread_cond_init pthread_testcancel)
195 AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
196 AC_CHECK_FUNCS(pthread_mutexattr_settype)
197 AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
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 if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
208 AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.])
209 fi
210
211 dnl We use FBDev DGA if possible.
212 if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
213 AC_CHECK_HEADER(linux/fb.h, [
214 AC_DEFINE(ENABLE_FBDEV_DGA, 1, [Define if using Linux fbdev extension.])
215 ], [
216 AC_MSG_WARN([Could not find Linux FBDev extension, ignoring --enable-fbdev-dga.])
217 WANT_FBDEV_DGA=no
218 ])
219 fi
220
221 dnl We use XFree86 DGA if possible.
222 if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then
223 AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [
224 AC_DEFINE(ENABLE_XF86_DGA, 1, [Define if using XFree86 DGA extension.])
225 LIBS="$LIBS -lXxf86dga"
226 ], [
227 AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.])
228 WANT_XF86_DGA=no
229 ])
230 fi
231
232 dnl We use XFree86 VidMode if possible.
233 if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then
234 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [
235 AC_DEFINE(ENABLE_XF86_VIDMODE, 1, [Define if using XFree86 DGA extension.])
236 LIBS="$LIBS -lXxf86vm"
237 ], [
238 AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.])
239 WANT_XF86_VIDMODE=no
240 ])
241 fi
242
243 dnl We use GTK+ if possible.
244 UISRCS=../dummy/prefs_editor_dummy.cpp
245 case "x$WANT_GTK" in
246 xgtk2*)
247 AM_PATH_GTK_2_0(1.3.15, [
248 AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
249 CFLAGS="$CFLAGS $GTK_CFLAGS"
250 CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
251 LIBS="$LIBS $GTK_LIBS"
252 UISRCS=prefs_editor_gtk.cpp
253 WANT_GTK=gtk2
254 ], [
255 case "x${WANT_GTK}x" in
256 *gtkx)
257 AC_MSG_WARN([Could not find GTK+ 2.0, trying with GTK+ 1.2.])
258 WANT_GTK=gtk
259 ;;
260 *)
261 AC_MSG_WARN([Could not find GTK+, disabling user interface.])
262 WANT_GTK=no
263 ;;
264 esac
265 ])
266 ;;
267 esac
268 if [[ "x$WANT_GTK" = "xgtk" ]]; then
269 AM_PATH_GTK(1.2.0, [
270 AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
271 CFLAGS="$CFLAGS $GTK_CFLAGS"
272 CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
273 LIBS="$LIBS $GTK_LIBS"
274 UISRCS=prefs_editor_gtk.cpp
275 ], [
276 AC_MSG_WARN([Could not find GTK+, disabling user interface.])
277 WANT_GTK=no
278 ])
279 fi
280
281 dnl We use ESD if possible.
282 if [[ "x$WANT_ESD" = "xyes" ]]; then
283 AM_PATH_ESD(0.2.8, [
284 AC_DEFINE(ENABLE_ESD, 1, [Define is using ESD.])
285 CFLAGS="$CFLAGS $ESD_CFLAGS"
286 CXXFLAGS="$CXXFLAGS $ESD_CFLAGS"
287 LIBS="$LIBS $ESD_LIBS"
288 ], [
289 AC_MSG_WARN([Could not find ESD, disabling ESD support.])
290 WANT_ESD=no
291 ])
292 fi
293
294 dnl We use 64-bit file size support if possible.
295 AC_SYS_LARGEFILE
296
297 dnl Checks for header files.
298 AC_HEADER_STDC
299 AC_HEADER_SYS_WAIT
300 AC_CHECK_HEADERS(malloc.h stdint.h)
301 AC_CHECK_HEADERS(mach/vm_map.h mach/mach_init.h sys/mman.h)
302 AC_CHECK_HEADERS(unistd.h fcntl.h byteswap.h dirent.h)
303 AC_CHECK_HEADERS(sys/socket.h sys/ioctl.h sys/filio.h sys/bitypes.h sys/wait.h)
304 AC_CHECK_HEADERS(sys/time.h sys/poll.h sys/select.h arpa/inet.h)
305 AC_CHECK_HEADERS(linux/if.h linux/if_tun.h net/if.h net/if_tun.h, [], [], [
306 #ifdef HAVE_SYS_TYPES_H
307 #include <sys/types.h>
308 #endif
309 #ifdef HAVE_SYS_SOCKET_H
310 #include <sys/socket.h>
311 #endif
312 ])
313 AC_CHECK_HEADERS(AvailabilityMacros.h)
314 AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDevice.h)
315 AC_CHECK_HEADERS(fenv.h)
316
317 dnl Checks for typedefs, structures, and compiler characteristics.
318 AC_C_BIGENDIAN
319 AC_C_CONST
320 AC_C_INLINE
321 AC_CHECK_SIZEOF(short, 2)
322 AC_CHECK_SIZEOF(int, 4)
323 AC_CHECK_SIZEOF(long, 4)
324 AC_CHECK_SIZEOF(long long, 8)
325 AC_CHECK_SIZEOF(float, 4)
326 AC_CHECK_SIZEOF(double, 8)
327 AC_CHECK_SIZEOF(void *, 4)
328 AC_TYPE_OFF_T
329 AC_CHECK_TYPE(loff_t, off_t)
330 AC_TYPE_SIZE_T
331 AC_TYPE_SIGNAL
332 AC_HEADER_TIME
333 AC_STRUCT_TM
334
335 dnl Check whether sys/socket.h defines type socklen_t.
336 dnl (extracted from ac-archive/Miscellaneous)
337 AC_CACHE_CHECK([for socklen_t],
338 ac_cv_type_socklen_t, [
339 AC_TRY_COMPILE([
340 #include <sys/types.h>
341 #include <sys/socket.h>
342 ], [socklen_t len = 42; return 0;],
343 ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no,
344 dnl When cross-compiling, do not assume anything.
345 ac_cv_type_socklen_t="guessing no"
346 )
347 ])
348 if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then
349 AC_DEFINE(socklen_t, int, [Define to 'int' if <sys/types.h> doesn't define.])
350 fi
351
352 dnl Check whether struct sigaction has sa_restorer member.
353 AC_CACHE_CHECK([whether struct sigaction has sa_restorer],
354 ac_cv_signal_sa_restorer, [
355 AC_TRY_COMPILE([
356 #include <signal.h>
357 ], [struct sigaction sa; sa.sa_restorer = 0;],
358 ac_cv_signal_sa_restorer=yes, ac_cv_signal_sa_restorer=no,
359 dnl When cross-compiling, do not assume anything.
360 ac_cv_signal_sa_restorer=no
361 )
362 ])
363 if [[ "x$ac_cv_signal_sa_restorer" = "xyes" ]]; then
364 AC_DEFINE(HAVE_SIGNAL_SA_RESTORER, 1, [Define if sa_restorer is available in struct sigaction.])
365 fi
366
367 dnl Checks for library functions.
368 AC_CHECK_FUNCS(strdup strerror strlcpy cfmakeraw)
369 AC_CHECK_FUNCS(nanosleep)
370 AC_CHECK_FUNCS(sigaction signal)
371 AC_CHECK_FUNCS(mmap mprotect munmap)
372 AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
373 AC_CHECK_FUNCS(exp2f log2f exp2 log2)
374 AC_CHECK_FUNCS(floorf roundf ceilf truncf floor round ceil trunc)
375 AC_CHECK_FUNCS(poll inet_aton)
376
377 dnl Darwin seems to define mach_task_self() instead of task_self().
378 AC_CHECK_FUNCS(mach_task_self task_self)
379
380 dnl We need clock_gettime() for better performance but it may drag
381 dnl libpthread in, which we don't want for native ppc mode
382 case $EMULATED_PPC:$target_os in
383 no:linux*)
384 ;;
385 *:*)
386 AC_SEARCH_LIBS(clock_gettime, [rt posix4])
387 AC_CHECK_FUNCS(clock_gettime clock_nanosleep)
388 ;;
389 esac
390
391 dnl Check for headers and functions related to pty support (sshpty.c)
392 dnl From openssh-3.2.2p1 configure.ac
393 AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
394 AC_CHECK_FUNCS(_getpty vhangup strlcpy)
395
396 case "$host" in
397 *-*-hpux10.26)
398 disable_ptmx_check=yes
399 ;;
400 *-*-linux*)
401 no_dev_ptmx=1
402 ;;
403 mips-sony-bsd|mips-sony-newsos4)
404 AC_DEFINE(HAVE_NEWS4, 1, [Define if you are on NEWS-OS (additions from openssh-3.2.2p1, for sshpty.c).])
405 ;;
406 *-*-sco3.2v4*)
407 no_dev_ptmx=1
408 ;;
409 *-*-sco3.2v5*)
410 no_dev_ptmx=1
411 ;;
412 *-*-cygwin*)
413 no_dev_ptmx=1
414 ;;
415 esac
416
417 if test -z "$no_dev_ptmx" ; then
418 if test "x$disable_ptmx_check" != "xyes" ; then
419 AC_CHECK_FILE([/dev/ptmx],
420 [
421 AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.])
422 have_dev_ptmx=1
423 ]
424 )
425 fi
426 fi
427 AC_CHECK_FILE([/dev/ptc],
428 [
429 AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.])
430 have_dev_ptc=1
431 ]
432 )
433 dnl (end of code from openssh-3.2.2p1 configure.ac)
434
435 dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
436 AC_DEFUN(AC_CHECK_FRAMEWORK, [
437 AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
438 AC_CACHE_CHECK([whether compiler supports framework $1],
439 ac_Framework, [
440 saved_LIBS="$LIBS"
441 LIBS="$LIBS -framework $1"
442 AC_TRY_LINK(
443 [$2], [int main(void) { return 0; }],
444 [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
445 )
446 ])
447 AS_IF([test AS_VAR_GET(ac_Framework) = yes],
448 [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
449 )
450 AS_VAR_POPDEF([ac_Framework])dnl
451 ])
452
453 dnl Check for some MacOS X frameworks
454 AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
455 AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
456 AC_CHECK_FRAMEWORK(CoreFoundation, [#include <CoreFoundation/CoreFoundation.h>])
457
458 dnl Select system-dependant sources.
459 SERIALSRC=serial_unix.cpp
460 ETHERSRC=../dummy/ether_dummy.cpp
461 SCSISRC=../dummy/scsi_dummy.cpp
462 AUDIOSRC=../dummy/audio_dummy.cpp
463 EXTFSSRC=extfs_unix.cpp
464 EXTRASYSSRCS=
465 case "$target_os" in
466 linux*)
467 ETHERSRC=ether_unix.cpp
468 AUDIOSRC=audio_oss_esd.cpp
469 SCSISRC=Linux/scsi_linux.cpp
470 if [[ "x$EMULATED_PPC" = "xno" ]]; then
471 EXTRASYSSRCS="paranoia.cpp Linux/sheepthreads.c ppc_asm.S"
472 fi
473 ;;
474 freebsd*)
475 ETHERSRC=ether_unix.cpp
476 ;;
477 netbsd*)
478 ETHERSRC=ether_unix.cpp
479 if [[ "x$EMULATED_PPC" = "xno" ]]; then
480 EXTRASYSSRCS="paranoia.cpp NetBSD/sheepthreads.c ppc_asm.S"
481 fi
482 ;;
483 darwin*)
484 ETHERSRC=ether_unix.cpp
485 if [[ "x$EMULATED_PPC" = "xno" ]]; then
486 EXTRASYSSRCS="paranoia.cpp ppc_asm.S"
487 fi
488 if [[ "x$ac_cv_framework_IOKit" = "xyes" -a "x$ac_cv_framework_CoreFoundation" = "xyes" ]]; then
489 EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/sys_darwin.cpp"
490 fi
491 if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
492 EXTFSSRC=../MacOSX/extfs_macosx.mm
493 fi
494 ;;
495 irix*)
496 ETHERSRC=ether_unix.cpp
497 AUDIOSRC=Irix/audio_irix.cpp
498 LIBS="$LIBS -laudio"
499 WANT_ESD=no
500 ;;
501 esac
502
503 dnl Is the slirp library supported?
504 if [[ "x$ETHERSRC" = "xether_unix.cpp" ]]; then
505 AC_DEFINE(HAVE_SLIRP, 1, [Define if slirp library is supported])
506 SLIRP_SRCS="\
507 ../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \
508 ../slirp/cksum.c ../slirp/mbuf.c ../slirp/tcp_output.c \
509 ../slirp/debug.c ../slirp/misc.c ../slirp/tcp_subr.c \
510 ../slirp/if.c ../slirp/sbuf.c ../slirp/tcp_timer.c \
511 ../slirp/ip_icmp.c ../slirp/slirp.c ../slirp/tftp.c \
512 ../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c"
513 fi
514 AC_SUBST(SLIRP_SRCS)
515
516 dnl SDL overrides
517 if [[ "x$WANT_SDL" = "xyes" ]]; then
518 AC_DEFINE(USE_SDL, 1, [Define to enble SDL support.])
519 fi
520 if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
521 AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support.])
522 VIDEOSRCS="../SDL/video_sdl.cpp"
523 KEYCODES="../SDL/keycodes"
524 if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
525 EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp"
526 else
527 EXTRASYSSRCS="$EXTRASYSSRCS ../dummy/clip_dummy.cpp"
528 fi
529 else
530 VIDEOSRCS="video_x.cpp"
531 KEYCODES="keycodes"
532 EXTRASYSSRCS="$EXTRASYSSRCS clip_unix.cpp"
533 fi
534 if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then
535 AC_DEFINE(USE_SDL_AUDIO, 1, [Define to enable SDL audio support])
536 AUDIOSRC="../SDL/audio_sdl.cpp"
537 fi
538
539 SYSSRCS="$VIDEOSRCS $EXTFSSRC $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $EXTRASYSSRCS"
540
541 dnl Define a macro that translates a yesno-variable into a C macro definition
542 dnl to be put into the config.h file
543 dnl $1 -- the macro to define
544 dnl $2 -- the value to translate
545 dnl $3 -- template name
546 AC_DEFUN(AC_TRANSLATE_DEFINE, [
547 if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
548 AC_DEFINE($1, 1, $3)
549 fi
550 ])
551
552 dnl Check that the host supports TUN/TAP devices
553 AC_CACHE_CHECK([whether TUN/TAP is supported],
554 ac_cv_tun_tap_support, [
555 AC_TRY_COMPILE([
556 #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
557 #include <linux/if.h>
558 #include <linux/if_tun.h>
559 #endif
560 #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
561 #include <net/if.h>
562 #include <net/if_tun.h>
563 #endif
564 ], [
565 struct ifreq ifr;
566 memset(&ifr, 0, sizeof(ifr));
567 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
568 ],
569 ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
570 )
571 ])
572 AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
573 [Define if your system supports TUN/TAP devices.])
574
575 dnl Various checks if the system supports vm_allocate() and the like functions.
576 have_mach_vm=no
577 if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
578 "x$ac_cv_func_vm_protect" = "xyes" ]]; then
579 have_mach_vm=yes
580 fi
581 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
582 [Define if your system has a working vm_allocate()-based memory allocator.])
583
584 dnl Check that vm_allocate(), vm_protect() work
585 if [[ "x$have_mach_vm" = "xyes" ]]; then
586
587 AC_CACHE_CHECK([whether vm_protect works],
588 ac_cv_vm_protect_works, [
589 AC_LANG_SAVE
590 AC_LANG_CPLUSPLUS
591 ac_cv_vm_protect_works=yes
592 dnl First the tests that should segfault
593 for test_def in NONE_READ NONE_WRITE READ_WRITE; do
594 AC_TRY_RUN([
595 #define CONFIGURE_TEST_VM_MAP
596 #define TEST_VM_PROT_$test_def
597 #include "vm_alloc.cpp"
598 ], ac_cv_vm_protect_works=no, rm -f core,
599 dnl When cross-compiling, do not assume anything
600 ac_cv_vm_protect_works="guessing no"
601 )
602 done
603 AC_TRY_RUN([
604 #define CONFIGURE_TEST_VM_MAP
605 #define TEST_VM_PROT_RDWR_WRITE
606 #include "vm_alloc.cpp"
607 ], , ac_cv_vm_protect_works=no,
608 dnl When cross-compiling, do not assume anything
609 ac_cv_vm_protect_works="guessing no"
610 )
611 AC_LANG_RESTORE
612 ]
613 )
614
615 dnl Remove support for vm_allocate() if vm_protect() does not work
616 if [[ "x$have_mach_vm" = "xyes" ]]; then
617 case $ac_cv_vm_protect_works in
618 *yes) have_mach_vm=yes;;
619 *no) have_mach_vm=no;;
620 esac
621 fi
622 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
623 [Define if your system has a working vm_allocate()-based memory allocator.])
624
625 fi dnl HAVE_MACH_VM
626
627 dnl Various checks if the system supports mmap() and the like functions.
628 dnl ... and Mach memory allocators are not supported
629 have_mmap_vm=no
630 if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
631 "x$ac_cv_func_mprotect" = "xyes" ]]; then
632 if [[ "x$have_mach_vm" = "xno" ]]; then
633 have_mmap_vm=yes
634 fi
635 fi
636 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
637 [Define if your system has a working mmap()-based memory allocator.])
638
639 dnl Check that mmap() and associated functions work.
640 if [[ "x$have_mmap_vm" = "xyes" ]]; then
641
642 dnl Check if we have a working anonymous mmap()
643 AC_CACHE_CHECK([whether mmap supports MAP_ANON],
644 ac_cv_mmap_anon, [
645 AC_LANG_SAVE
646 AC_LANG_CPLUSPLUS
647 AC_TRY_RUN([
648 #define HAVE_MMAP_ANON
649 #define CONFIGURE_TEST_VM_MAP
650 #define TEST_VM_MMAP_ANON
651 #include "vm_alloc.cpp"
652 ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
653 dnl When cross-compiling, do not assume anything.
654 ac_cv_mmap_anon="guessing no"
655 )
656 AC_LANG_RESTORE
657 ]
658 )
659 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
660 [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
661
662 AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
663 ac_cv_mmap_anonymous, [
664 AC_LANG_SAVE
665 AC_LANG_CPLUSPLUS
666 AC_TRY_RUN([
667 #define HAVE_MMAP_ANONYMOUS
668 #define CONFIGURE_TEST_VM_MAP
669 #define TEST_VM_MMAP_ANON
670 #include "vm_alloc.cpp"
671 ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
672 dnl When cross-compiling, do not assume anything.
673 ac_cv_mmap_anonymous="guessing no"
674 )
675 AC_LANG_RESTORE
676 ]
677 )
678 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
679 [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
680
681 AC_CACHE_CHECK([whether mprotect works],
682 ac_cv_mprotect_works, [
683 AC_LANG_SAVE
684 AC_LANG_CPLUSPLUS
685 ac_cv_mprotect_works=yes
686 dnl First the tests that should segfault
687 for test_def in NONE_READ NONE_WRITE READ_WRITE; do
688 AC_TRY_RUN([
689 #define CONFIGURE_TEST_VM_MAP
690 #define TEST_VM_PROT_$test_def
691 #include "vm_alloc.cpp"
692 ], ac_cv_mprotect_works=no, rm -f core,
693 dnl When cross-compiling, do not assume anything
694 ac_cv_mprotect_works="guessing no"
695 )
696 done
697 AC_TRY_RUN([
698 #define CONFIGURE_TEST_VM_MAP
699 #define TEST_VM_PROT_RDWR_WRITE
700 #include "vm_alloc.cpp"
701 ], , ac_cv_mprotect_works=no,
702 dnl When cross-compiling, do not assume anything
703 ac_cv_mprotect_works="guessing no"
704 )
705 AC_LANG_RESTORE
706 ]
707 )
708
709 dnl Remove support for mmap() if mprotect() does not work
710 if [[ "x$have_mmap_vm" = "xyes" ]]; then
711 case $ac_cv_mprotect_works in
712 *yes) have_mmap_vm=yes;;
713 *no) have_mmap_vm=no;;
714 esac
715 fi
716 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
717 [Define if your system has a working mmap()-based memory allocator.])
718
719 fi dnl HAVE_MMAP_VM
720
721 dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
722 AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000],
723 ac_cv_pagezero_hack, [
724 ac_cv_pagezero_hack=no
725 if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then
726 ac_cv_pagezero_hack=yes
727 dnl might as well skip the test for mmap-able low memory
728 ac_cv_can_map_lm=no
729 fi
730 ])
731 AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
732 [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
733
734 dnl Check if we can mmap 0x3000 bytes from 0x0000
735 AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000],
736 ac_cv_can_map_lm, [
737 AC_LANG_SAVE
738 AC_LANG_CPLUSPLUS
739 AC_TRY_RUN([
740 #include "vm_alloc.cpp"
741 int main(void) { /* returns 0 if we could map the lowmem globals */
742 volatile char * lm = 0;
743 if (vm_init() < 0) exit(1);
744 if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
745 lm[0] = 'z';
746 if (vm_release((char *)lm, 0x2000) < 0) exit(1);
747 vm_exit(); exit(0);
748 }
749 ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
750 dnl When cross-compiling, do not assume anything.
751 ac_cv_can_map_lm="guessing no"
752 )
753 AC_LANG_RESTORE
754 ]
755 )
756
757 dnl Check signal handlers need to be reinstalled
758 AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
759 ac_cv_signal_need_reinstall, [
760 AC_LANG_SAVE
761 AC_LANG_CPLUSPLUS
762 AC_TRY_RUN([
763 #include <stdlib.h>
764 #ifdef HAVE_UNISTD_H
765 #include <unistd.h>
766 #endif
767 #include <signal.h>
768 static int handled_signal = 0;
769 RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
770 int main(void) { /* returns 0 if signals need not to be reinstalled */
771 signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
772 exit(handled_signal == 2);
773 }
774 ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
775 dnl When cross-compiling, do not assume anything.
776 ac_cv_signal_need_reinstall="guessing yes"
777 )
778 AC_LANG_RESTORE
779 ]
780 )
781 AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
782 [Define if your system requires signals to be reinstalled.])
783
784 dnl Check if sigaction handlers need to be reinstalled
785 AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
786 ac_cv_sigaction_need_reinstall, [
787 AC_LANG_SAVE
788 AC_LANG_CPLUSPLUS
789 AC_TRY_RUN([
790 #include <stdlib.h>
791 #ifdef HAVE_UNISTD_H
792 #include <unistd.h>
793 #endif
794 #include <signal.h>
795 static int handled_signal = 0;
796 RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
797 typedef RETSIGTYPE (*signal_handler)(int);
798 static signal_handler mysignal(int sig, signal_handler handler) {
799 struct sigaction old_sa;
800 struct sigaction new_sa;
801 new_sa.sa_handler = handler;
802 return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
803 }
804 int main(void) { /* returns 0 if signals need not to be reinstalled */
805 mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
806 exit(handled_signal == 2);
807 }
808 ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
809 dnl When cross-compiling, do not assume anything.
810 ac_cv_sigaction_need_reinstall="guessing yes"
811 )
812 AC_LANG_RESTORE
813 ]
814 )
815 AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
816 [Define if your system requires sigactions to be reinstalled.])
817
818 dnl Check if Mach exceptions supported.
819 AC_CACHE_CHECK([whether your system supports Mach exceptions],
820 ac_cv_have_mach_exceptions, [
821 AC_LANG_SAVE
822 AC_LANG_CPLUSPLUS
823 AC_TRY_RUN([
824 #define HAVE_MACH_EXCEPTIONS 1
825 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
826 #include "vm_alloc.cpp"
827 #include "sigsegv.cpp"
828 ],
829 ac_cv_have_mach_exceptions=yes,
830 ac_cv_have_mach_exceptions=no,
831 dnl When cross-compiling, do not assume anything.
832 ac_cv_have_mach_exceptions=no
833 )
834 AC_LANG_RESTORE
835 ]
836 )
837 if [[ "$ac_cv_have_mach_exceptions" = "yes" ]]; then
838 sigsegv_recovery=mach
839 fi
840 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
841 [Define if your system supports Mach exceptions.])
842
843 dnl Check if Windows exceptions are supported.
844 AC_CACHE_CHECK([whether your system supports Windows exceptions],
845 ac_cv_have_win32_exceptions, [
846 AC_LANG_SAVE
847 AC_LANG_CPLUSPLUS
848 AC_TRY_RUN([
849 #define HAVE_WIN32_EXCEPTIONS 1
850 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
851 #include "vm_alloc.cpp"
852 #include "sigsegv.cpp"
853 ], [
854 sigsegv_recovery=win32
855 ac_cv_have_win32_exceptions=yes
856 ],
857 ac_cv_have_win32_exceptions=no,
858 dnl When cross-compiling, do not assume anything.
859 ac_cv_have_win32_exceptions=no
860 )
861 AC_LANG_RESTORE
862 ]
863 )
864 AC_TRANSLATE_DEFINE(HAVE_WIN32_EXCEPTIONS, "$ac_cv_have_win32_exceptions",
865 [Define if your system supports Windows exceptions.])
866
867 dnl Otherwise, check if extended signals are supported.
868 if [[ -z "$sigsegv_recovery" ]]; then
869 AC_CACHE_CHECK([whether your system supports extended signal handlers],
870 ac_cv_have_extended_signals, [
871 AC_LANG_SAVE
872 AC_LANG_CPLUSPLUS
873 AC_TRY_RUN([
874 #define HAVE_SIGINFO_T 1
875 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
876 #include "vm_alloc.cpp"
877 #include "sigsegv.cpp"
878 ],
879 ac_cv_have_extended_signals=yes,
880 ac_cv_have_extended_signals=no,
881 dnl When cross-compiling, do not assume anything.
882 ac_cv_have_extended_signals=no
883 )
884 AC_LANG_RESTORE
885 ]
886 )
887 if [[ "$ac_cv_have_extended_signals" = "yes" ]]; then
888 sigsegv_recovery=siginfo
889 fi
890 AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
891 [Define if your system support extended signals.])
892 fi
893
894 dnl Otherwise, check for subterfuges.
895 if [[ -z "$sigsegv_recovery" ]]; then
896 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
897 ac_cv_have_sigcontext_hack, [
898 AC_LANG_SAVE
899 AC_LANG_CPLUSPLUS
900 AC_TRY_RUN([
901 #define HAVE_SIGCONTEXT_SUBTERFUGE 1
902 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
903 #include "vm_alloc.cpp"
904 #include "sigsegv.cpp"
905 ],
906 ac_cv_have_sigcontext_hack=yes,
907 ac_cv_have_sigcontext_hack=no,
908 dnl When cross-compiling, do not assume anything.
909 ac_cv_have_sigcontext_hack=no
910 )
911 AC_LANG_RESTORE
912 ])
913 if [[ "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
914 sigsegv_recovery=sigcontext
915 fi
916 AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
917 [Define if we know a hack to replace siginfo_t->si_addr member.])
918 fi
919
920 dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
921 AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
922 ac_cv_have_skip_instruction, [
923 AC_LANG_SAVE
924 AC_LANG_CPLUSPLUS
925 AC_TRY_RUN([
926 #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
927 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
928 #include "vm_alloc.cpp"
929 #include "sigsegv.cpp"
930 ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
931 dnl When cross-compiling, do not assume anything.
932 ac_cv_have_skip_instruction=no
933 )
934 AC_LANG_RESTORE
935 ]
936 )
937 AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
938 [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
939
940 dnl Can we do Video on SEGV Signals ?
941 CAN_VOSF=no
942 if [[ -n "$sigsegv_recovery" ]]; then
943 CAN_VOSF=yes
944 fi
945
946 dnl Enable VOSF screen updates with this feature is requested and feasible
947 if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
948 AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
949 else
950 WANT_VOSF=no
951 fi
952
953 dnl Check addressing mode to use
954 AC_MSG_CHECKING([for addressing mode to use])
955 if [[ "$EMULATED_PPC" != "yes" ]]; then
956 if [[ "$WANT_ADDRESSING_MODE" != "real" ]]; then
957 AC_MSG_WARN([Running in native PowerPC mode, force use of Real Addressing.])
958 WANT_ADDRESSING_MODE="real"
959 fi
960 fi
961 if [[ "$WANT_ADDRESSING_MODE" = "direct" ]]; then
962 if [[ -n "$NATMEM_OFFSET" ]]; then
963 NATMEM_OFFSET_DEF="-DNATMEM_OFFSET=$NATMEM_OFFSET"
964 fi
965 AC_LANG_SAVE
966 AC_LANG_CPLUSPLUS
967 cat confdefs.h > conftest.$ac_ext
968 cat >> conftest.$ac_ext << EOF
969 #include <stdio.h>
970 #include <string.h>
971 #include "vm_alloc.cpp"
972
973 int main(void)
974 {
975 if (vm_init() < 0)
976 return 1;
977
978 static const struct {
979 unsigned long base;
980 unsigned int size;
981 } ranges[[]] = {
982 { 0x00000000, 0x0003000 },
983 { 0x10000000, 0x2000000 },
984 { 0x40800000, 0x0400000 },
985 { 0x68070000, 0x0010000 },
986 { 0x69000000, 0x0080000 },
987 { 0x68ffe000, 0x0002000 },
988 { 0x5fffe000, 0x0002000 },
989 { 0x60000000, 0x0040000 },
990 };
991 const int n_ranges = sizeof(ranges)/ sizeof(ranges[[0]]);
992
993 #ifdef NATMEM_OFFSET
994 unsigned long ofs = NATMEM_OFFSET;
995 #else
996 for (unsigned long ofs = 0x10000000; ofs <= 0x90000000; ofs += 0x10000000)
997 #endif
998 for (int i = 0; i < n_ranges; i++) {
999 char *m = (char *)(ranges[[i]].base + ofs);
1000 if (vm_acquire_fixed(m, ranges[[i]].size) != 0)
1001 break;
1002 memset(m, 0, ranges[[i]].size);
1003 vm_release(m, ranges[[i]].size);
1004 if (i == n_ranges - 1) {
1005 if (sizeof(void *) == 8 && ofs > 0xffffffff)
1006 printf("0x%lxul\n", ofs);
1007 else
1008 printf("0x%08x\n", ofs);
1009 return 0;
1010 }
1011 }
1012
1013 vm_exit();
1014 return 1;
1015 }
1016 EOF
1017 doit='$CXX conftest.$ac_ext -o conftest.$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS $NATMEM_OFFSET_DEF >& AS_MESSAGE_LOG_FD'
1018 if AC_TRY_EVAL(doit); then
1019 NATMEM_OFFSET=`./conftest.$ac_exeext`
1020 else
1021 NATMEM_OFFSET=
1022 fi
1023 rm -f conftest*
1024 AC_LANG_RESTORE
1025
1026 if [[ -z "$NATMEM_OFFSET" ]]; then
1027 AC_MSG_ERROR([could not determine a sensible NATMEM_OFFSET value])
1028 else
1029 WANT_ADDRESSING_MODE="direct,$NATMEM_OFFSET"
1030 AC_DEFINE_UNQUOTED(NATMEM_OFFSET, $NATMEM_OFFSET,
1031 [Define constant offset for Mac address translation])
1032 fi
1033 fi
1034 AC_MSG_RESULT($WANT_ADDRESSING_MODE)
1035
1036 dnl Utility macro used by next two tests.
1037 dnl AC_EXAMINE_OBJECT(C source code,
1038 dnl commands examining object file,
1039 dnl [commands to run if compile failed]):
1040 dnl
1041 dnl Compile the source code to an object file; then convert it into a
1042 dnl printable representation. All unprintable characters and
1043 dnl asterisks (*) are replaced by dots (.). All white space is
1044 dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
1045 dnl output, but runs of newlines are compressed to a single newline.
1046 dnl Finally, line breaks are forcibly inserted so that no line is
1047 dnl longer than 80 columns and the file ends with a newline. The
1048 dnl result of all this processing is in the file conftest.dmp, which
1049 dnl may be examined by the commands in the second argument.
1050 dnl
1051 AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
1052 [AC_LANG_SAVE
1053 AC_LANG_C
1054 dnl Next bit cribbed from AC_TRY_COMPILE.
1055 cat > conftest.$ac_ext <<EOF
1056 [#line __oline__ "configure"
1057 #include "confdefs.h"
1058 $1
1059 ]EOF
1060 if AC_TRY_EVAL(ac_compile); then
1061 od -c conftest.o |
1062 sed ['s/^[0-7]*[ ]*/ /
1063 s/\*/./g
1064 s/ \\n/*/g
1065 s/ [0-9][0-9][0-9]/./g
1066 s/ \\[^ ]/./g'] |
1067 tr -d '
1068 ' | tr -s '*' '
1069 ' | fold | sed '$a\
1070 ' > conftest.dmp
1071 $2
1072 ifelse($3, , , else
1073 $3
1074 )dnl
1075 fi
1076 rm -rf conftest*
1077 AC_LANG_RESTORE])
1078
1079 dnl Floating point format probe.
1080 dnl The basic concept is the same as the above: grep the object
1081 dnl file for an interesting string. We have to watch out for
1082 dnl rounding changing the values in the object, however; this is
1083 dnl handled by ignoring the least significant byte of the float.
1084 dnl
1085 dnl Does not know about VAX G-float or C4x idiosyncratic format.
1086 dnl It does know about PDP-10 idiosyncratic format, but this is
1087 dnl not presently supported by GCC. S/390 "binary floating point"
1088 dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
1089 dnl as ASCII?)
1090 dnl
1091 AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
1092 [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
1093 [gcc_AC_EXAMINE_OBJECT(
1094 [/* This will not work unless sizeof(double) == 8. */
1095 extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1096
1097 /* This structure must have no internal padding. */
1098 struct possibility {
1099 char prefix[8];
1100 double candidate;
1101 char postfix[8];
1102 };
1103
1104 #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1105 struct possibility table [] =
1106 {
1107 C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1108 C( 3.53802595280598432000e+18), /* D__float - VAX */
1109 C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1110 C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1111 C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
1112 };],
1113 [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1114 ac_cv_c_float_format='IEEE (big-endian)'
1115 elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1116 ac_cv_c_float_format='IEEE (big-endian)'
1117 elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1118 ac_cv_c_float_format='IEEE (little-endian)'
1119 elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1120 ac_cv_c_float_format='IEEE (little-endian)'
1121 elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1122 ac_cv_c_float_format='VAX D-float'
1123 elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1124 ac_cv_c_float_format='PDP-10'
1125 elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1126 ac_cv_c_float_format='IBM 370 hex'
1127 else
1128 AC_MSG_ERROR(Unknown floating point format)
1129 fi],
1130 [AC_MSG_ERROR(compile failed)])
1131 ])
1132 # IEEE is the default format. If the float endianness isn't the same
1133 # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1134 # (which is a tristate: yes, no, default). This is only an issue with
1135 # IEEE; the other formats are only supported by a few machines each,
1136 # all with the same endianness.
1137 format=IEEE_FLOAT_FORMAT
1138 fbigend=
1139 case $ac_cv_c_float_format in
1140 'IEEE (big-endian)' )
1141 if test $ac_cv_c_bigendian = no; then
1142 fbigend=1
1143 fi
1144 ;;
1145 'IEEE (little-endian)' )
1146 if test $ac_cv_c_bigendian = yes; then
1147 fbigend=0
1148 fi
1149 ;;
1150 'VAX D-float' )
1151 format=VAX_FLOAT_FORMAT
1152 ;;
1153 'PDP-10' )
1154 format=PDP10_FLOAT_FORMAT
1155 ;;
1156 'IBM 370 hex' )
1157 format=IBM_FLOAT_FORMAT
1158 ;;
1159 esac
1160 AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1161 [Define to the floating point format of the host machine.])
1162 if test -n "$fbigend"; then
1163 AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1164 [Define to 1 if the host machine stores floating point numbers in
1165 memory with the word containing the sign bit at the lowest address,
1166 or to 0 if it does it the other way around.
1167
1168 This macro should not be defined if the ordering is the same as for
1169 multi-word integers.])
1170 fi
1171 ])
1172
1173 dnl Check for host float format
1174 gcc_AC_C_FLOAT_FORMAT
1175
1176 dnl Platform specific binary postprocessor
1177 AC_PATH_PROG(BLESS, "true")
1178 if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
1179 BLESS=Darwin/lowmem
1180 LDFLAGS="$LDFLAGS -pagezero_size 0x3000"
1181 fi
1182
1183 dnl Check for GCC 2.7 or higher.
1184 HAVE_GCC27=no
1185 AC_MSG_CHECKING(for GCC 2.7 or higher)
1186 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5)
1187 # error gcc < 2.7
1188 #endif
1189 ]])],
1190 [AC_MSG_RESULT(yes); HAVE_GCC27=yes],
1191 [AC_MSG_RESULT(no)])
1192
1193 dnl Check for GCC 3.0 or higher.
1194 HAVE_GCC30=no
1195 AC_MSG_CHECKING(for GCC 3.0 or higher)
1196 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ >= 3)
1197 # error gcc < 3
1198 #endif
1199 ]])],
1200 [AC_MSG_RESULT(yes); HAVE_GCC30=yes],
1201 [AC_MSG_RESULT(no)])
1202
1203 dnl Check for ICC.
1204 AC_MSG_CHECKING(for ICC)
1205 HAVE_ICC=no
1206 if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
1207 HAVE_ICC=yes
1208 fi
1209 AC_MSG_RESULT($HAVE_ICC)
1210
1211 dnl Determine the generated object format
1212 AC_CACHE_CHECK([the format of compiler generated objects],
1213 ac_cv_object_format, [
1214 echo 'int i;' > conftest.$ac_ext
1215 ac_cv_object_format=no
1216 if AC_TRY_EVAL(ac_compile); then
1217 case `/usr/bin/file conftest.$ac_objext` in
1218 *"ELF"*)
1219 ac_cv_object_format=elf
1220 ;;
1221 *"Mach-O"*)
1222 ac_cv_object_format=mach
1223 ;;
1224 *)
1225 ac_cv_object_format=unknown
1226 ;;
1227 esac
1228 fi
1229 rm -rf conftest*
1230 ])
1231
1232 dnl Add -fno-strict-aliasing for slirp sources
1233 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1234 SAVED_CFLAGS="$CFLAGS"
1235 CFLAGS="$CFLAGS -fno-strict-aliasing"
1236 AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
1237 ac_cv_gcc_no_strict_aliasing, [
1238 AC_TRY_COMPILE([],[],
1239 [ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
1240 [ac_cv_gcc_no_strict_aliasing=no])
1241 ])
1242 CFLAGS="$SAVED_CFLAGS"
1243 fi
1244
1245 dnl Add -mdynamic-no-pic for MacOS X (XXX icc10 will support MacOS X)
1246 if [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1247 SAVED_CFLAGS="$CFLAGS"
1248 CFLAGS="$CFLAGS -mdynamic-no-pic"
1249 AC_CACHE_CHECK([whether the compiler supports -mdynamic-no-pic],
1250 ac_cv_gcc_mdynamic_no_pic, [
1251 AC_TRY_COMPILE([],[],[ac_cv_gcc_mdynamic_no_pic=yes],[ac_cv_gcc_mdynamic_no_pic=no])
1252 ])
1253 if [[ "x$ac_cv_gcc_mdynamic_no_pic" = "xyes" ]]; then
1254 CXXFLAGS="$CXXFLAGS -mdynamic-no-pic"
1255 else
1256 CFLAGS="$SAVED_CFLAGS"
1257 fi
1258 fi
1259
1260 dnl CPU emulator sources
1261 if [[ "x$EMULATED_PPC" = "xyes" ]]; then
1262 CPUSRCS="\
1263 ../kpx_cpu/src/mathlib/ieeefp.cpp \
1264 ../kpx_cpu/src/mathlib/mathlib.cpp \
1265 ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
1266 ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
1267 ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
1268 ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp"
1269 CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
1270
1271 dnl Enable JIT compiler, if possible
1272 if [[ "x$WANT_JIT" = "xyes" ]]; then
1273 AC_CACHE_CHECK([whether dyngen can be used],
1274 ac_cv_use_dyngen, [
1275 case $host_cpu:$ac_cv_object_format in
1276 powerpc:elf)
1277 ac_cv_use_dyngen=yes
1278 ;;
1279 x86_64:elf)
1280 ac_cv_use_dyngen=yes
1281 ;;
1282 i?86:elf)
1283 ac_cv_use_dyngen=yes
1284 ;;
1285 powerpc:mach)
1286 ac_cv_use_dyngen=yes
1287 ;;
1288 i?86:mach)
1289 ac_cv_use_dyngen=yes
1290 ;;
1291 *:*)
1292 ac_cv_use_dyngen=no
1293 ;;
1294 esac
1295 dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
1296 if [[ -z "$DYNGEN_CC" ]]; then
1297 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1298 DYNGEN_CC=$CXX
1299 else
1300 for p in /usr/bin /usr/local/bin; do
1301 gxx="$p/g++"
1302 if [[ -x "$gxx" ]]; then
1303 DYNGEN_CC="$gxx"
1304 fi
1305 done
1306 fi
1307 fi
1308 if [[ -z "$DYNGEN_CC" ]]; then
1309 ac_cv_use_dyngen=no
1310 fi
1311 ])
1312 if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1313 case $host_cpu in
1314 i?86)
1315 DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2"
1316 ;;
1317 powerpc)
1318 if [[ "x$ac_cv_object_format" = "xmach" ]]; then
1319 DYNGEN_OP_FLAGS="-mdynamic-no-pic"
1320 fi
1321 ;;
1322 esac
1323 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1324 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0"
1325 else
1326 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
1327 fi
1328 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-functions -finline-limit=10000 -fno-exceptions -g0"
1329 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1330 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
1331 fi
1332 else
1333 WANT_JIT=no
1334 fi
1335 AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
1336 if [[ "x$WANT_JIT" = "xyes" ]]; then
1337 DYNGENSRCS="\
1338 ../kpx_cpu/src/cpu/jit/dyngen.c \
1339 ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
1340 CPUSRCS="\
1341 ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
1342 ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
1343 ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS"
1344 fi
1345 fi
1346 CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
1347 else
1348 WANT_JIT=no
1349 fi
1350 if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1351 AC_CACHE_CHECK([whether static data regions are executable],
1352 ac_cv_have_static_data_exec, [
1353 AC_TRY_RUN([int main(void) {
1354 #if defined(__powerpc__) || defined(__ppc__)
1355 static unsigned int p[8] = {0x4e800020,};
1356 asm volatile("dcbst 0,%0" : : "r" (p) : "memory");
1357 asm volatile("sync" : : : "memory");
1358 asm volatile("icbi 0,%0" : : "r" (p) : "memory");
1359 asm volatile("sync" : : : "memory");
1360 asm volatile("isync" : : : "memory");
1361 ((void (*)(void))p)();
1362 return 0;
1363 #endif
1364 return 1;
1365 }], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no,
1366 dnl When cross-compiling, do not assume anything.
1367 ac_cv_have_static_data_exec=no
1368 )
1369 ])
1370 else
1371 ac_cv_use_dyngen=no
1372 fi
1373 AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec",
1374 [Define if your system marks static data pages as executable.])
1375
1376 if [[ "x$WANT_JIT" = "xyes" ]]; then
1377 CPPFLAGS="$CPPFLAGS -DUSE_JIT"
1378 fi
1379
1380 dnl Generate Makefile.
1381 AC_SUBST(PERL)
1382 AC_SUBST(USE_DYNGEN, [$ac_cv_use_dyngen])
1383 AC_SUBST(DYNGENSRCS)
1384 AC_SUBST(DYNGEN_CC)
1385 AC_SUBST(DYNGEN_OP_FLAGS)
1386 AC_SUBST(SYSSRCS)
1387 AC_SUBST(CPUSRCS)
1388 AC_SUBST(BLESS)
1389 AC_SUBST(KEYCODES)
1390 AC_OUTPUT([
1391 Makefile
1392 ../MacOSX/Info.plist
1393 ])
1394
1395 dnl Print summary.
1396 echo
1397 echo SheepShaver configuration summary:
1398 echo
1399 echo SDL support ...................... : $SDL_SUPPORT
1400 echo FBDev DGA support ................ : $WANT_FBDEV_DGA
1401 echo XFree86 DGA support .............. : $WANT_XF86_DGA
1402 echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
1403 echo Using PowerPC emulator ........... : $EMULATED_PPC
1404 echo Enable JIT compiler .............. : $WANT_JIT
1405 echo Enable video on SEGV signals ..... : $WANT_VOSF
1406 echo ESD sound support ................ : $WANT_ESD
1407 echo GTK user interface ............... : $WANT_GTK
1408 echo mon debugger support ............. : $WANT_MON
1409 echo Addressing mode .................. : $WANT_ADDRESSING_MODE
1410 echo Bad memory access recovery type .. : $sigsegv_recovery
1411 echo
1412 echo "Configuration done. Now type \"make\"."