ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/configure.in
Revision: 1.24
Committed: 2007-06-15T17:11:46Z (17 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.23: +40 -271 lines
Log Message:
Enable universal builds with --enable-universal

Move arch-dependent definitions to config_macosx.h, i.e. make them compile
time instead of configure time. Support IEEE FPU emulation core only.

File Contents

# User Rev Content
1 nigel 1.10 dnl Mac OS X configuration driver
2 gbeauche 1.24 dnl $Id: configure.in,v 1.23 2007/06/15 10:11:28 gbeauche Exp $
3 nigel 1.1 dnl Process this file with autoconf to produce a configure script.
4     dnl Based on Unix/configure.in
5     dnl Written in 1999 by Christian Bauer et al.
6 nigel 1.17 dnl Occasionally re-synchronised (merged?) with latest version
7     dnl Written in 2002 by Christian Bauer et al.
8 nigel 1.1
9 nigel 1.11 dnl autoconf on 10.1 doesn't understand these
10     dnl AC_INIT([Basilisk II], 1.0, [Christian.Bauer@uni-mainz.de], BasiliskII)
11     dnl AC_CONFIG_SRCDIR(main_macosx.mm)
12 nigel 1.1 AC_INIT(main_macosx.mm)
13 gbeauche 1.22 AC_CONFIG_AUX_DIR(../Unix)
14 nigel 1.1 AC_PREREQ(2.12)
15     AC_CONFIG_HEADER(config.h)
16 gbeauche 1.24 AH_TOP([
17     /* Include MacOS X macros determined at compile-time */
18     #include "config_macosx.h"
19     ])
20 nigel 1.1
21 nigel 1.13 dnl Aliases for PACKAGE and VERSION macros.
22     AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE_NAME", [Define this program name.])
23     AC_DEFINE_UNQUOTED(VERSION, "$PACKAGE_VERSION", [Define this program version.])
24    
25     dnl Some systems do not put corefiles in the currect directory, avoid saving
26     dnl cores for the configure tests since some are intended to dump core.
27     ulimit -c 0
28    
29 gbeauche 1.24 dnl Universal binaries.
30     AC_ARG_ENABLE(universal,
31     [ --enable-universal enable universal binaries for selected arches [default=no]],
32     [ WANT_UNIVERSAL=""
33     for arch in $enableval; do
34     case $arch in
35     yes) WANT_UNIVERSAL="i386 ppc";;
36     ppc|ppc64|i386|x86_64) WANT_UNIVERSAL="$WANT_UNIVERSAL $arch";;
37     esac
38     done
39     ])
40    
41 nigel 1.5 dnl Video options.
42 nigel 1.1 AC_ARG_ENABLE(multiwin,
43 gbeauche 1.24 [ --enable-multiwin allow multiple emulator windows [default=no]], [ENABLE_MULTIPLE=$enableval], [ENABLE_MULTIPLE=no])
44 nigel 1.1
45 nigel 1.5 dnl JIT compiler options.
46     AC_ARG_ENABLE(jit-compiler, [ --enable-jit-compiler enable JIT compiler [default=no]], [WANT_JIT=$enableval], [WANT_JIT=no])
47     AC_ARG_ENABLE(jit-debug, [ --enable-jit-debug activate native code disassemblers [default=no]], [WANT_JIT_DEBUG=$enableval], [WANT_JIT_DEBUG=no])
48    
49 nigel 1.1 dnl Addressing modes.
50     AC_ARG_ENABLE(addressing,
51     [ --enable-addressing=AM specify the addressing mode to use [default=fastest]],
52     [ case "$enableval" in
53     real) ADDRESSING_TEST_ORDER="real";;
54     direct) ADDRESSING_TEST_ORDER="direct";;
55     banks) ADDRESSING_TEST_ORDER="banks";;
56     fastest)ADDRESSING_TEST_ORDER="direct banks";;
57     *) AC_MSG_ERROR([--enable-addressing takes only one of the following values: fastest, real, direct, banks]);;
58     esac
59     ],
60     [ ADDRESSING_TEST_ORDER="direct banks"
61     ])
62    
63     dnl External packages.
64     AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
65    
66     dnl Canonical system information.
67     AC_CANONICAL_HOST
68     AC_CANONICAL_TARGET
69    
70 nigel 1.14 dnl Target OS type (target is host if not cross-compiling).
71     case "$target_os" in
72     linux*) OS_TYPE=linux;;
73     netbsd*) OS_TYPE=netbsd;;
74     freebsd*) OS_TYPE=freebsd;;
75     solaris*) OS_TYPE=solaris;;
76     darwin*) OS_TYPE=darwin;;
77     *) OS_TYPE=`echo $target_os | sed -e 's/-/_/g' | sed -e 's/\./_/g'`;;
78     esac
79 nigel 1.1 DEFINES="$DEFINES -DOS_$OS_TYPE"
80    
81     dnl Target CPU type.
82     HAVE_I386=no
83     HAVE_M68K=no
84     HAVE_SPARC=no
85     HAVE_POWERPC=no
86 nigel 1.10 HAVE_X86_64=no
87 nigel 1.1 case "$target_cpu" in
88 nigel 1.10 i386* | i486* | i586* | i686* | i786* ) HAVE_I386=yes;;
89     m68k* ) HAVE_M68K=yes;;
90     sparc* ) HAVE_SPARC=yes;;
91     powerpc* ) HAVE_POWERPC=yes;;
92     x86_64* ) HAVE_X86_64=yes;;
93 nigel 1.1 esac
94    
95     dnl Checks for programs.
96     AC_PROG_CC
97     AC_PROG_CC_C_O
98     AC_PROG_CPP
99     AC_PROG_CXX
100     AC_PROG_MAKE_SET
101     AC_PROG_INSTALL
102 nigel 1.17 AC_PROG_EGREP
103 nigel 1.1
104     dnl We use mon if possible.
105     MONSRCS=
106     if [[ "x$WANT_MON" = "xyes" ]]; then
107     AC_MSG_CHECKING(for mon)
108     mon_srcdir=../../../mon/src
109     if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
110     AC_MSG_RESULT(yes)
111 nigel 1.5 AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".])
112 gbeauche 1.23 MONSRCS="$mon_srcdir/mon.cpp $mon_srcdir/mon_6502.cpp $mon_srcdir/mon_z80.cpp $mon_srcdir/mon_cmd.cpp $mon_srcdir/mon_disass.cpp $mon_srcdir/mon_ppc.cpp $mon_srcdir/mon_lowmem.cpp $mon_srcdir/disass/floatformat.c $mon_srcdir/disass/i386-dis.c $mon_srcdir/disass/m68k-dis.c $mon_srcdir/disass/m68k-opc.c $mon_srcdir/disass/mips-dis.c $mon_srcdir/disass/mips-opc.c $mon_srcdir/disass/mips16-opc.c"
113     AC_SUBST(MONSRCS)
114 nigel 1.1 CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
115 nigel 1.10 AC_CHECK_LIB(ncurses, tgetent, ,
116     AC_CHECK_LIB(termcap, tgetent, ,
117     AC_CHECK_LIB(termlib, tgetent, ,
118     AC_CHECK_LIB(terminfo, tgetent, ,
119     AC_CHECK_LIB(Hcurses, tgetent, ,
120     AC_CHECK_LIB(curses, tgetent))))))
121 nigel 1.1 AC_CHECK_LIB(readline, readline)
122     else
123     AC_MSG_RESULT(no)
124     AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
125     WANT_MON=no
126     fi
127     fi
128    
129 nigel 1.14 dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL.
130 nigel 1.1 HAVE_PTHREADS=yes
131 nigel 1.14 AC_CHECK_LIB(pthread, pthread_create, , [
132     AC_CHECK_LIB(c_r, pthread_create, , [
133     AC_CHECK_LIB(PTL, pthread_create, , [
134     HAVE_PTHREADS=no
135     ])
136     ])
137     ])
138     dnl OS X does have pthreads, but not in any of the above locations:
139     HAVE_PTHREADS=yes
140     if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
141     AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.])
142     fi
143 nigel 1.17 AC_CHECK_FUNCS(pthread_cond_init)
144     AC_CHECK_FUNCS(pthread_cancel pthread_testcancel)
145 nigel 1.3 AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
146     AC_CHECK_FUNCS(pthread_mutexattr_settype)
147 nigel 1.5 AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
148 nigel 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 nigel 1.5 dnl We want to enable multiple window support if possible
158 nigel 1.1 if [[ "x$WANT_MWIN" = "xyes" ]]; then
159     WANT_MWIN=yes
160     DEFINES="$DEFINES -DENABLE_MULTIPLE"
161     fi
162    
163 nigel 1.5 dnl We use 64-bit file size support if possible.
164     AC_SYS_LARGEFILE
165    
166 nigel 1.1 dnl Checks for header files.
167     AC_HEADER_STDC
168 nigel 1.17 AC_CHECK_HEADERS(stdlib.h stdint.h)
169 nigel 1.13 AC_CHECK_HEADERS(unistd.h fcntl.h sys/types.h sys/time.h sys/mman.h mach/mach.h)
170 nigel 1.12 AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
171 nigel 1.17 AC_CHECK_HEADERS(sys/socket.h sys/ioctl.h sys/filio.h sys/bitypes.h sys/wait.h)
172     AC_CHECK_HEADERS(sys/poll.h sys/select.h)
173     AC_CHECK_HEADERS(arpa/inet.h)
174     AC_CHECK_HEADERS(linux/if.h linux/if_tun.h net/if.h net/if_tun.h, [], [], [
175     #ifdef HAVE_SYS_TYPES_H
176     #include <sys/types.h>
177     #endif
178     #ifdef HAVE_SYS_SOCKET_H
179     #include <sys/socket.h>
180     #endif
181     ])
182     AC_CHECK_HEADERS(AvailabilityMacros.h)
183 gbeauche 1.16 AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDevice.h)
184 nigel 1.1
185     dnl Checks for typedefs, structures, and compiler characteristics.
186     AC_C_CONST
187     AC_C_INLINE
188 nigel 1.10 AC_TYPE_OFF_T
189 nigel 1.13 dnl These two symbols are not defined in 10.1's autoconf:
190 nigel 1.8 dnl AC_CHECK_TYPE(loff_t, off_t)
191     dnl AC_CHECK_TYPE(caddr_t, [char *])
192     dnl We define loff_t as a typedef of off_t in sysdeps.h if we don't have LOFF_T
193 nigel 1.13 dnl OS X does have caddr_t, but the above check doesn't work, so we have to do:
194     AC_DEFINE(HAVE_CADDR_T, 1, [The type "caddr_t" does exist on MacOS X.])
195 nigel 1.1 AC_TYPE_SIZE_T
196     AC_TYPE_SIGNAL
197     AC_HEADER_TIME
198     AC_STRUCT_TM
199    
200 nigel 1.5 dnl Check whether sys/socket.h defines type socklen_t.
201     dnl (extracted from ac-archive/Miscellaneous)
202     AC_CACHE_CHECK([for socklen_t],
203     ac_cv_type_socklen_t, [
204     AC_TRY_COMPILE([
205     #include <sys/types.h>
206     #include <sys/socket.h>
207     ], [socklen_t len = 42; return 0;],
208     ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no,
209     dnl When cross-compiling, do not assume anything.
210     ac_cv_type_socklen_t="guessing no"
211     )
212     ])
213     if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then
214     AC_DEFINE(socklen_t, int, [Define to 'int' if <sys/types.h> doesn't define.])
215     fi
216    
217 nigel 1.1 dnl Checks for library functions.
218 nigel 1.17 AC_CHECK_FUNCS(strdup strerror cfmakeraw)
219 nigel 1.1 AC_CHECK_FUNCS(clock_gettime timer_create)
220     AC_CHECK_FUNCS(sigaction signal)
221     AC_CHECK_FUNCS(mmap mprotect munmap)
222     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
223 nigel 1.17 AC_CHECK_FUNCS(poll inet_aton)
224 nigel 1.1
225     dnl Darwin seems to define mach_task_self() instead of task_self().
226     AC_CHECK_FUNCS(mach_task_self task_self)
227    
228 nigel 1.17 dnl Check for headers and functions related to pty support (sshpty.c)
229     dnl From openssh-3.2.2p1 configure.ac
230    
231     AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
232     AC_CHECK_FUNCS(_getpty vhangup strlcpy)
233     if test -z "$no_dev_ptmx" ; then
234     if test "x$disable_ptmx_check" != "xyes" ; then
235     AC_CHECK_FILE([/dev/ptmx],
236     [
237     AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.])
238     have_dev_ptmx=1
239     ]
240     )
241     fi
242     fi
243     AC_CHECK_FILE([/dev/ptc],
244     [
245     AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.])
246     have_dev_ptc=1
247     ]
248     )
249    
250     dnl (end of code from openssh-3.2.2p1 configure.ac)
251    
252    
253 nigel 1.19 dnl Check for systems where POSIX-style non-blocking I/O (O_NONBLOCK)
254     dnl doesn't work or is unimplemented. On these systems (mostly older
255     dnl ones), use the old BSD-style FIONBIO approach instead. [tcl.m4]
256     AC_CACHE_CHECK([FIONBIO vs. O_NONBLOCK for non-blocking I/O],
257     ac_cv_nonblocking_io, [
258     case "$host" in
259     *-*-osf*)
260     ac_cv_nonblocking_io=FIONBIO
261     ;;
262     *-*-sunos4*)
263     ac_cv_nonblocking_io=FIONBIO
264     ;;
265     *-*-ultrix*)
266     ac_cv_nonblocking_io=FIONBIO
267     ;;
268     *)
269     ac_cv_nonblocking_io=O_NONBLOCK
270     ;;
271     esac
272     ])
273     if [[ "$ac_cv_nonblocking_io" = "FIONBIO" ]]; then
274     AC_DEFINE(USE_FIONBIO, 1, [Define if BSD-style non-blocking I/O is to be used])
275     fi
276    
277     dnl Check whether compiler supports byte bit-fields
278     AC_CACHE_CHECK([whether compiler supports byte bit-fields],
279     ac_cv_have_byte_bitfields, [
280     AC_LANG_SAVE
281     AC_LANG_CPLUSPLUS
282     AC_TRY_RUN([
283     struct A {
284     unsigned char b1:4;
285     unsigned char b2:4;
286     unsigned char c;
287     unsigned short s;
288     unsigned char a[4];
289     };
290    
291     int main(void) {
292     A a;
293     return ! (sizeof(A) == 8 && &a.c == ((unsigned char *)&a + 1));
294     }],
295     [ac_cv_have_byte_bitfields=yes],
296     [ac_cv_have_byte_bitfields=no],
297     dnl When cross-compiling, assume only GCC supports this
298     [if [[ "$GCC" = "yes" ]]; then
299     ac_cv_have_byte_bitfields="guessing yes"
300     else
301     ac_cv_have_byte_bitfields="guessing no"
302     fi]
303     )
304     AC_LANG_RESTORE
305     ])
306    
307 nigel 1.17 dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
308     AC_DEFUN([AC_CHECK_FRAMEWORK], [
309     AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
310     AC_CACHE_CHECK([whether compiler supports framework $1],
311     ac_Framework, [
312     saved_LIBS="$LIBS"
313     LIBS="$LIBS -framework $1"
314     AC_TRY_LINK(
315 nigel 1.20 [$2], [],
316 nigel 1.17 [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
317     )
318     ])
319     AS_IF([test AS_VAR_GET(ac_Framework) = yes],
320     [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
321     )
322     AS_VAR_POPDEF([ac_Framework])dnl
323     ])
324    
325     dnl Check for some MacOS X frameworks
326 nigel 1.20 AC_CHECK_FRAMEWORK(AppKit, [])
327 nigel 1.17 AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
328     AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
329     AC_CHECK_FRAMEWORK(CoreFoundation, [#include <CoreFoundation/CoreFoundation.h>])
330 gbeauche 1.22 AC_CHECK_FRAMEWORK(CoreAudio, [#include <CoreAudio/CoreAudio.h>])
331     AC_CHECK_FRAMEWORK(AudioUnit, [#include <AudioUnit/AudioUnit.h>])
332     AC_CHECK_FRAMEWORK(AudioToolbox, [#include <AudioToolbox/AudioToolbox.h>])
333 nigel 1.17
334 nigel 1.1 dnl Select system-dependant source files.
335 nigel 1.17 ETHERSRC=ether_unix.cpp
336 nigel 1.13 DEFINES="$DEFINES -DBSD_COMP"
337     CXXFLAGS="$CXXFLAGS -fpermissive"
338 nigel 1.1 dnl Check for the CAM library
339 nigel 1.5 AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no)
340 nigel 1.1 if [[ "x$HAVE_LIBCAM" = "xno" ]]; then
341     AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.])
342 nigel 1.5 else
343     dnl Check for the sys kernel includes
344 nigel 1.1 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 nigel 1.17 dnl Is the slirp library supported?
357 gbeauche 1.23 WANT_SLIRP=no
358 nigel 1.19 case "$ac_cv_have_byte_bitfields" in
359     yes|"guessing yes")
360 gbeauche 1.23 WANT_SLIRP=yes
361 nigel 1.19 ETHERSRC=ether_unix.cpp
362     ;;
363     esac
364 gbeauche 1.23 if [[ "x$WANT_SLIRP" = "xyes" ]]; then
365 nigel 1.17 AC_DEFINE(HAVE_SLIRP, 1, [Define if slirp library is supported])
366     SLIRP_SRCS="\
367     ../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \
368     ../slirp/cksum.c ../slirp/mbuf.c ../slirp/tcp_output.c \
369     ../slirp/debug.c ../slirp/misc.c ../slirp/tcp_subr.c \
370     ../slirp/if.c ../slirp/sbuf.c ../slirp/tcp_timer.c \
371     ../slirp/ip_icmp.c ../slirp/slirp.c ../slirp/tftp.c \
372     ../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c"
373     fi
374 gbeauche 1.23 AC_SUBST(WANT_SLIRP)
375 nigel 1.17 AC_SUBST(SLIRP_SRCS)
376    
377 nigel 1.1
378     dnl Define a macro that translates a yesno-variable into a C macro definition
379     dnl to be put into the config.h file
380     dnl $1 -- the macro to define
381     dnl $2 -- the value to translate
382 nigel 1.5 dnl $3 -- template name
383 nigel 1.17 AC_DEFUN([AC_TRANSLATE_DEFINE], [
384 nigel 1.1 if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
385 nigel 1.5 AC_DEFINE($1, 1, $3)
386 nigel 1.1 fi
387     ])
388    
389 nigel 1.17 dnl Check that the host supports TUN/TAP devices
390     AC_CACHE_CHECK([whether TUN/TAP is supported],
391     ac_cv_tun_tap_support, [
392     AC_TRY_COMPILE([
393     #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
394     #include <linux/if.h>
395     #include <linux/if_tun.h>
396     #endif
397     #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
398     #include <net/if.h>
399     #include <net/if_tun.h>
400     #endif
401     ], [
402     struct ifreq ifr;
403     memset(&ifr, 0, sizeof(ifr));
404     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
405     ],
406     ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
407     )
408     ])
409     AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
410     [Define if your system supports TUN/TAP devices.])
411    
412 nigel 1.1 dnl Various checks if the system supports vm_allocate() and the like functions.
413     have_mach_vm=no
414     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
415     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
416     have_mach_vm=yes
417     fi
418 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
419     [Define if your system has a working vm_allocate()-based memory allocator.])
420 nigel 1.1
421     dnl Check that vm_allocate(), vm_protect() work
422     if [[ "x$have_mach_vm" = "xyes" ]]; then
423    
424 nigel 1.5 AC_CACHE_CHECK([whether vm_protect works],
425 nigel 1.1 ac_cv_vm_protect_works, [
426     AC_LANG_SAVE
427     AC_LANG_CPLUSPLUS
428     ac_cv_vm_protect_works=yes
429     dnl First the tests that should segfault
430     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
431     AC_TRY_RUN([
432     #define CONFIGURE_TEST_VM_MAP
433     #define TEST_VM_PROT_$test_def
434 nigel 1.6 #include "../Unix/vm_alloc.cpp"
435 nigel 1.1 ], ac_cv_vm_protect_works=no, rm -f core,
436     dnl When cross-compiling, do not assume anything
437     ac_cv_vm_protect_works="guessing no"
438     )
439     done
440     AC_TRY_RUN([
441     #define CONFIGURE_TEST_VM_MAP
442     #define TEST_VM_PROT_RDWR_WRITE
443 nigel 1.6 #include "../Unix/vm_alloc.cpp"
444 nigel 1.1 ], , ac_cv_vm_protect_works=no,
445     dnl When cross-compiling, do not assume anything
446     ac_cv_vm_protect_works="guessing no"
447     )
448     AC_LANG_RESTORE
449     ]
450     )
451    
452     dnl Remove support for vm_allocate() if vm_protect() does not work
453     if [[ "x$have_mach_vm" = "xyes" ]]; then
454     case $ac_cv_vm_protect_works in
455     *yes) have_mach_vm=yes;;
456     *no) have_mach_vm=no;;
457     esac
458     fi
459 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
460     [Define if your system has a working vm_allocate()-based memory allocator.])
461 nigel 1.1
462     fi dnl HAVE_MACH_VM
463    
464     dnl Various checks if the system supports mmap() and the like functions.
465     dnl ... and Mach memory allocators are not supported
466     have_mmap_vm=no
467     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
468     "x$ac_cv_func_mprotect" = "xyes" ]]; then
469     if [[ "x$have_mach_vm" = "xno" ]]; then
470     have_mmap_vm=yes
471     fi
472     fi
473 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
474     [Define if your system has a working mmap()-based memory allocator.])
475 nigel 1.1
476     dnl Check that mmap() and associated functions work.
477     if [[ "x$have_mmap_vm" = "xyes" ]]; then
478    
479     dnl Check if we have a working anonymous mmap()
480 nigel 1.5 AC_CACHE_CHECK([whether mmap supports MAP_ANON],
481 nigel 1.1 ac_cv_mmap_anon, [
482     AC_LANG_SAVE
483     AC_LANG_CPLUSPLUS
484     AC_TRY_RUN([
485     #define HAVE_MMAP_ANON
486     #define CONFIGURE_TEST_VM_MAP
487     #define TEST_VM_MMAP_ANON
488 nigel 1.6 #include "../Unix/vm_alloc.cpp"
489 nigel 1.1 ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
490     dnl When cross-compiling, do not assume anything.
491     ac_cv_mmap_anon="guessing no"
492     )
493     AC_LANG_RESTORE
494     ]
495     )
496 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
497     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
498 nigel 1.1
499 nigel 1.5 AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
500 nigel 1.1 ac_cv_mmap_anonymous, [
501     AC_LANG_SAVE
502     AC_LANG_CPLUSPLUS
503     AC_TRY_RUN([
504     #define HAVE_MMAP_ANONYMOUS
505     #define CONFIGURE_TEST_VM_MAP
506     #define TEST_VM_MMAP_ANON
507 nigel 1.6 #include "../Unix/vm_alloc.cpp"
508 nigel 1.1 ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
509     dnl When cross-compiling, do not assume anything.
510     ac_cv_mmap_anonymous="guessing no"
511     )
512     AC_LANG_RESTORE
513     ]
514     )
515 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
516     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
517 nigel 1.1
518 nigel 1.5 AC_CACHE_CHECK([whether mprotect works],
519 nigel 1.1 ac_cv_mprotect_works, [
520     AC_LANG_SAVE
521     AC_LANG_CPLUSPLUS
522     ac_cv_mprotect_works=yes
523     dnl First the tests that should segfault
524     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
525     AC_TRY_RUN([
526     #define CONFIGURE_TEST_VM_MAP
527     #define TEST_VM_PROT_$test_def
528 nigel 1.6 #include "../Unix/vm_alloc.cpp"
529 nigel 1.1 ], ac_cv_mprotect_works=no, rm -f core,
530     dnl When cross-compiling, do not assume anything
531     ac_cv_mprotect_works="guessing no"
532     )
533     done
534     AC_TRY_RUN([
535     #define CONFIGURE_TEST_VM_MAP
536     #define TEST_VM_PROT_RDWR_WRITE
537 nigel 1.6 #include "../Unix/vm_alloc.cpp"
538 nigel 1.1 ], , ac_cv_mprotect_works=no,
539     dnl When cross-compiling, do not assume anything
540     ac_cv_mprotect_works="guessing no"
541     )
542     AC_LANG_RESTORE
543     ]
544     )
545    
546     dnl Remove support for mmap() if mprotect() does not work
547     if [[ "x$have_mmap_vm" = "xyes" ]]; then
548     case $ac_cv_mprotect_works in
549     *yes) have_mmap_vm=yes;;
550     *no) have_mmap_vm=no;;
551     esac
552     fi
553 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
554     [Define if your system has a working mmap()-based memory allocator.])
555 nigel 1.1
556     fi dnl HAVE_MMAP_VM
557    
558 nigel 1.12 dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
559     AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x2000],
560     ac_cv_pagezero_hack, [
561     ac_cv_pagezero_hack=no
562     if AC_TRY_COMMAND([Darwin/testlmem.sh 0x2000]); then
563     ac_cv_pagezero_hack=yes
564     dnl might as well skip the test for mmap-able low memory
565     ac_cv_can_map_lm=no
566     fi
567     ])
568     AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
569     [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
570    
571 nigel 1.1 dnl Check if we can mmap 0x2000 bytes from 0x0000
572 nigel 1.5 AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x2000],
573 nigel 1.1 ac_cv_can_map_lm, [
574     AC_LANG_SAVE
575     AC_LANG_CPLUSPLUS
576     AC_TRY_RUN([
577 nigel 1.6 #include "../Unix/vm_alloc.cpp"
578 nigel 1.1 int main(void) { /* returns 0 if we could map the lowmem globals */
579 nigel 1.11 volatile char * lm = 0;
580 nigel 1.1 if (vm_init() < 0) exit(1);
581 nigel 1.12 if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
582 nigel 1.1 lm[0] = 'z';
583     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
584     vm_exit(); exit(0);
585     }
586     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
587     dnl When cross-compiling, do not assume anything.
588     ac_cv_can_map_lm="guessing no"
589     )
590     AC_LANG_RESTORE
591     ]
592     )
593    
594     dnl Check signal handlers need to be reinstalled
595 nigel 1.5 AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
596 nigel 1.1 ac_cv_signal_need_reinstall, [
597     AC_LANG_SAVE
598     AC_LANG_CPLUSPLUS
599     AC_TRY_RUN([
600     #include <stdlib.h>
601     #ifdef HAVE_UNISTD_H
602     #include <unistd.h>
603     #endif
604     #include <signal.h>
605     static int handled_signal = 0;
606     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
607     int main(void) { /* returns 0 if signals need not to be reinstalled */
608     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
609     exit(handled_signal == 2);
610     }
611     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
612     dnl When cross-compiling, do not assume anything.
613     ac_cv_signal_need_reinstall="guessing yes"
614     )
615     AC_LANG_RESTORE
616     ]
617     )
618 nigel 1.5 AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
619     [Define if your system requires signals to be reinstalled.])
620 nigel 1.1
621     dnl Check if sigaction handlers need to be reinstalled
622 nigel 1.5 AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
623 nigel 1.1 ac_cv_sigaction_need_reinstall, [
624     AC_LANG_SAVE
625     AC_LANG_CPLUSPLUS
626     AC_TRY_RUN([
627     #include <stdlib.h>
628     #ifdef HAVE_UNISTD_H
629     #include <unistd.h>
630     #endif
631     #include <signal.h>
632     static int handled_signal = 0;
633     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
634     typedef RETSIGTYPE (*signal_handler)(int);
635     static signal_handler mysignal(int sig, signal_handler handler) {
636     struct sigaction old_sa;
637     struct sigaction new_sa;
638     new_sa.sa_handler = handler;
639     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
640     }
641     int main(void) { /* returns 0 if signals need not to be reinstalled */
642     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
643     exit(handled_signal == 2);
644     }
645     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
646     dnl When cross-compiling, do not assume anything.
647     ac_cv_sigaction_need_reinstall="guessing yes"
648     )
649     AC_LANG_RESTORE
650     ]
651     )
652 nigel 1.5 AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
653     [Define if your system requires sigactions to be reinstalled.])
654 nigel 1.1
655 nigel 1.12 dnl Check if Mach exceptions supported.
656     AC_CACHE_CHECK([whether your system supports Mach exceptions],
657     ac_cv_have_mach_exceptions, [
658 nigel 1.1 AC_LANG_SAVE
659     AC_LANG_CPLUSPLUS
660     AC_TRY_RUN([
661 nigel 1.12 #define HAVE_MACH_EXCEPTIONS 1
662 nigel 1.1 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
663 nigel 1.13 #include "../Unix/vm_alloc.cpp"
664     #include "../Unix/sigsegv.cpp"
665 nigel 1.12 ], [
666     sigsegv_recovery=mach
667     ac_cv_have_mach_exceptions=yes
668     ],
669     ac_cv_have_mach_exceptions=no,
670 nigel 1.1 dnl When cross-compiling, do not assume anything.
671 nigel 1.12 ac_cv_have_mach_exceptions=no
672 nigel 1.1 )
673     AC_LANG_RESTORE
674     ]
675     )
676 nigel 1.12 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
677     [Define if your system supports Mach exceptions.])
678    
679     dnl Otherwise, check if extended signals are supported.
680     if [[ -z "$sigsegv_recovery" ]]; then
681     AC_CACHE_CHECK([whether your system supports extended signal handlers],
682     ac_cv_have_extended_signals, [
683     AC_LANG_SAVE
684     AC_LANG_CPLUSPLUS
685     AC_TRY_RUN([
686     #define HAVE_SIGINFO_T 1
687     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
688     #include "../Unix/vm_alloc.cpp"
689     #include "../Unix/sigsegv.cpp"
690     ], [
691     sigsegv_recovery=siginfo
692     ac_cv_have_extended_signals=yes
693     ],
694     ac_cv_have_extended_signals=no,
695     dnl When cross-compiling, do not assume anything.
696     ac_cv_have_extended_signals=no
697     )
698     AC_LANG_RESTORE
699     ]
700     )
701     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
702     [Define if your system support extended signals.])
703     fi
704 nigel 1.5
705 nigel 1.1 dnl Otherwise, check for subterfuges.
706 nigel 1.14 if [[ -z "$sigsegv_recovery" ]]; then
707 nigel 1.13 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
708     ac_cv_have_sigcontext_hack, [
709     AC_LANG_SAVE
710     AC_LANG_CPLUSPLUS
711 nigel 1.14 AC_TRY_RUN([
712 nigel 1.13 #define HAVE_SIGCONTEXT_SUBTERFUGE 1
713     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
714     #include "../Unix/vm_alloc.cpp"
715     #include "../Unix/sigsegv.cpp"
716     ], [
717     sigsegv_recovery=sigcontext
718     ac_cv_have_sigcontext_hack=yes
719     ],
720     ac_cv_have_sigcontext_hack=no,
721     dnl When cross-compiling, do not assume anything.
722     ac_cv_have_sigcontext_hack=no
723     )
724     AC_LANG_RESTORE
725     ])
726     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
727     [Define if we know a hack to replace siginfo_t->si_addr member.])
728     fi
729 nigel 1.1
730 nigel 1.5 dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
731     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
732     ac_cv_have_skip_instruction, [
733     AC_LANG_SAVE
734     AC_LANG_CPLUSPLUS
735     AC_TRY_RUN([
736     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
737     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
738 nigel 1.6 #include "../Unix/vm_alloc.cpp"
739     #include "../Unix/sigsegv.cpp"
740 nigel 1.5 ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
741     dnl When cross-compiling, do not assume anything.
742     ac_cv_have_skip_instruction=no
743     )
744     AC_LANG_RESTORE
745     ]
746     )
747     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
748     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
749    
750 nigel 1.1 dnl Can we do Video on SEGV Signals ?
751     CAN_VOSF=no
752 nigel 1.12 if [[ -n "$sigsegv_recovery" ]]; then
753 nigel 1.1 CAN_VOSF=yes
754     fi
755    
756 nigel 1.12 dnl A dummy program that returns always true
757 nigel 1.17 AC_PATH_PROG([BLESS], "true")
758 nigel 1.12
759 nigel 1.19 dnl Check for linker script support
760     case $target_os:$target_cpu in
761     linux*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
762     linux*:x86_64) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-x86_64.ld";;
763 nigel 1.20 linux*:powerpc) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-ppc.ld";;
764     netbsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
765     freebsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/freebsd-i386.ld";;
766     darwin*:*) LINKER_SCRIPT_FLAGS="-Wl,-seg1addr,0x78048000";;
767 nigel 1.19 esac
768     if [[ -n "$LINKER_SCRIPT_FLAGS" ]]; then
769     AC_CACHE_CHECK([whether linker script is usable],
770     ac_cv_linker_script_works, [
771     AC_LANG_SAVE
772     AC_LANG_CPLUSPLUS
773     saved_LDFLAGS="$LDFLAGS"
774     LDFLAGS="$LDFLAGS $LINKER_SCRIPT_FLAGS"
775     AC_TRY_RUN(
776     [int main() {if ((char *)&main < (char *)0x70000000) return 1;}],
777     [ac_cv_linker_script_works=yes],
778     [ac_cv_linker_script_works=no],
779     dnl When cross-compiling, assume it works
780     [ac_cv_linker_script_works="guessing yes"]
781     )
782     AC_LANG_RESTORE
783     if [[ "$ac_cv_linker_script_works" = "no" ]]; then
784     LDFLAGS="$saved_LDFLAGS"
785     LINKER_SCRIPT_FLAGS=""
786     fi
787     ])
788     fi
789     AC_TRANSLATE_DEFINE(HAVE_LINKER_SCRIPT, "$ac_cv_linker_script_works",
790     [Define if there is a linker script to relocate the executable above 0x70000000.])
791    
792 nigel 1.1 dnl Determine the addressing mode to use
793 gbeauche 1.23 ADDRESSING_MODE=""
794     AC_MSG_CHECKING([for the addressing mode to use])
795 nigel 1.1 for am in $ADDRESSING_TEST_ORDER; do
796     case $am in
797     real)
798     dnl Requires ability to mmap() Low Memory globals
799 nigel 1.12 if [[ "x$ac_cv_can_map_lm$ac_cv_pagezero_hack" = "xnono" ]]; then
800 nigel 1.1 continue
801     fi
802 nigel 1.12 dnl Requires VOSF screen updates
803 nigel 1.1 if [[ "x$CAN_VOSF" = "xno" ]]; then
804     continue
805     fi
806     dnl Real addressing will probably work.
807     ADDRESSING_MODE="real"
808     WANT_VOSF=yes dnl we can use VOSF and we need it actually
809     DEFINES="$DEFINES -DREAL_ADDRESSING"
810 nigel 1.13 AC_DEFINE(REAL_ADDRESSING, 1, [Emulated memory is memory mapped to actual address.])
811 nigel 1.12 if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
812     BLESS=Darwin/lowmem
813     LDFLAGS="$LDFLAGS -pagezero_size 0x2000"
814     fi
815 nigel 1.1 break
816     ;;
817     direct)
818     dnl Requires VOSF screen updates
819     if [[ "x$CAN_VOSF" = "xyes" ]]; then
820     ADDRESSING_MODE="direct"
821     WANT_VOSF=yes dnl we can use VOSF and we need it actually
822     DEFINES="$DEFINES -DDIRECT_ADDRESSING"
823 nigel 1.13 AC_DEFINE(DIRECT_ADDRESSING, 1, [Emulated memory is an offset from actual address.])
824 nigel 1.1 break
825     fi
826     ;;
827     banks)
828     dnl Default addressing mode
829     ADDRESSING_MODE="memory banks"
830     break
831     ;;
832     *)
833     AC_MSG_ERROR([Internal configure.in script error for $am addressing mode])
834     esac
835     done
836 gbeauche 1.23 AC_MSG_RESULT($ADDRESSING_MODE)
837     if [[ "x$ADDRESSING_MODE" = "x" ]]; then
838     AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER])
839     ADDRESSING_MODE="memory banks"
840 nigel 1.1 fi
841    
842 nigel 1.5 dnl Banked Memory Addressing mode is not supported by the JIT compiler
843     if [[ "x$WANT_JIT" = "xyes" -a "x$ADDRESSING_MODE" = "xmemory banks" ]]; then
844     AC_MSG_ERROR([Sorry, the JIT Compiler requires Direct Addressing, at least])
845     fi
846    
847 nigel 1.1 dnl Enable VOSF screen updates with this feature is requested and feasible
848     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
849 nigel 1.5 AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
850 nigel 1.1 else
851     WANT_VOSF=no
852     fi
853    
854     dnl Check for GAS.
855     HAVE_GAS=no
856     AC_MSG_CHECKING(for GAS .p2align feature)
857     cat >conftest.S << EOF
858     .text
859     .p2align 5
860     EOF
861     if $CC conftest.S -c -o conftest.o >/dev/null 2>&1 ; then HAVE_GAS=yes; fi
862     AC_MSG_RESULT($HAVE_GAS)
863    
864     dnl Check for GCC 2.7 or higher.
865     HAVE_GCC27=no
866     AC_MSG_CHECKING(for GCC 2.7 or higher)
867 nigel 1.17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5)
868     # error gcc < 2.7
869     #endif
870     ]])],
871     [AC_MSG_RESULT(yes); HAVE_GCC27=yes],
872     [AC_MSG_RESULT(no)])
873 nigel 1.1
874     dnl Check for GCC 3.0 or higher.
875     HAVE_GCC30=no
876     AC_MSG_CHECKING(for GCC 3.0 or higher)
877 nigel 1.17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ >= 3)
878     # error gcc < 3
879     #endif
880     ]])],
881     [AC_MSG_RESULT(yes); HAVE_GCC30=yes],
882     [AC_MSG_RESULT(no)])
883    
884     dnl Check for ICC.
885     AC_MSG_CHECKING(for ICC)
886     HAVE_ICC=no
887     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
888     HAVE_ICC=yes
889     fi
890     AC_MSG_RESULT($HAVE_ICC)
891 nigel 1.1
892     dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher.
893 nigel 1.3 dnl Also set "-fno-exceptions" for C++ because exception handling requires
894     dnl the frame pointer.
895 nigel 1.1 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
896     CFLAGS="$CFLAGS -fomit-frame-pointer"
897 nigel 1.3 CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -fno-exceptions"
898 nigel 1.1 fi
899    
900     dnl (gb) Do not merge constants since it breaks fpu/fpu_x86.cpp.
901     dnl As of 2001/08/02, this affects the following compilers:
902     dnl Official: probably gcc-3.1 (mainline CVS)
903     dnl Mandrake: gcc-2.96 >= 0.59mdk, gcc-3.0.1 >= 0.1mdk
904     dnl Red Hat : gcc-2.96 >= 89, gcc-3.0 >= 1
905 nigel 1.17 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
906 nigel 1.1 SAVED_CXXFLAGS="$CXXFLAGS"
907     CXXFLAGS="$CXXFLAGS -fno-merge-constants"
908     AC_CACHE_CHECK([whether GCC supports constants merging], ac_cv_gcc_constants_merging, [
909     AC_LANG_SAVE
910     AC_LANG_CPLUSPLUS
911     AC_TRY_COMPILE([],[],[ac_cv_gcc_constants_merging=yes],[ac_cv_gcc_constants_merging=no])
912     AC_LANG_RESTORE
913     ])
914     if [[ "x$ac_cv_gcc_constants_merging" != "xyes" ]]; then
915     CXXFLAGS="$SAVED_CXXFLAGS"
916     fi
917     fi
918    
919 nigel 1.17 dnl Store motion was introduced in 3.3-hammer branch and any gcc >= 3.4
920     dnl However, there are some corner cases exposed on x86-64
921     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
922     SAVED_CXXFLAGS="$CXXFLAGS"
923     CXXFLAGS="$CXXFLAGS -fno-gcse-sm"
924     AC_CACHE_CHECK([whether GCC supports store motion], ac_cv_gcc_store_motion, [
925     AC_LANG_SAVE
926     AC_LANG_CPLUSPLUS
927     AC_TRY_COMPILE([],[],[ac_cv_gcc_store_motion=yes],[ac_cv_gcc_store_motion=no])
928     AC_LANG_RESTORE
929     ])
930     if [[ "x$ac_cv_gcc_store_motion" != "xyes" ]]; then
931     CXXFLAGS="$SAVED_CXXFLAGS"
932     fi
933     fi
934    
935     dnl Add -fno-strict-aliasing for slirp sources
936     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
937     SAVED_CFLAGS="$CFLAGS"
938     CFLAGS="$CFLAGS -fno-strict-aliasing"
939     AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
940     ac_cv_gcc_no_strict_aliasing, [
941     AC_TRY_COMPILE([],[],
942     [ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
943     [ac_cv_gcc_no_strict_aliasing=no])
944     ])
945     CFLAGS="$SAVED_CFLAGS"
946     fi
947    
948 nigel 1.18 dnl Add -mdynamic-no-pic for MacOS X (XXX icc10 will support MacOS X)
949     if [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
950 nigel 1.17 SAVED_CFLAGS="$CFLAGS"
951     CFLAGS="$CFLAGS -mdynamic-no-pic"
952     AC_CACHE_CHECK([whether the compiler supports -mdynamic-no-pic],
953     ac_cv_gcc_mdynamic_no_pic, [
954     AC_TRY_COMPILE([],[],[ac_cv_gcc_mdynamic_no_pic=yes],[ac_cv_gcc_mdynamic_no_pic=no])
955     ])
956     if [[ "x$ac_cv_gcc_mdynamic_no_pic" = "xyes" ]]; then
957     CXXFLAGS="$CXXFLAGS -mdynamic-no-pic"
958     else
959     CFLAGS="$SAVED_CFLAGS"
960     fi
961     fi
962    
963 gbeauche 1.24 dnl Make sure we can enable JIT debug mode.
964     if [[ "x$WANT_JIT_DEBUG" = "xyes" ]]; then
965     if [[ ":$WANT_JIT:$WANT_MON:" != ":yes:yes:" ]]; then
966     AC_MSG_WARN([cxmon not found, ignoring --enable-jit-debug])
967     WANT_JIT_DEBUG=no
968 nigel 1.5 fi
969 nigel 1.1 fi
970    
971 gbeauche 1.24 dnl Additionnal checks for the IEEE FPU emulation code.
972 nigel 1.5 AC_CHECK_HEADERS(ieee754.h ieeefp.h floatingpoint.h nan.h)
973 nigel 1.1 AC_CHECK_FUNCS(atanh)
974 nigel 1.5 AC_CHECK_FUNCS(isnan isinf finite isnormal signbit)
975 gbeauche 1.24 dnl Math functions not mandated by C99 standard
976     AC_CHECK_FUNCS(isnanl isinfl)
977     dnl Math functions required by C99 standard, but probably not
978     dnl implemented everywhere. In that case, we fall back to the
979     dnl regular variant for doubles.
980     AC_CHECK_FUNCS(logl log10l expl powl fabsl sqrtl)
981     AC_CHECK_FUNCS(sinl cosl tanl sinhl coshl tanhl)
982     AC_CHECK_FUNCS(asinl acosl atanl asinhl acoshl atanhl)
983     AC_CHECK_FUNCS(floorl ceill)
984 nigel 1.1
985     dnl Remove the "-g" option if set for GCC.
986     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
987 nigel 1.17 CFLAGS=`echo $CFLAGS | sed -e 's/-g\b//g'`
988     CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g\b//g'`
989 nigel 1.1 fi
990    
991 nigel 1.14 dnl
992     dnl Some Mac OS X specific stuff:
993     dnl
994    
995     dnl MacOS 10.2 (and later?) have a particular header for defining the OS version
996     if [[ "x$ac_cv_header_AvailabilityMacros_h" = "xyes" ]]; then
997     AC_DEFINE(AVAILABILITYMACROS, 1, [Header specific to 10.2 and later.])
998     fi
999    
1000     dnl Which IDE do we use?
1001 nigel 1.15 if test -d "/Developer/Applications/Xcode.app"; then
1002 nigel 1.14 IDE=xcodebuild
1003     PROJECT=BasiliskII.xcode
1004     IDEARGS="-project BasiliskII.xcode"
1005     else
1006     IDE=pbxbuild
1007     PROJECT=BasiliskII.pbproj
1008     IDEARGS=""
1009     fi
1010    
1011 gbeauche 1.24 dnl Universal binaries
1012     if [[ -z "$WANT_UNIVERSAL" ]]; then
1013     WANT_UNIVERSAL=`echo $target_cpu | sed -e 's/i.86/i386/'`
1014     fi
1015     AC_SUBST(TARGET_ARCHES, [$WANT_UNIVERSAL])
1016    
1017 nigel 1.17 AC_DEFINE(DATADIR, "~", [unix_ether needs this!])
1018    
1019 nigel 1.1 dnl Generate Makefile.
1020     AC_SUBST(DEFINES)
1021 gbeauche 1.23 AC_SUBST(MONSRCS)
1022 nigel 1.1 AC_SUBST(CPUINCLUDES)
1023 nigel 1.12 AC_SUBST(BLESS)
1024 nigel 1.14 AC_SUBST(IDE)
1025     AC_SUBST(PROJECT)
1026     AC_SUBST(IDEARGS)
1027 nigel 1.17 AC_SUBST(SLIRP_SRCS)
1028 nigel 1.18 AC_SUBST(KEYCODES)
1029 gbeauche 1.23 AC_SUBST(WANT_JIT)
1030     AC_SUBST(WANT_JIT_DEBUG)
1031 nigel 1.11 dnl autoconf on 10.1 doesn't understand these
1032     dnl AC_CONFIG_FILES([Makefile])
1033     dnl AC_OUTPUT
1034 nigel 1.1 AC_OUTPUT(Makefile)
1035    
1036     dnl Print summary.
1037     echo
1038     echo Basilisk II configuration summary:
1039     echo
1040 gbeauche 1.24 echo Build binaries for ..................... : $WANT_UNIVERSAL
1041 nigel 1.8 echo Multiple emulator windows .............. : $ENABLE_MULTIPLE
1042 nigel 1.5 echo Enable video on SEGV signals ........... : $WANT_VOSF
1043     echo mon debugger support ................... : $WANT_MON
1044 gbeauche 1.23 echo Build JIT compiler ..................... : $WANT_JIT
1045     echo Build JIT with debug code .............. : $WANT_JIT_DEBUG
1046 nigel 1.5 echo Addressing mode ........................ : $ADDRESSING_MODE
1047 nigel 1.12 echo Bad memory access recovery type ........ : $sigsegv_recovery
1048 nigel 1.15 echo Mac OS X development environment ....... : $IDE
1049 nigel 1.1 echo
1050 nigel 1.2 echo "Configuration done. Now type \"make\" (or \"make ide\")."