--- SheepShaver/src/Unix/configure.in 2003/12/04 22:28:40 1.13 +++ SheepShaver/src/Unix/configure.in 2004/02/20 17:21:08 1.19 @@ -18,6 +18,7 @@ AC_ARG_ENABLE(vosf, [ --enable- 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(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]) dnl Checks for programs. AC_PROG_CC @@ -34,6 +35,9 @@ AC_EGREP_CPP(yes, #ifdef __powerpc__ yes #endif +#ifdef __ppc__ + yes +#endif ], [AC_MSG_RESULT(yes); HAVE_PPC=yes], AC_MSG_RESULT(no)) dnl We use native CPU if possible. @@ -48,9 +52,17 @@ fi dnl We use mon if possible. MONSRCS= +case "x$WANT_MON" in +x/* | x.*) + mon_srcdir=$WANT_MON + WANT_MON=yes + ;; +xyes) + mon_srcdir=../../../mon/src + ;; +esac if [[ "x$WANT_MON" = "xyes" ]]; then AC_MSG_CHECKING(for mon) - mon_srcdir=../../../mon/src if grep mon_init $mon_srcdir/mon.h >/dev/null 2>/dev/null; then AC_MSG_RESULT(yes) AC_DEFINE(ENABLE_MON) @@ -85,7 +97,12 @@ LIBS="$LIBS $X_PRE_LIBS $X_LIBS -lX11 -l dnl We need pthreads on non-PowerPC systems. Try libpthread first, then libc_r (FreeBSD), then PTL. HAVE_PTHREADS=yes -if [[ "x$EMULATED_PPC" = "xyes" ]]; then +case $EMULATED_PPC:$target_os in +no:linux*) + dnl We do have our own pthread_cancel() implementation + AC_DEFINE(HAVE_PTHREAD_CANCEL, 1, [Define if you have the pthread_cancel function.]) + ;; +*:*) AC_CHECK_LIB(pthread, pthread_create, , [ AC_CHECK_LIB(c_r, pthread_create, , [ AC_CHECK_LIB(PTL, pthread_create, , [ @@ -94,18 +111,21 @@ if [[ "x$EMULATED_PPC" = "xyes" ]]; then ]) ]) AC_CHECK_FUNCS(pthread_cancel) + 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 -fi - -dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes. -SEMSRC= -AC_CHECK_FUNCS(sem_init, , [ + dnl If POSIX.4 semaphores are not available, we emulate them with pthread mutexes. + SEMSRC= + AC_CHECK_FUNCS(sem_init, , [ if test "x$HAVE_PTHREADS" = "xyes"; then SEMSRC=posix_sem.cpp fi -]) + ]) + ;; +esac dnl We use XFree86 DGA if possible. if [[ "x$WANT_XF86_DGA" = "xyes" ]]; then @@ -130,7 +150,7 @@ if [[ "x$WANT_XF86_VIDMODE" = "xyes" ]]; fi dnl We use GTK+ if possible. -UISRCS= +UISRCS=../dummy/prefs_editor_dummy.cpp if [[ "x$WANT_GTK" = "xyes" ]]; then AM_PATH_GTK(1.2.0, [ AC_DEFINE(ENABLE_GTK) @@ -163,6 +183,9 @@ AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(mach/vm_map.h mach/mach_init.h sys/mman.h) AC_CHECK_HEADERS(sys/time.h sys/times.h) AC_CHECK_HEADERS(unistd.h fcntl.h byteswap.h) +AC_CHECK_HEADER(mmintrin.h, [have_mmintrin_h=yes]) +AC_CHECK_HEADER(xmmintrin.h, [have_xmmintrin_h=yes]) +AC_CHECK_HEADER(emmintrin.h, [have_emmintrin_h=yes]) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_BIGENDIAN @@ -182,18 +205,64 @@ AC_TYPE_SIGNAL AC_HEADER_TIME AC_STRUCT_TM +dnl Check whether struct sigaction has sa_restorer member. +AC_CACHE_CHECK([whether struct sigaction has sa_restorer], + ac_cv_signal_sa_restorer, [ + AC_TRY_COMPILE([ + #include + ], [struct sigaction sa; sa.sa_restorer = 0;], + ac_cv_signal_sa_restorer=yes, ac_cv_signal_sa_restorer=no, + dnl When cross-compiling, do not assume anything. + ac_cv_signal_sa_restorer=no + ) +]) +if [[ "x$ac_cv_signal_sa_restorer" = "xyes" ]]; then + AC_DEFINE(HAVE_SIGNAL_SA_RESTORER) +fi + dnl Checks for library functions. AC_CHECK_FUNCS(strdup cfmakeraw) -AC_CHECK_FUNCS(nanosleep clock_gettime timer_create) +AC_CHECK_FUNCS(nanosleep) AC_CHECK_FUNCS(sigaction signal) AC_CHECK_FUNCS(mmap mprotect munmap) AC_CHECK_FUNCS(vm_allocate vm_deallocate vm_protect) +dnl Darwin seems to define mach_task_self() instead of task_self(). +AC_CHECK_FUNCS(mach_task_self task_self) + +dnl We need clock_gettime() for better performance but it may drag +dnl libpthread in, which we don't want for native ppc mode +case $EMULATED_PPC:$target_os in +no:linux*) + ;; +*:*) + AC_SEARCH_LIBS(clock_gettime, [rt posix4]) + AC_CHECK_FUNCS(clock_gettime) + ;; +esac + dnl Select system-dependant sources. -if [[ "x$EMULATED_PPC" = "xno" ]]; then - SYSSRCS="Linux/paranoia.cpp Linux/sheepthreads.c Linux/asm_linux.S" -fi -SYSSRCS="$SYSSRCS $SEMSRCS $UISRCS $MONSRCS" +SERIALSRC=serial_unix.cpp +ETHERSRC=../dummy/ether_dummy.cpp +SCSISRC=../dummy/scsi_dummy.cpp +AUDIOSRC=../dummy/audio_dummy.cpp +EXTRASYSSRCS= +case "$target_os" in +linux*) + ETHERSRC=Linux/ether_linux.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" + fi + ;; +darwin*) + if [[ "x$EMULATED_PPC" = "xno" ]]; then + EXTRASYSSRCS="Darwin/paranoia.cpp Linux/asm_linux.S" + fi + ;; +esac +SYSSRCS="$SERIALSRC $ETHERSRC $SCSISRC $AUDIOSRC $SEMSRC $UISRCS $MONSRCS $EXTRASYSSRCS" dnl Define a macro that translates a yesno-variable into a C macro definition dnl to be put into the config.h file @@ -352,8 +421,21 @@ AC_TRANSLATE_DEFINE(HAVE_MMAP_VM, $have_ fi dnl HAVE_MMAP_VM -dnl Check if we can mmap 0x2000 bytes from 0x0000 -AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x2000], +dnl Check if we can modify the __PAGEZERO segment for use as Low Memory +AC_CACHE_CHECK([whether __PAGEZERO can be Low Memory area 0x0000-0x3000], + ac_cv_pagezero_hack, [ + ac_cv_pagezero_hack=no + if AC_TRY_COMMAND([Darwin/testlmem.sh 0x3000]); then + ac_cv_pagezero_hack=yes + dnl might as well skip the test for mmap-able low memory + ac_cv_can_map_lm=no + fi +]) +AC_TRANSLATE_DEFINE(PAGEZERO_HACK, "$ac_cv_pagezero_hack", + [Define if the __PAGEZERO Mach-O Low Memory Globals hack works on this system.]) + +dnl Check if we can mmap 0x3000 bytes from 0x0000 +AC_CACHE_CHECK([whether we can map Low Memory area 0x0000-0x3000], ac_cv_can_map_lm, [ AC_LANG_SAVE AC_LANG_CPLUSPLUS @@ -436,28 +518,58 @@ AC_CACHE_CHECK([whether sigaction handle AC_TRANSLATE_DEFINE(SIGACTION_NEED_REINSTALL, "$ac_cv_sigaction_need_reinstall", [Define if your system requires sigactions to be reinstalled.]) -dnl Check if extended signals are supported. -AC_CACHE_CHECK([whether your system supports extended signal handlers], - ac_cv_have_extended_signals, [ +dnl Check if Mach exceptions supported. +AC_CACHE_CHECK([whether your system supports Mach exceptions], + ac_cv_have_mach_exceptions, [ AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_RUN([ - #define HAVE_SIGINFO_T 1 + #define HAVE_MACH_EXCEPTIONS 1 #define CONFIGURE_TEST_SIGSEGV_RECOVERY #include "vm_alloc.cpp" #include "sigsegv.cpp" - ], ac_cv_have_extended_signals=yes, ac_cv_have_extended_signals=no, + ], [ + sigsegv_recovery=mach + ac_cv_have_mach_exceptions=yes + ], + ac_cv_have_mach_exceptions=no, dnl When cross-compiling, do not assume anything. - ac_cv_have_extended_signals=no + ac_cv_have_mach_exceptions=no ) AC_LANG_RESTORE ] ) -AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals", - [Define if your system support extended signals.]) +AC_TRANSLATE_DEFINE(HAVE_MACH_EXCEPTIONS, "$ac_cv_have_mach_exceptions", + [Define if your system supports Mach exceptions.]) + +dnl Otherwise, check if extended signals are supported. +if [[ -z "$sigsegv_recovery" ]]; then + AC_CACHE_CHECK([whether your system supports extended signal handlers], + ac_cv_have_extended_signals, [ + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_RUN([ + #define HAVE_SIGINFO_T 1 + #define CONFIGURE_TEST_SIGSEGV_RECOVERY + #include "vm_alloc.cpp" + #include "sigsegv.cpp" + ], [ + sigsegv_recovery=siginfo + ac_cv_have_extended_signals=yes + ], + ac_cv_have_extended_signals=no, + dnl When cross-compiling, do not assume anything. + ac_cv_have_extended_signals=no + ) + AC_LANG_RESTORE + ] + ) + AC_TRANSLATE_DEFINE(HAVE_SIGINFO_T, "$ac_cv_have_extended_signals", + [Define if your system support extended signals.]) +fi dnl Otherwise, check for subterfuges. -if [[ "x$ac_cv_have_extended_signals" = "xno" ]]; then +if [[ -z "$sigsegv_recovery" ]]; then AC_CACHE_CHECK([whether we then have a subterfuge for your system], ac_cv_have_sigcontext_hack, [ AC_LANG_SAVE @@ -467,7 +579,11 @@ if [[ "x$ac_cv_have_extended_signals" = #define CONFIGURE_TEST_SIGSEGV_RECOVERY #include "vm_alloc.cpp" #include "sigsegv.cpp" - ], ac_cv_have_sigcontext_hack=yes, ac_cv_have_sigcontext_hack=no, + ], [ + sigsegv_recovery=sigcontext + ac_cv_have_sigcontext_hack=yes + ], + ac_cv_have_sigcontext_hack=no, dnl When cross-compiling, do not assume anything. ac_cv_have_sigcontext_hack=no ) @@ -499,7 +615,7 @@ AC_TRANSLATE_DEFINE(HAVE_SIGSEGV_SKIP_IN dnl Can we do Video on SEGV Signals ? CAN_VOSF=no -if [[ "$ac_cv_have_extended_signals" = "yes" -o "$ac_cv_have_sigcontext_hack" = "yes" ]]; then +if [[ -n "$sigsegv_recovery" ]]; then CAN_VOSF=yes fi @@ -510,6 +626,13 @@ else WANT_VOSF=no fi +dnl Platform specific binary postprocessor +BLESS=/bin/true +if [[ "x$ac_cv_pagezero_hack" = "xyes" ]]; then + BLESS=Darwin/lowmem + LDFLAGS="$LDFLAGS -pagezero_size 0x3000" +fi + dnl Check for GCC 2.7 or higher. HAVE_GCC27=no AC_MSG_CHECKING(for GCC 2.7 or higher) @@ -528,6 +651,14 @@ AC_EGREP_CPP(xyes, #endif ], [AC_MSG_RESULT(yes); HAVE_GCC30=yes], AC_MSG_RESULT(no)) +dnl Check for ICC. +AC_MSG_CHECKING(for ICC) +HAVE_ICC=no +if $CXX -V -v 2>&1 | grep -q "Intel(R) C++ Compiler"; then + HAVE_ICC=yes +fi +AC_MSG_RESULT($HAVE_ICC) + # Test if the compiler can generate ELF objects AC_CACHE_CHECK([whether the compiler can generate ELF objects], ac_cv_elf_objects, [ @@ -571,6 +702,22 @@ if [[ "x$EMULATED_PPC" = "xyes" ]]; then ac_cv_use_dyngen=no ;; esac + dnl Check for a suitable synthetic opcodes compiler (icc is faking itself as gcc 3.2.2) + if [[ -z "$DYNGEN_CC" ]]; then + if [[ "x$HAVE_GCC27" = "xyes" -a "x$HAVE_ICC" = "xno" ]]; then + DYNGEN_CC=$CXX + else + for p in /usr/bin /usr/local/bin; do + gxx="$p/g++" + if [[ -x "$gxx" ]]; then + DYNGEN_CC="$gxx" + fi + done + fi + fi + if [[ -z "$DYNGEN_CC" ]] || ! { echo '#include ' | $DYNGEN_CC -xc++ -c -o /dev/null - >& /dev/null; }; then + ac_cv_use_dyngen=no + fi ]) if [[ "x$ac_cv_use_dyngen" = "xyes" ]]; then case $host_cpu in @@ -581,6 +728,15 @@ if [[ "x$EMULATED_PPC" = "xyes" ]]; then else DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -malign-functions=0" fi + if [[ "x$have_mmintrin_h" = "xyes" ]]; then + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -mmmx" + fi + if [[ "x$have_xmmintrin_h" = "xyes" ]]; then + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse" + fi + if [[ "x$have_emmintrin_h" = "xyes" ]]; then + DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -msse2" + fi ;; esac DYNGEN_OP_FLAGS="$DYNGEN_OP_FLAGS -finline-limit=10000" @@ -635,9 +791,11 @@ fi dnl Generate Makefile. AC_SUBST(DYNGENSRCS) +AC_SUBST(DYNGEN_CC) AC_SUBST(DYNGEN_OP_FLAGS) AC_SUBST(SYSSRCS) AC_SUBST(CPUSRCS) +AC_SUBST(BLESS) AC_OUTPUT(Makefile) dnl Print summary. @@ -652,5 +810,6 @@ echo Enable video on SEGV signals ..... echo ESD sound support ................ : $WANT_ESD echo GTK user interface ............... : $WANT_GTK echo mon debugger support ............. : $WANT_MON +echo Bad memory access recovery type .. : $sigsegv_recovery echo echo "Configuration done. Now type \"make\"."