ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.81
Committed: 2010-10-19T03:21:52Z (14 years ago) by asvitkine
Branch: MAIN
Changes since 1.80: +28 -0 lines
Log Message:
[Geoffrey Brown]
For my work on digital preservation it's important to have "golden"
disk images that are not corrupted by user action.  In order to enable
this, I've added support for VHD virtual disks (especially snapshots !)
to the Linux and OS X versions of BasiliskII and SheepShaver.

The support uses the open source libvhd library which is part of xen,
available here:
  http://www.xen.org/products/xen_source.html

The piece that's needed is libvhd which is in tools/blktap2 and it can
be separately compiled.
The vhd-util enables creation of vhd disks and snapshots.

Compiling libvhd for OS X is non-trivial and required  1) a new config
and 2) a number of small changes to the include files and c files.
Compiling for linux is a snap.

I use this as follows.

1) create my "golden image"  gold.dsk in the usual way
2) create a snapshot:  vhd-util snapshot -n gold.vhd -p gold.dsk -m
3) use the snapshot in my prefs file

In my work the golden images are in an AFS system which means the golden
images can reside at "universal" addresses.   The snapshots are initially
tiny, so a complete virtual machine configuration -- prefs + snapshot is
quick to download for the end user.

The snapshots are copy on write which has the pleasant side effect of
letting the end user keep any changes.

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