ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.11
Committed: 2004-11-25T19:14:15Z (19 years, 11 months ago) by gbeauche
Branch: MAIN
Changes since 1.10: +2 -1 lines
Log Message:
enable build of the cpu tester from the SheepShaver tree

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