ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.in
Revision: 1.17
Committed: 2004-01-18T22:12:24Z (20 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.16: +131 -30 lines
Log Message:
Handle dummy files. Merge in configure stuff for Mach exception filters.
Check whether struct sigaction defines sa_restorer member. Don't include
posix_sem.cpp on native Linux/ppc builds.

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