ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.9
Committed: 2004-11-22T22:51:54Z (20 years ago) by gbeauche
Branch: MAIN
Changes since 1.8: +124 -27 lines
Log Message:
Cygwin support. Only generate NATMEM_OFFSET definitions in Direct Addressing
mode. Merge sshpty.c support detection code from Basilisk II.

File Contents

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