ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.2
Committed: 2004-06-30T08:48:45Z (20 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.1: +7 -0 lines
Log Message:
Avoid corefiles. Check for large file support (> 2 GB).

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     AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes])
21     AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=no]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=no])
22     AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes])
23     AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes])
24     AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes])
25     AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
26     AC_ARG_WITH(dgcc, [ --with-dgcc=COMPILER use C++ COMPILER to compile synthetic opcodes], [DYNGEN_CC=$withval])
27    
28     dnl SDL options.
29     AC_ARG_ENABLE(sdl-static, [ --enable-sdl-static use SDL static libraries for linking [default=no]], [WANT_SDL_STATIC=$enableval], [WANT_SDL_STATIC=no])
30     AC_ARG_ENABLE(sdl-video, [ --enable-sdl-video use SDL for video graphics [default=no]], [WANT_SDL_VIDEO=$enableval], [WANT_SDL_VIDEO=no])
31    
32     dnl Checks for programs.
33     AC_PROG_CC
34     AC_PROG_CPP
35     AC_PROG_CXX
36     AC_PROG_MAKE_SET
37     AC_PROG_INSTALL
38    
39     dnl Check for PowerPC target CPU.
40     HAVE_PPC=no
41     AC_MSG_CHECKING(for PowerPC target CPU)
42     AC_EGREP_CPP(yes,
43     [
44     #ifdef __powerpc__
45     yes
46     #endif
47     #ifdef __ppc__
48     yes
49     #endif
50     ], [AC_MSG_RESULT(yes); HAVE_PPC=yes], AC_MSG_RESULT(no))
51    
52     dnl We use native CPU if possible.
53     EMULATED_PPC=yes
54     case $WANT_EMULATED_PPC in
55     auto) [[ "x$HAVE_PPC" = "xyes" ]] && EMULATED_PPC=no;;
56     no) EMULATED_PPC=no;;
57     esac
58     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
59     AC_DEFINE(EMULATED_PPC, 1, [Define if using a PowerPC CPU emulator.])
60     fi
61    
62     dnl We use mon if possible.
63     MONSRCS=
64     case "x$WANT_MON" in
65     x/* | x.*)
66     mon_srcdir=$WANT_MON
67     WANT_MON=yes
68     ;;
69     xyes)
70     mon_srcdir=../../../mon/src
71     ;;
72     esac
73     if [[ "x$WANT_MON" = "xyes" ]]; then
74     AC_MSG_CHECKING(for mon)
75     if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
76     AC_MSG_RESULT(yes)
77     AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".])
78     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"
79     CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
80     AC_CHECK_LIB(ncurses, tgetent, ,
81     AC_CHECK_LIB(termcap, tgetent, ,
82     AC_CHECK_LIB(termlib, tgetent, ,
83     AC_CHECK_LIB(terminfo, tgetent, ,
84     AC_CHECK_LIB(Hcurses, tgetent, ,
85     AC_CHECK_LIB(curses, tgetent))))))
86     AC_CHECK_LIB(readline, readline)
87     AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
88     else
89     AC_MSG_RESULT(no)
90     AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
91     WANT_MON=no
92     fi
93     fi
94    
95     dnl Checks for libraries.
96     AC_CHECK_LIB(posix4, sem_init)
97    
98     dnl Do we need SDL?
99     WANT_SDL=no
100     SDL_SUPPORT="none"
101     if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
102     WANT_SDL=yes
103     WANT_XF86_DGA=no
104     WANT_XF86_VIDMODE=no
105     WANT_FBDEV_DGA=no
106     SDL_SUPPORT="video"
107     fi
108     if [[ "x$WANT_SDL" = "xyes" ]]; then
109     AC_PATH_PROG(sdl_config, "sdl-config")
110     if [[ -n "$sdl_config" ]]; then
111     sdl_cflags=`$sdl_config --cflags`
112     if [[ "x$WANT_SDL_STATIC" = "xyes" ]]; then
113     sdl_libs=`$sdl_config --static-libs`
114     else
115     sdl_libs=`$sdl_config --libs`
116     fi
117     CFLAGS="$CFLAGS $sdl_cflags"
118     CXXFLAGS="$CXXFLAGS $sdl_cflags"
119     LIBS="$LIBS $sdl_libs"
120     else
121     WANT_SDL=no
122     fi
123     fi
124    
125     dnl We need X11, if not using SDL.
126     if [[ "x$WANT_SDL" = "xno" ]]; then
127     AC_PATH_XTRA
128     if [[ "x$no_x" = "xyes" ]]; then
129     AC_MSG_ERROR([You need X11 to run SheepShaver.])
130     fi
131     CFLAGS="$CFLAGS $X_CFLAGS"
132     CXXFLAGS="$CXXFLAGS $X_CFLAGS"
133     LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
134     fi
135    
136     dnl We need pthreads on non-PowerPC systems. Try libpthread first, then libc_r (FreeBSD), then PTL.
137     HAVE_PTHREADS=yes
138     case $EMULATED_PPC:$target_os in
139     no:linux*)
140     dnl We do have our own pthread_cancel() implementation
141     AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if you have the pthread_cancel function.])
142     ;;
143     *:*)
144     AC_CHECK_LIB(pthread, pthread_create, , [
145     AC_CHECK_LIB(c_r, pthread_create, , [
146     AC_CHECK_LIB(PTL, pthread_create, , [
147     AC_MSG_ERROR([You need pthreads to run Basilisk II.])
148     ])
149     ])
150     ])
151     AC_CHECK_FUNCS(pthread_cancel)
152     AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
153     AC_CHECK_FUNCS(pthread_mutexattr_settype)
154     AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
155     if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
156     AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.])
157     fi
158     dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
159     SEMSRC=
160     AC_CHECK_FUNCS(sem_init, , [
161     if test "x$HAVE_PTHREADS" = "xyes"; then
162     SEMSRC=posix_sem.cpp
163     fi
164     ])
165     ;;
166     esac
167    
168     dnl We use XFree86 DGA if possible.
169     if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then
170     AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [
171     AC_DEFINE(ENABLE_XF86_DGA, 1, [Define if using XFree86 DGA extension.])
172     LIBS="$LIBS -lXxf86dga"
173     ], [
174     AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.])
175     WANT_XF86_DGA=no
176     ])
177     fi
178    
179     dnl We use XFree86 VidMode if possible.
180     if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then
181     AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [
182     AC_DEFINE(ENABLE_XF86_VIDMODE, 1, [Define if using XFree86 DGA extension.])
183     LIBS="$LIBS -lXxf86vm"
184     ], [
185     AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.])
186     WANT_XF86_VIDMODE=no
187     ])
188     fi
189    
190     dnl We use GTK+ if possible.
191     UISRCS=../dummy/prefs_editor_dummy.cpp
192     if [[ "x$WANT_GTK" = "xyes" ]]; then
193     AM_PATH_GTK(1.2.0, [
194     AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
195     CFLAGS="$CFLAGS $GTK_CFLAGS"
196     CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
197     LIBS="$LIBS $GTK_LIBS"
198     UISRCS=prefs_editor_gtk.cpp
199     ], [
200     AC_MSG_WARN([Could not find GTK+, disabling user interface.])
201     WANT_GTK=no
202     ])
203     fi
204    
205     dnl We use ESD if possible.
206     if [[ "x$WANT_ESD" = "xyes" ]]; then
207     AM_PATH_ESD(0.2.8, [
208     AC_DEFINE(ENABLE_ESD, 1, [Define is using ESD.])
209     CFLAGS="$CFLAGS $ESD_CFLAGS"
210     CXXFLAGS="$CXXFLAGS $ESD_CFLAGS"
211     LIBS="$LIBS $ESD_LIBS"
212     ], [
213     AC_MSG_WARN([Could not find ESD, disabling ESD support.])
214     WANT_ESD=no
215     ])
216     fi
217    
218 gbeauche 1.2 dnl We use 64-bit file size support if possible.
219     AC_SYS_LARGEFILE
220    
221 gbeauche 1.1 dnl Checks for header files.
222     AC_HEADER_STDC
223     AC_HEADER_SYS_WAIT
224     AC_CHECK_HEADERS(mach/vm_map.h mach/mach_init.h sys/mman.h)
225     AC_CHECK_HEADERS(sys/time.h sys/times.h sys/socket.h)
226     AC_CHECK_HEADERS(unistd.h fcntl.h byteswap.h)
227     AC_CHECK_HEADERS(linux/if.h, [], [], [
228     #if HAVE_SYS_SOCKET_H
229     # include <sys/socket.h>
230     #endif
231     ])
232     AC_CHECK_HEADERS(linux/if_tun.h net/if.h net/if_tun.h)
233    
234     dnl Checks for typedefs, structures, and compiler characteristics.
235     AC_C_BIGENDIAN
236     AC_C_CONST
237     AC_C_INLINE
238     AC_CHECK_SIZEOF(short, 2)
239     AC_CHECK_SIZEOF(int, 4)
240     AC_CHECK_SIZEOF(long, 4)
241     AC_CHECK_SIZEOF(long long, 8)
242     AC_CHECK_SIZEOF(float, 4)
243     AC_CHECK_SIZEOF(double, 8)
244     AC_CHECK_SIZEOF(void *, 4)
245     AC_TYPE_OFF_T
246     AC_CHECK_TYPE(loff_t, off_t)
247     AC_TYPE_SIZE_T
248     AC_TYPE_SIGNAL
249     AC_HEADER_TIME
250     AC_STRUCT_TM
251    
252     dnl Check whether struct sigaction has sa_restorer member.
253     AC_CACHE_CHECK([whether struct sigaction has sa_restorer],
254     ac_cv_signal_sa_restorer, [
255     AC_TRY_COMPILE([
256     #include <signal.h>
257     ], [struct sigaction sa; sa.sa_restorer = 0;],
258     ac_cv_signal_sa_restorer=yes, ac_cv_signal_sa_restorer=no,
259     dnl When cross-compiling, do not assume anything.
260     ac_cv_signal_sa_restorer=no
261     )
262     ])
263     if [[ "x$ac_cv_signal_sa_restorer" = "xyes" ]]; then
264     AC_DEFINE(HAVE_SIGNAL_SA_RESTORER, 1, [Define if sa_restorer is available in struct sigaction.])
265     fi
266    
267     dnl Checks for library functions.
268     AC_CHECK_FUNCS(strdup strlcpy cfmakeraw)
269     AC_CHECK_FUNCS(nanosleep)
270     AC_CHECK_FUNCS(sigaction signal)
271     AC_CHECK_FUNCS(mmap mprotect munmap)
272     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
273     AC_CHECK_FUNCS(posix_memalign memalign valloc)
274    
275     dnl Darwin seems to define mach_task_self() instead of task_self().
276     AC_CHECK_FUNCS(mach_task_self task_self)
277    
278     dnl We need clock_gettime() for better performance but it may drag
279     dnl libpthread in, which we don't want for native ppc mode
280     case $EMULATED_PPC:$target_os in
281     no:linux*)
282     ;;
283     *:*)
284     AC_SEARCH_LIBS(clock_gettime, [rt posix4])
285     AC_CHECK_FUNCS(clock_gettime)
286     ;;
287     esac
288    
289     dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
290     AC_DEFUN(AC_CHECK_FRAMEWORK, [
291     AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
292     AC_CACHE_CHECK([whether compiler supports framework $1],
293     ac_Framework, [
294     saved_LIBS="$LIBS"
295     LIBS="$LIBS -framework $1"
296     AC_TRY_LINK(
297     [$2], [int main(void) { return 0; }],
298     [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
299     )
300     ])
301     AS_IF([test AS_VAR_GET(ac_Framework) = yes],
302     [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
303     )
304     AS_VAR_POPDEF([ac_Framework])dnl
305     ])
306    
307     dnl Check for some MacOS X frameworks
308     AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
309     AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
310    
311     dnl Select system-dependant sources.
312     SERIALSRC=serial_unix.cpp
313     ETHERSRC=../dummy/ether_dummy.cpp
314     SCSISRC=../dummy/scsi_dummy.cpp
315     AUDIOSRC=../dummy/audio_dummy.cpp
316     EXTRASYSSRCS=
317     case "$target_os" in
318     linux*)
319     ETHERSRC=Linux/ether_linux.cpp
320     AUDIOSRC=audio_oss_esd.cpp
321     SCSISRC=Linux/scsi_linux.cpp
322     if [[ "x$EMULATED_PPC" = "xno" ]]; then
323     EXTRASYSSRCS="Linux/paranoia.cpp Linux/sheepthreads.c Linux/asm_linux.S"
324     fi
325     ;;
326     darwin*)
327     if [[ "x$EMULATED_PPC" = "xno" ]]; then
328     EXTRASYSSRCS="Darwin/paranoia.cpp Linux/asm_linux.S"
329     fi
330     if [[ "x$ac_cv_framework_IOKit" = "xyes" ]]; then
331     EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/sys_darwin.cpp"
332     fi
333     ;;
334     esac
335    
336     dnl SDL overrides
337     if [[ "x$WANT_SDL" = "xyes" ]]; then
338     AC_DEFINE(USE_SDL, 1, [Define to enble SDL support.])
339     fi
340     if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
341     VIDEOSRCS="../SDL/video_sdl.cpp"
342     AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support.])
343     KEYCODES="../SDL/keycodes"
344     if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
345     EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp"
346     else
347     EXTRASYSSRCS="$EXTRASYSSRCS ../dummy/clip_dummy.cpp"
348     fi
349     else
350     VIDEOSRCS="video_x.cpp"
351     KEYCODES="keycodes"
352     EXTRASYSSRCS="$EXTRASYSSRCS clip_unix.cpp"
353     fi
354    
355     SYSSRCS="$VIDEOSRCS $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
356    
357     dnl Define a macro that translates a yesno-variable into a C macro definition
358     dnl to be put into the config.h file
359     dnl $1 -- the macro to define
360     dnl $2 -- the value to translate
361     dnl $3 -- template name
362     AC_DEFUN(AC_TRANSLATE_DEFINE, [
363     if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
364     AC_DEFINE($1, 1, $3)
365     fi
366     ])
367    
368     dnl Check that the host supports TUN/TAP devices
369     AC_CACHE_CHECK([whether TUN/TAP is supported],
370     ac_cv_tun_tap_support, [
371     AC_TRY_COMPILE([
372     #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
373     #include <linux/if.h>
374     #include <linux/if_tun.h>
375     #endif
376     #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
377     #include <net/if.h>
378     #include <net/if_tun.h>
379     #endif
380     ], [
381     struct ifreq ifr;
382     memset(&ifr, 0, sizeof(ifr));
383     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
384     ],
385     ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
386     )
387     ])
388     AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
389     [Define if your system supports TUN/TAP devices.])
390    
391     dnl Various checks if the system supports vm_allocate() and the like functions.
392     have_mach_vm=no
393     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
394     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
395     have_mach_vm=yes
396     fi
397     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
398     [Define if your system has a working vm_allocate()-based memory allocator.])
399    
400     dnl Check that vm_allocate(), vm_protect() work
401     if [[ "x$have_mach_vm" = "xyes" ]]; then
402    
403     AC_CACHE_CHECK([whether vm_protect works],
404     ac_cv_vm_protect_works, [
405     AC_LANG_SAVE
406     AC_LANG_CPLUSPLUS
407     ac_cv_vm_protect_works=yes
408     dnl First the tests that should segfault
409     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
410     AC_TRY_RUN([
411     #define CONFIGURE_TEST_VM_MAP
412     #define TEST_VM_PROT_$test_def
413     #include "vm_alloc.cpp"
414     ], ac_cv_vm_protect_works=no, rm -f core,
415     dnl When cross-compiling, do not assume anything
416     ac_cv_vm_protect_works="guessing no"
417     )
418     done
419     AC_TRY_RUN([
420     #define CONFIGURE_TEST_VM_MAP
421     #define TEST_VM_PROT_RDWR_WRITE
422     #include "vm_alloc.cpp"
423     ], , ac_cv_vm_protect_works=no,
424     dnl When cross-compiling, do not assume anything
425     ac_cv_vm_protect_works="guessing no"
426     )
427     AC_LANG_RESTORE
428     ]
429     )
430    
431     dnl Remove support for vm_allocate() if vm_protect() does not work
432     if [[ "x$have_mach_vm" = "xyes" ]]; then
433     case $ac_cv_vm_protect_works in
434     *yes) have_mach_vm=yes;;
435     *no) have_mach_vm=no;;
436     esac
437     fi
438     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
439     [Define if your system has a working vm_allocate()-based memory allocator.])
440    
441     fi dnl HAVE_MACH_VM
442    
443     dnl Various checks if the system supports mmap() and the like functions.
444     dnl ... and Mach memory allocators are not supported
445     have_mmap_vm=no
446     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
447     "x$ac_cv_func_mprotect" = "xyes" ]]; then
448     if [[ "x$have_mach_vm" = "xno" ]]; then
449     have_mmap_vm=yes
450     fi
451     fi
452     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
453     [Define if your system has a working mmap()-based memory allocator.])
454    
455     dnl Check that mmap() and associated functions work.
456     if [[ "x$have_mmap_vm" = "xyes" ]]; then
457    
458     dnl Check if we have a working anonymous mmap()
459     AC_CACHE_CHECK([whether mmap supports MAP_ANON],
460     ac_cv_mmap_anon, [
461     AC_LANG_SAVE
462     AC_LANG_CPLUSPLUS
463     AC_TRY_RUN([
464     #define HAVE_MMAP_ANON
465     #define CONFIGURE_TEST_VM_MAP
466     #define TEST_VM_MMAP_ANON
467     #include "vm_alloc.cpp"
468     ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
469     dnl When cross-compiling, do not assume anything.
470     ac_cv_mmap_anon="guessing no"
471     )
472     AC_LANG_RESTORE
473     ]
474     )
475     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
476     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
477    
478     AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
479     ac_cv_mmap_anonymous, [
480     AC_LANG_SAVE
481     AC_LANG_CPLUSPLUS
482     AC_TRY_RUN([
483     #define HAVE_MMAP_ANONYMOUS
484     #define CONFIGURE_TEST_VM_MAP
485     #define TEST_VM_MMAP_ANON
486     #include "vm_alloc.cpp"
487     ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
488     dnl When cross-compiling, do not assume anything.
489     ac_cv_mmap_anonymous="guessing no"
490     )
491     AC_LANG_RESTORE
492     ]
493     )
494     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
495     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
496    
497     AC_CACHE_CHECK([whether mprotect works],
498     ac_cv_mprotect_works, [
499     AC_LANG_SAVE
500     AC_LANG_CPLUSPLUS
501     ac_cv_mprotect_works=yes
502     dnl First the tests that should segfault
503     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
504     AC_TRY_RUN([
505     #define CONFIGURE_TEST_VM_MAP
506     #define TEST_VM_PROT_$test_def
507     #include "vm_alloc.cpp"
508     ], ac_cv_mprotect_works=no, rm -f core,
509     dnl When cross-compiling, do not assume anything
510     ac_cv_mprotect_works="guessing no"
511     )
512     done
513     AC_TRY_RUN([
514     #define CONFIGURE_TEST_VM_MAP
515     #define TEST_VM_PROT_RDWR_WRITE
516     #include "vm_alloc.cpp"
517     ], , ac_cv_mprotect_works=no,
518     dnl When cross-compiling, do not assume anything
519     ac_cv_mprotect_works="guessing no"
520     )
521     AC_LANG_RESTORE
522     ]
523     )
524    
525     dnl Remove support for mmap() if mprotect() does not work
526     if [[ "x$have_mmap_vm" = "xyes" ]]; then
527     case $ac_cv_mprotect_works in
528     *yes) have_mmap_vm=yes;;
529     *no) have_mmap_vm=no;;
530     esac
531     fi
532     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
533     [Define if your system has a working mmap()-based memory allocator.])
534    
535     fi dnl HAVE_MMAP_VM
536    
537     dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
538     AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000],
539     ac_cv_pagezero_hack, [
540     ac_cv_pagezero_hack=no
541     if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then
542     ac_cv_pagezero_hack=yes
543     dnl might as well skip the test for mmap-able low memory
544     ac_cv_can_map_lm=no
545     fi
546     ])
547     AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
548     [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
549    
550     dnl Check if we can mmap 0x3000 bytes from 0x0000
551     AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000],
552     ac_cv_can_map_lm, [
553     AC_LANG_SAVE
554     AC_LANG_CPLUSPLUS
555     AC_TRY_RUN([
556     #include "vm_alloc.cpp"
557     int main(void) { /* returns 0 if we could map the lowmem globals */
558     volatile char * lm = 0;
559     if (vm_init() < 0) exit(1);
560     if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
561     lm[0] = 'z';
562     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
563     vm_exit(); exit(0);
564     }
565     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
566     dnl When cross-compiling, do not assume anything.
567     ac_cv_can_map_lm="guessing no"
568     )
569     AC_LANG_RESTORE
570     ]
571     )
572    
573     dnl Check signal handlers need to be reinstalled
574     AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
575     ac_cv_signal_need_reinstall, [
576     AC_LANG_SAVE
577     AC_LANG_CPLUSPLUS
578     AC_TRY_RUN([
579     #include <stdlib.h>
580     #ifdef HAVE_UNISTD_H
581     #include <unistd.h>
582     #endif
583     #include <signal.h>
584     static int handled_signal = 0;
585     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
586     int main(void) { /* returns 0 if signals need not to be reinstalled */
587     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
588     exit(handled_signal == 2);
589     }
590     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
591     dnl When cross-compiling, do not assume anything.
592     ac_cv_signal_need_reinstall="guessing yes"
593     )
594     AC_LANG_RESTORE
595     ]
596     )
597     AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
598     [Define if your system requires signals to be reinstalled.])
599    
600     dnl Check if sigaction handlers need to be reinstalled
601     AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
602     ac_cv_sigaction_need_reinstall, [
603     AC_LANG_SAVE
604     AC_LANG_CPLUSPLUS
605     AC_TRY_RUN([
606     #include <stdlib.h>
607     #ifdef HAVE_UNISTD_H
608     #include <unistd.h>
609     #endif
610     #include <signal.h>
611     static int handled_signal = 0;
612     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
613     typedef RETSIGTYPE (*signal_handler)(int);
614     static signal_handler mysignal(int sig, signal_handler handler) {
615     struct sigaction old_sa;
616     struct sigaction new_sa;
617     new_sa.sa_handler = handler;
618     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
619     }
620     int main(void) { /* returns 0 if signals need not to be reinstalled */
621     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
622     exit(handled_signal == 2);
623     }
624     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
625     dnl When cross-compiling, do not assume anything.
626     ac_cv_sigaction_need_reinstall="guessing yes"
627     )
628     AC_LANG_RESTORE
629     ]
630     )
631     AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
632     [Define if your system requires sigactions to be reinstalled.])
633    
634     dnl Check if Mach exceptions supported.
635     AC_CACHE_CHECK([whether your system supports Mach exceptions],
636     ac_cv_have_mach_exceptions, [
637     AC_LANG_SAVE
638     AC_LANG_CPLUSPLUS
639     AC_TRY_RUN([
640     #define HAVE_MACH_EXCEPTIONS 1
641     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
642     #include "vm_alloc.cpp"
643     #include "sigsegv.cpp"
644     ],
645     ac_cv_have_mach_exceptions=yes,
646     ac_cv_have_mach_exceptions=no,
647     dnl When cross-compiling, do not assume anything.
648     ac_cv_have_mach_exceptions=no
649     )
650     AC_LANG_RESTORE
651     ]
652     )
653     if [[ "$ac_cv_have_mach_exceptions" = "yes" ]]; then
654     sigsegv_recovery=mach
655     fi
656     AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
657     [Define if your system supports Mach exceptions.])
658    
659     dnl Otherwise, check if extended signals are supported.
660     if [[ -z "$sigsegv_recovery" ]]; then
661     AC_CACHE_CHECK([whether your system supports extended signal handlers],
662     ac_cv_have_extended_signals, [
663     AC_LANG_SAVE
664     AC_LANG_CPLUSPLUS
665     AC_TRY_RUN([
666     #define HAVE_SIGINFO_T 1
667     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
668     #include "vm_alloc.cpp"
669     #include "sigsegv.cpp"
670     ],
671     ac_cv_have_extended_signals=yes,
672     ac_cv_have_extended_signals=no,
673     dnl When cross-compiling, do not assume anything.
674     ac_cv_have_extended_signals=no
675     )
676     AC_LANG_RESTORE
677     ]
678     )
679     if [[ "$ac_cv_have_extended_signals" = "yes" ]]; then
680     sigsegv_recovery=siginfo
681     fi
682     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
683     [Define if your system support extended signals.])
684     fi
685    
686     dnl Otherwise, check for subterfuges.
687     if [[ -z "$sigsegv_recovery" ]]; then
688     AC_CACHE_CHECK([whether we then have a subterfuge for your system],
689     ac_cv_have_sigcontext_hack, [
690     AC_LANG_SAVE
691     AC_LANG_CPLUSPLUS
692     AC_TRY_RUN([
693     #define HAVE_SIGCONTEXT_SUBTERFUGE 1
694     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
695     #include "vm_alloc.cpp"
696     #include "sigsegv.cpp"
697     ],
698     ac_cv_have_sigcontext_hack=yes,
699     ac_cv_have_sigcontext_hack=no,
700     dnl When cross-compiling, do not assume anything.
701     ac_cv_have_sigcontext_hack=no
702     )
703     AC_LANG_RESTORE
704     ])
705     if [[ "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
706     sigsegv_recovery=sigcontext
707     fi
708     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
709     [Define if we know a hack to replace siginfo_t->si_addr member.])
710     fi
711    
712     dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
713     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
714     ac_cv_have_skip_instruction, [
715     AC_LANG_SAVE
716     AC_LANG_CPLUSPLUS
717     AC_TRY_RUN([
718     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
719     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
720     #include "vm_alloc.cpp"
721     #include "sigsegv.cpp"
722     ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
723     dnl When cross-compiling, do not assume anything.
724     ac_cv_have_skip_instruction=no
725     )
726     AC_LANG_RESTORE
727     ]
728     )
729     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
730     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
731    
732     dnl Can we do Video on SEGV Signals ?
733     CAN_VOSF=no
734     if [[ -n "$sigsegv_recovery" ]]; then
735     CAN_VOSF=yes
736     fi
737    
738     dnl Enable VOSF screen updates with this feature is requested and feasible
739     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
740     AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
741     else
742     WANT_VOSF=no
743     fi
744    
745     dnl Platform specific binary postprocessor
746     AC_PATH_PROG(BLESS, "true")
747     if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
748     BLESS=Darwin/lowmem
749     LDFLAGS="$LDFLAGS -pagezero_size 0x3000"
750     fi
751    
752     dnl Check for GCC 2.7 or higher.
753     HAVE_GCC27=no
754     AC_MSG_CHECKING(for GCC 2.7 or higher)
755     AC_EGREP_CPP(xyes,
756     [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
757     xyes
758     #endif
759     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
760    
761     dnl Check for GCC 3.0 or higher.
762     HAVE_GCC30=no
763     AC_MSG_CHECKING(for GCC 3.0 or higher)
764     AC_EGREP_CPP(xyes,
765     [#if __GNUC__ >= 3
766     xyes
767     #endif
768     ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
769    
770     dnl Check for ICC.
771     AC_MSG_CHECKING(for ICC)
772     HAVE_ICC=no
773     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
774     HAVE_ICC=yes
775     fi
776     AC_MSG_RESULT($HAVE_ICC)
777    
778     # Test if the compiler can generate ELF objects
779     AC_CACHE_CHECK([whether the compiler can generate ELF objects],
780     ac_cv_elf_objects, [
781     echo 'int i;' > conftest.$ac_ext
782     ac_cv_elf_objects=no
783     if AC_TRY_EVAL(ac_compile); then
784     case `/usr/bin/file conftest.$ac_objext` in
785     *"ELF"*)
786     ac_cv_elf_objects=yes
787     ;;
788     esac
789     fi
790     rm -rf conftest*
791     ])
792     ELF_OBJECTS=$ac_cv_elf_objects
793    
794     dnl CPU emulator sources
795     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
796     CPUSRCS="\
797     ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
798     ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
799     ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
800     ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp"
801     CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
802    
803     dnl Enable JIT compiler, if possible
804     if [[ "x$WANT_JIT" = "xyes" ]]; then
805     AC_CACHE_CHECK([whether dyngen can be used],
806     ac_cv_use_dyngen, [
807     case $host_cpu:$ELF_OBJECTS in
808     powerpc:yes)
809     ac_cv_use_dyngen=yes
810     ;;
811     x86_64:yes)
812     ac_cv_use_dyngen=yes
813     ;;
814     i?86:yes)
815     ac_cv_use_dyngen=yes
816     ;;
817     *:*)
818     ac_cv_use_dyngen=no
819     ;;
820     esac
821     dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
822     if [[ -z "$DYNGEN_CC" ]]; then
823     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
824     DYNGEN_CC=$CXX
825     else
826     for p in /usr/bin /usr/local/bin; do
827     gxx="$p/g++"
828     if [[ -x "$gxx" ]]; then
829     DYNGEN_CC="$gxx"
830     fi
831     done
832     fi
833     fi
834     if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include <limits>' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then
835     ac_cv_use_dyngen=no
836     fi
837     ])
838     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
839     case $host_cpu in
840     i?86)
841     DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2"
842     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
843     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0"
844     else
845     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
846     fi
847     saved_CPPFLAGS=$CPPFLAGS
848     CPPFLAGS="$CPPFLAGS -mmmx"
849     AC_CHECK_HEADERS(mmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -mmmx"])
850     CPPFLAGS="$CPPFLAGS -msse"
851     AC_CHECK_HEADERS(xmmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse"])
852     CPPFLAGS="$CPPFLAGS -msse2"
853     AC_CHECK_HEADERS(emmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse2"])
854     CPPFLAGS=$saved_CPPFLAGS
855     ;;
856     x86_64)
857     AC_CHECK_HEADERS(mmintrin.h xmmintrin.h emmintrin.h)
858     ;;
859     esac
860     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000"
861     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
862     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
863     fi
864     else
865     WANT_JIT=no
866     fi
867     AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
868     if [[ "x$WANT_JIT" = "xyes" ]]; then
869     DYNGENSRCS="\
870     ../kpx_cpu/src/cpu/jit/dyngen.c \
871     ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
872     CPUSRCS="\
873     ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
874     ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
875     ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS"
876     fi
877     fi
878     CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
879     else
880     WANT_JIT=no
881     fi
882     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
883     AC_CACHE_CHECK([whether static data regions are executable],
884     ac_cv_have_static_data_exec, [
885     AC_TRY_RUN([int main(void) {
886     #if defined(__powerpc__)
887     static unsigned int p[8] = {0x4e800020,};
888     asm volatile("dcbst 0,%0" : : "r" (p) : "memory");
889     asm volatile("sync" : : : "memory");
890     asm volatile("icbi 0,%0" : : "r" (p) : "memory");
891     asm volatile("sync" : : : "memory");
892     asm volatile("isync" : : : "memory");
893     ((void (*)(void))p)();
894     return 0;
895     #endif
896     return 1;
897     }], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no,
898     dnl When cross-compiling, do not assume anything.
899     ac_cv_have_static_data_exec=no
900     )
901     ])
902     fi
903     AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec",
904     [Define if your system marks static data pages as executable.])
905    
906     if [[ "x$WANT_JIT" = "xyes" ]]; then
907     CPPFLAGS="$CPPFLAGS -DUSE_JIT"
908     fi
909    
910     dnl Generate Makefile.
911     AC_SUBST(DYNGENSRCS)
912     AC_SUBST(DYNGEN_CC)
913     AC_SUBST(DYNGEN_OP_FLAGS)
914     AC_SUBST(SYSSRCS)
915     AC_SUBST(CPUSRCS)
916     AC_SUBST(BLESS)
917     AC_SUBST(KEYCODES)
918     AC_OUTPUT(Makefile)
919    
920     dnl Print summary.
921     echo
922     echo SheepShaver configuration summary:
923     echo
924     echo SDL support ...................... : $SDL_SUPPORT
925     echo XFree86 DGA support .............. : $WANT_XF86_DGA
926     echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
927     echo Using PowerPC emulator ........... : $EMULATED_PPC
928     echo Enable JIT compiler .............. : $WANT_JIT
929     echo Enable video on SEGV signals ..... : $WANT_VOSF
930     echo ESD sound support ................ : $WANT_ESD
931     echo GTK user interface ............... : $WANT_GTK
932     echo mon debugger support ............. : $WANT_MON
933     echo Bad memory access recovery type .. : $sigsegv_recovery
934     echo
935     echo "Configuration done. Now type \"make\"."