ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.31
Committed: 2004-07-19T19:25:07Z (20 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.30: +14 -3 lines
Log Message:
SDL audio support

File Contents

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