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