ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.73
Committed: 2012-06-15T23:00:24Z (12 years, 5 months ago) by asvitkine
Branch: MAIN
Changes since 1.72: +4 -1 lines
Log Message:
[Steven Noonan] configure.ac: fix TUN/TAP detection on Linux

28ff27fc3ae3878fe9ca589f3c55c4261814266a
From: Steven Noonan <steven@uplinklabs.net>
Date: Wed, 1 Jun 2011 01:34:07 -0700
Subject: [PATCH] configure.ac: fix TUN/TAP detection on Linux

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 asvitkine 1.73 AC_CHECK_HEADERS(netinet/in.h linux/if.h linux/if_tun.h net/if.h net/if_tun.h, [], [], [
374 gbeauche 1.32 #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 asvitkine 1.73 #if defined(HAVE_NETINET_IN_H)
757     #include <netinet/in.h>
758     #endif
759 gbeauche 1.1 #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
760     #include <linux/if.h>
761     #include <linux/if_tun.h>
762     #endif
763     #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
764     #include <net/if.h>
765     #include <net/if_tun.h>
766     #endif
767     ], [
768     struct ifreq ifr;
769     memset(&ifr, 0, sizeof(ifr));
770     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
771     ],
772     ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
773     )
774     ])
775     AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
776     [Define if your system supports TUN/TAP devices.])
777    
778     dnl Various checks if the system supports vm_allocate() and the like functions.
779     have_mach_vm=no
780     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
781     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
782     have_mach_vm=yes
783     fi
784     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
785     [Define if your system has a working vm_allocate()-based memory allocator.])
786    
787     dnl Check that vm_allocate(), vm_protect() work
788     if [[ "x$have_mach_vm" = "xyes" ]]; then
789    
790     AC_CACHE_CHECK([whether vm_protect works],
791     ac_cv_vm_protect_works, [
792     AC_LANG_SAVE
793     AC_LANG_CPLUSPLUS
794     ac_cv_vm_protect_works=yes
795     dnl First the tests that should segfault
796     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
797     AC_TRY_RUN([
798     #define CONFIGURE_TEST_VM_MAP
799     #define TEST_VM_PROT_$test_def
800     #include "vm_alloc.cpp"
801     ], ac_cv_vm_protect_works=no, rm -f core,
802     dnl When cross-compiling, do not assume anything
803     ac_cv_vm_protect_works="guessing no"
804     )
805     done
806     AC_TRY_RUN([
807     #define CONFIGURE_TEST_VM_MAP
808     #define TEST_VM_PROT_RDWR_WRITE
809     #include "vm_alloc.cpp"
810     ], , ac_cv_vm_protect_works=no,
811     dnl When cross-compiling, do not assume anything
812     ac_cv_vm_protect_works="guessing no"
813     )
814     AC_LANG_RESTORE
815     ]
816     )
817    
818     dnl Remove support for vm_allocate() if vm_protect() does not work
819     if [[ "x$have_mach_vm" = "xyes" ]]; then
820     case $ac_cv_vm_protect_works in
821     *yes) have_mach_vm=yes;;
822     *no) have_mach_vm=no;;
823     esac
824     fi
825     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
826     [Define if your system has a working vm_allocate()-based memory allocator.])
827    
828     fi dnl HAVE_MACH_VM
829    
830     dnl Various checks if the system supports mmap() and the like functions.
831     dnl ... and Mach memory allocators are not supported
832     have_mmap_vm=no
833     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
834     "x$ac_cv_func_mprotect" = "xyes" ]]; then
835     if [[ "x$have_mach_vm" = "xno" ]]; then
836     have_mmap_vm=yes
837     fi
838     fi
839     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
840     [Define if your system has a working mmap()-based memory allocator.])
841    
842     dnl Check that mmap() and associated functions work.
843     if [[ "x$have_mmap_vm" = "xyes" ]]; then
844    
845     dnl Check if we have a working anonymous mmap()
846     AC_CACHE_CHECK([whether mmap supports MAP_ANON],
847     ac_cv_mmap_anon, [
848     AC_LANG_SAVE
849     AC_LANG_CPLUSPLUS
850     AC_TRY_RUN([
851     #define HAVE_MMAP_ANON
852     #define CONFIGURE_TEST_VM_MAP
853     #define TEST_VM_MMAP_ANON
854     #include "vm_alloc.cpp"
855     ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
856     dnl When cross-compiling, do not assume anything.
857     ac_cv_mmap_anon="guessing no"
858     )
859     AC_LANG_RESTORE
860     ]
861     )
862     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
863     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
864    
865     AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
866     ac_cv_mmap_anonymous, [
867     AC_LANG_SAVE
868     AC_LANG_CPLUSPLUS
869     AC_TRY_RUN([
870     #define HAVE_MMAP_ANONYMOUS
871     #define CONFIGURE_TEST_VM_MAP
872     #define TEST_VM_MMAP_ANON
873     #include "vm_alloc.cpp"
874     ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
875     dnl When cross-compiling, do not assume anything.
876     ac_cv_mmap_anonymous="guessing no"
877     )
878     AC_LANG_RESTORE
879     ]
880     )
881     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
882     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
883    
884     AC_CACHE_CHECK([whether mprotect works],
885     ac_cv_mprotect_works, [
886     AC_LANG_SAVE
887     AC_LANG_CPLUSPLUS
888     ac_cv_mprotect_works=yes
889     dnl First the tests that should segfault
890     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
891     AC_TRY_RUN([
892     #define CONFIGURE_TEST_VM_MAP
893     #define TEST_VM_PROT_$test_def
894     #include "vm_alloc.cpp"
895     ], ac_cv_mprotect_works=no, rm -f core,
896     dnl When cross-compiling, do not assume anything
897     ac_cv_mprotect_works="guessing no"
898     )
899     done
900     AC_TRY_RUN([
901     #define CONFIGURE_TEST_VM_MAP
902     #define TEST_VM_PROT_RDWR_WRITE
903     #include "vm_alloc.cpp"
904     ], , ac_cv_mprotect_works=no,
905     dnl When cross-compiling, do not assume anything
906     ac_cv_mprotect_works="guessing no"
907     )
908     AC_LANG_RESTORE
909     ]
910     )
911    
912     dnl Remove support for mmap() if mprotect() does not work
913     if [[ "x$have_mmap_vm" = "xyes" ]]; then
914     case $ac_cv_mprotect_works in
915     *yes) have_mmap_vm=yes;;
916     *no) have_mmap_vm=no;;
917     esac
918     fi
919     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
920     [Define if your system has a working mmap()-based memory allocator.])
921    
922     fi dnl HAVE_MMAP_VM
923    
924     dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
925     AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000],
926     ac_cv_pagezero_hack, [
927     ac_cv_pagezero_hack=no
928     if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then
929     ac_cv_pagezero_hack=yes
930     dnl might as well skip the test for mmap-able low memory
931     ac_cv_can_map_lm=no
932     fi
933     ])
934     AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
935     [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
936    
937     dnl Check if we can mmap 0x3000 bytes from 0x0000
938     AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000],
939     ac_cv_can_map_lm, [
940     AC_LANG_SAVE
941     AC_LANG_CPLUSPLUS
942     AC_TRY_RUN([
943     #include "vm_alloc.cpp"
944     int main(void) { /* returns 0 if we could map the lowmem globals */
945     volatile char * lm = 0;
946     if (vm_init() < 0) exit(1);
947     if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
948     lm[0] = 'z';
949     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
950     vm_exit(); exit(0);
951     }
952     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
953     dnl When cross-compiling, do not assume anything.
954     ac_cv_can_map_lm="guessing no"
955     )
956     AC_LANG_RESTORE
957     ]
958     )
959    
960     dnl Check signal handlers need to be reinstalled
961     AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
962     ac_cv_signal_need_reinstall, [
963     AC_LANG_SAVE
964     AC_LANG_CPLUSPLUS
965     AC_TRY_RUN([
966     #include <stdlib.h>
967     #ifdef HAVE_UNISTD_H
968     #include <unistd.h>
969     #endif
970     #include <signal.h>
971     static int handled_signal = 0;
972     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
973     int main(void) { /* returns 0 if signals need not to be reinstalled */
974     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
975     exit(handled_signal == 2);
976     }
977     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
978     dnl When cross-compiling, do not assume anything.
979     ac_cv_signal_need_reinstall="guessing yes"
980     )
981     AC_LANG_RESTORE
982     ]
983     )
984     AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
985     [Define if your system requires signals to be reinstalled.])
986    
987     dnl Check if sigaction handlers need to be reinstalled
988     AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
989     ac_cv_sigaction_need_reinstall, [
990     AC_LANG_SAVE
991     AC_LANG_CPLUSPLUS
992     AC_TRY_RUN([
993     #include <stdlib.h>
994     #ifdef HAVE_UNISTD_H
995     #include <unistd.h>
996     #endif
997     #include <signal.h>
998     static int handled_signal = 0;
999     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
1000     typedef RETSIGTYPE (*signal_handler)(int);
1001     static signal_handler mysignal(int sig, signal_handler handler) {
1002     struct sigaction old_sa;
1003     struct sigaction new_sa;
1004     new_sa.sa_handler = handler;
1005     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
1006     }
1007     int main(void) { /* returns 0 if signals need not to be reinstalled */
1008     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
1009     exit(handled_signal == 2);
1010     }
1011     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
1012     dnl When cross-compiling, do not assume anything.
1013     ac_cv_sigaction_need_reinstall="guessing yes"
1014     )
1015     AC_LANG_RESTORE
1016     ]
1017     )
1018     AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
1019     [Define if your system requires sigactions to be reinstalled.])
1020    
1021     dnl Check if Mach exceptions supported.
1022     AC_CACHE_CHECK([whether your system supports Mach exceptions],
1023     ac_cv_have_mach_exceptions, [
1024     AC_LANG_SAVE
1025     AC_LANG_CPLUSPLUS
1026     AC_TRY_RUN([
1027     #define HAVE_MACH_EXCEPTIONS 1
1028     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
1029     #include "vm_alloc.cpp"
1030     #include "sigsegv.cpp"
1031     ],
1032     ac_cv_have_mach_exceptions=yes,
1033     ac_cv_have_mach_exceptions=no,
1034     dnl When cross-compiling, do not assume anything.
1035     ac_cv_have_mach_exceptions=no
1036     )
1037     AC_LANG_RESTORE
1038     ]
1039     )
1040     if [[ "$ac_cv_have_mach_exceptions" = "yes" ]]; then
1041     sigsegv_recovery=mach
1042     fi
1043     AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
1044     [Define if your system supports Mach exceptions.])
1045    
1046 gbeauche 1.9 dnl Check if Windows exceptions are supported.
1047     AC_CACHE_CHECK([whether your system supports Windows exceptions],
1048     ac_cv_have_win32_exceptions, [
1049     AC_LANG_SAVE
1050     AC_LANG_CPLUSPLUS
1051     AC_TRY_RUN([
1052     #define HAVE_WIN32_EXCEPTIONS 1
1053     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
1054     #include "vm_alloc.cpp"
1055     #include "sigsegv.cpp"
1056     ], [
1057     sigsegv_recovery=win32
1058     ac_cv_have_win32_exceptions=yes
1059     ],
1060     ac_cv_have_win32_exceptions=no,
1061     dnl When cross-compiling, do not assume anything.
1062     ac_cv_have_win32_exceptions=no
1063     )
1064     AC_LANG_RESTORE
1065     ]
1066     )
1067     AC_TRANSLATE_DEFINE(HAVE_WIN32_EXCEPTIONS, "$ac_cv_have_win32_exceptions",
1068     [Define if your system supports Windows exceptions.])
1069    
1070 gbeauche 1.1 dnl Otherwise, check if extended signals are supported.
1071     if [[ -z "$sigsegv_recovery" ]]; then
1072     AC_CACHE_CHECK([whether your system supports extended signal handlers],
1073     ac_cv_have_extended_signals, [
1074     AC_LANG_SAVE
1075     AC_LANG_CPLUSPLUS
1076     AC_TRY_RUN([
1077     #define HAVE_SIGINFO_T 1
1078     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
1079     #include "vm_alloc.cpp"
1080     #include "sigsegv.cpp"
1081     ],
1082     ac_cv_have_extended_signals=yes,
1083     ac_cv_have_extended_signals=no,
1084     dnl When cross-compiling, do not assume anything.
1085     ac_cv_have_extended_signals=no
1086     )
1087     AC_LANG_RESTORE
1088     ]
1089     )
1090     if [[ "$ac_cv_have_extended_signals" = "yes" ]]; then
1091     sigsegv_recovery=siginfo
1092     fi
1093     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
1094     [Define if your system support extended signals.])
1095     fi
1096    
1097     dnl Otherwise, check for subterfuges.
1098     if [[ -z "$sigsegv_recovery" ]]; then
1099     AC_CACHE_CHECK([whether we then have a subterfuge for your system],
1100     ac_cv_have_sigcontext_hack, [
1101     AC_LANG_SAVE
1102     AC_LANG_CPLUSPLUS
1103     AC_TRY_RUN([
1104     #define HAVE_SIGCONTEXT_SUBTERFUGE 1
1105     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
1106     #include "vm_alloc.cpp"
1107     #include "sigsegv.cpp"
1108     ],
1109     ac_cv_have_sigcontext_hack=yes,
1110     ac_cv_have_sigcontext_hack=no,
1111     dnl When cross-compiling, do not assume anything.
1112     ac_cv_have_sigcontext_hack=no
1113     )
1114     AC_LANG_RESTORE
1115     ])
1116     if [[ "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
1117     sigsegv_recovery=sigcontext
1118     fi
1119     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
1120     [Define if we know a hack to replace siginfo_t->si_addr member.])
1121     fi
1122    
1123     dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
1124     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
1125     ac_cv_have_skip_instruction, [
1126     AC_LANG_SAVE
1127     AC_LANG_CPLUSPLUS
1128     AC_TRY_RUN([
1129     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
1130     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
1131     #include "vm_alloc.cpp"
1132     #include "sigsegv.cpp"
1133     ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
1134     dnl When cross-compiling, do not assume anything.
1135     ac_cv_have_skip_instruction=no
1136     )
1137     AC_LANG_RESTORE
1138     ]
1139     )
1140     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
1141     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
1142    
1143     dnl Can we do Video on SEGV Signals ?
1144     CAN_VOSF=no
1145     if [[ -n "$sigsegv_recovery" ]]; then
1146     CAN_VOSF=yes
1147     fi
1148    
1149     dnl Enable VOSF screen updates with this feature is requested and feasible
1150     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
1151     AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
1152     else
1153     WANT_VOSF=no
1154     fi
1155    
1156 gbeauche 1.8 dnl Check addressing mode to use
1157     AC_MSG_CHECKING([for addressing mode to use])
1158     if [[ "$EMULATED_PPC" != "yes" ]]; then
1159     if [[ "$WANT_ADDRESSING_MODE" != "real" ]]; then
1160     AC_MSG_WARN([Running in native PowerPC mode, force use of Real Addressing.])
1161     WANT_ADDRESSING_MODE="real"
1162     fi
1163     fi
1164     if [[ "$WANT_ADDRESSING_MODE" = "direct" ]]; then
1165     if [[ -n "$NATMEM_OFFSET" ]]; then
1166     NATMEM_OFFSET_DEF="-DNATMEM_OFFSET=$NATMEM_OFFSET"
1167     fi
1168     AC_LANG_SAVE
1169     AC_LANG_CPLUSPLUS
1170     cat confdefs.h > conftest.$ac_ext
1171     cat >> conftest.$ac_ext << EOF
1172     #include <stdio.h>
1173     #include <string.h>
1174     #include "vm_alloc.cpp"
1175    
1176     int main(void)
1177     {
1178     if (vm_init() < 0)
1179     return 1;
1180    
1181     static const struct {
1182     unsigned long base;
1183     unsigned int size;
1184     } ranges[[]] = {
1185     { 0x00000000, 0x0003000 },
1186     { 0x10000000, 0x2000000 },
1187     { 0x40800000, 0x0400000 },
1188     { 0x68070000, 0x0010000 },
1189     { 0x69000000, 0x0080000 },
1190     { 0x68ffe000, 0x0002000 },
1191     { 0x5fffe000, 0x0002000 },
1192     { 0x60000000, 0x0040000 },
1193     };
1194     const int n_ranges = sizeof(ranges)/ sizeof(ranges[[0]]);
1195    
1196     #ifdef NATMEM_OFFSET
1197     unsigned long ofs = NATMEM_OFFSET;
1198     #else
1199     for (unsigned long ofs = 0x10000000; ofs <= 0x90000000; ofs += 0x10000000)
1200     #endif
1201     for (int i = 0; i < n_ranges; i++) {
1202     char *m = (char *)(ranges[[i]].base + ofs);
1203     if (vm_acquire_fixed(m, ranges[[i]].size) != 0)
1204     break;
1205     memset(m, 0, ranges[[i]].size);
1206     vm_release(m, ranges[[i]].size);
1207     if (i == n_ranges - 1) {
1208 gbeauche 1.13 if (sizeof(void *) == 8 && ofs > 0xffffffff)
1209     printf("0x%lxul\n", ofs);
1210     else
1211     printf("0x%08x\n", ofs);
1212 gbeauche 1.8 return 0;
1213     }
1214     }
1215    
1216     vm_exit();
1217     return 1;
1218     }
1219     EOF
1220     doit='$CXX conftest.$ac_ext -o conftest.$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS $NATMEM_OFFSET_DEF >& AS_MESSAGE_LOG_FD'
1221     if AC_TRY_EVAL(doit); then
1222     NATMEM_OFFSET=`./conftest.$ac_exeext`
1223 gbeauche 1.9 else
1224     NATMEM_OFFSET=
1225 gbeauche 1.8 fi
1226     rm -f conftest*
1227     AC_LANG_RESTORE
1228 gbeauche 1.9
1229     if [[ -z "$NATMEM_OFFSET" ]]; then
1230     AC_MSG_ERROR([could not determine a sensible NATMEM_OFFSET value])
1231     else
1232     WANT_ADDRESSING_MODE="direct,$NATMEM_OFFSET"
1233     AC_DEFINE_UNQUOTED(NATMEM_OFFSET, $NATMEM_OFFSET,
1234     [Define constant offset for Mac address translation])
1235     fi
1236 gbeauche 1.8 fi
1237     AC_MSG_RESULT($WANT_ADDRESSING_MODE)
1238    
1239 gbeauche 1.26 dnl Utility macro used by next two tests.
1240     dnl AC_EXAMINE_OBJECT(C source code,
1241     dnl commands examining object file,
1242     dnl [commands to run if compile failed]):
1243     dnl
1244     dnl Compile the source code to an object file; then convert it into a
1245     dnl printable representation. All unprintable characters and
1246     dnl asterisks (*) are replaced by dots (.). All white space is
1247     dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
1248     dnl output, but runs of newlines are compressed to a single newline.
1249     dnl Finally, line breaks are forcibly inserted so that no line is
1250     dnl longer than 80 columns and the file ends with a newline. The
1251     dnl result of all this processing is in the file conftest.dmp, which
1252     dnl may be examined by the commands in the second argument.
1253     dnl
1254     AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
1255     [AC_LANG_SAVE
1256     AC_LANG_C
1257     dnl Next bit cribbed from AC_TRY_COMPILE.
1258     cat > conftest.$ac_ext <<EOF
1259     [#line __oline__ "configure"
1260     #include "confdefs.h"
1261     $1
1262     ]EOF
1263     if AC_TRY_EVAL(ac_compile); then
1264     od -c conftest.o |
1265     sed ['s/^[0-7]*[ ]*/ /
1266     s/\*/./g
1267     s/ \\n/*/g
1268     s/ [0-9][0-9][0-9]/./g
1269     s/ \\[^ ]/./g'] |
1270     tr -d '
1271     ' | tr -s '*' '
1272     ' | fold | sed '$a\
1273     ' > conftest.dmp
1274     $2
1275     ifelse($3, , , else
1276     $3
1277     )dnl
1278     fi
1279     rm -rf conftest*
1280     AC_LANG_RESTORE])
1281    
1282     dnl Floating point format probe.
1283     dnl The basic concept is the same as the above: grep the object
1284     dnl file for an interesting string. We have to watch out for
1285     dnl rounding changing the values in the object, however; this is
1286     dnl handled by ignoring the least significant byte of the float.
1287     dnl
1288     dnl Does not know about VAX G-float or C4x idiosyncratic format.
1289     dnl It does know about PDP-10 idiosyncratic format, but this is
1290     dnl not presently supported by GCC. S/390 "binary floating point"
1291     dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
1292     dnl as ASCII?)
1293     dnl
1294     AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
1295     [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
1296     [gcc_AC_EXAMINE_OBJECT(
1297     [/* This will not work unless sizeof(double) == 8. */
1298     extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1299    
1300     /* This structure must have no internal padding. */
1301     struct possibility {
1302     char prefix[8];
1303     double candidate;
1304     char postfix[8];
1305     };
1306    
1307     #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1308     struct possibility table [] =
1309     {
1310     C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1311     C( 3.53802595280598432000e+18), /* D__float - VAX */
1312     C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1313     C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1314     C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
1315     };],
1316     [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1317     ac_cv_c_float_format='IEEE (big-endian)'
1318     elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1319     ac_cv_c_float_format='IEEE (big-endian)'
1320     elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1321     ac_cv_c_float_format='IEEE (little-endian)'
1322     elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1323     ac_cv_c_float_format='IEEE (little-endian)'
1324     elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1325     ac_cv_c_float_format='VAX D-float'
1326     elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1327     ac_cv_c_float_format='PDP-10'
1328     elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1329     ac_cv_c_float_format='IBM 370 hex'
1330     else
1331     AC_MSG_ERROR(Unknown floating point format)
1332     fi],
1333     [AC_MSG_ERROR(compile failed)])
1334     ])
1335     # IEEE is the default format. If the float endianness isn't the same
1336     # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1337     # (which is a tristate: yes, no, default). This is only an issue with
1338     # IEEE; the other formats are only supported by a few machines each,
1339     # all with the same endianness.
1340     format=IEEE_FLOAT_FORMAT
1341     fbigend=
1342     case $ac_cv_c_float_format in
1343     'IEEE (big-endian)' )
1344     if test $ac_cv_c_bigendian = no; then
1345     fbigend=1
1346     fi
1347     ;;
1348     'IEEE (little-endian)' )
1349     if test $ac_cv_c_bigendian = yes; then
1350     fbigend=0
1351     fi
1352     ;;
1353     'VAX D-float' )
1354     format=VAX_FLOAT_FORMAT
1355     ;;
1356     'PDP-10' )
1357     format=PDP10_FLOAT_FORMAT
1358     ;;
1359     'IBM 370 hex' )
1360     format=IBM_FLOAT_FORMAT
1361     ;;
1362     esac
1363     AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1364     [Define to the floating point format of the host machine.])
1365     if test -n "$fbigend"; then
1366     AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1367     [Define to 1 if the host machine stores floating point numbers in
1368     memory with the word containing the sign bit at the lowest address,
1369     or to 0 if it does it the other way around.
1370    
1371     This macro should not be defined if the ordering is the same as for
1372     multi-word integers.])
1373     fi
1374     ])
1375    
1376     dnl Check for host float format
1377     gcc_AC_C_FLOAT_FORMAT
1378    
1379 gbeauche 1.1 dnl Platform specific binary postprocessor
1380     AC_PATH_PROG(BLESS, "true")
1381     if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
1382     BLESS=Darwin/lowmem
1383     LDFLAGS="$LDFLAGS -pagezero_size 0x3000"
1384     fi
1385    
1386     dnl Check for GCC 2.7 or higher.
1387     HAVE_GCC27=no
1388     AC_MSG_CHECKING(for GCC 2.7 or higher)
1389 gbeauche 1.36 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5)
1390     # error gcc < 2.7
1391 gbeauche 1.44 typedef syntax error;
1392 gbeauche 1.36 #endif
1393     ]])],
1394     [AC_MSG_RESULT(yes); HAVE_GCC27=yes],
1395     [AC_MSG_RESULT(no)])
1396 gbeauche 1.1
1397     dnl Check for GCC 3.0 or higher.
1398     HAVE_GCC30=no
1399     AC_MSG_CHECKING(for GCC 3.0 or higher)
1400 gbeauche 1.36 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ >= 3)
1401     # error gcc < 3
1402 gbeauche 1.44 typedef syntax error;
1403 gbeauche 1.36 #endif
1404     ]])],
1405     [AC_MSG_RESULT(yes); HAVE_GCC30=yes],
1406     [AC_MSG_RESULT(no)])
1407 gbeauche 1.1
1408     dnl Check for ICC.
1409     AC_MSG_CHECKING(for ICC)
1410     HAVE_ICC=no
1411     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
1412     HAVE_ICC=yes
1413     fi
1414     AC_MSG_RESULT($HAVE_ICC)
1415    
1416 gbeauche 1.9 dnl Determine the generated object format
1417 gbeauche 1.24 AC_CACHE_CHECK([the format of compiler generated objects],
1418 gbeauche 1.9 ac_cv_object_format, [
1419 gbeauche 1.1 echo 'int i;' > conftest.$ac_ext
1420 gbeauche 1.9 ac_cv_object_format=no
1421 gbeauche 1.1 if AC_TRY_EVAL(ac_compile); then
1422     case `/usr/bin/file conftest.$ac_objext` in
1423     *"ELF"*)
1424 gbeauche 1.9 ac_cv_object_format=elf
1425     ;;
1426 gbeauche 1.24 *"Mach-O"*)
1427     ac_cv_object_format=mach
1428     ;;
1429 gbeauche 1.9 *)
1430     ac_cv_object_format=unknown
1431 gbeauche 1.1 ;;
1432     esac
1433     fi
1434     rm -rf conftest*
1435     ])
1436    
1437 gbeauche 1.32 dnl Add -fno-strict-aliasing for slirp sources
1438     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1439     SAVED_CFLAGS="$CFLAGS"
1440     CFLAGS="$CFLAGS -fno-strict-aliasing"
1441     AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
1442     ac_cv_gcc_no_strict_aliasing, [
1443     AC_TRY_COMPILE([],[],
1444     [ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
1445     [ac_cv_gcc_no_strict_aliasing=no])
1446     ])
1447     CFLAGS="$SAVED_CFLAGS"
1448     fi
1449    
1450 gbeauche 1.39 dnl Add -mdynamic-no-pic for MacOS X (XXX icc10 will support MacOS X)
1451     if [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1452 gbeauche 1.31 SAVED_CFLAGS="$CFLAGS"
1453     CFLAGS="$CFLAGS -mdynamic-no-pic"
1454     AC_CACHE_CHECK([whether the compiler supports -mdynamic-no-pic],
1455     ac_cv_gcc_mdynamic_no_pic, [
1456     AC_TRY_COMPILE([],[],[ac_cv_gcc_mdynamic_no_pic=yes],[ac_cv_gcc_mdynamic_no_pic=no])
1457     ])
1458     if [[ "x$ac_cv_gcc_mdynamic_no_pic" = "xyes" ]]; then
1459     CXXFLAGS="$CXXFLAGS -mdynamic-no-pic"
1460     else
1461     CFLAGS="$SAVED_CFLAGS"
1462     fi
1463     fi
1464    
1465 gbeauche 1.1 dnl CPU emulator sources
1466     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
1467     CPUSRCS="\
1468 gbeauche 1.9 ../kpx_cpu/src/mathlib/ieeefp.cpp \
1469 gbeauche 1.26 ../kpx_cpu/src/mathlib/mathlib.cpp \
1470 gbeauche 1.1 ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
1471     ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
1472     ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
1473 gbeauche 1.55 ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp \
1474     ../kpx_cpu/src/utils/utils-cpuinfo.cpp"
1475 gbeauche 1.1 CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
1476    
1477     dnl Enable JIT compiler, if possible
1478     if [[ "x$WANT_JIT" = "xyes" ]]; then
1479     AC_CACHE_CHECK([whether dyngen can be used],
1480     ac_cv_use_dyngen, [
1481 gbeauche 1.9 case $host_cpu:$ac_cv_object_format in
1482     powerpc:elf)
1483 gbeauche 1.1 ac_cv_use_dyngen=yes
1484     ;;
1485 gbeauche 1.9 x86_64:elf)
1486 gbeauche 1.1 ac_cv_use_dyngen=yes
1487     ;;
1488 gbeauche 1.9 i?86:elf)
1489 gbeauche 1.1 ac_cv_use_dyngen=yes
1490     ;;
1491 gbeauche 1.43 mips:elf)
1492     ac_cv_use_dyngen=yes
1493     ;;
1494 gbeauche 1.24 powerpc:mach)
1495     ac_cv_use_dyngen=yes
1496     ;;
1497 asvitkine 1.72 x86_64:mach)
1498     ac_cv_use_dyngen=yes
1499     ;;
1500 gbeauche 1.41 i?86:mach)
1501     ac_cv_use_dyngen=yes
1502     ;;
1503 gbeauche 1.1 *:*)
1504     ac_cv_use_dyngen=no
1505     ;;
1506     esac
1507     dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
1508     if [[ -z "$DYNGEN_CC" ]]; then
1509     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1510     DYNGEN_CC=$CXX
1511     else
1512 gbeauche 1.44 for p in /usr/bin /usr/local/bin /usr/freeware/bin; do
1513 gbeauche 1.1 gxx="$p/g++"
1514     if [[ -x "$gxx" ]]; then
1515     DYNGEN_CC="$gxx"
1516     fi
1517     done
1518     fi
1519     fi
1520 gbeauche 1.27 if [[ -z "$DYNGEN_CC" ]]; then
1521 gbeauche 1.1 ac_cv_use_dyngen=no
1522     fi
1523     ])
1524     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1525     case $host_cpu in
1526     i?86)
1527 gbeauche 1.46 DYNGEN_OP_FLAGS="-fomit-frame-pointer"
1528 gbeauche 1.24 ;;
1529 gbeauche 1.43 mips)
1530     DYNGEN_OP_FLAGS="-fno-delayed-branch -mno-abicalls"
1531     ;;
1532 gbeauche 1.24 powerpc)
1533     if [[ "x$ac_cv_object_format" = "xmach" ]]; then
1534     DYNGEN_OP_FLAGS="-mdynamic-no-pic"
1535 gbeauche 1.1 fi
1536     ;;
1537     esac
1538 gbeauche 1.44 have_dyngen_gcc3=no
1539     case "x`$DYNGEN_CC -dumpversion`" in
1540     x[12].*) ;;
1541     x*) have_dyngen_gcc3=yes ;;
1542     esac
1543     if [[ "x$have_dyngen_gcc3" = "xyes" ]]; then
1544 gbeauche 1.53 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-align-functions"
1545 gbeauche 1.24 else
1546     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
1547     fi
1548 gbeauche 1.38 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-functions -finline-limit=10000 -fno-exceptions -g0"
1549 gbeauche 1.44 if [[ "x$have_dyngen_gcc3" = "xyes" ]]; then
1550 gbeauche 1.1 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
1551     fi
1552 gbeauche 1.43 if [[ "x$DYNGEN_CC" != "x$CXX" ]]; then
1553     DYNGEN_CFLAGS="-O2 $CFLAGS"
1554     DYNGEN_CXXFLAGS="-O2 $CXXFLAGS"
1555     else
1556     DYNGEN_CFLAGS="\$(CFLAGS)"
1557     DYNGEN_CXXFLAGS="\$(CXXFLAGS)"
1558     fi
1559 gbeauche 1.1 else
1560     WANT_JIT=no
1561     fi
1562     AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
1563     if [[ "x$WANT_JIT" = "xyes" ]]; then
1564     DYNGENSRCS="\
1565     ../kpx_cpu/src/cpu/jit/dyngen.c \
1566     ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
1567     CPUSRCS="\
1568     ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
1569     ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
1570 gbeauche 1.55 ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp \
1571     ../kpx_cpu/src/cpu/ppc/ppc-jit.cpp $CPUSRCS"
1572 gbeauche 1.1 fi
1573     fi
1574     CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
1575     else
1576     WANT_JIT=no
1577     fi
1578     if [[ "x$WANT_JIT" = "xyes" ]]; then
1579     CPPFLAGS="$CPPFLAGS -DUSE_JIT"
1580     fi
1581    
1582 gbeauche 1.43 dnl Higher level optimizations with MIPSPro compilers are possible
1583     if [[ "x$HAVE_IPA" = "xyes" ]]; then
1584     CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1585     CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1586     CXXFLAGS="-LANG:std $CXXFLAGS"
1587     LDFLAGS="$LDFLAGS -O3 -OPT:Olimit=0 -IPA"
1588     fi
1589    
1590 gbeauche 1.52 dnl Check for linker script support
1591     case $target_os:$target_cpu in
1592     linux*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
1593     linux*:x86_64) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-x86_64.ld";;
1594     linux*:powerpc) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-ppc.ld";;
1595     netbsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
1596     freebsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/freebsd-i386.ld";;
1597     darwin*:*) LINKER_SCRIPT_FLAGS="-Wl,-seg1addr,0x78048000";;
1598     esac
1599     if [[ -n "$LINKER_SCRIPT_FLAGS" ]]; then
1600     AC_CACHE_CHECK([whether linker script is usable],
1601     ac_cv_linker_script_works, [
1602     AC_LANG_SAVE
1603     AC_LANG_CPLUSPLUS
1604     saved_LDFLAGS="$LDFLAGS"
1605     LDFLAGS="$LDFLAGS $LINKER_SCRIPT_FLAGS"
1606     AC_TRY_RUN(
1607     [int main() {if ((char *)&main < (char *)0x70000000) return 1;}],
1608     [ac_cv_linker_script_works=yes],
1609     [ac_cv_linker_script_works=no],
1610     dnl When cross-compiling, assume it works
1611     [ac_cv_linker_script_works="guessing yes"]
1612     )
1613     AC_LANG_RESTORE
1614     if [[ "$ac_cv_linker_script_works" = "no" ]]; then
1615     LDFLAGS="$saved_LDFLAGS"
1616     LINKER_SCRIPT_FLAGS=""
1617     fi
1618     ])
1619     fi
1620     AC_TRANSLATE_DEFINE(HAVE_LINKER_SCRIPT, "$ac_cv_linker_script_works",
1621     [Define if there is a linker script to relocate the executable above 0x70000000.])
1622    
1623 gbeauche 1.1 dnl Generate Makefile.
1624 gbeauche 1.16 AC_SUBST(PERL)
1625 gbeauche 1.14 AC_SUBST(USE_DYNGEN, [$ac_cv_use_dyngen])
1626 gbeauche 1.1 AC_SUBST(DYNGENSRCS)
1627     AC_SUBST(DYNGEN_CC)
1628 gbeauche 1.43 AC_SUBST(DYNGEN_CFLAGS)
1629     AC_SUBST(DYNGEN_CXXFLAGS)
1630 gbeauche 1.1 AC_SUBST(DYNGEN_OP_FLAGS)
1631     AC_SUBST(SYSSRCS)
1632     AC_SUBST(CPUSRCS)
1633     AC_SUBST(BLESS)
1634     AC_SUBST(KEYCODES)
1635 gbeauche 1.5 AC_OUTPUT([
1636     Makefile
1637     ../MacOSX/Info.plist
1638     ])
1639 gbeauche 1.1
1640     dnl Print summary.
1641     echo
1642     echo SheepShaver configuration summary:
1643     echo
1644     echo SDL support ...................... : $SDL_SUPPORT
1645 asvitkine 1.68 echo BINCUE support ................... : $have_bincue
1646 asvitkine 1.69 echo LIBVHD support ................... : $have_libvhd
1647 gbeauche 1.21 echo FBDev DGA support ................ : $WANT_FBDEV_DGA
1648 gbeauche 1.1 echo XFree86 DGA support .............. : $WANT_XF86_DGA
1649     echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
1650     echo Using PowerPC emulator ........... : $EMULATED_PPC
1651     echo Enable JIT compiler .............. : $WANT_JIT
1652     echo Enable video on SEGV signals ..... : $WANT_VOSF
1653     echo ESD sound support ................ : $WANT_ESD
1654     echo GTK user interface ............... : $WANT_GTK
1655     echo mon debugger support ............. : $WANT_MON
1656 gbeauche 1.8 echo Addressing mode .................. : $WANT_ADDRESSING_MODE
1657 gbeauche 1.1 echo Bad memory access recovery type .. : $sigsegv_recovery
1658     echo
1659     echo "Configuration done. Now type \"make\"."