ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.in
Revision: 1.27
Committed: 2004-06-24T16:13:53Z (20 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.26: +2 -2 lines
Log Message:
Check for strlcpy(). Check for "true" better with AC_PROG_PATH

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