ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.in
Revision: 1.30
Committed: 2004-06-27T22:12:52Z (20 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.29: +36 -2 lines
Log Message:
Add configure macros to check for -framework Carbon and -framwork IOKit so
that we can include ../MacOSX/clip_macosx.cpp (clipboard support),
../MacOSX/sys_darwin.cpp (cdrom, floppy et al. support). Also handle new
SDL keycodes file.

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 gbeauche 1.30 dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES)
277     AC_DEFUN(AC_CHECK_FRAMEWORK, [
278     AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl
279     AC_CACHE_CHECK([whether compiler supports framework $1],
280     ac_Framework, [
281     saved_LIBS="$LIBS"
282     LIBS="$LIBS -framework $1"
283     AC_TRY_LINK(
284     [$2], [int main(void) { return 0; }],
285     [AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"]
286     )
287     ])
288     AS_IF([test AS_VAR_GET(ac_Framework) = yes],
289     [AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])]
290     )
291     AS_VAR_POPDEF([ac_Framework])dnl
292     ])
293    
294     dnl Check for some MacOS X frameworks
295     AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>])
296     AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>])
297    
298 cebix 1.1 dnl Select system-dependant sources.
299 gbeauche 1.17 SERIALSRC=serial_unix.cpp
300     ETHERSRC=../dummy/ether_dummy.cpp
301     SCSISRC=../dummy/scsi_dummy.cpp
302     AUDIOSRC=../dummy/audio_dummy.cpp
303     EXTRASYSSRCS=
304     case "$target_os" in
305     linux*)
306     ETHERSRC=Linux/ether_linux.cpp
307     AUDIOSRC=audio_oss_esd.cpp
308     SCSISRC=Linux/scsi_linux.cpp
309     if [[ "x$EMULATED_PPC" = "xno" ]]; then
310     EXTRASYSSRCS="Linux/paranoia.cpp Linux/sheepthreads.c Linux/asm_linux.S"
311     fi
312     ;;
313     darwin*)
314     if [[ "x$EMULATED_PPC" = "xno" ]]; then
315     EXTRASYSSRCS="Darwin/paranoia.cpp Linux/asm_linux.S"
316     fi
317 gbeauche 1.30 if [[ "x$ac_cv_framework_IOKit" = "xyes" ]]; then
318     EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/sys_darwin.cpp"
319     fi
320 gbeauche 1.17 ;;
321     esac
322 gbeauche 1.26
323     dnl SDL overrides
324     if [[ "x$WANT_SDL" = "xyes" ]]; then
325     AC_DEFINE(USE_SDL, 1, [Define to enble SDL support])
326     fi
327     if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
328 gbeauche 1.30 VIDEOSRCS="../SDL/video_sdl.cpp"
329 gbeauche 1.26 AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support])
330 gbeauche 1.30 KEYCODES="../SDL/keycodes"
331     if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
332     EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp"
333     else
334     EXTRASYSSRCS="$EXTRASYSSRCS ../dummy/clip_dummy.cpp"
335     fi
336 gbeauche 1.26 else
337 gbeauche 1.30 VIDEOSRCS="video_x.cpp"
338     KEYCODES="keycodes"
339     EXTRASYSSRCS="$EXTRASYSSRCS clip_unix.cpp"
340 gbeauche 1.26 fi
341    
342     SYSSRCS="$VIDEOSRCS $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
343 gbeauche 1.4
344     dnl Define a macro that translates a yesno-variable into a C macro definition
345     dnl to be put into the config.h file
346     dnl $1 -- the macro to define
347     dnl $2 -- the value to translate
348     dnl $3 -- template name
349     AC_DEFUN(AC_TRANSLATE_DEFINE, [
350     if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
351     AC_DEFINE($1, 1, $3)
352     fi
353     ])
354    
355 gbeauche 1.24 dnl Check that the host supports TUN/TAP devices
356     AC_CACHE_CHECK([whether TUN/TAP is supported],
357     ac_cv_tun_tap_support, [
358     AC_TRY_COMPILE([
359     #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
360     #include <linux/if.h>
361     #include <linux/if_tun.h>
362     #endif
363     #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
364     #include <net/if.h>
365     #include <net/if_tun.h>
366     #endif
367     ], [
368     struct ifreq ifr;
369     memset(&ifr, 0, sizeof(ifr));
370     ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
371     ],
372     ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
373     )
374     ])
375     AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
376     [Define if your system supports TUN/TAP devices.])
377    
378 gbeauche 1.4 dnl Various checks if the system supports vm_allocate() and the like functions.
379     have_mach_vm=no
380     if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
381     "x$ac_cv_func_vm_protect" = "xyes" ]]; then
382     have_mach_vm=yes
383     fi
384     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
385     [Define if your system has a working vm_allocate()-based memory allocator.])
386    
387     dnl Check that vm_allocate(), vm_protect() work
388     if [[ "x$have_mach_vm" = "xyes" ]]; then
389    
390     AC_CACHE_CHECK([whether vm_protect works],
391     ac_cv_vm_protect_works, [
392     AC_LANG_SAVE
393     AC_LANG_CPLUSPLUS
394     ac_cv_vm_protect_works=yes
395     dnl First the tests that should segfault
396     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
397     AC_TRY_RUN([
398     #define CONFIGURE_TEST_VM_MAP
399     #define TEST_VM_PROT_$test_def
400     #include "vm_alloc.cpp"
401     ], ac_cv_vm_protect_works=no, rm -f core,
402     dnl When cross-compiling, do not assume anything
403     ac_cv_vm_protect_works="guessing no"
404     )
405     done
406     AC_TRY_RUN([
407     #define CONFIGURE_TEST_VM_MAP
408     #define TEST_VM_PROT_RDWR_WRITE
409     #include "vm_alloc.cpp"
410     ], , ac_cv_vm_protect_works=no,
411     dnl When cross-compiling, do not assume anything
412     ac_cv_vm_protect_works="guessing no"
413     )
414     AC_LANG_RESTORE
415     ]
416     )
417    
418     dnl Remove support for vm_allocate() if vm_protect() does not work
419     if [[ "x$have_mach_vm" = "xyes" ]]; then
420     case $ac_cv_vm_protect_works in
421     *yes) have_mach_vm=yes;;
422     *no) have_mach_vm=no;;
423     esac
424     fi
425     AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
426     [Define if your system has a working vm_allocate()-based memory allocator.])
427    
428     fi dnl HAVE_MACH_VM
429    
430     dnl Various checks if the system supports mmap() and the like functions.
431     dnl ... and Mach memory allocators are not supported
432     have_mmap_vm=no
433     if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
434     "x$ac_cv_func_mprotect" = "xyes" ]]; then
435     if [[ "x$have_mach_vm" = "xno" ]]; then
436     have_mmap_vm=yes
437     fi
438     fi
439     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
440     [Define if your system has a working mmap()-based memory allocator.])
441    
442     dnl Check that mmap() and associated functions work.
443     if [[ "x$have_mmap_vm" = "xyes" ]]; then
444    
445     dnl Check if we have a working anonymous mmap()
446     AC_CACHE_CHECK([whether mmap supports MAP_ANON],
447     ac_cv_mmap_anon, [
448     AC_LANG_SAVE
449     AC_LANG_CPLUSPLUS
450     AC_TRY_RUN([
451     #define HAVE_MMAP_ANON
452     #define CONFIGURE_TEST_VM_MAP
453     #define TEST_VM_MMAP_ANON
454     #include "vm_alloc.cpp"
455     ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
456     dnl When cross-compiling, do not assume anything.
457     ac_cv_mmap_anon="guessing no"
458     )
459     AC_LANG_RESTORE
460     ]
461     )
462     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
463     [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
464    
465     AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
466     ac_cv_mmap_anonymous, [
467     AC_LANG_SAVE
468     AC_LANG_CPLUSPLUS
469     AC_TRY_RUN([
470     #define HAVE_MMAP_ANONYMOUS
471     #define CONFIGURE_TEST_VM_MAP
472     #define TEST_VM_MMAP_ANON
473     #include "vm_alloc.cpp"
474     ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
475     dnl When cross-compiling, do not assume anything.
476     ac_cv_mmap_anonymous="guessing no"
477     )
478     AC_LANG_RESTORE
479     ]
480     )
481     AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
482     [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
483    
484     AC_CACHE_CHECK([whether mprotect works],
485     ac_cv_mprotect_works, [
486     AC_LANG_SAVE
487     AC_LANG_CPLUSPLUS
488     ac_cv_mprotect_works=yes
489     dnl First the tests that should segfault
490     for test_def in NONE_READ NONE_WRITE READ_WRITE; do
491     AC_TRY_RUN([
492     #define CONFIGURE_TEST_VM_MAP
493     #define TEST_VM_PROT_$test_def
494     #include "vm_alloc.cpp"
495     ], ac_cv_mprotect_works=no, rm -f core,
496     dnl When cross-compiling, do not assume anything
497     ac_cv_mprotect_works="guessing no"
498     )
499     done
500     AC_TRY_RUN([
501     #define CONFIGURE_TEST_VM_MAP
502     #define TEST_VM_PROT_RDWR_WRITE
503     #include "vm_alloc.cpp"
504     ], , ac_cv_mprotect_works=no,
505     dnl When cross-compiling, do not assume anything
506     ac_cv_mprotect_works="guessing no"
507     )
508     AC_LANG_RESTORE
509     ]
510     )
511    
512     dnl Remove support for mmap() if mprotect() does not work
513     if [[ "x$have_mmap_vm" = "xyes" ]]; then
514     case $ac_cv_mprotect_works in
515     *yes) have_mmap_vm=yes;;
516     *no) have_mmap_vm=no;;
517     esac
518     fi
519     AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
520     [Define if your system has a working mmap()-based memory allocator.])
521    
522     fi dnl HAVE_MMAP_VM
523    
524 gbeauche 1.17 dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
525     AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000],
526     ac_cv_pagezero_hack, [
527     ac_cv_pagezero_hack=no
528     if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then
529     ac_cv_pagezero_hack=yes
530     dnl might as well skip the test for mmap-able low memory
531     ac_cv_can_map_lm=no
532     fi
533     ])
534     AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
535     [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
536    
537     dnl Check if we can mmap 0x3000 bytes from 0x0000
538     AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000],
539 gbeauche 1.4 ac_cv_can_map_lm, [
540     AC_LANG_SAVE
541     AC_LANG_CPLUSPLUS
542     AC_TRY_RUN([
543     #include "vm_alloc.cpp"
544     int main(void) { /* returns 0 if we could map the lowmem globals */
545     volatile char * lm = 0;
546     if (vm_init() < 0) exit(1);
547     if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
548     lm[0] = 'z';
549     if (vm_release((char *)lm, 0x2000) < 0) exit(1);
550     vm_exit(); exit(0);
551     }
552     ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
553     dnl When cross-compiling, do not assume anything.
554     ac_cv_can_map_lm="guessing no"
555     )
556     AC_LANG_RESTORE
557     ]
558     )
559    
560     dnl Check signal handlers need to be reinstalled
561     AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
562     ac_cv_signal_need_reinstall, [
563     AC_LANG_SAVE
564     AC_LANG_CPLUSPLUS
565     AC_TRY_RUN([
566     #include <stdlib.h>
567     #ifdef HAVE_UNISTD_H
568     #include <unistd.h>
569     #endif
570     #include <signal.h>
571     static int handled_signal = 0;
572     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
573     int main(void) { /* returns 0 if signals need not to be reinstalled */
574     signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
575     exit(handled_signal == 2);
576     }
577     ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
578     dnl When cross-compiling, do not assume anything.
579     ac_cv_signal_need_reinstall="guessing yes"
580     )
581     AC_LANG_RESTORE
582     ]
583     )
584     AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
585     [Define if your system requires signals to be reinstalled.])
586    
587     dnl Check if sigaction handlers need to be reinstalled
588     AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
589     ac_cv_sigaction_need_reinstall, [
590     AC_LANG_SAVE
591     AC_LANG_CPLUSPLUS
592     AC_TRY_RUN([
593     #include <stdlib.h>
594     #ifdef HAVE_UNISTD_H
595     #include <unistd.h>
596     #endif
597     #include <signal.h>
598     static int handled_signal = 0;
599     RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
600     typedef RETSIGTYPE (*signal_handler)(int);
601     static signal_handler mysignal(int sig, signal_handler handler) {
602     struct sigaction old_sa;
603     struct sigaction new_sa;
604     new_sa.sa_handler = handler;
605     return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
606     }
607     int main(void) { /* returns 0 if signals need not to be reinstalled */
608     mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
609     exit(handled_signal == 2);
610     }
611     ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
612     dnl When cross-compiling, do not assume anything.
613     ac_cv_sigaction_need_reinstall="guessing yes"
614     )
615     AC_LANG_RESTORE
616     ]
617     )
618     AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
619     [Define if your system requires sigactions to be reinstalled.])
620    
621 gbeauche 1.17 dnl Check if Mach exceptions supported.
622     AC_CACHE_CHECK([whether your system supports Mach exceptions],
623     ac_cv_have_mach_exceptions, [
624 gbeauche 1.4 AC_LANG_SAVE
625     AC_LANG_CPLUSPLUS
626     AC_TRY_RUN([
627 gbeauche 1.17 #define HAVE_MACH_EXCEPTIONS 1
628 gbeauche 1.4 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
629     #include "vm_alloc.cpp"
630     #include "sigsegv.cpp"
631 gbeauche 1.17 ],
632 gbeauche 1.23 ac_cv_have_mach_exceptions=yes,
633 gbeauche 1.17 ac_cv_have_mach_exceptions=no,
634 gbeauche 1.4 dnl When cross-compiling, do not assume anything.
635 gbeauche 1.17 ac_cv_have_mach_exceptions=no
636 gbeauche 1.4 )
637     AC_LANG_RESTORE
638     ]
639     )
640 gbeauche 1.23 if [[ "$ac_cv_have_mach_exceptions" = "yes" ]]; then
641     sigsegv_recovery=mach
642     fi
643 gbeauche 1.17 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
644     [Define if your system supports Mach exceptions.])
645    
646     dnl Otherwise, check if extended signals are supported.
647     if [[ -z "$sigsegv_recovery" ]]; then
648     AC_CACHE_CHECK([whether your system supports extended signal handlers],
649     ac_cv_have_extended_signals, [
650     AC_LANG_SAVE
651     AC_LANG_CPLUSPLUS
652     AC_TRY_RUN([
653     #define HAVE_SIGINFO_T 1
654     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
655     #include "vm_alloc.cpp"
656     #include "sigsegv.cpp"
657     ],
658 gbeauche 1.23 ac_cv_have_extended_signals=yes,
659 gbeauche 1.17 ac_cv_have_extended_signals=no,
660     dnl When cross-compiling, do not assume anything.
661     ac_cv_have_extended_signals=no
662     )
663     AC_LANG_RESTORE
664     ]
665     )
666 gbeauche 1.23 if [[ "$ac_cv_have_extended_signals" = "yes" ]]; then
667     sigsegv_recovery=siginfo
668     fi
669 gbeauche 1.17 AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
670     [Define if your system support extended signals.])
671     fi
672 gbeauche 1.4
673     dnl Otherwise, check for subterfuges.
674 gbeauche 1.17 if [[ -z "$sigsegv_recovery" ]]; then
675 gbeauche 1.4 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
676     ac_cv_have_sigcontext_hack, [
677     AC_LANG_SAVE
678     AC_LANG_CPLUSPLUS
679     AC_TRY_RUN([
680     #define HAVE_SIGCONTEXT_SUBTERFUGE 1
681     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
682     #include "vm_alloc.cpp"
683     #include "sigsegv.cpp"
684 gbeauche 1.17 ],
685 gbeauche 1.23 ac_cv_have_sigcontext_hack=yes,
686 gbeauche 1.17 ac_cv_have_sigcontext_hack=no,
687 gbeauche 1.4 dnl When cross-compiling, do not assume anything.
688     ac_cv_have_sigcontext_hack=no
689     )
690     AC_LANG_RESTORE
691     ])
692 gbeauche 1.23 if [[ "$ac_cv_have_sigcontext_hack" = "yes" ]]; then
693     sigsegv_recovery=sigcontext
694     fi
695 gbeauche 1.4 AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
696     [Define if we know a hack to replace siginfo_t->si_addr member.])
697     fi
698    
699     dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
700     AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
701     ac_cv_have_skip_instruction, [
702     AC_LANG_SAVE
703     AC_LANG_CPLUSPLUS
704     AC_TRY_RUN([
705     #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
706     #define CONFIGURE_TEST_SIGSEGV_RECOVERY
707     #include "vm_alloc.cpp"
708     #include "sigsegv.cpp"
709     ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
710     dnl When cross-compiling, do not assume anything.
711     ac_cv_have_skip_instruction=no
712     )
713     AC_LANG_RESTORE
714     ]
715     )
716     AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
717     [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
718 cebix 1.1
719 gbeauche 1.5 dnl Can we do Video on SEGV Signals ?
720     CAN_VOSF=no
721 gbeauche 1.17 if [[ -n "$sigsegv_recovery" ]]; then
722 gbeauche 1.5 CAN_VOSF=yes
723     fi
724    
725     dnl Enable VOSF screen updates with this feature is requested and feasible
726     if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
727     AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
728     else
729     WANT_VOSF=no
730     fi
731    
732 gbeauche 1.17 dnl Platform specific binary postprocessor
733 gbeauche 1.27 AC_PATH_PROG(BLESS, "true")
734 gbeauche 1.17 if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
735     BLESS=Darwin/lowmem
736     LDFLAGS="$LDFLAGS -pagezero_size 0x3000"
737     fi
738    
739 gbeauche 1.9 dnl Check for GCC 2.7 or higher.
740     HAVE_GCC27=no
741     AC_MSG_CHECKING(for GCC 2.7 or higher)
742     AC_EGREP_CPP(xyes,
743     [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
744     xyes
745     #endif
746     ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
747    
748     dnl Check for GCC 3.0 or higher.
749     HAVE_GCC30=no
750     AC_MSG_CHECKING(for GCC 3.0 or higher)
751     AC_EGREP_CPP(xyes,
752     [#if __GNUC__ >= 3
753     xyes
754     #endif
755     ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
756    
757 gbeauche 1.18 dnl Check for ICC.
758     AC_MSG_CHECKING(for ICC)
759     HAVE_ICC=no
760     if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then
761     HAVE_ICC=yes
762     fi
763     AC_MSG_RESULT($HAVE_ICC)
764    
765 gbeauche 1.9 # Test if the compiler can generate ELF objects
766     AC_CACHE_CHECK([whether the compiler can generate ELF objects],
767     ac_cv_elf_objects, [
768     echo 'int i;' > conftest.$ac_ext
769     ac_cv_elf_objects=no
770     if AC_TRY_EVAL(ac_compile); then
771     case `/usr/bin/file conftest.$ac_objext` in
772     *"ELF"*)
773     ac_cv_elf_objects=yes
774     ;;
775     esac
776     fi
777     rm -rf conftest*
778     ])
779     ELF_OBJECTS=$ac_cv_elf_objects
780    
781     dnl CPU emulator sources
782     if [[ "x$EMULATED_PPC" = "xyes" ]]; then
783     CPUSRCS="\
784     ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \
785     ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \
786     ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \
787     ../kpx_cpu/src/cpu/ppc/ppc-translate.cpp"
788     CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src"
789    
790     dnl Enable JIT compiler, if possible
791     if [[ "x$WANT_JIT" = "xyes" ]]; then
792     AC_CACHE_CHECK([whether dyngen can be used],
793     ac_cv_use_dyngen, [
794     case $host_cpu:$ELF_OBJECTS in
795     powerpc:yes)
796     ac_cv_use_dyngen=yes
797     ;;
798     x86_64:yes)
799     ac_cv_use_dyngen=yes
800     ;;
801     i?86:yes)
802     ac_cv_use_dyngen=yes
803     ;;
804     *:*)
805     ac_cv_use_dyngen=no
806     ;;
807     esac
808 gbeauche 1.18 dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2)
809     if [[ -z "$DYNGEN_CC" ]]; then
810     if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then
811     DYNGEN_CC=$CXX
812     else
813     for p in /usr/bin /usr/local/bin; do
814     gxx="$p/g++"
815     if [[ -x "$gxx" ]]; then
816     DYNGEN_CC="$gxx"
817     fi
818     done
819     fi
820     fi
821     if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include <limits>' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then
822     ac_cv_use_dyngen=no
823     fi
824 gbeauche 1.9 ])
825     if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
826     case $host_cpu in
827 gbeauche 1.11 i?86)
828 gbeauche 1.9 DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2"
829     if [[ "x$HAVE_GCC30" = "xyes" ]]; then
830     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0"
831     else
832     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0"
833 gbeauche 1.19 fi
834 gbeauche 1.21 saved_CPPFLAGS=$CPPFLAGS
835     CPPFLAGS="$CPPFLAGS -mmmx"
836     AC_CHECK_HEADERS(mmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -mmmx"])
837     CPPFLAGS="$CPPFLAGS -msse"
838     AC_CHECK_HEADERS(xmmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse"])
839     CPPFLAGS="$CPPFLAGS -msse2"
840     AC_CHECK_HEADERS(emmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse2"])
841     CPPFLAGS=$saved_CPPFLAGS
842     ;;
843     x86_64)
844     AC_CHECK_HEADERS(mmintrin.h xmmintrin.h emmintrin.h)
845 gbeauche 1.9 ;;
846     esac
847 gbeauche 1.12 DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000"
848 gbeauche 1.9 if [[ "x$HAVE_GCC30" = "xyes" ]]; then
849     DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls"
850     fi
851     else
852     WANT_JIT=no
853     fi
854     AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine])
855     if [[ "x$WANT_JIT" = "xyes" ]]; then
856     DYNGENSRCS="\
857     ../kpx_cpu/src/cpu/jit/dyngen.c \
858     ../kpx_cpu/src/cpu/jit/cxxdemangle.cpp"
859     CPUSRCS="\
860     ../kpx_cpu/src/cpu/jit/jit-cache.cpp \
861     ../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \
862     ../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp $CPUSRCS"
863     fi
864     fi
865     CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp"
866 gbeauche 1.13 else
867     WANT_JIT=no
868 gbeauche 1.9 fi
869 gbeauche 1.10 if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then
870     AC_CACHE_CHECK([whether static data regions are executable],
871     ac_cv_have_static_data_exec, [
872     AC_TRY_RUN([int main(void) {
873     #if defined(__powerpc__)
874     static unsigned int p[8] = {0x4e800020,};
875     asm volatile("dcbst 0,%0" : : "r" (p) : "memory");
876     asm volatile("sync" : : : "memory");
877     asm volatile("icbi 0,%0" : : "r" (p) : "memory");
878     asm volatile("sync" : : : "memory");
879     asm volatile("isync" : : : "memory");
880     ((void (*)(void))p)();
881     return 0;
882     #endif
883     return 1;
884     }], ac_cv_have_static_data_exec=yes, ac_cv_have_static_data_exec=no,
885     dnl When cross-compiling, do not assume anything.
886     ac_cv_have_static_data_exec=no
887     )
888     ])
889     fi
890     AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec",
891     [Define if your system marks static data pages as executable.])
892 gbeauche 1.12
893     if [[ "x$WANT_JIT" = "xyes" ]]; then
894     CPPFLAGS="$CPPFLAGS -DUSE_JIT"
895     fi
896 gbeauche 1.9
897 cebix 1.1 dnl Generate Makefile.
898 gbeauche 1.9 AC_SUBST(DYNGENSRCS)
899 gbeauche 1.18 AC_SUBST(DYNGEN_CC)
900 gbeauche 1.9 AC_SUBST(DYNGEN_OP_FLAGS)
901 cebix 1.1 AC_SUBST(SYSSRCS)
902 gbeauche 1.9 AC_SUBST(CPUSRCS)
903 gbeauche 1.17 AC_SUBST(BLESS)
904 gbeauche 1.30 AC_SUBST(KEYCODES)
905 cebix 1.1 AC_OUTPUT(Makefile)
906    
907     dnl Print summary.
908     echo
909     echo SheepShaver configuration summary:
910     echo
911 gbeauche 1.26 echo SDL support ...................... : $SDL_SUPPORT
912 cebix 1.1 echo XFree86 DGA support .............. : $WANT_XF86_DGA
913     echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE
914 gbeauche 1.6 echo Using PowerPC emulator ........... : $EMULATED_PPC
915 gbeauche 1.9 echo Enable JIT compiler .............. : $WANT_JIT
916 gbeauche 1.5 echo Enable video on SEGV signals ..... : $WANT_VOSF
917 cebix 1.1 echo ESD sound support ................ : $WANT_ESD
918     echo GTK user interface ............... : $WANT_GTK
919     echo mon debugger support ............. : $WANT_MON
920 gbeauche 1.17 echo Bad memory access recovery type .. : $sigsegv_recovery
921 cebix 1.1 echo
922     echo "Configuration done. Now type \"make\"."