ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.72
Committed: 2012-06-15T22:58:29Z (12 years, 5 months ago) by asvitkine
Branch: MAIN
Changes since 1.71: +3 -0 lines
Log Message:
[Steven Noonan] configure.ac: enable JIT on 64-bit Intel Mac

d4dc0c70b24dc5981e752403e8fe047637d712a1
From: Steven Noonan <steven@uplinklabs.net>
Date: Wed, 1 Jun 2011 17:48:33 -0700
Subject: [PATCH] configure.ac: enable JIT on 64-bit Intel Mac

Signed-off-by: Steven Noonan <steven@uplinklabs.net>

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