--- SheepShaver/src/Unix/configure.ac 2004/11/13 14:09:15 1.8 +++ SheepShaver/src/Unix/configure.ac 2005/07/10 15:43:33 1.37 @@ -14,14 +14,29 @@ dnl Some systems do not put corefiles in dnl cores for the configure tests since some are intended to dump core. ulimit -c 0 +dnl Invite Cygwin users to build within the Windows/ directory +case $target_os in +*cygwin* | *mingw32*) + AC_MSG_ERROR([You can only build the Windows version from its directory, Cygwin/X11 is not supported.]) + ;; +esac + dnl Options. AC_ARG_ENABLE(jit, [ --enable-jit enable JIT compiler [default=yes]], [WANT_JIT=$enableval], [WANT_JIT=yes]) AC_ARG_ENABLE(ppc-emulator, [ --enable-ppc-emulator use the selected PowerPC emulator [default=auto]], [WANT_EMULATED_PPC=$enableval], [WANT_EMULATED_PPC=auto]) +AC_ARG_ENABLE(fbdev-dga, [ --enable-fbdev-dga use direct frame buffer access via /dev/fb0 [default=yes]], [WANT_FBDEV_DGA=$enableval], [WANT_FBDEV_DGA=yes]) AC_ARG_ENABLE(xf86-dga, [ --enable-xf86-dga use the XFree86 DGA extension [default=yes]], [WANT_XF86_DGA=$enableval], [WANT_XF86_DGA=yes]) -AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=no]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=no]) +AC_ARG_ENABLE(xf86-vidmode, [ --enable-xf86-vidmode use the XFree86 VidMode extension [default=yes]], [WANT_XF86_VIDMODE=$enableval], [WANT_XF86_VIDMODE=yes]) AC_ARG_ENABLE(vosf, [ --enable-vosf enable video on SEGV signals [default=yes]], [WANT_VOSF=$enableval], [WANT_VOSF=yes]) AC_ARG_WITH(esd, [ --with-esd support ESD for sound under Linux/FreeBSD [default=yes]], [WANT_ESD=$withval], [WANT_ESD=yes]) -AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], [WANT_GTK=$withval], [WANT_GTK=yes]) +AC_ARG_WITH(gtk, [ --with-gtk use GTK user interface [default=yes]], + [case "$withval" in + gtk1) WANT_GTK="gtk";; + gtk|gtk2) WANT_GTK="$withval";; + yes) WANT_GTK="gtk2 gtk";; + *) WANT_GTK="no";; + esac], + [WANT_GTK="gtk2 gtk"]) AC_ARG_WITH(mon, [ --with-mon use mon as debugger [default=yes]], [WANT_MON=$withval], [WANT_MON=yes]) AC_ARG_WITH(dgcc, [ --with-dgcc=COMPILER use C++ COMPILER to compile synthetic opcodes], [DYNGEN_CC=$withval]) @@ -31,7 +46,7 @@ AC_ARG_ENABLE(addressing, [case "$enableval" in real) WANT_ADDRESSING_MODE="real";; direct) WANT_ADDRESSING_MODE="direct";; - direct,0x*) WANT_ADDRESSING_MODE="direct"; NATMEM_OFFSET=`echo "$enableval" | sed -n '/direct,\(0[[xX]][[0-9A-Fa-f]]*\)/s//\1/p'`;; + direct,0x*) WANT_ADDRESSING_MODE="direct"; NATMEM_OFFSET=`echo "$enableval" | sed -n '/direct,\(0[[xX]][[0-9A-Fa-f]]*\([[UuLl]]\{1,2\}\)\?\)$/s//\1/p'`;; esac], [WANT_ADDRESSING_MODE="real"] ) @@ -48,6 +63,8 @@ AC_PROG_CXX AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PROG_EGREP +AC_PATH_PROGS(FILE, [file false]) +AC_PATH_PROG(PERL, [perl]) dnl Check for PowerPC target CPU. HAVE_PPC=no @@ -104,6 +121,7 @@ if [[ "x$WANT_MON" = "xyes" ]]; then WANT_MON=no fi fi +AC_SUBST(MONSRCS) dnl Checks for libraries. AC_CHECK_LIB(posix4, sem_init) @@ -135,6 +153,8 @@ if [[ "x$WANT_SDL" = "xyes" ]]; then LIBS="$LIBS $sdl_libs" else WANT_SDL=no + WANT_SDL_VIDEO=no + WANT_SDL_AUDIO=no fi SDL_SUPPORT=`echo "$SDL_SUPPORT" | sed -e "s/^ //"` else @@ -142,7 +162,7 @@ else fi dnl We need X11, if not using SDL. -if [[ "x$WANT_SDL" = "xno" ]]; then +if [[ "x$WANT_SDL_VIDEO" != "xyes" ]]; then AC_PATH_XTRA if [[ "x$no_x" = "xyes" ]]; then AC_MSG_ERROR([You need X11 to run SheepShaver.]) @@ -155,7 +175,7 @@ fi dnl We need pthreads on non-PowerPC systems. Try libpthread first, then libc_r (FreeBSD), then PTL. HAVE_PTHREADS=yes case $EMULATED_PPC:$target_os in -no:linux*) +no:linux*|no:netbsd*) dnl We do have our own pthread_cancel() implementation AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if you have the pthread_cancel function.]) ;; @@ -163,17 +183,17 @@ no:linux*) AC_CHECK_LIB(pthread, pthread_create, , [ AC_CHECK_LIB(c_r, pthread_create, , [ AC_CHECK_LIB(PTL, pthread_create, , [ - AC_MSG_ERROR([You need pthreads to run Basilisk II.]) + dnl XXX remove when no pthreads case is merged + AC_MSG_ERROR([You need pthreads to run SheepShaver.]) + HAVE_PTHREADS=no ]) ]) ]) AC_CHECK_FUNCS(pthread_cancel) + AC_CHECK_FUNCS(pthread_cond_init pthread_testcancel) AC_CHECK_FUNCS(pthread_mutexattr_setprotocol) AC_CHECK_FUNCS(pthread_mutexattr_settype) AC_CHECK_FUNCS(pthread_mutexattr_setpshared) - if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then - AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.]) - fi dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes. SEMSRC= AC_CHECK_FUNCS(sem_init, , [ @@ -183,6 +203,19 @@ no:linux*) ]) ;; esac +if [[ "x$HAVE_PTHREADS" = "xyes" ]]; then + AC_DEFINE(HAVE_PTHREADS, 1, [Define if pthreads are available.]) +fi + +dnl We use FBDev DGA if possible. +if [[ "x$WANT_FBDEV_DGA" = "xyes" ]]; then + AC_CHECK_HEADER(linux/fb.h, [ + AC_DEFINE(ENABLE_FBDEV_DGA, 1, [Define if using Linux fbdev extension.]) + ], [ + AC_MSG_WARN([Could not find Linux FBDev extension, ignoring --enable-fbdev-dga.]) + WANT_FBDEV_DGA=no + ]) +fi dnl We use XFree86 DGA if possible. if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then @@ -208,7 +241,30 @@ fi dnl We use GTK+ if possible. UISRCS=../dummy/prefs_editor_dummy.cpp -if [[ "x$WANT_GTK" = "xyes" ]]; then +case "x$WANT_GTK" in +xgtk2*) + AM_PATH_GTK_2_0(1.3.15, [ + AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.]) + CFLAGS="$CFLAGS $GTK_CFLAGS" + CXXFLAGS="$CXXFLAGS $GTK_CFLAGS" + LIBS="$LIBS $GTK_LIBS" + UISRCS=prefs_editor_gtk.cpp + WANT_GTK=gtk2 + ], [ + case "x${WANT_GTK}x" in + *gtkx) + AC_MSG_WARN([Could not find GTK+ 2.0, trying with GTK+ 1.2.]) + WANT_GTK=gtk + ;; + *) + AC_MSG_WARN([Could not find GTK+, disabling user interface.]) + WANT_GTK=no + ;; + esac + ]) + ;; +esac +if [[ "x$WANT_GTK" = "xgtk" ]]; then AM_PATH_GTK(1.2.0, [ AC_DEFINE(ENABLE_GTK, 1, [Define if using GTK.]) CFLAGS="$CFLAGS $GTK_CFLAGS" @@ -240,15 +296,22 @@ AC_SYS_LARGEFILE dnl Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT +AC_CHECK_HEADERS(malloc.h stdint.h) AC_CHECK_HEADERS(mach/vm_map.h mach/mach_init.h sys/mman.h) -AC_CHECK_HEADERS(sys/time.h sys/times.h sys/socket.h) AC_CHECK_HEADERS(unistd.h fcntl.h byteswap.h dirent.h) -AC_CHECK_HEADERS(linux/if.h, [], [], [ -#if HAVE_SYS_SOCKET_H -# include +AC_CHECK_HEADERS(sys/socket.h sys/ioctl.h sys/filio.h sys/bitypes.h sys/wait.h) +AC_CHECK_HEADERS(sys/time.h sys/poll.h sys/select.h arpa/inet.h) +AC_CHECK_HEADERS(linux/if.h linux/if_tun.h net/if.h net/if_tun.h, [], [], [ +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include #endif ]) -AC_CHECK_HEADERS(linux/if_tun.h net/if.h net/if_tun.h) +AC_CHECK_HEADERS(AvailabilityMacros.h) +AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDevice.h) +AC_CHECK_HEADERS(fenv.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_BIGENDIAN @@ -268,6 +331,23 @@ AC_TYPE_SIGNAL AC_HEADER_TIME AC_STRUCT_TM +dnl Check whether sys/socket.h defines type socklen_t. +dnl (extracted from ac-archive/Miscellaneous) +AC_CACHE_CHECK([for socklen_t], + ac_cv_type_socklen_t, [ + AC_TRY_COMPILE([ + #include + #include + ], [socklen_t len = 42; return 0;], + ac_cv_type_socklen_t=yes, ac_cv_type_socklen_t=no, + dnl When cross-compiling, do not assume anything. + ac_cv_type_socklen_t="guessing no" + ) +]) +if [[ "x$ac_cv_type_socklen_t" != "xyes" ]]; then + AC_DEFINE(socklen_t, int, [Define to 'int' if doesn't define.]) +fi + dnl Check whether struct sigaction has sa_restorer member. AC_CACHE_CHECK([whether struct sigaction has sa_restorer], ac_cv_signal_sa_restorer, [ @@ -284,12 +364,14 @@ if [[ "x$ac_cv_signal_sa_restorer" = "xy fi dnl Checks for library functions. -AC_CHECK_FUNCS(strdup strlcpy cfmakeraw) +AC_CHECK_FUNCS(strdup strerror strlcpy cfmakeraw) AC_CHECK_FUNCS(nanosleep) AC_CHECK_FUNCS(sigaction signal) AC_CHECK_FUNCS(mmap mprotect munmap) AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect) -AC_CHECK_FUNCS(posix_memalign memalign valloc) +AC_CHECK_FUNCS(exp2f log2f exp2 log2) +AC_CHECK_FUNCS(floorf roundf ceilf truncf floor round ceil trunc) +AC_CHECK_FUNCS(poll inet_aton) dnl Darwin seems to define mach_task_self() instead of task_self(). AC_CHECK_FUNCS(mach_task_self task_self) @@ -301,10 +383,54 @@ no:linux*) ;; *:*) AC_SEARCH_LIBS(clock_gettime, [rt posix4]) - AC_CHECK_FUNCS(clock_gettime) + AC_CHECK_FUNCS(clock_gettime clock_nanosleep) ;; esac +dnl Check for headers and functions related to pty support (sshpty.c) +dnl From openssh-3.2.2p1 configure.ac +AC_CHECK_HEADERS(strings.h login.h sys/bsdtty.h sys/stat.h util.h pty.h) +AC_CHECK_FUNCS(_getpty vhangup strlcpy) + +case "$host" in +*-*-hpux10.26) + disable_ptmx_check=yes + ;; +*-*-linux*) + no_dev_ptmx=1 + ;; +mips-sony-bsd|mips-sony-newsos4) + AC_DEFINE(HAVE_NEWS4, 1, [Define if you are on NEWS-OS (additions from openssh-3.2.2p1, for sshpty.c).]) + ;; +*-*-sco3.2v4*) + no_dev_ptmx=1 + ;; +*-*-sco3.2v5*) + no_dev_ptmx=1 + ;; +*-*-cygwin*) + no_dev_ptmx=1 + ;; +esac + +if test -z "$no_dev_ptmx" ; then + if test "x$disable_ptmx_check" != "xyes" ; then + AC_CHECK_FILE([/dev/ptmx], + [ + AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX, 1, [Define if you have /dev/ptmx.]) + have_dev_ptmx=1 + ] + ) + fi +fi +AC_CHECK_FILE([/dev/ptc], + [ + AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC, 1, [Define if you have /dev/ptc.]) + have_dev_ptc=1 + ] +) +dnl (end of code from openssh-3.2.2p1 configure.ac) + dnl AC_CHECK_FRAMEWORK($1=NAME, $2=INCLUDES) AC_DEFUN(AC_CHECK_FRAMEWORK, [ AS_VAR_PUSHDEF([ac_Framework], [ac_cv_framework_$1])dnl @@ -326,6 +452,7 @@ AC_DEFUN(AC_CHECK_FRAMEWORK, [ dnl Check for some MacOS X frameworks AC_CHECK_FRAMEWORK(Carbon, [#include ]) AC_CHECK_FRAMEWORK(IOKit, [#include ]) +AC_CHECK_FRAMEWORK(CoreFoundation, [#include ]) dnl Select system-dependant sources. SERIALSRC=serial_unix.cpp @@ -336,18 +463,28 @@ EXTFSSRC=extfs_unix.cpp EXTRASYSSRCS= case "$target_os" in linux*) - ETHERSRC=Linux/ether_linux.cpp + ETHERSRC=ether_unix.cpp AUDIOSRC=audio_oss_esd.cpp SCSISRC=Linux/scsi_linux.cpp if [[ "x$EMULATED_PPC" = "xno" ]]; then - EXTRASYSSRCS="Linux/paranoia.cpp Linux/sheepthreads.c Linux/asm_linux.S" + EXTRASYSSRCS="paranoia.cpp Linux/sheepthreads.c ppc_asm.S" + fi + ;; +freebsd*) + ETHERSRC=ether_unix.cpp + ;; +netbsd*) + ETHERSRC=ether_unix.cpp + if [[ "x$EMULATED_PPC" = "xno" ]]; then + EXTRASYSSRCS="paranoia.cpp NetBSD/sheepthreads.c ppc_asm.S" fi ;; darwin*) + ETHERSRC=ether_unix.cpp if [[ "x$EMULATED_PPC" = "xno" ]]; then - EXTRASYSSRCS="Darwin/paranoia.cpp Linux/asm_linux.S" + EXTRASYSSRCS="paranoia.cpp ppc_asm.S" fi - if [[ "x$ac_cv_framework_IOKit" = "xyes" ]]; then + if [[ "x$ac_cv_framework_IOKit" = "xyes" -a "x$ac_cv_framework_CoreFoundation" = "xyes" ]]; then EXTRASYSSRCS="$EXTRASYSSRCS ../MacOSX/sys_darwin.cpp" fi if [[ "x$ac_cv_framework_Carbon" = "xyes" ]]; then @@ -356,6 +493,19 @@ darwin*) ;; esac +dnl Is the slirp library supported? +if [[ "x$ETHERSRC" = "xether_unix.cpp" ]]; then + AC_DEFINE(HAVE_SLIRP, 1, [Define if slirp library is supported]) + SLIRP_SRCS="\ + ../slirp/bootp.c ../slirp/ip_output.c ../slirp/tcp_input.c \ + ../slirp/cksum.c ../slirp/mbuf.c ../slirp/tcp_output.c \ + ../slirp/debug.c ../slirp/misc.c ../slirp/tcp_subr.c \ + ../slirp/if.c ../slirp/sbuf.c ../slirp/tcp_timer.c \ + ../slirp/ip_icmp.c ../slirp/slirp.c ../slirp/tftp.c \ + ../slirp/ip_input.c ../slirp/socket.c ../slirp/udp.c" +fi +AC_SUBST(SLIRP_SRCS) + dnl SDL overrides if [[ "x$WANT_SDL" = "xyes" ]]; then AC_DEFINE(USE_SDL, 1, [Define to enble SDL support.]) @@ -379,7 +529,7 @@ if [[ "x$WANT_SDL_AUDIO" = "xyes" ]]; th AUDIOSRC="../SDL/audio_sdl.cpp" fi -SYSSRCS="$VIDEOSRCS $EXTFSSRC $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS" +SYSSRCS="$VIDEOSRCS $EXTFSSRC $SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $EXTRASYSSRCS" dnl Define a macro that translates a yesno-variable into a C macro definition dnl to be put into the config.h file @@ -683,6 +833,30 @@ fi AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions", [Define if your system supports Mach exceptions.]) +dnl Check if Windows exceptions are supported. +AC_CACHE_CHECK([whether your system supports Windows exceptions], + ac_cv_have_win32_exceptions, [ + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_RUN([ + #define HAVE_WIN32_EXCEPTIONS 1 + #define CONFIGURE_TEST_SIGSEGV_RECOVERY + #include "vm_alloc.cpp" + #include "sigsegv.cpp" + ], [ + sigsegv_recovery=win32 + ac_cv_have_win32_exceptions=yes + ], + ac_cv_have_win32_exceptions=no, + dnl When cross-compiling, do not assume anything. + ac_cv_have_win32_exceptions=no + ) + AC_LANG_RESTORE + ] +) +AC_TRANSLATE_DEFINE(HAVE_WIN32_EXCEPTIONS, "$ac_cv_have_win32_exceptions", + [Define if your system supports Windows exceptions.]) + dnl Otherwise, check if extended signals are supported. if [[ -z "$sigsegv_recovery" ]]; then AC_CACHE_CHECK([whether your system supports extended signal handlers], @@ -821,7 +995,10 @@ int main(void) memset(m, 0, ranges[[i]].size); vm_release(m, ranges[[i]].size); if (i == n_ranges - 1) { - printf("0x%08x\n", ofs); + if (sizeof(void *) == 8 && ofs > 0xffffffff) + printf("0x%lxul\n", ofs); + else + printf("0x%08x\n", ofs); return 0; } } @@ -833,22 +1010,161 @@ EOF doit='$CXX conftest.$ac_ext -o conftest.$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS $NATMEM_OFFSET_DEF >& AS_MESSAGE_LOG_FD' if AC_TRY_EVAL(doit); then NATMEM_OFFSET=`./conftest.$ac_exeext` - if [[ -z "$NATMEM_OFFSET" ]]; then - AC_MSG_ERROR([could not determine a sensible NATMEM_OFFSET value]) - else - WANT_ADDRESSING_MODE="direct,$NATMEM_OFFSET" - fi + else + NATMEM_OFFSET= fi rm -f conftest* AC_LANG_RESTORE + + if [[ -z "$NATMEM_OFFSET" ]]; then + AC_MSG_ERROR([could not determine a sensible NATMEM_OFFSET value]) + else + WANT_ADDRESSING_MODE="direct,$NATMEM_OFFSET" + AC_DEFINE_UNQUOTED(NATMEM_OFFSET, $NATMEM_OFFSET, + [Define constant offset for Mac address translation]) + fi fi AC_MSG_RESULT($WANT_ADDRESSING_MODE) -if [[ -z "$NATMEM_OFFSET" ]]; then - NATMEM_OFFSET=0 +dnl Utility macro used by next two tests. +dnl AC_EXAMINE_OBJECT(C source code, +dnl commands examining object file, +dnl [commands to run if compile failed]): +dnl +dnl Compile the source code to an object file; then convert it into a +dnl printable representation. All unprintable characters and +dnl asterisks (*) are replaced by dots (.). All white space is +dnl deleted. Newlines (ASCII 0x10) in the input are preserved in the +dnl output, but runs of newlines are compressed to a single newline. +dnl Finally, line breaks are forcibly inserted so that no line is +dnl longer than 80 columns and the file ends with a newline. The +dnl result of all this processing is in the file conftest.dmp, which +dnl may be examined by the commands in the second argument. +dnl +AC_DEFUN([gcc_AC_EXAMINE_OBJECT], +[AC_LANG_SAVE +AC_LANG_C +dnl Next bit cribbed from AC_TRY_COMPILE. +cat > conftest.$ac_ext < conftest.dmp + $2 +ifelse($3, , , else + $3 +)dnl +fi +rm -rf conftest* +AC_LANG_RESTORE]) + +dnl Floating point format probe. +dnl The basic concept is the same as the above: grep the object +dnl file for an interesting string. We have to watch out for +dnl rounding changing the values in the object, however; this is +dnl handled by ignoring the least significant byte of the float. +dnl +dnl Does not know about VAX G-float or C4x idiosyncratic format. +dnl It does know about PDP-10 idiosyncratic format, but this is +dnl not presently supported by GCC. S/390 "binary floating point" +dnl is in fact IEEE (but maybe we should have that in EBCDIC as well +dnl as ASCII?) +dnl +AC_DEFUN([gcc_AC_C_FLOAT_FORMAT], +[AC_CACHE_CHECK(floating point format, ac_cv_c_float_format, +[gcc_AC_EXAMINE_OBJECT( +[/* This will not work unless sizeof(double) == 8. */ +extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1]; + +/* This structure must have no internal padding. */ +struct possibility { + char prefix[8]; + double candidate; + char postfix[8]; +}; + +#define C(cand) { "\nformat:", cand, ":tamrof\n" } +struct possibility table [] = +{ + C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */ + C( 3.53802595280598432000e+18), /* D__float - VAX */ + C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */ + C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */ + C(-5.22995989424860458374e+10) /* IBMHEXFP - s/390 format, EBCDIC */ +};], + [if grep 'format:.@IEEEF.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='IEEE (big-endian)' + elif grep 'format:.I@@PFE.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='IEEE (big-endian)' + elif grep 'format:.FEEEI@.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='IEEE (little-endian)' + elif grep 'format:.EFP@@I.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='IEEE (little-endian)' + elif grep 'format:.__floa.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='VAX D-float' + elif grep 'format:..PDP-1.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='PDP-10' + elif grep 'format:.BMHEXF.:tamrof' conftest.dmp >/dev/null 2>&1; then + ac_cv_c_float_format='IBM 370 hex' + else + AC_MSG_ERROR(Unknown floating point format) + fi], + [AC_MSG_ERROR(compile failed)]) +]) +# IEEE is the default format. If the float endianness isn't the same +# as the integer endianness, we have to set FLOAT_WORDS_BIG_ENDIAN +# (which is a tristate: yes, no, default). This is only an issue with +# IEEE; the other formats are only supported by a few machines each, +# all with the same endianness. +format=IEEE_FLOAT_FORMAT +fbigend= +case $ac_cv_c_float_format in + 'IEEE (big-endian)' ) + if test $ac_cv_c_bigendian = no; then + fbigend=1 + fi + ;; + 'IEEE (little-endian)' ) + if test $ac_cv_c_bigendian = yes; then + fbigend=0 + fi + ;; + 'VAX D-float' ) + format=VAX_FLOAT_FORMAT + ;; + 'PDP-10' ) + format=PDP10_FLOAT_FORMAT + ;; + 'IBM 370 hex' ) + format=IBM_FLOAT_FORMAT + ;; +esac +AC_DEFINE_UNQUOTED(HOST_FLOAT_FORMAT, $format, + [Define to the floating point format of the host machine.]) +if test -n "$fbigend"; then + AC_DEFINE_UNQUOTED(HOST_FLOAT_WORDS_BIG_ENDIAN, $fbigend, + [Define to 1 if the host machine stores floating point numbers in + memory with the word containing the sign bit at the lowest address, + or to 0 if it does it the other way around. + + This macro should not be defined if the ordering is the same as for + multi-word integers.]) fi -AC_DEFINE_UNQUOTED(NATMEM_OFFSET, $NATMEM_OFFSET, - [Define constant offset for Mac address translation]) +]) + +dnl Check for host float format +gcc_AC_C_FLOAT_FORMAT dnl Platform specific binary postprocessor AC_PATH_PROG(BLESS, "true") @@ -860,20 +1176,22 @@ fi dnl Check for GCC 2.7 or higher. HAVE_GCC27=no AC_MSG_CHECKING(for GCC 2.7 or higher) -AC_EGREP_CPP(xyes, -[#if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5 - xyes -#endif -], [AC_MSG_RESULT(yes); HAVE_GCC27=yes], AC_MSG_RESULT(no)) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 5) + # error gcc < 2.7 + #endif + ]])], + [AC_MSG_RESULT(yes); HAVE_GCC27=yes], + [AC_MSG_RESULT(no)]) dnl Check for GCC 3.0 or higher. HAVE_GCC30=no AC_MSG_CHECKING(for GCC 3.0 or higher) -AC_EGREP_CPP(xyes, -[#if __GNUC__ >= 3 - xyes -#endif -], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no)) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if ! (__GNUC__ >= 3) + # error gcc < 3 + #endif + ]])], + [AC_MSG_RESULT(yes); HAVE_GCC30=yes], + [AC_MSG_RESULT(no)]) dnl Check for ICC. AC_MSG_CHECKING(for ICC) @@ -883,25 +1201,60 @@ if $CXX -V -v 2>&1 | grep -q "Intel(R) C fi AC_MSG_RESULT($HAVE_ICC) -dnl Test if the compiler can generate ELF objects -AC_CACHE_CHECK([whether the compiler can generate ELF objects], - ac_cv_elf_objects, [ +dnl Determine the generated object format +AC_CACHE_CHECK([the format of compiler generated objects], + ac_cv_object_format, [ echo 'int i;' > conftest.$ac_ext - ac_cv_elf_objects=no + ac_cv_object_format=no if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *"ELF"*) - ac_cv_elf_objects=yes + ac_cv_object_format=elf + ;; + *"Mach-O"*) + ac_cv_object_format=mach + ;; + *) + ac_cv_object_format=unknown ;; esac fi rm -rf conftest* ]) -ELF_OBJECTS=$ac_cv_elf_objects + +dnl Add -fno-strict-aliasing for slirp sources +if [[ "x$HAVE_GCC30" = "xyes" ]]; then + SAVED_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-strict-aliasing" + AC_CACHE_CHECK([whether the compiler supports -fno-strict-aliasing], + ac_cv_gcc_no_strict_aliasing, [ + AC_TRY_COMPILE([],[], + [ac_cv_gcc_no_strict_aliasing=yes; AC_SUBST(SLIRP_CFLAGS, "-fno-strict-aliasing")], + [ac_cv_gcc_no_strict_aliasing=no]) + ]) + CFLAGS="$SAVED_CFLAGS" +fi + +dnl Add -mdynamic-no-pic for MacOS X +if [[ "x$HAVE_GCC30" = "xyes" ]]; then + SAVED_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -mdynamic-no-pic" + AC_CACHE_CHECK([whether the compiler supports -mdynamic-no-pic], + ac_cv_gcc_mdynamic_no_pic, [ + AC_TRY_COMPILE([],[],[ac_cv_gcc_mdynamic_no_pic=yes],[ac_cv_gcc_mdynamic_no_pic=no]) + ]) + if [[ "x$ac_cv_gcc_mdynamic_no_pic" = "xyes" ]]; then + CXXFLAGS="$CXXFLAGS -mdynamic-no-pic" + else + CFLAGS="$SAVED_CFLAGS" + fi +fi dnl CPU emulator sources if [[ "x$EMULATED_PPC" = "xyes" ]]; then CPUSRCS="\ + ../kpx_cpu/src/mathlib/ieeefp.cpp \ + ../kpx_cpu/src/mathlib/mathlib.cpp \ ../kpx_cpu/src/cpu/ppc/ppc-cpu.cpp \ ../kpx_cpu/src/cpu/ppc/ppc-decode.cpp \ ../kpx_cpu/src/cpu/ppc/ppc-execute.cpp \ @@ -912,14 +1265,17 @@ if [[ "x$EMULATED_PPC" = "xyes" ]]; then if [[ "x$WANT_JIT" = "xyes" ]]; then AC_CACHE_CHECK([whether dyngen can be used], ac_cv_use_dyngen, [ - case $host_cpu:$ELF_OBJECTS in - powerpc:yes) + case $host_cpu:$ac_cv_object_format in + powerpc:elf) + ac_cv_use_dyngen=yes + ;; + x86_64:elf) ac_cv_use_dyngen=yes ;; - x86_64:yes) + i?86:elf) ac_cv_use_dyngen=yes ;; - i?86:yes) + powerpc:mach) ac_cv_use_dyngen=yes ;; *:*) @@ -939,7 +1295,7 @@ if [[ "x$EMULATED_PPC" = "xyes" ]]; then done fi fi - if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include ' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then + if [[ -z "$DYNGEN_CC" ]]; then ac_cv_use_dyngen=no fi ]) @@ -947,25 +1303,19 @@ if [[ "x$EMULATED_PPC" = "xyes" ]]; then case $host_cpu in i?86) DYNGEN_OP_FLAGS="-fomit-frame-pointer -mpreferred-stack-boundary=2" - if [[ "x$HAVE_GCC30" = "xyes" ]]; then - DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0" - else - DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0" - fi - saved_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -mmmx" - AC_CHECK_HEADERS(mmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -mmmx"]) - CPPFLAGS="$CPPFLAGS -msse" - AC_CHECK_HEADERS(xmmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse"]) - CPPFLAGS="$CPPFLAGS -msse2" - AC_CHECK_HEADERS(emmintrin.h, [DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse2"]) - CPPFLAGS=$saved_CPPFLAGS ;; - x86_64) - AC_CHECK_HEADERS(mmintrin.h xmmintrin.h emmintrin.h) + powerpc) + if [[ "x$ac_cv_object_format" = "xmach" ]]; then + DYNGEN_OP_FLAGS="-mdynamic-no-pic" + fi ;; esac - DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000" + if [[ "x$HAVE_GCC30" = "xyes" ]]; then + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -falign-functions=0" + else + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0" + fi + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000 -fno-exceptions -g0" if [[ "x$HAVE_GCC30" = "xyes" ]]; then DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -fno-reorder-blocks -fno-optimize-sibling-calls" fi @@ -991,7 +1341,7 @@ if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; AC_CACHE_CHECK([whether static data regions are executable], ac_cv_have_static_data_exec, [ AC_TRY_RUN([int main(void) { -#if defined(__powerpc__) +#if defined(__powerpc__) || defined(__ppc__) static unsigned int p[8] = {0x4e800020,}; asm volatile("dcbst 0,%0" : : "r" (p) : "memory"); asm volatile("sync" : : : "memory"); @@ -1007,6 +1357,8 @@ if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; ac_cv_have_static_data_exec=no ) ]) +else + ac_cv_use_dyngen=no fi AC_TRANSLATE_DEFINE(HAVE_STATIC_DATA_EXEC, "$ac_cv_have_static_data_exec", [Define if your system marks static data pages as executable.]) @@ -1016,6 +1368,8 @@ if [[ "x$WANT_JIT" = "xyes" ]]; then fi dnl Generate Makefile. +AC_SUBST(PERL) +AC_SUBST(USE_DYNGEN, [$ac_cv_use_dyngen]) AC_SUBST(DYNGENSRCS) AC_SUBST(DYNGEN_CC) AC_SUBST(DYNGEN_OP_FLAGS) @@ -1033,6 +1387,7 @@ echo echo SheepShaver configuration summary: echo echo SDL support ...................... : $SDL_SUPPORT +echo FBDev DGA support ................ : $WANT_FBDEV_DGA echo XFree86 DGA support .............. : $WANT_XF86_DGA echo XFree86 VidMode support .......... : $WANT_XF86_VIDMODE echo Using PowerPC emulator ........... : $EMULATED_PPC