ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.38
Committed: 2004-11-17T00:59:04Z (20 years ago) by gbeauche
Branch: MAIN
Changes since 1.37: +8 -1 lines
Log Message:
Use Windows clipboard code with SDL graphics only. X11 output will use
the X server glue anyway

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 EXTRASYSSRCS="../Windows/BasiliskII.rc"
471 ;;
472 esac
473 dnl SDL overrides
474 if [[ "x$WANT_SDL" = "xyes" ]]; then
475 AC_DEFINE(USE_SDL, 1, [Define to enble SDL support])
476 fi
477 if [[ "x$WANT_SDL_VIDEO" = "xyes" ]]; then
478 AC_DEFINE(USE_SDL_VIDEO, 1, [Define to enable SDL video graphics support])
479 VIDEOSRCS="../SDL/video_sdl.cpp"
480 KEYCODES="../SDL/keycodes"
481 if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then
482 EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/clip_macosx.cpp"
483 else
484 case "$target_os" in
485 cygwin*)
486 EXTRASYSSRCS="$EXTRASYSSRCS ../Windows/clip_windows.cpp"
487 ;;
488 *)
489 EXTRASYSSRCS="$EXTRASYSSRCS ../dummy/clip_dummy.cpp"
490 ;;
491 esac
492 fi
493 else
494 VIDEOSRCS="video_x.cpp"
495 KEYCODES="keycodes"
496 EXTRASYSSRCS="$EXTRASYSSRCS clip_unix.cpp"
497 fi
498 if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; then
499 AC_DEFINE(USE_SDL_AUDIO, 1, [Define to enable SDL audio support])
500 AUDIOSRC="../SDL/audio_sdl.cpp"
501 fi
502
503 dnl Use 68k CPU natively?
504 WANT_NATIVE_M68K=no
505 if [[ "x$HAVE_M68K" = "xyes" -a "x$CAN_NATIVE_M68K" = "xyes" ]]; then
506 AC_DEFINE(ENABLE_NATIVE_M68K, 1, [Define if using native 68k mode.])
507 WANT_NATIVE_M68K=yes
508 fi
509
510 if [[ "x$HAVE_PTHREADS" = "xno" ]]; then
511 dnl Serial, ethernet and audio support needs pthreads
512 AC_MSG_WARN([You don't have pthreads, disabling serial, ethernet and audio support.])
513 SERIALSRC=../dummy/serial_dummy.cpp
514 ETHERSRC=../dummy/ether_dummy.cpp
515 AUDIOSRC=../dummy/audio_dummy.cpp
516 fi
517 SYSSRCS="$VIDEOSRCS $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS"
518
519 dnl Define a macro that translates a yesno-variable into a C macro definition
520 dnl to be put into the config.h file
521 dnl $1 -- the macro to define
522 dnl $2 -- the value to translate
523 dnl $3 -- template name
524 AC_DEFUN(AC_TRANSLATE_DEFINE, [
525 if [[ "x$2" = "xyes" -o "x$2" = "xguessing yes" ]]; then
526 AC_DEFINE($1, 1, $3)
527 fi
528 ])
529
530 dnl Check that the host supports TUN/TAP devices
531 AC_CACHE_CHECK([whether TUN/TAP is supported],
532 ac_cv_tun_tap_support, [
533 AC_TRY_COMPILE([
534 #if defined(HAVE_LINUX_IF_H) && defined(HAVE_LINUX_IF_TUN_H)
535 #include <linux/if.h>
536 #include <linux/if_tun.h>
537 #endif
538 #if defined(HAVE_NET_IF_H) && defined(HAVE_NET_IF_TUN_H)
539 #include <net/if.h>
540 #include <net/if_tun.h>
541 #endif
542 ], [
543 struct ifreq ifr;
544 memset(&ifr, 0, sizeof(ifr));
545 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
546 ],
547 ac_cv_tun_tap_support=yes, ac_cv_tun_tap_support=no
548 )
549 ])
550 AC_TRANSLATE_DEFINE(ENABLE_TUNTAP, "$ac_cv_tun_tap_support",
551 [Define if your system supports TUN/TAP devices.])
552
553 dnl Various checks if the system supports vm_allocate() and the like functions.
554 have_mach_vm=no
555 if [[ "x$ac_cv_func_vm_allocate" = "xyes" -a "x$ac_cv_func_vm_deallocate" = "xyes" -a \
556 "x$ac_cv_func_vm_protect" = "xyes" ]]; then
557 have_mach_vm=yes
558 fi
559 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
560 [Define if your system has a working vm_allocate()-based memory allocator.])
561
562 dnl Check that vm_allocate(), vm_protect() work
563 if [[ "x$have_mach_vm" = "xyes" ]]; then
564
565 AC_CACHE_CHECK([whether vm_protect works],
566 ac_cv_vm_protect_works, [
567 AC_LANG_SAVE
568 AC_LANG_CPLUSPLUS
569 ac_cv_vm_protect_works=yes
570 dnl First the tests that should segfault
571 for test_def in NONE_READ NONE_WRITE READ_WRITE; do
572 AC_TRY_RUN([
573 #define CONFIGURE_TEST_VM_MAP
574 #define TEST_VM_PROT_$test_def
575 #include "vm_alloc.cpp"
576 ], ac_cv_vm_protect_works=no, rm -f core,
577 dnl When cross-compiling, do not assume anything
578 ac_cv_vm_protect_works="guessing no"
579 )
580 done
581 AC_TRY_RUN([
582 #define CONFIGURE_TEST_VM_MAP
583 #define TEST_VM_PROT_RDWR_WRITE
584 #include "vm_alloc.cpp"
585 ], , ac_cv_vm_protect_works=no,
586 dnl When cross-compiling, do not assume anything
587 ac_cv_vm_protect_works="guessing no"
588 )
589 AC_LANG_RESTORE
590 ]
591 )
592
593 dnl Remove support for vm_allocate() if vm_protect() does not work
594 if [[ "x$have_mach_vm" = "xyes" ]]; then
595 case $ac_cv_vm_protect_works in
596 *yes) have_mach_vm=yes;;
597 *no) have_mach_vm=no;;
598 esac
599 fi
600 AC_TRANSLATE_DEFINE(HAVE_MACH_VM, "$have_mach_vm",
601 [Define if your system has a working vm_allocate()-based memory allocator.])
602
603 fi dnl HAVE_MACH_VM
604
605 dnl Various checks if the system supports mmap() and the like functions.
606 dnl ... and Mach memory allocators are not supported
607 have_mmap_vm=no
608 if [[ "x$ac_cv_func_mmap" = "xyes" -a "x$ac_cv_func_munmap" = "xyes" -a \
609 "x$ac_cv_func_mprotect" = "xyes" ]]; then
610 if [[ "x$have_mach_vm" = "xno" ]]; then
611 have_mmap_vm=yes
612 fi
613 fi
614 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, "$have_mmap_vm",
615 [Define if your system has a working mmap()-based memory allocator.])
616
617 dnl Check that mmap() and associated functions work.
618 if [[ "x$have_mmap_vm" = "xyes" ]]; then
619
620 dnl Check if we have a working anonymous mmap()
621 AC_CACHE_CHECK([whether mmap supports MAP_ANON],
622 ac_cv_mmap_anon, [
623 AC_LANG_SAVE
624 AC_LANG_CPLUSPLUS
625 AC_TRY_RUN([
626 #define HAVE_MMAP_ANON
627 #define CONFIGURE_TEST_VM_MAP
628 #define TEST_VM_MMAP_ANON
629 #include "vm_alloc.cpp"
630 ], ac_cv_mmap_anon=yes, ac_cv_mmap_anon=no,
631 dnl When cross-compiling, do not assume anything.
632 ac_cv_mmap_anon="guessing no"
633 )
634 AC_LANG_RESTORE
635 ]
636 )
637 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANON, "$ac_cv_mmap_anon",
638 [Define if <sys/mman.h> defines MAP_ANON and mmap()'ing with MAP_ANON works.])
639
640 AC_CACHE_CHECK([whether mmap supports MAP_ANONYMOUS],
641 ac_cv_mmap_anonymous, [
642 AC_LANG_SAVE
643 AC_LANG_CPLUSPLUS
644 AC_TRY_RUN([
645 #define HAVE_MMAP_ANONYMOUS
646 #define CONFIGURE_TEST_VM_MAP
647 #define TEST_VM_MMAP_ANON
648 #include "vm_alloc.cpp"
649 ], ac_cv_mmap_anonymous=yes, ac_cv_mmap_anonymous=no,
650 dnl When cross-compiling, do not assume anything.
651 ac_cv_mmap_anonymous="guessing no"
652 )
653 AC_LANG_RESTORE
654 ]
655 )
656 AC_TRANSLATE_DEFINE(HAVE_MMAP_ANONYMOUS, "$ac_cv_mmap_anonymous",
657 [Define if <sys/mman.h> defines MAP_ANONYMOUS and mmap()'ing with MAP_ANONYMOUS works.])
658
659 AC_CACHE_CHECK([whether mprotect works],
660 ac_cv_mprotect_works, [
661 AC_LANG_SAVE
662 AC_LANG_CPLUSPLUS
663 ac_cv_mprotect_works=yes
664 dnl First the tests that should segfault
665 for test_def in NONE_READ NONE_WRITE READ_WRITE; do
666 AC_TRY_RUN([
667 #define CONFIGURE_TEST_VM_MAP
668 #define TEST_VM_PROT_$test_def
669 #include "vm_alloc.cpp"
670 ], ac_cv_mprotect_works=no, rm -f core,
671 dnl When cross-compiling, do not assume anything
672 ac_cv_mprotect_works="guessing no"
673 )
674 done
675 AC_TRY_RUN([
676 #define CONFIGURE_TEST_VM_MAP
677 #define TEST_VM_PROT_RDWR_WRITE
678 #include "vm_alloc.cpp"
679 ], , ac_cv_mprotect_works=no,
680 dnl When cross-compiling, do not assume anything
681 ac_cv_mprotect_works="guessing no"
682 )
683 AC_LANG_RESTORE
684 ]
685 )
686
687 dnl Remove support for mmap() if mprotect() does not work
688 if [[ "x$have_mmap_vm" = "xyes" ]]; then
689 case $ac_cv_mprotect_works in
690 *yes) have_mmap_vm=yes;;
691 *no) have_mmap_vm=no;;
692 esac
693 fi
694 AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_mmap_vm,
695 [Define if your system has a working mmap()-based memory allocator.])
696
697 fi dnl HAVE_MMAP_VM
698
699 dnl Check if we can modify the __PAGEZERO segment for use as Low Memory
700 AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x2000],
701 ac_cv_pagezero_hack, [
702 ac_cv_pagezero_hack=no
703 if AC_TRY_COMMAND([Darwin/testlmem.sh 0x2000]); then
704 ac_cv_pagezero_hack=yes
705 dnl might as well skip the test for mmap-able low memory
706 ac_cv_can_map_lm=no
707 fi
708 ])
709 AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack",
710 [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.])
711
712 dnl Check if we can mmap 0x2000 bytes from 0x0000
713 AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x2000],
714 ac_cv_can_map_lm, [
715 AC_LANG_SAVE
716 AC_LANG_CPLUSPLUS
717 AC_TRY_RUN([
718 #include "vm_alloc.cpp"
719 int main(void) { /* returns 0 if we could map the lowmem globals */
720 volatile char * lm = 0;
721 if (vm_init() < 0) exit(1);
722 if (vm_acquire_fixed(0, 0x2000) < 0) exit(1);
723 lm[0] = 'z';
724 if (vm_release((char *)lm, 0x2000) < 0) exit(1);
725 vm_exit(); exit(0);
726 }
727 ], ac_cv_can_map_lm=yes, ac_cv_can_map_lm=no,
728 dnl When cross-compiling, do not assume anything.
729 ac_cv_can_map_lm="guessing no"
730 )
731 AC_LANG_RESTORE
732 ]
733 )
734
735 dnl Check if we have POSIX shared memory support
736 AC_CACHE_CHECK([whether POSIX shared memory is working],
737 ac_cv_have_posix_shm, [
738 AC_LANG_SAVE
739 AC_LANG_CPLUSPLUS
740 AC_TRY_RUN([
741 #define HAVE_POSIX_SHM
742 #include "vm_alloc.cpp"
743 int main(void) { /* returns 0 if we have working POSIX shm */
744 if (vm_init() < 0) exit(2);
745 char *m1 = (char *)vm_acquire(32768, VM_MAP_DEFAULT | VM_MAP_33BIT);
746 if (m1 == VM_MAP_FAILED) exit(3);
747 vm_exit(); exit(0);
748 }
749 ], ac_cv_have_posix_shm=yes, ac_cv_have_posix_shm=no,
750 dnl When cross-compiling, do not assume anything.
751 ac_cv_have_posix_shm="guessing no"
752 )
753 AC_LANG_RESTORE
754 ]
755 )
756 AC_TRANSLATE_DEFINE(HAVE_POSIX_SHM, "$ac_cv_have_posix_shm",
757 [Define if your system supports POSIX shared memory.])
758
759 dnl Check if we have working 33-bit memory addressing
760 AC_CACHE_CHECK([whether 33-bit memory addressing is working],
761 ac_cv_have_33bit_addressing, [
762 AC_LANG_SAVE
763 AC_LANG_CPLUSPLUS
764 AC_TRY_RUN([
765 #define USE_33BIT_ADDRESSING 1
766 #include "vm_alloc.cpp"
767 int main(void) { /* returns 0 if we have working 33-bit addressing */
768 if (sizeof(void *) < 8) exit(1);
769 if (vm_init() < 0) exit(2);
770 char *m1 = (char *)vm_acquire(32768, VM_MAP_DEFAULT | VM_MAP_33BIT);
771 if (m1 == VM_MAP_FAILED) exit(3);
772 char *m2 = m1 + (1L << 32);
773 m1[0] = 0x12; if (m2[0] != 0x12) exit(4);
774 m2[0] = 0x34; if (m1[0] != 0x34) exit(5);
775 vm_exit(); exit(0);
776 }
777 ], ac_cv_have_33bit_addressing=yes, ac_cv_have_33bit_addressing=no,
778 dnl When cross-compiling, do not assume anything.
779 ac_cv_have_33bit_addressing="guessing no"
780 )
781 AC_LANG_RESTORE
782 ]
783 )
784
785 dnl Check signal handlers need to be reinstalled
786 AC_CACHE_CHECK([whether signal handlers need to be reinstalled],
787 ac_cv_signal_need_reinstall, [
788 AC_LANG_SAVE
789 AC_LANG_CPLUSPLUS
790 AC_TRY_RUN([
791 #include <stdlib.h>
792 #ifdef HAVE_UNISTD_H
793 #include <unistd.h>
794 #endif
795 #include <signal.h>
796 static int handled_signal = 0;
797 RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
798 int main(void) { /* returns 0 if signals need not to be reinstalled */
799 signal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
800 exit(handled_signal == 2);
801 }
802 ], ac_cv_signal_need_reinstall=yes, ac_cv_signal_need_reinstall=no,
803 dnl When cross-compiling, do not assume anything.
804 ac_cv_signal_need_reinstall="guessing yes"
805 )
806 AC_LANG_RESTORE
807 ]
808 )
809 AC_TRANSLATE_DEFINE(SIGNAL_NEED_REINSTALL, "$ac_cv_signal_need_reinstall",
810 [Define if your system requires signals to be reinstalled.])
811
812 dnl Check if sigaction handlers need to be reinstalled
813 AC_CACHE_CHECK([whether sigaction handlers need to be reinstalled],
814 ac_cv_sigaction_need_reinstall, [
815 AC_LANG_SAVE
816 AC_LANG_CPLUSPLUS
817 AC_TRY_RUN([
818 #include <stdlib.h>
819 #ifdef HAVE_UNISTD_H
820 #include <unistd.h>
821 #endif
822 #include <signal.h>
823 static int handled_signal = 0;
824 RETSIGTYPE sigusr1_handler(int) { handled_signal++; }
825 typedef RETSIGTYPE (*signal_handler)(int);
826 static signal_handler mysignal(int sig, signal_handler handler) {
827 struct sigaction old_sa;
828 struct sigaction new_sa;
829 new_sa.sa_handler = handler;
830 return ((sigaction(sig,&new_sa,&old_sa) < 0) ? SIG_IGN : old_sa.sa_handler);
831 }
832 int main(void) { /* returns 0 if signals need not to be reinstalled */
833 mysignal(SIGUSR1, sigusr1_handler); raise(SIGUSR1); raise(SIGUSR1);
834 exit(handled_signal == 2);
835 }
836 ], ac_cv_sigaction_need_reinstall=yes, ac_cv_sigaction_need_reinstall=no,
837 dnl When cross-compiling, do not assume anything.
838 ac_cv_sigaction_need_reinstall="guessing yes"
839 )
840 AC_LANG_RESTORE
841 ]
842 )
843 AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall",
844 [Define if your system requires sigactions to be reinstalled.])
845
846 dnl Check if Mach exceptions supported.
847 AC_CACHE_CHECK([whether your system supports Mach exceptions],
848 ac_cv_have_mach_exceptions, [
849 AC_LANG_SAVE
850 AC_LANG_CPLUSPLUS
851 AC_TRY_RUN([
852 #define HAVE_MACH_EXCEPTIONS 1
853 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
854 #include "vm_alloc.cpp"
855 #include "sigsegv.cpp"
856 ], [
857 sigsegv_recovery=mach
858 ac_cv_have_mach_exceptions=yes
859 ],
860 ac_cv_have_mach_exceptions=no,
861 dnl When cross-compiling, do not assume anything.
862 ac_cv_have_mach_exceptions=no
863 )
864 AC_LANG_RESTORE
865 ]
866 )
867 AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions",
868 [Define if your system supports Mach exceptions.])
869
870 dnl Check if Windows exceptions are supported.
871 AC_CACHE_CHECK([whether your system supports Windows exceptions],
872 ac_cv_have_win32_exceptions, [
873 AC_LANG_SAVE
874 AC_LANG_CPLUSPLUS
875 AC_TRY_RUN([
876 #define HAVE_WIN32_EXCEPTIONS 1
877 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
878 #include "vm_alloc.cpp"
879 #include "sigsegv.cpp"
880 ], [
881 sigsegv_recovery=win32
882 ac_cv_have_win32_exceptions=yes
883 ],
884 ac_cv_have_win32_exceptions=no,
885 dnl When cross-compiling, do not assume anything.
886 ac_cv_have_win32_exceptions=no
887 )
888 AC_LANG_RESTORE
889 ]
890 )
891 AC_TRANSLATE_DEFINE(HAVE_WIN32_EXCEPTIONS, "$ac_cv_have_win32_exceptions",
892 [Define if your system supports Windows exceptions.])
893
894 dnl Otherwise, check if extended signals are supported.
895 if [[ -z "$sigsegv_recovery" ]]; then
896 AC_CACHE_CHECK([whether your system supports extended signal handlers],
897 ac_cv_have_extended_signals, [
898 AC_LANG_SAVE
899 AC_LANG_CPLUSPLUS
900 AC_TRY_RUN([
901 #define HAVE_SIGINFO_T 1
902 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
903 #include "vm_alloc.cpp"
904 #include "sigsegv.cpp"
905 ], [
906 sigsegv_recovery=siginfo
907 ac_cv_have_extended_signals=yes
908 ],
909 ac_cv_have_extended_signals=no,
910 dnl When cross-compiling, do not assume anything.
911 ac_cv_have_extended_signals=no
912 )
913 AC_LANG_RESTORE
914 ]
915 )
916 AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals",
917 [Define if your system support extended signals.])
918 fi
919
920 dnl Otherwise, check for subterfuges.
921 if [[ -z "$sigsegv_recovery" ]]; then
922 AC_CACHE_CHECK([whether we then have a subterfuge for your system],
923 ac_cv_have_sigcontext_hack, [
924 AC_LANG_SAVE
925 AC_LANG_CPLUSPLUS
926 AC_TRY_RUN([
927 #define HAVE_SIGCONTEXT_SUBTERFUGE 1
928 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
929 #include "vm_alloc.cpp"
930 #include "sigsegv.cpp"
931 ], [
932 sigsegv_recovery=sigcontext
933 ac_cv_have_sigcontext_hack=yes
934 ],
935 ac_cv_have_sigcontext_hack=no,
936 dnl When cross-compiling, do not assume anything.
937 ac_cv_have_sigcontext_hack=no
938 )
939 AC_LANG_RESTORE
940 ])
941 AC_TRANSLATE_DEFINE(HAVE_SIGCONTEXT_SUBTERFUGE, "$ac_cv_have_sigcontext_hack",
942 [Define if we know a hack to replace siginfo_t->si_addr member.])
943 fi
944
945 dnl Check if we can ignore the fault (instruction skipping in SIGSEGV handler)
946 AC_CACHE_CHECK([whether we can skip instruction in SIGSEGV handler],
947 ac_cv_have_skip_instruction, [
948 AC_LANG_SAVE
949 AC_LANG_CPLUSPLUS
950 AC_TRY_RUN([
951 #define HAVE_SIGSEGV_SKIP_INSTRUCTION 1
952 #define CONFIGURE_TEST_SIGSEGV_RECOVERY
953 #include "vm_alloc.cpp"
954 #include "sigsegv.cpp"
955 ], ac_cv_have_skip_instruction=yes, ac_cv_have_skip_instruction=no,
956 dnl When cross-compiling, do not assume anything.
957 ac_cv_have_skip_instruction=no
958 )
959 AC_LANG_RESTORE
960 ]
961 )
962 AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_INSTRUCTION, "$ac_cv_have_skip_instruction",
963 [Define if we can ignore the fault (instruction skipping in SIGSEGV handler).])
964
965 dnl Can we do Video on SEGV Signals ?
966 CAN_VOSF=no
967 if [[ -n "$sigsegv_recovery" ]]; then
968 CAN_VOSF=yes
969 fi
970
971 dnl A dummy program that returns always true
972 AC_PATH_PROG([BLESS], "true")
973
974 dnl Determine the addressing mode to use
975 if [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
976 ADDRESSING_MODE="real"
977 else
978 ADDRESSING_MODE=""
979 AC_MSG_CHECKING([for the addressing mode to use])
980 for am in $ADDRESSING_TEST_ORDER; do
981 case $am in
982 real)
983 dnl Requires ability to mmap() Low Memory globals
984 if [[ "x$ac_cv_can_map_lm$ac_cv_pagezero_hack" = "xnono" ]]; then
985 continue
986 fi
987 dnl Requires VOSF screen updates
988 if [[ "x$CAN_VOSF" = "xno" ]]; then
989 continue
990 fi
991 dnl Real addressing will probably work.
992 ADDRESSING_MODE="real"
993 WANT_VOSF=yes dnl we can use VOSF and we need it actually
994 DEFINES="$DEFINES -DREAL_ADDRESSING"
995 if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then
996 BLESS=Darwin/lowmem
997 LDFLAGS="$LDFLAGS -pagezero_size 0x2000"
998 fi
999 break
1000 ;;
1001 direct)
1002 dnl Requires VOSF screen updates
1003 if [[ "x$CAN_VOSF" = "xyes" ]]; then
1004 ADDRESSING_MODE="direct"
1005 WANT_VOSF=yes dnl we can use VOSF and we need it actually
1006 DEFINES="$DEFINES -DDIRECT_ADDRESSING"
1007 break
1008 fi
1009 ;;
1010 banks)
1011 dnl Default addressing mode
1012 ADDRESSING_MODE="memory banks"
1013 break
1014 ;;
1015 *)
1016 AC_MSG_ERROR([Internal configure.in script error for $am addressing mode])
1017 esac
1018 done
1019 AC_MSG_RESULT($ADDRESSING_MODE)
1020 if [[ "x$ADDRESSING_MODE" = "x" ]]; then
1021 AC_MSG_WARN([Sorry, no suitable addressing mode in $ADDRESSING_TEST_ORDER])
1022 ADDRESSING_MODE="memory banks"
1023 fi
1024 fi
1025
1026 dnl Banked Memory Addressing mode is not supported by the JIT compiler
1027 if [[ "x$WANT_JIT" = "xyes" -a "x$ADDRESSING_MODE" = "xmemory banks" ]]; then
1028 AC_MSG_ERROR([Sorry, the JIT Compiler requires Direct Addressing, at least])
1029 fi
1030
1031 dnl Enable VOSF screen updates with this feature is requested and feasible
1032 if [[ "x$WANT_VOSF" = "xyes" -a "x$CAN_VOSF" = "xyes" ]]; then
1033 AC_DEFINE(ENABLE_VOSF, 1, [Define if using video enabled on SEGV signals.])
1034 else
1035 WANT_VOSF=no
1036 fi
1037
1038 dnl Check for GAS.
1039 HAVE_GAS=no
1040 AC_MSG_CHECKING(for GAS .p2align feature)
1041 cat >conftest.S << EOF
1042 .text
1043 .p2align 5
1044 EOF
1045 if $CC conftest.S -c -o conftest.o >/dev/null 2>&1 ; then HAVE_GAS=yes; fi
1046 AC_MSG_RESULT($HAVE_GAS)
1047
1048 dnl Check for GCC 2.7 or higher.
1049 HAVE_GCC27=no
1050 AC_MSG_CHECKING(for GCC 2.7 or higher)
1051 AC_EGREP_CPP(xyes,
1052 [#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5
1053 xyes
1054 #endif
1055 ], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no))
1056
1057 dnl Check for GCC 3.0 or higher.
1058 HAVE_GCC30=no
1059 AC_MSG_CHECKING(for GCC 3.0 or higher)
1060 AC_EGREP_CPP(xyes,
1061 [#if __GNUC__ >= 3
1062 xyes
1063 #endif
1064 ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no))
1065
1066 dnl Set "-fomit-frame-pointer" on i386 GCC 2.7 or higher.
1067 dnl Also set "-fno-exceptions" for C++ because exception handling requires
1068 dnl the frame pointer.
1069 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
1070 CFLAGS="$CFLAGS -fomit-frame-pointer"
1071 CXXFLAGS="$CXXFLAGS -fomit-frame-pointer -fno-exceptions"
1072 fi
1073
1074 dnl (gb) Do not merge constants since it breaks fpu/fpu_x86.cpp.
1075 dnl As of 2001/08/02, this affects the following compilers:
1076 dnl Official: probably gcc-3.1 (mainline CVS)
1077 dnl Mandrake: gcc-2.96 >= 0.59mdk, gcc-3.0.1 >= 0.1mdk
1078 dnl Red Hat : gcc-2.96 >= 89, gcc-3.0 >= 1
1079 if [[ "x$HAVE_GCC27" = "xyes" ]]; then
1080 SAVED_CXXFLAGS="$CXXFLAGS"
1081 CXXFLAGS="$CXXFLAGS -fno-merge-constants"
1082 AC_CACHE_CHECK([whether GCC supports constants merging], ac_cv_gcc_constants_merging, [
1083 AC_LANG_SAVE
1084 AC_LANG_CPLUSPLUS
1085 AC_TRY_COMPILE([],[],[ac_cv_gcc_constants_merging=yes],[ac_cv_gcc_constants_merging=no])
1086 AC_LANG_RESTORE
1087 ])
1088 if [[ "x$ac_cv_gcc_constants_merging" != "xyes" ]]; then
1089 CXXFLAGS="$SAVED_CXXFLAGS"
1090 fi
1091 fi
1092
1093 dnl Store motion was introduced in 3.3-hammer branch and any gcc >= 3.4
1094 dnl However, there are some corner cases exposed on x86-64
1095 if [[ "x$HAVE_GCC27" = "xyes" ]]; then
1096 SAVED_CXXFLAGS="$CXXFLAGS"
1097 CXXFLAGS="$CXXFLAGS -fno-gcse-sm"
1098 AC_CACHE_CHECK([whether GCC supports store motion], ac_cv_gcc_store_motion, [
1099 AC_LANG_SAVE
1100 AC_LANG_CPLUSPLUS
1101 AC_TRY_COMPILE([],[],[ac_cv_gcc_store_motion=yes],[ac_cv_gcc_store_motion=no])
1102 AC_LANG_RESTORE
1103 ])
1104 if [[ "x$ac_cv_gcc_store_motion" != "xyes" ]]; then
1105 CXXFLAGS="$SAVED_CXXFLAGS"
1106 fi
1107 fi
1108
1109 dnl Select appropriate CPU source and REGPARAM define.
1110 ASM_OPTIMIZATIONS=none
1111 CPUSRCS="cpuemu1.cpp cpuemu2.cpp cpuemu3.cpp cpuemu4.cpp cpuemu5.cpp cpuemu6.cpp cpuemu7.cpp cpuemu8.cpp"
1112
1113 dnl (gb) JITSRCS will be emptied later if the JIT is not available
1114 dnl Other platforms should define their own set of noflags file variants
1115 CAN_JIT=no
1116 JITSRCS="compemu1.cpp compemu2.cpp compemu3.cpp compemu4.cpp compemu5.cpp compemu6.cpp compemu7.cpp compemu8.cpp"
1117
1118 if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_I386" = "xyes" ]]; then
1119 dnl i386 CPU
1120 DEFINES="$DEFINES -DUNALIGNED_PROFITABLE -DREGPARAM=\"__attribute__((regparm(3)))\""
1121 if [[ "x$HAVE_GAS" = "xyes" ]]; then
1122 ASM_OPTIMIZATIONS=i386
1123 DEFINES="$DEFINES -DX86_ASSEMBLY -DOPTIMIZED_FLAGS -DSAHF_SETO_PROFITABLE"
1124 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"
1125 CAN_JIT=yes
1126 fi
1127 elif [[ "x$HAVE_GCC30" = "xyes" -a "x$HAVE_X86_64" = "xyes" ]]; then
1128 dnl x86-64 CPU
1129 DEFINES="$DEFINES -DUNALIGNED_PROFITABLE"
1130 if [[ "x$HAVE_GAS" = "xyes" ]]; then
1131 ASM_OPTIMIZATIONS="x86-64"
1132 DEFINES="$DEFINES -DX86_64_ASSEMBLY -DOPTIMIZED_FLAGS"
1133 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"
1134 CAN_JIT=yes
1135 WANT_33BIT_ADDRESSING=yes
1136 fi
1137 elif [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_SPARC" = "xyes" -a "x$HAVE_GAS" = "xyes" ]]; then
1138 dnl SPARC CPU
1139 case "$target_os" in
1140 solaris*)
1141 AC_MSG_CHECKING(SPARC CPU architecture)
1142 SPARC_TYPE=`Solaris/which_sparc`
1143 AC_MSG_RESULT($SPARC_TYPE)
1144 case "$SPARC_TYPE" in
1145 SPARC_V8)
1146 ASM_OPTIMIZATIONS="SPARC V8 architecture"
1147 DEFINES="$DEFINES -DSPARC_V8_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
1148 CFLAGS="$CFLAGS -Wa,-Av8"
1149 CXXFLAGS="$CXXFLAGS -Wa,-Av8"
1150 ;;
1151 SPARC_V9)
1152 ASM_OPTIMIZATIONS="SPARC V9 architecture"
1153 DEFINES="$DEFINES -DSPARC_V9_ASSEMBLY" dnl -DOPTIMIZED_FLAGS"
1154 CFLAGS="$CFLAGS -Wa,-Av9"
1155 CXXFLAGS="$CXXFLAGS -Wa,-Av9"
1156 ;;
1157 esac
1158 ;;
1159 esac
1160 elif [[ "x$WANT_NATIVE_M68K" = "xyes" ]]; then
1161 dnl Native m68k, no emulation
1162 CPUINCLUDES="-I../native_cpu"
1163 CPUSRCS="asm_support.s"
1164 fi
1165
1166 dnl Enable JIT compiler, if possible.
1167 if [[ "x$WANT_JIT" = "xyes" -a "x$CAN_JIT" ]]; then
1168 JITSRCS="$JITSRCS ../uae_cpu/compiler/compemu_support.cpp ../uae_cpu/compiler/compemu_fpp.cpp compstbl.o cpustbl_nf.o"
1169 DEFINES="$DEFINES -DUSE_JIT -DUSE_JIT_FPU"
1170
1171 if [[ "x$WANT_JIT_DEBUG" = "xyes" ]]; then
1172 if [[ "x$WANT_MON" = "xyes" ]]; then
1173 DEFINES="$DEFINES -DJIT_DEBUG=1"
1174 else
1175 AC_MSG_WARN([cxmon not found, ignoring --enable-jit-debug])
1176 WANT_JIT_DEBUG=no
1177 fi
1178 fi
1179
1180 dnl IEEE core is the only FPU emulator to use with the JIT compiler
1181 case $FPE_CORE_TEST_ORDER in
1182 ieee*) ;;
1183 *) AC_MSG_WARN([Forcing use of the IEEE FPU core, as the JIT compiler supports only this one.]) ;;
1184 esac
1185 FPE_CORE_TEST_ORDER="ieee"
1186 else
1187 WANT_JIT=no
1188 WANT_JIT_DEBUG=no
1189 JITSRCS=""
1190 fi
1191
1192 dnl Use 33-bit memory addressing?
1193 if [[ "$ac_cv_have_33bit_addressing:$WANT_33BIT_ADDRESSING" = "yes:yes" ]]; then
1194 use_33bit_addressing=yes
1195 fi
1196 AC_TRANSLATE_DEFINE(USE_33BIT_ADDRESSING, "$use_33bit_addressing",
1197 [Define to use 33-bit memory addressing on 64-bit JIT capable systems.])
1198
1199 dnl Utility macro used by next two tests.
1200 dnl AC_EXAMINE_OBJECT(C source code,
1201 dnl commands examining object file,
1202 dnl [commands to run if compile failed]):
1203 dnl
1204 dnl Compile the source code to an object file; then convert it into a
1205 dnl printable representation. All unprintable characters and
1206 dnl asterisks (*) are replaced by dots (.). All white space is
1207 dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the
1208 dnl output, but runs of newlines are compressed to a single newline.
1209 dnl Finally, line breaks are forcibly inserted so that no line is
1210 dnl longer than 80 columns and the file ends with a newline. The
1211 dnl result of all this processing is in the file conftest.dmp, which
1212 dnl may be examined by the commands in the second argument.
1213 dnl
1214 AC_DEFUN([gcc_AC_EXAMINE_OBJECT],
1215 [AC_LANG_SAVE
1216 AC_LANG_C
1217 dnl Next bit cribbed from AC_TRY_COMPILE.
1218 cat > conftest.$ac_ext <<EOF
1219 [#line __oline__ "configure"
1220 #include "confdefs.h"
1221 $1
1222 ]EOF
1223 if AC_TRY_EVAL(ac_compile); then
1224 od -c conftest.o |
1225 sed ['s/^[0-7]*[ ]*/ /
1226 s/\*/./g
1227 s/ \\n/*/g
1228 s/ [0-9][0-9][0-9]/./g
1229 s/ \\[^ ]/./g'] |
1230 tr -d '
1231 ' | tr -s '*' '
1232 ' | fold | sed '$a\
1233 ' > conftest.dmp
1234 $2
1235 ifelse($3, , , else
1236 $3
1237 )dnl
1238 fi
1239 rm -rf conftest*
1240 AC_LANG_RESTORE])
1241
1242 dnl Floating point format probe.
1243 dnl The basic concept is the same as the above: grep the object
1244 dnl file for an interesting string. We have to watch out for
1245 dnl rounding changing the values in the object, however; this is
1246 dnl handled by ignoring the least significant byte of the float.
1247 dnl
1248 dnl Does not know about VAX G-float or C4x idiosyncratic format.
1249 dnl It does know about PDP-10 idiosyncratic format, but this is
1250 dnl not presently supported by GCC. S/390 "binary floating point"
1251 dnl is in fact IEEE (but maybe we should have that in EBCDIC as well
1252 dnl as ASCII?)
1253 dnl
1254 AC_DEFUN([gcc_AC_C_FLOAT_FORMAT],
1255 [AC_CACHE_CHECK(floating point format, ac_cv_c_float_format,
1256 [gcc_AC_EXAMINE_OBJECT(
1257 [/* This will not work unless sizeof(double) == 8. */
1258 extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];
1259
1260 /* This structure must have no internal padding. */
1261 struct possibility {
1262 char prefix[8];
1263 double candidate;
1264 char postfix[8];
1265 };
1266
1267 #define C(cand) { "\nformat:", cand, ":tamrof\n" }
1268 struct possibility table [] =
1269 {
1270 C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
1271 C( 3.53802595280598432000e+18), /* D__float - VAX */
1272 C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
1273 C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
1274 C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */
1275 };],
1276 [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1277 ac_cv_c_float_format='IEEE (big-endian)'
1278 elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then
1279 ac_cv_c_float_format='IEEE (big-endian)'
1280 elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then
1281 ac_cv_c_float_format='IEEE (little-endian)'
1282 elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then
1283 ac_cv_c_float_format='IEEE (little-endian)'
1284 elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then
1285 ac_cv_c_float_format='VAX D-float'
1286 elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then
1287 ac_cv_c_float_format='PDP-10'
1288 elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then
1289 ac_cv_c_float_format='IBM 370 hex'
1290 else
1291 AC_MSG_ERROR(Unknown floating point format)
1292 fi],
1293 [AC_MSG_ERROR(compile failed)])
1294 ])
1295 # IEEE is the default format. If the float endianness isn't the same
1296 # as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN
1297 # (which is a tristate: yes, no, default). This is only an issue with
1298 # IEEE; the other formats are only supported by a few machines each,
1299 # all with the same endianness.
1300 format=IEEE_FLOAT_FORMAT
1301 fbigend=
1302 case $ac_cv_c_float_format in
1303 'IEEE (big-endian)' )
1304 if test $ac_cv_c_bigendian = no; then
1305 fbigend=1
1306 fi
1307 ;;
1308 'IEEE (little-endian)' )
1309 if test $ac_cv_c_bigendian = yes; then
1310 fbigend=0
1311 fi
1312 ;;
1313 'VAX D-float' )
1314 format=VAX_FLOAT_FORMAT
1315 ;;
1316 'PDP-10' )
1317 format=PDP10_FLOAT_FORMAT
1318 ;;
1319 'IBM 370 hex' )
1320 format=IBM_FLOAT_FORMAT
1321 ;;
1322 esac
1323 AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format,
1324 [Define to the floating point format of the host machine.])
1325 if test -n "$fbigend"; then
1326 AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend,
1327 [Define to 1 if the host machine stores floating point numbers in
1328 memory with the word containing the sign bit at the lowest address,
1329 or to 0 if it does it the other way around.
1330
1331 This macro should not be defined if the ordering is the same as for
1332 multi-word integers.])
1333 fi
1334 ])
1335
1336 dnl Select appropriate FPU source.
1337 gcc_AC_C_FLOAT_FORMAT
1338 AC_CHECK_HEADERS(ieee754.h ieeefp.h floatingpoint.h nan.h)
1339
1340 for fpe in $FPE_CORE_TEST_ORDER; do
1341 case $fpe in
1342 ieee)
1343 case $ac_cv_c_float_format in
1344 IEEE*)
1345 FPE_CORE="IEEE fpu core"
1346 DEFINES="$DEFINES -DFPU_IEEE"
1347 FPUSRCS="../uae_cpu/fpu/fpu_ieee.cpp"
1348 dnl Math functions not mandated by C99 standard
1349 AC_CHECK_FUNCS(isnanl isinfl)
1350 dnl Math functions required by C99 standard, but probably not
1351 dnl implemented everywhere. In that case, we fall back to the
1352 dnl regular variant for doubles.
1353 AC_CHECK_FUNCS(logl log10l expl powl fabsl sqrtl)
1354 AC_CHECK_FUNCS(sinl cosl tanl sinhl coshl tanhl)
1355 AC_CHECK_FUNCS(asinl acosl atanl asinhl acoshl atanhl)
1356 AC_CHECK_FUNCS(floorl ceill)
1357 break
1358 ;;
1359 esac
1360 ;;
1361 x86)
1362 if [[ ":$HAVE_GCC27:$HAVE_I386:$HAVE_GAS:" = ":yes:yes:yes:" ]]; then
1363 FPE_CORE="i387 fpu core"
1364 DEFINES="$DEFINES -DFPU_X86"
1365 FPUSRCS="../uae_cpu/fpu/fpu_x86.cpp"
1366 break
1367 fi
1368 ;;
1369 uae)
1370 FPE_CORE="uae fpu core"
1371 DEFINES="$DEFINES -DFPU_UAE"
1372 FPUSRCS="../uae_cpu/fpu/fpu_uae.cpp"
1373 break
1374 ;;
1375 *)
1376 AC_MSG_ERROR([Internal configure.in script error for $fpe fpu core])
1377 ;;
1378 esac
1379 done
1380 if [[ "x$FPE_CORE" = "x" ]]; then
1381 AC_MSG_ERROR([Sorry, no suitable FPU core found in $FPE_CORE_TEST_ORDER])
1382 fi
1383
1384 dnl Check for certain math functions
1385 AC_CHECK_FUNCS(atanh)
1386 AC_CHECK_FUNCS(isnan isinf finite isnormal signbit)
1387
1388 dnl UAE CPU sources for all non-m68k-native architectures.
1389 if [[ "x$WANT_NATIVE_M68K" = "xno" ]]; then
1390 CPUINCLUDES="-I../uae_cpu"
1391 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"
1392 fi
1393
1394 dnl Remove the "-g" option if set for GCC.
1395 if [[ "x$HAVE_GCC27" = "xyes" ]]; then
1396 CFLAGS=`echo $CFLAGS | sed -e 's/-g\b//g'`
1397 CXXFLAGS=`echo $CXXFLAGS | sed -e 's/-g\b//g'`
1398 fi
1399
1400 dnl Or if we have -IPA (MIPSPro compilers)
1401 if [[ "x$HAVE_IPA" = "xyes" ]]; then
1402 CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1403 CXXFLAGS="`echo $CXXFLAGS | sed -e 's/-g//g'` -O3 -OPT:Olimit=0 -IPA"
1404 CXXFLAGS="-LANG:std $CXXFLAGS"
1405 LDFLAGS="$LDFLAGS -O3 -OPT:Olimit=0 -IPA"
1406 fi
1407
1408 dnl Generate Makefile.
1409 AC_SUBST(DEFINES)
1410 AC_SUBST(SYSSRCS)
1411 AC_SUBST(CPUINCLUDES)
1412 AC_SUBST(CPUSRCS)
1413 AC_SUBST(BLESS)
1414 AC_SUBST(KEYCODES)
1415 AC_CONFIG_FILES([Makefile])
1416 AC_OUTPUT
1417
1418 dnl Print summary.
1419 echo
1420 echo Basilisk II configuration summary:
1421 echo
1422 echo SDL support ............................ : $SDL_SUPPORT
1423 echo XFree86 DGA support .................... : $WANT_XF86_DGA
1424 echo XFree86 VidMode support ................ : $WANT_XF86_VIDMODE
1425 echo fbdev DGA support ...................... : $WANT_FBDEV_DGA
1426 echo Enable video on SEGV signals ........... : $WANT_VOSF
1427 echo ESD sound support ...................... : $WANT_ESD
1428 echo GTK user interface ..................... : $WANT_GTK
1429 echo mon debugger support ................... : $WANT_MON
1430 echo Running m68k code natively ............. : $WANT_NATIVE_M68K
1431 echo Use JIT compiler ....................... : $WANT_JIT
1432 echo JIT debug mode ......................... : $WANT_JIT_DEBUG
1433 echo Floating-Point emulation core .......... : $FPE_CORE
1434 echo Assembly optimizations ................. : $ASM_OPTIMIZATIONS
1435 echo Addressing mode ........................ : $ADDRESSING_MODE
1436 echo Bad memory access recovery type ........ : $sigsegv_recovery
1437 echo
1438 echo "Configuration done. Now type \"make\" (or \"gmake\")."