ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/configure.in
Revision: 1.26
Committed: 2007-06-15T22:54:23Z (17 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.25: +5 -274 lines
Log Message:
Fix REAL_ADDRESSING mode on MacOS X, aka move Mach defines to config_macosx.h
and fix lowmem (BLESS) to handle other-endian binaries.

File Contents

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