ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/configure.in
Revision: 1.22
Committed: 2007-06-15T09:16:58Z (17 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.21: +5 -1 lines
Log Message:
Build MacOS X binaries only from the command line. Prepare the configure
scripts as follows: [NO_CONFIGURE=1] ../Unix/autogen.sh

Second round will be to build FAT binaries.

File Contents

# User Rev Content
1 nigel 1.10 dnl Mac OS X configuration driver
2 gbeauche 1.22 dnl $Id: configure.in,v 1.21 2007/01/13 18:21:30 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     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"
112 nigel 1.1 CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
113 nigel 1.10 AC_CHECK_LIB(ncurses, tgetent, ,
114     AC_CHECK_LIB(termcap, tgetent, ,
115     AC_CHECK_LIB(termlib, tgetent, ,
116     AC_CHECK_LIB(terminfo, tgetent, ,
117     AC_CHECK_LIB(Hcurses, tgetent, ,
118     AC_CHECK_LIB(curses, tgetent))))))
119 nigel 1.1 AC_CHECK_LIB(readline, readline)
120     else
121     AC_MSG_RESULT(no)
122     AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
123     WANT_MON=no
124     fi
125     fi
126    
127 nigel 1.14 dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL.
128 nigel 1.1 HAVE_PTHREADS=yes
129 nigel 1.14 AC_CHECK_LIB(pthread, pthread_create, , [
130     AC_CHECK_LIB(c_r, pthread_create, , [
131     AC_CHECK_LIB(PTL, pthread_create, , [
132     HAVE_PTHREADS=no
133     ])
134     ])
135     ])
136     dnl OS X does have pthreads, but not in any of the above locations:
137     HAVE_PTHREADS=yes
138     if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
139     AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.])
140     fi
141 nigel 1.17 AC_CHECK_FUNCS(pthread_cond_init)
142     AC_CHECK_FUNCS(pthread_cancel pthread_testcancel)
143 nigel 1.3 AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
144     AC_CHECK_FUNCS(pthread_mutexattr_settype)
145 nigel 1.5 AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
146 nigel 1.1
147     dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
148     SEMSRC=
149     AC_CHECK_FUNCS(sem_init, , [
150     if test "x$HAVE_PTHREADS" = "xyes"; then
151     SEMSRC=posix_sem.cpp
152     fi
153     ])
154    
155 nigel 1.5 dnl We want to enable multiple window support if possible
156 nigel 1.1 if [[ "x$WANT_MWIN" = "xyes" ]]; then
157     WANT_MWIN=yes
158     DEFINES="$DEFINES -DENABLE_MULTIPLE"
159     fi
160    
161 nigel 1.5 dnl We use 64-bit file size support if possible.
162     AC_SYS_LARGEFILE
163    
164 nigel 1.1 dnl Checks for header files.
165     AC_HEADER_STDC
166 nigel 1.17 AC_CHECK_HEADERS(stdlib.h stdint.h)
167 nigel 1.13 AC_CHECK_HEADERS(unistd.h fcntl.h sys/types.h sys/time.h sys/mman.h mach/mach.h)
168 nigel 1.12 AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
169 nigel 1.17 AC_CHECK_HEADERS(sys/socket.h sys/ioctl.h sys/filio.h sys/bitypes.h sys/wait.h)
170     AC_CHECK_HEADERS(sys/poll.h sys/select.h)
171     AC_CHECK_HEADERS(arpa/inet.h)
172     AC_CHECK_HEADERS(linux/if.h linux/if_tun.h net/if.h net/if_tun.h, [], [], [
173     #ifdef HAVE_SYS_TYPES_H
174     #include <sys/types.h>
175     #endif
176     #ifdef HAVE_SYS_SOCKET_H
177     #include <sys/socket.h>
178     #endif
179     ])
180     AC_CHECK_HEADERS(AvailabilityMacros.h)
181 gbeauche 1.16 AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDevice.h)
182 nigel 1.1
183     dnl Checks for typedefs, structures, and compiler characteristics.
184     AC_C_BIGENDIAN
185     AC_C_CONST
186     AC_C_INLINE
187     AC_CHECK_SIZEOF(short, 2)
188     AC_CHECK_SIZEOF(int, 4)
189     AC_CHECK_SIZEOF(long, 4)
190     AC_CHECK_SIZEOF(long long, 8)
191 nigel 1.5 AC_CHECK_SIZEOF(float, 4)
192     AC_CHECK_SIZEOF(double, 8)
193     AC_CHECK_SIZEOF(long double, 12)
194 nigel 1.1 AC_CHECK_SIZEOF(void *, 4)
195 nigel 1.10 AC_TYPE_OFF_T
196 nigel 1.13 dnl These two symbols are not defined in 10.1's autoconf:
197 nigel 1.8 dnl AC_CHECK_TYPE(loff_t, off_t)
198     dnl AC_CHECK_TYPE(caddr_t, [char *])
199     dnl We define loff_t as a typedef of off_t in sysdeps.h if we don't have LOFF_T
200 nigel 1.13 dnl OS X does have caddr_t, but the above check doesn't work, so we have to do:
201     AC_DEFINE(HAVE_CADDR_T, 1, [The type "caddr_t" does exist on MacOS X.])
202 nigel 1.1 AC_TYPE_SIZE_T
203     AC_TYPE_SIGNAL
204     AC_HEADER_TIME
205     AC_STRUCT_TM
206    
207 nigel 1.5 dnl Check whether sys/socket.h defines type socklen_t.
208     dnl (extracted from ac-archive/Miscellaneous)
209     AC_CACHE_CHECK([for socklen_t],
210     ac_cv_type_socklen_t, [
211     AC_TRY_COMPILE([
212     #include <sys/types.h>
213     #include <sys/socket.h>
214     ], [socklen_t len = 42; return 0;],
215     ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no,
216     dnl When cross-compiling, do not assume anything.
217     ac_cv_type_socklen_t="guessing no"
218     )
219     ])
220     if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then
221     AC_DEFINE(socklen_t, int, [Define to 'int' if <sys/types.h> doesn't define.])
222     fi
223    
224 nigel 1.1 dnl Checks for library functions.
225 nigel 1.17 AC_CHECK_FUNCS(strdup strerror cfmakeraw)
226 nigel 1.1 AC_CHECK_FUNCS(clock_gettime timer_create)
227     AC_CHECK_FUNCS(sigaction signal)
228     AC_CHECK_FUNCS(mmap mprotect munmap)
229     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
230 nigel 1.17 AC_CHECK_FUNCS(poll inet_aton)
231 nigel 1.1
232     dnl Darwin seems to define mach_task_self() instead of task_self().
233     AC_CHECK_FUNCS(mach_task_self task_self)
234    
235 nigel 1.17 dnl Check for headers and functions related to pty support (sshpty.c)
236     dnl From openssh-3.2.2p1 configure.ac
237    
238     AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
239     AC_CHECK_FUNCS(_getpty vhangup strlcpy)
240     if test -z "$no_dev_ptmx" ; then
241     if test "x$disable_ptmx_check" != "xyes" ; then
242     AC_CHECK_FILE([/dev/ptmx],
243     [
244     AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.])
245     have_dev_ptmx=1
246     ]
247     )
248     fi
249     fi
250     AC_CHECK_FILE([/dev/ptc],
251     [
252     AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.])
253     have_dev_ptc=1
254     ]
255     )
256    
257     dnl (end of code from openssh-3.2.2p1 configure.ac)
258    
259    
260 nigel 1.19 dnl Check for systems where POSIX-style non-blocking I/O (O_NONBLOCK)
261     dnl doesn't work or is unimplemented. On these systems (mostly older
262     dnl ones), use the old BSD-style FIONBIO approach instead. [tcl.m4]
263     AC_CACHE_CHECK([FIONBIO vs. O_NONBLOCK for non-blocking I/O],
264     ac_cv_nonblocking_io, [
265     case "$host" in
266     *-*-osf*)
267     ac_cv_nonblocking_io=FIONBIO
268     ;;
269     *-*-sunos4*)
270     ac_cv_nonblocking_io=FIONBIO
271     ;;
272     *-*-ultrix*)
273     ac_cv_nonblocking_io=FIONBIO
274     ;;
275     *)
276     ac_cv_nonblocking_io=O_NONBLOCK
277     ;;
278     esac
279     ])
280     if [[ "$ac_cv_nonblocking_io" = "FIONBIO" ]]; then
281     AC_DEFINE(USE_FIONBIO, 1, [Define if BSD-style non-blocking I/O is to be used])
282     fi
283    
284     dnl Check whether compiler supports byte bit-fields
285     AC_CACHE_CHECK([whether compiler supports byte bit-fields],
286     ac_cv_have_byte_bitfields, [
287     AC_LANG_SAVE
288     AC_LANG_CPLUSPLUS
289     AC_TRY_RUN([
290     struct A {
291     unsigned char b1:4;
292     unsigned char b2:4;
293     unsigned char c;
294     unsigned short s;
295     unsigned char a[4];
296     };
297    
298     int main(void) {
299     A a;
300     return ! (sizeof(A) == 8 && &a.c == ((unsigned char *)&a + 1));
301     }],
302     [ac_cv_have_byte_bitfields=yes],
303     [ac_cv_have_byte_bitfields=no],
304     dnl When cross-compiling, assume only GCC supports this
305     [if [[ "$GCC" = "yes" ]]; then
306     ac_cv_have_byte_bitfields="guessing yes"
307     else
308     ac_cv_have_byte_bitfields="guessing no"
309     fi]
310     )
311     AC_LANG_RESTORE
312     ])
313    
314 nigel 1.17 dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
315     AC_DEFUN([AC_CHECK_FRAMEWORK], [
316     AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
317     AC_CACHE_CHECK([whether compiler supports framework $1],
318     ac_Framework, [
319     saved_LIBS="$LIBS"
320     LIBS="$LIBS -framework $1"
321     AC_TRY_LINK(
322 nigel 1.20 [$2], [],
323 nigel 1.17 [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
324     )
325     ])
326     AS_IF([test AS_VAR_GET(ac_Framework) = yes],
327     [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
328     )
329     AS_VAR_POPDEF([ac_Framework])dnl
330     ])
331    
332     dnl Check for some MacOS X frameworks
333 nigel 1.20 AC_CHECK_FRAMEWORK(AppKit, [])
334 nigel 1.17 AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
335     AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
336     AC_CHECK_FRAMEWORK(CoreFoundation, [#include <CoreFoundation/CoreFoundation.h>])
337 gbeauche 1.22 AC_CHECK_FRAMEWORK(CoreAudio, [#include <CoreAudio/CoreAudio.h>])
338     AC_CHECK_FRAMEWORK(AudioUnit, [#include <AudioUnit/AudioUnit.h>])
339     AC_CHECK_FRAMEWORK(AudioToolbox, [#include <AudioToolbox/AudioToolbox.h>])
340 nigel 1.17
341 nigel 1.1 dnl Select system-dependant source files.
342 nigel 1.17 ETHERSRC=ether_unix.cpp
343 nigel 1.13 DEFINES="$DEFINES -DBSD_COMP"
344     CXXFLAGS="$CXXFLAGS -fpermissive"
345 nigel 1.1 dnl Check for the CAM library
346 nigel 1.5 AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no)
347 nigel 1.1 if [[ "x$HAVE_LIBCAM" = "xno" ]]; then
348     AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.])
349 nigel 1.5 else
350     dnl Check for the sys kernel includes
351 nigel 1.1 AC_CHECK_HEADER(camlib.h)
352     if [[ "x$ac_cv_header_camlib_h" = "xno" ]]; then
353     dnl In this case I should fix this thing including a "patch"
354     dnl to access directly to the functions in the kernel :) --Orlando
355     AC_MSG_WARN([Cannot find includes for CAM library, disabling SCSI support.])
356     else
357     SCSISRC=FreeBSD/scsi_freebsd.cpp
358     LIBS="$LIBS -lcam"
359     DEFINES="$DEFINES -DCAM"
360     fi
361     fi
362    
363 nigel 1.17 dnl Is the slirp library supported?
364 nigel 1.19 case "$ac_cv_have_byte_bitfields" in
365     yes|"guessing yes")
366     CAN_SLIRP=yes
367     ETHERSRC=ether_unix.cpp
368     ;;
369     esac
370     if [[ -n "$CAN_SLIRP" ]]; then
371 nigel 1.17 AC_DEFINE(HAVE_SLIRP, 1, [Define if slirp library is supported])
372     SLIRP_SRCS="\
373     ../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \
374     ../slirp/cksum.c ../slirp/mbuf.c ../slirp/tcp_output.c \
375     ../slirp/debug.c ../slirp/misc.c ../slirp/tcp_subr.c \
376     ../slirp/if.c ../slirp/sbuf.c ../slirp/tcp_timer.c \
377     ../slirp/ip_icmp.c ../slirp/slirp.c ../slirp/tftp.c \
378     ../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c"
379     fi
380     AC_SUBST(SLIRP_SRCS)
381    
382 nigel 1.1 dnl Use 68k CPU natively?
383     WANT_NATIVE_M68K=no
384    
385    
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     if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
802     ADDRESSING_MODE="real"
803     else
804     ADDRESSING_MODE=""
805     AC_MSG_CHECKING([for the addressing mode to use])
806     for am in $ADDRESSING_TEST_ORDER; do
807     case $am in
808     real)
809     dnl Requires ability to mmap() Low Memory globals
810 nigel 1.12 if [[ "x$ac_cv_can_map_lm$ac_cv_pagezero_hack" = "xnono" ]]; then
811 nigel 1.1 continue
812     fi
813 nigel 1.12 dnl Requires VOSF screen updates
814 nigel 1.1 if [[ "x$CAN_VOSF" = "xno" ]]; then
815     continue
816     fi
817     dnl Real addressing will probably work.
818     ADDRESSING_MODE="real"
819     WANT_VOSF=yes dnl we can use VOSF and we need it actually
820     DEFINES="$DEFINES -DREAL_ADDRESSING"
821 nigel 1.13 AC_DEFINE(REAL_ADDRESSING, 1, [Emulated memory is memory mapped to actual address.])
822 nigel 1.12 if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
823     BLESS=Darwin/lowmem
824     LDFLAGS="$LDFLAGS -pagezero_size 0x2000"
825     fi
826 nigel 1.1 break
827     ;;
828     direct)
829     dnl Requires VOSF screen updates
830     if [[ "x$CAN_VOSF" = "xyes" ]]; then
831     ADDRESSING_MODE="direct"
832     WANT_VOSF=yes dnl we can use VOSF and we need it actually
833     DEFINES="$DEFINES -DDIRECT_ADDRESSING"
834 nigel 1.13 AC_DEFINE(DIRECT_ADDRESSING, 1, [Emulated memory is an offset from actual address.])
835 nigel 1.1 break
836     fi
837     ;;
838     banks)
839     dnl Default addressing mode
840     ADDRESSING_MODE="memory banks"
841     break
842     ;;
843     *)
844     AC_MSG_ERROR([Internal configure.in script error for $am addressing mode])
845     esac
846     done
847     AC_MSG_RESULT($ADDRESSING_MODE)
848     if [[ "x$ADDRESSING_MODE" = "x" ]]; then
849     AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER])
850     ADDRESSING_MODE="memory banks"
851     fi
852     fi
853    
854 nigel 1.5 dnl Banked Memory Addressing mode is not supported by the JIT compiler
855     if [[ "x$WANT_JIT" = "xyes" -a "x$ADDRESSING_MODE" = "xmemory banks" ]]; then
856     AC_MSG_ERROR([Sorry, the JIT Compiler requires Direct Addressing, at least])
857     fi
858    
859 nigel 1.1 dnl Enable VOSF screen updates with this feature is requested and feasible
860     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
861 nigel 1.5 AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
862 nigel 1.1 else
863     WANT_VOSF=no
864     fi
865    
866     dnl Check for GAS.
867     HAVE_GAS=no
868     AC_MSG_CHECKING(for GAS .p2align feature)
869     cat >conftest.S << EOF
870     .text
871     .p2align 5
872     EOF
873     if $CC conftest.S -c -o conftest.o >/dev/null 2>&1 ; then HAVE_GAS=yes; fi
874     AC_MSG_RESULT($HAVE_GAS)
875    
876     dnl Check for GCC 2.7 or higher.
877     HAVE_GCC27=no
878     AC_MSG_CHECKING(for GCC 2.7 or higher)
879 nigel 1.17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5)
880     # error gcc < 2.7
881     #endif
882     ]])],
883     [AC_MSG_RESULT(yes); HAVE_GCC27=yes],
884     [AC_MSG_RESULT(no)])
885 nigel 1.1
886     dnl Check for GCC 3.0 or higher.
887     HAVE_GCC30=no
888     AC_MSG_CHECKING(for GCC 3.0 or higher)
889 nigel 1.17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ >= 3)
890     # error gcc < 3
891     #endif
892     ]])],
893     [AC_MSG_RESULT(yes); HAVE_GCC30=yes],
894     [AC_MSG_RESULT(no)])
895    
896     dnl Check for ICC.
897     AC_MSG_CHECKING(for ICC)
898     HAVE_ICC=no
899     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
900     HAVE_ICC=yes
901     fi
902     AC_MSG_RESULT($HAVE_ICC)
903 nigel 1.1
904     dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher.
905 nigel 1.3 dnl Also set "-fno-exceptions" for C++ because exception handling requires
906     dnl the frame pointer.
907 nigel 1.1 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
908     CFLAGS="$CFLAGS -fomit-frame-pointer"
909 nigel 1.3 CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -fno-exceptions"
910 nigel 1.1 fi
911    
912     dnl (gb) Do not merge constants since it breaks fpu/fpu_x86.cpp.
913     dnl As of 2001/08/02, this affects the following compilers:
914     dnl Official: probably gcc-3.1 (mainline CVS)
915     dnl Mandrake: gcc-2.96 >= 0.59mdk, gcc-3.0.1 >= 0.1mdk
916     dnl Red Hat : gcc-2.96 >= 89, gcc-3.0 >= 1
917 nigel 1.17 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
918 nigel 1.1 SAVED_CXXFLAGS="$CXXFLAGS"
919     CXXFLAGS="$CXXFLAGS -fno-merge-constants"
920     AC_CACHE_CHECK([whether GCC supports constants merging], ac_cv_gcc_constants_merging, [
921     AC_LANG_SAVE
922     AC_LANG_CPLUSPLUS
923     AC_TRY_COMPILE([],[],[ac_cv_gcc_constants_merging=yes],[ac_cv_gcc_constants_merging=no])
924     AC_LANG_RESTORE
925     ])
926     if [[ "x$ac_cv_gcc_constants_merging" != "xyes" ]]; then
927     CXXFLAGS="$SAVED_CXXFLAGS"
928     fi
929     fi
930    
931 nigel 1.17 dnl Store motion was introduced in 3.3-hammer branch and any gcc >= 3.4
932     dnl However, there are some corner cases exposed on x86-64
933     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
934     SAVED_CXXFLAGS="$CXXFLAGS"
935     CXXFLAGS="$CXXFLAGS -fno-gcse-sm"
936     AC_CACHE_CHECK([whether GCC supports store motion], ac_cv_gcc_store_motion, [
937     AC_LANG_SAVE
938     AC_LANG_CPLUSPLUS
939     AC_TRY_COMPILE([],[],[ac_cv_gcc_store_motion=yes],[ac_cv_gcc_store_motion=no])
940     AC_LANG_RESTORE
941     ])
942     if [[ "x$ac_cv_gcc_store_motion" != "xyes" ]]; then
943     CXXFLAGS="$SAVED_CXXFLAGS"
944     fi
945     fi
946    
947     dnl Add -fno-strict-aliasing for slirp sources
948     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
949     SAVED_CFLAGS="$CFLAGS"
950     CFLAGS="$CFLAGS -fno-strict-aliasing"
951     AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
952     ac_cv_gcc_no_strict_aliasing, [
953     AC_TRY_COMPILE([],[],
954     [ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
955     [ac_cv_gcc_no_strict_aliasing=no])
956     ])
957     CFLAGS="$SAVED_CFLAGS"
958     fi
959    
960 nigel 1.18 dnl Add -mdynamic-no-pic for MacOS X (XXX icc10 will support MacOS X)
961     if [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
962 nigel 1.17 SAVED_CFLAGS="$CFLAGS"
963     CFLAGS="$CFLAGS -mdynamic-no-pic"
964     AC_CACHE_CHECK([whether the compiler supports -mdynamic-no-pic],
965     ac_cv_gcc_mdynamic_no_pic, [
966     AC_TRY_COMPILE([],[],[ac_cv_gcc_mdynamic_no_pic=yes],[ac_cv_gcc_mdynamic_no_pic=no])
967     ])
968     if [[ "x$ac_cv_gcc_mdynamic_no_pic" = "xyes" ]]; then
969     CXXFLAGS="$CXXFLAGS -mdynamic-no-pic"
970     else
971     CFLAGS="$SAVED_CFLAGS"
972     fi
973     fi
974    
975 nigel 1.1 dnl Select appropriate CPU source and REGPARAM define.
976     ASM_OPTIMIZATIONS=none
977     CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
978 nigel 1.5
979     dnl (gb) JITSRCS will be emptied later if the JIT is not available
980     dnl Other platforms should define their own set of noflags file variants
981     CAN_JIT=no
982     JITSRCS="compemu1.cpp compemu2.cpp compemu3.cpp compemu4.cpp compemu5.cpp compemu6.cpp compemu7.cpp compemu8.cpp"
983    
984 nigel 1.10 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
985 nigel 1.1 dnl i386 CPU
986 nigel 1.5 DEFINES="$DEFINES -DUNALIGNED_PROFITABLE -DREGPARAM=\"__attribute__((regparm(3)))\""
987 nigel 1.1 if [[ "x$HAVE_GAS" = "xyes" ]]; then
988     ASM_OPTIMIZATIONS=i386
989 nigel 1.5 DEFINES="$DEFINES -DX86_ASSEMBLY -DOPTIMIZED_FLAGS -DSAHF_SETO_PROFITABLE"
990 nigel 1.10 JITSRCS="cpuemu1_nf.cpp cpuemu2_nf.cpp cpuemu3_nf.cpp cpuemu4_nf.cpp cpuemu5_nf.cpp cpuemu6_nf.cpp cpuemu7_nf.cpp cpuemu8_nf.cpp $JITSRCS"
991     CAN_JIT=yes
992     fi
993     elif [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_X86_64" = "xyes" ]]; then
994     dnl x86-64 CPU
995     DEFINES="$DEFINES -DUNALIGNED_PROFITABLE"
996     if [[ "x$HAVE_GAS" = "xyes" ]]; then
997     ASM_OPTIMIZATIONS="x86-64"
998     DEFINES="$DEFINES -DX86_64_ASSEMBLY -DOPTIMIZED_FLAGS"
999 nigel 1.17 JITSRCS="cpuemu1_nf.cpp cpuemu2_nf.cpp cpuemu3_nf.cpp cpuemu4_nf.cpp cpuemu5_nf.cpp cpuemu6_nf.cpp cpuemu7_nf.cpp cpuemu8_nf.cpp $JITSRCS"
1000     CAN_JIT=yes
1001 nigel 1.1 fi
1002     elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
1003     dnl SPARC CPU
1004     case "$target_os" in
1005     solaris*)
1006     AC_MSG_CHECKING(SPARC CPU architecture)
1007     SPARC_TYPE=`Solaris/which_sparc`
1008     AC_MSG_RESULT($SPARC_TYPE)
1009     case "$SPARC_TYPE" in
1010     SPARC_V8)
1011     ASM_OPTIMIZATIONS="SPARC V8 architecture"
1012     DEFINES="$DEFINES -DSPARC_V8_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
1013     CFLAGS="$CFLAGS -Wa,-Av8"
1014     CXXFLAGS="$CXXFLAGS -Wa,-Av8"
1015     ;;
1016     SPARC_V9)
1017     ASM_OPTIMIZATIONS="SPARC V9 architecture"
1018     DEFINES="$DEFINES -DSPARC_V9_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
1019     CFLAGS="$CFLAGS -Wa,-Av9"
1020     CXXFLAGS="$CXXFLAGS -Wa,-Av9"
1021     ;;
1022     esac
1023     ;;
1024     esac
1025     elif [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
1026     dnl Native m68k, no emulation
1027     CPUINCLUDES="-I../native_cpu"
1028     CPUSRCS="asm_support.s"
1029     fi
1030    
1031 nigel 1.5 dnl Enable JIT compiler, if possible.
1032     if [[ "x$WANT_JIT" = "xyes" -a "x$CAN_JIT" ]]; then
1033     JITSRCS="$JITSRCS ../uae_cpu/compiler/compemu_support.cpp ../uae_cpu/compiler/compemu_fpp.cpp compstbl.o cpustbl_nf.o"
1034     DEFINES="$DEFINES -DUSE_JIT -DUSE_JIT_FPU"
1035    
1036     if [[ "x$WANT_JIT_DEBUG" = "xyes" ]]; then
1037     if [[ "x$WANT_MON" = "xyes" ]]; then
1038     DEFINES="$DEFINES -DJIT_DEBUG=1"
1039     else
1040     AC_MSG_WARN([cxmon not found, ignoring --enable-jit-debug])
1041     WANT_JIT_DEBUG=no
1042     fi
1043     fi
1044    
1045     dnl IEEE core is the only FPU emulator to use with the JIT compiler
1046     case $FPE_CORE_TEST_ORDER in
1047     ieee*) ;;
1048     *) AC_MSG_WARN([Forcing use of the IEEE FPU core, as the JIT compiler supports only this one.]) ;;
1049     esac
1050     FPE_CORE_TEST_ORDER="ieee"
1051     else
1052     WANT_JIT=no
1053     WANT_JIT_DEBUG=no
1054     JITSRCS=""
1055     fi
1056    
1057     dnl Utility macro used by next two tests.
1058     dnl AC_EXAMINE_OBJECT(C source code,
1059     dnl commands examining object file,
1060     dnl [commands to run if compile failed]):
1061     dnl
1062     dnl Compile the source code to an object file; then convert it into a
1063     dnl printable representation. All unprintable characters and
1064     dnl asterisks (*) are replaced by dots (.). All white space is
1065     dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
1066     dnl output, but runs of newlines are compressed to a single newline.
1067     dnl Finally, line breaks are forcibly inserted so that no line is
1068     dnl longer than 80 columns and the file ends with a newline. The
1069     dnl result of all this processing is in the file conftest.dmp, which
1070     dnl may be examined by the commands in the second argument.
1071     dnl
1072     AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
1073     [AC_LANG_SAVE
1074     AC_LANG_C
1075     dnl Next bit cribbed from AC_TRY_COMPILE.
1076     cat > conftest.$ac_ext <<EOF
1077     [#line __oline__ "configure"
1078     #include "confdefs.h"
1079     $1
1080     ]EOF
1081     if AC_TRY_EVAL(ac_compile); then
1082     od -c conftest.o |
1083     sed ['s/^[0-7]*[ ]*/ /
1084     s/\*/./g
1085     s/ \\n/*/g
1086     s/ [0-9][0-9][0-9]/./g
1087     s/ \\[^ ]/./g'] |
1088     tr -d '
1089     ' | tr -s '*' '
1090     ' | fold | sed '$a\
1091     ' > conftest.dmp
1092     $2
1093     ifelse($3, , , else
1094     $3
1095     )dnl
1096     fi
1097     rm -rf conftest*
1098     AC_LANG_RESTORE])
1099    
1100     dnl Floating point format probe.
1101     dnl The basic concept is the same as the above: grep the object
1102     dnl file for an interesting string. We have to watch out for
1103     dnl rounding changing the values in the object, however; this is
1104     dnl handled by ignoring the least significant byte of the float.
1105     dnl
1106     dnl Does not know about VAX G-float or C4x idiosyncratic format.
1107     dnl It does know about PDP-10 idiosyncratic format, but this is
1108     dnl not presently supported by GCC. S/390 "binary floating point"
1109     dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
1110     dnl as ASCII?)
1111     dnl
1112     AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
1113     [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
1114     [gcc_AC_EXAMINE_OBJECT(
1115     [/* This will not work unless sizeof(double) == 8. */
1116     extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1117    
1118     /* This structure must have no internal padding. */
1119     struct possibility {
1120     char prefix[8];
1121     double candidate;
1122     char postfix[8];
1123     };
1124    
1125     #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1126     struct possibility table [] =
1127     {
1128     C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1129     C( 3.53802595280598432000e+18), /* D__float - VAX */
1130     C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1131     C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1132     C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
1133     };],
1134     [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1135     ac_cv_c_float_format='IEEE (big-endian)'
1136     elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1137     ac_cv_c_float_format='IEEE (big-endian)'
1138     elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1139     ac_cv_c_float_format='IEEE (little-endian)'
1140     elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1141     ac_cv_c_float_format='IEEE (little-endian)'
1142     elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1143     ac_cv_c_float_format='VAX D-float'
1144     elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1145     ac_cv_c_float_format='PDP-10'
1146     elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1147     ac_cv_c_float_format='IBM 370 hex'
1148 nigel 1.1 else
1149 nigel 1.5 AC_MSG_ERROR(Unknown floating point format)
1150     fi],
1151     [AC_MSG_ERROR(compile failed)])
1152     ])
1153     # IEEE is the default format. If the float endianness isn't the same
1154     # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1155     # (which is a tristate: yes, no, default). This is only an issue with
1156     # IEEE; the other formats are only supported by a few machines each,
1157     # all with the same endianness.
1158     format=IEEE_FLOAT_FORMAT
1159     fbigend=
1160     case $ac_cv_c_float_format in
1161     'IEEE (big-endian)' )
1162     if test $ac_cv_c_bigendian = no; then
1163     fbigend=1
1164     fi
1165     ;;
1166     'IEEE (little-endian)' )
1167     if test $ac_cv_c_bigendian = yes; then
1168     fbigend=0
1169     fi
1170     ;;
1171     'VAX D-float' )
1172     format=VAX_FLOAT_FORMAT
1173     ;;
1174     'PDP-10' )
1175     format=PDP10_FLOAT_FORMAT
1176     ;;
1177     'IBM 370 hex' )
1178     format=IBM_FLOAT_FORMAT
1179     ;;
1180     esac
1181     AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1182     [Define to the floating point format of the host machine.])
1183     if test -n "$fbigend"; then
1184     AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1185     [Define to 1 if the host machine stores floating point numbers in
1186     memory with the word containing the sign bit at the lowest address,
1187     or to 0 if it does it the other way around.
1188    
1189     This macro should not be defined if the ordering is the same as for
1190     multi-word integers.])
1191 nigel 1.1 fi
1192 nigel 1.5 ])
1193 nigel 1.1
1194 nigel 1.5 dnl Select appropriate FPU source.
1195     gcc_AC_C_FLOAT_FORMAT
1196     AC_CHECK_HEADERS(ieee754.h ieeefp.h floatingpoint.h nan.h)
1197    
1198     for fpe in $FPE_CORE_TEST_ORDER; do
1199     case $fpe in
1200     ieee)
1201     case $ac_cv_c_float_format in
1202     IEEE*)
1203     FPE_CORE="IEEE fpu core"
1204     DEFINES="$DEFINES -DFPU_IEEE"
1205 nigel 1.13 AC_DEFINE(FPU_IEEE, 1, [Floating Point Core emulation method is IEEE.])
1206 nigel 1.5 FPUSRCS="../uae_cpu/fpu/fpu_ieee.cpp"
1207     dnl Math functions not mandated by C99 standard
1208     AC_CHECK_FUNCS(isnanl isinfl)
1209     dnl Math functions required by C99 standard, but probably not
1210     dnl implemented everywhere. In that case, we fall back to the
1211     dnl regular variant for doubles.
1212     AC_CHECK_FUNCS(logl log10l expl powl fabsl sqrtl)
1213     AC_CHECK_FUNCS(sinl cosl tanl sinhl coshl tanhl)
1214     AC_CHECK_FUNCS(asinl acosl atanl asinhl acoshl atanhl)
1215     AC_CHECK_FUNCS(floorl ceill)
1216     break
1217     ;;
1218     esac
1219     ;;
1220     x86)
1221     if [[ ":$HAVE_GCC27:$HAVE_I386:$HAVE_GAS:" = ":yes:yes:yes:" ]]; then
1222     FPE_CORE="i387 fpu core"
1223     DEFINES="$DEFINES -DFPU_X86"
1224     FPUSRCS="../uae_cpu/fpu/fpu_x86.cpp"
1225     break
1226     fi
1227     ;;
1228     uae)
1229     FPE_CORE="uae fpu core"
1230     DEFINES="$DEFINES -DFPU_UAE"
1231 nigel 1.13 AC_DEFINE(FPU_UAE, 1, [Floating Point Core emulation is standard UAE.])
1232 nigel 1.5 FPUSRCS="../uae_cpu/fpu/fpu_uae.cpp"
1233     break
1234     ;;
1235     *)
1236     AC_MSG_ERROR([Internal configure.in script error for $fpe fpu core])
1237     ;;
1238     esac
1239     done
1240     if [[ "x$FPE_CORE" = "x" ]]; then
1241     AC_MSG_ERROR([Sorry, no suitable FPU core found in $FPE_CORE_TEST_ORDER])
1242 nigel 1.1 fi
1243    
1244     dnl Check for certain math functions
1245     AC_CHECK_FUNCS(atanh)
1246 nigel 1.5 AC_CHECK_FUNCS(isnan isinf finite isnormal signbit)
1247 nigel 1.1
1248     dnl UAE CPU sources for all non-m68k-native architectures.
1249     if [[ "x$WANT_NATIVE_M68K" = "xno" ]]; then
1250     CPUINCLUDES="-I../uae_cpu"
1251 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"
1252 nigel 1.1 fi
1253    
1254     dnl Remove the "-g" option if set for GCC.
1255     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
1256 nigel 1.17 CFLAGS=`echo $CFLAGS | sed -e 's/-g\b//g'`
1257     CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g\b//g'`
1258 nigel 1.1 fi
1259    
1260 nigel 1.10 dnl Or if we have -IPA (MIPSPro compilers)
1261     if [[ "x$HAVE_IPA" = "xyes" ]]; then
1262     CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1263     CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1264 nigel 1.1 CXXFLAGS="-LANG:std $CXXFLAGS"
1265 nigel 1.10 LDFLAGS="$LDFLAGS -O3 -OPT:Olimit=0 -IPA"
1266 nigel 1.1 fi
1267    
1268 nigel 1.14 dnl
1269     dnl Some Mac OS X specific stuff:
1270     dnl
1271    
1272     dnl MacOS 10.2 (and later?) have a particular header for defining the OS version
1273     if [[ "x$ac_cv_header_AvailabilityMacros_h" = "xyes" ]]; then
1274     AC_DEFINE(AVAILABILITYMACROS, 1, [Header specific to 10.2 and later.])
1275     fi
1276    
1277     dnl Which IDE do we use?
1278 nigel 1.15 if test -d "/Developer/Applications/Xcode.app"; then
1279 nigel 1.14 IDE=xcodebuild
1280     PROJECT=BasiliskII.xcode
1281     IDEARGS="-project BasiliskII.xcode"
1282     else
1283     IDE=pbxbuild
1284     PROJECT=BasiliskII.pbproj
1285     IDEARGS=""
1286     fi
1287    
1288 nigel 1.17 AC_DEFINE(HAVE_SLIRP, 1, [Try to compile network emulation library!])
1289     AC_DEFINE(DATADIR, "~", [unix_ether needs this!])
1290    
1291 nigel 1.1 dnl Generate Makefile.
1292     AC_SUBST(DEFINES)
1293     AC_SUBST(SYSSRCS)
1294     AC_SUBST(CPUINCLUDES)
1295     AC_SUBST(CPUSRCS)
1296 nigel 1.12 AC_SUBST(BLESS)
1297 nigel 1.14 AC_SUBST(IDE)
1298     AC_SUBST(PROJECT)
1299     AC_SUBST(IDEARGS)
1300 nigel 1.17 AC_SUBST(SLIRP_SRCS)
1301 nigel 1.18 AC_SUBST(KEYCODES)
1302 nigel 1.11 dnl autoconf on 10.1 doesn't understand these
1303     dnl AC_CONFIG_FILES([Makefile])
1304     dnl AC_OUTPUT
1305 nigel 1.1 AC_OUTPUT(Makefile)
1306    
1307     dnl Print summary.
1308     echo
1309     echo Basilisk II configuration summary:
1310     echo
1311 nigel 1.8 echo Multiple emulator windows .............. : $ENABLE_MULTIPLE
1312 nigel 1.5 echo Enable video on SEGV signals ........... : $WANT_VOSF
1313     echo mon debugger support ................... : $WANT_MON
1314 nigel 1.17 echo Running m68k code natively ............. : $WANT_NATIVE_M68K
1315 nigel 1.5 echo Use JIT compiler ....................... : $WANT_JIT
1316     echo JIT debug mode ......................... : $WANT_JIT_DEBUG
1317     echo Floating-Point emulation core .......... : $FPE_CORE
1318     echo Assembly optimizations ................. : $ASM_OPTIMIZATIONS
1319     echo Addressing mode ........................ : $ADDRESSING_MODE
1320 nigel 1.12 echo Bad memory access recovery type ........ : $sigsegv_recovery
1321 nigel 1.15 echo Mac OS X development environment ....... : $IDE
1322 nigel 1.1 echo
1323 nigel 1.2 echo "Configuration done. Now type \"make\" (or \"make ide\")."