ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.15
Committed: 2005-01-19T20:26:01Z (19 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.14: +3 -1 lines
Log Message:
take care when only compiling in SDL audio support with X11 graphics

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