ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.68
Committed: 2006-04-19T06:55:54Z (18 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.67: +1 -5 lines
Log Message:
Always build the STANDALONE_GUI hooks into Basilisk II.

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