ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.36
Committed: 2004-11-14T23:24:51Z (20 years ago) by gbeauche
Branch: MAIN
Changes since 1.35: +42 -2 lines
Log Message:
Check for egrep early, as AC_EGREP_CPP wouldn't work correctly otherwise
(e.g. GCC version not detected, likewise for ANSI C headers). Add check
for Windows exceptions support. Some cosmetics for Cygwin.

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