ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.25
Committed: 2004-05-09T16:11:45Z (20 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.24: +24 -0 lines
Log Message:
TUN/TAP support

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 dnl Video options.
18 AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes])
19 AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=yes]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=yes])
20 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])
21 AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes])
22
23 dnl JIT compiler options.
24 AC_ARG_ENABLE(jit-compiler, [ --enable-jit-compiler enable JIT compiler [default=no]], [WANT_JIT=$enableval], [WANT_JIT=no])
25 AC_ARG_ENABLE(jit-debug, [ --enable-jit-debug activate native code disassemblers [default=no]], [WANT_JIT_DEBUG=$enableval], [WANT_JIT_DEBUG=no])
26
27 dnl FPU emulation core.
28 AC_ARG_ENABLE(fpe,
29 [ --enable-fpe=FPE specify which fpu emulator to use [default=auto]],
30 [ case "$enableval" in
31 dnl default is always ieee, if architecture has this fp format
32 auto) FPE_CORE_TEST_ORDER="ieee uae";;
33 ieee) FPE_CORE_TEST_ORDER="ieee";;
34 uae) FPE_CORE_TEST_ORDER="uae";;
35 x86) FPE_CORE_TEST_ORDER="x86";;
36 *) AC_MSG_ERROR([--enable-fpe takes only one of the following values: auto, x86, ieee, uae]);;
37 esac
38 ],
39 [ FPE_CORE_TEST_ORDER="ieee uae"
40 ])
41
42 dnl Addressing modes.
43 AC_ARG_ENABLE(addressing,
44 [ --enable-addressing=AM specify the addressing mode to use [default=fastest]],
45 [ case "$enableval" in
46 real) ADDRESSING_TEST_ORDER="real";;
47 direct) ADDRESSING_TEST_ORDER="direct";;
48 banks) ADDRESSING_TEST_ORDER="banks";;
49 fastest)ADDRESSING_TEST_ORDER="direct banks";;
50 *) AC_MSG_ERROR([--enable-addressing takes only one of the following values: fastest, real, direct, banks]);;
51 esac
52 ],
53 [ ADDRESSING_TEST_ORDER="direct banks"
54 ])
55
56 dnl External packages.
57 AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes])
58 AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes])
59 AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes])
60
61 dnl Canonical system information.
62 AC_CANONICAL_HOST
63 AC_CANONICAL_TARGET
64
65 dnl Target OS type (target is host if not cross-compiling).
66 case "$target_os" in
67 linux*) OS_TYPE=linux;;
68 netbsd*) OS_TYPE=netbsd;;
69 freebsd*) OS_TYPE=freebsd;;
70 solaris*) OS_TYPE=solaris;;
71 darwin*) OS_TYPE=darwin;;
72 *) OS_TYPE=`echo $target_os | sed -e 's/-/_/g' | sed -e 's/\./_/g'`;;
73 esac
74 DEFINES="$DEFINES -DOS_$OS_TYPE"
75
76 dnl Target CPU type.
77 HAVE_I386=no
78 HAVE_M68K=no
79 HAVE_SPARC=no
80 HAVE_POWERPC=no
81 HAVE_X86_64=no
82 case "$target_cpu" in
83 i386* | i486* | i586* | i686* | i786* ) HAVE_I386=yes;;
84 m68k* ) HAVE_M68K=yes;;
85 sparc* ) HAVE_SPARC=yes;;
86 powerpc* ) HAVE_POWERPC=yes;;
87 x86_64* ) HAVE_X86_64=yes;;
88 esac
89
90 dnl Checks for programs.
91 AC_PROG_CC
92 AC_PROG_CC_C_O
93 AC_PROG_CPP
94 AC_PROG_CXX
95 AC_PROG_MAKE_SET
96 AC_PROG_INSTALL
97
98 dnl We use mon if possible.
99 MONSRCS=
100 if [[ "x$WANT_MON" = "xyes" ]]; then
101 AC_MSG_CHECKING(for mon)
102 mon_srcdir=../../../mon/src
103 if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then
104 AC_MSG_RESULT(yes)
105 AC_DEFINE(ENABLE_MON, 1, [Define if using "mon".])
106 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"
107 CXXFLAGS="$CXXFLAGS -I$mon_srcdir -I$mon_srcdir/disass"
108 AC_CHECK_LIB(ncurses, tgetent, ,
109 AC_CHECK_LIB(termcap, tgetent, ,
110 AC_CHECK_LIB(termlib, tgetent, ,
111 AC_CHECK_LIB(terminfo, tgetent, ,
112 AC_CHECK_LIB(Hcurses, tgetent, ,
113 AC_CHECK_LIB(curses, tgetent))))))
114 AC_CHECK_LIB(readline, readline)
115 else
116 AC_MSG_RESULT(no)
117 AC_MSG_WARN([Could not find mon, ignoring --with-mon.])
118 WANT_MON=no
119 fi
120 fi
121
122 dnl Checks for libraries.
123 AC_CHECK_LIB(posix4, sem_init)
124 AC_CHECK_LIB(rt, timer_create)
125
126 dnl We need X11.
127 AC_PATH_XTRA
128 if [[ "x$no_x" = "xyes" ]]; then
129 AC_MSG_ERROR([You need X11 to run Basilisk II.])
130 fi
131 CFLAGS="$CFLAGS $X_CFLAGS"
132 CXXFLAGS="$CXXFLAGS $X_CFLAGS"
133 LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -lXext $X_EXTRA_LIBS"
134
135 dnl We want pthreads. Try libpthread first, then libc_r (FreeBSD), then PTL.
136 HAVE_PTHREADS=yes
137 AC_CHECK_LIB(pthread, pthread_create, , [
138 AC_CHECK_LIB(c_r, pthread_create, , [
139 AC_CHECK_LIB(PTL, pthread_create, , [
140 HAVE_PTHREADS=no
141 ])
142 ])
143 ])
144 if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then
145 AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.])
146 fi
147 AC_CHECK_FUNCS(pthread_cancel)
148 AC_CHECK_FUNCS(pthread_mutexattr_setprotocol)
149 AC_CHECK_FUNCS(pthread_mutexattr_settype)
150 AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
151
152 dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes.
153 SEMSRC=
154 AC_CHECK_FUNCS(sem_init, , [
155 if test "x$HAVE_PTHREADS" = "xyes"; then
156 SEMSRC=posix_sem.cpp
157 fi
158 ])
159
160 dnl We use DGA (XFree86 or fbdev) if possible.
161 if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then
162 AC_CHECK_LIB(Xxf86dga, XF86DGAQueryExtension, [
163 AC_DEFINE(ENABLE_XF86_DGA, 1, [Define if using XFree86 DGA extension.])
164 LIBS="$LIBS -lXxf86dga"
165 if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
166 AC_MSG_WARN([Cannot have both --enable-xf86-dga and --enable-fbdev-dga, ignoring --enable-fbdev-dga.])
167 WANT_FBDEV_DGA=no
168 fi
169 ], [
170 AC_MSG_WARN([Could not find XFree86 DGA extension, ignoring --enable-xf86-dga.])
171 WANT_XF86_DGA=no
172 ])
173 fi
174 if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then
175 AC_DEFINE(ENABLE_FBDEV_DGA, 1, [Define if using DGA with framebuffer device.])
176 fi
177
178 dnl We use XFree86 VidMode if possible.
179 if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; then
180 AC_CHECK_LIB(Xxf86vm, XF86VidModeQueryExtension, [
181 AC_DEFINE(ENABLE_XF86_VIDMODE, 1, [Define if using XFree86 DGA extension.])
182 LIBS="$LIBS -lXxf86vm"
183 ], [
184 AC_MSG_WARN([Could not find XFree86 VidMode extension, ignoring --enable-xf86-vidmode.])
185 WANT_XF86_VIDMODE=no
186 ])
187 fi
188
189 dnl We use GTK+ if possible.
190 UISRCS=../dummy/prefs_editor_dummy.cpp
191 if [[ "x$WANT_GTK" = "xyes" ]]; then
192 AM_PATH_GTK(1.2.0, [
193 AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.])
194 CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
195 LIBS="$LIBS $GTK_LIBS"
196 UISRCS=prefs_editor_gtk.cpp
197 dnl somehow, <gnome-i18n.h> would redefine gettext() to nothing if
198 dnl ENABLE_NLS is not set, thusly conflicting with C++ <string> which
199 dnl includes <libintl.h>
200 AM_GNU_GETTEXT
201 B2_PATH_GNOMEUI([
202 AC_DEFINE(HAVE_GNOMEUI, 1, [Define if libgnomeui is available.])
203 CXXFLAGS="$CXXFLAGS $GNOMEUI_CFLAGS"
204 LIBS="$LIBS $GNOMEUI_LIBS"
205 ], [])
206 ], [
207 AC_MSG_WARN([Could not find GTK+, disabling user interface.])
208 WANT_GTK=no
209 ])
210 fi
211
212 dnl We use ESD if possible.
213 if [[ "x$WANT_ESD" = "xyes" ]]; then
214 AM_PATH_ESD(0.2.8, [
215 AC_DEFINE(ENABLE_ESD, 1, [Define is using ESD.])
216 CFLAGS="$CFLAGS $ESD_CFLAGS"
217 CXXFLAGS="$CXXFLAGS $ESD_CFLAGS"
218 LIBS="$LIBS $ESD_LIBS"
219 ], [
220 AC_MSG_WARN([Could not find ESD, disabling ESD support.])
221 WANT_ESD=no
222 ])
223 fi
224
225 dnl We use 64-bit file size support if possible.
226 AC_SYS_LARGEFILE
227
228 dnl Checks for header files.
229 AC_HEADER_STDC
230 AC_CHECK_HEADERS(unistd.h fcntl.h sys/types.h sys/time.h sys/mman.h mach/mach.h)
231 AC_CHECK_HEADERS(readline.h history.h readline/readline.h readline/history.h)
232 AC_CHECK_HEADERS(linux/if.h linux/if_tun.h net/if.h net/if_tun.h)
233
234 dnl Checks for typedefs, structures, and compiler characteristics.
235 AC_C_BIGENDIAN
236 AC_C_CONST
237 AC_C_INLINE
238 AC_CHECK_SIZEOF(short, 2)
239 AC_CHECK_SIZEOF(int, 4)
240 AC_CHECK_SIZEOF(long, 4)
241 AC_CHECK_SIZEOF(long long, 8)
242 AC_CHECK_SIZEOF(float, 4)
243 AC_CHECK_SIZEOF(double, 8)
244 AC_CHECK_SIZEOF(long double, 12)
245 AC_CHECK_SIZEOF(void *, 4)
246 AC_TYPE_OFF_T
247 AC_CHECK_TYPES(loff_t)
248 AC_CHECK_TYPES(caddr_t)
249 AC_TYPE_SIZE_T
250 AC_TYPE_SIGNAL
251 AC_HEADER_TIME
252 AC_STRUCT_TM
253
254 dnl Check whether sys/socket.h defines type socklen_t.
255 dnl (extracted from ac-archive/Miscellaneous)
256 AC_CACHE_CHECK([for socklen_t],
257 ac_cv_type_socklen_t, [
258 AC_TRY_COMPILE([
259 #include <sys/types.h>
260 #include <sys/socket.h>
261 ], [socklen_t len = 42; return 0;],
262 ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no,
263 dnl When cross-compiling, do not assume anything.
264 ac_cv_type_socklen_t="guessing no"
265 )
266 ])
267 if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then
268 AC_DEFINE(socklen_t, int, [Define to 'int' if <sys/types.h> doesn't define.])
269 fi
270
271 dnl Checks for library functions.
272 AC_CHECK_FUNCS(strdup cfmakeraw)
273 AC_CHECK_FUNCS(clock_gettime timer_create)
274 AC_CHECK_FUNCS(sigaction signal)
275 AC_CHECK_FUNCS(mmap mprotect munmap)
276 AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect)
277
278 dnl Darwin seems to define mach_task_self() instead of task_self().
279 AC_CHECK_FUNCS(mach_task_self task_self)
280
281 dnl Check for headers and functions related to pty support (sshpty.c)
282 dnl From openssh-3.2.2p1 configure.ac
283
284 AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h)
285 AC_CHECK_FUNCS(_getpty vhangup strlcpy)
286
287 case "$host" in
288 *-*-hpux10.26)
289 disable_ptmx_check=yes
290 ;;
291 *-*-linux*)
292 no_dev_ptmx=1
293 ;;
294 mips-sony-bsd|mips-sony-newsos4)
295 AC_DEFINE(HAVE_NEWS4, 1, [Define if you are on NEWS-OS (additions from openssh-3.2.2p1, for sshpty.c).])
296 ;;
297 *-*-sco3.2v4*)
298 no_dev_ptmx=1
299 ;;
300 *-*-sco3.2v5*)
301 no_dev_ptmx=1
302 ;;
303 esac
304
305 if test -z "$no_dev_ptmx" ; then
306 if test "x$disable_ptmx_check" != "xyes" ; then
307 AC_CHECK_FILE([/dev/ptmx],
308 [
309 AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.])
310 have_dev_ptmx=1
311 ]
312 )
313 fi
314 fi
315 AC_CHECK_FILE([/dev/ptc],
316 [
317 AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.])
318 have_dev_ptc=1
319 ]
320 )
321
322 dnl (end of code from openssh-3.2.2p1 configure.ac)
323
324
325 dnl Select system-dependant source files.
326 SERIALSRC=serial_unix.cpp
327 ETHERSRC=../dummy/ether_dummy.cpp
328 SCSISRC=../dummy/scsi_dummy.cpp
329 AUDIOSRC=../dummy/audio_dummy.cpp
330 EXTRASYSSRCS=
331 CAN_NATIVE_M68K=no
332 case "$target_os" in
333 linux*)
334 ETHERSRC=ether_unix.cpp
335 AUDIOSRC=audio_oss_esd.cpp
336 SCSISRC=Linux/scsi_linux.cpp
337 ;;
338 freebsd*)
339 ETHERSRC=ether_unix.cpp
340 AUDIOSRC=audio_oss_esd.cpp
341 DEFINES="$DEFINES -DBSD_COMP"
342 CXXFLAGS="$CXXFLAGS -fpermissive"
343 dnl Check for the CAM library
344 AC_CHECK_LIB(cam, cam_open_btl, HAVE_LIBCAM=yes, HAVE_LIBCAM=no)
345 if [[ "x$HAVE_LIBCAM" = "xno" ]]; then
346 AC_MSG_WARN([Cannot find libcam for SCSI management, disabling SCSI support.])
347 else
348 dnl Check for the sys kernel includes
349 AC_CHECK_HEADER(camlib.h)
350 if [[ "x$ac_cv_header_camlib_h" = "xno" ]]; then
351 dnl In this case I should fix this thing including a "patch"
352 dnl to access directly to the functions in the kernel :) --Orlando
353 AC_MSG_WARN([Cannot find includes for CAM library, disabling SCSI support.])
354 else
355 SCSISRC=FreeBSD/scsi_freebsd.cpp
356 LIBS="$LIBS -lcam"
357 DEFINES="$DEFINES -DCAM"
358 fi
359 fi
360 ;;
361 netbsd*)
362 CAN_NATIVE_M68K=yes
363 ;;
364 solaris*)
365 AUDIOSRC=Solaris/audio_solaris.cpp
366 DEFINES="$DEFINES -DBSD_COMP -D_POSIX_PTHREAD_SEMANTICS"
367 ;;
368 irix*)
369 ETHERSRC=ether_unix.cpp
370 AUDIOSRC=Irix/audio_irix.cpp
371 EXTRASYSSRCS=Irix/unaligned.c
372 dnl IRIX headers work fine, but somehow don't define or use "STDC_HEADERS"
373 DEFINES="$DEFINES -DCRTSCTS=CNEW_RTSCTS -DB230400=B115200 -DSTDC_HEADERS"
374 LIBS="$LIBS -laudio"
375 WANT_ESD=no
376
377 dnl Check if our compiler supports -IPA (MIPSPro)
378 HAVE_IPA=no
379 ocflags="$CFLAGS"
380 CFLAGS=`echo "$CFLAGS -IPA" | sed -e "s/-g//g"`
381 AC_MSG_CHECKING(if "-IPA" works)
382 dnl Do a test compile of an empty function
383 AC_TRY_COMPILE(,, [AC_MSG_RESULT(yes); HAVE_IPA=yes], AC_MSG_RESULT(no))
384 CFLAGS="$ocflags"
385
386 ;;
387 esac
388
389 dnl Use 68k CPU natively?
390 WANT_NATIVE_M68K=no
391 if [[ "x$HAVE_M68K" = "xyes" -a "x$CAN_NATIVE_M68K" = "xyes" ]]; then
392 AC_DEFINE(ENABLE_NATIVE_M68K, 1, [Define if using native 68k mode.])
393 WANT_NATIVE_M68K=yes
394 fi
395
396 if [[ "x$HAVE_PTHREADS" = "xno" ]]; then
397 dnl Serial, ethernet and audio support needs pthreads
398 AC_MSG_WARN([You don't have pthreads, disabling serial, ethernet and audio support.])
399 SERIALSRC=../dummy/serial_dummy.cpp
400 ETHERSRC=../dummy/ether_dummy.cpp
401 AUDIOSRC=../dummy/audio_dummy.cpp
402 fi
403 SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
404
405 dnl Define a macro that translates a yesno-variable into a C macro definition
406 dnl to be put into the config.h file
407 dnl $1 -- the macro to define
408 dnl $2 -- the value to translate
409 dnl $3 -- template name
410 AC_DEFUN(AC_TRANSLATE_DEFINE, [
411 if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
412 AC_DEFINE($1, 1, $3)
413 fi
414 ])
415
416 dnl Check that the host supports TUN/TAP devices
417 AC_CACHE_CHECK([whether TUN/TAP is supported],
418 ac_cv_tun_tap_support, [
419 AC_TRY_COMPILE([
420 #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
421 #include <linux/if.h>
422 #include <linux/if_tun.h>
423 #endif
424 #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
425 #include <net/if.h>
426 #include <net/if_tun.h>
427 #endif
428 ], [
429 struct ifreq ifr;
430 memset(&ifr, 0, sizeof(ifr));
431 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
432 ],
433 ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
434 )
435 ])
436 AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
437 [Define if your system supports TUN/TAP devices.])
438
439 dnl Various checks if the system supports vm_allocate() and the like functions.
440 have_mach_vm=no
441 if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
442 "x$ac_cv_func_vm_protect" = "xyes" ]]; then
443 have_mach_vm=yes
444 fi
445 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
446 [Define if your system has a working vm_allocate()-based memory allocator.])
447
448 dnl Check that vm_allocate(), vm_protect() work
449 if [[ "x$have_mach_vm" = "xyes" ]]; then
450
451 AC_CACHE_CHECK([whether vm_protect works],
452 ac_cv_vm_protect_works, [
453 AC_LANG_SAVE
454 AC_LANG_CPLUSPLUS
455 ac_cv_vm_protect_works=yes
456 dnl First the tests that should segfault
457 for test_def in NONE_READ NONE_WRITE READ_WRITE; do
458 AC_TRY_RUN([
459 #define CONFIGURE_TEST_VM_MAP
460 #define TEST_VM_PROT_$test_def
461 #include "vm_alloc.cpp"
462 ], ac_cv_vm_protect_works=no, rm -f core,
463 dnl When cross-compiling, do not assume anything
464 ac_cv_vm_protect_works="guessing no"
465 )
466 done
467 AC_TRY_RUN([
468 #define CONFIGURE_TEST_VM_MAP
469 #define TEST_VM_PROT_RDWR_WRITE
470 #include "vm_alloc.cpp"
471 ], , ac_cv_vm_protect_works=no,
472 dnl When cross-compiling, do not assume anything
473 ac_cv_vm_protect_works="guessing no"
474 )
475 AC_LANG_RESTORE
476 ]
477 )
478
479 dnl Remove support for vm_allocate() if vm_protect() does not work
480 if [[ "x$have_mach_vm" = "xyes" ]]; then
481 case $ac_cv_vm_protect_works in
482 *yes) have_mach_vm=yes;;
483 *no) have_mach_vm=no;;
484 esac
485 fi
486 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
487 [Define if your system has a working vm_allocate()-based memory allocator.])
488
489 fi dnl HAVE_MACH_VM
490
491 dnl Various checks if the system supports mmap() and the like functions.
492 dnl ... and Mach memory allocators are not supported
493 have_mmap_vm=no
494 if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
495 "x$ac_cv_func_mprotect" = "xyes" ]]; then
496 if [[ "x$have_mach_vm" = "xno" ]]; then
497 have_mmap_vm=yes
498 fi
499 fi
500 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
501 [Define if your system has a working mmap()-based memory allocator.])
502
503 dnl Check that mmap() and associated functions work.
504 if [[ "x$have_mmap_vm" = "xyes" ]]; then
505
506 dnl Check if we have a working anonymous mmap()
507 AC_CACHE_CHECK([whether mmap supports MAP_ANON],
508 ac_cv_mmap_anon, [
509 AC_LANG_SAVE
510 AC_LANG_CPLUSPLUS
511 AC_TRY_RUN([
512 #define HAVE_MMAP_ANON
513 #define CONFIGURE_TEST_VM_MAP
514 #define TEST_VM_MMAP_ANON
515 #include "vm_alloc.cpp"
516 ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
517 dnl When cross-compiling, do not assume anything.
518 ac_cv_mmap_anon="guessing no"
519 )
520 AC_LANG_RESTORE
521 ]
522 )
523 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
524 [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
525
526 AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
527 ac_cv_mmap_anonymous, [
528 AC_LANG_SAVE
529 AC_LANG_CPLUSPLUS
530 AC_TRY_RUN([
531 #define HAVE_MMAP_ANONYMOUS
532 #define CONFIGURE_TEST_VM_MAP
533 #define TEST_VM_MMAP_ANON
534 #include "vm_alloc.cpp"
535 ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
536 dnl When cross-compiling, do not assume anything.
537 ac_cv_mmap_anonymous="guessing no"
538 )
539 AC_LANG_RESTORE
540 ]
541 )
542 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
543 [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
544
545 AC_CACHE_CHECK([whether mprotect works],
546 ac_cv_mprotect_works, [
547 AC_LANG_SAVE
548 AC_LANG_CPLUSPLUS
549 ac_cv_mprotect_works=yes
550 dnl First the tests that should segfault
551 for test_def in NONE_READ NONE_WRITE READ_WRITE; do
552 AC_TRY_RUN([
553 #define CONFIGURE_TEST_VM_MAP
554 #define TEST_VM_PROT_$test_def
555 #include "vm_alloc.cpp"
556 ], ac_cv_mprotect_works=no, rm -f core,
557 dnl When cross-compiling, do not assume anything
558 ac_cv_mprotect_works="guessing no"
559 )
560 done
561 AC_TRY_RUN([
562 #define CONFIGURE_TEST_VM_MAP
563 #define TEST_VM_PROT_RDWR_WRITE
564 #include "vm_alloc.cpp"
565 ], , ac_cv_mprotect_works=no,
566 dnl When cross-compiling, do not assume anything
567 ac_cv_mprotect_works="guessing no"
568 )
569 AC_LANG_RESTORE
570 ]
571 )
572
573 dnl Remove support for mmap() if mprotect() does not work
574 if [[ "x$have_mmap_vm" = "xyes" ]]; then
575 case $ac_cv_mprotect_works in
576 *yes) have_mmap_vm=yes;;
577 *no) have_mmap_vm=no;;
578 esac
579 fi
580 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
581 [Define if your system has a working mmap()-based memory allocator.])
582
583 fi dnl HAVE_MMAP_VM
584
585 dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
586 AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x2000],
587 ac_cv_pagezero_hack, [
588 ac_cv_pagezero_hack=no
589 if AC_TRY_COMMAND([Darwin/testlmem.sh 0x2000]); then
590 ac_cv_pagezero_hack=yes
591 dnl might as well skip the test for mmap-able low memory
592 ac_cv_can_map_lm=no
593 fi
594 ])
595 AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
596 [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
597
598 dnl Check if we can mmap 0x2000 bytes from 0x0000
599 AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x2000],
600 ac_cv_can_map_lm, [
601 AC_LANG_SAVE
602 AC_LANG_CPLUSPLUS
603 AC_TRY_RUN([
604 #include "vm_alloc.cpp"
605 int main(void) { /* returns 0 if we could map the lowmem globals */
606 volatile char * lm = 0;
607 if (vm_init() < 0) exit(1);
608 if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
609 lm[0] = 'z';
610 if (vm_release((char *)lm, 0x2000) < 0) exit(1);
611 vm_exit(); exit(0);
612 }
613 ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
614 dnl When cross-compiling, do not assume anything.
615 ac_cv_can_map_lm="guessing no"
616 )
617 AC_LANG_RESTORE
618 ]
619 )
620
621 dnl Check signal handlers need to be reinstalled
622 AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
623 ac_cv_signal_need_reinstall, [
624 AC_LANG_SAVE
625 AC_LANG_CPLUSPLUS
626 AC_TRY_RUN([
627 #include <stdlib.h>
628 #ifdef HAVE_UNISTD_H
629 #include <unistd.h>
630 #endif
631 #include <signal.h>
632 static int handled_signal = 0;
633 RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
634 int main(void) { /* returns 0 if signals need not to be reinstalled */
635 signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
636 exit(handled_signal == 2);
637 }
638 ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
639 dnl When cross-compiling, do not assume anything.
640 ac_cv_signal_need_reinstall="guessing yes"
641 )
642 AC_LANG_RESTORE
643 ]
644 )
645 AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
646 [Define if your system requires signals to be reinstalled.])
647
648 dnl Check if sigaction handlers need to be reinstalled
649 AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
650 ac_cv_sigaction_need_reinstall, [
651 AC_LANG_SAVE
652 AC_LANG_CPLUSPLUS
653 AC_TRY_RUN([
654 #include <stdlib.h>
655 #ifdef HAVE_UNISTD_H
656 #include <unistd.h>
657 #endif
658 #include <signal.h>
659 static int handled_signal = 0;
660 RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
661 typedef RETSIGTYPE (*signal_handler)(int);
662 static signal_handler mysignal(int sig, signal_handler handler) {
663 struct sigaction old_sa;
664 struct sigaction new_sa;
665 new_sa.sa_handler = handler;
666 return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
667 }
668 int main(void) { /* returns 0 if signals need not to be reinstalled */
669 mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
670 exit(handled_signal == 2);
671 }
672 ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
673 dnl When cross-compiling, do not assume anything.
674 ac_cv_sigaction_need_reinstall="guessing yes"
675 )
676 AC_LANG_RESTORE
677 ]
678 )
679 AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
680 [Define if your system requires sigactions to be reinstalled.])
681
682 dnl Check if Mach exceptions supported.
683 AC_CACHE_CHECK([whether your system supports Mach exceptions],
684 ac_cv_have_mach_exceptions, [
685 AC_LANG_SAVE
686 AC_LANG_CPLUSPLUS
687 AC_TRY_RUN([
688 #define HAVE_MACH_EXCEPTIONS 1
689 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
690 #include "vm_alloc.cpp"
691 #include "sigsegv.cpp"
692 ], [
693 sigsegv_recovery=mach
694 ac_cv_have_mach_exceptions=yes
695 ],
696 ac_cv_have_mach_exceptions=no,
697 dnl When cross-compiling, do not assume anything.
698 ac_cv_have_mach_exceptions=no
699 )
700 AC_LANG_RESTORE
701 ]
702 )
703 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
704 [Define if your system supports Mach exceptions.])
705
706 dnl Otherwise, check if extended signals are supported.
707 if [[ -z "$sigsegv_recovery" ]]; then
708 AC_CACHE_CHECK([whether your system supports extended signal handlers],
709 ac_cv_have_extended_signals, [
710 AC_LANG_SAVE
711 AC_LANG_CPLUSPLUS
712 AC_TRY_RUN([
713 #define HAVE_SIGINFO_T 1
714 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
715 #include "vm_alloc.cpp"
716 #include "sigsegv.cpp"
717 ], [
718 sigsegv_recovery=siginfo
719 ac_cv_have_extended_signals=yes
720 ],
721 ac_cv_have_extended_signals=no,
722 dnl When cross-compiling, do not assume anything.
723 ac_cv_have_extended_signals=no
724 )
725 AC_LANG_RESTORE
726 ]
727 )
728 AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
729 [Define if your system support extended signals.])
730 fi
731
732 dnl Otherwise, check for subterfuges.
733 if [[ -z "$sigsegv_recovery" ]]; then
734 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
735 ac_cv_have_sigcontext_hack, [
736 AC_LANG_SAVE
737 AC_LANG_CPLUSPLUS
738 AC_TRY_RUN([
739 #define HAVE_SIGCONTEXT_SUBTERFUGE 1
740 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
741 #include "vm_alloc.cpp"
742 #include "sigsegv.cpp"
743 ], [
744 sigsegv_recovery=sigcontext
745 ac_cv_have_sigcontext_hack=yes
746 ],
747 ac_cv_have_sigcontext_hack=no,
748 dnl When cross-compiling, do not assume anything.
749 ac_cv_have_sigcontext_hack=no
750 )
751 AC_LANG_RESTORE
752 ])
753 AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
754 [Define if we know a hack to replace siginfo_t->si_addr member.])
755 fi
756
757 dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
758 AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
759 ac_cv_have_skip_instruction, [
760 AC_LANG_SAVE
761 AC_LANG_CPLUSPLUS
762 AC_TRY_RUN([
763 #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
764 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
765 #include "vm_alloc.cpp"
766 #include "sigsegv.cpp"
767 ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
768 dnl When cross-compiling, do not assume anything.
769 ac_cv_have_skip_instruction=no
770 )
771 AC_LANG_RESTORE
772 ]
773 )
774 AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
775 [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
776
777 dnl Can we do Video on SEGV Signals ?
778 CAN_VOSF=no
779 if [[ -n "$sigsegv_recovery" ]]; then
780 CAN_VOSF=yes
781 fi
782
783 dnl A dummy program that returns always true
784 BLESS=/bin/true
785
786 dnl Determine the addressing mode to use
787 if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
788 ADDRESSING_MODE="real"
789 else
790 ADDRESSING_MODE=""
791 AC_MSG_CHECKING([for the addressing mode to use])
792 for am in $ADDRESSING_TEST_ORDER; do
793 case $am in
794 real)
795 dnl Requires ability to mmap() Low Memory globals
796 if [[ "x$ac_cv_can_map_lm$ac_cv_pagezero_hack" = "xnono" ]]; then
797 continue
798 fi
799 dnl Requires VOSF screen updates
800 if [[ "x$CAN_VOSF" = "xno" ]]; then
801 continue
802 fi
803 dnl Real addressing will probably work.
804 ADDRESSING_MODE="real"
805 WANT_VOSF=yes dnl we can use VOSF and we need it actually
806 DEFINES="$DEFINES -DREAL_ADDRESSING"
807 if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
808 BLESS=Darwin/lowmem
809 LDFLAGS="$LDFLAGS -pagezero_size 0x2000"
810 fi
811 break
812 ;;
813 direct)
814 dnl Requires VOSF screen updates
815 if [[ "x$CAN_VOSF" = "xyes" ]]; then
816 ADDRESSING_MODE="direct"
817 WANT_VOSF=yes dnl we can use VOSF and we need it actually
818 DEFINES="$DEFINES -DDIRECT_ADDRESSING"
819 break
820 fi
821 ;;
822 banks)
823 dnl Default addressing mode
824 ADDRESSING_MODE="memory banks"
825 break
826 ;;
827 *)
828 AC_MSG_ERROR([Internal configure.in script error for $am addressing mode])
829 esac
830 done
831 AC_MSG_RESULT($ADDRESSING_MODE)
832 if [[ "x$ADDRESSING_MODE" = "x" ]]; then
833 AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER])
834 ADDRESSING_MODE="memory banks"
835 fi
836 fi
837
838 dnl Banked Memory Addressing mode is not supported by the JIT compiler
839 if [[ "x$WANT_JIT" = "xyes" -a "x$ADDRESSING_MODE" = "xmemory banks" ]]; then
840 AC_MSG_ERROR([Sorry, the JIT Compiler requires Direct Addressing, at least])
841 fi
842
843 dnl Enable VOSF screen updates with this feature is requested and feasible
844 if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
845 AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
846 else
847 WANT_VOSF=no
848 fi
849
850 dnl Check for GAS.
851 HAVE_GAS=no
852 AC_MSG_CHECKING(for GAS .p2align feature)
853 cat >conftest.S << EOF
854 .text
855 .p2align 5
856 EOF
857 if $CC conftest.S -c -o conftest.o >/dev/null 2>&1 ; then HAVE_GAS=yes; fi
858 AC_MSG_RESULT($HAVE_GAS)
859
860 dnl Check for GCC 2.7 or higher.
861 HAVE_GCC27=no
862 AC_MSG_CHECKING(for GCC 2.7 or higher)
863 AC_EGREP_CPP(xyes,
864 [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
865 xyes
866 #endif
867 ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
868
869 dnl Check for GCC 3.0 or higher.
870 HAVE_GCC30=no
871 AC_MSG_CHECKING(for GCC 3.0 or higher)
872 AC_EGREP_CPP(xyes,
873 [#if __GNUC__ >= 3
874 xyes
875 #endif
876 ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
877
878 dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher.
879 dnl Also set "-fno-exceptions" for C++ because exception handling requires
880 dnl the frame pointer.
881 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
882 CFLAGS="$CFLAGS -fomit-frame-pointer"
883 CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -fno-exceptions"
884 fi
885
886 dnl (gb) Do not merge constants since it breaks fpu/fpu_x86.cpp.
887 dnl As of 2001/08/02, this affects the following compilers:
888 dnl Official: probably gcc-3.1 (mainline CVS)
889 dnl Mandrake: gcc-2.96 >= 0.59mdk, gcc-3.0.1 >= 0.1mdk
890 dnl Red Hat : gcc-2.96 >= 89, gcc-3.0 >= 1
891 if [[ "x$HAVE_GCC27" = "xyes" ]]; then
892 SAVED_CXXFLAGS="$CXXFLAGS"
893 CXXFLAGS="$CXXFLAGS -fno-merge-constants"
894 AC_CACHE_CHECK([whether GCC supports constants merging], ac_cv_gcc_constants_merging, [
895 AC_LANG_SAVE
896 AC_LANG_CPLUSPLUS
897 AC_TRY_COMPILE([],[],[ac_cv_gcc_constants_merging=yes],[ac_cv_gcc_constants_merging=no])
898 AC_LANG_RESTORE
899 ])
900 if [[ "x$ac_cv_gcc_constants_merging" != "xyes" ]]; then
901 CXXFLAGS="$SAVED_CXXFLAGS"
902 fi
903 fi
904
905 dnl Select appropriate CPU source and REGPARAM define.
906 ASM_OPTIMIZATIONS=none
907 CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
908
909 dnl (gb) JITSRCS will be emptied later if the JIT is not available
910 dnl Other platforms should define their own set of noflags file variants
911 CAN_JIT=no
912 JITSRCS="compemu1.cpp compemu2.cpp compemu3.cpp compemu4.cpp compemu5.cpp compemu6.cpp compemu7.cpp compemu8.cpp"
913
914 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
915 dnl i386 CPU
916 DEFINES="$DEFINES -DUNALIGNED_PROFITABLE -DREGPARAM=\"__attribute__((regparm(3)))\""
917 if [[ "x$HAVE_GAS" = "xyes" ]]; then
918 ASM_OPTIMIZATIONS=i386
919 DEFINES="$DEFINES -DX86_ASSEMBLY -DOPTIMIZED_FLAGS -DSAHF_SETO_PROFITABLE"
920 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"
921 CAN_JIT=yes
922 fi
923 elif [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_X86_64" = "xyes" ]]; then
924 dnl x86-64 CPU
925 DEFINES="$DEFINES -DUNALIGNED_PROFITABLE"
926 if [[ "x$HAVE_GAS" = "xyes" ]]; then
927 ASM_OPTIMIZATIONS="x86-64"
928 DEFINES="$DEFINES -DX86_64_ASSEMBLY -DOPTIMIZED_FLAGS"
929 fi
930 elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
931 dnl SPARC CPU
932 case "$target_os" in
933 solaris*)
934 AC_MSG_CHECKING(SPARC CPU architecture)
935 SPARC_TYPE=`Solaris/which_sparc`
936 AC_MSG_RESULT($SPARC_TYPE)
937 case "$SPARC_TYPE" in
938 SPARC_V8)
939 ASM_OPTIMIZATIONS="SPARC V8 architecture"
940 DEFINES="$DEFINES -DSPARC_V8_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
941 CFLAGS="$CFLAGS -Wa,-Av8"
942 CXXFLAGS="$CXXFLAGS -Wa,-Av8"
943 ;;
944 SPARC_V9)
945 ASM_OPTIMIZATIONS="SPARC V9 architecture"
946 DEFINES="$DEFINES -DSPARC_V9_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
947 CFLAGS="$CFLAGS -Wa,-Av9"
948 CXXFLAGS="$CXXFLAGS -Wa,-Av9"
949 ;;
950 esac
951 ;;
952 esac
953 elif [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
954 dnl Native m68k, no emulation
955 CPUINCLUDES="-I../native_cpu"
956 CPUSRCS="asm_support.s"
957 fi
958
959 dnl Enable JIT compiler, if possible.
960 if [[ "x$WANT_JIT" = "xyes" -a "x$CAN_JIT" ]]; then
961 JITSRCS="$JITSRCS ../uae_cpu/compiler/compemu_support.cpp ../uae_cpu/compiler/compemu_fpp.cpp compstbl.o cpustbl_nf.o"
962 DEFINES="$DEFINES -DUSE_JIT -DUSE_JIT_FPU"
963
964 if [[ "x$WANT_JIT_DEBUG" = "xyes" ]]; then
965 if [[ "x$WANT_MON" = "xyes" ]]; then
966 DEFINES="$DEFINES -DJIT_DEBUG=1"
967 else
968 AC_MSG_WARN([cxmon not found, ignoring --enable-jit-debug])
969 WANT_JIT_DEBUG=no
970 fi
971 fi
972
973 dnl IEEE core is the only FPU emulator to use with the JIT compiler
974 case $FPE_CORE_TEST_ORDER in
975 ieee*) ;;
976 *) AC_MSG_WARN([Forcing use of the IEEE FPU core, as the JIT compiler supports only this one.]) ;;
977 esac
978 FPE_CORE_TEST_ORDER="ieee"
979 else
980 WANT_JIT=no
981 WANT_JIT_DEBUG=no
982 JITSRCS=""
983 fi
984
985 dnl Utility macro used by next two tests.
986 dnl AC_EXAMINE_OBJECT(C source code,
987 dnl commands examining object file,
988 dnl [commands to run if compile failed]):
989 dnl
990 dnl Compile the source code to an object file; then convert it into a
991 dnl printable representation. All unprintable characters and
992 dnl asterisks (*) are replaced by dots (.). All white space is
993 dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
994 dnl output, but runs of newlines are compressed to a single newline.
995 dnl Finally, line breaks are forcibly inserted so that no line is
996 dnl longer than 80 columns and the file ends with a newline. The
997 dnl result of all this processing is in the file conftest.dmp, which
998 dnl may be examined by the commands in the second argument.
999 dnl
1000 AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
1001 [AC_LANG_SAVE
1002 AC_LANG_C
1003 dnl Next bit cribbed from AC_TRY_COMPILE.
1004 cat > conftest.$ac_ext <<EOF
1005 [#line __oline__ "configure"
1006 #include "confdefs.h"
1007 $1
1008 ]EOF
1009 if AC_TRY_EVAL(ac_compile); then
1010 od -c conftest.o |
1011 sed ['s/^[0-7]*[ ]*/ /
1012 s/\*/./g
1013 s/ \\n/*/g
1014 s/ [0-9][0-9][0-9]/./g
1015 s/ \\[^ ]/./g'] |
1016 tr -d '
1017 ' | tr -s '*' '
1018 ' | fold | sed '$a\
1019 ' > conftest.dmp
1020 $2
1021 ifelse($3, , , else
1022 $3
1023 )dnl
1024 fi
1025 rm -rf conftest*
1026 AC_LANG_RESTORE])
1027
1028 dnl Floating point format probe.
1029 dnl The basic concept is the same as the above: grep the object
1030 dnl file for an interesting string. We have to watch out for
1031 dnl rounding changing the values in the object, however; this is
1032 dnl handled by ignoring the least significant byte of the float.
1033 dnl
1034 dnl Does not know about VAX G-float or C4x idiosyncratic format.
1035 dnl It does know about PDP-10 idiosyncratic format, but this is
1036 dnl not presently supported by GCC. S/390 "binary floating point"
1037 dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
1038 dnl as ASCII?)
1039 dnl
1040 AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
1041 [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
1042 [gcc_AC_EXAMINE_OBJECT(
1043 [/* This will not work unless sizeof(double) == 8. */
1044 extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1045
1046 /* This structure must have no internal padding. */
1047 struct possibility {
1048 char prefix[8];
1049 double candidate;
1050 char postfix[8];
1051 };
1052
1053 #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1054 struct possibility table [] =
1055 {
1056 C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1057 C( 3.53802595280598432000e+18), /* D__float - VAX */
1058 C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1059 C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1060 C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
1061 };],
1062 [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1063 ac_cv_c_float_format='IEEE (big-endian)'
1064 elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1065 ac_cv_c_float_format='IEEE (big-endian)'
1066 elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1067 ac_cv_c_float_format='IEEE (little-endian)'
1068 elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1069 ac_cv_c_float_format='IEEE (little-endian)'
1070 elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1071 ac_cv_c_float_format='VAX D-float'
1072 elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1073 ac_cv_c_float_format='PDP-10'
1074 elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1075 ac_cv_c_float_format='IBM 370 hex'
1076 else
1077 AC_MSG_ERROR(Unknown floating point format)
1078 fi],
1079 [AC_MSG_ERROR(compile failed)])
1080 ])
1081 # IEEE is the default format. If the float endianness isn't the same
1082 # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1083 # (which is a tristate: yes, no, default). This is only an issue with
1084 # IEEE; the other formats are only supported by a few machines each,
1085 # all with the same endianness.
1086 format=IEEE_FLOAT_FORMAT
1087 fbigend=
1088 case $ac_cv_c_float_format in
1089 'IEEE (big-endian)' )
1090 if test $ac_cv_c_bigendian = no; then
1091 fbigend=1
1092 fi
1093 ;;
1094 'IEEE (little-endian)' )
1095 if test $ac_cv_c_bigendian = yes; then
1096 fbigend=0
1097 fi
1098 ;;
1099 'VAX D-float' )
1100 format=VAX_FLOAT_FORMAT
1101 ;;
1102 'PDP-10' )
1103 format=PDP10_FLOAT_FORMAT
1104 ;;
1105 'IBM 370 hex' )
1106 format=IBM_FLOAT_FORMAT
1107 ;;
1108 esac
1109 AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1110 [Define to the floating point format of the host machine.])
1111 if test -n "$fbigend"; then
1112 AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1113 [Define to 1 if the host machine stores floating point numbers in
1114 memory with the word containing the sign bit at the lowest address,
1115 or to 0 if it does it the other way around.
1116
1117 This macro should not be defined if the ordering is the same as for
1118 multi-word integers.])
1119 fi
1120 ])
1121
1122 dnl Select appropriate FPU source.
1123 gcc_AC_C_FLOAT_FORMAT
1124 AC_CHECK_HEADERS(ieee754.h ieeefp.h floatingpoint.h nan.h)
1125
1126 for fpe in $FPE_CORE_TEST_ORDER; do
1127 case $fpe in
1128 ieee)
1129 case $ac_cv_c_float_format in
1130 IEEE*)
1131 FPE_CORE="IEEE fpu core"
1132 DEFINES="$DEFINES -DFPU_IEEE"
1133 FPUSRCS="../uae_cpu/fpu/fpu_ieee.cpp"
1134 dnl Math functions not mandated by C99 standard
1135 AC_CHECK_FUNCS(isnanl isinfl)
1136 dnl Math functions required by C99 standard, but probably not
1137 dnl implemented everywhere. In that case, we fall back to the
1138 dnl regular variant for doubles.
1139 AC_CHECK_FUNCS(logl log10l expl powl fabsl sqrtl)
1140 AC_CHECK_FUNCS(sinl cosl tanl sinhl coshl tanhl)
1141 AC_CHECK_FUNCS(asinl acosl atanl asinhl acoshl atanhl)
1142 AC_CHECK_FUNCS(floorl ceill)
1143 break
1144 ;;
1145 esac
1146 ;;
1147 x86)
1148 if [[ ":$HAVE_GCC27:$HAVE_I386:$HAVE_GAS:" = ":yes:yes:yes:" ]]; then
1149 FPE_CORE="i387 fpu core"
1150 DEFINES="$DEFINES -DFPU_X86"
1151 FPUSRCS="../uae_cpu/fpu/fpu_x86.cpp"
1152 break
1153 fi
1154 ;;
1155 uae)
1156 FPE_CORE="uae fpu core"
1157 DEFINES="$DEFINES -DFPU_UAE"
1158 FPUSRCS="../uae_cpu/fpu/fpu_uae.cpp"
1159 break
1160 ;;
1161 *)
1162 AC_MSG_ERROR([Internal configure.in script error for $fpe fpu core])
1163 ;;
1164 esac
1165 done
1166 if [[ "x$FPE_CORE" = "x" ]]; then
1167 AC_MSG_ERROR([Sorry, no suitable FPU core found in $FPE_CORE_TEST_ORDER])
1168 fi
1169
1170 dnl Check for certain math functions
1171 AC_CHECK_FUNCS(atanh)
1172 AC_CHECK_FUNCS(isnan isinf finite isnormal signbit)
1173
1174 dnl UAE CPU sources for all non-m68k-native architectures.
1175 if [[ "x$WANT_NATIVE_M68K" = "xno" ]]; then
1176 CPUINCLUDES="-I../uae_cpu"
1177 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"
1178 fi
1179
1180 dnl Remove the "-g" option if set for GCC.
1181 if [[ "x$HAVE_GCC27" = "xyes" ]]; then
1182 CFLAGS=`echo $CFLAGS | sed -e 's/-g//g'`
1183 CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g//g'`
1184 fi
1185
1186 dnl Or if we have -IPA (MIPSPro compilers)
1187 if [[ "x$HAVE_IPA" = "xyes" ]]; then
1188 CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1189 CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1190 CXXFLAGS="-LANG:std $CXXFLAGS"
1191 LDFLAGS="$LDFLAGS -O3 -OPT:Olimit=0 -IPA"
1192 fi
1193
1194 dnl Generate Makefile.
1195 AC_SUBST(DEFINES)
1196 AC_SUBST(SYSSRCS)
1197 AC_SUBST(CPUINCLUDES)
1198 AC_SUBST(CPUSRCS)
1199 AC_SUBST(BLESS)
1200 AC_CONFIG_FILES([Makefile])
1201 AC_OUTPUT
1202
1203 dnl Print summary.
1204 echo
1205 echo Basilisk II configuration summary:
1206 echo
1207 echo XFree86 DGA support .................... : $WANT_XF86_DGA
1208 echo XFree86 VidMode support ................ : $WANT_XF86_VIDMODE
1209 echo fbdev DGA support ...................... : $WANT_FBDEV_DGA
1210 echo Enable video on SEGV signals ........... : $WANT_VOSF
1211 echo ESD sound support ...................... : $WANT_ESD
1212 echo GTK user interface ..................... : $WANT_GTK
1213 echo mon debugger support ................... : $WANT_MON
1214 echo Running m68k code natively ............. : $WANT_NATIVE_M68K
1215 echo Use JIT compiler ....................... : $WANT_JIT
1216 echo JIT debug mode ......................... : $WANT_JIT_DEBUG
1217 echo Floating-Point emulation core .......... : $FPE_CORE
1218 echo Assembly optimizations ................. : $ASM_OPTIMIZATIONS
1219 echo Addressing mode ........................ : $ADDRESSING_MODE
1220 echo Bad memory access recovery type ........ : $sigsegv_recovery
1221 echo
1222 echo "Configuration done. Now type \"make\" (or \"gmake\")."