ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.in
Revision: 1.29
Committed: 2004-06-26T15:26:17Z (20 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.28: +0 -8 lines
Log Message:
Performance of VOSF is heuristically determined at run-time, so have to
initialize SIGSEGV handlers early, as in Basilisk II. Besides, also add
missing call to vm_init() in case host system doesn't have MAP_ANON.

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