ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.83
Committed: 2012-04-01T16:34:26Z (12 years, 7 months ago) by asvitkine
Branch: MAIN
Changes since 1.82: +2 -0 lines
Log Message:
|Description: fixes configure script generation on some systems.
|Author: Giulio Paci <giuliopaci@gmail.com>

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