ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.23
Committed: 2005-06-11T16:47:00Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.22: +0 -1 lines
Log Message:
remove duplicate

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.1 AC_CACHE_CHECK([whether the compiler can generate ELF 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     *)
1046     ac_cv_object_format=unknown
1047 gbeauche 1.1 ;;
1048     esac
1049     fi
1050     rm -rf conftest*
1051     ])
1052    
1053     dnl CPU emulator sources
1054     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
1055     CPUSRCS="\
1056 gbeauche 1.9 ../kpx_cpu/src/mathlib/ieeefp.cpp \
1057 gbeauche 1.1 ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
1058     ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
1059     ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
1060     ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp"
1061     CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
1062    
1063     dnl Enable JIT compiler, if possible
1064     if [[ "x$WANT_JIT" = "xyes" ]]; then
1065     AC_CACHE_CHECK([whether dyngen can be used],
1066     ac_cv_use_dyngen, [
1067 gbeauche 1.9 case $host_cpu:$ac_cv_object_format in
1068     powerpc:elf)
1069 gbeauche 1.1 ac_cv_use_dyngen=yes
1070     ;;
1071 gbeauche 1.9 x86_64:elf)
1072 gbeauche 1.1 ac_cv_use_dyngen=yes
1073     ;;
1074 gbeauche 1.9 i?86:elf)
1075 gbeauche 1.1 ac_cv_use_dyngen=yes
1076     ;;
1077     *:*)
1078     ac_cv_use_dyngen=no
1079     ;;
1080     esac
1081     dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
1082     if [[ -z "$DYNGEN_CC" ]]; then
1083     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
1084     DYNGEN_CC=$CXX
1085     else
1086     for p in /usr/bin /usr/local/bin; do
1087     gxx="$p/g++"
1088     if [[ -x "$gxx" ]]; then
1089     DYNGEN_CC="$gxx"
1090     fi
1091     done
1092     fi
1093     fi
1094     if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include <limits>' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then
1095     ac_cv_use_dyngen=no
1096     fi
1097     ])
1098     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1099     case $host_cpu in
1100     i?86)
1101     DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2"
1102     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1103     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0"
1104     else
1105     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
1106     fi
1107     ;;
1108     esac
1109 gbeauche 1.16 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000 -g0"
1110 gbeauche 1.1 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
1111     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
1112     fi
1113     else
1114     WANT_JIT=no
1115     fi
1116     AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
1117     if [[ "x$WANT_JIT" = "xyes" ]]; then
1118     DYNGENSRCS="\
1119     ../kpx_cpu/src/cpu/jit/dyngen.c \
1120     ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
1121     CPUSRCS="\
1122     ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
1123     ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
1124     ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS"
1125     fi
1126     fi
1127     CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
1128     else
1129     WANT_JIT=no
1130     fi
1131     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
1132     AC_CACHE_CHECK([whether static data regions are executable],
1133     ac_cv_have_static_data_exec, [
1134     AC_TRY_RUN([int main(void) {
1135     #if defined(__powerpc__)
1136     static unsigned int p[8] = {0x4e800020,};
1137     asm volatile("dcbst 0,%0" : : "r" (p) : "memory");
1138     asm volatile("sync" : : : "memory");
1139     asm volatile("icbi 0,%0" : : "r" (p) : "memory");
1140     asm volatile("sync" : : : "memory");
1141     asm volatile("isync" : : : "memory");
1142     ((void (*)(void))p)();
1143     return 0;
1144     #endif
1145     return 1;
1146     }], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no,
1147     dnl When cross-compiling, do not assume anything.
1148     ac_cv_have_static_data_exec=no
1149     )
1150     ])
1151 gbeauche 1.14 else
1152     ac_cv_use_dyngen=no
1153 gbeauche 1.1 fi
1154     AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec",
1155     [Define if your system marks static data pages as executable.])
1156    
1157     if [[ "x$WANT_JIT" = "xyes" ]]; then
1158     CPPFLAGS="$CPPFLAGS -DUSE_JIT"
1159     fi
1160    
1161     dnl Generate Makefile.
1162 gbeauche 1.16 AC_SUBST(PERL)
1163 gbeauche 1.14 AC_SUBST(USE_DYNGEN, [$ac_cv_use_dyngen])
1164 gbeauche 1.1 AC_SUBST(DYNGENSRCS)
1165     AC_SUBST(DYNGEN_CC)
1166     AC_SUBST(DYNGEN_OP_FLAGS)
1167     AC_SUBST(SYSSRCS)
1168     AC_SUBST(CPUSRCS)
1169     AC_SUBST(BLESS)
1170     AC_SUBST(KEYCODES)
1171 gbeauche 1.5 AC_OUTPUT([
1172     Makefile
1173     ../MacOSX/Info.plist
1174     ])
1175 gbeauche 1.1
1176     dnl Print summary.
1177     echo
1178     echo SheepShaver configuration summary:
1179     echo
1180     echo SDL support ...................... : $SDL_SUPPORT
1181 gbeauche 1.21 echo FBDev DGA support ................ : $WANT_FBDEV_DGA
1182 gbeauche 1.1 echo XFree86 DGA support .............. : $WANT_XF86_DGA
1183     echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
1184     echo Using PowerPC emulator ........... : $EMULATED_PPC
1185     echo Enable JIT compiler .............. : $WANT_JIT
1186     echo Enable video on SEGV signals ..... : $WANT_VOSF
1187     echo ESD sound support ................ : $WANT_ESD
1188     echo GTK user interface ............... : $WANT_GTK
1189     echo mon debugger support ............. : $WANT_MON
1190 gbeauche 1.8 echo Addressing mode .................. : $WANT_ADDRESSING_MODE
1191 gbeauche 1.1 echo Bad memory access recovery type .. : $sigsegv_recovery
1192     echo
1193     echo "Configuration done. Now type \"make\"."