ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.66
Committed: 2009-08-18T03:27:50Z (15 years, 2 months ago) by asvitkine
Branch: MAIN
Changes since 1.65: +2 -2 lines
Log Message:
MacOSX: Use the prefs editor from the Launcher project.

File Contents

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