ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.24
Committed: 2005-06-14T06:32:52Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.23: +17 -6 lines
Log Message:
Support JIT on Mach/ppc platforms. Mach/i386 (Darwin/x86) is to follow.

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     AC_CHECK_FUNCS(posix_memalign memalign valloc)
350 gbeauche 1.16 AC_CHECK_FUNCS(exp2f log2f exp2 log2 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.1 dnl Platform specific binary postprocessor
1003     AC_PATH_PROG(BLESS, "true")
1004     if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
1005     BLESS=Darwin/lowmem
1006     LDFLAGS="$LDFLAGS -pagezero_size 0x3000"
1007     fi
1008    
1009     dnl Check for GCC 2.7 or higher.
1010     HAVE_GCC27=no
1011     AC_MSG_CHECKING(for GCC 2.7 or higher)
1012     AC_EGREP_CPP(xyes,
1013     [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
1014     xyes
1015     #endif
1016     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
1017    
1018     dnl Check for GCC 3.0 or higher.
1019     HAVE_GCC30=no
1020     AC_MSG_CHECKING(for GCC 3.0 or higher)
1021     AC_EGREP_CPP(xyes,
1022     [#if __GNUC__ >= 3
1023     xyes
1024     #endif
1025     ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
1026    
1027     dnl Check for ICC.
1028     AC_MSG_CHECKING(for ICC)
1029     HAVE_ICC=no
1030     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
1031     HAVE_ICC=yes
1032     fi
1033     AC_MSG_RESULT($HAVE_ICC)
1034    
1035 gbeauche 1.9 dnl Determine the generated object format
1036 gbeauche 1.24 AC_CACHE_CHECK([the format of compiler generated objects],
1037 gbeauche 1.9 ac_cv_object_format, [
1038 gbeauche 1.1 echo 'int i;' > conftest.$ac_ext
1039 gbeauche 1.9 ac_cv_object_format=no
1040 gbeauche 1.1 if AC_TRY_EVAL(ac_compile); then
1041     case `/usr/bin/file conftest.$ac_objext` in
1042     *"ELF"*)
1043 gbeauche 1.9 ac_cv_object_format=elf
1044     ;;
1045 gbeauche 1.24 *"Mach-O"*)
1046     ac_cv_object_format=mach
1047     ;;
1048 gbeauche 1.9 *)
1049     ac_cv_object_format=unknown
1050 gbeauche 1.1 ;;
1051     esac
1052     fi
1053     rm -rf conftest*
1054     ])
1055    
1056     dnl CPU emulator sources
1057     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
1058     CPUSRCS="\
1059 gbeauche 1.9 ../kpx_cpu/src/mathlib/ieeefp.cpp \
1060 gbeauche 1.1 ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
1061     ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
1062     ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
1063     ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp"
1064     CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
1065    
1066     dnl Enable JIT compiler, if possible
1067     if [[ "x$WANT_JIT" = "xyes" ]]; then
1068     AC_CACHE_CHECK([whether dyngen can be used],
1069     ac_cv_use_dyngen, [
1070 gbeauche 1.9 case $host_cpu:$ac_cv_object_format in
1071     powerpc:elf)
1072 gbeauche 1.1 ac_cv_use_dyngen=yes
1073     ;;
1074 gbeauche 1.9 x86_64:elf)
1075 gbeauche 1.1 ac_cv_use_dyngen=yes
1076     ;;
1077 gbeauche 1.9 i?86:elf)
1078 gbeauche 1.1 ac_cv_use_dyngen=yes
1079     ;;
1080 gbeauche 1.24 powerpc:mach)
1081     ac_cv_use_dyngen=yes
1082     ;;
1083 gbeauche 1.1 *:*)
1084     ac_cv_use_dyngen=no
1085     ;;
1086     esac
1087     dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
1088     if [[ -z "$DYNGEN_CC" ]]; then
1089     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1090     DYNGEN_CC=$CXX
1091     else
1092     for p in /usr/bin /usr/local/bin; do
1093     gxx="$p/g++"
1094     if [[ -x "$gxx" ]]; then
1095     DYNGEN_CC="$gxx"
1096     fi
1097     done
1098     fi
1099     fi
1100     if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include <limits>' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then
1101     ac_cv_use_dyngen=no
1102     fi
1103     ])
1104     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1105     case $host_cpu in
1106     i?86)
1107     DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2"
1108 gbeauche 1.24 ;;
1109     powerpc)
1110     if [[ "x$ac_cv_object_format" = "xmach" ]]; then
1111     DYNGEN_OP_FLAGS="-mdynamic-no-pic"
1112 gbeauche 1.1 fi
1113     ;;
1114     esac
1115 gbeauche 1.24 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1116     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0"
1117     else
1118     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
1119     fi
1120     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000 -fno-exceptions -g0"
1121 gbeauche 1.1 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1122     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
1123     fi
1124     else
1125     WANT_JIT=no
1126     fi
1127     AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
1128     if [[ "x$WANT_JIT" = "xyes" ]]; then
1129     DYNGENSRCS="\
1130     ../kpx_cpu/src/cpu/jit/dyngen.c \
1131     ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
1132     CPUSRCS="\
1133     ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
1134     ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
1135     ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS"
1136     fi
1137     fi
1138     CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
1139     else
1140     WANT_JIT=no
1141     fi
1142     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1143     AC_CACHE_CHECK([whether static data regions are executable],
1144     ac_cv_have_static_data_exec, [
1145     AC_TRY_RUN([int main(void) {
1146     #if defined(__powerpc__)
1147     static unsigned int p[8] = {0x4e800020,};
1148     asm volatile("dcbst 0,%0" : : "r" (p) : "memory");
1149     asm volatile("sync" : : : "memory");
1150     asm volatile("icbi 0,%0" : : "r" (p) : "memory");
1151     asm volatile("sync" : : : "memory");
1152     asm volatile("isync" : : : "memory");
1153     ((void (*)(void))p)();
1154     return 0;
1155     #endif
1156     return 1;
1157     }], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no,
1158     dnl When cross-compiling, do not assume anything.
1159     ac_cv_have_static_data_exec=no
1160     )
1161     ])
1162 gbeauche 1.14 else
1163     ac_cv_use_dyngen=no
1164 gbeauche 1.1 fi
1165     AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec",
1166     [Define if your system marks static data pages as executable.])
1167    
1168     if [[ "x$WANT_JIT" = "xyes" ]]; then
1169     CPPFLAGS="$CPPFLAGS -DUSE_JIT"
1170     fi
1171    
1172     dnl Generate Makefile.
1173 gbeauche 1.16 AC_SUBST(PERL)
1174 gbeauche 1.14 AC_SUBST(USE_DYNGEN, [$ac_cv_use_dyngen])
1175 gbeauche 1.1 AC_SUBST(DYNGENSRCS)
1176     AC_SUBST(DYNGEN_CC)
1177     AC_SUBST(DYNGEN_OP_FLAGS)
1178     AC_SUBST(SYSSRCS)
1179     AC_SUBST(CPUSRCS)
1180     AC_SUBST(BLESS)
1181     AC_SUBST(KEYCODES)
1182 gbeauche 1.5 AC_OUTPUT([
1183     Makefile
1184     ../MacOSX/Info.plist
1185     ])
1186 gbeauche 1.1
1187     dnl Print summary.
1188     echo
1189     echo SheepShaver configuration summary:
1190     echo
1191     echo SDL support ...................... : $SDL_SUPPORT
1192 gbeauche 1.21 echo FBDev DGA support ................ : $WANT_FBDEV_DGA
1193 gbeauche 1.1 echo XFree86 DGA support .............. : $WANT_XF86_DGA
1194     echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
1195     echo Using PowerPC emulator ........... : $EMULATED_PPC
1196     echo Enable JIT compiler .............. : $WANT_JIT
1197     echo Enable video on SEGV signals ..... : $WANT_VOSF
1198     echo ESD sound support ................ : $WANT_ESD
1199     echo GTK user interface ............... : $WANT_GTK
1200     echo mon debugger support ............. : $WANT_MON
1201 gbeauche 1.8 echo Addressing mode .................. : $WANT_ADDRESSING_MODE
1202 gbeauche 1.1 echo Bad memory access recovery type .. : $sigsegv_recovery
1203     echo
1204     echo "Configuration done. Now type \"make\"."