ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.in
Revision: 1.25
Committed: 2004-06-22T22:41:44Z (20 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.24: +8 -0 lines
Log Message:
Disable VOSF on OSX, SIGSEGV recovery is too slow.

File Contents

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