ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.29
Committed: 2004-06-27T18:14:43Z (20 years, 2 months ago) by gbeauche
Branch: MAIN
Changes since 1.28: +3 -0 lines
Log Message:
Handle SDL scancode -> Mac keycode map files

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