ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.52
Committed: 2006-05-06T10:42:51Z (18 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.51: +33 -0 lines
Log Message:
Add linker scripts from Basilisk II and make it possible to allocate up to
1 GB of Mac memory. Only tested on Linux/x86_64 so far but with a somewhat
interesting (MacOS, ROM, RAM size) matrix.

XXX: It should be possible to allocate up to 1.5 GB by relocating the ROM
base to something like 0x60800000.

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