ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.31
Committed: 2005-07-01T06:16:00Z (19 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.30: +16 -1 lines
Log Message:
Check for <stdint.h> ourselves + build with -mdynamic-no-pic on MacOS X.

File Contents

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