ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.34
Committed: 2004-11-08T21:07:07Z (20 years ago) by gbeauche
Branch: MAIN
Changes since 1.33: +59 -0 lines
Log Message:
Enable 33-bit memory addressing on 64-bit JIT capable platforms (e.g. x86-64).
This is useful to get rid of address offset sign extensions. It uses POSIX
shared memory to create aliased regions, fallback to usual sign-extension
way if shm_open et al. don't work (e.g. no /dev/shm mounted)

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