ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.in
Revision: 1.23
Committed: 2004-04-13T22:13:19Z (20 years, 7 months ago) by gbeauche
Branch: MAIN
Changes since 1.22: +13 -10 lines
Log Message:
Disable VidMode extension by default as some video cards don't support it
well, thus causing a black screen. Besides, fix up sigsegv_recovery logic

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 cebix 1.1
187     dnl Checks for typedefs, structures, and compiler characteristics.
188     AC_C_BIGENDIAN
189     AC_C_CONST
190     AC_C_INLINE
191     AC_CHECK_SIZEOF(short, 2)
192     AC_CHECK_SIZEOF(int, 4)
193     AC_CHECK_SIZEOF(long, 4)
194     AC_CHECK_SIZEOF(long long, 8)
195 gbeauche 1.4 AC_CHECK_SIZEOF(float, 4)
196     AC_CHECK_SIZEOF(double, 8)
197 gbeauche 1.3 AC_CHECK_SIZEOF(void *, 4)
198 cebix 1.1 AC_TYPE_OFF_T
199     AC_CHECK_TYPE(loff_t, off_t)
200     AC_TYPE_SIZE_T
201 gbeauche 1.4 AC_TYPE_SIGNAL
202 cebix 1.1 AC_HEADER_TIME
203     AC_STRUCT_TM
204    
205 gbeauche 1.17 dnl Check whether struct sigaction has sa_restorer member.
206     AC_CACHE_CHECK([whether struct sigaction has sa_restorer],
207     ac_cv_signal_sa_restorer, [
208     AC_TRY_COMPILE([
209     #include <signal.h>
210     ], [struct sigaction sa; sa.sa_restorer = 0;],
211     ac_cv_signal_sa_restorer=yes, ac_cv_signal_sa_restorer=no,
212     dnl When cross-compiling, do not assume anything.
213     ac_cv_signal_sa_restorer=no
214     )
215     ])
216     if [[ "x$ac_cv_signal_sa_restorer" = "xyes" ]]; then
217     AC_DEFINE(HAVE_SIGNAL_SA_RESTORER)
218     fi
219    
220 cebix 1.1 dnl Checks for library functions.
221     AC_CHECK_FUNCS(strdup cfmakeraw)
222 gbeauche 1.16 AC_CHECK_FUNCS(nanosleep)
223 gbeauche 1.4 AC_CHECK_FUNCS(sigaction signal)
224     AC_CHECK_FUNCS(mmap mprotect munmap)
225     AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
226 gbeauche 1.22 AC_CHECK_FUNCS(posix_memalign memalign valloc)
227 gbeauche 1.17
228     dnl Darwin seems to define mach_task_self() instead of task_self().
229     AC_CHECK_FUNCS(mach_task_self task_self)
230    
231 gbeauche 1.16 dnl We need clock_gettime() for better performance but it may drag
232     dnl libpthread in, which we don't want for native ppc mode
233 gbeauche 1.17 case $EMULATED_PPC:$target_os in
234     no:linux*)
235     ;;
236     *:*)
237 gbeauche 1.16 AC_SEARCH_LIBS(clock_gettime, [rt posix4])
238     AC_CHECK_FUNCS(clock_gettime)
239 gbeauche 1.17 ;;
240     esac
241 cebix 1.1
242     dnl Select system-dependant sources.
243 gbeauche 1.17 SERIALSRC=serial_unix.cpp
244     ETHERSRC=../dummy/ether_dummy.cpp
245     SCSISRC=../dummy/scsi_dummy.cpp
246     AUDIOSRC=../dummy/audio_dummy.cpp
247     EXTRASYSSRCS=
248     case "$target_os" in
249     linux*)
250     ETHERSRC=Linux/ether_linux.cpp
251     AUDIOSRC=audio_oss_esd.cpp
252     SCSISRC=Linux/scsi_linux.cpp
253     if [[ "x$EMULATED_PPC" = "xno" ]]; then
254     EXTRASYSSRCS="Linux/paranoia.cpp Linux/sheepthreads.c Linux/asm_linux.S"
255     fi
256     ;;
257     darwin*)
258     if [[ "x$EMULATED_PPC" = "xno" ]]; then
259     EXTRASYSSRCS="Darwin/paranoia.cpp Linux/asm_linux.S"
260     fi
261     ;;
262     esac
263     SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
264 gbeauche 1.4
265     dnl Define a macro that translates a yesno-variable into a C macro definition
266     dnl to be put into the config.h file
267     dnl $1 -- the macro to define
268     dnl $2 -- the value to translate
269     dnl $3 -- template name
270     AC_DEFUN(AC_TRANSLATE_DEFINE, [
271     if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
272     AC_DEFINE($1, 1, $3)
273     fi
274     ])
275    
276     dnl Various checks if the system supports vm_allocate() and the like functions.
277     have_mach_vm=no
278     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
279     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
280     have_mach_vm=yes
281     fi
282     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
283     [Define if your system has a working vm_allocate()-based memory allocator.])
284    
285     dnl Check that vm_allocate(), vm_protect() work
286     if [[ "x$have_mach_vm" = "xyes" ]]; then
287    
288     AC_CACHE_CHECK([whether vm_protect works],
289     ac_cv_vm_protect_works, [
290     AC_LANG_SAVE
291     AC_LANG_CPLUSPLUS
292     ac_cv_vm_protect_works=yes
293     dnl First the tests that should segfault
294     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
295     AC_TRY_RUN([
296     #define CONFIGURE_TEST_VM_MAP
297     #define TEST_VM_PROT_$test_def
298     #include "vm_alloc.cpp"
299     ], ac_cv_vm_protect_works=no, rm -f core,
300     dnl When cross-compiling, do not assume anything
301     ac_cv_vm_protect_works="guessing no"
302     )
303     done
304     AC_TRY_RUN([
305     #define CONFIGURE_TEST_VM_MAP
306     #define TEST_VM_PROT_RDWR_WRITE
307     #include "vm_alloc.cpp"
308     ], , ac_cv_vm_protect_works=no,
309     dnl When cross-compiling, do not assume anything
310     ac_cv_vm_protect_works="guessing no"
311     )
312     AC_LANG_RESTORE
313     ]
314     )
315    
316     dnl Remove support for vm_allocate() if vm_protect() does not work
317     if [[ "x$have_mach_vm" = "xyes" ]]; then
318     case $ac_cv_vm_protect_works in
319     *yes) have_mach_vm=yes;;
320     *no) have_mach_vm=no;;
321     esac
322     fi
323     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
324     [Define if your system has a working vm_allocate()-based memory allocator.])
325    
326     fi dnl HAVE_MACH_VM
327    
328     dnl Various checks if the system supports mmap() and the like functions.
329     dnl ... and Mach memory allocators are not supported
330     have_mmap_vm=no
331     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
332     "x$ac_cv_func_mprotect" = "xyes" ]]; then
333     if [[ "x$have_mach_vm" = "xno" ]]; then
334     have_mmap_vm=yes
335     fi
336     fi
337     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
338     [Define if your system has a working mmap()-based memory allocator.])
339    
340     dnl Check that mmap() and associated functions work.
341     if [[ "x$have_mmap_vm" = "xyes" ]]; then
342    
343     dnl Check if we have a working anonymous mmap()
344     AC_CACHE_CHECK([whether mmap supports MAP_ANON],
345     ac_cv_mmap_anon, [
346     AC_LANG_SAVE
347     AC_LANG_CPLUSPLUS
348     AC_TRY_RUN([
349     #define HAVE_MMAP_ANON
350     #define CONFIGURE_TEST_VM_MAP
351     #define TEST_VM_MMAP_ANON
352     #include "vm_alloc.cpp"
353     ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
354     dnl When cross-compiling, do not assume anything.
355     ac_cv_mmap_anon="guessing no"
356     )
357     AC_LANG_RESTORE
358     ]
359     )
360     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
361     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
362    
363     AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
364     ac_cv_mmap_anonymous, [
365     AC_LANG_SAVE
366     AC_LANG_CPLUSPLUS
367     AC_TRY_RUN([
368     #define HAVE_MMAP_ANONYMOUS
369     #define CONFIGURE_TEST_VM_MAP
370     #define TEST_VM_MMAP_ANON
371     #include "vm_alloc.cpp"
372     ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
373     dnl When cross-compiling, do not assume anything.
374     ac_cv_mmap_anonymous="guessing no"
375     )
376     AC_LANG_RESTORE
377     ]
378     )
379     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
380     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
381    
382     AC_CACHE_CHECK([whether mprotect works],
383     ac_cv_mprotect_works, [
384     AC_LANG_SAVE
385     AC_LANG_CPLUSPLUS
386     ac_cv_mprotect_works=yes
387     dnl First the tests that should segfault
388     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
389     AC_TRY_RUN([
390     #define CONFIGURE_TEST_VM_MAP
391     #define TEST_VM_PROT_$test_def
392     #include "vm_alloc.cpp"
393     ], ac_cv_mprotect_works=no, rm -f core,
394     dnl When cross-compiling, do not assume anything
395     ac_cv_mprotect_works="guessing no"
396     )
397     done
398     AC_TRY_RUN([
399     #define CONFIGURE_TEST_VM_MAP
400     #define TEST_VM_PROT_RDWR_WRITE
401     #include "vm_alloc.cpp"
402     ], , ac_cv_mprotect_works=no,
403     dnl When cross-compiling, do not assume anything
404     ac_cv_mprotect_works="guessing no"
405     )
406     AC_LANG_RESTORE
407     ]
408     )
409    
410     dnl Remove support for mmap() if mprotect() does not work
411     if [[ "x$have_mmap_vm" = "xyes" ]]; then
412     case $ac_cv_mprotect_works in
413     *yes) have_mmap_vm=yes;;
414     *no) have_mmap_vm=no;;
415     esac
416     fi
417     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
418     [Define if your system has a working mmap()-based memory allocator.])
419    
420     fi dnl HAVE_MMAP_VM
421    
422 gbeauche 1.17 dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
423     AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000],
424     ac_cv_pagezero_hack, [
425     ac_cv_pagezero_hack=no
426     if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then
427     ac_cv_pagezero_hack=yes
428     dnl might as well skip the test for mmap-able low memory
429     ac_cv_can_map_lm=no
430     fi
431     ])
432     AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
433     [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
434    
435     dnl Check if we can mmap 0x3000 bytes from 0x0000
436     AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000],
437 gbeauche 1.4 ac_cv_can_map_lm, [
438     AC_LANG_SAVE
439     AC_LANG_CPLUSPLUS
440     AC_TRY_RUN([
441     #include "vm_alloc.cpp"
442     int main(void) { /* returns 0 if we could map the lowmem globals */
443     volatile char * lm = 0;
444     if (vm_init() < 0) exit(1);
445     if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
446     lm[0] = 'z';
447     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
448     vm_exit(); exit(0);
449     }
450     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
451     dnl When cross-compiling, do not assume anything.
452     ac_cv_can_map_lm="guessing no"
453     )
454     AC_LANG_RESTORE
455     ]
456     )
457    
458     dnl Check signal handlers need to be reinstalled
459     AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
460     ac_cv_signal_need_reinstall, [
461     AC_LANG_SAVE
462     AC_LANG_CPLUSPLUS
463     AC_TRY_RUN([
464     #include <stdlib.h>
465     #ifdef HAVE_UNISTD_H
466     #include <unistd.h>
467     #endif
468     #include <signal.h>
469     static int handled_signal = 0;
470     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
471     int main(void) { /* returns 0 if signals need not to be reinstalled */
472     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
473     exit(handled_signal == 2);
474     }
475     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
476     dnl When cross-compiling, do not assume anything.
477     ac_cv_signal_need_reinstall="guessing yes"
478     )
479     AC_LANG_RESTORE
480     ]
481     )
482     AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
483     [Define if your system requires signals to be reinstalled.])
484    
485     dnl Check if sigaction handlers need to be reinstalled
486     AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
487     ac_cv_sigaction_need_reinstall, [
488     AC_LANG_SAVE
489     AC_LANG_CPLUSPLUS
490     AC_TRY_RUN([
491     #include <stdlib.h>
492     #ifdef HAVE_UNISTD_H
493     #include <unistd.h>
494     #endif
495     #include <signal.h>
496     static int handled_signal = 0;
497     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
498     typedef RETSIGTYPE (*signal_handler)(int);
499     static signal_handler mysignal(int sig, signal_handler handler) {
500     struct sigaction old_sa;
501     struct sigaction new_sa;
502     new_sa.sa_handler = handler;
503     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
504     }
505     int main(void) { /* returns 0 if signals need not to be reinstalled */
506     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
507     exit(handled_signal == 2);
508     }
509     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
510     dnl When cross-compiling, do not assume anything.
511     ac_cv_sigaction_need_reinstall="guessing yes"
512     )
513     AC_LANG_RESTORE
514     ]
515     )
516     AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
517     [Define if your system requires sigactions to be reinstalled.])
518    
519 gbeauche 1.17 dnl Check if Mach exceptions supported.
520     AC_CACHE_CHECK([whether your system supports Mach exceptions],
521     ac_cv_have_mach_exceptions, [
522 gbeauche 1.4 AC_LANG_SAVE
523     AC_LANG_CPLUSPLUS
524     AC_TRY_RUN([
525 gbeauche 1.17 #define HAVE_MACH_EXCEPTIONS 1
526 gbeauche 1.4 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
527     #include "vm_alloc.cpp"
528     #include "sigsegv.cpp"
529 gbeauche 1.17 ],
530 gbeauche 1.23 ac_cv_have_mach_exceptions=yes,
531 gbeauche 1.17 ac_cv_have_mach_exceptions=no,
532 gbeauche 1.4 dnl When cross-compiling, do not assume anything.
533 gbeauche 1.17 ac_cv_have_mach_exceptions=no
534 gbeauche 1.4 )
535     AC_LANG_RESTORE
536     ]
537     )
538 gbeauche 1.23 if [[ "$ac_cv_have_mach_exceptions" = "yes" ]]; then
539     sigsegv_recovery=mach
540     fi
541 gbeauche 1.17 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
542     [Define if your system supports Mach exceptions.])
543    
544     dnl Otherwise, check if extended signals are supported.
545     if [[ -z "$sigsegv_recovery" ]]; then
546     AC_CACHE_CHECK([whether your system supports extended signal handlers],
547     ac_cv_have_extended_signals, [
548     AC_LANG_SAVE
549     AC_LANG_CPLUSPLUS
550     AC_TRY_RUN([
551     #define HAVE_SIGINFO_T 1
552     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
553     #include "vm_alloc.cpp"
554     #include "sigsegv.cpp"
555     ],
556 gbeauche 1.23 ac_cv_have_extended_signals=yes,
557 gbeauche 1.17 ac_cv_have_extended_signals=no,
558     dnl When cross-compiling, do not assume anything.
559     ac_cv_have_extended_signals=no
560     )
561     AC_LANG_RESTORE
562     ]
563     )
564 gbeauche 1.23 if [[ "$ac_cv_have_extended_signals" = "yes" ]]; then
565     sigsegv_recovery=siginfo
566     fi
567 gbeauche 1.17 AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
568     [Define if your system support extended signals.])
569     fi
570 gbeauche 1.4
571     dnl Otherwise, check for subterfuges.
572 gbeauche 1.17 if [[ -z "$sigsegv_recovery" ]]; then
573 gbeauche 1.4 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
574     ac_cv_have_sigcontext_hack, [
575     AC_LANG_SAVE
576     AC_LANG_CPLUSPLUS
577     AC_TRY_RUN([
578     #define HAVE_SIGCONTEXT_SUBTERFUGE 1
579     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
580     #include "vm_alloc.cpp"
581     #include "sigsegv.cpp"
582 gbeauche 1.17 ],
583 gbeauche 1.23 ac_cv_have_sigcontext_hack=yes,
584 gbeauche 1.17 ac_cv_have_sigcontext_hack=no,
585 gbeauche 1.4 dnl When cross-compiling, do not assume anything.
586     ac_cv_have_sigcontext_hack=no
587     )
588     AC_LANG_RESTORE
589     ])
590 gbeauche 1.23 if [[ "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
591     sigsegv_recovery=sigcontext
592     fi
593 gbeauche 1.4 AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
594     [Define if we know a hack to replace siginfo_t->si_addr member.])
595     fi
596    
597     dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
598     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
599     ac_cv_have_skip_instruction, [
600     AC_LANG_SAVE
601     AC_LANG_CPLUSPLUS
602     AC_TRY_RUN([
603     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
604     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
605     #include "vm_alloc.cpp"
606     #include "sigsegv.cpp"
607     ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
608     dnl When cross-compiling, do not assume anything.
609     ac_cv_have_skip_instruction=no
610     )
611     AC_LANG_RESTORE
612     ]
613     )
614     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
615     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
616 cebix 1.1
617 gbeauche 1.5 dnl Can we do Video on SEGV Signals ?
618     CAN_VOSF=no
619 gbeauche 1.17 if [[ -n "$sigsegv_recovery" ]]; then
620 gbeauche 1.5 CAN_VOSF=yes
621     fi
622    
623     dnl Enable VOSF screen updates with this feature is requested and feasible
624     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
625     AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
626     else
627     WANT_VOSF=no
628     fi
629    
630 gbeauche 1.17 dnl Platform specific binary postprocessor
631     BLESS=/bin/true
632     if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
633     BLESS=Darwin/lowmem
634     LDFLAGS="$LDFLAGS -pagezero_size 0x3000"
635     fi
636    
637 gbeauche 1.9 dnl Check for GCC 2.7 or higher.
638     HAVE_GCC27=no
639     AC_MSG_CHECKING(for GCC 2.7 or higher)
640     AC_EGREP_CPP(xyes,
641     [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
642     xyes
643     #endif
644     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
645    
646     dnl Check for GCC 3.0 or higher.
647     HAVE_GCC30=no
648     AC_MSG_CHECKING(for GCC 3.0 or higher)
649     AC_EGREP_CPP(xyes,
650     [#if __GNUC__ >= 3
651     xyes
652     #endif
653     ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
654    
655 gbeauche 1.18 dnl Check for ICC.
656     AC_MSG_CHECKING(for ICC)
657     HAVE_ICC=no
658     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
659     HAVE_ICC=yes
660     fi
661     AC_MSG_RESULT($HAVE_ICC)
662    
663 gbeauche 1.9 # Test if the compiler can generate ELF objects
664     AC_CACHE_CHECK([whether the compiler can generate ELF objects],
665     ac_cv_elf_objects, [
666     echo 'int i;' > conftest.$ac_ext
667     ac_cv_elf_objects=no
668     if AC_TRY_EVAL(ac_compile); then
669     case `/usr/bin/file conftest.$ac_objext` in
670     *"ELF"*)
671     ac_cv_elf_objects=yes
672     ;;
673     esac
674     fi
675     rm -rf conftest*
676     ])
677     ELF_OBJECTS=$ac_cv_elf_objects
678    
679     dnl CPU emulator sources
680     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
681     CPUSRCS="\
682     ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
683     ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
684     ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
685     ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp"
686     CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
687    
688     dnl Enable JIT compiler, if possible
689     if [[ "x$WANT_JIT" = "xyes" ]]; then
690     AC_CACHE_CHECK([whether dyngen can be used],
691     ac_cv_use_dyngen, [
692     case $host_cpu:$ELF_OBJECTS in
693     powerpc:yes)
694     ac_cv_use_dyngen=yes
695     ;;
696     x86_64:yes)
697     ac_cv_use_dyngen=yes
698     ;;
699     i?86:yes)
700     ac_cv_use_dyngen=yes
701     ;;
702     *:*)
703     ac_cv_use_dyngen=no
704     ;;
705     esac
706 gbeauche 1.18 dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
707     if [[ -z "$DYNGEN_CC" ]]; then
708     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
709     DYNGEN_CC=$CXX
710     else
711     for p in /usr/bin /usr/local/bin; do
712     gxx="$p/g++"
713     if [[ -x "$gxx" ]]; then
714     DYNGEN_CC="$gxx"
715     fi
716     done
717     fi
718     fi
719     if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include <limits>' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then
720     ac_cv_use_dyngen=no
721     fi
722 gbeauche 1.9 ])
723     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
724     case $host_cpu in
725 gbeauche 1.11 i?86)
726 gbeauche 1.9 DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2"
727     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
728     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0"
729     else
730     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
731 gbeauche 1.19 fi
732 gbeauche 1.21 saved_CPPFLAGS=$CPPFLAGS
733     CPPFLAGS="$CPPFLAGS -mmmx"
734     AC_CHECK_HEADERS(mmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -mmmx"])
735     CPPFLAGS="$CPPFLAGS -msse"
736     AC_CHECK_HEADERS(xmmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse"])
737     CPPFLAGS="$CPPFLAGS -msse2"
738     AC_CHECK_HEADERS(emmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse2"])
739     CPPFLAGS=$saved_CPPFLAGS
740     ;;
741     x86_64)
742     AC_CHECK_HEADERS(mmintrin.h xmmintrin.h emmintrin.h)
743 gbeauche 1.9 ;;
744     esac
745 gbeauche 1.12 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000"
746 gbeauche 1.9 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
747     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
748     fi
749     else
750     WANT_JIT=no
751     fi
752     AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
753     if [[ "x$WANT_JIT" = "xyes" ]]; then
754     DYNGENSRCS="\
755     ../kpx_cpu/src/cpu/jit/dyngen.c \
756     ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
757     CPUSRCS="\
758     ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
759     ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
760     ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS"
761     fi
762     fi
763     CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
764 gbeauche 1.13 else
765     WANT_JIT=no
766 gbeauche 1.9 fi
767 gbeauche 1.10 if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
768     AC_CACHE_CHECK([whether static data regions are executable],
769     ac_cv_have_static_data_exec, [
770     AC_TRY_RUN([int main(void) {
771     #if defined(__powerpc__)
772     static unsigned int p[8] = {0x4e800020,};
773     asm volatile("dcbst 0,%0" : : "r" (p) : "memory");
774     asm volatile("sync" : : : "memory");
775     asm volatile("icbi 0,%0" : : "r" (p) : "memory");
776     asm volatile("sync" : : : "memory");
777     asm volatile("isync" : : : "memory");
778     ((void (*)(void))p)();
779     return 0;
780     #endif
781     return 1;
782     }], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no,
783     dnl When cross-compiling, do not assume anything.
784     ac_cv_have_static_data_exec=no
785     )
786     ])
787     fi
788     AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec",
789     [Define if your system marks static data pages as executable.])
790 gbeauche 1.12
791     if [[ "x$WANT_JIT" = "xyes" ]]; then
792     CPPFLAGS="$CPPFLAGS -DUSE_JIT"
793     fi
794 gbeauche 1.9
795 cebix 1.1 dnl Generate Makefile.
796 gbeauche 1.9 AC_SUBST(DYNGENSRCS)
797 gbeauche 1.18 AC_SUBST(DYNGEN_CC)
798 gbeauche 1.9 AC_SUBST(DYNGEN_OP_FLAGS)
799 cebix 1.1 AC_SUBST(SYSSRCS)
800 gbeauche 1.9 AC_SUBST(CPUSRCS)
801 gbeauche 1.17 AC_SUBST(BLESS)
802 cebix 1.1 AC_OUTPUT(Makefile)
803    
804     dnl Print summary.
805     echo
806     echo SheepShaver configuration summary:
807     echo
808     echo XFree86 DGA support .............. : $WANT_XF86_DGA
809     echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
810 gbeauche 1.6 echo Using PowerPC emulator ........... : $EMULATED_PPC
811 gbeauche 1.9 echo Enable JIT compiler .............. : $WANT_JIT
812 gbeauche 1.5 echo Enable video on SEGV signals ..... : $WANT_VOSF
813 cebix 1.1 echo ESD sound support ................ : $WANT_ESD
814     echo GTK user interface ............... : $WANT_GTK
815     echo mon debugger support ............. : $WANT_MON
816 gbeauche 1.17 echo Bad memory access recovery type .. : $sigsegv_recovery
817 cebix 1.1 echo
818     echo "Configuration done. Now type \"make\"."