ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/configure.ac
Revision: 1.17
Committed: 2005-02-20T18:26:39Z (19 years, 7 months ago) by gbeauche
Branch: MAIN
Changes since 1.16: +8 -3 lines
Log Message:
native NetBSD/ppc support

File Contents

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