ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.14
Committed: 2005-01-10T22:50:54Z (19 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.13: +3 -0 lines
Log Message:
better handling of no-dyngen cases in makefiles

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