ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.70
Committed: 2010-12-28T02:36:09Z (13 years, 10 months ago) by asvitkine
Branch: MAIN
Changes since 1.69: +7 -0 lines
Log Message:
Add macro guards for config.h.

File Contents

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