ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.80
Committed: 2010-10-06T00:30:23Z (14 years, 1 month ago) by asvitkine
Branch: MAIN
Changes since 1.79: +21 -0 lines
Log Message:
[Geoffrey Brown]

Add bin/cue support. The following should work:

1) Basilisk and SheepShaver with sdl-audio and bincue on linux and os x
2) SheepShaver with bincue and core audio on os x

File Contents

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