ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.35
Committed: 2004-11-10T07:33:15Z (20 years ago) by gbeauche
Branch: MAIN
Changes since 1.34: +6 -1 lines
Log Message:
fix detection of <linux/if.h> (thanks Bob Deblier)

File Contents

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