ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.27
Committed: 2005-06-22T15:37:25Z (18 years, 11 months ago) by gbeauche
Branch: MAIN
Changes since 1.26: +1 -1 lines
Log Message:
Enable build of the JIT with GCC 2.9x compilers (e.g. "2.96" from MDK 8.1).

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