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.3, [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 |
AH_TOP( |
9 |
#ifndef CONFIG_H |
10 |
#define CONFIG_H |
11 |
) |
12 |
AH_BOTTOM( |
13 |
#endif /* CONFIG_H */ |
14 |
) |
15 |
|
16 |
dnl Canonical system information. |
17 |
AC_CANONICAL_HOST |
18 |
AC_CANONICAL_TARGET |
19 |
|
20 |
dnl Some systems do not put corefiles in the currect directory, avoid saving |
21 |
dnl cores for the configure tests since some are intended to dump core. |
22 |
ulimit -c 0 |
23 |
|
24 |
dnl Invite Cygwin users to build within the Windows/ directory |
25 |
case $target_os in |
26 |
*cygwin* | *mingw32*) |
27 |
AC_MSG_ERROR([You can only build the Windows version from its directory, Cygwin/X11 is not supported.]) |
28 |
;; |
29 |
esac |
30 |
|
31 |
dnl Options. |
32 |
AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes]) |
33 |
AC_ARG_ENABLE(ppc-emulator, [ --enable-ppc-emulator use the selected PowerPC emulator [default=auto]], [WANT_EMULATED_PPC=$enableval], [WANT_EMULATED_PPC=auto]) |
34 |
AC_ARG_ENABLE(fbdev-dga, [ --enable-fbdev-dga use direct frame buffer access via /dev/fb0 [default=yes]], [WANT_FBDEV_DGA=$enableval], [WANT_FBDEV_DGA=yes]) |
35 |
AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes]) |
36 |
AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=yes]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=yes]) |
37 |
AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes]) |
38 |
AC_ARG_ENABLE(standalone-gui,[ --enable-standalone-gui enable a standalone GUI prefs editor [default=no]], [WANT_STANDALONE_GUI=$enableval], [WANT_STANDALONE_GUI=no]) |
39 |
AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes]) |
40 |
AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], |
41 |
[case "$withval" in |
42 |
gtk1) WANT_GTK="gtk";; |
43 |
gtk|gtk2) WANT_GTK="$withval";; |
44 |
yes) WANT_GTK="gtk2 gtk";; |
45 |
*) WANT_GTK="no";; |
46 |
esac], |
47 |
[WANT_GTK="gtk2 gtk"]) |
48 |
AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes]) |
49 |
AC_ARG_WITH(dgcc, [ --with-dgcc=COMPILER use C++ COMPILER to compile synthetic opcodes], [DYNGEN_CC=$withval]) |
50 |
|
51 |
AC_ARG_WITH(bincue, |
52 |
AS_HELP_STRING([--with-bincue], [Allow cdrom image files in bin/cue mode])) |
53 |
|
54 |
AC_ARG_WITH(libvhd, |
55 |
AS_HELP_STRING([--with-libvhd], [Enable VHD disk images])) |
56 |
|
57 |
|
58 |
dnl Addressing mode |
59 |
AC_ARG_ENABLE(addressing, |
60 |
[ --enable-addressing=AM set the addressing mode to use [default=real]], |
61 |
[case "$enableval" in |
62 |
real) WANT_ADDRESSING_MODE="real";; |
63 |
direct) WANT_ADDRESSING_MODE="direct";; |
64 |
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'`;; |
65 |
esac], |
66 |
[WANT_ADDRESSING_MODE="real"] |
67 |
) |
68 |
|
69 |
dnl SDL options. |
70 |
AC_ARG_ENABLE(sdl-static, [ --enable-sdl-static use SDL static libraries for linking [default=no]], [WANT_SDL_STATIC=$enableval], [WANT_SDL_STATIC=no]) |
71 |
AC_ARG_ENABLE(sdl-video, [ --enable-sdl-video use SDL for video graphics [default=no]], [WANT_SDL_VIDEO=$enableval], [WANT_SDL_VIDEO=no]) |
72 |
AC_ARG_ENABLE(sdl-audio, [ --enable-sdl-audio use SDL for audio [default=no]], [WANT_SDL_AUDIO=$enableval], [WANT_SDL_AUDIO=no]) |
73 |
AC_ARG_ENABLE(sdl-framework, [ --enable-sdl-framework use SDL framework [default=no]], [WANT_SDL_FRAMEWORK=$enableval], [WANT_SDL_FRAMEWORK=no]) |
74 |
AC_ARG_ENABLE(sdl-framework-prefix, [ --enable-sdl-framework-prefix=PFX default=/Library/Frameworks], [SDL_FRAMEWORK="$enableval"], [SDL_FRAMEWORK=/Library/Frameworks]) |
75 |
|
76 |
dnl Checks for programs. |
77 |
AC_PROG_CC |
78 |
AC_PROG_CPP |
79 |
AC_PROG_CXX |
80 |
AC_PROG_MAKE_SET |
81 |
AC_PROG_INSTALL |
82 |
AC_PROG_EGREP |
83 |
AC_PATH_PROGS(FILE, [file false]) |
84 |
AC_PATH_PROG(PERL, [perl]) |
85 |
|
86 |
dnl Check for PowerPC target CPU. |
87 |
HAVE_PPC=no |
88 |
AC_MSG_CHECKING(for PowerPC target CPU) |
89 |
AC_EGREP_CPP(yes, |
90 |
[ |
91 |
#ifdef __powerpc__ |
92 |
yes |
93 |
#endif |
94 |
#ifdef __ppc__ |
95 |
yes |
96 |
#endif |
97 |
], [AC_MSG_RESULT(yes); HAVE_PPC=yes], AC_MSG_RESULT(no)) |
98 |
|
99 |
dnl We use native CPU if possible. |
100 |
EMULATED_PPC=yes |
101 |
case $WANT_EMULATED_PPC in |
102 |
auto) [[ "x$HAVE_PPC" = "xyes" ]] && EMULATED_PPC=no;; |
103 |
no) EMULATED_PPC=no;; |
104 |
esac |
105 |
if [[ "x$EMULATED_PPC" = "xyes" ]]; then |
106 |
AC_DEFINE(EMULATED_PPC, 1, [Define if using a PowerPC CPU emulator.]) |
107 |
fi |
108 |
|
109 |
dnl We use mon if possible. |
110 |
MONSRCS= |
111 |
case "x$WANT_MON" in |
112 |
x/* | x.*) |
113 |
mon_srcdir=$WANT_MON |
114 |
WANT_MON=yes |
115 |
;; |
116 |
xyes) |
117 |
mon_srcdir=../../../mon/src |
118 |
;; |
119 |
esac |
120 |
if [[ "x$WANT_MON" = "xyes" ]]; then |
121 |
AC_MSG_CHECKING(for mon) |
122 |
if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then |
123 |
AC_MSG_RESULT(yes) |
124 |
AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".]) |
125 |
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 $mon_srcdir/disass/mips-dis.c $mon_srcdir/disass/mips-opc.c $mon_srcdir/disass/mips16-opc.c" |
126 |
CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass" |
127 |
AC_CHECK_LIB(ncurses, tgetent, , |
128 |
[AC_CHECK_LIB(termcap, tgetent, , |
129 |
[AC_CHECK_LIB(termlib, tgetent, , |
130 |
[AC_CHECK_LIB(terminfo, tgetent, , |
131 |
[AC_CHECK_LIB(Hcurses, tgetent, , |
132 |
[AC_CHECK_LIB(curses, tgetent)])])])])]) |
133 |
AC_CHECK_LIB(readline, readline) |
134 |
AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h) |
135 |
else |
136 |
AC_MSG_RESULT(no) |
137 |
AC_MSG_WARN([Could not find mon, ignoring --with-mon.]) |
138 |
WANT_MON=no |
139 |
fi |
140 |
fi |
141 |
AC_SUBST(MONSRCS) |
142 |
|
143 |
dnl Checks for libraries. |
144 |
AC_CHECK_LIB(posix4, sem_init) |
145 |
AC_CHECK_LIB(m, cos) |
146 |
|
147 |
dnl AC_CHECK_SDLFRAMEWORK($1=NAME, $2=INCLUDES) |
148 |
dnl AC_TRY_LINK uses main() but SDL needs main to take args, |
149 |
dnl therefore main is undefined with #undef. |
150 |
dnl Framework can be in an custom location. |
151 |
AC_DEFUN([AC_CHECK_SDLFRAMEWORK], [ |
152 |
AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1]) |
153 |
AC_CACHE_CHECK([whether compiler supports framework $1], |
154 |
ac_Framework, [ |
155 |
saved_LIBS="$LIBS" |
156 |
LIBS="$LIBS -framework $1" |
157 |
if [[ "x$SDL_FRAMEWORK" != "x/Library/Frameworks" ]]; then |
158 |
if [[ "x$SDL_FRAMEWORK" != "x/System/Library/Frameworks" ]]; then |
159 |
LIBS="$saved_LIBS -F$SDL_FRAMEWORK -framework $1" |
160 |
fi |
161 |
fi |
162 |
saved_CPPFLAGS="$CPPFLAGS" |
163 |
CPPFLAGS="$CPPFLAGS -I$SDL_FRAMEWORK/SDL.framework/Headers" |
164 |
AC_TRY_LINK( |
165 |
[$2 |
166 |
#undef main], [], |
167 |
[AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); |
168 |
LIBS="$saved_LIBS"; CPPFLAGS="$saved_CPPFLAGS"] |
169 |
) |
170 |
]) |
171 |
AS_IF([test AS_VAR_GET(ac_Framework) = yes], |
172 |
[AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])] |
173 |
) |
174 |
AS_VAR_POPDEF([ac_Framework]) |
175 |
]) |
176 |
|
177 |
dnl Do we need SDL? |
178 |
WANT_SDL=no |
179 |
if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then |
180 |
WANT_SDL=yes |
181 |
WANT_XF86_DGA=no |
182 |
WANT_XF86_VIDMODE=no |
183 |
WANT_FBDEV_DGA=no |
184 |
SDL_SUPPORT="$SDL_SUPPORT video" |
185 |
fi |
186 |
if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then |
187 |
WANT_SDL=yes |
188 |
SDL_SUPPORT="$SDL_SUPPORT audio" |
189 |
fi |
190 |
if [[ "x$WANT_SDL" = "xyes" ]]; then |
191 |
if [[ "x$WANT_SDL_FRAMEWORK" = "xyes" ]]; then |
192 |
AC_CHECK_SDLFRAMEWORK(SDL, [#include <SDL.h>]) |
193 |
else |
194 |
ac_cv_framework_SDL=no |
195 |
fi |
196 |
if [[ "x$ac_cv_framework_SDL" = "xno" ]]; then |
197 |
AC_PATH_PROG(sdl_config, "sdl-config") |
198 |
if [[ -n "$sdl_config" ]]; then |
199 |
sdl_cflags=`$sdl_config --cflags` |
200 |
if [[ "x$WANT_SDL_STATIC" = "xyes" ]]; then |
201 |
sdl_libs=`$sdl_config --static-libs` |
202 |
else |
203 |
sdl_libs=`$sdl_config --libs` |
204 |
fi |
205 |
CFLAGS="$CFLAGS $sdl_cflags" |
206 |
CXXFLAGS="$CXXFLAGS $sdl_cflags" |
207 |
LIBS="$LIBS $sdl_libs" |
208 |
else |
209 |
WANT_SDL=no |
210 |
WANT_SDL_VIDEO=no |
211 |
WANT_SDL_AUDIO=no |
212 |
fi |
213 |
fi |
214 |
SDL_SUPPORT=`echo "$SDL_SUPPORT" | sed -e "s/^ //"` |
215 |
else |
216 |
SDL_SUPPORT="none" |
217 |
fi |
218 |
|
219 |
dnl We need X11, if not using SDL. |
220 |
if [[ "x$WANT_SDL_VIDEO" != "xyes" ]]; then |
221 |
AC_PATH_XTRA |
222 |
if [[ "x$no_x" = "xyes" ]]; then |
223 |
AC_MSG_ERROR([You need X11 to run SheepShaver.]) |
224 |
fi |
225 |
CFLAGS="$CFLAGS $X_CFLAGS" |
226 |
CXXFLAGS="$CXXFLAGS $X_CFLAGS" |
227 |
LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS" |
228 |
fi |
229 |
|
230 |
|
231 |
|
232 |
dnl We need pthreads on non-PowerPC systems. Try libpthread first, then libc_r (FreeBSD), then PTL. |
233 |
HAVE_PTHREADS=yes |
234 |
case $EMULATED_PPC:$target_os in |
235 |
no:linux*|no:netbsd*) |
236 |
dnl We do have our own pthread_cancel() implementation |
237 |
AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if you have the pthread_cancel function.]) |
238 |
;; |
239 |
*:*) |
240 |
AC_CHECK_LIB(pthread, pthread_create, , [ |
241 |
AC_CHECK_LIB(c_r, pthread_create, , [ |
242 |
AC_CHECK_LIB(PTL, pthread_create, , [ |
243 |
dnl XXX remove when no pthreads case is merged |
244 |
AC_MSG_ERROR([You need pthreads to run SheepShaver.]) |
245 |
HAVE_PTHREADS=no |
246 |
]) |
247 |
]) |
248 |
]) |
249 |
AC_CHECK_FUNCS(pthread_cancel) |
250 |
AC_CHECK_FUNCS(pthread_cond_init pthread_testcancel) |
251 |
AC_CHECK_FUNCS(pthread_mutexattr_setprotocol) |
252 |
AC_CHECK_FUNCS(pthread_mutexattr_settype) |
253 |
AC_CHECK_FUNCS(pthread_mutexattr_setpshared) |
254 |
dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes. |
255 |
SEMSRC= |
256 |
AC_CHECK_FUNCS(sem_init, , [ |
257 |
if test "x$HAVE_PTHREADS" = "xyes"; then |
258 |
SEMSRC=posix_sem.cpp |
259 |
fi |
260 |
]) |
261 |
;; |
262 |
esac |
263 |
if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then |
264 |
AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.]) |
265 |
fi |
266 |
|
267 |
dnl We use FBDev DGA if possible. |
268 |
if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then |
269 |
AC_CHECK_HEADER(linux/fb.h, [ |
270 |
AC_DEFINE(ENABLE_FBDEV_DGA, 1, [Define if using Linux fbdev extension.]) |
271 |
], [ |
272 |
AC_MSG_WARN([Could not find Linux FBDev extension, ignoring --enable-fbdev-dga.]) |
273 |
WANT_FBDEV_DGA=no |
274 |
]) |
275 |
fi |
276 |
|
277 |
dnl We use XFree86 DGA if possible. |
278 |
if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then |
279 |
AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [ |
280 |
AC_DEFINE(ENABLE_XF86_DGA, 1, [Define if using XFree86 DGA extension.]) |
281 |
LIBS="$LIBS -lXxf86dga" |
282 |
], [ |
283 |
AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.]) |
284 |
WANT_XF86_DGA=no |
285 |
]) |
286 |
fi |
287 |
|
288 |
dnl We use XFree86 VidMode if possible. |
289 |
if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then |
290 |
AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [ |
291 |
AC_DEFINE(ENABLE_XF86_VIDMODE, 1, [Define if using XFree86 DGA extension.]) |
292 |
LIBS="$LIBS -lXxf86vm" |
293 |
], [ |
294 |
AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.]) |
295 |
WANT_XF86_VIDMODE=no |
296 |
]) |
297 |
fi |
298 |
|
299 |
dnl We use GTK+ if possible. |
300 |
UISRCS=../dummy/prefs_editor_dummy.cpp |
301 |
case "x$WANT_GTK" in |
302 |
xgtk2*) |
303 |
WANT_GTK=no |
304 |
AM_PATH_GTK_2_0(1.3.15, [ |
305 |
GUI_CFLAGS="$GTK_CFLAGS" |
306 |
GUI_LIBS="$GTK_LIBS" |
307 |
WANT_GTK=gtk2 |
308 |
], [ |
309 |
case "x${WANT_GTK}x" in |
310 |
*gtkx) |
311 |
AC_MSG_WARN([Could not find GTK+ 2.0, trying with GTK+ 1.2.]) |
312 |
WANT_GTK=gtk |
313 |
;; |
314 |
*) |
315 |
AC_MSG_WARN([Could not find GTK+, disabling user interface.]) |
316 |
WANT_GTK=no |
317 |
;; |
318 |
esac |
319 |
]) |
320 |
;; |
321 |
esac |
322 |
if [[ "x$WANT_GTK" = "xgtk" ]]; then |
323 |
WANT_GTK=no |
324 |
AM_PATH_GTK(1.2.0, [ |
325 |
GUI_CFLAGS="$GTK_CFLAGS" |
326 |
GUI_LIBS="$GTK_LIBS" |
327 |
WANT_GTK=gtk |
328 |
], [ |
329 |
AC_MSG_WARN([Could not find GTK+, disabling user interface.]) |
330 |
]) |
331 |
fi |
332 |
if [[ "x$WANT_GTK" != "xno" -a "x$WANT_STANDALONE_GUI" = "xno" ]]; then |
333 |
AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.]) |
334 |
UISRCS=prefs_editor_gtk.cpp |
335 |
fi |
336 |
AC_SUBST(GUI_CFLAGS) |
337 |
AC_SUBST(GUI_LIBS) |
338 |
|
339 |
dnl Build external GUI if requested. |
340 |
if [[ "$WANT_STANDALONE_GUI" != "yes" ]]; then |
341 |
WANT_STANDALONE_GUI=no |
342 |
fi |
343 |
if [[ "$WANT_GTK" = "no" ]]; then |
344 |
WANT_STANDALONE_GUI=no |
345 |
fi |
346 |
AC_SUBST(STANDALONE_GUI, [$WANT_STANDALONE_GUI]) |
347 |
|
348 |
dnl We use ESD if possible. |
349 |
if [[ "x$WANT_ESD" = "xyes" ]]; then |
350 |
WANT_ESD=no |
351 |
AM_PATH_ESD(0.2.8, [ |
352 |
AC_DEFINE(ENABLE_ESD, 1, [Define is using ESD.]) |
353 |
CFLAGS="$CFLAGS $ESD_CFLAGS" |
354 |
CXXFLAGS="$CXXFLAGS $ESD_CFLAGS" |
355 |
LIBS="$LIBS $ESD_LIBS" |
356 |
WANT_ESD=yes |
357 |
], [ |
358 |
AC_MSG_WARN([Could not find ESD, disabling ESD support.]) |
359 |
]) |
360 |
fi |
361 |
|
362 |
dnl We use 64-bit file size support if possible. |
363 |
AC_SYS_LARGEFILE |
364 |
|
365 |
dnl Checks for header files. |
366 |
AC_HEADER_STDC |
367 |
AC_HEADER_SYS_WAIT |
368 |
AC_CHECK_HEADERS(malloc.h stdint.h) |
369 |
AC_CHECK_HEADERS(mach/vm_map.h mach/mach_init.h sys/mman.h) |
370 |
AC_CHECK_HEADERS(unistd.h fcntl.h byteswap.h dirent.h) |
371 |
AC_CHECK_HEADERS(sys/socket.h sys/ioctl.h sys/filio.h sys/bitypes.h sys/wait.h) |
372 |
AC_CHECK_HEADERS(sys/time.h sys/poll.h sys/select.h arpa/inet.h) |
373 |
AC_CHECK_HEADERS(netinet/in.h linux/if.h linux/if_tun.h net/if.h net/if_tun.h, [], [], [ |
374 |
#ifdef HAVE_SYS_TYPES_H |
375 |
#include <sys/types.h> |
376 |
#endif |
377 |
#ifdef HAVE_SYS_SOCKET_H |
378 |
#include <sys/socket.h> |
379 |
#endif |
380 |
]) |
381 |
AC_CHECK_HEADERS(AvailabilityMacros.h) |
382 |
AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDevice.h) |
383 |
AC_CHECK_HEADERS(fenv.h) |
384 |
AC_CHECK_HEADERS(sys/stropts.h stropts.h) |
385 |
|
386 |
dnl Checks for typedefs, structures, and compiler characteristics. |
387 |
AC_C_BIGENDIAN |
388 |
AC_C_CONST |
389 |
AC_C_INLINE |
390 |
AC_CHECK_SIZEOF(short, 2) |
391 |
AC_CHECK_SIZEOF(int, 4) |
392 |
AC_CHECK_SIZEOF(long, 4) |
393 |
AC_CHECK_SIZEOF(long long, 8) |
394 |
AC_CHECK_SIZEOF(float, 4) |
395 |
AC_CHECK_SIZEOF(double, 8) |
396 |
AC_CHECK_SIZEOF(void *, 4) |
397 |
AC_TYPE_OFF_T |
398 |
AC_CHECK_TYPE(loff_t, off_t) |
399 |
AC_TYPE_SIZE_T |
400 |
AC_TYPE_SIGNAL |
401 |
AC_HEADER_TIME |
402 |
AC_STRUCT_TM |
403 |
|
404 |
dnl Check whether sys/socket.h defines type socklen_t. |
405 |
dnl (extracted from ac-archive/Miscellaneous) |
406 |
AC_CACHE_CHECK([for socklen_t], |
407 |
ac_cv_type_socklen_t, [ |
408 |
AC_TRY_COMPILE([ |
409 |
#include <sys/types.h> |
410 |
#include <sys/socket.h> |
411 |
], [socklen_t len = 42; return 0;], |
412 |
ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no, |
413 |
dnl When cross-compiling, do not assume anything. |
414 |
ac_cv_type_socklen_t="guessing no" |
415 |
) |
416 |
]) |
417 |
if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then |
418 |
AC_DEFINE(socklen_t, int, [Define to 'int' if <sys/types.h> doesn't define.]) |
419 |
fi |
420 |
|
421 |
dnl Check whether struct sigaction has sa_restorer member. |
422 |
AC_CACHE_CHECK([whether struct sigaction has sa_restorer], |
423 |
ac_cv_signal_sa_restorer, [ |
424 |
AC_TRY_COMPILE([ |
425 |
#include <signal.h> |
426 |
], [struct sigaction sa; sa.sa_restorer = 0;], |
427 |
ac_cv_signal_sa_restorer=yes, ac_cv_signal_sa_restorer=no, |
428 |
dnl When cross-compiling, do not assume anything. |
429 |
ac_cv_signal_sa_restorer=no |
430 |
) |
431 |
]) |
432 |
if [[ "x$ac_cv_signal_sa_restorer" = "xyes" ]]; then |
433 |
AC_DEFINE(HAVE_SIGNAL_SA_RESTORER, 1, [Define if sa_restorer is available in struct sigaction.]) |
434 |
fi |
435 |
|
436 |
dnl Checks for library functions. |
437 |
AC_CHECK_FUNCS(strdup strerror strlcpy cfmakeraw) |
438 |
AC_CHECK_FUNCS(nanosleep) |
439 |
AC_CHECK_FUNCS(sigaction signal) |
440 |
AC_CHECK_FUNCS(mmap mprotect munmap) |
441 |
AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect) |
442 |
AC_CHECK_FUNCS(exp2f log2f exp2 log2) |
443 |
AC_CHECK_FUNCS(floorf roundf ceilf truncf floor round ceil trunc) |
444 |
AC_CHECK_FUNCS(poll inet_aton) |
445 |
|
446 |
dnl Darwin seems to define mach_task_self() instead of task_self(). |
447 |
AC_CHECK_FUNCS(mach_task_self task_self) |
448 |
|
449 |
dnl We need clock_gettime() for better performance but it may drag |
450 |
dnl libpthread in, which we don't want for native ppc mode |
451 |
case $EMULATED_PPC:$target_os in |
452 |
no:linux*) |
453 |
;; |
454 |
*:*) |
455 |
AC_SEARCH_LIBS(clock_gettime, [rt posix4]) |
456 |
AC_CHECK_FUNCS(clock_gettime clock_nanosleep) |
457 |
;; |
458 |
esac |
459 |
|
460 |
dnl Check for headers and functions related to pty support (sshpty.c) |
461 |
dnl From openssh-3.2.2p1 configure.ac |
462 |
AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h) |
463 |
AC_CHECK_FUNCS(_getpty vhangup strlcpy) |
464 |
|
465 |
case "$host" in |
466 |
*-*-hpux10.26) |
467 |
disable_ptmx_check=yes |
468 |
;; |
469 |
*-*-linux*) |
470 |
no_dev_ptmx=1 |
471 |
;; |
472 |
mips-sony-bsd|mips-sony-newsos4) |
473 |
AC_DEFINE(HAVE_NEWS4, 1, [Define if you are on NEWS-OS (additions from openssh-3.2.2p1, for sshpty.c).]) |
474 |
;; |
475 |
*-*-sco3.2v4*) |
476 |
no_dev_ptmx=1 |
477 |
;; |
478 |
*-*-sco3.2v5*) |
479 |
no_dev_ptmx=1 |
480 |
;; |
481 |
*-*-cygwin*) |
482 |
no_dev_ptmx=1 |
483 |
;; |
484 |
*-*-darwin*) |
485 |
no_dev_ptmx=1 |
486 |
;; |
487 |
esac |
488 |
|
489 |
if test -z "$no_dev_ptmx" ; then |
490 |
if test "x$disable_ptmx_check" != "xyes" ; then |
491 |
AC_CHECK_FILE([/dev/ptmx], |
492 |
[ |
493 |
AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.]) |
494 |
have_dev_ptmx=1 |
495 |
] |
496 |
) |
497 |
fi |
498 |
fi |
499 |
AC_CHECK_FILE([/dev/ptc], |
500 |
[ |
501 |
AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.]) |
502 |
have_dev_ptc=1 |
503 |
] |
504 |
) |
505 |
dnl (end of code from openssh-3.2.2p1 configure.ac) |
506 |
|
507 |
dnl Check for systems where POSIX-style non-blocking I/O (O_NONBLOCK) |
508 |
dnl doesn't work or is unimplemented. On these systems (mostly older |
509 |
dnl ones), use the old BSD-style FIONBIO approach instead. [tcl.m4] |
510 |
AC_CACHE_CHECK([FIONBIO vs. O_NONBLOCK for non-blocking I/O], |
511 |
ac_cv_nonblocking_io, [ |
512 |
case "$host" in |
513 |
*-*-osf*) |
514 |
ac_cv_nonblocking_io=FIONBIO |
515 |
;; |
516 |
*-*-sunos4*) |
517 |
ac_cv_nonblocking_io=FIONBIO |
518 |
;; |
519 |
*-*-ultrix*) |
520 |
ac_cv_nonblocking_io=FIONBIO |
521 |
;; |
522 |
*) |
523 |
ac_cv_nonblocking_io=O_NONBLOCK |
524 |
;; |
525 |
esac |
526 |
]) |
527 |
if [[ "$ac_cv_nonblocking_io" = "FIONBIO" ]]; then |
528 |
AC_DEFINE(USE_FIONBIO, 1, [Define if BSD-style non-blocking I/O is to be used]) |
529 |
fi |
530 |
|
531 |
dnl Check whether compiler supports byte bit-fields |
532 |
AC_CACHE_CHECK([whether compiler supports byte bit-fields], |
533 |
ac_cv_have_byte_bitfields, [ |
534 |
AC_LANG_SAVE |
535 |
AC_LANG_CPLUSPLUS |
536 |
AC_TRY_RUN([ |
537 |
struct A { |
538 |
unsigned char b1:4; |
539 |
unsigned char b2:4; |
540 |
unsigned char c; |
541 |
unsigned short s; |
542 |
unsigned char a[4]; |
543 |
}; |
544 |
|
545 |
int main(void) { |
546 |
A a; |
547 |
return ! (sizeof(A) == 8 && &a.c == ((unsigned char *)&a + 1)); |
548 |
}], |
549 |
[ac_cv_have_byte_bitfields=yes], |
550 |
[ac_cv_have_byte_bitfields=no], |
551 |
dnl When cross-compiling, assume only GCC supports this |
552 |
[if [[ "$GCC" = "yes" ]]; then |
553 |
ac_cv_have_byte_bitfields="guessing yes" |
554 |
else |
555 |
ac_cv_have_byte_bitfields="guessing no" |
556 |
fi] |
557 |
) |
558 |
AC_LANG_RESTORE |
559 |
]) |
560 |
|
561 |
dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES) |
562 |
AC_DEFUN([AC_CHECK_FRAMEWORK], [ |
563 |
AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl |
564 |
AC_CACHE_CHECK([whether compiler supports framework $1], |
565 |
ac_Framework, [ |
566 |
saved_LIBS="$LIBS" |
567 |
LIBS="$LIBS -framework $1" |
568 |
AC_TRY_LINK( |
569 |
[$2], [], |
570 |
[AS_VAR_SET(ac_Framework, yes)], [AS_VAR_SET(ac_Framework, no); LIBS="$saved_LIBS"] |
571 |
) |
572 |
]) |
573 |
AS_IF([test AS_VAR_GET(ac_Framework) = yes], |
574 |
[AC_DEFINE(AS_TR_CPP(HAVE_FRAMEWORK_$1), 1, [Define if framework $1 is available.])] |
575 |
) |
576 |
AS_VAR_POPDEF([ac_Framework])dnl |
577 |
]) |
578 |
|
579 |
dnl Check for some MacOS X frameworks |
580 |
AC_CHECK_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>]) |
581 |
AC_CHECK_FRAMEWORK(IOKit, [#include <IOKit/IOKitLib.h>]) |
582 |
AC_CHECK_FRAMEWORK(CoreFoundation, [#include <CoreFoundation/CoreFoundation.h>]) |
583 |
AC_CHECK_FRAMEWORK(CoreAudio, [#include <CoreAudio/CoreAudio.h>]) |
584 |
AC_CHECK_FRAMEWORK(AudioUnit, [#include <AudioUnit/AudioUnit.h>]) |
585 |
AC_CHECK_FRAMEWORK(AudioToolbox, [#include <AudioToolbox/AudioToolbox.h>]) |
586 |
AC_CHECK_FRAMEWORK(AppKit, []) |
587 |
|
588 |
dnl Select system-dependant sources. |
589 |
SERIALSRC=serial_unix.cpp |
590 |
ETHERSRC=../dummy/ether_dummy.cpp |
591 |
SCSISRC=../dummy/scsi_dummy.cpp |
592 |
AUDIOSRC=../dummy/audio_dummy.cpp |
593 |
PREFSSRC=../dummy/prefs_dummy.cpp |
594 |
EXTFSSRC=extfs_unix.cpp |
595 |
EXTRASYSSRCS= |
596 |
case "$target_os" in |
597 |
linux*) |
598 |
ETHERSRC=ether_unix.cpp |
599 |
AUDIOSRC=audio_oss_esd.cpp |
600 |
SCSISRC=Linux/scsi_linux.cpp |
601 |
if [[ "x$EMULATED_PPC" = "xno" ]]; then |
602 |
EXTRASYSSRCS="paranoia.cpp Linux/sheepthreads.c ppc_asm.S" |
603 |
fi |
604 |
;; |
605 |
freebsd*) |
606 |
ETHERSRC=ether_unix.cpp |
607 |
;; |
608 |
netbsd*) |
609 |
ETHERSRC=ether_unix.cpp |
610 |
if [[ "x$EMULATED_PPC" = "xno" ]]; then |
611 |
EXTRASYSSRCS="paranoia.cpp NetBSD/sheepthreads.c ppc_asm.S" |
612 |
fi |
613 |
;; |
614 |
darwin*) |
615 |
ETHERSRC=ether_unix.cpp |
616 |
if [[ "x$EMULATED_PPC" = "xno" ]]; then |
617 |
EXTRASYSSRCS="paranoia.cpp ppc_asm.S" |
618 |
fi |
619 |
if [[ "x$ac_cv_framework_IOKit" = "xyes" -a "x$ac_cv_framework_CoreFoundation" = "xyes" ]]; then |
620 |
EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/sys_darwin.cpp" |
621 |
fi |
622 |
if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then |
623 |
EXTFSSRC=../MacOSX/extfs_macosx.cpp |
624 |
if [[ "x$ac_cv_framework_AppKit" = "xyes" -a "x$WANT_GTK" = "xno" ]]; then |
625 |
PREFSSRC="../MacOSX/prefs_macosx.mm ../MacOSX/Launcher/VMSettingsController.mm" |
626 |
CPPFLAGS="$CPPFLAGS -I../MacOSX/Launcher" |
627 |
fi |
628 |
fi |
629 |
if [[ "x$WANT_ESD" = "xno" -a "x$ac_cv_framework_CoreAudio" = "xyes" -a "x$WANT_SDL_AUDIO" = "xno" ]]; then |
630 |
AUDIOSRC="../MacOSX/audio_macosx.cpp ../MacOSX/AudioBackEnd.cpp ../MacOSX/AudioDevice.cpp ../MacOSX/MacOSX_sound_if.cpp" |
631 |
OSX_CORE_AUDIO="-DOSX_CORE_AUDIO" |
632 |
fi |
633 |
;; |
634 |
irix*) |
635 |
AUDIOSRC=Irix/audio_irix.cpp |
636 |
LIBS="$LIBS -laudio" |
637 |
WANT_ESD=no |
638 |
|
639 |
dnl Check if our compiler supports -IPA (MIPSPro) |
640 |
HAVE_IPA=no |
641 |
ocflags="$CFLAGS" |
642 |
CFLAGS=`echo " $CFLAGS -IPA" | sed -e "s/ -g //g"` |
643 |
AC_MSG_CHECKING(if "-IPA" works) |
644 |
dnl Do a test compile of an empty function |
645 |
AC_TRY_COMPILE([#if defined __GNUC__ |
646 |
# error GCC does not support IPA yet |
647 |
#endif],, [AC_MSG_RESULT(yes); HAVE_IPA=yes], AC_MSG_RESULT(no)) |
648 |
CFLAGS="$ocflags" |
649 |
;; |
650 |
esac |
651 |
|
652 |
dnl BINCUE |
653 |
AS_IF([test "x$with_bincue" = "xyes" ], [have_bincue=yes], [have_bincue=no]) |
654 |
AS_IF([test "x$have_bincue" = "xyes" ], [ |
655 |
if [[ "xOSX_CORE_AUDIO" = "xno" -a "x$WANT_SDL_AUDIO"="xno"]]; then |
656 |
AC_MSG_ERROR([You need SDL or OSX Core Audio to use BINCUE support.]) |
657 |
else |
658 |
CPPFLAGS="$CPPFLAGS -DBINCUE $OSX_CORE_AUDIO" |
659 |
fi |
660 |
]) |
661 |
|
662 |
dnl LIBVHD |
663 |
AS_IF([test "x$with_libvhd" = "xyes" ], [have_libvhd=yes], [have_libvhd=no]) |
664 |
AS_IF([test "x$have_libvhd" = "xyes" ], [ |
665 |
CPPFLAGS="$CPPFLAGS -DHAVE_LIBVHD" |
666 |
LIBS="$LIBS -lvhd" |
667 |
case $target_os in |
668 |
linux*) |
669 |
LIBS="$LIBS -luuid" |
670 |
esac |
671 |
AC_CHECK_LIB(vhd, vhd_open) |
672 |
AC_CHECK_LIB(vhd, vhd_io_read) |
673 |
AC_CHECK_LIB(vhd, vhd_io_write) |
674 |
AC_CHECK_LIB(vhd, vhd_close) |
675 |
]) |
676 |
|
677 |
|
678 |
|
679 |
|
680 |
dnl Is the slirp library supported? |
681 |
case "$ac_cv_have_byte_bitfields" in |
682 |
yes|"guessing yes") |
683 |
CAN_SLIRP=yes |
684 |
ETHERSRC=ether_unix.cpp |
685 |
;; |
686 |
esac |
687 |
if [[ -n "$CAN_SLIRP" ]]; then |
688 |
AC_DEFINE(HAVE_SLIRP, 1, [Define if slirp library is supported]) |
689 |
SLIRP_SRCS="\ |
690 |
../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \ |
691 |
../slirp/cksum.c ../slirp/mbuf.c ../slirp/tcp_output.c \ |
692 |
../slirp/debug.c ../slirp/misc.c ../slirp/tcp_subr.c \ |
693 |
../slirp/if.c ../slirp/sbuf.c ../slirp/tcp_timer.c \ |
694 |
../slirp/ip_icmp.c ../slirp/slirp.c ../slirp/tftp.c \ |
695 |
../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c" |
696 |
fi |
697 |
AC_SUBST(SLIRP_SRCS) |
698 |
|
699 |
dnl SDL overrides |
700 |
if [[ "x$WANT_SDL" = "xyes" ]]; then |
701 |
AC_DEFINE(USE_SDL, 1, [Define to enble SDL support.]) |
702 |
if [[ "x$WANT_SDL_FRAMEWORK" = "xyes" ]]; then |
703 |
EXTRASYSSRCS="$EXTRASYSSRCS ../SDL/SDLMain.m" |
704 |
fi |
705 |
fi |
706 |
if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then |
707 |
AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support.]) |
708 |
VIDEOSRCS="../SDL/video_sdl.cpp" |
709 |
KEYCODES="../SDL/keycodes" |
710 |
if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then |
711 |
EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp" |
712 |
EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/utils_macosx.mm" |
713 |
CPPFLAGS="$CPPFLAGS -I../MacOSX" |
714 |
else |
715 |
EXTRASYSSRCS="$EXTRASYSSRCS ../dummy/clip_dummy.cpp" |
716 |
fi |
717 |
else |
718 |
VIDEOSRCS="video_x.cpp" |
719 |
KEYCODES="keycodes" |
720 |
EXTRASYSSRCS="$EXTRASYSSRCS clip_unix.cpp" |
721 |
fi |
722 |
if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then |
723 |
AC_DEFINE(USE_SDL_AUDIO, 1, [Define to enable SDL audio support]) |
724 |
AUDIOSRC="../SDL/audio_sdl.cpp" |
725 |
fi |
726 |
|
727 |
dnl BINCUE overrides |
728 |
|
729 |
if [[ "x$have_bincue" = "xyes" ]]; then |
730 |
EXTRASYSSRCS="$EXTRASYSSRCS bincue_unix.cpp" |
731 |
fi |
732 |
|
733 |
dnl libvhd overrides |
734 |
|
735 |
if [[ "x$have_libvhd" = "xyes" ]]; then |
736 |
EXTRASYSSRCS="$EXTRASYSSRCS vhd_unix.cpp" |
737 |
fi |
738 |
|
739 |
|
740 |
SYSSRCS="$VIDEOSRCS $EXTFSSRC $PREFSSRC $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $EXTRASYSSRCS" |
741 |
|
742 |
dnl Define a macro that translates a yesno-variable into a C macro definition |
743 |
dnl to be put into the config.h file |
744 |
dnl $1 -- the macro to define |
745 |
dnl $2 -- the value to translate |
746 |
dnl $3 -- template name |
747 |
AC_DEFUN([AC_TRANSLATE_DEFINE], [ |
748 |
if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then |
749 |
AC_DEFINE($1, 1, $3) |
750 |
fi |
751 |
]) |
752 |
|
753 |
dnl Check that the host supports TUN/TAP devices |
754 |
AC_CACHE_CHECK([whether TUN/TAP is supported], |
755 |
ac_cv_tun_tap_support, [ |
756 |
AC_TRY_COMPILE([ |
757 |
#if defined(HAVE_NETINET_IN_H) |
758 |
#include <netinet/in.h> |
759 |
#endif |
760 |
#if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H) |
761 |
#include <linux/if.h> |
762 |
#include <linux/if_tun.h> |
763 |
#endif |
764 |
#if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H) |
765 |
#include <net/if.h> |
766 |
#include <net/if_tun.h> |
767 |
#endif |
768 |
], [ |
769 |
struct ifreq ifr; |
770 |
memset(&ifr, 0, sizeof(ifr)); |
771 |
ifr.ifr_flags = IFF_TAP | IFF_NO_PI; |
772 |
], |
773 |
ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no |
774 |
) |
775 |
]) |
776 |
AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support", |
777 |
[Define if your system supports TUN/TAP devices.]) |
778 |
|
779 |
dnl Various checks if the system supports vm_allocate() and the like functions. |
780 |
have_mach_vm=no |
781 |
if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \ |
782 |
"x$ac_cv_func_vm_protect" = "xyes" ]]; then |
783 |
have_mach_vm=yes |
784 |
fi |
785 |
AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm", |
786 |
[Define if your system has a working vm_allocate()-based memory allocator.]) |
787 |
|
788 |
dnl Check that vm_allocate(), vm_protect() work |
789 |
if [[ "x$have_mach_vm" = "xyes" ]]; then |
790 |
|
791 |
AC_CACHE_CHECK([whether vm_protect works], |
792 |
ac_cv_vm_protect_works, [ |
793 |
AC_LANG_SAVE |
794 |
AC_LANG_CPLUSPLUS |
795 |
ac_cv_vm_protect_works=yes |
796 |
dnl First the tests that should segfault |
797 |
for test_def in NONE_READ NONE_WRITE READ_WRITE; do |
798 |
AC_TRY_RUN([ |
799 |
#define CONFIGURE_TEST_VM_MAP |
800 |
#define TEST_VM_PROT_$test_def |
801 |
#include "vm_alloc.cpp" |
802 |
], ac_cv_vm_protect_works=no, rm -f core, |
803 |
dnl When cross-compiling, do not assume anything |
804 |
ac_cv_vm_protect_works="guessing no" |
805 |
) |
806 |
done |
807 |
AC_TRY_RUN([ |
808 |
#define CONFIGURE_TEST_VM_MAP |
809 |
#define TEST_VM_PROT_RDWR_WRITE |
810 |
#include "vm_alloc.cpp" |
811 |
], , ac_cv_vm_protect_works=no, |
812 |
dnl When cross-compiling, do not assume anything |
813 |
ac_cv_vm_protect_works="guessing no" |
814 |
) |
815 |
AC_LANG_RESTORE |
816 |
] |
817 |
) |
818 |
|
819 |
dnl Remove support for vm_allocate() if vm_protect() does not work |
820 |
if [[ "x$have_mach_vm" = "xyes" ]]; then |
821 |
case $ac_cv_vm_protect_works in |
822 |
*yes) have_mach_vm=yes;; |
823 |
*no) have_mach_vm=no;; |
824 |
esac |
825 |
fi |
826 |
AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm", |
827 |
[Define if your system has a working vm_allocate()-based memory allocator.]) |
828 |
|
829 |
fi dnl HAVE_MACH_VM |
830 |
|
831 |
dnl Various checks if the system supports mmap() and the like functions. |
832 |
dnl ... and Mach memory allocators are not supported |
833 |
have_mmap_vm=no |
834 |
if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \ |
835 |
"x$ac_cv_func_mprotect" = "xyes" ]]; then |
836 |
if [[ "x$have_mach_vm" = "xno" ]]; then |
837 |
have_mmap_vm=yes |
838 |
fi |
839 |
fi |
840 |
AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm", |
841 |
[Define if your system has a working mmap()-based memory allocator.]) |
842 |
|
843 |
dnl Check that mmap() and associated functions work. |
844 |
if [[ "x$have_mmap_vm" = "xyes" ]]; then |
845 |
|
846 |
dnl Check if we have a working anonymous mmap() |
847 |
AC_CACHE_CHECK([whether mmap supports MAP_ANON], |
848 |
ac_cv_mmap_anon, [ |
849 |
AC_LANG_SAVE |
850 |
AC_LANG_CPLUSPLUS |
851 |
AC_TRY_RUN([ |
852 |
#define HAVE_MMAP_ANON |
853 |
#define CONFIGURE_TEST_VM_MAP |
854 |
#define TEST_VM_MMAP_ANON |
855 |
#include "vm_alloc.cpp" |
856 |
], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no, |
857 |
dnl When cross-compiling, do not assume anything. |
858 |
ac_cv_mmap_anon="guessing no" |
859 |
) |
860 |
AC_LANG_RESTORE |
861 |
] |
862 |
) |
863 |
AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon", |
864 |
[Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.]) |
865 |
|
866 |
AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS], |
867 |
ac_cv_mmap_anonymous, [ |
868 |
AC_LANG_SAVE |
869 |
AC_LANG_CPLUSPLUS |
870 |
AC_TRY_RUN([ |
871 |
#define HAVE_MMAP_ANONYMOUS |
872 |
#define CONFIGURE_TEST_VM_MAP |
873 |
#define TEST_VM_MMAP_ANON |
874 |
#include "vm_alloc.cpp" |
875 |
], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no, |
876 |
dnl When cross-compiling, do not assume anything. |
877 |
ac_cv_mmap_anonymous="guessing no" |
878 |
) |
879 |
AC_LANG_RESTORE |
880 |
] |
881 |
) |
882 |
AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous", |
883 |
[Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.]) |
884 |
|
885 |
AC_CACHE_CHECK([whether mprotect works], |
886 |
ac_cv_mprotect_works, [ |
887 |
AC_LANG_SAVE |
888 |
AC_LANG_CPLUSPLUS |
889 |
ac_cv_mprotect_works=yes |
890 |
dnl First the tests that should segfault |
891 |
for test_def in NONE_READ NONE_WRITE READ_WRITE; do |
892 |
AC_TRY_RUN([ |
893 |
#define CONFIGURE_TEST_VM_MAP |
894 |
#define TEST_VM_PROT_$test_def |
895 |
#include "vm_alloc.cpp" |
896 |
], ac_cv_mprotect_works=no, rm -f core, |
897 |
dnl When cross-compiling, do not assume anything |
898 |
ac_cv_mprotect_works="guessing no" |
899 |
) |
900 |
done |
901 |
AC_TRY_RUN([ |
902 |
#define CONFIGURE_TEST_VM_MAP |
903 |
#define TEST_VM_PROT_RDWR_WRITE |
904 |
#include "vm_alloc.cpp" |
905 |
], , ac_cv_mprotect_works=no, |
906 |
dnl When cross-compiling, do not assume anything |
907 |
ac_cv_mprotect_works="guessing no" |
908 |
) |
909 |
AC_LANG_RESTORE |
910 |
] |
911 |
) |
912 |
|
913 |
dnl Remove support for mmap() if mprotect() does not work |
914 |
if [[ "x$have_mmap_vm" = "xyes" ]]; then |
915 |
case $ac_cv_mprotect_works in |
916 |
*yes) have_mmap_vm=yes;; |
917 |
*no) have_mmap_vm=no;; |
918 |
esac |
919 |
fi |
920 |
AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm, |
921 |
[Define if your system has a working mmap()-based memory allocator.]) |
922 |
|
923 |
fi dnl HAVE_MMAP_VM |
924 |
|
925 |
dnl Check if we can modify the __PAGEZERO segment for use as Low Memory |
926 |
AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000], |
927 |
ac_cv_pagezero_hack, [ |
928 |
ac_cv_pagezero_hack=no |
929 |
if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then |
930 |
ac_cv_pagezero_hack=yes |
931 |
dnl might as well skip the test for mmap-able low memory |
932 |
ac_cv_can_map_lm=no |
933 |
fi |
934 |
]) |
935 |
AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack", |
936 |
[Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.]) |
937 |
|
938 |
dnl Check if we can mmap 0x3000 bytes from 0x0000 |
939 |
AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000], |
940 |
ac_cv_can_map_lm, [ |
941 |
AC_LANG_SAVE |
942 |
AC_LANG_CPLUSPLUS |
943 |
AC_TRY_RUN([ |
944 |
#include "vm_alloc.cpp" |
945 |
int main(void) { /* returns 0 if we could map the lowmem globals */ |
946 |
volatile char * lm = 0; |
947 |
if (vm_init() < 0) exit(1); |
948 |
if (vm_acquire_fixed(0, 0x2000) < 0) exit(1); |
949 |
lm[0] = 'z'; |
950 |
if (vm_release((char *)lm, 0x2000) < 0) exit(1); |
951 |
vm_exit(); exit(0); |
952 |
} |
953 |
], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no, |
954 |
dnl When cross-compiling, do not assume anything. |
955 |
ac_cv_can_map_lm="guessing no" |
956 |
) |
957 |
AC_LANG_RESTORE |
958 |
] |
959 |
) |
960 |
|
961 |
dnl Check signal handlers need to be reinstalled |
962 |
AC_CACHE_CHECK([whether signal handlers need to be reinstalled], |
963 |
ac_cv_signal_need_reinstall, [ |
964 |
AC_LANG_SAVE |
965 |
AC_LANG_CPLUSPLUS |
966 |
AC_TRY_RUN([ |
967 |
#include <stdlib.h> |
968 |
#ifdef HAVE_UNISTD_H |
969 |
#include <unistd.h> |
970 |
#endif |
971 |
#include <signal.h> |
972 |
static int handled_signal = 0; |
973 |
RETSIGTYPE sigusr1_handler(int) { handled_signal++; } |
974 |
int main(void) { /* returns 0 if signals need not to be reinstalled */ |
975 |
signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1); |
976 |
exit(handled_signal == 2); |
977 |
} |
978 |
], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no, |
979 |
dnl When cross-compiling, do not assume anything. |
980 |
ac_cv_signal_need_reinstall="guessing yes" |
981 |
) |
982 |
AC_LANG_RESTORE |
983 |
] |
984 |
) |
985 |
AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall", |
986 |
[Define if your system requires signals to be reinstalled.]) |
987 |
|
988 |
dnl Check if sigaction handlers need to be reinstalled |
989 |
AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled], |
990 |
ac_cv_sigaction_need_reinstall, [ |
991 |
AC_LANG_SAVE |
992 |
AC_LANG_CPLUSPLUS |
993 |
AC_TRY_RUN([ |
994 |
#include <stdlib.h> |
995 |
#ifdef HAVE_UNISTD_H |
996 |
#include <unistd.h> |
997 |
#endif |
998 |
#include <signal.h> |
999 |
static int handled_signal = 0; |
1000 |
RETSIGTYPE sigusr1_handler(int) { handled_signal++; } |
1001 |
typedef RETSIGTYPE (*signal_handler)(int); |
1002 |
static signal_handler mysignal(int sig, signal_handler handler) { |
1003 |
struct sigaction old_sa; |
1004 |
struct sigaction new_sa; |
1005 |
new_sa.sa_handler = handler; |
1006 |
return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler); |
1007 |
} |
1008 |
int main(void) { /* returns 0 if signals need not to be reinstalled */ |
1009 |
mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1); |
1010 |
exit(handled_signal == 2); |
1011 |
} |
1012 |
], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no, |
1013 |
dnl When cross-compiling, do not assume anything. |
1014 |
ac_cv_sigaction_need_reinstall="guessing yes" |
1015 |
) |
1016 |
AC_LANG_RESTORE |
1017 |
] |
1018 |
) |
1019 |
AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall", |
1020 |
[Define if your system requires sigactions to be reinstalled.]) |
1021 |
|
1022 |
dnl Check if Mach exceptions supported. |
1023 |
AC_CACHE_CHECK([whether your system supports Mach exceptions], |
1024 |
ac_cv_have_mach_exceptions, [ |
1025 |
AC_LANG_SAVE |
1026 |
AC_LANG_CPLUSPLUS |
1027 |
AC_TRY_RUN([ |
1028 |
#define HAVE_MACH_EXCEPTIONS 1 |
1029 |
#define CONFIGURE_TEST_SIGSEGV_RECOVERY |
1030 |
#include "vm_alloc.cpp" |
1031 |
#include "sigsegv.cpp" |
1032 |
], |
1033 |
ac_cv_have_mach_exceptions=yes, |
1034 |
ac_cv_have_mach_exceptions=no, |
1035 |
dnl When cross-compiling, do not assume anything. |
1036 |
ac_cv_have_mach_exceptions=no |
1037 |
) |
1038 |
AC_LANG_RESTORE |
1039 |
] |
1040 |
) |
1041 |
if [[ "$ac_cv_have_mach_exceptions" = "yes" ]]; then |
1042 |
sigsegv_recovery=mach |
1043 |
fi |
1044 |
AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions", |
1045 |
[Define if your system supports Mach exceptions.]) |
1046 |
|
1047 |
dnl Check if Windows exceptions are supported. |
1048 |
AC_CACHE_CHECK([whether your system supports Windows exceptions], |
1049 |
ac_cv_have_win32_exceptions, [ |
1050 |
AC_LANG_SAVE |
1051 |
AC_LANG_CPLUSPLUS |
1052 |
AC_TRY_RUN([ |
1053 |
#define HAVE_WIN32_EXCEPTIONS 1 |
1054 |
#define CONFIGURE_TEST_SIGSEGV_RECOVERY |
1055 |
#include "vm_alloc.cpp" |
1056 |
#include "sigsegv.cpp" |
1057 |
], [ |
1058 |
sigsegv_recovery=win32 |
1059 |
ac_cv_have_win32_exceptions=yes |
1060 |
], |
1061 |
ac_cv_have_win32_exceptions=no, |
1062 |
dnl When cross-compiling, do not assume anything. |
1063 |
ac_cv_have_win32_exceptions=no |
1064 |
) |
1065 |
AC_LANG_RESTORE |
1066 |
] |
1067 |
) |
1068 |
AC_TRANSLATE_DEFINE(HAVE_WIN32_EXCEPTIONS, "$ac_cv_have_win32_exceptions", |
1069 |
[Define if your system supports Windows exceptions.]) |
1070 |
|
1071 |
dnl Otherwise, check if extended signals are supported. |
1072 |
if [[ -z "$sigsegv_recovery" ]]; then |
1073 |
AC_CACHE_CHECK([whether your system supports extended signal handlers], |
1074 |
ac_cv_have_extended_signals, [ |
1075 |
AC_LANG_SAVE |
1076 |
AC_LANG_CPLUSPLUS |
1077 |
AC_TRY_RUN([ |
1078 |
#define HAVE_SIGINFO_T 1 |
1079 |
#define CONFIGURE_TEST_SIGSEGV_RECOVERY |
1080 |
#include "vm_alloc.cpp" |
1081 |
#include "sigsegv.cpp" |
1082 |
], |
1083 |
ac_cv_have_extended_signals=yes, |
1084 |
ac_cv_have_extended_signals=no, |
1085 |
dnl When cross-compiling, do not assume anything. |
1086 |
ac_cv_have_extended_signals=no |
1087 |
) |
1088 |
AC_LANG_RESTORE |
1089 |
] |
1090 |
) |
1091 |
if [[ "$ac_cv_have_extended_signals" = "yes" ]]; then |
1092 |
sigsegv_recovery=siginfo |
1093 |
fi |
1094 |
AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals", |
1095 |
[Define if your system support extended signals.]) |
1096 |
fi |
1097 |
|
1098 |
dnl Otherwise, check for subterfuges. |
1099 |
if [[ -z "$sigsegv_recovery" ]]; then |
1100 |
AC_CACHE_CHECK([whether we then have a subterfuge for your system], |
1101 |
ac_cv_have_sigcontext_hack, [ |
1102 |
AC_LANG_SAVE |
1103 |
AC_LANG_CPLUSPLUS |
1104 |
AC_TRY_RUN([ |
1105 |
#define HAVE_SIGCONTEXT_SUBTERFUGE 1 |
1106 |
#define CONFIGURE_TEST_SIGSEGV_RECOVERY |
1107 |
#include "vm_alloc.cpp" |
1108 |
#include "sigsegv.cpp" |
1109 |
], |
1110 |
ac_cv_have_sigcontext_hack=yes, |
1111 |
ac_cv_have_sigcontext_hack=no, |
1112 |
dnl When cross-compiling, do not assume anything. |
1113 |
ac_cv_have_sigcontext_hack=no |
1114 |
) |
1115 |
AC_LANG_RESTORE |
1116 |
]) |
1117 |
if [[ "$ac_cv_have_sigcontext_hack" = "yes" ]]; then |
1118 |
sigsegv_recovery=sigcontext |
1119 |
fi |
1120 |
AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack", |
1121 |
[Define if we know a hack to replace siginfo_t->si_addr member.]) |
1122 |
fi |
1123 |
|
1124 |
dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler) |
1125 |
AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler], |
1126 |
ac_cv_have_skip_instruction, [ |
1127 |
AC_LANG_SAVE |
1128 |
AC_LANG_CPLUSPLUS |
1129 |
AC_TRY_RUN([ |
1130 |
#define HAVE_SIGSEGV_SKIP_INSTRUCTION 1 |
1131 |
#define CONFIGURE_TEST_SIGSEGV_RECOVERY |
1132 |
#include "vm_alloc.cpp" |
1133 |
#include "sigsegv.cpp" |
1134 |
], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no, |
1135 |
dnl When cross-compiling, do not assume anything. |
1136 |
ac_cv_have_skip_instruction=no |
1137 |
) |
1138 |
AC_LANG_RESTORE |
1139 |
] |
1140 |
) |
1141 |
AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction", |
1142 |
[Define if we can ignore the fault (instruction skipping in SIGSEGV handler).]) |
1143 |
|
1144 |
dnl Can we do Video on SEGV Signals ? |
1145 |
CAN_VOSF=no |
1146 |
if [[ -n "$sigsegv_recovery" ]]; then |
1147 |
CAN_VOSF=yes |
1148 |
fi |
1149 |
|
1150 |
dnl Enable VOSF screen updates with this feature is requested and feasible |
1151 |
if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then |
1152 |
AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.]) |
1153 |
else |
1154 |
WANT_VOSF=no |
1155 |
fi |
1156 |
|
1157 |
dnl Check addressing mode to use |
1158 |
AC_MSG_CHECKING([for addressing mode to use]) |
1159 |
if [[ "$EMULATED_PPC" != "yes" ]]; then |
1160 |
if [[ "$WANT_ADDRESSING_MODE" != "real" ]]; then |
1161 |
AC_MSG_WARN([Running in native PowerPC mode, force use of Real Addressing.]) |
1162 |
WANT_ADDRESSING_MODE="real" |
1163 |
fi |
1164 |
fi |
1165 |
if [[ "$WANT_ADDRESSING_MODE" = "direct" ]]; then |
1166 |
if [[ -n "$NATMEM_OFFSET" ]]; then |
1167 |
NATMEM_OFFSET_DEF="-DNATMEM_OFFSET=$NATMEM_OFFSET" |
1168 |
fi |
1169 |
AC_LANG_SAVE |
1170 |
AC_LANG_CPLUSPLUS |
1171 |
cat confdefs.h > conftest.$ac_ext |
1172 |
cat >> conftest.$ac_ext << EOF |
1173 |
#include <stdio.h> |
1174 |
#include <string.h> |
1175 |
#include "vm_alloc.cpp" |
1176 |
|
1177 |
int main(void) |
1178 |
{ |
1179 |
if (vm_init() < 0) |
1180 |
return 1; |
1181 |
|
1182 |
static const struct { |
1183 |
unsigned long base; |
1184 |
unsigned int size; |
1185 |
} ranges[[]] = { |
1186 |
{ 0x00000000, 0x0003000 }, |
1187 |
{ 0x10000000, 0x2000000 }, |
1188 |
{ 0x40800000, 0x0400000 }, |
1189 |
{ 0x68070000, 0x0010000 }, |
1190 |
{ 0x69000000, 0x0080000 }, |
1191 |
{ 0x68ffe000, 0x0002000 }, |
1192 |
{ 0x5fffe000, 0x0002000 }, |
1193 |
{ 0x60000000, 0x0040000 }, |
1194 |
}; |
1195 |
const int n_ranges = sizeof(ranges)/ sizeof(ranges[[0]]); |
1196 |
|
1197 |
#ifdef NATMEM_OFFSET |
1198 |
unsigned long ofs = NATMEM_OFFSET; |
1199 |
#else |
1200 |
for (unsigned long ofs = 0x10000000; ofs <= 0x90000000; ofs += 0x10000000) |
1201 |
#endif |
1202 |
for (int i = 0; i < n_ranges; i++) { |
1203 |
char *m = (char *)(ranges[[i]].base + ofs); |
1204 |
if (vm_acquire_fixed(m, ranges[[i]].size) != 0) |
1205 |
break; |
1206 |
memset(m, 0, ranges[[i]].size); |
1207 |
vm_release(m, ranges[[i]].size); |
1208 |
if (i == n_ranges - 1) { |
1209 |
if (sizeof(void *) == 8 && ofs > 0xffffffff) |
1210 |
printf("0x%lxul\n", ofs); |
1211 |
else |
1212 |
printf("0x%08x\n", ofs); |
1213 |
return 0; |
1214 |
} |
1215 |
} |
1216 |
|
1217 |
vm_exit(); |
1218 |
return 1; |
1219 |
} |
1220 |
EOF |
1221 |
doit='$CXX conftest.$ac_ext -o conftest.$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS $NATMEM_OFFSET_DEF >& AS_MESSAGE_LOG_FD' |
1222 |
if AC_TRY_EVAL(doit); then |
1223 |
NATMEM_OFFSET=`./conftest.$ac_exeext` |
1224 |
else |
1225 |
NATMEM_OFFSET= |
1226 |
fi |
1227 |
rm -f conftest* |
1228 |
AC_LANG_RESTORE |
1229 |
|
1230 |
if [[ -z "$NATMEM_OFFSET" ]]; then |
1231 |
AC_MSG_ERROR([could not determine a sensible NATMEM_OFFSET value]) |
1232 |
else |
1233 |
WANT_ADDRESSING_MODE="direct,$NATMEM_OFFSET" |
1234 |
AC_DEFINE_UNQUOTED(NATMEM_OFFSET, $NATMEM_OFFSET, |
1235 |
[Define constant offset for Mac address translation]) |
1236 |
fi |
1237 |
fi |
1238 |
AC_MSG_RESULT($WANT_ADDRESSING_MODE) |
1239 |
|
1240 |
dnl Utility macro used by next two tests. |
1241 |
dnl AC_EXAMINE_OBJECT(C source code, |
1242 |
dnl commands examining object file, |
1243 |
dnl [commands to run if compile failed]): |
1244 |
dnl |
1245 |
dnl Compile the source code to an object file; then convert it into a |
1246 |
dnl printable representation. All unprintable characters and |
1247 |
dnl asterisks (*) are replaced by dots (.). All white space is |
1248 |
dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the |
1249 |
dnl output, but runs of newlines are compressed to a single newline. |
1250 |
dnl Finally, line breaks are forcibly inserted so that no line is |
1251 |
dnl longer than 80 columns and the file ends with a newline. The |
1252 |
dnl result of all this processing is in the file conftest.dmp, which |
1253 |
dnl may be examined by the commands in the second argument. |
1254 |
dnl |
1255 |
AC_DEFUN([gcc_AC_EXAMINE_OBJECT], |
1256 |
[AC_LANG_SAVE |
1257 |
AC_LANG_C |
1258 |
dnl Next bit cribbed from AC_TRY_COMPILE. |
1259 |
cat > conftest.$ac_ext <<EOF |
1260 |
[#line __oline__ "configure" |
1261 |
#include "confdefs.h" |
1262 |
$1 |
1263 |
]EOF |
1264 |
if AC_TRY_EVAL(ac_compile); then |
1265 |
od -c conftest.o | |
1266 |
sed ['s/^[0-7]*[ ]*/ / |
1267 |
s/\*/./g |
1268 |
s/ \\n/*/g |
1269 |
s/ [0-9][0-9][0-9]/./g |
1270 |
s/ \\[^ ]/./g'] | |
1271 |
tr -d ' |
1272 |
' | tr -s '*' ' |
1273 |
' | fold | sed '$a\ |
1274 |
' > conftest.dmp |
1275 |
$2 |
1276 |
ifelse($3, , , else |
1277 |
$3 |
1278 |
)dnl |
1279 |
fi |
1280 |
rm -rf conftest* |
1281 |
AC_LANG_RESTORE]) |
1282 |
|
1283 |
dnl Floating point format probe. |
1284 |
dnl The basic concept is the same as the above: grep the object |
1285 |
dnl file for an interesting string. We have to watch out for |
1286 |
dnl rounding changing the values in the object, however; this is |
1287 |
dnl handled by ignoring the least significant byte of the float. |
1288 |
dnl |
1289 |
dnl Does not know about VAX G-float or C4x idiosyncratic format. |
1290 |
dnl It does know about PDP-10 idiosyncratic format, but this is |
1291 |
dnl not presently supported by GCC. S/390 "binary floating point" |
1292 |
dnl is in fact IEEE (but maybe we should have that in EBCDIC as well |
1293 |
dnl as ASCII?) |
1294 |
dnl |
1295 |
AC_DEFUN([gcc_AC_C_FLOAT_FORMAT], |
1296 |
[AC_CACHE_CHECK(floating point format, ac_cv_c_float_format, |
1297 |
[gcc_AC_EXAMINE_OBJECT( |
1298 |
[/* This will not work unless sizeof(double) == 8. */ |
1299 |
extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1]; |
1300 |
|
1301 |
/* This structure must have no internal padding. */ |
1302 |
struct possibility { |
1303 |
char prefix[8]; |
1304 |
double candidate; |
1305 |
char postfix[8]; |
1306 |
}; |
1307 |
|
1308 |
#define C(cand) { "\nformat:", cand, ":tamrof\n" } |
1309 |
struct possibility table [] = |
1310 |
{ |
1311 |
C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */ |
1312 |
C( 3.53802595280598432000e+18), /* D__float - VAX */ |
1313 |
C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */ |
1314 |
C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */ |
1315 |
C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */ |
1316 |
};], |
1317 |
[if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then |
1318 |
ac_cv_c_float_format='IEEE (big-endian)' |
1319 |
elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then |
1320 |
ac_cv_c_float_format='IEEE (big-endian)' |
1321 |
elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then |
1322 |
ac_cv_c_float_format='IEEE (little-endian)' |
1323 |
elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then |
1324 |
ac_cv_c_float_format='IEEE (little-endian)' |
1325 |
elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then |
1326 |
ac_cv_c_float_format='VAX D-float' |
1327 |
elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then |
1328 |
ac_cv_c_float_format='PDP-10' |
1329 |
elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then |
1330 |
ac_cv_c_float_format='IBM 370 hex' |
1331 |
else |
1332 |
AC_MSG_ERROR(Unknown floating point format) |
1333 |
fi], |
1334 |
[AC_MSG_ERROR(compile failed)]) |
1335 |
]) |
1336 |
# IEEE is the default format. If the float endianness isn't the same |
1337 |
# as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN |
1338 |
# (which is a tristate: yes, no, default). This is only an issue with |
1339 |
# IEEE; the other formats are only supported by a few machines each, |
1340 |
# all with the same endianness. |
1341 |
format=IEEE_FLOAT_FORMAT |
1342 |
fbigend= |
1343 |
case $ac_cv_c_float_format in |
1344 |
'IEEE (big-endian)' ) |
1345 |
if test $ac_cv_c_bigendian = no; then |
1346 |
fbigend=1 |
1347 |
fi |
1348 |
;; |
1349 |
'IEEE (little-endian)' ) |
1350 |
if test $ac_cv_c_bigendian = yes; then |
1351 |
fbigend=0 |
1352 |
fi |
1353 |
;; |
1354 |
'VAX D-float' ) |
1355 |
format=VAX_FLOAT_FORMAT |
1356 |
;; |
1357 |
'PDP-10' ) |
1358 |
format=PDP10_FLOAT_FORMAT |
1359 |
;; |
1360 |
'IBM 370 hex' ) |
1361 |
format=IBM_FLOAT_FORMAT |
1362 |
;; |
1363 |
esac |
1364 |
AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format, |
1365 |
[Define to the floating point format of the host machine.]) |
1366 |
if test -n "$fbigend"; then |
1367 |
AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend, |
1368 |
[Define to 1 if the host machine stores floating point numbers in |
1369 |
memory with the word containing the sign bit at the lowest address, |
1370 |
or to 0 if it does it the other way around. |
1371 |
|
1372 |
This macro should not be defined if the ordering is the same as for |
1373 |
multi-word integers.]) |
1374 |
fi |
1375 |
]) |
1376 |
|
1377 |
dnl Check for host float format |
1378 |
gcc_AC_C_FLOAT_FORMAT |
1379 |
|
1380 |
dnl Platform specific binary postprocessor |
1381 |
AC_PATH_PROG(BLESS, "true") |
1382 |
if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then |
1383 |
BLESS=Darwin/lowmem |
1384 |
LDFLAGS="$LDFLAGS -pagezero_size 0x3000" |
1385 |
fi |
1386 |
|
1387 |
dnl Check for GCC 2.7 or higher. |
1388 |
HAVE_GCC27=no |
1389 |
AC_MSG_CHECKING(for GCC 2.7 or higher) |
1390 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5) |
1391 |
# error gcc < 2.7 |
1392 |
typedef syntax error; |
1393 |
#endif |
1394 |
]])], |
1395 |
[AC_MSG_RESULT(yes); HAVE_GCC27=yes], |
1396 |
[AC_MSG_RESULT(no)]) |
1397 |
|
1398 |
dnl Check for GCC 3.0 or higher. |
1399 |
HAVE_GCC30=no |
1400 |
AC_MSG_CHECKING(for GCC 3.0 or higher) |
1401 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ >= 3) |
1402 |
# error gcc < 3 |
1403 |
typedef syntax error; |
1404 |
#endif |
1405 |
]])], |
1406 |
[AC_MSG_RESULT(yes); HAVE_GCC30=yes], |
1407 |
[AC_MSG_RESULT(no)]) |
1408 |
|
1409 |
dnl Check for ICC. |
1410 |
AC_MSG_CHECKING(for ICC) |
1411 |
HAVE_ICC=no |
1412 |
if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then |
1413 |
HAVE_ICC=yes |
1414 |
fi |
1415 |
AC_MSG_RESULT($HAVE_ICC) |
1416 |
|
1417 |
dnl Determine the generated object format |
1418 |
AC_CACHE_CHECK([the format of compiler generated objects], |
1419 |
ac_cv_object_format, [ |
1420 |
echo 'int i;' > conftest.$ac_ext |
1421 |
ac_cv_object_format=no |
1422 |
if AC_TRY_EVAL(ac_compile); then |
1423 |
case `/usr/bin/file conftest.$ac_objext` in |
1424 |
*"ELF"*) |
1425 |
ac_cv_object_format=elf |
1426 |
;; |
1427 |
*"Mach-O"*) |
1428 |
ac_cv_object_format=mach |
1429 |
;; |
1430 |
*) |
1431 |
ac_cv_object_format=unknown |
1432 |
;; |
1433 |
esac |
1434 |
fi |
1435 |
rm -rf conftest* |
1436 |
]) |
1437 |
|
1438 |
dnl Add -fno-strict-aliasing for slirp sources |
1439 |
if [[ "x$HAVE_GCC30" = "xyes" ]]; then |
1440 |
SAVED_CFLAGS="$CFLAGS" |
1441 |
CFLAGS="$CFLAGS -fno-strict-aliasing" |
1442 |
AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing], |
1443 |
ac_cv_gcc_no_strict_aliasing, [ |
1444 |
AC_TRY_COMPILE([],[], |
1445 |
[ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")], |
1446 |
[ac_cv_gcc_no_strict_aliasing=no]) |
1447 |
]) |
1448 |
CFLAGS="$SAVED_CFLAGS" |
1449 |
fi |
1450 |
|
1451 |
dnl Add -mdynamic-no-pic for MacOS X (XXX icc10 will support MacOS X) |
1452 |
if [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then |
1453 |
SAVED_CFLAGS="$CFLAGS" |
1454 |
CFLAGS="$CFLAGS -mdynamic-no-pic" |
1455 |
AC_CACHE_CHECK([whether the compiler supports -mdynamic-no-pic], |
1456 |
ac_cv_gcc_mdynamic_no_pic, [ |
1457 |
AC_TRY_COMPILE([],[],[ac_cv_gcc_mdynamic_no_pic=yes],[ac_cv_gcc_mdynamic_no_pic=no]) |
1458 |
]) |
1459 |
if [[ "x$ac_cv_gcc_mdynamic_no_pic" = "xyes" ]]; then |
1460 |
CXXFLAGS="$CXXFLAGS -mdynamic-no-pic" |
1461 |
else |
1462 |
CFLAGS="$SAVED_CFLAGS" |
1463 |
fi |
1464 |
fi |
1465 |
|
1466 |
dnl CPU emulator sources |
1467 |
if [[ "x$EMULATED_PPC" = "xyes" ]]; then |
1468 |
CPUSRCS="\ |
1469 |
../kpx_cpu/src/mathlib/ieeefp.cpp \ |
1470 |
../kpx_cpu/src/mathlib/mathlib.cpp \ |
1471 |
../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \ |
1472 |
../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \ |
1473 |
../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \ |
1474 |
../kpx_cpu/src/cpu/ppc/ppc-translate.cpp \ |
1475 |
../kpx_cpu/src/utils/utils-cpuinfo.cpp" |
1476 |
CPPFLAGS="$CPPFLAGS -I../kpx_cpu/include -I../kpx_cpu/src" |
1477 |
|
1478 |
dnl Enable JIT compiler, if possible |
1479 |
if [[ "x$WANT_JIT" = "xyes" ]]; then |
1480 |
AC_CACHE_CHECK([whether dyngen can be used], |
1481 |
ac_cv_use_dyngen, [ |
1482 |
case $host_cpu:$ac_cv_object_format in |
1483 |
powerpc:elf) |
1484 |
ac_cv_use_dyngen=yes |
1485 |
;; |
1486 |
x86_64:elf) |
1487 |
ac_cv_use_dyngen=yes |
1488 |
;; |
1489 |
i?86:elf) |
1490 |
ac_cv_use_dyngen=yes |
1491 |
;; |
1492 |
mips:elf) |
1493 |
ac_cv_use_dyngen=yes |
1494 |
;; |
1495 |
powerpc:mach) |
1496 |
ac_cv_use_dyngen=yes |
1497 |
;; |
1498 |
x86_64:mach) |
1499 |
ac_cv_use_dyngen=yes |
1500 |
;; |
1501 |
i?86:mach) |
1502 |
ac_cv_use_dyngen=yes |
1503 |
;; |
1504 |
*:*) |
1505 |
ac_cv_use_dyngen=no |
1506 |
;; |
1507 |
esac |
1508 |
dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2) |
1509 |
if [[ -z "$DYNGEN_CC" ]]; then |
1510 |
if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then |
1511 |
DYNGEN_CC=$CXX |
1512 |
else |
1513 |
for p in /usr/bin /usr/local/bin /usr/freeware/bin; do |
1514 |
gxx="$p/g++" |
1515 |
if [[ -x "$gxx" ]]; then |
1516 |
DYNGEN_CC="$gxx" |
1517 |
fi |
1518 |
done |
1519 |
fi |
1520 |
fi |
1521 |
if [[ -z "$DYNGEN_CC" ]]; then |
1522 |
ac_cv_use_dyngen=no |
1523 |
fi |
1524 |
]) |
1525 |
if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then |
1526 |
case $host_cpu in |
1527 |
i?86) |
1528 |
DYNGEN_OP_FLAGS="-fomit-frame-pointer" |
1529 |
;; |
1530 |
mips) |
1531 |
DYNGEN_OP_FLAGS="-fno-delayed-branch -mno-abicalls" |
1532 |
;; |
1533 |
powerpc) |
1534 |
if [[ "x$ac_cv_object_format" = "xmach" ]]; then |
1535 |
DYNGEN_OP_FLAGS="-mdynamic-no-pic" |
1536 |
fi |
1537 |
;; |
1538 |
esac |
1539 |
have_dyngen_gcc3=no |
1540 |
case "x`$DYNGEN_CC -dumpversion`" in |
1541 |
x[12].*) ;; |
1542 |
x*) have_dyngen_gcc3=yes ;; |
1543 |
esac |
1544 |
if [[ "x$have_dyngen_gcc3" = "xyes" ]]; then |
1545 |
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-align-functions" |
1546 |
else |
1547 |
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0" |
1548 |
fi |
1549 |
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-functions -finline-limit=10000 -fno-exceptions -g0" |
1550 |
if [[ "x$have_dyngen_gcc3" = "xyes" ]]; then |
1551 |
DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls" |
1552 |
fi |
1553 |
if [[ "x$DYNGEN_CC" != "x$CXX" ]]; then |
1554 |
DYNGEN_CFLAGS="-O2 $CFLAGS" |
1555 |
DYNGEN_CXXFLAGS="-O2 $CXXFLAGS" |
1556 |
else |
1557 |
DYNGEN_CFLAGS="\$(CFLAGS)" |
1558 |
DYNGEN_CXXFLAGS="\$(CXXFLAGS)" |
1559 |
fi |
1560 |
else |
1561 |
WANT_JIT=no |
1562 |
fi |
1563 |
AC_TRANSLATE_DEFINE(ENABLE_DYNGEN, $ac_cv_use_dyngen, [Define to enable dyngen engine]) |
1564 |
if [[ "x$WANT_JIT" = "xyes" ]]; then |
1565 |
DYNGENSRCS="\ |
1566 |
../kpx_cpu/src/cpu/jit/dyngen.c \ |
1567 |
../kpx_cpu/src/cpu/jit/cxxdemangle.cpp" |
1568 |
CPUSRCS="\ |
1569 |
../kpx_cpu/src/cpu/jit/jit-cache.cpp \ |
1570 |
../kpx_cpu/src/cpu/jit/basic-dyngen.cpp \ |
1571 |
../kpx_cpu/src/cpu/ppc/ppc-dyngen.cpp \ |
1572 |
../kpx_cpu/src/cpu/ppc/ppc-jit.cpp $CPUSRCS" |
1573 |
fi |
1574 |
fi |
1575 |
CPUSRCS="$CPUSRCS ../kpx_cpu/sheepshaver_glue.cpp ../kpx_cpu/ppc-dis.c" |
1576 |
else |
1577 |
WANT_JIT=no |
1578 |
fi |
1579 |
if [[ "x$WANT_JIT" = "xyes" ]]; then |
1580 |
CPPFLAGS="$CPPFLAGS -DUSE_JIT" |
1581 |
fi |
1582 |
|
1583 |
dnl Higher level optimizations with MIPSPro compilers are possible |
1584 |
if [[ "x$HAVE_IPA" = "xyes" ]]; then |
1585 |
CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA" |
1586 |
CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA" |
1587 |
CXXFLAGS="-LANG:std $CXXFLAGS" |
1588 |
LDFLAGS="$LDFLAGS -O3 -OPT:Olimit=0 -IPA" |
1589 |
fi |
1590 |
|
1591 |
dnl Check for linker script support |
1592 |
case $target_os:$target_cpu in |
1593 |
linux*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";; |
1594 |
linux*:x86_64) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-x86_64.ld";; |
1595 |
linux*:powerpc) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-ppc.ld";; |
1596 |
netbsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/linux-i386.ld";; |
1597 |
freebsd*:i?86) LINKER_SCRIPT_FLAGS="-Wl,-T,ldscripts/freebsd-i386.ld";; |
1598 |
darwin*:*) LINKER_SCRIPT_FLAGS="-Wl,-seg1addr,0x78048000";; |
1599 |
esac |
1600 |
if [[ -n "$LINKER_SCRIPT_FLAGS" ]]; then |
1601 |
AC_CACHE_CHECK([whether linker script is usable], |
1602 |
ac_cv_linker_script_works, [ |
1603 |
AC_LANG_SAVE |
1604 |
AC_LANG_CPLUSPLUS |
1605 |
saved_LDFLAGS="$LDFLAGS" |
1606 |
LDFLAGS="$LDFLAGS $LINKER_SCRIPT_FLAGS" |
1607 |
AC_TRY_RUN( |
1608 |
[int main() {if ((char *)&main < (char *)0x70000000) return 1;}], |
1609 |
[ac_cv_linker_script_works=yes], |
1610 |
[ac_cv_linker_script_works=no], |
1611 |
dnl When cross-compiling, assume it works |
1612 |
[ac_cv_linker_script_works="guessing yes"] |
1613 |
) |
1614 |
AC_LANG_RESTORE |
1615 |
if [[ "$ac_cv_linker_script_works" = "no" ]]; then |
1616 |
LDFLAGS="$saved_LDFLAGS" |
1617 |
LINKER_SCRIPT_FLAGS="" |
1618 |
fi |
1619 |
]) |
1620 |
fi |
1621 |
AC_TRANSLATE_DEFINE(HAVE_LINKER_SCRIPT, "$ac_cv_linker_script_works", |
1622 |
[Define if there is a linker script to relocate the executable above 0x70000000.]) |
1623 |
|
1624 |
dnl Generate Makefile. |
1625 |
AC_SUBST(PERL) |
1626 |
AC_SUBST(USE_DYNGEN, [$ac_cv_use_dyngen]) |
1627 |
AC_SUBST(DYNGENSRCS) |
1628 |
AC_SUBST(DYNGEN_CC) |
1629 |
AC_SUBST(DYNGEN_CFLAGS) |
1630 |
AC_SUBST(DYNGEN_CXXFLAGS) |
1631 |
AC_SUBST(DYNGEN_OP_FLAGS) |
1632 |
AC_SUBST(SYSSRCS) |
1633 |
AC_SUBST(CPUSRCS) |
1634 |
AC_SUBST(BLESS) |
1635 |
AC_SUBST(KEYCODES) |
1636 |
AC_OUTPUT([ |
1637 |
Makefile |
1638 |
../MacOSX/Info.plist |
1639 |
]) |
1640 |
|
1641 |
dnl Print summary. |
1642 |
echo |
1643 |
echo SheepShaver configuration summary: |
1644 |
echo |
1645 |
echo SDL support ...................... : $SDL_SUPPORT |
1646 |
echo BINCUE support ................... : $have_bincue |
1647 |
echo LIBVHD support ................... : $have_libvhd |
1648 |
echo FBDev DGA support ................ : $WANT_FBDEV_DGA |
1649 |
echo XFree86 DGA support .............. : $WANT_XF86_DGA |
1650 |
echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE |
1651 |
echo Using PowerPC emulator ........... : $EMULATED_PPC |
1652 |
echo Enable JIT compiler .............. : $WANT_JIT |
1653 |
echo Enable video on SEGV signals ..... : $WANT_VOSF |
1654 |
echo ESD sound support ................ : $WANT_ESD |
1655 |
echo GTK user interface ............... : $WANT_GTK |
1656 |
echo mon debugger support ............. : $WANT_MON |
1657 |
echo Addressing mode .................. : $WANT_ADDRESSING_MODE |
1658 |
echo Bad memory access recovery type .. : $sigsegv_recovery |
1659 |
echo |
1660 |
echo "Configuration done. Now type \"make\"." |