ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.77
Committed: 2010-07-27T22:52:33Z (14 years, 4 months ago) by asvitkine
Branch: MAIN
Changes since 1.76: +3 -2 lines
Log Message:
Fixing sigsegv on Mach x86_64 - possibly a hack; I'm not sure why the
address returned doesn't have that bit set already.

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