ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.78
Committed: 2010-07-28T01:07:45Z (14 years, 4 months ago) by asvitkine
Branch: MAIN
Changes since 1.77: +34 -3 lines
Log Message:
Do the right thing if host-triplet is a i386-i686, but gcc compiles by
default as x86_64. Fixes configure on Snow Leopard.

File Contents

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