ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.19
Committed: 2003-08-17T10:35:18Z (21 years, 3 months ago) by gbeauche
Branch: MAIN
Changes since 1.18: +4 -0 lines
Log Message:
Aliases for PACKAGE and VERSION used for localisation if compiling cxmon
now that we check for AM_GNU_GETTEXT. Yes, life sucks sometimes.

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