ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.38
Committed: 2005-07-25T19:46:24Z (19 years, 3 months ago) by gbeauche
Branch: MAIN
Changes since 1.37: +1 -1 lines
Log Message:
force -finline-functions to get inlining really operating with gcc < 3.3.6
on x86 or you may get a _ZN9bit_fieldILi0ELi0EE7extractEj undefined symbol

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