ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.in
Revision: 1.16
Committed: 2004-01-06T13:24:56Z (20 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.15: +10 -1 lines
Log Message:
Look for clock_gettime() as it is faster that gettime() for GetTicks_usec()
implementation. Also look for extra pthread related functions.

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