ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.37
Committed: 2004-11-15T00:07:54Z (20 years ago) by gbeauche
Branch: MAIN
Changes since 1.36: +1 -0 lines
Log Message:
Add Lauri's icon for Basilisk II builds on Windows

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