ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.21
Committed: 2003-10-12T15:56:00Z (20 years, 7 months ago) by gbeauche
Branch: MAIN
Changes since 1.20: +51 -12 lines
Log Message:
Mach bad access recovery support from Michael Z. Sliczniak

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     AC_DEFINE(PACKAGE, PACKAGE_NAME, [Alias to PACKAGE for i18n.])
11     AC_DEFINE(VERSION, PACKAGE_VERSION, [Alias to VERSION for i18n.])
12    
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.5 dnl JIT compiler options.
24     AC_ARG_ENABLE(jit-compiler, [ --enable-jit-compiler enable JIT compiler [default=no]], [WANT_JIT=$enableval], [WANT_JIT=no])
25     AC_ARG_ENABLE(jit-debug, [ --enable-jit-debug activate native code disassemblers [default=no]], [WANT_JIT_DEBUG=$enableval], [WANT_JIT_DEBUG=no])
26    
27 gbeauche 1.1 dnl FPU emulation core.
28     AC_ARG_ENABLE(fpe,
29     [ --enable-fpe=FPE specify which fpu emulator to use [default=auto]],
30     [ case "$enableval" in
31     dnl default is always ieee, if architecture has this fp format
32     auto) FPE_CORE_TEST_ORDER="ieee uae";;
33     ieee) FPE_CORE_TEST_ORDER="ieee";;
34     uae) FPE_CORE_TEST_ORDER="uae";;
35     x86) FPE_CORE_TEST_ORDER="x86";;
36     *) AC_MSG_ERROR([--enable-fpe takes only one of the following values: auto, x86, ieee, uae]);;
37     esac
38     ],
39     [ FPE_CORE_TEST_ORDER="ieee uae"
40     ])
41    
42     dnl Addressing modes.
43     AC_ARG_ENABLE(addressing,
44     [ --enable-addressing=AM specify the addressing mode to use [default=fastest]],
45     [ case "$enableval" in
46     real) ADDRESSING_TEST_ORDER="real";;
47     direct) ADDRESSING_TEST_ORDER="direct";;
48     banks) ADDRESSING_TEST_ORDER="banks";;
49     fastest)ADDRESSING_TEST_ORDER="direct banks";;
50     *) AC_MSG_ERROR([--enable-addressing takes only one of the following values: fastest, real, direct, banks]);;
51     esac
52     ],
53     [ ADDRESSING_TEST_ORDER="direct banks"
54     ])
55    
56     dnl External packages.
57     AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes])
58     AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes])
59     AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
60    
61     dnl Canonical system information.
62     AC_CANONICAL_HOST
63     AC_CANONICAL_TARGET
64    
65     dnl Target OS type (target is host if not cross-compiling).
66     case "$target_os" in
67     linux*) OS_TYPE=linux;;
68     netbsd*) OS_TYPE=netbsd;;
69     freebsd*) OS_TYPE=freebsd;;
70     solaris*) OS_TYPE=solaris;;
71     darwin*) OS_TYPE=darwin;;
72     *) OS_TYPE=`echo $target_os | sed -e 's/-/_/g' | sed -e 's/\./_/g'`;;
73     esac
74     DEFINES="$DEFINES -DOS_$OS_TYPE"
75    
76     dnl Target CPU type.
77     HAVE_I386=no
78     HAVE_M68K=no
79     HAVE_SPARC=no
80     HAVE_POWERPC=no
81 gbeauche 1.13 HAVE_X86_64=no
82 gbeauche 1.1 case "$target_cpu" in
83 gbeauche 1.12 i386* | i486* | i586* | i686* | i786* ) HAVE_I386=yes;;
84     m68k* ) HAVE_M68K=yes;;
85     sparc* ) HAVE_SPARC=yes;;
86     powerpc* ) HAVE_POWERPC=yes;;
87 gbeauche 1.13 x86_64* ) HAVE_X86_64=yes;;
88 gbeauche 1.1 esac
89    
90     dnl Checks for programs.
91     AC_PROG_CC
92     AC_PROG_CC_C_O
93     AC_PROG_CPP
94     AC_PROG_CXX
95     AC_PROG_MAKE_SET
96     AC_PROG_INSTALL
97    
98     dnl We use mon if possible.
99     MONSRCS=
100     if [[ "x$WANT_MON" = "xyes" ]]; then
101     AC_MSG_CHECKING(for mon)
102     mon_srcdir=../../../mon/src
103     if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
104     AC_MSG_RESULT(yes)
105     AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".])
106     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"
107     CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
108     AC_CHECK_LIB(ncurses, tgetent, ,
109     AC_CHECK_LIB(termcap, tgetent, ,
110     AC_CHECK_LIB(termlib, tgetent, ,
111     AC_CHECK_LIB(terminfo, tgetent, ,
112     AC_CHECK_LIB(Hcurses, tgetent, ,
113     AC_CHECK_LIB(curses, tgetent))))))
114     AC_CHECK_LIB(readline, readline)
115     else
116     AC_MSG_RESULT(no)
117     AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
118     WANT_MON=no
119     fi
120     fi
121    
122     dnl Checks for libraries.
123     AC_CHECK_LIB(posix4, sem_init)
124     AC_CHECK_LIB(rt, timer_create)
125    
126     dnl We need X11.
127     AC_PATH_XTRA
128     if [[ "x$no_x" = "xyes" ]]; then
129     AC_MSG_ERROR([You need X11 to run Basilisk II.])
130     fi
131     CFLAGS="$CFLAGS $X_CFLAGS"
132     CXXFLAGS="$CXXFLAGS $X_CFLAGS"
133     LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
134    
135     dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL.
136     HAVE_PTHREADS=yes
137     AC_CHECK_LIB(pthread, pthread_create, , [
138     AC_CHECK_LIB(c_r, pthread_create, , [
139     AC_CHECK_LIB(PTL, pthread_create, , [
140     HAVE_PTHREADS=no
141     ])
142     ])
143     ])
144     if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
145     AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.])
146     fi
147     AC_CHECK_FUNCS(pthread_cancel)
148     AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
149     AC_CHECK_FUNCS(pthread_mutexattr_settype)
150 gbeauche 1.3 AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
151 gbeauche 1.1
152     dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
153     SEMSRC=
154     AC_CHECK_FUNCS(sem_init, , [
155     if test "x$HAVE_PTHREADS" = "xyes"; then
156     SEMSRC=posix_sem.cpp
157     fi
158     ])
159    
160     dnl We use DGA (XFree86 or fbdev) if possible.
161     if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then
162     AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [
163     AC_DEFINE(ENABLE_XF86_DGA, 1, [Define if using XFree86 DGA extension.])
164     LIBS="$LIBS -lXxf86dga"
165     if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
166     AC_MSG_WARN([Cannot have both --enable-xf86-dga and --enable-fbdev-dga, ignoring --enable-fbdev-dga.])
167     WANT_FBDEV_DGA=no
168     fi
169     ], [
170     AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.])
171     WANT_XF86_DGA=no
172     ])
173     fi
174     if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
175     AC_DEFINE(ENABLE_FBDEV_DGA, 1, [Define if using DGA with framebuffer device.])
176     fi
177    
178     dnl We use XFree86 VidMode if possible.
179     if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then
180     AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [
181     AC_DEFINE(ENABLE_XF86_VIDMODE, 1, [Define if using XFree86 DGA extension.])
182     LIBS="$LIBS -lXxf86vm"
183     ], [
184     AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.])
185     WANT_XF86_VIDMODE=no
186     ])
187     fi
188    
189     dnl We use GTK+ if possible.
190     UISRCS=../dummy/prefs_editor_dummy.cpp
191     if [[ "x$WANT_GTK" = "xyes" ]]; then
192     AM_PATH_GTK(1.2.0, [
193     AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
194     CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
195     LIBS="$LIBS $GTK_LIBS"
196     UISRCS=prefs_editor_gtk.cpp
197 gbeauche 1.18 dnl somehow, <gnome-i18n.h> would redefine gettext() to nothing if
198     dnl ENABLE_NLS is not set, thusly conflicting with C++ <string> which
199     dnl includes <libintl.h>
200     AM_GNU_GETTEXT
201 gbeauche 1.1 B2_PATH_GNOMEUI([
202     AC_DEFINE(HAVE_GNOMEUI, 1, [Define if libgnomeui is available.])
203     CXXFLAGS="$CXXFLAGS $GNOMEUI_CFLAGS"
204     LIBS="$LIBS $GNOMEUI_LIBS"
205     ], [])
206     ], [
207     AC_MSG_WARN([Could not find GTK+, disabling user interface.])
208     WANT_GTK=no
209     ])
210     fi
211    
212     dnl We use ESD if possible.
213     if [[ "x$WANT_ESD" = "xyes" ]]; then
214     AM_PATH_ESD(0.2.8, [
215     AC_DEFINE(ENABLE_ESD, 1, [Define is using ESD.])
216     CFLAGS="$CFLAGS $ESD_CFLAGS"
217     CXXFLAGS="$CXXFLAGS $ESD_CFLAGS"
218     LIBS="$LIBS $ESD_LIBS"
219     ], [
220     AC_MSG_WARN([Could not find ESD, disabling ESD support.])
221     WANT_ESD=no
222     ])
223     fi
224    
225     dnl We use 64-bit file size support if possible.
226     AC_SYS_LARGEFILE
227    
228     dnl Checks for header files.
229     AC_HEADER_STDC
230 gbeauche 1.21 AC_CHECK_HEADERS(unistd.h fcntl.h sys/time.h sys/mman.h mach/mach.h)
231 gbeauche 1.20 AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
232 gbeauche 1.1
233     dnl Checks for typedefs, structures, and compiler characteristics.
234     AC_C_BIGENDIAN
235     AC_C_CONST
236     AC_C_INLINE
237     AC_CHECK_SIZEOF(short, 2)
238     AC_CHECK_SIZEOF(int, 4)
239     AC_CHECK_SIZEOF(long, 4)
240     AC_CHECK_SIZEOF(long long, 8)
241     AC_CHECK_SIZEOF(float, 4)
242     AC_CHECK_SIZEOF(double, 8)
243     AC_CHECK_SIZEOF(long double, 12)
244     AC_CHECK_SIZEOF(void *, 4)
245     AC_TYPE_OFF_T
246     AC_CHECK_TYPE(loff_t, off_t)
247     AC_CHECK_TYPE(caddr_t, [char *])
248     AC_TYPE_SIZE_T
249     AC_TYPE_SIGNAL
250     AC_HEADER_TIME
251     AC_STRUCT_TM
252    
253     dnl Check whether sys/socket.h defines type socklen_t.
254     dnl (extracted from ac-archive/Miscellaneous)
255     AC_CACHE_CHECK([for socklen_t],
256     ac_cv_type_socklen_t, [
257     AC_TRY_COMPILE([
258     #include <sys/types.h>
259     #include <sys/socket.h>
260     ], [socklen_t len = 42; return 0;],
261     ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no,
262     dnl When cross-compiling, do not assume anything.
263     ac_cv_type_socklen_t="guessing no"
264     )
265     ])
266     if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then
267     AC_DEFINE(socklen_t, int, [Define to 'int' if <sys/types.h> doesn't define.])
268     fi
269    
270     dnl Checks for library functions.
271     AC_CHECK_FUNCS(strdup cfmakeraw)
272     AC_CHECK_FUNCS(clock_gettime timer_create)
273     AC_CHECK_FUNCS(sigaction signal)
274     AC_CHECK_FUNCS(mmap mprotect munmap)
275     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
276    
277     dnl Darwin seems to define mach_task_self() instead of task_self().
278     AC_CHECK_FUNCS(mach_task_self task_self)
279    
280     dnl Check for headers and functions related to pty support (sshpty.c)
281     dnl From openssh-3.2.2p1 configure.ac
282    
283     AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
284     AC_CHECK_FUNCS(_getpty vhangup strlcpy)
285    
286     case "$host" in
287     *-*-hpux10.26)
288     disable_ptmx_check=yes
289     ;;
290     *-*-linux*)
291     no_dev_ptmx=1
292     ;;
293     mips-sony-bsd|mips-sony-newsos4)
294     AC_DEFINE(HAVE_NEWS4, 1, [Define if you are on NEWS-OS (additions from openssh-3.2.2p1, for sshpty.c).])
295     ;;
296     *-*-sco3.2v4*)
297     no_dev_ptmx=1
298     ;;
299     *-*-sco3.2v5*)
300     no_dev_ptmx=1
301     ;;
302     esac
303    
304     if test -z "$no_dev_ptmx" ; then
305     if test "x$disable_ptmx_check" != "xyes" ; then
306     AC_CHECK_FILE([/dev/ptmx],
307     [
308     AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.])
309     have_dev_ptmx=1
310     ]
311     )
312     fi
313     fi
314     AC_CHECK_FILE([/dev/ptc],
315     [
316     AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.])
317     have_dev_ptc=1
318     ]
319     )
320    
321     dnl (end of code from openssh-3.2.2p1 configure.ac)
322    
323    
324     dnl Select system-dependant source files.
325     SERIALSRC=serial_unix.cpp
326     ETHERSRC=../dummy/ether_dummy.cpp
327     SCSISRC=../dummy/scsi_dummy.cpp
328     AUDIOSRC=../dummy/audio_dummy.cpp
329     EXTRASYSSRCS=
330     CAN_NATIVE_M68K=no
331     case "$target_os" in
332     linux*)
333     ETHERSRC=ether_unix.cpp
334     AUDIOSRC=audio_oss_esd.cpp
335     SCSISRC=Linux/scsi_linux.cpp
336     ;;
337     freebsd*)
338     ETHERSRC=ether_unix.cpp
339     AUDIOSRC=audio_oss_esd.cpp
340     DEFINES="$DEFINES -DBSD_COMP"
341     CXXFLAGS="$CXXFLAGS -fpermissive"
342     dnl Check for the CAM library
343     AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no)
344     if [[ "x$HAVE_LIBCAM" = "xno" ]]; then
345     AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.])
346     else
347     dnl Check for the sys kernel includes
348     AC_CHECK_HEADER(camlib.h)
349     if [[ "x$ac_cv_header_camlib_h" = "xno" ]]; then
350     dnl In this case I should fix this thing including a "patch"
351     dnl to access directly to the functions in the kernel :) --Orlando
352     AC_MSG_WARN([Cannot find includes for CAM library, disabling SCSI support.])
353     else
354     SCSISRC=FreeBSD/scsi_freebsd.cpp
355     LIBS="$LIBS -lcam"
356     DEFINES="$DEFINES -DCAM"
357     fi
358     fi
359     ;;
360     netbsd*)
361     CAN_NATIVE_M68K=yes
362     ;;
363     solaris*)
364     AUDIOSRC=Solaris/audio_solaris.cpp
365     DEFINES="$DEFINES -DBSD_COMP -D_POSIX_PTHREAD_SEMANTICS"
366     ;;
367     irix*)
368     ETHERSRC=ether_unix.cpp
369     AUDIOSRC=Irix/audio_irix.cpp
370     EXTRASYSSRCS=Irix/unaligned.c
371     dnl IRIX headers work fine, but somehow don't define or use "STDC_HEADERS"
372     DEFINES="$DEFINES -DCRTSCTS=CNEW_RTSCTS -DB230400=B115200 -DSTDC_HEADERS"
373     LIBS="$LIBS -laudio"
374     WANT_ESD=no
375    
376 gbeauche 1.14 dnl Check if our compiler supports -IPA (MIPSPro)
377     HAVE_IPA=no
378 gbeauche 1.1 ocflags="$CFLAGS"
379 gbeauche 1.14 CFLAGS=`echo "$CFLAGS -IPA" | sed -e "s/-g//g"`
380     AC_MSG_CHECKING(if "-IPA" works)
381 gbeauche 1.1 dnl Do a test compile of an empty function
382 gbeauche 1.14 AC_TRY_COMPILE(,, [AC_MSG_RESULT(yes); HAVE_IPA=yes], AC_MSG_RESULT(no))
383 gbeauche 1.1 CFLAGS="$ocflags"
384    
385     ;;
386     esac
387    
388     dnl Use 68k CPU natively?
389     WANT_NATIVE_M68K=no
390     if [[ "x$HAVE_M68K" = "xyes" -a "x$CAN_NATIVE_M68K" = "xyes" ]]; then
391     AC_DEFINE(ENABLE_NATIVE_M68K, 1, [Define if using native 68k mode.])
392     WANT_NATIVE_M68K=yes
393     fi
394    
395     if [[ "x$HAVE_PTHREADS" = "xno" ]]; then
396     dnl Serial, ethernet and audio support needs pthreads
397     AC_MSG_WARN([You don't have pthreads, disabling serial, ethernet and audio support.])
398     SERIALSRC=../dummy/serial_dummy.cpp
399     ETHERSRC=../dummy/ether_dummy.cpp
400     AUDIOSRC=../dummy/audio_dummy.cpp
401     fi
402     SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
403    
404     dnl Define a macro that translates a yesno-variable into a C macro definition
405     dnl to be put into the config.h file
406     dnl $1 -- the macro to define
407     dnl $2 -- the value to translate
408     dnl $3 -- template name
409     AC_DEFUN(AC_TRANSLATE_DEFINE, [
410     if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
411     AC_DEFINE($1, 1, $3)
412     fi
413     ])
414    
415     dnl Various checks if the system supports vm_allocate() and the like functions.
416     have_mach_vm=no
417     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
418     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
419     have_mach_vm=yes
420     fi
421     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
422     [Define if your system has a working vm_allocate()-based memory allocator.])
423    
424     dnl Check that vm_allocate(), vm_protect() work
425     if [[ "x$have_mach_vm" = "xyes" ]]; then
426    
427     AC_CACHE_CHECK([whether vm_protect works],
428     ac_cv_vm_protect_works, [
429     AC_LANG_SAVE
430     AC_LANG_CPLUSPLUS
431     ac_cv_vm_protect_works=yes
432     dnl First the tests that should segfault
433     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
434     AC_TRY_RUN([
435     #define CONFIGURE_TEST_VM_MAP
436     #define TEST_VM_PROT_$test_def
437     #include "vm_alloc.cpp"
438     ], ac_cv_vm_protect_works=no, rm -f core,
439     dnl When cross-compiling, do not assume anything
440     ac_cv_vm_protect_works="guessing no"
441     )
442     done
443     AC_TRY_RUN([
444     #define CONFIGURE_TEST_VM_MAP
445     #define TEST_VM_PROT_RDWR_WRITE
446     #include "vm_alloc.cpp"
447     ], , ac_cv_vm_protect_works=no,
448     dnl When cross-compiling, do not assume anything
449     ac_cv_vm_protect_works="guessing no"
450     )
451     AC_LANG_RESTORE
452     ]
453     )
454    
455     dnl Remove support for vm_allocate() if vm_protect() does not work
456     if [[ "x$have_mach_vm" = "xyes" ]]; then
457     case $ac_cv_vm_protect_works in
458     *yes) have_mach_vm=yes;;
459     *no) have_mach_vm=no;;
460     esac
461     fi
462     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
463     [Define if your system has a working vm_allocate()-based memory allocator.])
464    
465     fi dnl HAVE_MACH_VM
466    
467     dnl Various checks if the system supports mmap() and the like functions.
468     dnl ... and Mach memory allocators are not supported
469     have_mmap_vm=no
470     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
471     "x$ac_cv_func_mprotect" = "xyes" ]]; then
472     if [[ "x$have_mach_vm" = "xno" ]]; then
473     have_mmap_vm=yes
474     fi
475     fi
476     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
477     [Define if your system has a working mmap()-based memory allocator.])
478    
479     dnl Check that mmap() and associated functions work.
480     if [[ "x$have_mmap_vm" = "xyes" ]]; then
481    
482     dnl Check if we have a working anonymous mmap()
483     AC_CACHE_CHECK([whether mmap supports MAP_ANON],
484     ac_cv_mmap_anon, [
485     AC_LANG_SAVE
486     AC_LANG_CPLUSPLUS
487     AC_TRY_RUN([
488     #define HAVE_MMAP_ANON
489     #define CONFIGURE_TEST_VM_MAP
490     #define TEST_VM_MMAP_ANON
491     #include "vm_alloc.cpp"
492     ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
493     dnl When cross-compiling, do not assume anything.
494     ac_cv_mmap_anon="guessing no"
495     )
496     AC_LANG_RESTORE
497     ]
498     )
499     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
500     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
501    
502     AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
503     ac_cv_mmap_anonymous, [
504     AC_LANG_SAVE
505     AC_LANG_CPLUSPLUS
506     AC_TRY_RUN([
507     #define HAVE_MMAP_ANONYMOUS
508     #define CONFIGURE_TEST_VM_MAP
509     #define TEST_VM_MMAP_ANON
510     #include "vm_alloc.cpp"
511     ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
512     dnl When cross-compiling, do not assume anything.
513     ac_cv_mmap_anonymous="guessing no"
514     )
515     AC_LANG_RESTORE
516     ]
517     )
518     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
519     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
520    
521     AC_CACHE_CHECK([whether mprotect works],
522     ac_cv_mprotect_works, [
523     AC_LANG_SAVE
524     AC_LANG_CPLUSPLUS
525     ac_cv_mprotect_works=yes
526     dnl First the tests that should segfault
527     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
528     AC_TRY_RUN([
529     #define CONFIGURE_TEST_VM_MAP
530     #define TEST_VM_PROT_$test_def
531     #include "vm_alloc.cpp"
532     ], ac_cv_mprotect_works=no, rm -f core,
533     dnl When cross-compiling, do not assume anything
534     ac_cv_mprotect_works="guessing no"
535     )
536     done
537     AC_TRY_RUN([
538     #define CONFIGURE_TEST_VM_MAP
539     #define TEST_VM_PROT_RDWR_WRITE
540     #include "vm_alloc.cpp"
541     ], , ac_cv_mprotect_works=no,
542     dnl When cross-compiling, do not assume anything
543     ac_cv_mprotect_works="guessing no"
544     )
545     AC_LANG_RESTORE
546     ]
547     )
548    
549     dnl Remove support for mmap() if mprotect() does not work
550     if [[ "x$have_mmap_vm" = "xyes" ]]; then
551     case $ac_cv_mprotect_works in
552     *yes) have_mmap_vm=yes;;
553     *no) have_mmap_vm=no;;
554     esac
555     fi
556     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
557     [Define if your system has a working mmap()-based memory allocator.])
558    
559     fi dnl HAVE_MMAP_VM
560    
561     dnl Check if we can mmap 0x2000 bytes from 0x0000
562     AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x2000],
563     ac_cv_can_map_lm, [
564     AC_LANG_SAVE
565     AC_LANG_CPLUSPLUS
566     AC_TRY_RUN([
567     #include "vm_alloc.cpp"
568     int main(void) { /* returns 0 if we could map the lowmem globals */
569 gbeauche 1.15 volatile char * lm = 0;
570 gbeauche 1.1 if (vm_init() < 0) exit(1);
571 gbeauche 1.15 if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
572 gbeauche 1.1 lm[0] = 'z';
573     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
574     vm_exit(); exit(0);
575     }
576     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
577     dnl When cross-compiling, do not assume anything.
578     ac_cv_can_map_lm="guessing no"
579     )
580     AC_LANG_RESTORE
581     ]
582     )
583    
584     dnl Check signal handlers need to be reinstalled
585     AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
586     ac_cv_signal_need_reinstall, [
587     AC_LANG_SAVE
588     AC_LANG_CPLUSPLUS
589     AC_TRY_RUN([
590     #include <stdlib.h>
591     #ifdef HAVE_UNISTD_H
592     #include <unistd.h>
593     #endif
594     #include <signal.h>
595     static int handled_signal = 0;
596     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
597     int main(void) { /* returns 0 if signals need not to be reinstalled */
598     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
599     exit(handled_signal == 2);
600     }
601     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
602     dnl When cross-compiling, do not assume anything.
603     ac_cv_signal_need_reinstall="guessing yes"
604     )
605     AC_LANG_RESTORE
606     ]
607     )
608     AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
609     [Define if your system requires signals to be reinstalled.])
610    
611     dnl Check if sigaction handlers need to be reinstalled
612     AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
613     ac_cv_sigaction_need_reinstall, [
614     AC_LANG_SAVE
615     AC_LANG_CPLUSPLUS
616     AC_TRY_RUN([
617     #include <stdlib.h>
618     #ifdef HAVE_UNISTD_H
619     #include <unistd.h>
620     #endif
621     #include <signal.h>
622     static int handled_signal = 0;
623     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
624     typedef RETSIGTYPE (*signal_handler)(int);
625     static signal_handler mysignal(int sig, signal_handler handler) {
626     struct sigaction old_sa;
627     struct sigaction new_sa;
628     new_sa.sa_handler = handler;
629     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
630     }
631     int main(void) { /* returns 0 if signals need not to be reinstalled */
632     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
633     exit(handled_signal == 2);
634     }
635     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
636     dnl When cross-compiling, do not assume anything.
637     ac_cv_sigaction_need_reinstall="guessing yes"
638     )
639     AC_LANG_RESTORE
640     ]
641     )
642     AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
643     [Define if your system requires sigactions to be reinstalled.])
644    
645 gbeauche 1.21 dnl Check if Mach exceptions supported.
646     AC_CACHE_CHECK([whether your system supports Mach exceptions],
647     ac_cv_have_mach_exceptions, [
648 gbeauche 1.1 AC_LANG_SAVE
649     AC_LANG_CPLUSPLUS
650     AC_TRY_RUN([
651 gbeauche 1.21 #define HAVE_MACH_EXCEPTIONS 1
652 gbeauche 1.1 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
653     #include "vm_alloc.cpp"
654     #include "sigsegv.cpp"
655 gbeauche 1.21 ], [
656     sigsegv_recovery=mach
657     ac_cv_have_mach_exceptions=yes
658     ],
659     ac_cv_have_mach_exceptions=no,
660 gbeauche 1.1 dnl When cross-compiling, do not assume anything.
661 gbeauche 1.21 ac_cv_have_mach_exceptions=no
662 gbeauche 1.1 )
663     AC_LANG_RESTORE
664     ]
665     )
666 gbeauche 1.21 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
667     [Define if your system supports Mach exceptions.])
668    
669     dnl Otherwise, check if extended signals are supported.
670     if [[ -z "$sigsegv_recovery" ]]; then
671     AC_CACHE_CHECK([whether your system supports extended signal handlers],
672     ac_cv_have_extended_signals, [
673     AC_LANG_SAVE
674     AC_LANG_CPLUSPLUS
675     AC_TRY_RUN([
676     #define HAVE_SIGINFO_T 1
677     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
678     #include "vm_alloc.cpp"
679     #include "sigsegv.cpp"
680     ], [
681     sigsegv_recovery=siginfo
682     ac_cv_have_extended_signals=yes
683     ],
684     ac_cv_have_extended_signals=no,
685     dnl When cross-compiling, do not assume anything.
686     ac_cv_have_extended_signals=no
687     )
688     AC_LANG_RESTORE
689     ]
690     )
691     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
692     [Define if your system support extended signals.])
693     fi
694 gbeauche 1.1
695     dnl Otherwise, check for subterfuges.
696 gbeauche 1.21 if [[ -z "$sigsegv_recovery" ]]; then
697 gbeauche 1.1 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
698     ac_cv_have_sigcontext_hack, [
699     AC_LANG_SAVE
700     AC_LANG_CPLUSPLUS
701     AC_TRY_RUN([
702     #define HAVE_SIGCONTEXT_SUBTERFUGE 1
703     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
704     #include "vm_alloc.cpp"
705     #include "sigsegv.cpp"
706 gbeauche 1.21 ], [
707     sigsegv_recovery=sigcontext
708     ac_cv_have_sigcontext_hack=yes
709     ],
710     ac_cv_have_sigcontext_hack=no,
711 gbeauche 1.1 dnl When cross-compiling, do not assume anything.
712     ac_cv_have_sigcontext_hack=no
713     )
714     AC_LANG_RESTORE
715     ])
716     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
717     [Define if we know a hack to replace siginfo_t->si_addr member.])
718     fi
719    
720     dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
721     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
722     ac_cv_have_skip_instruction, [
723     AC_LANG_SAVE
724     AC_LANG_CPLUSPLUS
725     AC_TRY_RUN([
726     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
727     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
728     #include "vm_alloc.cpp"
729     #include "sigsegv.cpp"
730     ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
731     dnl When cross-compiling, do not assume anything.
732     ac_cv_have_skip_instruction=no
733     )
734     AC_LANG_RESTORE
735     ]
736     )
737     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
738     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
739    
740     dnl Can we do Video on SEGV Signals ?
741     CAN_VOSF=no
742 gbeauche 1.21 if [[ -n "$sigsegv_recovery" ]]; then
743 gbeauche 1.1 CAN_VOSF=yes
744     fi
745    
746     dnl Determine the addressing mode to use
747     if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
748     ADDRESSING_MODE="real"
749     else
750     ADDRESSING_MODE=""
751     AC_MSG_CHECKING([for the addressing mode to use])
752     for am in $ADDRESSING_TEST_ORDER; do
753     case $am in
754     real)
755     dnl Requires ability to mmap() Low Memory globals
756     if [[ "x$ac_cv_can_map_lm" = "xno" ]]; then
757     continue
758     fi
759     dnl Requires VOSF screen updates
760     if [[ "x$CAN_VOSF" = "xno" ]]; then
761     continue
762     fi
763     dnl Real addressing will probably work.
764     ADDRESSING_MODE="real"
765     WANT_VOSF=yes dnl we can use VOSF and we need it actually
766     DEFINES="$DEFINES -DREAL_ADDRESSING"
767     break
768     ;;
769     direct)
770     dnl Requires VOSF screen updates
771     if [[ "x$CAN_VOSF" = "xyes" ]]; then
772     ADDRESSING_MODE="direct"
773     WANT_VOSF=yes dnl we can use VOSF and we need it actually
774     DEFINES="$DEFINES -DDIRECT_ADDRESSING"
775     break
776     fi
777     ;;
778     banks)
779     dnl Default addressing mode
780     ADDRESSING_MODE="memory banks"
781     break
782     ;;
783     *)
784     AC_MSG_ERROR([Internal configure.in script error for $am addressing mode])
785     esac
786     done
787     AC_MSG_RESULT($ADDRESSING_MODE)
788     if [[ "x$ADDRESSING_MODE" = "x" ]]; then
789     AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER])
790     ADDRESSING_MODE="memory banks"
791     fi
792     fi
793    
794 gbeauche 1.5 dnl Banked Memory Addressing mode is not supported by the JIT compiler
795     if [[ "x$WANT_JIT" = "xyes" -a "x$ADDRESSING_MODE" = "xmemory banks" ]]; then
796     AC_MSG_ERROR([Sorry, the JIT Compiler requires Direct Addressing, at least])
797     fi
798    
799 gbeauche 1.1 dnl Enable VOSF screen updates with this feature is requested and feasible
800     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
801     AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
802     else
803     WANT_VOSF=no
804     fi
805    
806     dnl Check for GAS.
807     HAVE_GAS=no
808     AC_MSG_CHECKING(for GAS .p2align feature)
809     cat >conftest.S << EOF
810     .text
811     .p2align 5
812     EOF
813     if $CC conftest.S -c -o conftest.o >/dev/null 2>&1 ; then HAVE_GAS=yes; fi
814     AC_MSG_RESULT($HAVE_GAS)
815    
816     dnl Check for GCC 2.7 or higher.
817     HAVE_GCC27=no
818     AC_MSG_CHECKING(for GCC 2.7 or higher)
819 cebix 1.17 AC_EGREP_CPP(xyes,
820 gbeauche 1.1 [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
821 cebix 1.17 xyes
822 gbeauche 1.1 #endif
823     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
824    
825     dnl Check for GCC 3.0 or higher.
826     HAVE_GCC30=no
827     AC_MSG_CHECKING(for GCC 3.0 or higher)
828 cebix 1.17 AC_EGREP_CPP(xyes,
829 gbeauche 1.1 [#if __GNUC__ >= 3
830 cebix 1.17 xyes
831 gbeauche 1.1 #endif
832     ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
833    
834     dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher.
835     dnl Also set "-fno-exceptions" for C++ because exception handling requires
836     dnl the frame pointer.
837     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
838     CFLAGS="$CFLAGS -fomit-frame-pointer"
839     CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -fno-exceptions"
840     fi
841    
842     dnl (gb) Do not merge constants since it breaks fpu/fpu_x86.cpp.
843     dnl As of 2001/08/02, this affects the following compilers:
844     dnl Official: probably gcc-3.1 (mainline CVS)
845     dnl Mandrake: gcc-2.96 >= 0.59mdk, gcc-3.0.1 >= 0.1mdk
846     dnl Red Hat : gcc-2.96 >= 89, gcc-3.0 >= 1
847     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
848     SAVED_CXXFLAGS="$CXXFLAGS"
849     CXXFLAGS="$CXXFLAGS -fno-merge-constants"
850     AC_CACHE_CHECK([whether GCC supports constants merging], ac_cv_gcc_constants_merging, [
851     AC_LANG_SAVE
852     AC_LANG_CPLUSPLUS
853     AC_TRY_COMPILE([],[],[ac_cv_gcc_constants_merging=yes],[ac_cv_gcc_constants_merging=no])
854     AC_LANG_RESTORE
855     ])
856     if [[ "x$ac_cv_gcc_constants_merging" != "xyes" ]]; then
857     CXXFLAGS="$SAVED_CXXFLAGS"
858     fi
859     fi
860    
861     dnl Select appropriate CPU source and REGPARAM define.
862     ASM_OPTIMIZATIONS=none
863     CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
864 gbeauche 1.5
865     dnl (gb) JITSRCS will be emptied later if the JIT is not available
866     dnl Other platforms should define their own set of noflags file variants
867     CAN_JIT=no
868     JITSRCS="compemu1.cpp compemu2.cpp compemu3.cpp compemu4.cpp compemu5.cpp compemu6.cpp compemu7.cpp compemu8.cpp"
869    
870 gbeauche 1.11 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
871 gbeauche 1.1 dnl i386 CPU
872 gbeauche 1.7 DEFINES="$DEFINES -DUNALIGNED_PROFITABLE -DREGPARAM=\"__attribute__((regparm(3)))\""
873 gbeauche 1.1 if [[ "x$HAVE_GAS" = "xyes" ]]; then
874     ASM_OPTIMIZATIONS=i386
875 gbeauche 1.7 DEFINES="$DEFINES -DX86_ASSEMBLY -DOPTIMIZED_FLAGS -DSAHF_SETO_PROFITABLE"
876 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"
877 gbeauche 1.11 CAN_JIT=yes
878 gbeauche 1.13 fi
879     elif [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_X86_64" = "xyes" ]]; then
880     dnl x86-64 CPU
881     DEFINES="$DEFINES -DUNALIGNED_PROFITABLE"
882     if [[ "x$HAVE_GAS" = "xyes" ]]; then
883     ASM_OPTIMIZATIONS="x86-64"
884     DEFINES="$DEFINES -DX86_64_ASSEMBLY -DOPTIMIZED_FLAGS"
885 gbeauche 1.1 fi
886     elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
887     dnl SPARC CPU
888     case "$target_os" in
889     solaris*)
890     AC_MSG_CHECKING(SPARC CPU architecture)
891     SPARC_TYPE=`Solaris/which_sparc`
892     AC_MSG_RESULT($SPARC_TYPE)
893     case "$SPARC_TYPE" in
894     SPARC_V8)
895     ASM_OPTIMIZATIONS="SPARC V8 architecture"
896     DEFINES="$DEFINES -DSPARC_V8_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
897     CFLAGS="$CFLAGS -Wa,-Av8"
898     CXXFLAGS="$CXXFLAGS -Wa,-Av8"
899     ;;
900     SPARC_V9)
901     ASM_OPTIMIZATIONS="SPARC V9 architecture"
902     DEFINES="$DEFINES -DSPARC_V9_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
903     CFLAGS="$CFLAGS -Wa,-Av9"
904     CXXFLAGS="$CXXFLAGS -Wa,-Av9"
905     ;;
906     esac
907     ;;
908     esac
909     elif [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
910     dnl Native m68k, no emulation
911     CPUINCLUDES="-I../native_cpu"
912     CPUSRCS="asm_support.s"
913     fi
914    
915 gbeauche 1.5 dnl Enable JIT compiler, if possible.
916     if [[ "x$WANT_JIT" = "xyes" -a "x$CAN_JIT" ]]; then
917     JITSRCS="$JITSRCS ../uae_cpu/compiler/compemu_support.cpp ../uae_cpu/compiler/compemu_fpp.cpp compstbl.o cpustbl_nf.o"
918     DEFINES="$DEFINES -DUSE_JIT -DUSE_JIT_FPU"
919    
920     if [[ "x$WANT_JIT_DEBUG" = "xyes" ]]; then
921     if [[ "x$WANT_MON" = "xyes" ]]; then
922     DEFINES="$DEFINES -DJIT_DEBUG=1"
923     else
924     AC_MSG_WARN([cxmon not found, ignoring --enable-jit-debug])
925     WANT_JIT_DEBUG=no
926     fi
927     fi
928 gbeauche 1.8
929     dnl IEEE core is the only FPU emulator to use with the JIT compiler
930     case $FPE_CORE_TEST_ORDER in
931     ieee*) ;;
932     *) AC_MSG_WARN([Forcing use of the IEEE FPU core, as the JIT compiler supports only this one.]) ;;
933     esac
934     FPE_CORE_TEST_ORDER="ieee"
935 gbeauche 1.5 else
936     WANT_JIT=no
937     WANT_JIT_DEBUG=no
938     JITSRCS=""
939     fi
940    
941 gbeauche 1.1 dnl Utility macro used by next two tests.
942     dnl AC_EXAMINE_OBJECT(C source code,
943     dnl commands examining object file,
944     dnl [commands to run if compile failed]):
945     dnl
946     dnl Compile the source code to an object file; then convert it into a
947     dnl printable representation. All unprintable characters and
948     dnl asterisks (*) are replaced by dots (.). All white space is
949     dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
950     dnl output, but runs of newlines are compressed to a single newline.
951     dnl Finally, line breaks are forcibly inserted so that no line is
952     dnl longer than 80 columns and the file ends with a newline. The
953     dnl result of all this processing is in the file conftest.dmp, which
954     dnl may be examined by the commands in the second argument.
955     dnl
956     AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
957     [AC_LANG_SAVE
958     AC_LANG_C
959     dnl Next bit cribbed from AC_TRY_COMPILE.
960     cat > conftest.$ac_ext <<EOF
961     [#line __oline__ "configure"
962     #include "confdefs.h"
963     $1
964     ]EOF
965     if AC_TRY_EVAL(ac_compile); then
966     od -c conftest.o |
967     sed ['s/^[0-7]*[ ]*/ /
968     s/\*/./g
969     s/ \\n/*/g
970     s/ [0-9][0-9][0-9]/./g
971     s/ \\[^ ]/./g'] |
972     tr -d '
973     ' | tr -s '*' '
974     ' | fold | sed '$a\
975     ' > conftest.dmp
976     $2
977     ifelse($3, , , else
978     $3
979     )dnl
980     fi
981     rm -rf conftest*
982     AC_LANG_RESTORE])
983    
984     dnl Floating point format probe.
985     dnl The basic concept is the same as the above: grep the object
986     dnl file for an interesting string. We have to watch out for
987     dnl rounding changing the values in the object, however; this is
988     dnl handled by ignoring the least significant byte of the float.
989     dnl
990     dnl Does not know about VAX G-float or C4x idiosyncratic format.
991     dnl It does know about PDP-10 idiosyncratic format, but this is
992     dnl not presently supported by GCC. S/390 "binary floating point"
993     dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
994     dnl as ASCII?)
995     dnl
996     AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
997     [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
998     [gcc_AC_EXAMINE_OBJECT(
999     [/* This will not work unless sizeof(double) == 8. */
1000     extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1001    
1002     /* This structure must have no internal padding. */
1003     struct possibility {
1004     char prefix[8];
1005     double candidate;
1006     char postfix[8];
1007     };
1008    
1009     #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1010     struct possibility table [] =
1011     {
1012     C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1013     C( 3.53802595280598432000e+18), /* D__float - VAX */
1014     C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1015     C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1016     C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
1017     };],
1018     [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1019     ac_cv_c_float_format='IEEE (big-endian)'
1020     elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1021     ac_cv_c_float_format='IEEE (big-endian)'
1022     elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1023     ac_cv_c_float_format='IEEE (little-endian)'
1024     elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1025     ac_cv_c_float_format='IEEE (little-endian)'
1026     elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1027     ac_cv_c_float_format='VAX D-float'
1028     elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1029     ac_cv_c_float_format='PDP-10'
1030     elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1031     ac_cv_c_float_format='IBM 370 hex'
1032     else
1033     AC_MSG_ERROR(Unknown floating point format)
1034     fi],
1035     [AC_MSG_ERROR(compile failed)])
1036     ])
1037     # IEEE is the default format. If the float endianness isn't the same
1038     # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1039     # (which is a tristate: yes, no, default). This is only an issue with
1040     # IEEE; the other formats are only supported by a few machines each,
1041     # all with the same endianness.
1042     format=IEEE_FLOAT_FORMAT
1043     fbigend=
1044     case $ac_cv_c_float_format in
1045     'IEEE (big-endian)' )
1046     if test $ac_cv_c_bigendian = no; then
1047     fbigend=1
1048     fi
1049     ;;
1050     'IEEE (little-endian)' )
1051     if test $ac_cv_c_bigendian = yes; then
1052     fbigend=0
1053     fi
1054     ;;
1055     'VAX D-float' )
1056     format=VAX_FLOAT_FORMAT
1057     ;;
1058     'PDP-10' )
1059     format=PDP10_FLOAT_FORMAT
1060     ;;
1061     'IBM 370 hex' )
1062     format=IBM_FLOAT_FORMAT
1063     ;;
1064     esac
1065     AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1066     [Define to the floating point format of the host machine.])
1067     if test -n "$fbigend"; then
1068     AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1069     [Define to 1 if the host machine stores floating point numbers in
1070     memory with the word containing the sign bit at the lowest address,
1071     or to 0 if it does it the other way around.
1072    
1073     This macro should not be defined if the ordering is the same as for
1074     multi-word integers.])
1075     fi
1076     ])
1077    
1078     dnl Select appropriate FPU source.
1079     gcc_AC_C_FLOAT_FORMAT
1080     AC_CHECK_HEADERS(ieee754.h ieeefp.h floatingpoint.h nan.h)
1081    
1082     for fpe in $FPE_CORE_TEST_ORDER; do
1083     case $fpe in
1084     ieee)
1085 gbeauche 1.2 case $ac_cv_c_float_format in
1086     IEEE*)
1087 gbeauche 1.1 FPE_CORE="IEEE fpu core"
1088     DEFINES="$DEFINES -DFPU_IEEE"
1089     FPUSRCS="../uae_cpu/fpu/fpu_ieee.cpp"
1090 gbeauche 1.4 dnl Math functions not mandated by C99 standard
1091     AC_CHECK_FUNCS(isnanl isinfl)
1092     dnl Math functions required by C99 standard, but probably not
1093     dnl implemented everywhere. In that case, we fall back to the
1094     dnl regular variant for doubles.
1095     AC_CHECK_FUNCS(logl log10l expl powl fabsl sqrtl)
1096     AC_CHECK_FUNCS(sinl cosl tanl sinhl coshl tanhl)
1097     AC_CHECK_FUNCS(asinl acosl atanl asinhl acoshl atanhl)
1098     AC_CHECK_FUNCS(floorl ceill)
1099 gbeauche 1.1 break
1100 gbeauche 1.2 ;;
1101     esac
1102 gbeauche 1.1 ;;
1103     x86)
1104     if [[ ":$HAVE_GCC27:$HAVE_I386:$HAVE_GAS:" = ":yes:yes:yes:" ]]; then
1105     FPE_CORE="i387 fpu core"
1106     DEFINES="$DEFINES -DFPU_X86"
1107     FPUSRCS="../uae_cpu/fpu/fpu_x86.cpp"
1108     break
1109     fi
1110     ;;
1111     uae)
1112     FPE_CORE="uae fpu core"
1113     DEFINES="$DEFINES -DFPU_UAE"
1114     FPUSRCS="../uae_cpu/fpu/fpu_uae.cpp"
1115     break
1116     ;;
1117     *)
1118     AC_MSG_ERROR([Internal configure.in script error for $fpe fpu core])
1119     ;;
1120     esac
1121     done
1122     if [[ "x$FPE_CORE" = "x" ]]; then
1123     AC_MSG_ERROR([Sorry, no suitable FPU core found in $FPE_CORE_TEST_ORDER])
1124     fi
1125    
1126     dnl Check for certain math functions
1127     AC_CHECK_FUNCS(atanh)
1128 gbeauche 1.4 AC_CHECK_FUNCS(isnan isinf finite isnormal signbit)
1129 gbeauche 1.1
1130     dnl UAE CPU sources for all non-m68k-native architectures.
1131     if [[ "x$WANT_NATIVE_M68K" = "xno" ]]; then
1132     CPUINCLUDES="-I../uae_cpu"
1133 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"
1134 gbeauche 1.1 fi
1135    
1136     dnl Remove the "-g" option if set for GCC.
1137     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
1138     CFLAGS=`echo $CFLAGS | sed -e 's/-g//g'`
1139     CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g//g'`
1140     fi
1141    
1142 gbeauche 1.14 dnl Or if we have -IPA (MIPSPro compilers)
1143     if [[ "x$HAVE_IPA" = "xyes" ]]; then
1144     CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1145     CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1146 gbeauche 1.1 CXXFLAGS="-LANG:std $CXXFLAGS"
1147 gbeauche 1.14 LDFLAGS="$LDFLAGS -O3 -OPT:Olimit=0 -IPA"
1148 gbeauche 1.1 fi
1149    
1150     dnl Generate Makefile.
1151     AC_SUBST(DEFINES)
1152     AC_SUBST(SYSSRCS)
1153     AC_SUBST(CPUINCLUDES)
1154     AC_SUBST(CPUSRCS)
1155 cebix 1.16 AC_CONFIG_FILES([Makefile])
1156     AC_OUTPUT
1157 gbeauche 1.1
1158     dnl Print summary.
1159     echo
1160     echo Basilisk II configuration summary:
1161     echo
1162     echo XFree86 DGA support .................... : $WANT_XF86_DGA
1163     echo XFree86 VidMode support ................ : $WANT_XF86_VIDMODE
1164     echo fbdev DGA support ...................... : $WANT_FBDEV_DGA
1165     echo Enable video on SEGV signals ........... : $WANT_VOSF
1166     echo ESD sound support ...................... : $WANT_ESD
1167     echo GTK user interface ..................... : $WANT_GTK
1168     echo mon debugger support ................... : $WANT_MON
1169     echo Running m68k code natively ............. : $WANT_NATIVE_M68K
1170 gbeauche 1.5 echo Use JIT compiler ....................... : $WANT_JIT
1171     echo JIT debug mode ......................... : $WANT_JIT_DEBUG
1172 gbeauche 1.1 echo Floating-Point emulation core .......... : $FPE_CORE
1173     echo Assembly optimizations ................. : $ASM_OPTIMIZATIONS
1174     echo Addressing mode ........................ : $ADDRESSING_MODE
1175 gbeauche 1.21 echo Bad memory access recovery type ........ : $sigsegv_recovery
1176 gbeauche 1.1 echo
1177     echo "Configuration done. Now type \"make\" (or \"gmake\")."