ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.28
Committed: 2005-06-22T16:38:15Z (19 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.27: +0 -1 lines
Log Message:
Rework sheepshaver_cpu object allocation and get rid of POSIX'ish functions.

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
3    
4     AC_INIT([SheepShaver], 2.2, [Christian.Bauer@uni-mainz.de], SheepShaver)
5     AC_CONFIG_SRCDIR(main_unix.cpp)
6     AC_PREREQ(2.52)
7     AC_CONFIG_HEADER(config.h)
8    
9     dnl Canonical system information.
10     AC_CANONICAL_HOST
11     AC_CANONICAL_TARGET
12    
13 gbeauche 1.2 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.1 dnl Options.
18     AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes])
19     AC_ARG_ENABLE(ppc-emulator, [ --enable-ppc-emulator use the selected PowerPC emulator [default=auto]], [WANT_EMULATED_PPC=$enableval], [WANT_EMULATED_PPC=auto])
20 gbeauche 1.21 AC_ARG_ENABLE(fbdev-dga, [ --enable-fbdev-dga use direct frame buffer access via /dev/fb0 [default=yes]], [WANT_FBDEV_DGA=$enableval], [WANT_FBDEV_DGA=yes])
21 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])
22 gbeauche 1.22 AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=yes]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=yes])
23 gbeauche 1.1 AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes])
24     AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes])
25 gbeauche 1.20 AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]],
26     [case "$withval" in
27     gtk1) WANT_GTK="gtk";;
28     gtk|gtk2) WANT_GTK="$withval";;
29     yes) WANT_GTK="gtk2 gtk";;
30     *) WANT_GTK="no";;
31     esac],
32     [WANT_GTK="gtk2 gtk"])
33 gbeauche 1.1 AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
34     AC_ARG_WITH(dgcc, [ --with-dgcc=COMPILER use C++ COMPILER to compile synthetic opcodes], [DYNGEN_CC=$withval])
35    
36 gbeauche 1.8 dnl Addressing mode
37     AC_ARG_ENABLE(addressing,
38     [ --enable-addressing=AM set the addressing mode to use [default=real]],
39     [case "$enableval" in
40     real) WANT_ADDRESSING_MODE="real";;
41     direct) WANT_ADDRESSING_MODE="direct";;
42 gbeauche 1.13 direct,0x*) WANT_ADDRESSING_MODE="direct"; NATMEM_OFFSET=`echo "$enableval" | sed -n '/direct,\(0[[xX]][[0-9A-Fa-f]]*\([[UuLl]]\{1,2\}\)\?\)$/s//\1/p'`;;
43 gbeauche 1.8 esac],
44     [WANT_ADDRESSING_MODE="real"]
45     )
46    
47 gbeauche 1.1 dnl SDL options.
48     AC_ARG_ENABLE(sdl-static, [ --enable-sdl-static use SDL static libraries for linking [default=no]], [WANT_SDL_STATIC=$enableval], [WANT_SDL_STATIC=no])
49     AC_ARG_ENABLE(sdl-video, [ --enable-sdl-video use SDL for video graphics [default=no]], [WANT_SDL_VIDEO=$enableval], [WANT_SDL_VIDEO=no])
50 gbeauche 1.7 AC_ARG_ENABLE(sdl-audio, [ --enable-sdl-audio use SDL for audio [default=no]], [WANT_SDL_AUDIO=$enableval], [WANT_SDL_AUDIO=no])
51 gbeauche 1.1
52     dnl Checks for programs.
53     AC_PROG_CC
54     AC_PROG_CPP
55     AC_PROG_CXX
56     AC_PROG_MAKE_SET
57     AC_PROG_INSTALL
58 gbeauche 1.3 AC_PROG_EGREP
59 gbeauche 1.16 AC_PATH_PROGS(FILE, [file false])
60     AC_PATH_PROG(PERL, [perl])
61 gbeauche 1.1
62     dnl Check for PowerPC target CPU.
63     HAVE_PPC=no
64     AC_MSG_CHECKING(for PowerPC target CPU)
65     AC_EGREP_CPP(yes,
66     [
67     #ifdef __powerpc__
68     yes
69     #endif
70     #ifdef __ppc__
71     yes
72     #endif
73     ], [AC_MSG_RESULT(yes); HAVE_PPC=yes], AC_MSG_RESULT(no))
74    
75     dnl We use native CPU if possible.
76     EMULATED_PPC=yes
77     case $WANT_EMULATED_PPC in
78     auto) [[ "x$HAVE_PPC" = "xyes" ]] && EMULATED_PPC=no;;
79     no) EMULATED_PPC=no;;
80     esac
81     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
82     AC_DEFINE(EMULATED_PPC, 1, [Define if using a PowerPC CPU emulator.])
83     fi
84    
85     dnl We use mon if possible.
86     MONSRCS=
87     case "x$WANT_MON" in
88     x/* | x.*)
89     mon_srcdir=$WANT_MON
90     WANT_MON=yes
91     ;;
92     xyes)
93     mon_srcdir=../../../mon/src
94     ;;
95     esac
96     if [[ "x$WANT_MON" = "xyes" ]]; then
97     AC_MSG_CHECKING(for mon)
98     if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
99     AC_MSG_RESULT(yes)
100     AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".])
101     MONSRCS="$mon_srcdir/mon.cpp $mon_srcdir/mon_6502.cpp $mon_srcdir/mon_z80.cpp $mon_srcdir/mon_cmd.cpp $mon_srcdir/mon_lowmem.cpp $mon_srcdir/mon_disass.cpp $mon_srcdir/mon_ppc.cpp $mon_srcdir/disass/floatformat.c $mon_srcdir/disass/i386-dis.c $mon_srcdir/disass/m68k-dis.c $mon_srcdir/disass/m68k-opc.c"
102     CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
103     AC_CHECK_LIB(ncurses, tgetent, ,
104     AC_CHECK_LIB(termcap, tgetent, ,
105     AC_CHECK_LIB(termlib, tgetent, ,
106     AC_CHECK_LIB(terminfo, tgetent, ,
107     AC_CHECK_LIB(Hcurses, tgetent, ,
108     AC_CHECK_LIB(curses, tgetent))))))
109     AC_CHECK_LIB(readline, readline)
110     AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
111     else
112     AC_MSG_RESULT(no)
113     AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
114     WANT_MON=no
115     fi
116     fi
117 gbeauche 1.11 AC_SUBST(MONSRCS)
118 gbeauche 1.1
119     dnl Checks for libraries.
120     AC_CHECK_LIB(posix4, sem_init)
121    
122     dnl Do we need SDL?
123     WANT_SDL=no
124     if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
125     WANT_SDL=yes
126     WANT_XF86_DGA=no
127     WANT_XF86_VIDMODE=no
128     WANT_FBDEV_DGA=no
129 gbeauche 1.7 SDL_SUPPORT="$SDL_SUPPORT video"
130     fi
131     if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then
132     WANT_SDL=yes
133     SDL_SUPPORT="$SDL_SUPPORT audio"
134 gbeauche 1.1 fi
135     if [[ "x$WANT_SDL" = "xyes" ]]; then
136     AC_PATH_PROG(sdl_config, "sdl-config")
137     if [[ -n "$sdl_config" ]]; then
138 gbeauche 1.9 case $target_os in
139     # Special treatment for Cygwin so that we can still use the POSIX layer
140     *cygwin*)
141     sdl_cflags="-I`$sdl_config --prefix`/include/SDL"
142     sdl_libs="-L`$sdl_config --exec-prefix`/lib -lSDL"
143     ;;
144     *)
145     sdl_cflags=`$sdl_config --cflags`
146     if [[ "x$WANT_SDL_STATIC" = "xyes" ]]; then
147     sdl_libs=`$sdl_config --static-libs`
148     else
149     sdl_libs=`$sdl_config --libs`
150     fi
151     ;;
152     esac
153 gbeauche 1.1 CFLAGS="$CFLAGS $sdl_cflags"
154     CXXFLAGS="$CXXFLAGS $sdl_cflags"
155     LIBS="$LIBS $sdl_libs"
156     else
157     WANT_SDL=no
158 gbeauche 1.15 WANT_SDL_VIDEO=no
159     WANT_SDL_AUDIO=no
160 gbeauche 1.1 fi
161 gbeauche 1.7 SDL_SUPPORT=`echo "$SDL_SUPPORT" | sed -e "s/^ //"`
162     else
163     SDL_SUPPORT="none"
164 gbeauche 1.1 fi
165    
166     dnl We need X11, if not using SDL.
167 gbeauche 1.15 if [[ "x$WANT_SDL_VIDEO" != "xyes" ]]; then
168 gbeauche 1.1 AC_PATH_XTRA
169     if [[ "x$no_x" = "xyes" ]]; then
170     AC_MSG_ERROR([You need X11 to run SheepShaver.])
171     fi
172     CFLAGS="$CFLAGS $X_CFLAGS"
173     CXXFLAGS="$CXXFLAGS $X_CFLAGS"
174     LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
175     fi
176    
177     dnl We need pthreads on non-PowerPC systems. Try libpthread first, then libc_r (FreeBSD), then PTL.
178     HAVE_PTHREADS=yes
179     case $EMULATED_PPC:$target_os in
180 gbeauche 1.17 no:linux*|no:netbsd*)
181 gbeauche 1.1 dnl We do have our own pthread_cancel() implementation
182     AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if you have the pthread_cancel function.])
183     ;;
184     *:*)
185     AC_CHECK_LIB(pthread, pthread_create, , [
186     AC_CHECK_LIB(c_r, pthread_create, , [
187     AC_CHECK_LIB(PTL, pthread_create, , [
188     AC_MSG_ERROR([You need pthreads to run Basilisk II.])
189     ])
190     ])
191     ])
192     AC_CHECK_FUNCS(pthread_cancel)
193     AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
194     AC_CHECK_FUNCS(pthread_mutexattr_settype)
195     AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
196     if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
197     AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.])
198     fi
199     dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
200     SEMSRC=
201     AC_CHECK_FUNCS(sem_init, , [
202     if test "x$HAVE_PTHREADS" = "xyes"; then
203     SEMSRC=posix_sem.cpp
204     fi
205     ])
206     ;;
207     esac
208    
209 gbeauche 1.21 dnl We use FBDev DGA if possible.
210     if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
211     AC_CHECK_HEADER(linux/fb.h, [
212     AC_DEFINE(ENABLE_FBDEV_DGA, 1, [Define if using Linux fbdev extension.])
213     ], [
214     AC_MSG_WARN([Could not find Linux FBDev extension, ignoring --enable-fbdev-dga.])
215     WANT_FBDEV_DGA=no
216     ])
217     fi
218    
219 gbeauche 1.1 dnl We use XFree86 DGA if possible.
220     if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then
221     AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [
222     AC_DEFINE(ENABLE_XF86_DGA, 1, [Define if using XFree86 DGA extension.])
223     LIBS="$LIBS -lXxf86dga"
224     ], [
225     AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.])
226     WANT_XF86_DGA=no
227     ])
228     fi
229    
230     dnl We use XFree86 VidMode if possible.
231     if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then
232     AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [
233     AC_DEFINE(ENABLE_XF86_VIDMODE, 1, [Define if using XFree86 DGA extension.])
234     LIBS="$LIBS -lXxf86vm"
235     ], [
236     AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.])
237     WANT_XF86_VIDMODE=no
238     ])
239     fi
240    
241     dnl We use GTK+ if possible.
242     UISRCS=../dummy/prefs_editor_dummy.cpp
243 gbeauche 1.20 case "x$WANT_GTK" in
244     xgtk2*)
245     AM_PATH_GTK_2_0(1.3.15, [
246     AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
247     CFLAGS="$CFLAGS $GTK_CFLAGS"
248     CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
249     LIBS="$LIBS $GTK_LIBS"
250     UISRCS=prefs_editor_gtk.cpp
251     WANT_GTK=gtk2
252     ], [
253     case "x${WANT_GTK}x" in
254     *gtkx)
255     AC_MSG_WARN([Could not find GTK+ 2.0, trying with GTK+ 1.2.])
256     WANT_GTK=gtk
257     ;;
258     *)
259     AC_MSG_WARN([Could not find GTK+, disabling user interface.])
260     WANT_GTK=no
261     ;;
262     esac
263     ])
264     ;;
265     esac
266     if [[ "x$WANT_GTK" = "xgtk" ]]; then
267 gbeauche 1.1 AM_PATH_GTK(1.2.0, [
268     AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
269     CFLAGS="$CFLAGS $GTK_CFLAGS"
270     CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
271     LIBS="$LIBS $GTK_LIBS"
272     UISRCS=prefs_editor_gtk.cpp
273     ], [
274     AC_MSG_WARN([Could not find GTK+, disabling user interface.])
275     WANT_GTK=no
276     ])
277     fi
278    
279     dnl We use ESD if possible.
280     if [[ "x$WANT_ESD" = "xyes" ]]; then
281     AM_PATH_ESD(0.2.8, [
282     AC_DEFINE(ENABLE_ESD, 1, [Define is using ESD.])
283     CFLAGS="$CFLAGS $ESD_CFLAGS"
284     CXXFLAGS="$CXXFLAGS $ESD_CFLAGS"
285     LIBS="$LIBS $ESD_LIBS"
286     ], [
287     AC_MSG_WARN([Could not find ESD, disabling ESD support.])
288     WANT_ESD=no
289     ])
290     fi
291    
292 gbeauche 1.2 dnl We use 64-bit file size support if possible.
293     AC_SYS_LARGEFILE
294    
295 gbeauche 1.1 dnl Checks for header files.
296     AC_HEADER_STDC
297     AC_HEADER_SYS_WAIT
298 gbeauche 1.9 AC_CHECK_HEADERS(malloc.h)
299 gbeauche 1.1 AC_CHECK_HEADERS(mach/vm_map.h mach/mach_init.h sys/mman.h)
300     AC_CHECK_HEADERS(sys/time.h sys/times.h sys/socket.h)
301 gbeauche 1.4 AC_CHECK_HEADERS(unistd.h fcntl.h byteswap.h dirent.h)
302 gbeauche 1.1 AC_CHECK_HEADERS(linux/if.h, [], [], [
303     #if HAVE_SYS_SOCKET_H
304     # include <sys/socket.h>
305     #endif
306     ])
307     AC_CHECK_HEADERS(linux/if_tun.h net/if.h net/if_tun.h)
308 gbeauche 1.10 AC_CHECK_HEADERS(fenv.h)
309 gbeauche 1.1
310     dnl Checks for typedefs, structures, and compiler characteristics.
311     AC_C_BIGENDIAN
312     AC_C_CONST
313     AC_C_INLINE
314     AC_CHECK_SIZEOF(short, 2)
315     AC_CHECK_SIZEOF(int, 4)
316     AC_CHECK_SIZEOF(long, 4)
317     AC_CHECK_SIZEOF(long long, 8)
318     AC_CHECK_SIZEOF(float, 4)
319     AC_CHECK_SIZEOF(double, 8)
320     AC_CHECK_SIZEOF(void *, 4)
321     AC_TYPE_OFF_T
322     AC_CHECK_TYPE(loff_t, off_t)
323     AC_TYPE_SIZE_T
324     AC_TYPE_SIGNAL
325     AC_HEADER_TIME
326     AC_STRUCT_TM
327    
328     dnl Check whether struct sigaction has sa_restorer member.
329     AC_CACHE_CHECK([whether struct sigaction has sa_restorer],
330     ac_cv_signal_sa_restorer, [
331     AC_TRY_COMPILE([
332     #include <signal.h>
333     ], [struct sigaction sa; sa.sa_restorer = 0;],
334     ac_cv_signal_sa_restorer=yes, ac_cv_signal_sa_restorer=no,
335     dnl When cross-compiling, do not assume anything.
336     ac_cv_signal_sa_restorer=no
337     )
338     ])
339     if [[ "x$ac_cv_signal_sa_restorer" = "xyes" ]]; then
340     AC_DEFINE(HAVE_SIGNAL_SA_RESTORER, 1, [Define if sa_restorer is available in struct sigaction.])
341     fi
342    
343     dnl Checks for library functions.
344     AC_CHECK_FUNCS(strdup strlcpy cfmakeraw)
345     AC_CHECK_FUNCS(nanosleep)
346     AC_CHECK_FUNCS(sigaction signal)
347     AC_CHECK_FUNCS(mmap mprotect munmap)
348     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
349 gbeauche 1.26 AC_CHECK_FUNCS(exp2f log2f exp2 log2)
350     AC_CHECK_FUNCS(floorf roundf ceilf truncf floor round ceil trunc)
351 gbeauche 1.1
352     dnl Darwin seems to define mach_task_self() instead of task_self().
353     AC_CHECK_FUNCS(mach_task_self task_self)
354    
355     dnl We need clock_gettime() for better performance but it may drag
356     dnl libpthread in, which we don't want for native ppc mode
357     case $EMULATED_PPC:$target_os in
358     no:linux*)
359     ;;
360     *:*)
361     AC_SEARCH_LIBS(clock_gettime, [rt posix4])
362 gbeauche 1.18 AC_CHECK_FUNCS(clock_gettime clock_nanosleep)
363 gbeauche 1.1 ;;
364     esac
365    
366 gbeauche 1.9 dnl Check for headers and functions related to pty support (sshpty.c)
367     dnl From openssh-3.2.2p1 configure.ac
368     AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
369     AC_CHECK_FUNCS(_getpty vhangup strlcpy)
370    
371     case "$host" in
372     *-*-hpux10.26)
373     disable_ptmx_check=yes
374     ;;
375     *-*-linux*)
376     no_dev_ptmx=1
377     ;;
378     mips-sony-bsd|mips-sony-newsos4)
379     AC_DEFINE(HAVE_NEWS4, 1, [Define if you are on NEWS-OS (additions from openssh-3.2.2p1, for sshpty.c).])
380     ;;
381     *-*-sco3.2v4*)
382     no_dev_ptmx=1
383     ;;
384     *-*-sco3.2v5*)
385     no_dev_ptmx=1
386     ;;
387     *-*-cygwin*)
388     no_dev_ptmx=1
389     ;;
390     esac
391    
392     if test -z "$no_dev_ptmx" ; then
393     if test "x$disable_ptmx_check" != "xyes" ; then
394     AC_CHECK_FILE([/dev/ptmx],
395     [
396     AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.])
397     have_dev_ptmx=1
398     ]
399     )
400     fi
401     fi
402     AC_CHECK_FILE([/dev/ptc],
403     [
404     AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.])
405     have_dev_ptc=1
406     ]
407     )
408     dnl (end of code from openssh-3.2.2p1 configure.ac)
409    
410 gbeauche 1.1 dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
411     AC_DEFUN(AC_CHECK_FRAMEWORK, [
412     AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
413     AC_CACHE_CHECK([whether compiler supports framework $1],
414     ac_Framework, [
415     saved_LIBS="$LIBS"
416     LIBS="$LIBS -framework $1"
417     AC_TRY_LINK(
418     [$2], [int main(void) { return 0; }],
419     [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
420     )
421     ])
422     AS_IF([test AS_VAR_GET(ac_Framework) = yes],
423     [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
424     )
425     AS_VAR_POPDEF([ac_Framework])dnl
426     ])
427    
428     dnl Check for some MacOS X frameworks
429     AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
430     AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
431    
432     dnl Select system-dependant sources.
433     SERIALSRC=serial_unix.cpp
434     ETHERSRC=../dummy/ether_dummy.cpp
435     SCSISRC=../dummy/scsi_dummy.cpp
436     AUDIOSRC=../dummy/audio_dummy.cpp
437 gbeauche 1.6 EXTFSSRC=extfs_unix.cpp
438 gbeauche 1.1 EXTRASYSSRCS=
439     case "$target_os" in
440     linux*)
441     ETHERSRC=Linux/ether_linux.cpp
442     AUDIOSRC=audio_oss_esd.cpp
443     SCSISRC=Linux/scsi_linux.cpp
444     if [[ "x$EMULATED_PPC" = "xno" ]]; then
445 gbeauche 1.17 EXTRASYSSRCS="Linux/paranoia.cpp Linux/sheepthreads.c ppc_asm.S"
446     fi
447     ;;
448     netbsd*)
449     if [[ "x$EMULATED_PPC" = "xno" ]]; then
450     EXTRASYSSRCS="NetBSD/paranoia.cpp NetBSD/sheepthreads.c ppc_asm.S"
451 gbeauche 1.1 fi
452     ;;
453     darwin*)
454     if [[ "x$EMULATED_PPC" = "xno" ]]; then
455 gbeauche 1.17 EXTRASYSSRCS="Darwin/paranoia.cpp ppc_asm.S"
456 gbeauche 1.1 fi
457     if [[ "x$ac_cv_framework_IOKit" = "xyes" ]]; then
458     EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/sys_darwin.cpp"
459     fi
460 gbeauche 1.6 if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
461     EXTFSSRC=../MacOSX/extfs_macosx.mm
462     fi
463 gbeauche 1.1 ;;
464 gbeauche 1.9 cygwin*)
465     SERIALSRC="../dummy/serial_dummy.cpp"
466     ;;
467 gbeauche 1.1 esac
468    
469     dnl SDL overrides
470     if [[ "x$WANT_SDL" = "xyes" ]]; then
471     AC_DEFINE(USE_SDL, 1, [Define to enble SDL support.])
472     fi
473     if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
474 gbeauche 1.7 AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support.])
475 gbeauche 1.1 VIDEOSRCS="../SDL/video_sdl.cpp"
476     KEYCODES="../SDL/keycodes"
477     if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
478     EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp"
479     else
480 gbeauche 1.9 case "$target_os" in
481     cygwin*)
482     EXTRASYSSRCS="$EXTRASYSSRCS ../Windows/clip_windows.cpp"
483     ;;
484     *)
485     EXTRASYSSRCS="$EXTRASYSSRCS ../dummy/clip_dummy.cpp"
486     ;;
487     esac
488 gbeauche 1.1 fi
489     else
490     VIDEOSRCS="video_x.cpp"
491     KEYCODES="keycodes"
492     EXTRASYSSRCS="$EXTRASYSSRCS clip_unix.cpp"
493     fi
494 gbeauche 1.7 if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then
495     AC_DEFINE(USE_SDL_AUDIO, 1, [Define to enable SDL audio support])
496     AUDIOSRC="../SDL/audio_sdl.cpp"
497     fi
498 gbeauche 1.1
499 gbeauche 1.11 SYSSRCS="$VIDEOSRCS $EXTFSSRC $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $EXTRASYSSRCS"
500 gbeauche 1.1
501     dnl Define a macro that translates a yesno-variable into a C macro definition
502     dnl to be put into the config.h file
503     dnl $1 -- the macro to define
504     dnl $2 -- the value to translate
505     dnl $3 -- template name
506     AC_DEFUN(AC_TRANSLATE_DEFINE, [
507     if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
508     AC_DEFINE($1, 1, $3)
509     fi
510     ])
511    
512     dnl Check that the host supports TUN/TAP devices
513     AC_CACHE_CHECK([whether TUN/TAP is supported],
514     ac_cv_tun_tap_support, [
515     AC_TRY_COMPILE([
516     #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
517     #include <linux/if.h>
518     #include <linux/if_tun.h>
519     #endif
520     #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
521     #include <net/if.h>
522     #include <net/if_tun.h>
523     #endif
524     ], [
525     struct ifreq ifr;
526     memset(&ifr, 0, sizeof(ifr));
527     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
528     ],
529     ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
530     )
531     ])
532     AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
533     [Define if your system supports TUN/TAP devices.])
534    
535     dnl Various checks if the system supports vm_allocate() and the like functions.
536     have_mach_vm=no
537     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
538     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
539     have_mach_vm=yes
540     fi
541     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
542     [Define if your system has a working vm_allocate()-based memory allocator.])
543    
544     dnl Check that vm_allocate(), vm_protect() work
545     if [[ "x$have_mach_vm" = "xyes" ]]; then
546    
547     AC_CACHE_CHECK([whether vm_protect works],
548     ac_cv_vm_protect_works, [
549     AC_LANG_SAVE
550     AC_LANG_CPLUSPLUS
551     ac_cv_vm_protect_works=yes
552     dnl First the tests that should segfault
553     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
554     AC_TRY_RUN([
555     #define CONFIGURE_TEST_VM_MAP
556     #define TEST_VM_PROT_$test_def
557     #include "vm_alloc.cpp"
558     ], ac_cv_vm_protect_works=no, rm -f core,
559     dnl When cross-compiling, do not assume anything
560     ac_cv_vm_protect_works="guessing no"
561     )
562     done
563     AC_TRY_RUN([
564     #define CONFIGURE_TEST_VM_MAP
565     #define TEST_VM_PROT_RDWR_WRITE
566     #include "vm_alloc.cpp"
567     ], , ac_cv_vm_protect_works=no,
568     dnl When cross-compiling, do not assume anything
569     ac_cv_vm_protect_works="guessing no"
570     )
571     AC_LANG_RESTORE
572     ]
573     )
574    
575     dnl Remove support for vm_allocate() if vm_protect() does not work
576     if [[ "x$have_mach_vm" = "xyes" ]]; then
577     case $ac_cv_vm_protect_works in
578     *yes) have_mach_vm=yes;;
579     *no) have_mach_vm=no;;
580     esac
581     fi
582     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
583     [Define if your system has a working vm_allocate()-based memory allocator.])
584    
585     fi dnl HAVE_MACH_VM
586    
587     dnl Various checks if the system supports mmap() and the like functions.
588     dnl ... and Mach memory allocators are not supported
589     have_mmap_vm=no
590     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
591     "x$ac_cv_func_mprotect" = "xyes" ]]; then
592     if [[ "x$have_mach_vm" = "xno" ]]; then
593     have_mmap_vm=yes
594     fi
595     fi
596     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
597     [Define if your system has a working mmap()-based memory allocator.])
598    
599     dnl Check that mmap() and associated functions work.
600     if [[ "x$have_mmap_vm" = "xyes" ]]; then
601    
602     dnl Check if we have a working anonymous mmap()
603     AC_CACHE_CHECK([whether mmap supports MAP_ANON],
604     ac_cv_mmap_anon, [
605     AC_LANG_SAVE
606     AC_LANG_CPLUSPLUS
607     AC_TRY_RUN([
608     #define HAVE_MMAP_ANON
609     #define CONFIGURE_TEST_VM_MAP
610     #define TEST_VM_MMAP_ANON
611     #include "vm_alloc.cpp"
612     ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
613     dnl When cross-compiling, do not assume anything.
614     ac_cv_mmap_anon="guessing no"
615     )
616     AC_LANG_RESTORE
617     ]
618     )
619     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
620     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
621    
622     AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
623     ac_cv_mmap_anonymous, [
624     AC_LANG_SAVE
625     AC_LANG_CPLUSPLUS
626     AC_TRY_RUN([
627     #define HAVE_MMAP_ANONYMOUS
628     #define CONFIGURE_TEST_VM_MAP
629     #define TEST_VM_MMAP_ANON
630     #include "vm_alloc.cpp"
631     ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
632     dnl When cross-compiling, do not assume anything.
633     ac_cv_mmap_anonymous="guessing no"
634     )
635     AC_LANG_RESTORE
636     ]
637     )
638     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
639     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
640    
641     AC_CACHE_CHECK([whether mprotect works],
642     ac_cv_mprotect_works, [
643     AC_LANG_SAVE
644     AC_LANG_CPLUSPLUS
645     ac_cv_mprotect_works=yes
646     dnl First the tests that should segfault
647     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
648     AC_TRY_RUN([
649     #define CONFIGURE_TEST_VM_MAP
650     #define TEST_VM_PROT_$test_def
651     #include "vm_alloc.cpp"
652     ], ac_cv_mprotect_works=no, rm -f core,
653     dnl When cross-compiling, do not assume anything
654     ac_cv_mprotect_works="guessing no"
655     )
656     done
657     AC_TRY_RUN([
658     #define CONFIGURE_TEST_VM_MAP
659     #define TEST_VM_PROT_RDWR_WRITE
660     #include "vm_alloc.cpp"
661     ], , ac_cv_mprotect_works=no,
662     dnl When cross-compiling, do not assume anything
663     ac_cv_mprotect_works="guessing no"
664     )
665     AC_LANG_RESTORE
666     ]
667     )
668    
669     dnl Remove support for mmap() if mprotect() does not work
670     if [[ "x$have_mmap_vm" = "xyes" ]]; then
671     case $ac_cv_mprotect_works in
672     *yes) have_mmap_vm=yes;;
673     *no) have_mmap_vm=no;;
674     esac
675     fi
676     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
677     [Define if your system has a working mmap()-based memory allocator.])
678    
679     fi dnl HAVE_MMAP_VM
680    
681     dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
682     AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000],
683     ac_cv_pagezero_hack, [
684     ac_cv_pagezero_hack=no
685     if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then
686     ac_cv_pagezero_hack=yes
687     dnl might as well skip the test for mmap-able low memory
688     ac_cv_can_map_lm=no
689     fi
690     ])
691     AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
692     [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
693    
694     dnl Check if we can mmap 0x3000 bytes from 0x0000
695     AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000],
696     ac_cv_can_map_lm, [
697     AC_LANG_SAVE
698     AC_LANG_CPLUSPLUS
699     AC_TRY_RUN([
700     #include "vm_alloc.cpp"
701     int main(void) { /* returns 0 if we could map the lowmem globals */
702     volatile char * lm = 0;
703     if (vm_init() < 0) exit(1);
704     if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
705     lm[0] = 'z';
706     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
707     vm_exit(); exit(0);
708     }
709     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
710     dnl When cross-compiling, do not assume anything.
711     ac_cv_can_map_lm="guessing no"
712     )
713     AC_LANG_RESTORE
714     ]
715     )
716    
717     dnl Check signal handlers need to be reinstalled
718     AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
719     ac_cv_signal_need_reinstall, [
720     AC_LANG_SAVE
721     AC_LANG_CPLUSPLUS
722     AC_TRY_RUN([
723     #include <stdlib.h>
724     #ifdef HAVE_UNISTD_H
725     #include <unistd.h>
726     #endif
727     #include <signal.h>
728     static int handled_signal = 0;
729     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
730     int main(void) { /* returns 0 if signals need not to be reinstalled */
731     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
732     exit(handled_signal == 2);
733     }
734     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
735     dnl When cross-compiling, do not assume anything.
736     ac_cv_signal_need_reinstall="guessing yes"
737     )
738     AC_LANG_RESTORE
739     ]
740     )
741     AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
742     [Define if your system requires signals to be reinstalled.])
743    
744     dnl Check if sigaction handlers need to be reinstalled
745     AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
746     ac_cv_sigaction_need_reinstall, [
747     AC_LANG_SAVE
748     AC_LANG_CPLUSPLUS
749     AC_TRY_RUN([
750     #include <stdlib.h>
751     #ifdef HAVE_UNISTD_H
752     #include <unistd.h>
753     #endif
754     #include <signal.h>
755     static int handled_signal = 0;
756     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
757     typedef RETSIGTYPE (*signal_handler)(int);
758     static signal_handler mysignal(int sig, signal_handler handler) {
759     struct sigaction old_sa;
760     struct sigaction new_sa;
761     new_sa.sa_handler = handler;
762     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
763     }
764     int main(void) { /* returns 0 if signals need not to be reinstalled */
765     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
766     exit(handled_signal == 2);
767     }
768     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
769     dnl When cross-compiling, do not assume anything.
770     ac_cv_sigaction_need_reinstall="guessing yes"
771     )
772     AC_LANG_RESTORE
773     ]
774     )
775     AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
776     [Define if your system requires sigactions to be reinstalled.])
777    
778     dnl Check if Mach exceptions supported.
779     AC_CACHE_CHECK([whether your system supports Mach exceptions],
780     ac_cv_have_mach_exceptions, [
781     AC_LANG_SAVE
782     AC_LANG_CPLUSPLUS
783     AC_TRY_RUN([
784     #define HAVE_MACH_EXCEPTIONS 1
785     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
786     #include "vm_alloc.cpp"
787     #include "sigsegv.cpp"
788     ],
789     ac_cv_have_mach_exceptions=yes,
790     ac_cv_have_mach_exceptions=no,
791     dnl When cross-compiling, do not assume anything.
792     ac_cv_have_mach_exceptions=no
793     )
794     AC_LANG_RESTORE
795     ]
796     )
797     if [[ "$ac_cv_have_mach_exceptions" = "yes" ]]; then
798     sigsegv_recovery=mach
799     fi
800     AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
801     [Define if your system supports Mach exceptions.])
802    
803 gbeauche 1.9 dnl Check if Windows exceptions are supported.
804     AC_CACHE_CHECK([whether your system supports Windows exceptions],
805     ac_cv_have_win32_exceptions, [
806     AC_LANG_SAVE
807     AC_LANG_CPLUSPLUS
808     AC_TRY_RUN([
809     #define HAVE_WIN32_EXCEPTIONS 1
810     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
811     #include "vm_alloc.cpp"
812     #include "sigsegv.cpp"
813     ], [
814     sigsegv_recovery=win32
815     ac_cv_have_win32_exceptions=yes
816     ],
817     ac_cv_have_win32_exceptions=no,
818     dnl When cross-compiling, do not assume anything.
819     ac_cv_have_win32_exceptions=no
820     )
821     AC_LANG_RESTORE
822     ]
823     )
824     AC_TRANSLATE_DEFINE(HAVE_WIN32_EXCEPTIONS, "$ac_cv_have_win32_exceptions",
825     [Define if your system supports Windows exceptions.])
826    
827 gbeauche 1.1 dnl Otherwise, check if extended signals are supported.
828     if [[ -z "$sigsegv_recovery" ]]; then
829     AC_CACHE_CHECK([whether your system supports extended signal handlers],
830     ac_cv_have_extended_signals, [
831     AC_LANG_SAVE
832     AC_LANG_CPLUSPLUS
833     AC_TRY_RUN([
834     #define HAVE_SIGINFO_T 1
835     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
836     #include "vm_alloc.cpp"
837     #include "sigsegv.cpp"
838     ],
839     ac_cv_have_extended_signals=yes,
840     ac_cv_have_extended_signals=no,
841     dnl When cross-compiling, do not assume anything.
842     ac_cv_have_extended_signals=no
843     )
844     AC_LANG_RESTORE
845     ]
846     )
847     if [[ "$ac_cv_have_extended_signals" = "yes" ]]; then
848     sigsegv_recovery=siginfo
849     fi
850     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
851     [Define if your system support extended signals.])
852     fi
853    
854     dnl Otherwise, check for subterfuges.
855     if [[ -z "$sigsegv_recovery" ]]; then
856     AC_CACHE_CHECK([whether we then have a subterfuge for your system],
857     ac_cv_have_sigcontext_hack, [
858     AC_LANG_SAVE
859     AC_LANG_CPLUSPLUS
860     AC_TRY_RUN([
861     #define HAVE_SIGCONTEXT_SUBTERFUGE 1
862     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
863     #include "vm_alloc.cpp"
864     #include "sigsegv.cpp"
865     ],
866     ac_cv_have_sigcontext_hack=yes,
867     ac_cv_have_sigcontext_hack=no,
868     dnl When cross-compiling, do not assume anything.
869     ac_cv_have_sigcontext_hack=no
870     )
871     AC_LANG_RESTORE
872     ])
873     if [[ "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
874     sigsegv_recovery=sigcontext
875     fi
876     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
877     [Define if we know a hack to replace siginfo_t->si_addr member.])
878     fi
879    
880     dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
881     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
882     ac_cv_have_skip_instruction, [
883     AC_LANG_SAVE
884     AC_LANG_CPLUSPLUS
885     AC_TRY_RUN([
886     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
887     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
888     #include "vm_alloc.cpp"
889     #include "sigsegv.cpp"
890     ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
891     dnl When cross-compiling, do not assume anything.
892     ac_cv_have_skip_instruction=no
893     )
894     AC_LANG_RESTORE
895     ]
896     )
897     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
898     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
899    
900     dnl Can we do Video on SEGV Signals ?
901     CAN_VOSF=no
902     if [[ -n "$sigsegv_recovery" ]]; then
903     CAN_VOSF=yes
904     fi
905    
906     dnl Enable VOSF screen updates with this feature is requested and feasible
907     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
908     AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
909     else
910     WANT_VOSF=no
911     fi
912    
913 gbeauche 1.8 dnl Check addressing mode to use
914     AC_MSG_CHECKING([for addressing mode to use])
915 gbeauche 1.9 case "$os_target" in
916     cygwin*)
917     WANT_ADDRESSING_MODE="direct,cygwin-hack"
918     NATMEM_OFFSET=
919     ;;
920     esac
921 gbeauche 1.8 if [[ "$EMULATED_PPC" != "yes" ]]; then
922     if [[ "$WANT_ADDRESSING_MODE" != "real" ]]; then
923     AC_MSG_WARN([Running in native PowerPC mode, force use of Real Addressing.])
924     WANT_ADDRESSING_MODE="real"
925     fi
926     fi
927     if [[ "$WANT_ADDRESSING_MODE" = "direct" ]]; then
928     if [[ -n "$NATMEM_OFFSET" ]]; then
929     NATMEM_OFFSET_DEF="-DNATMEM_OFFSET=$NATMEM_OFFSET"
930     fi
931     AC_LANG_SAVE
932     AC_LANG_CPLUSPLUS
933     cat confdefs.h > conftest.$ac_ext
934     cat >> conftest.$ac_ext << EOF
935     #include <stdio.h>
936     #include <string.h>
937     #include "vm_alloc.cpp"
938    
939     int main(void)
940     {
941     if (vm_init() < 0)
942     return 1;
943    
944     static const struct {
945     unsigned long base;
946     unsigned int size;
947     } ranges[[]] = {
948     { 0x00000000, 0x0003000 },
949     { 0x10000000, 0x2000000 },
950     { 0x40800000, 0x0400000 },
951     { 0x68070000, 0x0010000 },
952     { 0x69000000, 0x0080000 },
953     { 0x68ffe000, 0x0002000 },
954     { 0x5fffe000, 0x0002000 },
955     { 0x60000000, 0x0040000 },
956     };
957     const int n_ranges = sizeof(ranges)/ sizeof(ranges[[0]]);
958    
959     #ifdef NATMEM_OFFSET
960     unsigned long ofs = NATMEM_OFFSET;
961     #else
962     for (unsigned long ofs = 0x10000000; ofs <= 0x90000000; ofs += 0x10000000)
963     #endif
964     for (int i = 0; i < n_ranges; i++) {
965     char *m = (char *)(ranges[[i]].base + ofs);
966     if (vm_acquire_fixed(m, ranges[[i]].size) != 0)
967     break;
968     memset(m, 0, ranges[[i]].size);
969     vm_release(m, ranges[[i]].size);
970     if (i == n_ranges - 1) {
971 gbeauche 1.13 if (sizeof(void *) == 8 && ofs > 0xffffffff)
972     printf("0x%lxul\n", ofs);
973     else
974     printf("0x%08x\n", ofs);
975 gbeauche 1.8 return 0;
976     }
977     }
978    
979     vm_exit();
980     return 1;
981     }
982     EOF
983     doit='$CXX conftest.$ac_ext -o conftest.$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS $NATMEM_OFFSET_DEF >& AS_MESSAGE_LOG_FD'
984     if AC_TRY_EVAL(doit); then
985     NATMEM_OFFSET=`./conftest.$ac_exeext`
986 gbeauche 1.9 else
987     NATMEM_OFFSET=
988 gbeauche 1.8 fi
989     rm -f conftest*
990     AC_LANG_RESTORE
991 gbeauche 1.9
992     if [[ -z "$NATMEM_OFFSET" ]]; then
993     AC_MSG_ERROR([could not determine a sensible NATMEM_OFFSET value])
994     else
995     WANT_ADDRESSING_MODE="direct,$NATMEM_OFFSET"
996     AC_DEFINE_UNQUOTED(NATMEM_OFFSET, $NATMEM_OFFSET,
997     [Define constant offset for Mac address translation])
998     fi
999 gbeauche 1.8 fi
1000     AC_MSG_RESULT($WANT_ADDRESSING_MODE)
1001    
1002 gbeauche 1.26 dnl Utility macro used by next two tests.
1003     dnl AC_EXAMINE_OBJECT(C source code,
1004     dnl commands examining object file,
1005     dnl [commands to run if compile failed]):
1006     dnl
1007     dnl Compile the source code to an object file; then convert it into a
1008     dnl printable representation. All unprintable characters and
1009     dnl asterisks (*) are replaced by dots (.). All white space is
1010     dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
1011     dnl output, but runs of newlines are compressed to a single newline.
1012     dnl Finally, line breaks are forcibly inserted so that no line is
1013     dnl longer than 80 columns and the file ends with a newline. The
1014     dnl result of all this processing is in the file conftest.dmp, which
1015     dnl may be examined by the commands in the second argument.
1016     dnl
1017     AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
1018     [AC_LANG_SAVE
1019     AC_LANG_C
1020     dnl Next bit cribbed from AC_TRY_COMPILE.
1021     cat > conftest.$ac_ext <<EOF
1022     [#line __oline__ "configure"
1023     #include "confdefs.h"
1024     $1
1025     ]EOF
1026     if AC_TRY_EVAL(ac_compile); then
1027     od -c conftest.o |
1028     sed ['s/^[0-7]*[ ]*/ /
1029     s/\*/./g
1030     s/ \\n/*/g
1031     s/ [0-9][0-9][0-9]/./g
1032     s/ \\[^ ]/./g'] |
1033     tr -d '
1034     ' | tr -s '*' '
1035     ' | fold | sed '$a\
1036     ' > conftest.dmp
1037     $2
1038     ifelse($3, , , else
1039     $3
1040     )dnl
1041     fi
1042     rm -rf conftest*
1043     AC_LANG_RESTORE])
1044    
1045     dnl Floating point format probe.
1046     dnl The basic concept is the same as the above: grep the object
1047     dnl file for an interesting string. We have to watch out for
1048     dnl rounding changing the values in the object, however; this is
1049     dnl handled by ignoring the least significant byte of the float.
1050     dnl
1051     dnl Does not know about VAX G-float or C4x idiosyncratic format.
1052     dnl It does know about PDP-10 idiosyncratic format, but this is
1053     dnl not presently supported by GCC. S/390 "binary floating point"
1054     dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
1055     dnl as ASCII?)
1056     dnl
1057     AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
1058     [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
1059     [gcc_AC_EXAMINE_OBJECT(
1060     [/* This will not work unless sizeof(double) == 8. */
1061     extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1062    
1063     /* This structure must have no internal padding. */
1064     struct possibility {
1065     char prefix[8];
1066     double candidate;
1067     char postfix[8];
1068     };
1069    
1070     #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1071     struct possibility table [] =
1072     {
1073     C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1074     C( 3.53802595280598432000e+18), /* D__float - VAX */
1075     C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1076     C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1077     C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
1078     };],
1079     [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1080     ac_cv_c_float_format='IEEE (big-endian)'
1081     elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1082     ac_cv_c_float_format='IEEE (big-endian)'
1083     elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1084     ac_cv_c_float_format='IEEE (little-endian)'
1085     elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1086     ac_cv_c_float_format='IEEE (little-endian)'
1087     elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1088     ac_cv_c_float_format='VAX D-float'
1089     elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1090     ac_cv_c_float_format='PDP-10'
1091     elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1092     ac_cv_c_float_format='IBM 370 hex'
1093     else
1094     AC_MSG_ERROR(Unknown floating point format)
1095     fi],
1096     [AC_MSG_ERROR(compile failed)])
1097     ])
1098     # IEEE is the default format. If the float endianness isn't the same
1099     # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1100     # (which is a tristate: yes, no, default). This is only an issue with
1101     # IEEE; the other formats are only supported by a few machines each,
1102     # all with the same endianness.
1103     format=IEEE_FLOAT_FORMAT
1104     fbigend=
1105     case $ac_cv_c_float_format in
1106     'IEEE (big-endian)' )
1107     if test $ac_cv_c_bigendian = no; then
1108     fbigend=1
1109     fi
1110     ;;
1111     'IEEE (little-endian)' )
1112     if test $ac_cv_c_bigendian = yes; then
1113     fbigend=0
1114     fi
1115     ;;
1116     'VAX D-float' )
1117     format=VAX_FLOAT_FORMAT
1118     ;;
1119     'PDP-10' )
1120     format=PDP10_FLOAT_FORMAT
1121     ;;
1122     'IBM 370 hex' )
1123     format=IBM_FLOAT_FORMAT
1124     ;;
1125     esac
1126     AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1127     [Define to the floating point format of the host machine.])
1128     if test -n "$fbigend"; then
1129     AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1130     [Define to 1 if the host machine stores floating point numbers in
1131     memory with the word containing the sign bit at the lowest address,
1132     or to 0 if it does it the other way around.
1133    
1134     This macro should not be defined if the ordering is the same as for
1135     multi-word integers.])
1136     fi
1137     ])
1138    
1139     dnl Check for host float format
1140     gcc_AC_C_FLOAT_FORMAT
1141    
1142 gbeauche 1.1 dnl Platform specific binary postprocessor
1143     AC_PATH_PROG(BLESS, "true")
1144     if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
1145     BLESS=Darwin/lowmem
1146     LDFLAGS="$LDFLAGS -pagezero_size 0x3000"
1147     fi
1148    
1149     dnl Check for GCC 2.7 or higher.
1150     HAVE_GCC27=no
1151     AC_MSG_CHECKING(for GCC 2.7 or higher)
1152     AC_EGREP_CPP(xyes,
1153     [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
1154     xyes
1155     #endif
1156     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
1157    
1158     dnl Check for GCC 3.0 or higher.
1159     HAVE_GCC30=no
1160     AC_MSG_CHECKING(for GCC 3.0 or higher)
1161     AC_EGREP_CPP(xyes,
1162     [#if __GNUC__ >= 3
1163     xyes
1164     #endif
1165     ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
1166    
1167     dnl Check for ICC.
1168     AC_MSG_CHECKING(for ICC)
1169     HAVE_ICC=no
1170     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
1171     HAVE_ICC=yes
1172     fi
1173     AC_MSG_RESULT($HAVE_ICC)
1174    
1175 gbeauche 1.9 dnl Determine the generated object format
1176 gbeauche 1.24 AC_CACHE_CHECK([the format of compiler generated objects],
1177 gbeauche 1.9 ac_cv_object_format, [
1178 gbeauche 1.1 echo 'int i;' > conftest.$ac_ext
1179 gbeauche 1.9 ac_cv_object_format=no
1180 gbeauche 1.1 if AC_TRY_EVAL(ac_compile); then
1181     case `/usr/bin/file conftest.$ac_objext` in
1182     *"ELF"*)
1183 gbeauche 1.9 ac_cv_object_format=elf
1184     ;;
1185 gbeauche 1.24 *"Mach-O"*)
1186     ac_cv_object_format=mach
1187     ;;
1188 gbeauche 1.9 *)
1189     ac_cv_object_format=unknown
1190 gbeauche 1.1 ;;
1191     esac
1192     fi
1193     rm -rf conftest*
1194     ])
1195    
1196     dnl CPU emulator sources
1197     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
1198     CPUSRCS="\
1199 gbeauche 1.9 ../kpx_cpu/src/mathlib/ieeefp.cpp \
1200 gbeauche 1.26 ../kpx_cpu/src/mathlib/mathlib.cpp \
1201 gbeauche 1.1 ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
1202     ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
1203     ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
1204     ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp"
1205     CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
1206    
1207     dnl Enable JIT compiler, if possible
1208     if [[ "x$WANT_JIT" = "xyes" ]]; then
1209     AC_CACHE_CHECK([whether dyngen can be used],
1210     ac_cv_use_dyngen, [
1211 gbeauche 1.9 case $host_cpu:$ac_cv_object_format in
1212     powerpc:elf)
1213 gbeauche 1.1 ac_cv_use_dyngen=yes
1214     ;;
1215 gbeauche 1.9 x86_64:elf)
1216 gbeauche 1.1 ac_cv_use_dyngen=yes
1217     ;;
1218 gbeauche 1.9 i?86:elf)
1219 gbeauche 1.1 ac_cv_use_dyngen=yes
1220     ;;
1221 gbeauche 1.24 powerpc:mach)
1222     ac_cv_use_dyngen=yes
1223     ;;
1224 gbeauche 1.1 *:*)
1225     ac_cv_use_dyngen=no
1226     ;;
1227     esac
1228     dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
1229     if [[ -z "$DYNGEN_CC" ]]; then
1230     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1231     DYNGEN_CC=$CXX
1232     else
1233     for p in /usr/bin /usr/local/bin; do
1234     gxx="$p/g++"
1235     if [[ -x "$gxx" ]]; then
1236     DYNGEN_CC="$gxx"
1237     fi
1238     done
1239     fi
1240     fi
1241 gbeauche 1.27 if [[ -z "$DYNGEN_CC" ]]; then
1242 gbeauche 1.1 ac_cv_use_dyngen=no
1243     fi
1244     ])
1245     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1246     case $host_cpu in
1247     i?86)
1248     DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2"
1249 gbeauche 1.24 ;;
1250     powerpc)
1251     if [[ "x$ac_cv_object_format" = "xmach" ]]; then
1252     DYNGEN_OP_FLAGS="-mdynamic-no-pic"
1253 gbeauche 1.1 fi
1254     ;;
1255     esac
1256 gbeauche 1.24 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1257     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0"
1258     else
1259     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
1260     fi
1261     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000 -fno-exceptions -g0"
1262 gbeauche 1.1 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1263     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
1264     fi
1265     else
1266     WANT_JIT=no
1267     fi
1268     AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
1269     if [[ "x$WANT_JIT" = "xyes" ]]; then
1270     DYNGENSRCS="\
1271     ../kpx_cpu/src/cpu/jit/dyngen.c \
1272     ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
1273     CPUSRCS="\
1274     ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
1275     ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
1276     ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS"
1277     fi
1278     fi
1279     CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
1280     else
1281     WANT_JIT=no
1282     fi
1283     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1284     AC_CACHE_CHECK([whether static data regions are executable],
1285     ac_cv_have_static_data_exec, [
1286     AC_TRY_RUN([int main(void) {
1287 gbeauche 1.25 #if defined(__powerpc__) || defined(__ppc__)
1288 gbeauche 1.1 static unsigned int p[8] = {0x4e800020,};
1289     asm volatile("dcbst 0,%0" : : "r" (p) : "memory");
1290     asm volatile("sync" : : : "memory");
1291     asm volatile("icbi 0,%0" : : "r" (p) : "memory");
1292     asm volatile("sync" : : : "memory");
1293     asm volatile("isync" : : : "memory");
1294     ((void (*)(void))p)();
1295     return 0;
1296     #endif
1297     return 1;
1298     }], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no,
1299     dnl When cross-compiling, do not assume anything.
1300     ac_cv_have_static_data_exec=no
1301     )
1302     ])
1303 gbeauche 1.14 else
1304     ac_cv_use_dyngen=no
1305 gbeauche 1.1 fi
1306     AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec",
1307     [Define if your system marks static data pages as executable.])
1308    
1309     if [[ "x$WANT_JIT" = "xyes" ]]; then
1310     CPPFLAGS="$CPPFLAGS -DUSE_JIT"
1311     fi
1312    
1313     dnl Generate Makefile.
1314 gbeauche 1.16 AC_SUBST(PERL)
1315 gbeauche 1.14 AC_SUBST(USE_DYNGEN, [$ac_cv_use_dyngen])
1316 gbeauche 1.1 AC_SUBST(DYNGENSRCS)
1317     AC_SUBST(DYNGEN_CC)
1318     AC_SUBST(DYNGEN_OP_FLAGS)
1319     AC_SUBST(SYSSRCS)
1320     AC_SUBST(CPUSRCS)
1321     AC_SUBST(BLESS)
1322     AC_SUBST(KEYCODES)
1323 gbeauche 1.5 AC_OUTPUT([
1324     Makefile
1325     ../MacOSX/Info.plist
1326     ])
1327 gbeauche 1.1
1328     dnl Print summary.
1329     echo
1330     echo SheepShaver configuration summary:
1331     echo
1332     echo SDL support ...................... : $SDL_SUPPORT
1333 gbeauche 1.21 echo FBDev DGA support ................ : $WANT_FBDEV_DGA
1334 gbeauche 1.1 echo XFree86 DGA support .............. : $WANT_XF86_DGA
1335     echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
1336     echo Using PowerPC emulator ........... : $EMULATED_PPC
1337     echo Enable JIT compiler .............. : $WANT_JIT
1338     echo Enable video on SEGV signals ..... : $WANT_VOSF
1339     echo ESD sound support ................ : $WANT_ESD
1340     echo GTK user interface ............... : $WANT_GTK
1341     echo mon debugger support ............. : $WANT_MON
1342 gbeauche 1.8 echo Addressing mode .................. : $WANT_ADDRESSING_MODE
1343 gbeauche 1.1 echo Bad memory access recovery type .. : $sigsegv_recovery
1344     echo
1345     echo "Configuration done. Now type \"make\"."