ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.65
Committed: 2006-03-25T07:08:50Z (18 years, 7 months ago) by gbeauche
Branch: MAIN
Changes since 1.64: +2 -1 lines
Log Message:
- add Linux/PPC linker script
- always relocate Basilisk II binary to 0x78048000 on MacOS X (including x86,
  to be tested later)

File Contents

# User Rev Content
1 gbeauche 1.1 dnl Process this file with autoconf to produce a configure script.
2     dnl Written in 2002 by Christian Bauer et al.
3    
4 cebix 1.16 AC_INIT([Basilisk II], 1.0, [Christian.Bauer@uni-mainz.de], BasiliskII)
5     AC_CONFIG_SRCDIR(main_unix.cpp)
6 gbeauche 1.1 AC_PREREQ(2.52)
7     AC_CONFIG_HEADER(config.h)
8    
9 gbeauche 1.19 dnl Aliases for PACKAGE and VERSION macros.
10 gbeauche 1.22 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE_NAME", [Define this program name.])
11     AC_DEFINE_UNQUOTED(VERSION, "$PACKAGE_VERSION", [Define this program version.])
12 gbeauche 1.19
13 gbeauche 1.21 dnl Some systems do not put corefiles in the currect directory, avoid saving
14     dnl cores for the configure tests since some are intended to dump core.
15     ulimit -c 0
16    
17 gbeauche 1.5 dnl Video options.
18 gbeauche 1.1 AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes])
19     AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=yes]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=yes])
20     AC_ARG_ENABLE(fbdev-dga, [ --enable-fbdev-dga use direct frame buffer access via /dev/fb [default=yes]], [WANT_FBDEV_DGA=$enableval], [WANT_FBDEV_DGA=yes])
21     AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes])
22    
23 gbeauche 1.26 dnl SDL options.
24 gbeauche 1.41 AC_ARG_ENABLE(sdl-static, [ --enable-sdl-static use SDL static libraries for linking [default=no]], [WANT_SDL_STATIC=$enableval], [WANT_SDL_STATIC=no])
25 gbeauche 1.26 AC_ARG_ENABLE(sdl-video, [ --enable-sdl-video use SDL for video graphics [default=no]], [WANT_SDL_VIDEO=$enableval], [WANT_SDL_VIDEO=no])
26 gbeauche 1.31 AC_ARG_ENABLE(sdl-audio, [ --enable-sdl-audio use SDL for audio [default=no]], [WANT_SDL_AUDIO=$enableval], [WANT_SDL_AUDIO=no])
27 gbeauche 1.26
28 gbeauche 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 gbeauche 1.1 dnl FPU emulation core.
33     AC_ARG_ENABLE(fpe,
34     [ --enable-fpe=FPE specify which fpu emulator to use [default=auto]],
35     [ case "$enableval" in
36     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     *) AC_MSG_ERROR([--enable-fpe takes only one of the following values: auto, x86, ieee, uae]);;
42     esac
43     ],
44     [ FPE_CORE_TEST_ORDER="ieee uae"
45     ])
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(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes])
63 gbeauche 1.49 AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]],
64     [case "$withval" in
65     gtk1) WANT_GTK="gtk";;
66     gtk|gtk2) WANT_GTK="$withval";;
67     yes) WANT_GTK="gtk2 gtk";;
68     *) WANT_GTK="no";;
69     esac],
70     [WANT_GTK="gtk2 gtk"])
71 gbeauche 1.1 AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
72    
73     dnl Canonical system information.
74     AC_CANONICAL_HOST
75     AC_CANONICAL_TARGET
76    
77     dnl Target OS type (target is host if not cross-compiling).
78     case "$target_os" in
79     linux*) OS_TYPE=linux;;
80     netbsd*) OS_TYPE=netbsd;;
81     freebsd*) OS_TYPE=freebsd;;
82     solaris*) OS_TYPE=solaris;;
83     darwin*) OS_TYPE=darwin;;
84     *) OS_TYPE=`echo $target_os | sed -e 's/-/_/g' | sed -e 's/\./_/g'`;;
85     esac
86     DEFINES="$DEFINES -DOS_$OS_TYPE"
87    
88     dnl Target CPU type.
89     HAVE_I386=no
90     HAVE_M68K=no
91     HAVE_SPARC=no
92     HAVE_POWERPC=no
93 gbeauche 1.13 HAVE_X86_64=no
94 gbeauche 1.1 case "$target_cpu" in
95 gbeauche 1.12 i386* | i486* | i586* | i686* | i786* ) HAVE_I386=yes;;
96     m68k* ) HAVE_M68K=yes;;
97     sparc* ) HAVE_SPARC=yes;;
98     powerpc* ) HAVE_POWERPC=yes;;
99 gbeauche 1.13 x86_64* ) HAVE_X86_64=yes;;
100 gbeauche 1.1 esac
101    
102     dnl Checks for programs.
103     AC_PROG_CC
104     AC_PROG_CC_C_O
105     AC_PROG_CPP
106     AC_PROG_CXX
107     AC_PROG_MAKE_SET
108     AC_PROG_INSTALL
109 gbeauche 1.36 AC_PROG_EGREP
110 gbeauche 1.1
111     dnl We use mon if possible.
112     MONSRCS=
113     if [[ "x$WANT_MON" = "xyes" ]]; then
114     AC_MSG_CHECKING(for mon)
115     mon_srcdir=../../../mon/src
116     if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
117     AC_MSG_RESULT(yes)
118     AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".])
119     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"
120     CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
121     AC_CHECK_LIB(ncurses, tgetent, ,
122     AC_CHECK_LIB(termcap, tgetent, ,
123     AC_CHECK_LIB(termlib, tgetent, ,
124     AC_CHECK_LIB(terminfo, tgetent, ,
125     AC_CHECK_LIB(Hcurses, tgetent, ,
126     AC_CHECK_LIB(curses, tgetent))))))
127     AC_CHECK_LIB(readline, readline)
128     else
129     AC_MSG_RESULT(no)
130     AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
131     WANT_MON=no
132     fi
133     fi
134    
135     dnl Checks for libraries.
136     AC_CHECK_LIB(posix4, sem_init)
137     AC_CHECK_LIB(rt, timer_create)
138 gbeauche 1.34 AC_CHECK_LIB(rt, shm_open)
139 gbeauche 1.56 AC_CHECK_LIB(m, cos)
140 gbeauche 1.1
141 gbeauche 1.26 dnl Do we need SDL?
142     WANT_SDL=no
143     if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
144     WANT_SDL=yes
145     WANT_XF86_DGA=no
146     WANT_XF86_VIDMODE=no
147     WANT_FBDEV_DGA=no
148 gbeauche 1.31 SDL_SUPPORT="$SDL_SUPPORT video"
149     fi
150     if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then
151     WANT_SDL=yes
152     SDL_SUPPORT="$SDL_SUPPORT audio"
153 gbeauche 1.26 fi
154     if [[ "x$WANT_SDL" = "xyes" ]]; then
155     AC_PATH_PROG(sdl_config, "sdl-config")
156     if [[ -n "$sdl_config" ]]; then
157 gbeauche 1.36 case $target_os in
158     # Special treatment for Cygwin so that we can still use the POSIX layer
159     *cygwin*)
160     sdl_cflags="-I`$sdl_config --prefix`/include/SDL"
161     sdl_libs="-L`$sdl_config --exec-prefix`/lib -lSDL"
162     ;;
163     *)
164     sdl_cflags=`$sdl_config --cflags`
165 gbeauche 1.41 if [[ "x$WANT_SDL_STATIC" = "xyes" ]]; then
166     sdl_libs=`$sdl_config --static-libs`
167     else
168     sdl_libs=`$sdl_config --libs`
169     fi
170 gbeauche 1.36 ;;
171     esac
172 gbeauche 1.26 CFLAGS="$CFLAGS $sdl_cflags"
173     CXXFLAGS="$CXXFLAGS $sdl_cflags"
174     LIBS="$LIBS $sdl_libs"
175     else
176     WANT_SDL=no
177     fi
178 gbeauche 1.31 SDL_SUPPORT=`echo "$SDL_SUPPORT" | sed -e "s/^ //"`
179     else
180     SDL_SUPPORT="none"
181 gbeauche 1.26 fi
182    
183     dnl We need X11, if not using SDL.
184     if [[ "x$WANT_SDL" = "xno" ]]; then
185     AC_PATH_XTRA
186     if [[ "x$no_x" = "xyes" ]]; then
187     AC_MSG_ERROR([You need X11 to run Basilisk II.])
188     fi
189     CFLAGS="$CFLAGS $X_CFLAGS"
190     CXXFLAGS="$CXXFLAGS $X_CFLAGS"
191     LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
192     fi
193 gbeauche 1.1
194     dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL.
195     HAVE_PTHREADS=yes
196     AC_CHECK_LIB(pthread, pthread_create, , [
197     AC_CHECK_LIB(c_r, pthread_create, , [
198     AC_CHECK_LIB(PTL, pthread_create, , [
199     HAVE_PTHREADS=no
200     ])
201     ])
202     ])
203     if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
204     AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.])
205     fi
206 gbeauche 1.50 AC_CHECK_FUNCS(pthread_cond_init)
207 gbeauche 1.46 AC_CHECK_FUNCS(pthread_cancel pthread_testcancel)
208 gbeauche 1.1 AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
209     AC_CHECK_FUNCS(pthread_mutexattr_settype)
210 gbeauche 1.3 AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
211 gbeauche 1.1
212     dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
213     SEMSRC=
214     AC_CHECK_FUNCS(sem_init, , [
215     if test "x$HAVE_PTHREADS" = "xyes"; then
216     SEMSRC=posix_sem.cpp
217     fi
218     ])
219    
220     dnl We use DGA (XFree86 or fbdev) if possible.
221     if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then
222     AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [
223     AC_DEFINE(ENABLE_XF86_DGA, 1, [Define if using XFree86 DGA extension.])
224     LIBS="$LIBS -lXxf86dga"
225     if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
226     AC_MSG_WARN([Cannot have both --enable-xf86-dga and --enable-fbdev-dga, ignoring --enable-fbdev-dga.])
227     WANT_FBDEV_DGA=no
228     fi
229     ], [
230     AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.])
231     WANT_XF86_DGA=no
232     ])
233     fi
234     if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
235     AC_DEFINE(ENABLE_FBDEV_DGA, 1, [Define if using DGA with framebuffer device.])
236     fi
237    
238     dnl We use XFree86 VidMode if possible.
239     if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then
240     AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [
241     AC_DEFINE(ENABLE_XF86_VIDMODE, 1, [Define if using XFree86 DGA extension.])
242     LIBS="$LIBS -lXxf86vm"
243     ], [
244     AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.])
245     WANT_XF86_VIDMODE=no
246     ])
247     fi
248    
249     dnl We use GTK+ if possible.
250     UISRCS=../dummy/prefs_editor_dummy.cpp
251 gbeauche 1.49 case "x$WANT_GTK" in
252     xgtk2*)
253     AM_PATH_GTK_2_0(1.3.15, [
254     AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
255     CFLAGS="$CFLAGS $GTK_CFLAGS"
256     CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
257     LIBS="$LIBS $GTK_LIBS"
258     UISRCS=prefs_editor_gtk.cpp
259     WANT_GTK=gtk2
260     ], [
261     case "x${WANT_GTK}x" in
262     *gtkx)
263     AC_MSG_WARN([Could not find GTK+ 2.0, trying with GTK+ 1.2.])
264     WANT_GTK=gtk
265     ;;
266     *)
267     AC_MSG_WARN([Could not find GTK+, disabling user interface.])
268     WANT_GTK=no
269     ;;
270     esac
271     ])
272     ;;
273     esac
274     if [[ "x$WANT_GTK" = "xgtk" ]]; then
275 gbeauche 1.1 AM_PATH_GTK(1.2.0, [
276     AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
277     CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
278     LIBS="$LIBS $GTK_LIBS"
279     UISRCS=prefs_editor_gtk.cpp
280 gbeauche 1.18 dnl somehow, <gnome-i18n.h> would redefine gettext() to nothing if
281     dnl ENABLE_NLS is not set, thusly conflicting with C++ <string> which
282     dnl includes <libintl.h>
283     AM_GNU_GETTEXT
284 gbeauche 1.1 B2_PATH_GNOMEUI([
285     AC_DEFINE(HAVE_GNOMEUI, 1, [Define if libgnomeui is available.])
286     CXXFLAGS="$CXXFLAGS $GNOMEUI_CFLAGS"
287     LIBS="$LIBS $GNOMEUI_LIBS"
288     ], [])
289     ], [
290     AC_MSG_WARN([Could not find GTK+, disabling user interface.])
291     WANT_GTK=no
292     ])
293     fi
294    
295     dnl We use ESD if possible.
296     if [[ "x$WANT_ESD" = "xyes" ]]; then
297     AM_PATH_ESD(0.2.8, [
298     AC_DEFINE(ENABLE_ESD, 1, [Define is using ESD.])
299     CFLAGS="$CFLAGS $ESD_CFLAGS"
300     CXXFLAGS="$CXXFLAGS $ESD_CFLAGS"
301     LIBS="$LIBS $ESD_LIBS"
302     ], [
303     AC_MSG_WARN([Could not find ESD, disabling ESD support.])
304     WANT_ESD=no
305     ])
306     fi
307    
308     dnl We use 64-bit file size support if possible.
309     AC_SYS_LARGEFILE
310    
311     dnl Checks for header files.
312     AC_HEADER_STDC
313 gbeauche 1.52 AC_CHECK_HEADERS(stdlib.h stdint.h)
314     AC_CHECK_HEADERS(unistd.h fcntl.h sys/types.h sys/time.h sys/mman.h mach/mach.h)
315 gbeauche 1.20 AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
316 gbeauche 1.42 AC_CHECK_HEADERS(sys/socket.h sys/ioctl.h sys/filio.h sys/bitypes.h sys/wait.h)
317     AC_CHECK_HEADERS(sys/poll.h sys/select.h)
318 gbeauche 1.39 AC_CHECK_HEADERS(arpa/inet.h)
319 gbeauche 1.35 AC_CHECK_HEADERS(linux/if.h linux/if_tun.h net/if.h net/if_tun.h, [], [], [
320 gbeauche 1.42 #ifdef HAVE_SYS_TYPES_H
321     #include <sys/types.h>
322     #endif
323 gbeauche 1.35 #ifdef HAVE_SYS_SOCKET_H
324     #include <sys/socket.h>
325     #endif
326     ])
327 gbeauche 1.30 AC_CHECK_HEADERS(AvailabilityMacros.h)
328 gbeauche 1.48 AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDevice.h)
329 gbeauche 1.1
330     dnl Checks for typedefs, structures, and compiler characteristics.
331     AC_C_BIGENDIAN
332     AC_C_CONST
333     AC_C_INLINE
334     AC_CHECK_SIZEOF(short, 2)
335     AC_CHECK_SIZEOF(int, 4)
336     AC_CHECK_SIZEOF(long, 4)
337     AC_CHECK_SIZEOF(long long, 8)
338     AC_CHECK_SIZEOF(float, 4)
339     AC_CHECK_SIZEOF(double, 8)
340     AC_CHECK_SIZEOF(long double, 12)
341     AC_CHECK_SIZEOF(void *, 4)
342     AC_TYPE_OFF_T
343 gbeauche 1.24 AC_CHECK_TYPES(loff_t)
344     AC_CHECK_TYPES(caddr_t)
345 gbeauche 1.1 AC_TYPE_SIZE_T
346     AC_TYPE_SIGNAL
347     AC_HEADER_TIME
348     AC_STRUCT_TM
349    
350     dnl Check whether sys/socket.h defines type socklen_t.
351     dnl (extracted from ac-archive/Miscellaneous)
352     AC_CACHE_CHECK([for socklen_t],
353     ac_cv_type_socklen_t, [
354     AC_TRY_COMPILE([
355     #include <sys/types.h>
356     #include <sys/socket.h>
357     ], [socklen_t len = 42; return 0;],
358     ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no,
359     dnl When cross-compiling, do not assume anything.
360     ac_cv_type_socklen_t="guessing no"
361     )
362     ])
363     if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then
364     AC_DEFINE(socklen_t, int, [Define to 'int' if <sys/types.h> doesn't define.])
365     fi
366    
367     dnl Checks for library functions.
368 gbeauche 1.39 AC_CHECK_FUNCS(strdup strerror cfmakeraw)
369 gbeauche 1.1 AC_CHECK_FUNCS(clock_gettime timer_create)
370     AC_CHECK_FUNCS(sigaction signal)
371     AC_CHECK_FUNCS(mmap mprotect munmap)
372     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
373 gbeauche 1.42 AC_CHECK_FUNCS(poll inet_aton)
374 gbeauche 1.1
375     dnl Darwin seems to define mach_task_self() instead of task_self().
376     AC_CHECK_FUNCS(mach_task_self task_self)
377    
378     dnl Check for headers and functions related to pty support (sshpty.c)
379     dnl From openssh-3.2.2p1 configure.ac
380    
381     AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
382     AC_CHECK_FUNCS(_getpty vhangup strlcpy)
383    
384     case "$host" in
385     *-*-hpux10.26)
386     disable_ptmx_check=yes
387     ;;
388     *-*-linux*)
389     no_dev_ptmx=1
390     ;;
391     mips-sony-bsd|mips-sony-newsos4)
392     AC_DEFINE(HAVE_NEWS4, 1, [Define if you are on NEWS-OS (additions from openssh-3.2.2p1, for sshpty.c).])
393     ;;
394     *-*-sco3.2v4*)
395     no_dev_ptmx=1
396     ;;
397     *-*-sco3.2v5*)
398     no_dev_ptmx=1
399     ;;
400 gbeauche 1.36 *-*-cygwin*)
401     no_dev_ptmx=1
402     ;;
403 gbeauche 1.1 esac
404    
405     if test -z "$no_dev_ptmx" ; then
406     if test "x$disable_ptmx_check" != "xyes" ; then
407     AC_CHECK_FILE([/dev/ptmx],
408     [
409     AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.])
410     have_dev_ptmx=1
411     ]
412     )
413     fi
414     fi
415     AC_CHECK_FILE([/dev/ptc],
416     [
417     AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.])
418     have_dev_ptc=1
419     ]
420     )
421    
422     dnl (end of code from openssh-3.2.2p1 configure.ac)
423    
424    
425 gbeauche 1.58 dnl Check for systems where POSIX-style non-blocking I/O (O_NONBLOCK)
426     dnl doesn't work or is unimplemented. On these systems (mostly older
427     dnl ones), use the old BSD-style FIONBIO approach instead. [tcl.m4]
428     AC_CACHE_CHECK([FIONBIO vs. O_NONBLOCK for non-blocking I/O],
429     ac_cv_nonblocking_io, [
430     case "$host" in
431     *-*-osf*)
432     ac_cv_nonblocking_io=FIONBIO
433     ;;
434     *-*-sunos4*)
435     ac_cv_nonblocking_io=FIONBIO
436     ;;
437     *-*-ultrix*)
438     ac_cv_nonblocking_io=FIONBIO
439     ;;
440     *)
441     ac_cv_nonblocking_io=O_NONBLOCK
442     ;;
443     esac
444     ])
445     if [[ "$ac_cv_nonblocking_io" = "FIONBIO" ]]; then
446     AC_DEFINE(USE_FIONBIO, 1, [Define if BSD-style non-blocking I/O is to be used])
447     fi
448    
449 gbeauche 1.59 dnl Check whether compiler supports byte bit-fields
450     AC_CACHE_CHECK([whether compiler supports byte bit-fields],
451     ac_cv_have_byte_bitfields, [
452     AC_LANG_SAVE
453     AC_LANG_CPLUSPLUS
454     AC_TRY_RUN([
455     struct A {
456     unsigned char b1:4;
457     unsigned char b2:4;
458     unsigned char c;
459     unsigned short s;
460     unsigned char a[4];
461     };
462    
463     int main(void) {
464     A a;
465     return ! (sizeof(A) == 8 && &a.c == ((unsigned char *)&a + 1));
466     }],
467     [ac_cv_have_byte_bitfields=yes],
468     [ac_cv_have_byte_bitfields=no],
469     dnl When cross-compiling, assume only GCC supports this
470     [if [[ "$GCC" = "yes" ]]; then
471     ac_cv_have_byte_bitfields="guessing yes"
472     else
473     ac_cv_have_byte_bitfields="guessing no"
474     fi]
475     )
476     AC_LANG_RESTORE
477     ])
478 gbeauche 1.58
479 gbeauche 1.30 dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
480 cebix 1.51 AC_DEFUN([AC_CHECK_FRAMEWORK], [
481 gbeauche 1.30 AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
482     AC_CACHE_CHECK([whether compiler supports framework $1],
483     ac_Framework, [
484     saved_LIBS="$LIBS"
485     LIBS="$LIBS -framework $1"
486     AC_TRY_LINK(
487 gbeauche 1.57 [$2], [],
488 gbeauche 1.30 [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
489     )
490     ])
491     AS_IF([test AS_VAR_GET(ac_Framework) = yes],
492     [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
493     )
494     AS_VAR_POPDEF([ac_Framework])dnl
495     ])
496    
497     dnl Check for some MacOS X frameworks
498 gbeauche 1.63 AC_CHECK_FRAMEWORK(AppKit, [])
499 gbeauche 1.30 AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
500     AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
501 gbeauche 1.48 AC_CHECK_FRAMEWORK(CoreFoundation, [#include <CoreFoundation/CoreFoundation.h>])
502 gbeauche 1.30
503 gbeauche 1.1 dnl Select system-dependant source files.
504     SERIALSRC=serial_unix.cpp
505     ETHERSRC=../dummy/ether_dummy.cpp
506     SCSISRC=../dummy/scsi_dummy.cpp
507     AUDIOSRC=../dummy/audio_dummy.cpp
508 gbeauche 1.41 EXTFSSRC=extfs_unix.cpp
509 gbeauche 1.1 EXTRASYSSRCS=
510     CAN_NATIVE_M68K=no
511     case "$target_os" in
512     linux*)
513     ETHERSRC=ether_unix.cpp
514     AUDIOSRC=audio_oss_esd.cpp
515     SCSISRC=Linux/scsi_linux.cpp
516     ;;
517     freebsd*)
518     ETHERSRC=ether_unix.cpp
519     AUDIOSRC=audio_oss_esd.cpp
520     DEFINES="$DEFINES -DBSD_COMP"
521     CXXFLAGS="$CXXFLAGS -fpermissive"
522     dnl Check for the CAM library
523     AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no)
524     if [[ "x$HAVE_LIBCAM" = "xno" ]]; then
525     AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.])
526     else
527     dnl Check for the sys kernel includes
528     AC_CHECK_HEADER(camlib.h)
529     if [[ "x$ac_cv_header_camlib_h" = "xno" ]]; then
530     dnl In this case I should fix this thing including a "patch"
531     dnl to access directly to the functions in the kernel :) --Orlando
532     AC_MSG_WARN([Cannot find includes for CAM library, disabling SCSI support.])
533     else
534     SCSISRC=FreeBSD/scsi_freebsd.cpp
535     LIBS="$LIBS -lcam"
536     DEFINES="$DEFINES -DCAM"
537     fi
538     fi
539     ;;
540     netbsd*)
541     CAN_NATIVE_M68K=yes
542 gbeauche 1.44 ETHERSRC=ether_unix.cpp
543 gbeauche 1.1 ;;
544     solaris*)
545     AUDIOSRC=Solaris/audio_solaris.cpp
546     DEFINES="$DEFINES -DBSD_COMP -D_POSIX_PTHREAD_SEMANTICS"
547     ;;
548     irix*)
549     AUDIOSRC=Irix/audio_irix.cpp
550     EXTRASYSSRCS=Irix/unaligned.c
551     LIBS="$LIBS -laudio"
552     WANT_ESD=no
553    
554 gbeauche 1.14 dnl Check if our compiler supports -IPA (MIPSPro)
555     HAVE_IPA=no
556 gbeauche 1.1 ocflags="$CFLAGS"
557 gbeauche 1.14 CFLAGS=`echo "$CFLAGS -IPA" | sed -e "s/-g//g"`
558     AC_MSG_CHECKING(if "-IPA" works)
559 gbeauche 1.1 dnl Do a test compile of an empty function
560 gbeauche 1.56 AC_TRY_COMPILE([#if defined __GNUC__
561     # error GCC does not support IPA yet
562     #endif],, [AC_MSG_RESULT(yes); HAVE_IPA=yes], AC_MSG_RESULT(no))
563 gbeauche 1.1 CFLAGS="$ocflags"
564 gbeauche 1.30 ;;
565     darwin*)
566 gbeauche 1.45 ETHERSRC=ether_unix.cpp
567 gbeauche 1.48 if [[ "x$ac_cv_framework_IOKit" = "xyes" -a "x$ac_cv_framework_CoreFoundation" = "xyes" ]]; then
568 gbeauche 1.30 EXTRASYSSRCS="../MacOSX/sys_darwin.cpp"
569     fi
570 gbeauche 1.41 if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
571     EXTFSSRC=../MacOSX/extfs_macosx.mm
572     fi
573 gbeauche 1.1 ;;
574 gbeauche 1.36 cygwin*)
575     SERIALSRC="../dummy/serial_dummy.cpp"
576 gbeauche 1.37 EXTRASYSSRCS="../Windows/BasiliskII.rc"
577 gbeauche 1.36 ;;
578 gbeauche 1.1 esac
579 gbeauche 1.43
580     dnl Is the slirp library supported?
581 gbeauche 1.59 case "$ac_cv_have_byte_bitfields" in
582     yes|"guessing yes")
583 gbeauche 1.60 CAN_SLIRP=yes
584 gbeauche 1.59 ETHERSRC=ether_unix.cpp
585     ;;
586     esac
587 gbeauche 1.60 if [[ -n "$CAN_SLIRP" ]]; then
588 gbeauche 1.43 AC_DEFINE(HAVE_SLIRP, 1, [Define if slirp library is supported])
589     SLIRP_SRCS="\
590     ../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \
591     ../slirp/cksum.c ../slirp/mbuf.c ../slirp/tcp_output.c \
592     ../slirp/debug.c ../slirp/misc.c ../slirp/tcp_subr.c \
593     ../slirp/if.c ../slirp/sbuf.c ../slirp/tcp_timer.c \
594     ../slirp/ip_icmp.c ../slirp/slirp.c ../slirp/tftp.c \
595     ../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c"
596     fi
597     AC_SUBST(SLIRP_SRCS)
598    
599 gbeauche 1.26 dnl SDL overrides
600     if [[ "x$WANT_SDL" = "xyes" ]]; then
601     AC_DEFINE(USE_SDL, 1, [Define to enble SDL support])
602     fi
603     if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
604 gbeauche 1.31 AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support])
605 gbeauche 1.30 VIDEOSRCS="../SDL/video_sdl.cpp"
606 gbeauche 1.29 KEYCODES="../SDL/keycodes"
607 gbeauche 1.30 if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
608     EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp"
609     else
610 gbeauche 1.38 case "$target_os" in
611     cygwin*)
612     EXTRASYSSRCS="$EXTRASYSSRCS ../Windows/clip_windows.cpp"
613     ;;
614     *)
615     EXTRASYSSRCS="$EXTRASYSSRCS ../dummy/clip_dummy.cpp"
616     ;;
617     esac
618 gbeauche 1.30 fi
619 gbeauche 1.26 else
620 gbeauche 1.30 VIDEOSRCS="video_x.cpp"
621 gbeauche 1.29 KEYCODES="keycodes"
622 gbeauche 1.30 EXTRASYSSRCS="$EXTRASYSSRCS clip_unix.cpp"
623 gbeauche 1.26 fi
624 gbeauche 1.31 if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then
625     AC_DEFINE(USE_SDL_AUDIO, 1, [Define to enable SDL audio support])
626     AUDIOSRC="../SDL/audio_sdl.cpp"
627     fi
628 gbeauche 1.1
629     dnl Use 68k CPU natively?
630     WANT_NATIVE_M68K=no
631     if [[ "x$HAVE_M68K" = "xyes" -a "x$CAN_NATIVE_M68K" = "xyes" ]]; then
632     AC_DEFINE(ENABLE_NATIVE_M68K, 1, [Define if using native 68k mode.])
633     WANT_NATIVE_M68K=yes
634     fi
635    
636     if [[ "x$HAVE_PTHREADS" = "xno" ]]; then
637     dnl Serial, ethernet and audio support needs pthreads
638     AC_MSG_WARN([You don't have pthreads, disabling serial, ethernet and audio support.])
639     SERIALSRC=../dummy/serial_dummy.cpp
640     ETHERSRC=../dummy/ether_dummy.cpp
641     AUDIOSRC=../dummy/audio_dummy.cpp
642     fi
643 gbeauche 1.41 SYSSRCS="$VIDEOSRCS $EXTFSSRC $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
644 gbeauche 1.1
645     dnl Define a macro that translates a yesno-variable into a C macro definition
646     dnl to be put into the config.h file
647     dnl $1 -- the macro to define
648     dnl $2 -- the value to translate
649     dnl $3 -- template name
650 cebix 1.51 AC_DEFUN([AC_TRANSLATE_DEFINE], [
651 gbeauche 1.1 if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
652     AC_DEFINE($1, 1, $3)
653     fi
654     ])
655    
656 gbeauche 1.25 dnl Check that the host supports TUN/TAP devices
657     AC_CACHE_CHECK([whether TUN/TAP is supported],
658     ac_cv_tun_tap_support, [
659     AC_TRY_COMPILE([
660     #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
661     #include <linux/if.h>
662     #include <linux/if_tun.h>
663     #endif
664     #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
665     #include <net/if.h>
666     #include <net/if_tun.h>
667     #endif
668     ], [
669     struct ifreq ifr;
670     memset(&ifr, 0, sizeof(ifr));
671     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
672     ],
673     ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
674     )
675     ])
676     AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
677     [Define if your system supports TUN/TAP devices.])
678    
679 gbeauche 1.1 dnl Various checks if the system supports vm_allocate() and the like functions.
680     have_mach_vm=no
681     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
682     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
683     have_mach_vm=yes
684     fi
685     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
686     [Define if your system has a working vm_allocate()-based memory allocator.])
687    
688     dnl Check that vm_allocate(), vm_protect() work
689     if [[ "x$have_mach_vm" = "xyes" ]]; then
690    
691     AC_CACHE_CHECK([whether vm_protect works],
692     ac_cv_vm_protect_works, [
693     AC_LANG_SAVE
694     AC_LANG_CPLUSPLUS
695     ac_cv_vm_protect_works=yes
696     dnl First the tests that should segfault
697     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
698     AC_TRY_RUN([
699     #define CONFIGURE_TEST_VM_MAP
700     #define TEST_VM_PROT_$test_def
701     #include "vm_alloc.cpp"
702     ], ac_cv_vm_protect_works=no, rm -f core,
703     dnl When cross-compiling, do not assume anything
704     ac_cv_vm_protect_works="guessing no"
705     )
706     done
707     AC_TRY_RUN([
708     #define CONFIGURE_TEST_VM_MAP
709     #define TEST_VM_PROT_RDWR_WRITE
710     #include "vm_alloc.cpp"
711     ], , ac_cv_vm_protect_works=no,
712     dnl When cross-compiling, do not assume anything
713     ac_cv_vm_protect_works="guessing no"
714     )
715     AC_LANG_RESTORE
716     ]
717     )
718    
719     dnl Remove support for vm_allocate() if vm_protect() does not work
720     if [[ "x$have_mach_vm" = "xyes" ]]; then
721     case $ac_cv_vm_protect_works in
722     *yes) have_mach_vm=yes;;
723     *no) have_mach_vm=no;;
724     esac
725     fi
726     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
727     [Define if your system has a working vm_allocate()-based memory allocator.])
728    
729     fi dnl HAVE_MACH_VM
730    
731     dnl Various checks if the system supports mmap() and the like functions.
732     dnl ... and Mach memory allocators are not supported
733     have_mmap_vm=no
734     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
735     "x$ac_cv_func_mprotect" = "xyes" ]]; then
736     if [[ "x$have_mach_vm" = "xno" ]]; then
737     have_mmap_vm=yes
738     fi
739     fi
740     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
741     [Define if your system has a working mmap()-based memory allocator.])
742    
743     dnl Check that mmap() and associated functions work.
744     if [[ "x$have_mmap_vm" = "xyes" ]]; then
745    
746     dnl Check if we have a working anonymous mmap()
747     AC_CACHE_CHECK([whether mmap supports MAP_ANON],
748     ac_cv_mmap_anon, [
749     AC_LANG_SAVE
750     AC_LANG_CPLUSPLUS
751     AC_TRY_RUN([
752     #define HAVE_MMAP_ANON
753     #define CONFIGURE_TEST_VM_MAP
754     #define TEST_VM_MMAP_ANON
755     #include "vm_alloc.cpp"
756     ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
757     dnl When cross-compiling, do not assume anything.
758     ac_cv_mmap_anon="guessing no"
759     )
760     AC_LANG_RESTORE
761     ]
762     )
763     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
764     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
765    
766     AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
767     ac_cv_mmap_anonymous, [
768     AC_LANG_SAVE
769     AC_LANG_CPLUSPLUS
770     AC_TRY_RUN([
771     #define HAVE_MMAP_ANONYMOUS
772     #define CONFIGURE_TEST_VM_MAP
773     #define TEST_VM_MMAP_ANON
774     #include "vm_alloc.cpp"
775     ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
776     dnl When cross-compiling, do not assume anything.
777     ac_cv_mmap_anonymous="guessing no"
778     )
779     AC_LANG_RESTORE
780     ]
781     )
782     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
783     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
784    
785     AC_CACHE_CHECK([whether mprotect works],
786     ac_cv_mprotect_works, [
787     AC_LANG_SAVE
788     AC_LANG_CPLUSPLUS
789     ac_cv_mprotect_works=yes
790     dnl First the tests that should segfault
791     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
792     AC_TRY_RUN([
793     #define CONFIGURE_TEST_VM_MAP
794     #define TEST_VM_PROT_$test_def
795     #include "vm_alloc.cpp"
796     ], ac_cv_mprotect_works=no, rm -f core,
797     dnl When cross-compiling, do not assume anything
798     ac_cv_mprotect_works="guessing no"
799     )
800     done
801     AC_TRY_RUN([
802     #define CONFIGURE_TEST_VM_MAP
803     #define TEST_VM_PROT_RDWR_WRITE
804     #include "vm_alloc.cpp"
805     ], , ac_cv_mprotect_works=no,
806     dnl When cross-compiling, do not assume anything
807     ac_cv_mprotect_works="guessing no"
808     )
809     AC_LANG_RESTORE
810     ]
811     )
812    
813     dnl Remove support for mmap() if mprotect() does not work
814     if [[ "x$have_mmap_vm" = "xyes" ]]; then
815     case $ac_cv_mprotect_works in
816     *yes) have_mmap_vm=yes;;
817     *no) have_mmap_vm=no;;
818     esac
819     fi
820     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
821     [Define if your system has a working mmap()-based memory allocator.])
822    
823     fi dnl HAVE_MMAP_VM
824    
825 gbeauche 1.23 dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
826     AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x2000],
827     ac_cv_pagezero_hack, [
828     ac_cv_pagezero_hack=no
829     if AC_TRY_COMMAND([Darwin/testlmem.sh 0x2000]); then
830     ac_cv_pagezero_hack=yes
831     dnl might as well skip the test for mmap-able low memory
832     ac_cv_can_map_lm=no
833     fi
834     ])
835     AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
836     [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
837    
838 gbeauche 1.1 dnl Check if we can mmap 0x2000 bytes from 0x0000
839     AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x2000],
840     ac_cv_can_map_lm, [
841     AC_LANG_SAVE
842     AC_LANG_CPLUSPLUS
843     AC_TRY_RUN([
844     #include "vm_alloc.cpp"
845     int main(void) { /* returns 0 if we could map the lowmem globals */
846 gbeauche 1.15 volatile char * lm = 0;
847 gbeauche 1.1 if (vm_init() < 0) exit(1);
848 gbeauche 1.15 if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
849 gbeauche 1.1 lm[0] = 'z';
850     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
851     vm_exit(); exit(0);
852     }
853     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
854     dnl When cross-compiling, do not assume anything.
855     ac_cv_can_map_lm="guessing no"
856     )
857     AC_LANG_RESTORE
858     ]
859     )
860    
861 gbeauche 1.34 dnl Check if we have POSIX shared memory support
862     AC_CACHE_CHECK([whether POSIX shared memory is working],
863     ac_cv_have_posix_shm, [
864     AC_LANG_SAVE
865     AC_LANG_CPLUSPLUS
866     AC_TRY_RUN([
867     #define HAVE_POSIX_SHM
868     #include "vm_alloc.cpp"
869     int main(void) { /* returns 0 if we have working POSIX shm */
870     if (vm_init() < 0) exit(2);
871     char *m1 = (char *)vm_acquire(32768, VM_MAP_DEFAULT | VM_MAP_33BIT);
872     if (m1 == VM_MAP_FAILED) exit(3);
873     vm_exit(); exit(0);
874     }
875     ], ac_cv_have_posix_shm=yes, ac_cv_have_posix_shm=no,
876     dnl When cross-compiling, do not assume anything.
877     ac_cv_have_posix_shm="guessing no"
878     )
879     AC_LANG_RESTORE
880     ]
881     )
882     AC_TRANSLATE_DEFINE(HAVE_POSIX_SHM, "$ac_cv_have_posix_shm",
883     [Define if your system supports POSIX shared memory.])
884    
885     dnl Check if we have working 33-bit memory addressing
886     AC_CACHE_CHECK([whether 33-bit memory addressing is working],
887     ac_cv_have_33bit_addressing, [
888     AC_LANG_SAVE
889     AC_LANG_CPLUSPLUS
890     AC_TRY_RUN([
891     #define USE_33BIT_ADDRESSING 1
892     #include "vm_alloc.cpp"
893     int main(void) { /* returns 0 if we have working 33-bit addressing */
894     if (sizeof(void *) < 8) exit(1);
895     if (vm_init() < 0) exit(2);
896     char *m1 = (char *)vm_acquire(32768, VM_MAP_DEFAULT | VM_MAP_33BIT);
897     if (m1 == VM_MAP_FAILED) exit(3);
898     char *m2 = m1 + (1L << 32);
899     m1[0] = 0x12; if (m2[0] != 0x12) exit(4);
900     m2[0] = 0x34; if (m1[0] != 0x34) exit(5);
901     vm_exit(); exit(0);
902     }
903     ], ac_cv_have_33bit_addressing=yes, ac_cv_have_33bit_addressing=no,
904     dnl When cross-compiling, do not assume anything.
905     ac_cv_have_33bit_addressing="guessing no"
906     )
907     AC_LANG_RESTORE
908     ]
909     )
910    
911 gbeauche 1.1 dnl Check signal handlers need to be reinstalled
912     AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
913     ac_cv_signal_need_reinstall, [
914     AC_LANG_SAVE
915     AC_LANG_CPLUSPLUS
916     AC_TRY_RUN([
917     #include <stdlib.h>
918     #ifdef HAVE_UNISTD_H
919     #include <unistd.h>
920     #endif
921     #include <signal.h>
922     static int handled_signal = 0;
923     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
924     int main(void) { /* returns 0 if signals need not to be reinstalled */
925     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
926     exit(handled_signal == 2);
927     }
928     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
929     dnl When cross-compiling, do not assume anything.
930     ac_cv_signal_need_reinstall="guessing yes"
931     )
932     AC_LANG_RESTORE
933     ]
934     )
935     AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
936     [Define if your system requires signals to be reinstalled.])
937    
938     dnl Check if sigaction handlers need to be reinstalled
939     AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
940     ac_cv_sigaction_need_reinstall, [
941     AC_LANG_SAVE
942     AC_LANG_CPLUSPLUS
943     AC_TRY_RUN([
944     #include <stdlib.h>
945     #ifdef HAVE_UNISTD_H
946     #include <unistd.h>
947     #endif
948     #include <signal.h>
949     static int handled_signal = 0;
950     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
951     typedef RETSIGTYPE (*signal_handler)(int);
952     static signal_handler mysignal(int sig, signal_handler handler) {
953     struct sigaction old_sa;
954     struct sigaction new_sa;
955     new_sa.sa_handler = handler;
956     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
957     }
958     int main(void) { /* returns 0 if signals need not to be reinstalled */
959     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
960     exit(handled_signal == 2);
961     }
962     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
963     dnl When cross-compiling, do not assume anything.
964     ac_cv_sigaction_need_reinstall="guessing yes"
965     )
966     AC_LANG_RESTORE
967     ]
968     )
969     AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
970     [Define if your system requires sigactions to be reinstalled.])
971    
972 gbeauche 1.21 dnl Check if Mach exceptions supported.
973     AC_CACHE_CHECK([whether your system supports Mach exceptions],
974     ac_cv_have_mach_exceptions, [
975 gbeauche 1.1 AC_LANG_SAVE
976     AC_LANG_CPLUSPLUS
977     AC_TRY_RUN([
978 gbeauche 1.21 #define HAVE_MACH_EXCEPTIONS 1
979 gbeauche 1.1 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
980     #include "vm_alloc.cpp"
981     #include "sigsegv.cpp"
982 gbeauche 1.21 ], [
983     sigsegv_recovery=mach
984     ac_cv_have_mach_exceptions=yes
985     ],
986     ac_cv_have_mach_exceptions=no,
987 gbeauche 1.1 dnl When cross-compiling, do not assume anything.
988 gbeauche 1.21 ac_cv_have_mach_exceptions=no
989 gbeauche 1.1 )
990     AC_LANG_RESTORE
991     ]
992     )
993 gbeauche 1.21 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
994     [Define if your system supports Mach exceptions.])
995    
996 gbeauche 1.36 dnl Check if Windows exceptions are supported.
997     AC_CACHE_CHECK([whether your system supports Windows exceptions],
998     ac_cv_have_win32_exceptions, [
999     AC_LANG_SAVE
1000     AC_LANG_CPLUSPLUS
1001     AC_TRY_RUN([
1002     #define HAVE_WIN32_EXCEPTIONS 1
1003     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
1004     #include "vm_alloc.cpp"
1005     #include "sigsegv.cpp"
1006     ], [
1007     sigsegv_recovery=win32
1008     ac_cv_have_win32_exceptions=yes
1009     ],
1010     ac_cv_have_win32_exceptions=no,
1011     dnl When cross-compiling, do not assume anything.
1012     ac_cv_have_win32_exceptions=no
1013     )
1014     AC_LANG_RESTORE
1015     ]
1016     )
1017     AC_TRANSLATE_DEFINE(HAVE_WIN32_EXCEPTIONS, "$ac_cv_have_win32_exceptions",
1018     [Define if your system supports Windows exceptions.])
1019    
1020 gbeauche 1.21 dnl Otherwise, check if extended signals are supported.
1021     if [[ -z "$sigsegv_recovery" ]]; then
1022     AC_CACHE_CHECK([whether your system supports extended signal handlers],
1023     ac_cv_have_extended_signals, [
1024     AC_LANG_SAVE
1025     AC_LANG_CPLUSPLUS
1026     AC_TRY_RUN([
1027     #define HAVE_SIGINFO_T 1
1028     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
1029     #include "vm_alloc.cpp"
1030     #include "sigsegv.cpp"
1031     ], [
1032     sigsegv_recovery=siginfo
1033     ac_cv_have_extended_signals=yes
1034     ],
1035     ac_cv_have_extended_signals=no,
1036     dnl When cross-compiling, do not assume anything.
1037     ac_cv_have_extended_signals=no
1038     )
1039     AC_LANG_RESTORE
1040     ]
1041     )
1042     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
1043     [Define if your system support extended signals.])
1044     fi
1045 gbeauche 1.1
1046     dnl Otherwise, check for subterfuges.
1047 gbeauche 1.21 if [[ -z "$sigsegv_recovery" ]]; then
1048 gbeauche 1.1 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
1049     ac_cv_have_sigcontext_hack, [
1050     AC_LANG_SAVE
1051     AC_LANG_CPLUSPLUS
1052     AC_TRY_RUN([
1053     #define HAVE_SIGCONTEXT_SUBTERFUGE 1
1054     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
1055     #include "vm_alloc.cpp"
1056     #include "sigsegv.cpp"
1057 gbeauche 1.21 ], [
1058     sigsegv_recovery=sigcontext
1059     ac_cv_have_sigcontext_hack=yes
1060     ],
1061     ac_cv_have_sigcontext_hack=no,
1062 gbeauche 1.1 dnl When cross-compiling, do not assume anything.
1063     ac_cv_have_sigcontext_hack=no
1064     )
1065     AC_LANG_RESTORE
1066     ])
1067     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
1068     [Define if we know a hack to replace siginfo_t->si_addr member.])
1069     fi
1070    
1071     dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
1072     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
1073     ac_cv_have_skip_instruction, [
1074     AC_LANG_SAVE
1075     AC_LANG_CPLUSPLUS
1076     AC_TRY_RUN([
1077     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
1078     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
1079     #include "vm_alloc.cpp"
1080     #include "sigsegv.cpp"
1081     ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
1082     dnl When cross-compiling, do not assume anything.
1083     ac_cv_have_skip_instruction=no
1084     )
1085     AC_LANG_RESTORE
1086     ]
1087     )
1088     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
1089     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
1090    
1091     dnl Can we do Video on SEGV Signals ?
1092     CAN_VOSF=no
1093 gbeauche 1.21 if [[ -n "$sigsegv_recovery" ]]; then
1094 gbeauche 1.1 CAN_VOSF=yes
1095     fi
1096    
1097 gbeauche 1.23 dnl A dummy program that returns always true
1098 gbeauche 1.28 AC_PATH_PROG([BLESS], "true")
1099 gbeauche 1.23
1100 gbeauche 1.61 dnl Check for linker script support
1101     case $target_os:$target_cpu in
1102     linux*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
1103     linux*:x86_64) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-x86_64.ld";;
1104 gbeauche 1.65 linux*:powerpc) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-ppc.ld";;
1105 gbeauche 1.64 netbsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";;
1106     freebsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/freebsd-i386.ld";;
1107 gbeauche 1.65 darwin*:*) LINKER_SCRIPT_FLAGS="-Wl,-seg1addr,0x78048000";;
1108 gbeauche 1.61 esac
1109     if [[ -n "$LINKER_SCRIPT_FLAGS" ]]; then
1110     AC_CACHE_CHECK([whether linker script is usable],
1111     ac_cv_linker_script_works, [
1112     AC_LANG_SAVE
1113     AC_LANG_CPLUSPLUS
1114     saved_LDFLAGS="$LDFLAGS"
1115     LDFLAGS="$LDFLAGS $LINKER_SCRIPT_FLAGS"
1116     AC_TRY_RUN(
1117     [int main() {if ((char *)&main < (char *)0x70000000) return 1;}],
1118     [ac_cv_linker_script_works=yes],
1119     [ac_cv_linker_script_works=no],
1120     dnl When cross-compiling, assume it works
1121     [ac_cv_linker_script_works="guessing yes"]
1122     )
1123     AC_LANG_RESTORE
1124     if [[ "$ac_cv_linker_script_works" = "no" ]]; then
1125     LDFLAGS="$saved_LDFLAGS"
1126     LINKER_SCRIPT_FLAGS=""
1127     fi
1128     ])
1129     fi
1130     AC_TRANSLATE_DEFINE(HAVE_LINKER_SCRIPT, "$ac_cv_linker_script_works",
1131     [Define if there is a linker script to relocate the executable above 0x70000000.])
1132    
1133 gbeauche 1.1 dnl Determine the addressing mode to use
1134     if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
1135     ADDRESSING_MODE="real"
1136     else
1137     ADDRESSING_MODE=""
1138     AC_MSG_CHECKING([for the addressing mode to use])
1139     for am in $ADDRESSING_TEST_ORDER; do
1140     case $am in
1141     real)
1142     dnl Requires ability to mmap() Low Memory globals
1143 gbeauche 1.23 if [[ "x$ac_cv_can_map_lm$ac_cv_pagezero_hack" = "xnono" ]]; then
1144 gbeauche 1.1 continue
1145     fi
1146 gbeauche 1.23 dnl Requires VOSF screen updates
1147 gbeauche 1.1 if [[ "x$CAN_VOSF" = "xno" ]]; then
1148     continue
1149     fi
1150     dnl Real addressing will probably work.
1151     ADDRESSING_MODE="real"
1152     WANT_VOSF=yes dnl we can use VOSF and we need it actually
1153     DEFINES="$DEFINES -DREAL_ADDRESSING"
1154 gbeauche 1.23 if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
1155     BLESS=Darwin/lowmem
1156     LDFLAGS="$LDFLAGS -pagezero_size 0x2000"
1157     fi
1158 gbeauche 1.1 break
1159     ;;
1160     direct)
1161     dnl Requires VOSF screen updates
1162     if [[ "x$CAN_VOSF" = "xyes" ]]; then
1163     ADDRESSING_MODE="direct"
1164     WANT_VOSF=yes dnl we can use VOSF and we need it actually
1165     DEFINES="$DEFINES -DDIRECT_ADDRESSING"
1166     break
1167     fi
1168     ;;
1169     banks)
1170     dnl Default addressing mode
1171     ADDRESSING_MODE="memory banks"
1172     break
1173     ;;
1174     *)
1175     AC_MSG_ERROR([Internal configure.in script error for $am addressing mode])
1176     esac
1177     done
1178     AC_MSG_RESULT($ADDRESSING_MODE)
1179     if [[ "x$ADDRESSING_MODE" = "x" ]]; then
1180     AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER])
1181     ADDRESSING_MODE="memory banks"
1182     fi
1183     fi
1184    
1185 gbeauche 1.5 dnl Banked Memory Addressing mode is not supported by the JIT compiler
1186     if [[ "x$WANT_JIT" = "xyes" -a "x$ADDRESSING_MODE" = "xmemory banks" ]]; then
1187     AC_MSG_ERROR([Sorry, the JIT Compiler requires Direct Addressing, at least])
1188     fi
1189    
1190 gbeauche 1.1 dnl Enable VOSF screen updates with this feature is requested and feasible
1191     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
1192     AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
1193     else
1194     WANT_VOSF=no
1195     fi
1196    
1197     dnl Check for GAS.
1198     HAVE_GAS=no
1199     AC_MSG_CHECKING(for GAS .p2align feature)
1200     cat >conftest.S << EOF
1201     .text
1202     .p2align 5
1203     EOF
1204     if $CC conftest.S -c -o conftest.o >/dev/null 2>&1 ; then HAVE_GAS=yes; fi
1205     AC_MSG_RESULT($HAVE_GAS)
1206    
1207     dnl Check for GCC 2.7 or higher.
1208     HAVE_GCC27=no
1209     AC_MSG_CHECKING(for GCC 2.7 or higher)
1210 gbeauche 1.53 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5)
1211     # error gcc < 2.7
1212     #endif
1213     ]])],
1214     [AC_MSG_RESULT(yes); HAVE_GCC27=yes],
1215     [AC_MSG_RESULT(no)])
1216 gbeauche 1.1
1217     dnl Check for GCC 3.0 or higher.
1218     HAVE_GCC30=no
1219     AC_MSG_CHECKING(for GCC 3.0 or higher)
1220 gbeauche 1.53 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ >= 3)
1221     # error gcc < 3
1222     #endif
1223     ]])],
1224     [AC_MSG_RESULT(yes); HAVE_GCC30=yes],
1225     [AC_MSG_RESULT(no)])
1226 gbeauche 1.1
1227 gbeauche 1.39 dnl Check for ICC.
1228     AC_MSG_CHECKING(for ICC)
1229     HAVE_ICC=no
1230     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
1231     HAVE_ICC=yes
1232     fi
1233     AC_MSG_RESULT($HAVE_ICC)
1234    
1235 gbeauche 1.1 dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher.
1236     dnl Also set "-fno-exceptions" for C++ because exception handling requires
1237     dnl the frame pointer.
1238     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
1239     CFLAGS="$CFLAGS -fomit-frame-pointer"
1240     CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -fno-exceptions"
1241     fi
1242    
1243     dnl (gb) Do not merge constants since it breaks fpu/fpu_x86.cpp.
1244     dnl As of 2001/08/02, this affects the following compilers:
1245     dnl Official: probably gcc-3.1 (mainline CVS)
1246     dnl Mandrake: gcc-2.96 >= 0.59mdk, gcc-3.0.1 >= 0.1mdk
1247     dnl Red Hat : gcc-2.96 >= 89, gcc-3.0 >= 1
1248 gbeauche 1.39 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1249 gbeauche 1.1 SAVED_CXXFLAGS="$CXXFLAGS"
1250     CXXFLAGS="$CXXFLAGS -fno-merge-constants"
1251     AC_CACHE_CHECK([whether GCC supports constants merging], ac_cv_gcc_constants_merging, [
1252     AC_LANG_SAVE
1253     AC_LANG_CPLUSPLUS
1254     AC_TRY_COMPILE([],[],[ac_cv_gcc_constants_merging=yes],[ac_cv_gcc_constants_merging=no])
1255     AC_LANG_RESTORE
1256     ])
1257     if [[ "x$ac_cv_gcc_constants_merging" != "xyes" ]]; then
1258     CXXFLAGS="$SAVED_CXXFLAGS"
1259     fi
1260     fi
1261    
1262 gbeauche 1.33 dnl Store motion was introduced in 3.3-hammer branch and any gcc >= 3.4
1263     dnl However, there are some corner cases exposed on x86-64
1264 gbeauche 1.39 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1265 gbeauche 1.33 SAVED_CXXFLAGS="$CXXFLAGS"
1266     CXXFLAGS="$CXXFLAGS -fno-gcse-sm"
1267     AC_CACHE_CHECK([whether GCC supports store motion], ac_cv_gcc_store_motion, [
1268     AC_LANG_SAVE
1269     AC_LANG_CPLUSPLUS
1270     AC_TRY_COMPILE([],[],[ac_cv_gcc_store_motion=yes],[ac_cv_gcc_store_motion=no])
1271     AC_LANG_RESTORE
1272     ])
1273     if [[ "x$ac_cv_gcc_store_motion" != "xyes" ]]; then
1274     CXXFLAGS="$SAVED_CXXFLAGS"
1275     fi
1276     fi
1277    
1278 gbeauche 1.39 dnl Add -fno-strict-aliasing for slirp sources
1279     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1280 gbeauche 1.40 SAVED_CFLAGS="$CFLAGS"
1281 gbeauche 1.39 CFLAGS="$CFLAGS -fno-strict-aliasing"
1282     AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing],
1283     ac_cv_gcc_no_strict_aliasing, [
1284     AC_TRY_COMPILE([],[],
1285 gbeauche 1.47 [ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")],
1286 gbeauche 1.39 [ac_cv_gcc_no_strict_aliasing=no])
1287     ])
1288     CFLAGS="$SAVED_CFLAGS"
1289     fi
1290    
1291 gbeauche 1.54 dnl Add -mdynamic-no-pic for MacOS X (XXX icc10 will support MacOS X)
1292     if [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1293 gbeauche 1.52 SAVED_CFLAGS="$CFLAGS"
1294     CFLAGS="$CFLAGS -mdynamic-no-pic"
1295     AC_CACHE_CHECK([whether the compiler supports -mdynamic-no-pic],
1296     ac_cv_gcc_mdynamic_no_pic, [
1297     AC_TRY_COMPILE([],[],[ac_cv_gcc_mdynamic_no_pic=yes],[ac_cv_gcc_mdynamic_no_pic=no])
1298     ])
1299     if [[ "x$ac_cv_gcc_mdynamic_no_pic" = "xyes" ]]; then
1300     CXXFLAGS="$CXXFLAGS -mdynamic-no-pic"
1301     else
1302     CFLAGS="$SAVED_CFLAGS"
1303     fi
1304     fi
1305    
1306 gbeauche 1.1 dnl Select appropriate CPU source and REGPARAM define.
1307     ASM_OPTIMIZATIONS=none
1308     CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
1309 gbeauche 1.5
1310     dnl (gb) JITSRCS will be emptied later if the JIT is not available
1311     dnl Other platforms should define their own set of noflags file variants
1312     CAN_JIT=no
1313     JITSRCS="compemu1.cpp compemu2.cpp compemu3.cpp compemu4.cpp compemu5.cpp compemu6.cpp compemu7.cpp compemu8.cpp"
1314    
1315 gbeauche 1.11 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
1316 gbeauche 1.1 dnl i386 CPU
1317 gbeauche 1.7 DEFINES="$DEFINES -DUNALIGNED_PROFITABLE -DREGPARAM=\"__attribute__((regparm(3)))\""
1318 gbeauche 1.1 if [[ "x$HAVE_GAS" = "xyes" ]]; then
1319     ASM_OPTIMIZATIONS=i386
1320 gbeauche 1.7 DEFINES="$DEFINES -DX86_ASSEMBLY -DOPTIMIZED_FLAGS -DSAHF_SETO_PROFITABLE"
1321 gbeauche 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"
1322 gbeauche 1.11 CAN_JIT=yes
1323 gbeauche 1.13 fi
1324     elif [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_X86_64" = "xyes" ]]; then
1325     dnl x86-64 CPU
1326     DEFINES="$DEFINES -DUNALIGNED_PROFITABLE"
1327     if [[ "x$HAVE_GAS" = "xyes" ]]; then
1328     ASM_OPTIMIZATIONS="x86-64"
1329     DEFINES="$DEFINES -DX86_64_ASSEMBLY -DOPTIMIZED_FLAGS"
1330 gbeauche 1.32 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"
1331     CAN_JIT=yes
1332 gbeauche 1.34 WANT_33BIT_ADDRESSING=yes
1333 gbeauche 1.1 fi
1334     elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
1335     dnl SPARC CPU
1336     case "$target_os" in
1337     solaris*)
1338     AC_MSG_CHECKING(SPARC CPU architecture)
1339     SPARC_TYPE=`Solaris/which_sparc`
1340     AC_MSG_RESULT($SPARC_TYPE)
1341     case "$SPARC_TYPE" in
1342     SPARC_V8)
1343     ASM_OPTIMIZATIONS="SPARC V8 architecture"
1344     DEFINES="$DEFINES -DSPARC_V8_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
1345     CFLAGS="$CFLAGS -Wa,-Av8"
1346     CXXFLAGS="$CXXFLAGS -Wa,-Av8"
1347     ;;
1348     SPARC_V9)
1349     ASM_OPTIMIZATIONS="SPARC V9 architecture"
1350     DEFINES="$DEFINES -DSPARC_V9_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
1351     CFLAGS="$CFLAGS -Wa,-Av9"
1352     CXXFLAGS="$CXXFLAGS -Wa,-Av9"
1353     ;;
1354     esac
1355     ;;
1356     esac
1357     elif [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
1358     dnl Native m68k, no emulation
1359     CPUINCLUDES="-I../native_cpu"
1360     CPUSRCS="asm_support.s"
1361     fi
1362    
1363 gbeauche 1.5 dnl Enable JIT compiler, if possible.
1364     if [[ "x$WANT_JIT" = "xyes" -a "x$CAN_JIT" ]]; then
1365     JITSRCS="$JITSRCS ../uae_cpu/compiler/compemu_support.cpp ../uae_cpu/compiler/compemu_fpp.cpp compstbl.o cpustbl_nf.o"
1366     DEFINES="$DEFINES -DUSE_JIT -DUSE_JIT_FPU"
1367    
1368     if [[ "x$WANT_JIT_DEBUG" = "xyes" ]]; then
1369     if [[ "x$WANT_MON" = "xyes" ]]; then
1370     DEFINES="$DEFINES -DJIT_DEBUG=1"
1371     else
1372     AC_MSG_WARN([cxmon not found, ignoring --enable-jit-debug])
1373     WANT_JIT_DEBUG=no
1374     fi
1375     fi
1376 gbeauche 1.8
1377     dnl IEEE core is the only FPU emulator to use with the JIT compiler
1378     case $FPE_CORE_TEST_ORDER in
1379     ieee*) ;;
1380     *) AC_MSG_WARN([Forcing use of the IEEE FPU core, as the JIT compiler supports only this one.]) ;;
1381     esac
1382     FPE_CORE_TEST_ORDER="ieee"
1383 gbeauche 1.5 else
1384     WANT_JIT=no
1385     WANT_JIT_DEBUG=no
1386     JITSRCS=""
1387     fi
1388    
1389 gbeauche 1.34 dnl Use 33-bit memory addressing?
1390     if [[ "$ac_cv_have_33bit_addressing:$WANT_33BIT_ADDRESSING" = "yes:yes" ]]; then
1391     use_33bit_addressing=yes
1392     fi
1393     AC_TRANSLATE_DEFINE(USE_33BIT_ADDRESSING, "$use_33bit_addressing",
1394     [Define to use 33-bit memory addressing on 64-bit JIT capable systems.])
1395    
1396 gbeauche 1.1 dnl Utility macro used by next two tests.
1397     dnl AC_EXAMINE_OBJECT(C source code,
1398     dnl commands examining object file,
1399     dnl [commands to run if compile failed]):
1400     dnl
1401     dnl Compile the source code to an object file; then convert it into a
1402     dnl printable representation. All unprintable characters and
1403     dnl asterisks (*) are replaced by dots (.). All white space is
1404     dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
1405     dnl output, but runs of newlines are compressed to a single newline.
1406     dnl Finally, line breaks are forcibly inserted so that no line is
1407     dnl longer than 80 columns and the file ends with a newline. The
1408     dnl result of all this processing is in the file conftest.dmp, which
1409     dnl may be examined by the commands in the second argument.
1410     dnl
1411     AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
1412     [AC_LANG_SAVE
1413     AC_LANG_C
1414     dnl Next bit cribbed from AC_TRY_COMPILE.
1415     cat > conftest.$ac_ext <<EOF
1416     [#line __oline__ "configure"
1417     #include "confdefs.h"
1418     $1
1419     ]EOF
1420     if AC_TRY_EVAL(ac_compile); then
1421     od -c conftest.o |
1422     sed ['s/^[0-7]*[ ]*/ /
1423     s/\*/./g
1424     s/ \\n/*/g
1425     s/ [0-9][0-9][0-9]/./g
1426     s/ \\[^ ]/./g'] |
1427     tr -d '
1428     ' | tr -s '*' '
1429     ' | fold | sed '$a\
1430     ' > conftest.dmp
1431     $2
1432     ifelse($3, , , else
1433     $3
1434     )dnl
1435     fi
1436     rm -rf conftest*
1437     AC_LANG_RESTORE])
1438    
1439     dnl Floating point format probe.
1440     dnl The basic concept is the same as the above: grep the object
1441     dnl file for an interesting string. We have to watch out for
1442     dnl rounding changing the values in the object, however; this is
1443     dnl handled by ignoring the least significant byte of the float.
1444     dnl
1445     dnl Does not know about VAX G-float or C4x idiosyncratic format.
1446     dnl It does know about PDP-10 idiosyncratic format, but this is
1447     dnl not presently supported by GCC. S/390 "binary floating point"
1448     dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
1449     dnl as ASCII?)
1450     dnl
1451     AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
1452     [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
1453     [gcc_AC_EXAMINE_OBJECT(
1454     [/* This will not work unless sizeof(double) == 8. */
1455     extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1456    
1457     /* This structure must have no internal padding. */
1458     struct possibility {
1459     char prefix[8];
1460     double candidate;
1461     char postfix[8];
1462     };
1463    
1464     #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1465     struct possibility table [] =
1466     {
1467     C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1468     C( 3.53802595280598432000e+18), /* D__float - VAX */
1469     C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1470     C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1471     C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
1472     };],
1473     [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1474     ac_cv_c_float_format='IEEE (big-endian)'
1475     elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1476     ac_cv_c_float_format='IEEE (big-endian)'
1477     elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1478     ac_cv_c_float_format='IEEE (little-endian)'
1479     elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1480     ac_cv_c_float_format='IEEE (little-endian)'
1481     elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1482     ac_cv_c_float_format='VAX D-float'
1483     elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1484     ac_cv_c_float_format='PDP-10'
1485     elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1486     ac_cv_c_float_format='IBM 370 hex'
1487     else
1488     AC_MSG_ERROR(Unknown floating point format)
1489     fi],
1490     [AC_MSG_ERROR(compile failed)])
1491     ])
1492     # IEEE is the default format. If the float endianness isn't the same
1493     # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1494     # (which is a tristate: yes, no, default). This is only an issue with
1495     # IEEE; the other formats are only supported by a few machines each,
1496     # all with the same endianness.
1497     format=IEEE_FLOAT_FORMAT
1498     fbigend=
1499     case $ac_cv_c_float_format in
1500     'IEEE (big-endian)' )
1501     if test $ac_cv_c_bigendian = no; then
1502     fbigend=1
1503     fi
1504     ;;
1505     'IEEE (little-endian)' )
1506     if test $ac_cv_c_bigendian = yes; then
1507     fbigend=0
1508     fi
1509     ;;
1510     'VAX D-float' )
1511     format=VAX_FLOAT_FORMAT
1512     ;;
1513     'PDP-10' )
1514     format=PDP10_FLOAT_FORMAT
1515     ;;
1516     'IBM 370 hex' )
1517     format=IBM_FLOAT_FORMAT
1518     ;;
1519     esac
1520     AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1521     [Define to the floating point format of the host machine.])
1522     if test -n "$fbigend"; then
1523     AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1524     [Define to 1 if the host machine stores floating point numbers in
1525     memory with the word containing the sign bit at the lowest address,
1526     or to 0 if it does it the other way around.
1527    
1528     This macro should not be defined if the ordering is the same as for
1529     multi-word integers.])
1530     fi
1531     ])
1532    
1533     dnl Select appropriate FPU source.
1534     gcc_AC_C_FLOAT_FORMAT
1535     AC_CHECK_HEADERS(ieee754.h ieeefp.h floatingpoint.h nan.h)
1536    
1537     for fpe in $FPE_CORE_TEST_ORDER; do
1538     case $fpe in
1539     ieee)
1540 gbeauche 1.2 case $ac_cv_c_float_format in
1541     IEEE*)
1542 gbeauche 1.1 FPE_CORE="IEEE fpu core"
1543     DEFINES="$DEFINES -DFPU_IEEE"
1544     FPUSRCS="../uae_cpu/fpu/fpu_ieee.cpp"
1545 gbeauche 1.4 dnl Math functions not mandated by C99 standard
1546     AC_CHECK_FUNCS(isnanl isinfl)
1547     dnl Math functions required by C99 standard, but probably not
1548     dnl implemented everywhere. In that case, we fall back to the
1549     dnl regular variant for doubles.
1550     AC_CHECK_FUNCS(logl log10l expl powl fabsl sqrtl)
1551     AC_CHECK_FUNCS(sinl cosl tanl sinhl coshl tanhl)
1552     AC_CHECK_FUNCS(asinl acosl atanl asinhl acoshl atanhl)
1553     AC_CHECK_FUNCS(floorl ceill)
1554 gbeauche 1.1 break
1555 gbeauche 1.2 ;;
1556     esac
1557 gbeauche 1.1 ;;
1558     x86)
1559     if [[ ":$HAVE_GCC27:$HAVE_I386:$HAVE_GAS:" = ":yes:yes:yes:" ]]; then
1560     FPE_CORE="i387 fpu core"
1561     DEFINES="$DEFINES -DFPU_X86"
1562     FPUSRCS="../uae_cpu/fpu/fpu_x86.cpp"
1563     break
1564     fi
1565     ;;
1566     uae)
1567     FPE_CORE="uae fpu core"
1568     DEFINES="$DEFINES -DFPU_UAE"
1569     FPUSRCS="../uae_cpu/fpu/fpu_uae.cpp"
1570     break
1571     ;;
1572     *)
1573     AC_MSG_ERROR([Internal configure.in script error for $fpe fpu core])
1574     ;;
1575     esac
1576     done
1577     if [[ "x$FPE_CORE" = "x" ]]; then
1578     AC_MSG_ERROR([Sorry, no suitable FPU core found in $FPE_CORE_TEST_ORDER])
1579     fi
1580    
1581     dnl Check for certain math functions
1582     AC_CHECK_FUNCS(atanh)
1583 gbeauche 1.4 AC_CHECK_FUNCS(isnan isinf finite isnormal signbit)
1584 gbeauche 1.1
1585     dnl UAE CPU sources for all non-m68k-native architectures.
1586     if [[ "x$WANT_NATIVE_M68K" = "xno" ]]; then
1587     CPUINCLUDES="-I../uae_cpu"
1588 gbeauche 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"
1589 gbeauche 1.1 fi
1590    
1591     dnl Remove the "-g" option if set for GCC.
1592     if [[ "x$HAVE_GCC27" = "xyes" ]]; then
1593 gbeauche 1.33 CFLAGS=`echo $CFLAGS | sed -e 's/-g\b//g'`
1594     CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g\b//g'`
1595 gbeauche 1.1 fi
1596    
1597 gbeauche 1.14 dnl Or if we have -IPA (MIPSPro compilers)
1598     if [[ "x$HAVE_IPA" = "xyes" ]]; then
1599     CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1600     CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1601 gbeauche 1.1 CXXFLAGS="-LANG:std $CXXFLAGS"
1602 gbeauche 1.14 LDFLAGS="$LDFLAGS -O3 -OPT:Olimit=0 -IPA"
1603 gbeauche 1.1 fi
1604    
1605     dnl Generate Makefile.
1606     AC_SUBST(DEFINES)
1607     AC_SUBST(SYSSRCS)
1608     AC_SUBST(CPUINCLUDES)
1609     AC_SUBST(CPUSRCS)
1610 gbeauche 1.23 AC_SUBST(BLESS)
1611 gbeauche 1.29 AC_SUBST(KEYCODES)
1612 cebix 1.16 AC_CONFIG_FILES([Makefile])
1613     AC_OUTPUT
1614 gbeauche 1.1
1615     dnl Print summary.
1616     echo
1617     echo Basilisk II configuration summary:
1618     echo
1619 gbeauche 1.26 echo SDL support ............................ : $SDL_SUPPORT
1620 gbeauche 1.1 echo XFree86 DGA support .................... : $WANT_XF86_DGA
1621     echo XFree86 VidMode support ................ : $WANT_XF86_VIDMODE
1622     echo fbdev DGA support ...................... : $WANT_FBDEV_DGA
1623     echo Enable video on SEGV signals ........... : $WANT_VOSF
1624     echo ESD sound support ...................... : $WANT_ESD
1625     echo GTK user interface ..................... : $WANT_GTK
1626     echo mon debugger support ................... : $WANT_MON
1627     echo Running m68k code natively ............. : $WANT_NATIVE_M68K
1628 gbeauche 1.5 echo Use JIT compiler ....................... : $WANT_JIT
1629     echo JIT debug mode ......................... : $WANT_JIT_DEBUG
1630 gbeauche 1.1 echo Floating-Point emulation core .......... : $FPE_CORE
1631     echo Assembly optimizations ................. : $ASM_OPTIMIZATIONS
1632     echo Addressing mode ........................ : $ADDRESSING_MODE
1633 gbeauche 1.21 echo Bad memory access recovery type ........ : $sigsegv_recovery
1634 gbeauche 1.1 echo
1635     echo "Configuration done. Now type \"make\" (or \"gmake\")."