ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.29
Committed: 2005-06-25T11:06:24Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.28: +6 -4 lines
Log Message:
We HAVE_PTHREADS even if we use our own pthreads implementation, this also
induces availability of locking primitives. I will merge the !HAVE_PTHREADS
case (a la Basilisk II) for EMULATED_PPC when I get back to home.

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