ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.59
Committed: 2007-06-13T16:34:13Z (17 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.58: +6 -0 lines
Log Message:
Add native audio support (without SDL) from Nigel's Basilisk II port to MacOS X.

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