ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.66
Committed: 2006-04-16T16:32:45Z (18 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.65: +15 -0 lines
Log Message:
Enable build of a standalone GUI (first step).

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