ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.33
Committed: 2005-07-03T13:39:06Z (19 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.32: +14 -32 lines
Log Message:
Remove obsolete and broken Cygwin/X11 hacks. Forbid builds of the Windows
version from within the Unix/ directory.

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