ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.67
Committed: 2006-04-16T21:25:41Z (18 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.66: +8 -7 lines
Log Message:
Make Basilisk II main application not use GTK libraries when compiling with
STANDALONE_GUI. This is the second step towards a more interesting GUI alike
to VMware. Communication from/to the GUI is held by some lightweight RPC.

Note: The step should be enough to provide a tiny GTK GUI for MacOS X.

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