ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.30
Committed: 2004-06-27T22:06:02Z (20 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.29: +36 -3 lines
Log Message:
Add configure macros to check for -framework Carbon & -framework IOKit so
that we choose to include ../MacOSX/clip_macosx.cpp, sys_darwin.cpp or not.

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