ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/configure.in
Revision: 1.25
Committed: 2007-06-15T21:46:25Z (17 years, 3 months ago) by gbeauche
Branch: MAIN
Changes since 1.24: +14 -2 lines
Log Message:
Disable cxmon by default for MacOS X builds. Add hackery to cross-compile
a working 10.2/ppc binary.

File Contents

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