ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.52
Committed: 2005-07-01T05:57:07Z (19 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.51: +17 -1 lines
Log Message:
- Check for <stdint.h> ourselves if AC_HEADER_STDC didn't do that
- Build with -mdynamic-no-pic on MacOS X, this brings up to 20% performance
  improvement in the CPU core.

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