ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.6
Committed: 2004-07-10T07:38:51Z (20 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.5: +5 -1 lines
Log Message:
Use Nigel's "extfs" implementation on MacOS X

File Contents

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