ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.28
Committed: 2004-06-24T22:34:43Z (20 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.27: +1 -1 lines
Log Message:
Check for the "true" command better with AC_PATH_PROG. aka fix BLESS
command checking on MacOS X.

File Contents

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