ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/configure.ac
Revision: 1.82
Committed: 2011-12-29T07:38:34Z (12 years, 10 months ago) by asvitkine
Branch: MAIN
Changes since 1.81: +2 -0 lines
Log Message:
move NSAutoReleasePool_wrap() into its own file

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