ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.7
Committed: 2004-07-19T19:42:21Z (20 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.6: +14 -3 lines
Log Message:
SDL audio support

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