ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.32
Committed: 2005-07-03T13:05:36Z (18 years, 11 months ago) by gbeauche
Branch: MAIN
Changes since 1.31: +44 -7 lines
Log Message:
Add necessary configury + support code to support slirp in SheepShaver,
the user-space network emulation layer. Enable it on all Unix supported
platforms where I know it works.

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