ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.84
Committed: 2012-06-17T23:15:10Z (12 years, 4 months ago) by asvitkine
Branch: MAIN
CVS Tags: HEAD
Changes since 1.83: +1 -0 lines
Log Message:
another try to get sshpty.c compiling on bsd

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