ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/configure.in
Revision: 1.23
Committed: 2007-06-15T10:11:28Z (17 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.22: +19 -61 lines
Log Message:
Fix cxmon files inclusion. Drop support for non ppc & x86 MacOS X arches.
Make JIT files & defs selection at build-time, not configure-time (FATs).

NOTE: be careful, larger changes are yet to come.

File Contents

# User Rev Content
1 nigel 1.10 dnl Mac OS X configuration driver
2 gbeauche 1.23 dnl $Id: configure.in,v 1.22 2007/06/15 09:16:58 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    
17 nigel 1.13 dnl Aliases for PACKAGE and VERSION macros.
18     AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE_NAME", [Define this program name.])
19     AC_DEFINE_UNQUOTED(VERSION, "$PACKAGE_VERSION", [Define this program version.])
20    
21     dnl Some systems do not put corefiles in the currect directory, avoid saving
22     dnl cores for the configure tests since some are intended to dump core.
23     ulimit -c 0
24    
25 nigel 1.5 dnl Video options.
26 nigel 1.1 AC_ARG_ENABLE(multiwin,
27 nigel 1.8 [ --enable-multiwin allow multiple emulator windows [default=no]], [ENABLE_MULTIPLE=$enableval], [ENABLE_MULTIPLE=no])
28 nigel 1.1
29 nigel 1.5 dnl JIT compiler options.
30     AC_ARG_ENABLE(jit-compiler, [ --enable-jit-compiler enable JIT compiler [default=no]], [WANT_JIT=$enableval], [WANT_JIT=no])
31     AC_ARG_ENABLE(jit-debug, [ --enable-jit-debug activate native code disassemblers [default=no]], [WANT_JIT_DEBUG=$enableval], [WANT_JIT_DEBUG=no])
32    
33 nigel 1.1 dnl FPU emulation core.
34     AC_ARG_ENABLE(fpe,
35 nigel 1.5 [ --enable-fpe=FPE specify which fpu emulator to use [default=auto]],
36 nigel 1.1 [ case "$enableval" in
37 nigel 1.5 dnl default is always ieee, if architecture has this fp format
38     auto) FPE_CORE_TEST_ORDER="ieee uae";;
39     ieee) FPE_CORE_TEST_ORDER="ieee";;
40     uae) FPE_CORE_TEST_ORDER="uae";;
41     x86) FPE_CORE_TEST_ORDER="x86";;
42 nigel 1.10 *) AC_MSG_ERROR([--enable-fpe takes only one of the following values: auto, x86, ieee, uae]);;
43 nigel 1.1 esac
44     ],
45 nigel 1.5 [ FPE_CORE_TEST_ORDER="ieee uae"
46 nigel 1.1 ])
47    
48     dnl Addressing modes.
49     AC_ARG_ENABLE(addressing,
50     [ --enable-addressing=AM specify the addressing mode to use [default=fastest]],
51     [ case "$enableval" in
52     real) ADDRESSING_TEST_ORDER="real";;
53     direct) ADDRESSING_TEST_ORDER="direct";;
54     banks) ADDRESSING_TEST_ORDER="banks";;
55     fastest)ADDRESSING_TEST_ORDER="direct banks";;
56     *) AC_MSG_ERROR([--enable-addressing takes only one of the following values: fastest, real, direct, banks]);;
57     esac
58     ],
59     [ ADDRESSING_TEST_ORDER="direct banks"
60     ])
61    
62     dnl External packages.
63     AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
64    
65     dnl Canonical system information.
66     AC_CANONICAL_HOST
67     AC_CANONICAL_TARGET
68    
69 nigel 1.14 dnl Target OS type (target is host if not cross-compiling).
70     case "$target_os" in
71     linux*) OS_TYPE=linux;;
72     netbsd*) OS_TYPE=netbsd;;
73     freebsd*) OS_TYPE=freebsd;;
74     solaris*) OS_TYPE=solaris;;
75     darwin*) OS_TYPE=darwin;;
76     *) OS_TYPE=`echo $target_os | sed -e 's/-/_/g' | sed -e 's/\./_/g'`;;
77     esac
78 nigel 1.1 DEFINES="$DEFINES -DOS_$OS_TYPE"
79    
80     dnl Target CPU type.
81     HAVE_I386=no
82     HAVE_M68K=no
83     HAVE_SPARC=no
84     HAVE_POWERPC=no
85 nigel 1.10 HAVE_X86_64=no
86 nigel 1.1 case "$target_cpu" in
87 nigel 1.10 i386* | i486* | i586* | i686* | i786* ) HAVE_I386=yes;;
88     m68k* ) HAVE_M68K=yes;;
89     sparc* ) HAVE_SPARC=yes;;
90     powerpc* ) HAVE_POWERPC=yes;;
91     x86_64* ) HAVE_X86_64=yes;;
92 nigel 1.1 esac
93    
94     dnl Checks for programs.
95     AC_PROG_CC
96     AC_PROG_CC_C_O
97     AC_PROG_CPP
98     AC_PROG_CXX
99     AC_PROG_MAKE_SET
100     AC_PROG_INSTALL
101 nigel 1.17 AC_PROG_EGREP
102 nigel 1.1
103     dnl We use mon if possible.
104     MONSRCS=
105     if [[ "x$WANT_MON" = "xyes" ]]; then
106     AC_MSG_CHECKING(for mon)
107     mon_srcdir=../../../mon/src
108     if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
109     AC_MSG_RESULT(yes)
110 nigel 1.5 AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".])
111 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"
112     AC_SUBST(MONSRCS)
113 nigel 1.1 CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
114 nigel 1.10 AC_CHECK_LIB(ncurses, tgetent, ,
115     AC_CHECK_LIB(termcap, tgetent, ,
116     AC_CHECK_LIB(termlib, tgetent, ,
117     AC_CHECK_LIB(terminfo, tgetent, ,
118     AC_CHECK_LIB(Hcurses, tgetent, ,
119     AC_CHECK_LIB(curses, tgetent))))))
120 nigel 1.1 AC_CHECK_LIB(readline, readline)
121     else
122     AC_MSG_RESULT(no)
123     AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
124     WANT_MON=no
125     fi
126     fi
127    
128 nigel 1.14 dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL.
129 nigel 1.1 HAVE_PTHREADS=yes
130 nigel 1.14 AC_CHECK_LIB(pthread, pthread_create, , [
131     AC_CHECK_LIB(c_r, pthread_create, , [
132     AC_CHECK_LIB(PTL, pthread_create, , [
133     HAVE_PTHREADS=no
134     ])
135     ])
136     ])
137     dnl OS X does have pthreads, but not in any of the above locations:
138     HAVE_PTHREADS=yes
139     if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
140     AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.])
141     fi
142 nigel 1.17 AC_CHECK_FUNCS(pthread_cond_init)
143     AC_CHECK_FUNCS(pthread_cancel pthread_testcancel)
144 nigel 1.3 AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
145     AC_CHECK_FUNCS(pthread_mutexattr_settype)
146 nigel 1.5 AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
147 nigel 1.1
148     dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
149     SEMSRC=
150     AC_CHECK_FUNCS(sem_init, , [
151     if test "x$HAVE_PTHREADS" = "xyes"; then
152     SEMSRC=posix_sem.cpp
153     fi
154     ])
155    
156 nigel 1.5 dnl We want to enable multiple window support if possible
157 nigel 1.1 if [[ "x$WANT_MWIN" = "xyes" ]]; then
158     WANT_MWIN=yes
159     DEFINES="$DEFINES -DENABLE_MULTIPLE"
160     fi
161    
162 nigel 1.5 dnl We use 64-bit file size support if possible.
163     AC_SYS_LARGEFILE
164    
165 nigel 1.1 dnl Checks for header files.
166     AC_HEADER_STDC
167 nigel 1.17 AC_CHECK_HEADERS(stdlib.h stdint.h)
168 nigel 1.13 AC_CHECK_HEADERS(unistd.h fcntl.h sys/types.h sys/time.h sys/mman.h mach/mach.h)
169 nigel 1.12 AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
170 nigel 1.17 AC_CHECK_HEADERS(sys/socket.h sys/ioctl.h sys/filio.h sys/bitypes.h sys/wait.h)
171     AC_CHECK_HEADERS(sys/poll.h sys/select.h)
172     AC_CHECK_HEADERS(arpa/inet.h)
173     AC_CHECK_HEADERS(linux/if.h linux/if_tun.h net/if.h net/if_tun.h, [], [], [
174     #ifdef HAVE_SYS_TYPES_H
175     #include <sys/types.h>
176     #endif
177     #ifdef HAVE_SYS_SOCKET_H
178     #include <sys/socket.h>
179     #endif
180     ])
181     AC_CHECK_HEADERS(AvailabilityMacros.h)
182 gbeauche 1.16 AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDevice.h)
183 nigel 1.1
184     dnl Checks for typedefs, structures, and compiler characteristics.
185     AC_C_BIGENDIAN
186     AC_C_CONST
187     AC_C_INLINE
188     AC_CHECK_SIZEOF(short, 2)
189     AC_CHECK_SIZEOF(int, 4)
190     AC_CHECK_SIZEOF(long, 4)
191     AC_CHECK_SIZEOF(long long, 8)
192 nigel 1.5 AC_CHECK_SIZEOF(float, 4)
193     AC_CHECK_SIZEOF(double, 8)
194     AC_CHECK_SIZEOF(long double, 12)
195 nigel 1.1 AC_CHECK_SIZEOF(void *, 4)
196 nigel 1.10 AC_TYPE_OFF_T
197 nigel 1.13 dnl These two symbols are not defined in 10.1's autoconf:
198 nigel 1.8 dnl AC_CHECK_TYPE(loff_t, off_t)
199     dnl AC_CHECK_TYPE(caddr_t, [char *])
200     dnl We define loff_t as a typedef of off_t in sysdeps.h if we don't have LOFF_T
201 nigel 1.13 dnl OS X does have caddr_t, but the above check doesn't work, so we have to do:
202     AC_DEFINE(HAVE_CADDR_T, 1, [The type "caddr_t" does exist on MacOS X.])
203 nigel 1.1 AC_TYPE_SIZE_T
204     AC_TYPE_SIGNAL
205     AC_HEADER_TIME
206     AC_STRUCT_TM
207    
208 nigel 1.5 dnl Check whether sys/socket.h defines type socklen_t.
209     dnl (extracted from ac-archive/Miscellaneous)
210     AC_CACHE_CHECK([for socklen_t],
211     ac_cv_type_socklen_t, [
212     AC_TRY_COMPILE([
213     #include <sys/types.h>
214     #include <sys/socket.h>
215     ], [socklen_t len = 42; return 0;],
216     ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no,
217     dnl When cross-compiling, do not assume anything.
218     ac_cv_type_socklen_t="guessing no"
219     )
220     ])
221     if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then
222     AC_DEFINE(socklen_t, int, [Define to 'int' if <sys/types.h> doesn't define.])
223     fi
224    
225 nigel 1.1 dnl Checks for library functions.
226 nigel 1.17 AC_CHECK_FUNCS(strdup strerror cfmakeraw)
227 nigel 1.1 AC_CHECK_FUNCS(clock_gettime timer_create)
228     AC_CHECK_FUNCS(sigaction signal)
229     AC_CHECK_FUNCS(mmap mprotect munmap)
230     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
231 nigel 1.17 AC_CHECK_FUNCS(poll inet_aton)
232 nigel 1.1
233     dnl Darwin seems to define mach_task_self() instead of task_self().
234     AC_CHECK_FUNCS(mach_task_self task_self)
235    
236 nigel 1.17 dnl Check for headers and functions related to pty support (sshpty.c)
237     dnl From openssh-3.2.2p1 configure.ac
238    
239     AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
240     AC_CHECK_FUNCS(_getpty vhangup strlcpy)
241     if test -z "$no_dev_ptmx" ; then
242     if test "x$disable_ptmx_check" != "xyes" ; then
243     AC_CHECK_FILE([/dev/ptmx],
244     [
245     AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.])
246     have_dev_ptmx=1
247     ]
248     )
249     fi
250     fi
251     AC_CHECK_FILE([/dev/ptc],
252     [
253     AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.])
254     have_dev_ptc=1
255     ]
256     )
257    
258     dnl (end of code from openssh-3.2.2p1 configure.ac)
259    
260    
261 nigel 1.19 dnl Check for systems where POSIX-style non-blocking I/O (O_NONBLOCK)
262     dnl doesn't work or is unimplemented. On these systems (mostly older
263     dnl ones), use the old BSD-style FIONBIO approach instead. [tcl.m4]
264     AC_CACHE_CHECK([FIONBIO vs. O_NONBLOCK for non-blocking I/O],
265     ac_cv_nonblocking_io, [
266     case "$host" in
267     *-*-osf*)
268     ac_cv_nonblocking_io=FIONBIO
269     ;;
270     *-*-sunos4*)
271     ac_cv_nonblocking_io=FIONBIO
272     ;;
273     *-*-ultrix*)
274     ac_cv_nonblocking_io=FIONBIO
275     ;;
276     *)
277     ac_cv_nonblocking_io=O_NONBLOCK
278     ;;
279     esac
280     ])
281     if [[ "$ac_cv_nonblocking_io" = "FIONBIO" ]]; then
282     AC_DEFINE(USE_FIONBIO, 1, [Define if BSD-style non-blocking I/O is to be used])
283     fi
284    
285     dnl Check whether compiler supports byte bit-fields
286     AC_CACHE_CHECK([whether compiler supports byte bit-fields],
287     ac_cv_have_byte_bitfields, [
288     AC_LANG_SAVE
289     AC_LANG_CPLUSPLUS
290     AC_TRY_RUN([
291     struct A {
292     unsigned char b1:4;
293     unsigned char b2:4;
294     unsigned char c;
295     unsigned short s;
296     unsigned char a[4];
297     };
298    
299     int main(void) {
300     A a;
301     return ! (sizeof(A) == 8 && &a.c == ((unsigned char *)&a + 1));
302     }],
303     [ac_cv_have_byte_bitfields=yes],
304     [ac_cv_have_byte_bitfields=no],
305     dnl When cross-compiling, assume only GCC supports this
306     [if [[ "$GCC" = "yes" ]]; then
307     ac_cv_have_byte_bitfields="guessing yes"
308     else
309     ac_cv_have_byte_bitfields="guessing no"
310     fi]
311     )
312     AC_LANG_RESTORE
313     ])
314    
315 nigel 1.17 dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
316     AC_DEFUN([AC_CHECK_FRAMEWORK], [
317     AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
318     AC_CACHE_CHECK([whether compiler supports framework $1],
319     ac_Framework, [
320     saved_LIBS="$LIBS"
321     LIBS="$LIBS -framework $1"
322     AC_TRY_LINK(
323 nigel 1.20 [$2], [],
324 nigel 1.17 [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
325     )
326     ])
327     AS_IF([test AS_VAR_GET(ac_Framework) = yes],
328     [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
329     )
330     AS_VAR_POPDEF([ac_Framework])dnl
331     ])
332    
333     dnl Check for some MacOS X frameworks
334 nigel 1.20 AC_CHECK_FRAMEWORK(AppKit, [])
335 nigel 1.17 AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
336     AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
337     AC_CHECK_FRAMEWORK(CoreFoundation, [#include <CoreFoundation/CoreFoundation.h>])
338 gbeauche 1.22 AC_CHECK_FRAMEWORK(CoreAudio, [#include <CoreAudio/CoreAudio.h>])
339     AC_CHECK_FRAMEWORK(AudioUnit, [#include <AudioUnit/AudioUnit.h>])
340     AC_CHECK_FRAMEWORK(AudioToolbox, [#include <AudioToolbox/AudioToolbox.h>])
341 nigel 1.17
342 nigel 1.1 dnl Select system-dependant source files.
343 nigel 1.17 ETHERSRC=ether_unix.cpp
344 nigel 1.13 DEFINES="$DEFINES -DBSD_COMP"
345     CXXFLAGS="$CXXFLAGS -fpermissive"
346 nigel 1.1 dnl Check for the CAM library
347 nigel 1.5 AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no)
348 nigel 1.1 if [[ "x$HAVE_LIBCAM" = "xno" ]]; then
349     AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.])
350 nigel 1.5 else
351     dnl Check for the sys kernel includes
352 nigel 1.1 AC_CHECK_HEADER(camlib.h)
353     if [[ "x$ac_cv_header_camlib_h" = "xno" ]]; then
354     dnl In this case I should fix this thing including a "patch"
355     dnl to access directly to the functions in the kernel :) --Orlando
356     AC_MSG_WARN([Cannot find includes for CAM library, disabling SCSI support.])
357     else
358     SCSISRC=FreeBSD/scsi_freebsd.cpp
359     LIBS="$LIBS -lcam"
360     DEFINES="$DEFINES -DCAM"
361     fi
362     fi
363    
364 nigel 1.17 dnl Is the slirp library supported?
365 gbeauche 1.23 WANT_SLIRP=no
366 nigel 1.19 case "$ac_cv_have_byte_bitfields" in
367     yes|"guessing yes")
368 gbeauche 1.23 WANT_SLIRP=yes
369 nigel 1.19 ETHERSRC=ether_unix.cpp
370     ;;
371     esac
372 gbeauche 1.23 if [[ "x$WANT_SLIRP" = "xyes" ]]; then
373 nigel 1.17 AC_DEFINE(HAVE_SLIRP, 1, [Define if slirp library is supported])
374     SLIRP_SRCS="\
375     ../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \
376     ../slirp/cksum.c ../slirp/mbuf.c ../slirp/tcp_output.c \
377     ../slirp/debug.c ../slirp/misc.c ../slirp/tcp_subr.c \
378     ../slirp/if.c ../slirp/sbuf.c ../slirp/tcp_timer.c \
379     ../slirp/ip_icmp.c ../slirp/slirp.c ../slirp/tftp.c \
380     ../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c"
381     fi
382 gbeauche 1.23 AC_SUBST(WANT_SLIRP)
383 nigel 1.17 AC_SUBST(SLIRP_SRCS)
384    
385 nigel 1.1
386     dnl Define a macro that translates a yesno-variable into a C macro definition
387     dnl to be put into the config.h file
388     dnl $1 -- the macro to define
389     dnl $2 -- the value to translate
390 nigel 1.5 dnl $3 -- template name
391 nigel 1.17 AC_DEFUN([AC_TRANSLATE_DEFINE], [
392 nigel 1.1 if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
393 nigel 1.5 AC_DEFINE($1, 1, $3)
394 nigel 1.1 fi
395     ])
396    
397 nigel 1.17 dnl Check that the host supports TUN/TAP devices
398     AC_CACHE_CHECK([whether TUN/TAP is supported],
399     ac_cv_tun_tap_support, [
400     AC_TRY_COMPILE([
401     #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
402     #include <linux/if.h>
403     #include <linux/if_tun.h>
404     #endif
405     #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
406     #include <net/if.h>
407     #include <net/if_tun.h>
408     #endif
409     ], [
410     struct ifreq ifr;
411     memset(&ifr, 0, sizeof(ifr));
412     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
413     ],
414     ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
415     )
416     ])
417     AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
418     [Define if your system supports TUN/TAP devices.])
419    
420 nigel 1.1 dnl Various checks if the system supports vm_allocate() and the like functions.
421     have_mach_vm=no
422     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
423     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
424     have_mach_vm=yes
425     fi
426 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
427     [Define if your system has a working vm_allocate()-based memory allocator.])
428 nigel 1.1
429     dnl Check that vm_allocate(), vm_protect() work
430     if [[ "x$have_mach_vm" = "xyes" ]]; then
431    
432 nigel 1.5 AC_CACHE_CHECK([whether vm_protect works],
433 nigel 1.1 ac_cv_vm_protect_works, [
434     AC_LANG_SAVE
435     AC_LANG_CPLUSPLUS
436     ac_cv_vm_protect_works=yes
437     dnl First the tests that should segfault
438     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
439     AC_TRY_RUN([
440     #define CONFIGURE_TEST_VM_MAP
441     #define TEST_VM_PROT_$test_def
442 nigel 1.6 #include "../Unix/vm_alloc.cpp"
443 nigel 1.1 ], ac_cv_vm_protect_works=no, rm -f core,
444     dnl When cross-compiling, do not assume anything
445     ac_cv_vm_protect_works="guessing no"
446     )
447     done
448     AC_TRY_RUN([
449     #define CONFIGURE_TEST_VM_MAP
450     #define TEST_VM_PROT_RDWR_WRITE
451 nigel 1.6 #include "../Unix/vm_alloc.cpp"
452 nigel 1.1 ], , ac_cv_vm_protect_works=no,
453     dnl When cross-compiling, do not assume anything
454     ac_cv_vm_protect_works="guessing no"
455     )
456     AC_LANG_RESTORE
457     ]
458     )
459    
460     dnl Remove support for vm_allocate() if vm_protect() does not work
461     if [[ "x$have_mach_vm" = "xyes" ]]; then
462     case $ac_cv_vm_protect_works in
463     *yes) have_mach_vm=yes;;
464     *no) have_mach_vm=no;;
465     esac
466     fi
467 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
468     [Define if your system has a working vm_allocate()-based memory allocator.])
469 nigel 1.1
470     fi dnl HAVE_MACH_VM
471    
472     dnl Various checks if the system supports mmap() and the like functions.
473     dnl ... and Mach memory allocators are not supported
474     have_mmap_vm=no
475     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
476     "x$ac_cv_func_mprotect" = "xyes" ]]; then
477     if [[ "x$have_mach_vm" = "xno" ]]; then
478     have_mmap_vm=yes
479     fi
480     fi
481 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
482     [Define if your system has a working mmap()-based memory allocator.])
483 nigel 1.1
484     dnl Check that mmap() and associated functions work.
485     if [[ "x$have_mmap_vm" = "xyes" ]]; then
486    
487     dnl Check if we have a working anonymous mmap()
488 nigel 1.5 AC_CACHE_CHECK([whether mmap supports MAP_ANON],
489 nigel 1.1 ac_cv_mmap_anon, [
490     AC_LANG_SAVE
491     AC_LANG_CPLUSPLUS
492     AC_TRY_RUN([
493     #define HAVE_MMAP_ANON
494     #define CONFIGURE_TEST_VM_MAP
495     #define TEST_VM_MMAP_ANON
496 nigel 1.6 #include "../Unix/vm_alloc.cpp"
497 nigel 1.1 ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
498     dnl When cross-compiling, do not assume anything.
499     ac_cv_mmap_anon="guessing no"
500     )
501     AC_LANG_RESTORE
502     ]
503     )
504 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
505     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
506 nigel 1.1
507 nigel 1.5 AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
508 nigel 1.1 ac_cv_mmap_anonymous, [
509     AC_LANG_SAVE
510     AC_LANG_CPLUSPLUS
511     AC_TRY_RUN([
512     #define HAVE_MMAP_ANONYMOUS
513     #define CONFIGURE_TEST_VM_MAP
514     #define TEST_VM_MMAP_ANON
515 nigel 1.6 #include "../Unix/vm_alloc.cpp"
516 nigel 1.1 ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
517     dnl When cross-compiling, do not assume anything.
518     ac_cv_mmap_anonymous="guessing no"
519     )
520     AC_LANG_RESTORE
521     ]
522     )
523 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
524     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
525 nigel 1.1
526 nigel 1.5 AC_CACHE_CHECK([whether mprotect works],
527 nigel 1.1 ac_cv_mprotect_works, [
528     AC_LANG_SAVE
529     AC_LANG_CPLUSPLUS
530     ac_cv_mprotect_works=yes
531     dnl First the tests that should segfault
532     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
533     AC_TRY_RUN([
534     #define CONFIGURE_TEST_VM_MAP
535     #define TEST_VM_PROT_$test_def
536 nigel 1.6 #include "../Unix/vm_alloc.cpp"
537 nigel 1.1 ], ac_cv_mprotect_works=no, rm -f core,
538     dnl When cross-compiling, do not assume anything
539     ac_cv_mprotect_works="guessing no"
540     )
541     done
542     AC_TRY_RUN([
543     #define CONFIGURE_TEST_VM_MAP
544     #define TEST_VM_PROT_RDWR_WRITE
545 nigel 1.6 #include "../Unix/vm_alloc.cpp"
546 nigel 1.1 ], , ac_cv_mprotect_works=no,
547     dnl When cross-compiling, do not assume anything
548     ac_cv_mprotect_works="guessing no"
549     )
550     AC_LANG_RESTORE
551     ]
552     )
553    
554     dnl Remove support for mmap() if mprotect() does not work
555     if [[ "x$have_mmap_vm" = "xyes" ]]; then
556     case $ac_cv_mprotect_works in
557     *yes) have_mmap_vm=yes;;
558     *no) have_mmap_vm=no;;
559     esac
560     fi
561 nigel 1.5 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
562     [Define if your system has a working mmap()-based memory allocator.])
563 nigel 1.1
564     fi dnl HAVE_MMAP_VM
565    
566 nigel 1.12 dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
567     AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x2000],
568     ac_cv_pagezero_hack, [
569     ac_cv_pagezero_hack=no
570     if AC_TRY_COMMAND([Darwin/testlmem.sh 0x2000]); then
571     ac_cv_pagezero_hack=yes
572     dnl might as well skip the test for mmap-able low memory
573     ac_cv_can_map_lm=no
574     fi
575     ])
576     AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
577     [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
578    
579 nigel 1.1 dnl Check if we can mmap 0x2000 bytes from 0x0000
580 nigel 1.5 AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x2000],
581 nigel 1.1 ac_cv_can_map_lm, [
582     AC_LANG_SAVE
583     AC_LANG_CPLUSPLUS
584     AC_TRY_RUN([
585 nigel 1.6 #include "../Unix/vm_alloc.cpp"
586 nigel 1.1 int main(void) { /* returns 0 if we could map the lowmem globals */
587 nigel 1.11 volatile char * lm = 0;
588 nigel 1.1 if (vm_init() < 0) exit(1);
589 nigel 1.12 if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
590 nigel 1.1 lm[0] = 'z';
591     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
592     vm_exit(); exit(0);
593     }
594     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
595     dnl When cross-compiling, do not assume anything.
596     ac_cv_can_map_lm="guessing no"
597     )
598     AC_LANG_RESTORE
599     ]
600     )
601    
602     dnl Check signal handlers need to be reinstalled
603 nigel 1.5 AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
604 nigel 1.1 ac_cv_signal_need_reinstall, [
605     AC_LANG_SAVE
606     AC_LANG_CPLUSPLUS
607     AC_TRY_RUN([
608     #include <stdlib.h>
609     #ifdef HAVE_UNISTD_H
610     #include <unistd.h>
611     #endif
612     #include <signal.h>
613     static int handled_signal = 0;
614     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
615     int main(void) { /* returns 0 if signals need not to be reinstalled */
616     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
617     exit(handled_signal == 2);
618     }
619     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
620     dnl When cross-compiling, do not assume anything.
621     ac_cv_signal_need_reinstall="guessing yes"
622     )
623     AC_LANG_RESTORE
624     ]
625     )
626 nigel 1.5 AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
627     [Define if your system requires signals to be reinstalled.])
628 nigel 1.1
629     dnl Check if sigaction handlers need to be reinstalled
630 nigel 1.5 AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
631 nigel 1.1 ac_cv_sigaction_need_reinstall, [
632     AC_LANG_SAVE
633     AC_LANG_CPLUSPLUS
634     AC_TRY_RUN([
635     #include <stdlib.h>
636     #ifdef HAVE_UNISTD_H
637     #include <unistd.h>
638     #endif
639     #include <signal.h>
640     static int handled_signal = 0;
641     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
642     typedef RETSIGTYPE (*signal_handler)(int);
643     static signal_handler mysignal(int sig, signal_handler handler) {
644     struct sigaction old_sa;
645     struct sigaction new_sa;
646     new_sa.sa_handler = handler;
647     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
648     }
649     int main(void) { /* returns 0 if signals need not to be reinstalled */
650     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
651     exit(handled_signal == 2);
652     }
653     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
654     dnl When cross-compiling, do not assume anything.
655     ac_cv_sigaction_need_reinstall="guessing yes"
656     )
657     AC_LANG_RESTORE
658     ]
659     )
660 nigel 1.5 AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
661     [Define if your system requires sigactions to be reinstalled.])
662 nigel 1.1
663 nigel 1.12 dnl Check if Mach exceptions supported.
664     AC_CACHE_CHECK([whether your system supports Mach exceptions],
665     ac_cv_have_mach_exceptions, [
666 nigel 1.1 AC_LANG_SAVE
667     AC_LANG_CPLUSPLUS
668     AC_TRY_RUN([
669 nigel 1.12 #define HAVE_MACH_EXCEPTIONS 1
670 nigel 1.1 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
671 nigel 1.13 #include "../Unix/vm_alloc.cpp"
672     #include "../Unix/sigsegv.cpp"
673 nigel 1.12 ], [
674     sigsegv_recovery=mach
675     ac_cv_have_mach_exceptions=yes
676     ],
677     ac_cv_have_mach_exceptions=no,
678 nigel 1.1 dnl When cross-compiling, do not assume anything.
679 nigel 1.12 ac_cv_have_mach_exceptions=no
680 nigel 1.1 )
681     AC_LANG_RESTORE
682     ]
683     )
684 nigel 1.12 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
685     [Define if your system supports Mach exceptions.])
686    
687     dnl Otherwise, check if extended signals are supported.
688     if [[ -z "$sigsegv_recovery" ]]; then
689     AC_CACHE_CHECK([whether your system supports extended signal handlers],
690     ac_cv_have_extended_signals, [
691     AC_LANG_SAVE
692     AC_LANG_CPLUSPLUS
693     AC_TRY_RUN([
694     #define HAVE_SIGINFO_T 1
695     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
696     #include "../Unix/vm_alloc.cpp"
697     #include "../Unix/sigsegv.cpp"
698     ], [
699     sigsegv_recovery=siginfo
700     ac_cv_have_extended_signals=yes
701     ],
702     ac_cv_have_extended_signals=no,
703     dnl When cross-compiling, do not assume anything.
704     ac_cv_have_extended_signals=no
705     )
706     AC_LANG_RESTORE
707     ]
708     )
709     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
710     [Define if your system support extended signals.])
711     fi
712 nigel 1.5
713 nigel 1.1 dnl Otherwise, check for subterfuges.
714 nigel 1.14 if [[ -z "$sigsegv_recovery" ]]; then
715 nigel 1.13 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
716     ac_cv_have_sigcontext_hack, [
717     AC_LANG_SAVE
718     AC_LANG_CPLUSPLUS
719 nigel 1.14 AC_TRY_RUN([
720 nigel 1.13 #define HAVE_SIGCONTEXT_SUBTERFUGE 1
721     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
722     #include "../Unix/vm_alloc.cpp"
723     #include "../Unix/sigsegv.cpp"
724     ], [
725     sigsegv_recovery=sigcontext
726     ac_cv_have_sigcontext_hack=yes
727     ],
728     ac_cv_have_sigcontext_hack=no,
729     dnl When cross-compiling, do not assume anything.
730     ac_cv_have_sigcontext_hack=no
731     )
732     AC_LANG_RESTORE
733     ])
734     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
735     [Define if we know a hack to replace siginfo_t->si_addr member.])
736     fi
737 nigel 1.1
738 nigel 1.5 dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
739     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
740     ac_cv_have_skip_instruction, [
741     AC_LANG_SAVE
742     AC_LANG_CPLUSPLUS
743     AC_TRY_RUN([
744     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
745     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
746 nigel 1.6 #include "../Unix/vm_alloc.cpp"
747     #include "../Unix/sigsegv.cpp"
748 nigel 1.5 ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
749     dnl When cross-compiling, do not assume anything.
750     ac_cv_have_skip_instruction=no
751     )
752     AC_LANG_RESTORE
753     ]
754     )
755     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
756     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
757    
758 nigel 1.1 dnl Can we do Video on SEGV Signals ?
759     CAN_VOSF=no
760 nigel 1.12 if [[ -n "$sigsegv_recovery" ]]; then
761 nigel 1.1 CAN_VOSF=yes
762     fi
763    
764 nigel 1.12 dnl A dummy program that returns always true
765 nigel 1.17 AC_PATH_PROG([BLESS], "true")
766 nigel 1.12
767 nigel 1.19 dnl Check for linker script support
768     case $target_os:$target_cpu in
769     linux*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
770     linux*:x86_64) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-x86_64.ld";;
771 nigel 1.20 linux*:powerpc) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-ppc.ld";;
772     netbsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
773     freebsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/freebsd-i386.ld";;
774     darwin*:*) LINKER_SCRIPT_FLAGS="-Wl,-seg1addr,0x78048000";;
775 nigel 1.19 esac
776     if [[ -n "$LINKER_SCRIPT_FLAGS" ]]; then
777     AC_CACHE_CHECK([whether linker script is usable],
778     ac_cv_linker_script_works, [
779     AC_LANG_SAVE
780     AC_LANG_CPLUSPLUS
781     saved_LDFLAGS="$LDFLAGS"
782     LDFLAGS="$LDFLAGS $LINKER_SCRIPT_FLAGS"
783     AC_TRY_RUN(
784     [int main() {if ((char *)&main < (char *)0x70000000) return 1;}],
785     [ac_cv_linker_script_works=yes],
786     [ac_cv_linker_script_works=no],
787     dnl When cross-compiling, assume it works
788     [ac_cv_linker_script_works="guessing yes"]
789     )
790     AC_LANG_RESTORE
791     if [[ "$ac_cv_linker_script_works" = "no" ]]; then
792     LDFLAGS="$saved_LDFLAGS"
793     LINKER_SCRIPT_FLAGS=""
794     fi
795     ])
796     fi
797     AC_TRANSLATE_DEFINE(HAVE_LINKER_SCRIPT, "$ac_cv_linker_script_works",
798     [Define if there is a linker script to relocate the executable above 0x70000000.])
799    
800 nigel 1.1 dnl Determine the addressing mode to use
801 gbeauche 1.23 ADDRESSING_MODE=""
802     AC_MSG_CHECKING([for the addressing mode to use])
803 nigel 1.1 for am in $ADDRESSING_TEST_ORDER; do
804     case $am in
805     real)
806     dnl Requires ability to mmap() Low Memory globals
807 nigel 1.12 if [[ "x$ac_cv_can_map_lm$ac_cv_pagezero_hack" = "xnono" ]]; then
808 nigel 1.1 continue
809     fi
810 nigel 1.12 dnl Requires VOSF screen updates
811 nigel 1.1 if [[ "x$CAN_VOSF" = "xno" ]]; then
812     continue
813     fi
814     dnl Real addressing will probably work.
815     ADDRESSING_MODE="real"
816     WANT_VOSF=yes dnl we can use VOSF and we need it actually
817     DEFINES="$DEFINES -DREAL_ADDRESSING"
818 nigel 1.13 AC_DEFINE(REAL_ADDRESSING, 1, [Emulated memory is memory mapped to actual address.])
819 nigel 1.12 if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
820     BLESS=Darwin/lowmem
821     LDFLAGS="$LDFLAGS -pagezero_size 0x2000"
822     fi
823 nigel 1.1 break
824     ;;
825     direct)
826     dnl Requires VOSF screen updates
827     if [[ "x$CAN_VOSF" = "xyes" ]]; then
828     ADDRESSING_MODE="direct"
829     WANT_VOSF=yes dnl we can use VOSF and we need it actually
830     DEFINES="$DEFINES -DDIRECT_ADDRESSING"
831 nigel 1.13 AC_DEFINE(DIRECT_ADDRESSING, 1, [Emulated memory is an offset from actual address.])
832 nigel 1.1 break
833     fi
834     ;;
835     banks)
836     dnl Default addressing mode
837     ADDRESSING_MODE="memory banks"
838     break
839     ;;
840     *)
841     AC_MSG_ERROR([Internal configure.in script error for $am addressing mode])
842     esac
843     done
844 gbeauche 1.23 AC_MSG_RESULT($ADDRESSING_MODE)
845     if [[ "x$ADDRESSING_MODE" = "x" ]]; then
846     AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER])
847     ADDRESSING_MODE="memory banks"
848 nigel 1.1 fi
849    
850 nigel 1.5 dnl Banked Memory Addressing mode is not supported by the JIT compiler
851     if [[ "x$WANT_JIT" = "xyes" -a "x$ADDRESSING_MODE" = "xmemory banks" ]]; then
852     AC_MSG_ERROR([Sorry, the JIT Compiler requires Direct Addressing, at least])
853     fi
854    
855 nigel 1.1 dnl Enable VOSF screen updates with this feature is requested and feasible
856     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
857 nigel 1.5 AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
858 nigel 1.1 else
859     WANT_VOSF=no
860     fi
861    
862     dnl Check for GAS.
863     HAVE_GAS=no
864     AC_MSG_CHECKING(for GAS .p2align feature)
865     cat >conftest.S << EOF
866     .text
867     .p2align 5
868     EOF
869     if $CC conftest.S -c -o conftest.o >/dev/null 2>&1 ; then HAVE_GAS=yes; fi
870     AC_MSG_RESULT($HAVE_GAS)
871    
872     dnl Check for GCC 2.7 or higher.
873     HAVE_GCC27=no
874     AC_MSG_CHECKING(for GCC 2.7 or higher)
875 nigel 1.17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5)
876     # error gcc < 2.7
877     #endif
878     ]])],
879     [AC_MSG_RESULT(yes); HAVE_GCC27=yes],
880     [AC_MSG_RESULT(no)])
881 nigel 1.1
882     dnl Check for GCC 3.0 or higher.
883     HAVE_GCC30=no
884     AC_MSG_CHECKING(for GCC 3.0 or higher)
885 nigel 1.17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ >= 3)
886     # error gcc < 3
887     #endif
888     ]])],
889     [AC_MSG_RESULT(yes); HAVE_GCC30=yes],
890     [AC_MSG_RESULT(no)])
891    
892     dnl Check for ICC.
893     AC_MSG_CHECKING(for ICC)
894     HAVE_ICC=no
895     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
896     HAVE_ICC=yes
897     fi
898     AC_MSG_RESULT($HAVE_ICC)
899 nigel 1.1
900     dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher.
901 nigel 1.3 dnl Also set "-fno-exceptions" for C++ because exception handling requires
902     dnl the frame pointer.
903 nigel 1.1 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
904     CFLAGS="$CFLAGS -fomit-frame-pointer"
905 nigel 1.3 CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -fno-exceptions"
906 nigel 1.1 fi
907    
908     dnl (gb) Do not merge constants since it breaks fpu/fpu_x86.cpp.
909     dnl As of 2001/08/02, this affects the following compilers:
910     dnl Official: probably gcc-3.1 (mainline CVS)
911     dnl Mandrake: gcc-2.96 >= 0.59mdk, gcc-3.0.1 >= 0.1mdk
912     dnl Red Hat : gcc-2.96 >= 89, gcc-3.0 >= 1
913 nigel 1.17 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
914 nigel 1.1 SAVED_CXXFLAGS="$CXXFLAGS"
915     CXXFLAGS="$CXXFLAGS -fno-merge-constants"
916     AC_CACHE_CHECK([whether GCC supports constants merging], ac_cv_gcc_constants_merging, [
917     AC_LANG_SAVE
918     AC_LANG_CPLUSPLUS
919     AC_TRY_COMPILE([],[],[ac_cv_gcc_constants_merging=yes],[ac_cv_gcc_constants_merging=no])
920     AC_LANG_RESTORE
921     ])
922     if [[ "x$ac_cv_gcc_constants_merging" != "xyes" ]]; then
923     CXXFLAGS="$SAVED_CXXFLAGS"
924     fi
925     fi
926    
927 nigel 1.17 dnl Store motion was introduced in 3.3-hammer branch and any gcc >= 3.4
928     dnl However, there are some corner cases exposed on x86-64
929     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
930     SAVED_CXXFLAGS="$CXXFLAGS"
931     CXXFLAGS="$CXXFLAGS -fno-gcse-sm"
932     AC_CACHE_CHECK([whether GCC supports store motion], ac_cv_gcc_store_motion, [
933     AC_LANG_SAVE
934     AC_LANG_CPLUSPLUS
935     AC_TRY_COMPILE([],[],[ac_cv_gcc_store_motion=yes],[ac_cv_gcc_store_motion=no])
936     AC_LANG_RESTORE
937     ])
938     if [[ "x$ac_cv_gcc_store_motion" != "xyes" ]]; then
939     CXXFLAGS="$SAVED_CXXFLAGS"
940     fi
941     fi
942    
943     dnl Add -fno-strict-aliasing for slirp sources
944     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
945     SAVED_CFLAGS="$CFLAGS"
946     CFLAGS="$CFLAGS -fno-strict-aliasing"
947     AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
948     ac_cv_gcc_no_strict_aliasing, [
949     AC_TRY_COMPILE([],[],
950     [ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
951     [ac_cv_gcc_no_strict_aliasing=no])
952     ])
953     CFLAGS="$SAVED_CFLAGS"
954     fi
955    
956 nigel 1.18 dnl Add -mdynamic-no-pic for MacOS X (XXX icc10 will support MacOS X)
957     if [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
958 nigel 1.17 SAVED_CFLAGS="$CFLAGS"
959     CFLAGS="$CFLAGS -mdynamic-no-pic"
960     AC_CACHE_CHECK([whether the compiler supports -mdynamic-no-pic],
961     ac_cv_gcc_mdynamic_no_pic, [
962     AC_TRY_COMPILE([],[],[ac_cv_gcc_mdynamic_no_pic=yes],[ac_cv_gcc_mdynamic_no_pic=no])
963     ])
964     if [[ "x$ac_cv_gcc_mdynamic_no_pic" = "xyes" ]]; then
965     CXXFLAGS="$CXXFLAGS -mdynamic-no-pic"
966     else
967     CFLAGS="$SAVED_CFLAGS"
968     fi
969     fi
970    
971 nigel 1.1 dnl Select appropriate CPU source and REGPARAM define.
972     ASM_OPTIMIZATIONS=none
973     CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
974 nigel 1.5
975     dnl Other platforms should define their own set of noflags file variants
976     CAN_JIT=no
977 nigel 1.10 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
978 nigel 1.1 dnl i386 CPU
979 nigel 1.5 DEFINES="$DEFINES -DUNALIGNED_PROFITABLE -DREGPARAM=\"__attribute__((regparm(3)))\""
980 nigel 1.1 if [[ "x$HAVE_GAS" = "xyes" ]]; then
981     ASM_OPTIMIZATIONS=i386
982 nigel 1.5 DEFINES="$DEFINES -DX86_ASSEMBLY -DOPTIMIZED_FLAGS -DSAHF_SETO_PROFITABLE"
983 nigel 1.10 CAN_JIT=yes
984     fi
985     elif [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_X86_64" = "xyes" ]]; then
986     dnl x86-64 CPU
987     DEFINES="$DEFINES -DUNALIGNED_PROFITABLE"
988     if [[ "x$HAVE_GAS" = "xyes" ]]; then
989     ASM_OPTIMIZATIONS="x86-64"
990     DEFINES="$DEFINES -DX86_64_ASSEMBLY -DOPTIMIZED_FLAGS"
991 nigel 1.17 CAN_JIT=yes
992 nigel 1.1 fi
993     fi
994    
995 nigel 1.5 dnl Enable JIT compiler, if possible.
996     if [[ "x$WANT_JIT" = "xyes" -a "x$CAN_JIT" ]]; then
997     if [[ "x$WANT_JIT_DEBUG" = "xyes" ]]; then
998 gbeauche 1.23 if [[ "x$WANT_MON" = "xno" ]]; then
999 nigel 1.5 AC_MSG_WARN([cxmon not found, ignoring --enable-jit-debug])
1000     WANT_JIT_DEBUG=no
1001     fi
1002     fi
1003    
1004     dnl IEEE core is the only FPU emulator to use with the JIT compiler
1005     case $FPE_CORE_TEST_ORDER in
1006     ieee*) ;;
1007     *) AC_MSG_WARN([Forcing use of the IEEE FPU core, as the JIT compiler supports only this one.]) ;;
1008     esac
1009     FPE_CORE_TEST_ORDER="ieee"
1010     else
1011     WANT_JIT=no
1012     WANT_JIT_DEBUG=no
1013     JITSRCS=""
1014     fi
1015    
1016     dnl Utility macro used by next two tests.
1017     dnl AC_EXAMINE_OBJECT(C source code,
1018     dnl commands examining object file,
1019     dnl [commands to run if compile failed]):
1020     dnl
1021     dnl Compile the source code to an object file; then convert it into a
1022     dnl printable representation. All unprintable characters and
1023     dnl asterisks (*) are replaced by dots (.). All white space is
1024     dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
1025     dnl output, but runs of newlines are compressed to a single newline.
1026     dnl Finally, line breaks are forcibly inserted so that no line is
1027     dnl longer than 80 columns and the file ends with a newline. The
1028     dnl result of all this processing is in the file conftest.dmp, which
1029     dnl may be examined by the commands in the second argument.
1030     dnl
1031     AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
1032     [AC_LANG_SAVE
1033     AC_LANG_C
1034     dnl Next bit cribbed from AC_TRY_COMPILE.
1035     cat > conftest.$ac_ext <<EOF
1036     [#line __oline__ "configure"
1037     #include "confdefs.h"
1038     $1
1039     ]EOF
1040     if AC_TRY_EVAL(ac_compile); then
1041     od -c conftest.o |
1042     sed ['s/^[0-7]*[ ]*/ /
1043     s/\*/./g
1044     s/ \\n/*/g
1045     s/ [0-9][0-9][0-9]/./g
1046     s/ \\[^ ]/./g'] |
1047     tr -d '
1048     ' | tr -s '*' '
1049     ' | fold | sed '$a\
1050     ' > conftest.dmp
1051     $2
1052     ifelse($3, , , else
1053     $3
1054     )dnl
1055     fi
1056     rm -rf conftest*
1057     AC_LANG_RESTORE])
1058    
1059     dnl Floating point format probe.
1060     dnl The basic concept is the same as the above: grep the object
1061     dnl file for an interesting string. We have to watch out for
1062     dnl rounding changing the values in the object, however; this is
1063     dnl handled by ignoring the least significant byte of the float.
1064     dnl
1065     dnl Does not know about VAX G-float or C4x idiosyncratic format.
1066     dnl It does know about PDP-10 idiosyncratic format, but this is
1067     dnl not presently supported by GCC. S/390 "binary floating point"
1068     dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
1069     dnl as ASCII?)
1070     dnl
1071     AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
1072     [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
1073     [gcc_AC_EXAMINE_OBJECT(
1074     [/* This will not work unless sizeof(double) == 8. */
1075     extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1076    
1077     /* This structure must have no internal padding. */
1078     struct possibility {
1079     char prefix[8];
1080     double candidate;
1081     char postfix[8];
1082     };
1083    
1084     #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1085     struct possibility table [] =
1086     {
1087     C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1088     C( 3.53802595280598432000e+18), /* D__float - VAX */
1089     C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1090     C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1091     C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
1092     };],
1093     [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1094     ac_cv_c_float_format='IEEE (big-endian)'
1095     elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1096     ac_cv_c_float_format='IEEE (big-endian)'
1097     elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1098     ac_cv_c_float_format='IEEE (little-endian)'
1099     elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1100     ac_cv_c_float_format='IEEE (little-endian)'
1101     elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1102     ac_cv_c_float_format='VAX D-float'
1103     elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1104     ac_cv_c_float_format='PDP-10'
1105     elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1106     ac_cv_c_float_format='IBM 370 hex'
1107 nigel 1.1 else
1108 nigel 1.5 AC_MSG_ERROR(Unknown floating point format)
1109     fi],
1110     [AC_MSG_ERROR(compile failed)])
1111     ])
1112     # IEEE is the default format. If the float endianness isn't the same
1113     # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1114     # (which is a tristate: yes, no, default). This is only an issue with
1115     # IEEE; the other formats are only supported by a few machines each,
1116     # all with the same endianness.
1117     format=IEEE_FLOAT_FORMAT
1118     fbigend=
1119     case $ac_cv_c_float_format in
1120     'IEEE (big-endian)' )
1121     if test $ac_cv_c_bigendian = no; then
1122     fbigend=1
1123     fi
1124     ;;
1125     'IEEE (little-endian)' )
1126     if test $ac_cv_c_bigendian = yes; then
1127     fbigend=0
1128     fi
1129     ;;
1130     'VAX D-float' )
1131     format=VAX_FLOAT_FORMAT
1132     ;;
1133     'PDP-10' )
1134     format=PDP10_FLOAT_FORMAT
1135     ;;
1136     'IBM 370 hex' )
1137     format=IBM_FLOAT_FORMAT
1138     ;;
1139     esac
1140     AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1141     [Define to the floating point format of the host machine.])
1142     if test -n "$fbigend"; then
1143     AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1144     [Define to 1 if the host machine stores floating point numbers in
1145     memory with the word containing the sign bit at the lowest address,
1146     or to 0 if it does it the other way around.
1147    
1148     This macro should not be defined if the ordering is the same as for
1149     multi-word integers.])
1150 nigel 1.1 fi
1151 nigel 1.5 ])
1152 nigel 1.1
1153 nigel 1.5 dnl Select appropriate FPU source.
1154     gcc_AC_C_FLOAT_FORMAT
1155     AC_CHECK_HEADERS(ieee754.h ieeefp.h floatingpoint.h nan.h)
1156    
1157     for fpe in $FPE_CORE_TEST_ORDER; do
1158     case $fpe in
1159     ieee)
1160     case $ac_cv_c_float_format in
1161     IEEE*)
1162     FPE_CORE="IEEE fpu core"
1163     DEFINES="$DEFINES -DFPU_IEEE"
1164 nigel 1.13 AC_DEFINE(FPU_IEEE, 1, [Floating Point Core emulation method is IEEE.])
1165 nigel 1.5 FPUSRCS="../uae_cpu/fpu/fpu_ieee.cpp"
1166     dnl Math functions not mandated by C99 standard
1167     AC_CHECK_FUNCS(isnanl isinfl)
1168     dnl Math functions required by C99 standard, but probably not
1169     dnl implemented everywhere. In that case, we fall back to the
1170     dnl regular variant for doubles.
1171     AC_CHECK_FUNCS(logl log10l expl powl fabsl sqrtl)
1172     AC_CHECK_FUNCS(sinl cosl tanl sinhl coshl tanhl)
1173     AC_CHECK_FUNCS(asinl acosl atanl asinhl acoshl atanhl)
1174     AC_CHECK_FUNCS(floorl ceill)
1175     break
1176     ;;
1177     esac
1178     ;;
1179     x86)
1180     if [[ ":$HAVE_GCC27:$HAVE_I386:$HAVE_GAS:" = ":yes:yes:yes:" ]]; then
1181     FPE_CORE="i387 fpu core"
1182     DEFINES="$DEFINES -DFPU_X86"
1183     FPUSRCS="../uae_cpu/fpu/fpu_x86.cpp"
1184     break
1185     fi
1186     ;;
1187     uae)
1188     FPE_CORE="uae fpu core"
1189     DEFINES="$DEFINES -DFPU_UAE"
1190 nigel 1.13 AC_DEFINE(FPU_UAE, 1, [Floating Point Core emulation is standard UAE.])
1191 nigel 1.5 FPUSRCS="../uae_cpu/fpu/fpu_uae.cpp"
1192     break
1193     ;;
1194     *)
1195     AC_MSG_ERROR([Internal configure.in script error for $fpe fpu core])
1196     ;;
1197     esac
1198     done
1199     if [[ "x$FPE_CORE" = "x" ]]; then
1200     AC_MSG_ERROR([Sorry, no suitable FPU core found in $FPE_CORE_TEST_ORDER])
1201 nigel 1.1 fi
1202    
1203     dnl Check for certain math functions
1204     AC_CHECK_FUNCS(atanh)
1205 nigel 1.5 AC_CHECK_FUNCS(isnan isinf finite isnormal signbit)
1206 nigel 1.1
1207     dnl UAE CPU sources for all non-m68k-native architectures.
1208     CPUINCLUDES="-I../uae_cpu"
1209 nigel 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"
1210 nigel 1.1
1211     dnl Remove the "-g" option if set for GCC.
1212     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
1213 nigel 1.17 CFLAGS=`echo $CFLAGS | sed -e 's/-g\b//g'`
1214     CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g\b//g'`
1215 nigel 1.1 fi
1216    
1217 nigel 1.10 dnl Or if we have -IPA (MIPSPro compilers)
1218     if [[ "x$HAVE_IPA" = "xyes" ]]; then
1219     CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1220     CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1221 nigel 1.1 CXXFLAGS="-LANG:std $CXXFLAGS"
1222 nigel 1.10 LDFLAGS="$LDFLAGS -O3 -OPT:Olimit=0 -IPA"
1223 nigel 1.1 fi
1224    
1225 nigel 1.14 dnl
1226     dnl Some Mac OS X specific stuff:
1227     dnl
1228    
1229     dnl MacOS 10.2 (and later?) have a particular header for defining the OS version
1230     if [[ "x$ac_cv_header_AvailabilityMacros_h" = "xyes" ]]; then
1231     AC_DEFINE(AVAILABILITYMACROS, 1, [Header specific to 10.2 and later.])
1232     fi
1233    
1234     dnl Which IDE do we use?
1235 nigel 1.15 if test -d "/Developer/Applications/Xcode.app"; then
1236 nigel 1.14 IDE=xcodebuild
1237     PROJECT=BasiliskII.xcode
1238     IDEARGS="-project BasiliskII.xcode"
1239     else
1240     IDE=pbxbuild
1241     PROJECT=BasiliskII.pbproj
1242     IDEARGS=""
1243     fi
1244    
1245 nigel 1.17 AC_DEFINE(HAVE_SLIRP, 1, [Try to compile network emulation library!])
1246     AC_DEFINE(DATADIR, "~", [unix_ether needs this!])
1247    
1248 nigel 1.1 dnl Generate Makefile.
1249     AC_SUBST(DEFINES)
1250 gbeauche 1.23 AC_SUBST(MONSRCS)
1251 nigel 1.1 AC_SUBST(CPUINCLUDES)
1252     AC_SUBST(CPUSRCS)
1253 nigel 1.12 AC_SUBST(BLESS)
1254 nigel 1.14 AC_SUBST(IDE)
1255     AC_SUBST(PROJECT)
1256     AC_SUBST(IDEARGS)
1257 nigel 1.17 AC_SUBST(SLIRP_SRCS)
1258 nigel 1.18 AC_SUBST(KEYCODES)
1259 gbeauche 1.23 AC_SUBST(WANT_JIT)
1260     AC_SUBST(WANT_JIT_DEBUG)
1261 nigel 1.11 dnl autoconf on 10.1 doesn't understand these
1262     dnl AC_CONFIG_FILES([Makefile])
1263     dnl AC_OUTPUT
1264 nigel 1.1 AC_OUTPUT(Makefile)
1265    
1266     dnl Print summary.
1267     echo
1268     echo Basilisk II configuration summary:
1269     echo
1270 nigel 1.8 echo Multiple emulator windows .............. : $ENABLE_MULTIPLE
1271 nigel 1.5 echo Enable video on SEGV signals ........... : $WANT_VOSF
1272     echo mon debugger support ................... : $WANT_MON
1273 gbeauche 1.23 echo Build JIT compiler ..................... : $WANT_JIT
1274     echo Build JIT with debug code .............. : $WANT_JIT_DEBUG
1275 nigel 1.5 echo Floating-Point emulation core .......... : $FPE_CORE
1276     echo Assembly optimizations ................. : $ASM_OPTIMIZATIONS
1277     echo Addressing mode ........................ : $ADDRESSING_MODE
1278 nigel 1.12 echo Bad memory access recovery type ........ : $sigsegv_recovery
1279 nigel 1.15 echo Mac OS X development environment ....... : $IDE
1280 nigel 1.1 echo
1281 nigel 1.2 echo "Configuration done. Now type \"make\" (or \"make ide\")."