ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/configure.in
Revision: 1.17
Committed: 2005-09-19T07:45:07Z (19 years, 1 month ago) by nigel
Branch: MAIN
Changes since 1.16: +233 -19 lines
Log Message:
Re-sync with Unix version. Fixes black screen bug

File Contents

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