ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.10
Committed: 2004-11-24T22:48:02Z (19 years, 11 months ago) by gbeauche
Branch: MAIN
Changes since 1.9: +1 -0 lines
Log Message:
check for <fenv.h>

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 gbeauche 1.10 AC_CHECK_HEADERS(fenv.h)
264 gbeauche 1.1
265     dnl Checks for typedefs, structures, and compiler characteristics.
266     AC_C_BIGENDIAN
267     AC_C_CONST
268     AC_C_INLINE
269     AC_CHECK_SIZEOF(short, 2)
270     AC_CHECK_SIZEOF(int, 4)
271     AC_CHECK_SIZEOF(long, 4)
272     AC_CHECK_SIZEOF(long long, 8)
273     AC_CHECK_SIZEOF(float, 4)
274     AC_CHECK_SIZEOF(double, 8)
275     AC_CHECK_SIZEOF(void *, 4)
276     AC_TYPE_OFF_T
277     AC_CHECK_TYPE(loff_t, off_t)
278     AC_TYPE_SIZE_T
279     AC_TYPE_SIGNAL
280     AC_HEADER_TIME
281     AC_STRUCT_TM
282    
283     dnl Check whether struct sigaction has sa_restorer member.
284     AC_CACHE_CHECK([whether struct sigaction has sa_restorer],
285     ac_cv_signal_sa_restorer, [
286     AC_TRY_COMPILE([
287     #include <signal.h>
288     ], [struct sigaction sa; sa.sa_restorer = 0;],
289     ac_cv_signal_sa_restorer=yes, ac_cv_signal_sa_restorer=no,
290     dnl When cross-compiling, do not assume anything.
291     ac_cv_signal_sa_restorer=no
292     )
293     ])
294     if [[ "x$ac_cv_signal_sa_restorer" = "xyes" ]]; then
295     AC_DEFINE(HAVE_SIGNAL_SA_RESTORER, 1, [Define if sa_restorer is available in struct sigaction.])
296     fi
297    
298     dnl Checks for library functions.
299     AC_CHECK_FUNCS(strdup strlcpy cfmakeraw)
300     AC_CHECK_FUNCS(nanosleep)
301     AC_CHECK_FUNCS(sigaction signal)
302     AC_CHECK_FUNCS(mmap mprotect munmap)
303     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
304     AC_CHECK_FUNCS(posix_memalign memalign valloc)
305    
306     dnl Darwin seems to define mach_task_self() instead of task_self().
307     AC_CHECK_FUNCS(mach_task_self task_self)
308    
309     dnl We need clock_gettime() for better performance but it may drag
310     dnl libpthread in, which we don't want for native ppc mode
311     case $EMULATED_PPC:$target_os in
312     no:linux*)
313     ;;
314     *:*)
315     AC_SEARCH_LIBS(clock_gettime, [rt posix4])
316     AC_CHECK_FUNCS(clock_gettime)
317     ;;
318     esac
319    
320 gbeauche 1.9 dnl Check for headers and functions related to pty support (sshpty.c)
321     dnl From openssh-3.2.2p1 configure.ac
322     AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
323     AC_CHECK_FUNCS(_getpty vhangup strlcpy)
324    
325     case "$host" in
326     *-*-hpux10.26)
327     disable_ptmx_check=yes
328     ;;
329     *-*-linux*)
330     no_dev_ptmx=1
331     ;;
332     mips-sony-bsd|mips-sony-newsos4)
333     AC_DEFINE(HAVE_NEWS4, 1, [Define if you are on NEWS-OS (additions from openssh-3.2.2p1, for sshpty.c).])
334     ;;
335     *-*-sco3.2v4*)
336     no_dev_ptmx=1
337     ;;
338     *-*-sco3.2v5*)
339     no_dev_ptmx=1
340     ;;
341     *-*-cygwin*)
342     no_dev_ptmx=1
343     ;;
344     esac
345    
346     if test -z "$no_dev_ptmx" ; then
347     if test "x$disable_ptmx_check" != "xyes" ; then
348     AC_CHECK_FILE([/dev/ptmx],
349     [
350     AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.])
351     have_dev_ptmx=1
352     ]
353     )
354     fi
355     fi
356     AC_CHECK_FILE([/dev/ptc],
357     [
358     AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.])
359     have_dev_ptc=1
360     ]
361     )
362     dnl (end of code from openssh-3.2.2p1 configure.ac)
363    
364 gbeauche 1.1 dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
365     AC_DEFUN(AC_CHECK_FRAMEWORK, [
366     AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
367     AC_CACHE_CHECK([whether compiler supports framework $1],
368     ac_Framework, [
369     saved_LIBS="$LIBS"
370     LIBS="$LIBS -framework $1"
371     AC_TRY_LINK(
372     [$2], [int main(void) { return 0; }],
373     [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
374     )
375     ])
376     AS_IF([test AS_VAR_GET(ac_Framework) = yes],
377     [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
378     )
379     AS_VAR_POPDEF([ac_Framework])dnl
380     ])
381    
382     dnl Check for some MacOS X frameworks
383     AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
384     AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
385    
386     dnl Select system-dependant sources.
387     SERIALSRC=serial_unix.cpp
388     ETHERSRC=../dummy/ether_dummy.cpp
389     SCSISRC=../dummy/scsi_dummy.cpp
390     AUDIOSRC=../dummy/audio_dummy.cpp
391 gbeauche 1.6 EXTFSSRC=extfs_unix.cpp
392 gbeauche 1.1 EXTRASYSSRCS=
393     case "$target_os" in
394     linux*)
395     ETHERSRC=Linux/ether_linux.cpp
396     AUDIOSRC=audio_oss_esd.cpp
397     SCSISRC=Linux/scsi_linux.cpp
398     if [[ "x$EMULATED_PPC" = "xno" ]]; then
399     EXTRASYSSRCS="Linux/paranoia.cpp Linux/sheepthreads.c Linux/asm_linux.S"
400     fi
401     ;;
402     darwin*)
403     if [[ "x$EMULATED_PPC" = "xno" ]]; then
404     EXTRASYSSRCS="Darwin/paranoia.cpp Linux/asm_linux.S"
405     fi
406     if [[ "x$ac_cv_framework_IOKit" = "xyes" ]]; then
407     EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/sys_darwin.cpp"
408     fi
409 gbeauche 1.6 if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
410     EXTFSSRC=../MacOSX/extfs_macosx.mm
411     fi
412 gbeauche 1.1 ;;
413 gbeauche 1.9 cygwin*)
414     SERIALSRC="../dummy/serial_dummy.cpp"
415     ;;
416 gbeauche 1.1 esac
417    
418     dnl SDL overrides
419     if [[ "x$WANT_SDL" = "xyes" ]]; then
420     AC_DEFINE(USE_SDL, 1, [Define to enble SDL support.])
421     fi
422     if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
423 gbeauche 1.7 AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support.])
424 gbeauche 1.1 VIDEOSRCS="../SDL/video_sdl.cpp"
425     KEYCODES="../SDL/keycodes"
426     if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
427     EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp"
428     else
429 gbeauche 1.9 case "$target_os" in
430     cygwin*)
431     EXTRASYSSRCS="$EXTRASYSSRCS ../Windows/clip_windows.cpp"
432     ;;
433     *)
434     EXTRASYSSRCS="$EXTRASYSSRCS ../dummy/clip_dummy.cpp"
435     ;;
436     esac
437 gbeauche 1.1 fi
438     else
439     VIDEOSRCS="video_x.cpp"
440     KEYCODES="keycodes"
441     EXTRASYSSRCS="$EXTRASYSSRCS clip_unix.cpp"
442     fi
443 gbeauche 1.7 if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then
444     AC_DEFINE(USE_SDL_AUDIO, 1, [Define to enable SDL audio support])
445     AUDIOSRC="../SDL/audio_sdl.cpp"
446     fi
447 gbeauche 1.1
448 gbeauche 1.6 SYSSRCS="$VIDEOSRCS $EXTFSSRC $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
449 gbeauche 1.1
450     dnl Define a macro that translates a yesno-variable into a C macro definition
451     dnl to be put into the config.h file
452     dnl $1 -- the macro to define
453     dnl $2 -- the value to translate
454     dnl $3 -- template name
455     AC_DEFUN(AC_TRANSLATE_DEFINE, [
456     if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
457     AC_DEFINE($1, 1, $3)
458     fi
459     ])
460    
461     dnl Check that the host supports TUN/TAP devices
462     AC_CACHE_CHECK([whether TUN/TAP is supported],
463     ac_cv_tun_tap_support, [
464     AC_TRY_COMPILE([
465     #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
466     #include <linux/if.h>
467     #include <linux/if_tun.h>
468     #endif
469     #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
470     #include <net/if.h>
471     #include <net/if_tun.h>
472     #endif
473     ], [
474     struct ifreq ifr;
475     memset(&ifr, 0, sizeof(ifr));
476     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
477     ],
478     ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
479     )
480     ])
481     AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
482     [Define if your system supports TUN/TAP devices.])
483    
484     dnl Various checks if the system supports vm_allocate() and the like functions.
485     have_mach_vm=no
486     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
487     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
488     have_mach_vm=yes
489     fi
490     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
491     [Define if your system has a working vm_allocate()-based memory allocator.])
492    
493     dnl Check that vm_allocate(), vm_protect() work
494     if [[ "x$have_mach_vm" = "xyes" ]]; then
495    
496     AC_CACHE_CHECK([whether vm_protect works],
497     ac_cv_vm_protect_works, [
498     AC_LANG_SAVE
499     AC_LANG_CPLUSPLUS
500     ac_cv_vm_protect_works=yes
501     dnl First the tests that should segfault
502     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
503     AC_TRY_RUN([
504     #define CONFIGURE_TEST_VM_MAP
505     #define TEST_VM_PROT_$test_def
506     #include "vm_alloc.cpp"
507     ], ac_cv_vm_protect_works=no, rm -f core,
508     dnl When cross-compiling, do not assume anything
509     ac_cv_vm_protect_works="guessing no"
510     )
511     done
512     AC_TRY_RUN([
513     #define CONFIGURE_TEST_VM_MAP
514     #define TEST_VM_PROT_RDWR_WRITE
515     #include "vm_alloc.cpp"
516     ], , ac_cv_vm_protect_works=no,
517     dnl When cross-compiling, do not assume anything
518     ac_cv_vm_protect_works="guessing no"
519     )
520     AC_LANG_RESTORE
521     ]
522     )
523    
524     dnl Remove support for vm_allocate() if vm_protect() does not work
525     if [[ "x$have_mach_vm" = "xyes" ]]; then
526     case $ac_cv_vm_protect_works in
527     *yes) have_mach_vm=yes;;
528     *no) have_mach_vm=no;;
529     esac
530     fi
531     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
532     [Define if your system has a working vm_allocate()-based memory allocator.])
533    
534     fi dnl HAVE_MACH_VM
535    
536     dnl Various checks if the system supports mmap() and the like functions.
537     dnl ... and Mach memory allocators are not supported
538     have_mmap_vm=no
539     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
540     "x$ac_cv_func_mprotect" = "xyes" ]]; then
541     if [[ "x$have_mach_vm" = "xno" ]]; then
542     have_mmap_vm=yes
543     fi
544     fi
545     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
546     [Define if your system has a working mmap()-based memory allocator.])
547    
548     dnl Check that mmap() and associated functions work.
549     if [[ "x$have_mmap_vm" = "xyes" ]]; then
550    
551     dnl Check if we have a working anonymous mmap()
552     AC_CACHE_CHECK([whether mmap supports MAP_ANON],
553     ac_cv_mmap_anon, [
554     AC_LANG_SAVE
555     AC_LANG_CPLUSPLUS
556     AC_TRY_RUN([
557     #define HAVE_MMAP_ANON
558     #define CONFIGURE_TEST_VM_MAP
559     #define TEST_VM_MMAP_ANON
560     #include "vm_alloc.cpp"
561     ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
562     dnl When cross-compiling, do not assume anything.
563     ac_cv_mmap_anon="guessing no"
564     )
565     AC_LANG_RESTORE
566     ]
567     )
568     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
569     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
570    
571     AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
572     ac_cv_mmap_anonymous, [
573     AC_LANG_SAVE
574     AC_LANG_CPLUSPLUS
575     AC_TRY_RUN([
576     #define HAVE_MMAP_ANONYMOUS
577     #define CONFIGURE_TEST_VM_MAP
578     #define TEST_VM_MMAP_ANON
579     #include "vm_alloc.cpp"
580     ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
581     dnl When cross-compiling, do not assume anything.
582     ac_cv_mmap_anonymous="guessing no"
583     )
584     AC_LANG_RESTORE
585     ]
586     )
587     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
588     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
589    
590     AC_CACHE_CHECK([whether mprotect works],
591     ac_cv_mprotect_works, [
592     AC_LANG_SAVE
593     AC_LANG_CPLUSPLUS
594     ac_cv_mprotect_works=yes
595     dnl First the tests that should segfault
596     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
597     AC_TRY_RUN([
598     #define CONFIGURE_TEST_VM_MAP
599     #define TEST_VM_PROT_$test_def
600     #include "vm_alloc.cpp"
601     ], ac_cv_mprotect_works=no, rm -f core,
602     dnl When cross-compiling, do not assume anything
603     ac_cv_mprotect_works="guessing no"
604     )
605     done
606     AC_TRY_RUN([
607     #define CONFIGURE_TEST_VM_MAP
608     #define TEST_VM_PROT_RDWR_WRITE
609     #include "vm_alloc.cpp"
610     ], , ac_cv_mprotect_works=no,
611     dnl When cross-compiling, do not assume anything
612     ac_cv_mprotect_works="guessing no"
613     )
614     AC_LANG_RESTORE
615     ]
616     )
617    
618     dnl Remove support for mmap() if mprotect() does not work
619     if [[ "x$have_mmap_vm" = "xyes" ]]; then
620     case $ac_cv_mprotect_works in
621     *yes) have_mmap_vm=yes;;
622     *no) have_mmap_vm=no;;
623     esac
624     fi
625     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
626     [Define if your system has a working mmap()-based memory allocator.])
627    
628     fi dnl HAVE_MMAP_VM
629    
630     dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
631     AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000],
632     ac_cv_pagezero_hack, [
633     ac_cv_pagezero_hack=no
634     if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then
635     ac_cv_pagezero_hack=yes
636     dnl might as well skip the test for mmap-able low memory
637     ac_cv_can_map_lm=no
638     fi
639     ])
640     AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
641     [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
642    
643     dnl Check if we can mmap 0x3000 bytes from 0x0000
644     AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000],
645     ac_cv_can_map_lm, [
646     AC_LANG_SAVE
647     AC_LANG_CPLUSPLUS
648     AC_TRY_RUN([
649     #include "vm_alloc.cpp"
650     int main(void) { /* returns 0 if we could map the lowmem globals */
651     volatile char * lm = 0;
652     if (vm_init() < 0) exit(1);
653     if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
654     lm[0] = 'z';
655     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
656     vm_exit(); exit(0);
657     }
658     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
659     dnl When cross-compiling, do not assume anything.
660     ac_cv_can_map_lm="guessing no"
661     )
662     AC_LANG_RESTORE
663     ]
664     )
665    
666     dnl Check signal handlers need to be reinstalled
667     AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
668     ac_cv_signal_need_reinstall, [
669     AC_LANG_SAVE
670     AC_LANG_CPLUSPLUS
671     AC_TRY_RUN([
672     #include <stdlib.h>
673     #ifdef HAVE_UNISTD_H
674     #include <unistd.h>
675     #endif
676     #include <signal.h>
677     static int handled_signal = 0;
678     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
679     int main(void) { /* returns 0 if signals need not to be reinstalled */
680     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
681     exit(handled_signal == 2);
682     }
683     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
684     dnl When cross-compiling, do not assume anything.
685     ac_cv_signal_need_reinstall="guessing yes"
686     )
687     AC_LANG_RESTORE
688     ]
689     )
690     AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
691     [Define if your system requires signals to be reinstalled.])
692    
693     dnl Check if sigaction handlers need to be reinstalled
694     AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
695     ac_cv_sigaction_need_reinstall, [
696     AC_LANG_SAVE
697     AC_LANG_CPLUSPLUS
698     AC_TRY_RUN([
699     #include <stdlib.h>
700     #ifdef HAVE_UNISTD_H
701     #include <unistd.h>
702     #endif
703     #include <signal.h>
704     static int handled_signal = 0;
705     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
706     typedef RETSIGTYPE (*signal_handler)(int);
707     static signal_handler mysignal(int sig, signal_handler handler) {
708     struct sigaction old_sa;
709     struct sigaction new_sa;
710     new_sa.sa_handler = handler;
711     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
712     }
713     int main(void) { /* returns 0 if signals need not to be reinstalled */
714     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
715     exit(handled_signal == 2);
716     }
717     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
718     dnl When cross-compiling, do not assume anything.
719     ac_cv_sigaction_need_reinstall="guessing yes"
720     )
721     AC_LANG_RESTORE
722     ]
723     )
724     AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
725     [Define if your system requires sigactions to be reinstalled.])
726    
727     dnl Check if Mach exceptions supported.
728     AC_CACHE_CHECK([whether your system supports Mach exceptions],
729     ac_cv_have_mach_exceptions, [
730     AC_LANG_SAVE
731     AC_LANG_CPLUSPLUS
732     AC_TRY_RUN([
733     #define HAVE_MACH_EXCEPTIONS 1
734     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
735     #include "vm_alloc.cpp"
736     #include "sigsegv.cpp"
737     ],
738     ac_cv_have_mach_exceptions=yes,
739     ac_cv_have_mach_exceptions=no,
740     dnl When cross-compiling, do not assume anything.
741     ac_cv_have_mach_exceptions=no
742     )
743     AC_LANG_RESTORE
744     ]
745     )
746     if [[ "$ac_cv_have_mach_exceptions" = "yes" ]]; then
747     sigsegv_recovery=mach
748     fi
749     AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
750     [Define if your system supports Mach exceptions.])
751    
752 gbeauche 1.9 dnl Check if Windows exceptions are supported.
753     AC_CACHE_CHECK([whether your system supports Windows exceptions],
754     ac_cv_have_win32_exceptions, [
755     AC_LANG_SAVE
756     AC_LANG_CPLUSPLUS
757     AC_TRY_RUN([
758     #define HAVE_WIN32_EXCEPTIONS 1
759     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
760     #include "vm_alloc.cpp"
761     #include "sigsegv.cpp"
762     ], [
763     sigsegv_recovery=win32
764     ac_cv_have_win32_exceptions=yes
765     ],
766     ac_cv_have_win32_exceptions=no,
767     dnl When cross-compiling, do not assume anything.
768     ac_cv_have_win32_exceptions=no
769     )
770     AC_LANG_RESTORE
771     ]
772     )
773     AC_TRANSLATE_DEFINE(HAVE_WIN32_EXCEPTIONS, "$ac_cv_have_win32_exceptions",
774     [Define if your system supports Windows exceptions.])
775    
776 gbeauche 1.1 dnl Otherwise, check if extended signals are supported.
777     if [[ -z "$sigsegv_recovery" ]]; then
778     AC_CACHE_CHECK([whether your system supports extended signal handlers],
779     ac_cv_have_extended_signals, [
780     AC_LANG_SAVE
781     AC_LANG_CPLUSPLUS
782     AC_TRY_RUN([
783     #define HAVE_SIGINFO_T 1
784     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
785     #include "vm_alloc.cpp"
786     #include "sigsegv.cpp"
787     ],
788     ac_cv_have_extended_signals=yes,
789     ac_cv_have_extended_signals=no,
790     dnl When cross-compiling, do not assume anything.
791     ac_cv_have_extended_signals=no
792     )
793     AC_LANG_RESTORE
794     ]
795     )
796     if [[ "$ac_cv_have_extended_signals" = "yes" ]]; then
797     sigsegv_recovery=siginfo
798     fi
799     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
800     [Define if your system support extended signals.])
801     fi
802    
803     dnl Otherwise, check for subterfuges.
804     if [[ -z "$sigsegv_recovery" ]]; then
805     AC_CACHE_CHECK([whether we then have a subterfuge for your system],
806     ac_cv_have_sigcontext_hack, [
807     AC_LANG_SAVE
808     AC_LANG_CPLUSPLUS
809     AC_TRY_RUN([
810     #define HAVE_SIGCONTEXT_SUBTERFUGE 1
811     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
812     #include "vm_alloc.cpp"
813     #include "sigsegv.cpp"
814     ],
815     ac_cv_have_sigcontext_hack=yes,
816     ac_cv_have_sigcontext_hack=no,
817     dnl When cross-compiling, do not assume anything.
818     ac_cv_have_sigcontext_hack=no
819     )
820     AC_LANG_RESTORE
821     ])
822     if [[ "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
823     sigsegv_recovery=sigcontext
824     fi
825     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
826     [Define if we know a hack to replace siginfo_t->si_addr member.])
827     fi
828    
829     dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
830     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
831     ac_cv_have_skip_instruction, [
832     AC_LANG_SAVE
833     AC_LANG_CPLUSPLUS
834     AC_TRY_RUN([
835     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
836     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
837     #include "vm_alloc.cpp"
838     #include "sigsegv.cpp"
839     ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
840     dnl When cross-compiling, do not assume anything.
841     ac_cv_have_skip_instruction=no
842     )
843     AC_LANG_RESTORE
844     ]
845     )
846     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
847     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
848    
849     dnl Can we do Video on SEGV Signals ?
850     CAN_VOSF=no
851     if [[ -n "$sigsegv_recovery" ]]; then
852     CAN_VOSF=yes
853     fi
854    
855     dnl Enable VOSF screen updates with this feature is requested and feasible
856     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
857     AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
858     else
859     WANT_VOSF=no
860     fi
861    
862 gbeauche 1.8 dnl Check addressing mode to use
863     AC_MSG_CHECKING([for addressing mode to use])
864 gbeauche 1.9 case "$os_target" in
865     cygwin*)
866     WANT_ADDRESSING_MODE="direct,cygwin-hack"
867     NATMEM_OFFSET=
868     ;;
869     esac
870 gbeauche 1.8 if [[ "$EMULATED_PPC" != "yes" ]]; then
871     if [[ "$WANT_ADDRESSING_MODE" != "real" ]]; then
872     AC_MSG_WARN([Running in native PowerPC mode, force use of Real Addressing.])
873     WANT_ADDRESSING_MODE="real"
874     fi
875     fi
876     if [[ "$WANT_ADDRESSING_MODE" = "direct" ]]; then
877     if [[ -n "$NATMEM_OFFSET" ]]; then
878     NATMEM_OFFSET_DEF="-DNATMEM_OFFSET=$NATMEM_OFFSET"
879     fi
880     AC_LANG_SAVE
881     AC_LANG_CPLUSPLUS
882     cat confdefs.h > conftest.$ac_ext
883     cat >> conftest.$ac_ext << EOF
884     #include <stdio.h>
885     #include <string.h>
886     #include "vm_alloc.cpp"
887    
888     int main(void)
889     {
890     if (vm_init() < 0)
891     return 1;
892    
893     static const struct {
894     unsigned long base;
895     unsigned int size;
896     } ranges[[]] = {
897     { 0x00000000, 0x0003000 },
898     { 0x10000000, 0x2000000 },
899     { 0x40800000, 0x0400000 },
900     { 0x68070000, 0x0010000 },
901     { 0x69000000, 0x0080000 },
902     { 0x68ffe000, 0x0002000 },
903     { 0x5fffe000, 0x0002000 },
904     { 0x60000000, 0x0040000 },
905     };
906     const int n_ranges = sizeof(ranges)/ sizeof(ranges[[0]]);
907    
908     #ifdef NATMEM_OFFSET
909     unsigned long ofs = NATMEM_OFFSET;
910     #else
911     for (unsigned long ofs = 0x10000000; ofs <= 0x90000000; ofs += 0x10000000)
912     #endif
913     for (int i = 0; i < n_ranges; i++) {
914     char *m = (char *)(ranges[[i]].base + ofs);
915     if (vm_acquire_fixed(m, ranges[[i]].size) != 0)
916     break;
917     memset(m, 0, ranges[[i]].size);
918     vm_release(m, ranges[[i]].size);
919     if (i == n_ranges - 1) {
920     printf("0x%08x\n", ofs);
921     return 0;
922     }
923     }
924    
925     vm_exit();
926     return 1;
927     }
928     EOF
929     doit='$CXX conftest.$ac_ext -o conftest.$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS $NATMEM_OFFSET_DEF >& AS_MESSAGE_LOG_FD'
930     if AC_TRY_EVAL(doit); then
931     NATMEM_OFFSET=`./conftest.$ac_exeext`
932 gbeauche 1.9 else
933     NATMEM_OFFSET=
934 gbeauche 1.8 fi
935     rm -f conftest*
936     AC_LANG_RESTORE
937 gbeauche 1.9
938     if [[ -z "$NATMEM_OFFSET" ]]; then
939     AC_MSG_ERROR([could not determine a sensible NATMEM_OFFSET value])
940     else
941     WANT_ADDRESSING_MODE="direct,$NATMEM_OFFSET"
942     AC_DEFINE_UNQUOTED(NATMEM_OFFSET, $NATMEM_OFFSET,
943     [Define constant offset for Mac address translation])
944     fi
945 gbeauche 1.8 fi
946     AC_MSG_RESULT($WANT_ADDRESSING_MODE)
947    
948 gbeauche 1.1 dnl Platform specific binary postprocessor
949     AC_PATH_PROG(BLESS, "true")
950     if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
951     BLESS=Darwin/lowmem
952     LDFLAGS="$LDFLAGS -pagezero_size 0x3000"
953     fi
954    
955     dnl Check for GCC 2.7 or higher.
956     HAVE_GCC27=no
957     AC_MSG_CHECKING(for GCC 2.7 or higher)
958     AC_EGREP_CPP(xyes,
959     [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
960     xyes
961     #endif
962     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
963    
964     dnl Check for GCC 3.0 or higher.
965     HAVE_GCC30=no
966     AC_MSG_CHECKING(for GCC 3.0 or higher)
967     AC_EGREP_CPP(xyes,
968     [#if __GNUC__ >= 3
969     xyes
970     #endif
971     ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
972    
973     dnl Check for ICC.
974     AC_MSG_CHECKING(for ICC)
975     HAVE_ICC=no
976     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
977     HAVE_ICC=yes
978     fi
979     AC_MSG_RESULT($HAVE_ICC)
980    
981 gbeauche 1.9 dnl Determine the generated object format
982 gbeauche 1.1 AC_CACHE_CHECK([whether the compiler can generate ELF objects],
983 gbeauche 1.9 ac_cv_object_format, [
984 gbeauche 1.1 echo 'int i;' > conftest.$ac_ext
985 gbeauche 1.9 ac_cv_object_format=no
986 gbeauche 1.1 if AC_TRY_EVAL(ac_compile); then
987     case `/usr/bin/file conftest.$ac_objext` in
988     *"ELF"*)
989 gbeauche 1.9 ac_cv_object_format=elf
990     ;;
991     *)
992     ac_cv_object_format=unknown
993 gbeauche 1.1 ;;
994     esac
995     fi
996     rm -rf conftest*
997     ])
998    
999     dnl CPU emulator sources
1000     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
1001     CPUSRCS="\
1002 gbeauche 1.9 ../kpx_cpu/src/mathlib/ieeefp.cpp \
1003 gbeauche 1.1 ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
1004     ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
1005     ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
1006     ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp"
1007     CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
1008    
1009     dnl Enable JIT compiler, if possible
1010     if [[ "x$WANT_JIT" = "xyes" ]]; then
1011     AC_CACHE_CHECK([whether dyngen can be used],
1012     ac_cv_use_dyngen, [
1013 gbeauche 1.9 case $host_cpu:$ac_cv_object_format in
1014     powerpc:elf)
1015 gbeauche 1.1 ac_cv_use_dyngen=yes
1016     ;;
1017 gbeauche 1.9 x86_64:elf)
1018 gbeauche 1.1 ac_cv_use_dyngen=yes
1019     ;;
1020 gbeauche 1.9 i?86:elf)
1021 gbeauche 1.1 ac_cv_use_dyngen=yes
1022     ;;
1023     *:*)
1024     ac_cv_use_dyngen=no
1025     ;;
1026     esac
1027     dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
1028     if [[ -z "$DYNGEN_CC" ]]; then
1029     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1030     DYNGEN_CC=$CXX
1031     else
1032     for p in /usr/bin /usr/local/bin; do
1033     gxx="$p/g++"
1034     if [[ -x "$gxx" ]]; then
1035     DYNGEN_CC="$gxx"
1036     fi
1037     done
1038     fi
1039     fi
1040     if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include <limits>' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then
1041     ac_cv_use_dyngen=no
1042     fi
1043     ])
1044     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1045     case $host_cpu in
1046     i?86)
1047     DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2"
1048     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1049     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0"
1050     else
1051     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
1052     fi
1053     saved_CPPFLAGS=$CPPFLAGS
1054     CPPFLAGS="$CPPFLAGS -mmmx"
1055     AC_CHECK_HEADERS(mmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -mmmx"])
1056     CPPFLAGS="$CPPFLAGS -msse"
1057     AC_CHECK_HEADERS(xmmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse"])
1058     CPPFLAGS="$CPPFLAGS -msse2"
1059     AC_CHECK_HEADERS(emmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse2"])
1060     CPPFLAGS=$saved_CPPFLAGS
1061     ;;
1062     x86_64)
1063     AC_CHECK_HEADERS(mmintrin.h xmmintrin.h emmintrin.h)
1064     ;;
1065     esac
1066     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000"
1067     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1068     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
1069     fi
1070     else
1071     WANT_JIT=no
1072     fi
1073     AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
1074     if [[ "x$WANT_JIT" = "xyes" ]]; then
1075     DYNGENSRCS="\
1076     ../kpx_cpu/src/cpu/jit/dyngen.c \
1077     ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
1078     CPUSRCS="\
1079     ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
1080     ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
1081     ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS"
1082     fi
1083     fi
1084     CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
1085     else
1086     WANT_JIT=no
1087     fi
1088     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1089     AC_CACHE_CHECK([whether static data regions are executable],
1090     ac_cv_have_static_data_exec, [
1091     AC_TRY_RUN([int main(void) {
1092     #if defined(__powerpc__)
1093     static unsigned int p[8] = {0x4e800020,};
1094     asm volatile("dcbst 0,%0" : : "r" (p) : "memory");
1095     asm volatile("sync" : : : "memory");
1096     asm volatile("icbi 0,%0" : : "r" (p) : "memory");
1097     asm volatile("sync" : : : "memory");
1098     asm volatile("isync" : : : "memory");
1099     ((void (*)(void))p)();
1100     return 0;
1101     #endif
1102     return 1;
1103     }], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no,
1104     dnl When cross-compiling, do not assume anything.
1105     ac_cv_have_static_data_exec=no
1106     )
1107     ])
1108     fi
1109     AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec",
1110     [Define if your system marks static data pages as executable.])
1111    
1112     if [[ "x$WANT_JIT" = "xyes" ]]; then
1113     CPPFLAGS="$CPPFLAGS -DUSE_JIT"
1114     fi
1115    
1116     dnl Generate Makefile.
1117     AC_SUBST(DYNGENSRCS)
1118     AC_SUBST(DYNGEN_CC)
1119     AC_SUBST(DYNGEN_OP_FLAGS)
1120     AC_SUBST(SYSSRCS)
1121     AC_SUBST(CPUSRCS)
1122     AC_SUBST(BLESS)
1123     AC_SUBST(KEYCODES)
1124 gbeauche 1.5 AC_OUTPUT([
1125     Makefile
1126     ../MacOSX/Info.plist
1127     ])
1128 gbeauche 1.1
1129     dnl Print summary.
1130     echo
1131     echo SheepShaver configuration summary:
1132     echo
1133     echo SDL support ...................... : $SDL_SUPPORT
1134     echo XFree86 DGA support .............. : $WANT_XF86_DGA
1135     echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
1136     echo Using PowerPC emulator ........... : $EMULATED_PPC
1137     echo Enable JIT compiler .............. : $WANT_JIT
1138     echo Enable video on SEGV signals ..... : $WANT_VOSF
1139     echo ESD sound support ................ : $WANT_ESD
1140     echo GTK user interface ............... : $WANT_GTK
1141     echo mon debugger support ............. : $WANT_MON
1142 gbeauche 1.8 echo Addressing mode .................. : $WANT_ADDRESSING_MODE
1143 gbeauche 1.1 echo Bad memory access recovery type .. : $sigsegv_recovery
1144     echo
1145     echo "Configuration done. Now type \"make\"."