ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.in
Revision: 1.22
Committed: 2004-02-24T14:09:11Z (20 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.21: +1 -0 lines
Log Message:
16-byte aligned memory allocator will try the following functions in-order
(determined at compile-time): posix_memalign, memalign, valloc, malloc.

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 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     sigsegv_recovery=mach
531     ac_cv_have_mach_exceptions=yes
532     ],
533     ac_cv_have_mach_exceptions=no,
534 gbeauche 1.4 dnl When cross-compiling, do not assume anything.
535 gbeauche 1.17 ac_cv_have_mach_exceptions=no
536 gbeauche 1.4 )
537     AC_LANG_RESTORE
538     ]
539     )
540 gbeauche 1.17 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
541     [Define if your system supports Mach exceptions.])
542    
543     dnl Otherwise, check if extended signals are supported.
544     if [[ -z "$sigsegv_recovery" ]]; then
545     AC_CACHE_CHECK([whether your system supports extended signal handlers],
546     ac_cv_have_extended_signals, [
547     AC_LANG_SAVE
548     AC_LANG_CPLUSPLUS
549     AC_TRY_RUN([
550     #define HAVE_SIGINFO_T 1
551     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
552     #include "vm_alloc.cpp"
553     #include "sigsegv.cpp"
554     ], [
555     sigsegv_recovery=siginfo
556     ac_cv_have_extended_signals=yes
557     ],
558     ac_cv_have_extended_signals=no,
559     dnl When cross-compiling, do not assume anything.
560     ac_cv_have_extended_signals=no
561     )
562     AC_LANG_RESTORE
563     ]
564     )
565     AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
566     [Define if your system support extended signals.])
567     fi
568 gbeauche 1.4
569     dnl Otherwise, check for subterfuges.
570 gbeauche 1.17 if [[ -z "$sigsegv_recovery" ]]; then
571 gbeauche 1.4 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
572     ac_cv_have_sigcontext_hack, [
573     AC_LANG_SAVE
574     AC_LANG_CPLUSPLUS
575     AC_TRY_RUN([
576     #define HAVE_SIGCONTEXT_SUBTERFUGE 1
577     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
578     #include "vm_alloc.cpp"
579     #include "sigsegv.cpp"
580 gbeauche 1.17 ], [
581     sigsegv_recovery=sigcontext
582     ac_cv_have_sigcontext_hack=yes
583     ],
584     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     AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
591     [Define if we know a hack to replace siginfo_t->si_addr member.])
592     fi
593    
594     dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
595     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
596     ac_cv_have_skip_instruction, [
597     AC_LANG_SAVE
598     AC_LANG_CPLUSPLUS
599     AC_TRY_RUN([
600     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
601     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
602     #include "vm_alloc.cpp"
603     #include "sigsegv.cpp"
604     ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
605     dnl When cross-compiling, do not assume anything.
606     ac_cv_have_skip_instruction=no
607     )
608     AC_LANG_RESTORE
609     ]
610     )
611     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
612     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
613 cebix 1.1
614 gbeauche 1.5 dnl Can we do Video on SEGV Signals ?
615     CAN_VOSF=no
616 gbeauche 1.17 if [[ -n "$sigsegv_recovery" ]]; then
617 gbeauche 1.5 CAN_VOSF=yes
618     fi
619    
620     dnl Enable VOSF screen updates with this feature is requested and feasible
621     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
622     AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
623     else
624     WANT_VOSF=no
625     fi
626    
627 gbeauche 1.17 dnl Platform specific binary postprocessor
628     BLESS=/bin/true
629     if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
630     BLESS=Darwin/lowmem
631     LDFLAGS="$LDFLAGS -pagezero_size 0x3000"
632     fi
633    
634 gbeauche 1.9 dnl Check for GCC 2.7 or higher.
635     HAVE_GCC27=no
636     AC_MSG_CHECKING(for GCC 2.7 or higher)
637     AC_EGREP_CPP(xyes,
638     [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
639     xyes
640     #endif
641     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
642    
643     dnl Check for GCC 3.0 or higher.
644     HAVE_GCC30=no
645     AC_MSG_CHECKING(for GCC 3.0 or higher)
646     AC_EGREP_CPP(xyes,
647     [#if __GNUC__ >= 3
648     xyes
649     #endif
650     ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
651    
652 gbeauche 1.18 dnl Check for ICC.
653     AC_MSG_CHECKING(for ICC)
654     HAVE_ICC=no
655     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
656     HAVE_ICC=yes
657     fi
658     AC_MSG_RESULT($HAVE_ICC)
659    
660 gbeauche 1.9 # Test if the compiler can generate ELF objects
661     AC_CACHE_CHECK([whether the compiler can generate ELF objects],
662     ac_cv_elf_objects, [
663     echo 'int i;' > conftest.$ac_ext
664     ac_cv_elf_objects=no
665     if AC_TRY_EVAL(ac_compile); then
666     case `/usr/bin/file conftest.$ac_objext` in
667     *"ELF"*)
668     ac_cv_elf_objects=yes
669     ;;
670     esac
671     fi
672     rm -rf conftest*
673     ])
674     ELF_OBJECTS=$ac_cv_elf_objects
675    
676     dnl CPU emulator sources
677     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
678     CPUSRCS="\
679     ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
680     ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
681     ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
682     ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp"
683     CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
684    
685     dnl Enable JIT compiler, if possible
686     if [[ "x$WANT_JIT" = "xyes" ]]; then
687     AC_CACHE_CHECK([whether dyngen can be used],
688     ac_cv_use_dyngen, [
689     case $host_cpu:$ELF_OBJECTS in
690     powerpc:yes)
691     ac_cv_use_dyngen=yes
692     ;;
693     x86_64:yes)
694     ac_cv_use_dyngen=yes
695     ;;
696     i?86:yes)
697     ac_cv_use_dyngen=yes
698     ;;
699     *:*)
700     ac_cv_use_dyngen=no
701     ;;
702     esac
703 gbeauche 1.18 dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
704     if [[ -z "$DYNGEN_CC" ]]; then
705     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
706     DYNGEN_CC=$CXX
707     else
708     for p in /usr/bin /usr/local/bin; do
709     gxx="$p/g++"
710     if [[ -x "$gxx" ]]; then
711     DYNGEN_CC="$gxx"
712     fi
713     done
714     fi
715     fi
716     if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include <limits>' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then
717     ac_cv_use_dyngen=no
718     fi
719 gbeauche 1.9 ])
720     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
721     case $host_cpu in
722 gbeauche 1.11 i?86)
723 gbeauche 1.9 DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2"
724     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
725     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0"
726     else
727     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
728 gbeauche 1.19 fi
729 gbeauche 1.21 saved_CPPFLAGS=$CPPFLAGS
730     CPPFLAGS="$CPPFLAGS -mmmx"
731     AC_CHECK_HEADERS(mmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -mmmx"])
732     CPPFLAGS="$CPPFLAGS -msse"
733     AC_CHECK_HEADERS(xmmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse"])
734     CPPFLAGS="$CPPFLAGS -msse2"
735     AC_CHECK_HEADERS(emmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse2"])
736     CPPFLAGS=$saved_CPPFLAGS
737     ;;
738     x86_64)
739     AC_CHECK_HEADERS(mmintrin.h xmmintrin.h emmintrin.h)
740 gbeauche 1.9 ;;
741     esac
742 gbeauche 1.12 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000"
743 gbeauche 1.9 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
744     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
745     fi
746     else
747     WANT_JIT=no
748     fi
749     AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
750     if [[ "x$WANT_JIT" = "xyes" ]]; then
751     DYNGENSRCS="\
752     ../kpx_cpu/src/cpu/jit/dyngen.c \
753     ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
754     CPUSRCS="\
755     ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
756     ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
757     ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS"
758     fi
759     fi
760     CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
761 gbeauche 1.13 else
762     WANT_JIT=no
763 gbeauche 1.9 fi
764 gbeauche 1.10 if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
765     AC_CACHE_CHECK([whether static data regions are executable],
766     ac_cv_have_static_data_exec, [
767     AC_TRY_RUN([int main(void) {
768     #if defined(__powerpc__)
769     static unsigned int p[8] = {0x4e800020,};
770     asm volatile("dcbst 0,%0" : : "r" (p) : "memory");
771     asm volatile("sync" : : : "memory");
772     asm volatile("icbi 0,%0" : : "r" (p) : "memory");
773     asm volatile("sync" : : : "memory");
774     asm volatile("isync" : : : "memory");
775     ((void (*)(void))p)();
776     return 0;
777     #endif
778     return 1;
779     }], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no,
780     dnl When cross-compiling, do not assume anything.
781     ac_cv_have_static_data_exec=no
782     )
783     ])
784     fi
785     AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec",
786     [Define if your system marks static data pages as executable.])
787 gbeauche 1.12
788     if [[ "x$WANT_JIT" = "xyes" ]]; then
789     CPPFLAGS="$CPPFLAGS -DUSE_JIT"
790     fi
791 gbeauche 1.9
792 cebix 1.1 dnl Generate Makefile.
793 gbeauche 1.9 AC_SUBST(DYNGENSRCS)
794 gbeauche 1.18 AC_SUBST(DYNGEN_CC)
795 gbeauche 1.9 AC_SUBST(DYNGEN_OP_FLAGS)
796 cebix 1.1 AC_SUBST(SYSSRCS)
797 gbeauche 1.9 AC_SUBST(CPUSRCS)
798 gbeauche 1.17 AC_SUBST(BLESS)
799 cebix 1.1 AC_OUTPUT(Makefile)
800    
801     dnl Print summary.
802     echo
803     echo SheepShaver configuration summary:
804     echo
805     echo XFree86 DGA support .............. : $WANT_XF86_DGA
806     echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
807 gbeauche 1.6 echo Using PowerPC emulator ........... : $EMULATED_PPC
808 gbeauche 1.9 echo Enable JIT compiler .............. : $WANT_JIT
809 gbeauche 1.5 echo Enable video on SEGV signals ..... : $WANT_VOSF
810 cebix 1.1 echo ESD sound support ................ : $WANT_ESD
811     echo GTK user interface ............... : $WANT_GTK
812     echo mon debugger support ............. : $WANT_MON
813 gbeauche 1.17 echo Bad memory access recovery type .. : $sigsegv_recovery
814 cebix 1.1 echo
815     echo "Configuration done. Now type \"make\"."