ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.69
Committed: 2010-10-19T22:20:01Z (14 years ago) by asvitkine
Branch: MAIN
Changes since 1.68: +27 -0 lines
Log Message:
[Geoffrey Brown]
VHD support

File Contents

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