X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libgomp%2Fconfigure.ac;h=5d11982b157a7bbbb8e2b51baa1dce48d4673062;hb=15256eba0cda9c163c3ae5ee86a932580b1bb20a;hp=854514a27f42349f972304d236dba7b7ccf06b97;hpb=1e8e992020adfba209ef30b3c369e2ca6282d837;p=pf3gnuchains%2Fgcc-fork.git diff --git a/libgomp/configure.ac b/libgomp/configure.ac index 854514a27f4..5d11982b157 100644 --- a/libgomp/configure.ac +++ b/libgomp/configure.ac @@ -16,9 +16,9 @@ LIBGOMP_ENABLE(version-specific-runtime-libs, no, , AC_MSG_RESULT($enable_version_specific_runtime_libs) AC_MSG_CHECKING([for --enable-linux-futex]) -LIBGOMP_ENABLE(linux-futex, yes, +LIBGOMP_ENABLE(linux-futex, default, , [Use the Linux futex system call], - permit yes|no) + permit yes|no|default) AC_MSG_RESULT($enable_linux_futex) # ------- @@ -122,6 +122,8 @@ AM_PROG_LIBTOOL AC_SUBST(enable_shared) AC_SUBST(enable_static) +AM_MAINTAINER_MODE + # We need gfortran to compile parts of the library # We can't use AC_PROG_FC because it expects a fully working gfortran. #AC_PROG_FC(gfortran) @@ -136,19 +138,27 @@ AC_SUBST(libtool_VERSION) # Check header files. AC_STDC_HEADERS AC_HEADER_TIME -AC_CHECK_HEADERS(unistd.h semaphore.h sys/time.h) -AC_CHECK_HEADER([pthread.h],[], - [AC_MSG_ERROR([Pthreads are required to build libgomp])]) +AC_CHECK_HEADERS(unistd.h semaphore.h sys/loadavg.h sys/time.h) + +GCC_HEADER_STDINT(gstdint.h) # Check to see if -pthread or -lpthread is needed. Prefer the former. +# In case the pthread.h system header is not found, this test will fail. XPCFLAGS="" -CFLAGS="$CFLAGS -pthread" + +# Darwin doesn't need the -pthread option since threads are in libSystem AC_LINK_IFELSE( [AC_LANG_PROGRAM( [#include void *g(void *d) { return NULL; }], [pthread_t t; pthread_create(&t,NULL,g,NULL);])], - [XPCFLAGS=" -Wc,-pthread"], + [case $host in + *-darwin*) + ;; + default) + XPCFLAGS=" -Wc,-pthread" + ;; + esac], [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS" AC_LINK_IFELSE( [AC_LANG_PROGRAM( @@ -161,6 +171,57 @@ AC_LINK_IFELSE( # Check for functions needed. AC_CHECK_FUNCS(getloadavg clock_gettime) +# Check for broken semaphore implementation on darwin. +# sem_init returns: sem_init error: Function not implemented. +case "$host" in + *-darwin*) + AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1, + Define if the POSIX Semaphores do not work on your system.) + ;; + *-linux*) + case "$enable_linux_futex" in + default) + # If headers don't have gettid/futex syscalls definition, then + # default to no, otherwise there will be compile time failures. + # Otherwise, default to yes. If we don't detect we are + # compiled/linked against NPTL and not cross-compiling, check + # if programs are run by default against NPTL and if not, issue + # a warning. + enable_linux_futex=no + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include + int lk;], + [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#ifndef _GNU_SOURCE + #define _GNU_SOURCE 1 + #endif + #include + pthread_t th; void *status;], + [pthread_tryjoin_np (th, &status);])],[enable_linux_futex=yes], + [if test x$cross_compiling = xno; then + if getconf GNU_LIBPTHREAD_VERSION 2>/dev/null \ + | LC_ALL=C grep -i NPTL > /dev/null 2>/dev/null; then + AC_MSG_WARN([The kernel might not support futex or gettid syscalls. +If so, please configure with --disable-linux-futex]) + fi + fi + enable_linux_futex=yes])]) + ;; + yes) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include + int lk;], + [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],[], + [AC_MSG_ERROR([SYS_gettid and SYS_futex required for --enable-linux-futex])]) + ;; + esac + ;; +esac + # At least for glibc, clock_gettime is in librt. But don't pull that # in if it still doesn't give us the function we want. if test $ac_cv_func_clock_gettime = no; then @@ -171,7 +232,7 @@ if test $ac_cv_func_clock_gettime = no; then fi # See if we support thread-local storage. -LIBGOMP_CHECK_TLS +GCC_CHECK_TLS # See what sort of export controls are availible. LIBGOMP_CHECK_ATTRIBUTE_VISIBILITY @@ -204,7 +265,7 @@ else fi # Set up the set of libraries that we need to link against for libgomp. -# Note that the GOMP_DRIVER_SPEC in gcc.c will force -pthread for -fopenmp, +# Note that the GOMP_SELF_SPEC in gcc.c will force -pthread for -fopenmp, # which will force linkage against -lpthread (or equivalent for the system). # That's not 100% ideal, but about the best we can do easily. if test $enable_shared = yes; then @@ -216,5 +277,46 @@ AC_SUBST(link_gomp) AM_CONDITIONAL([USE_FORTRAN], [test "$ac_cv_fc_compiler_gnu" = yes]) +# ??? 2006-01-24: Paulo committed to asking autoconf folk to document +# and export AC_COMPUTE_INT. If that happens, then we'll need to remove +# the underscore here and update the PREREQ. If it doesn't, then we'll +# need to copy this macro to our acinclude.m4. +save_CFLAGS="$CFLAGS" +for i in $config_path; do + if test -f $srcdir/config/$i/omp-lock.h; then + CFLAGS="$CFLAGS -include $srcdir/config/$i/omp-lock.h" + break + fi +done + +_AC_COMPUTE_INT([sizeof (omp_lock_t)], [OMP_LOCK_SIZE],, + [AC_MSG_ERROR([unsupported system, cannot find sizeof (omp_lock_t)])]) +_AC_COMPUTE_INT([__alignof (omp_lock_t)], [OMP_LOCK_ALIGN]) +_AC_COMPUTE_INT([sizeof (omp_nest_lock_t)], [OMP_NEST_LOCK_SIZE]) +_AC_COMPUTE_INT([__alignof (omp_nest_lock_t)], [OMP_NEST_LOCK_ALIGN]) + +# If the lock fits in an integer, then arrange for Fortran to use that +# integer. If it doesn't, then arrange for Fortran to use a pointer. +# Except that we don't have a way at present to multi-lib the installed +# Fortran modules, so we assume 8 bytes for pointers, regardless of the +# actual target. +OMP_LOCK_KIND=$OMP_LOCK_SIZE +OMP_NEST_LOCK_KIND=$OMP_NEST_LOCK_SIZE +if test $OMP_LOCK_SIZE -gt 8 || test $OMP_LOCK_ALIGN -gt $OMP_LOCK_SIZE; then + OMP_LOCK_KIND=8 +fi +if test $OMP_NEST_LOCK_SIZE -gt 8 || test $OMP_NEST_LOCK_ALIGN -gt $OMP_NEST_LOCK_SIZE; then + OMP_NEST_LOCK_KIND=8 +fi + +AC_SUBST(OMP_LOCK_SIZE) +AC_SUBST(OMP_LOCK_ALIGN) +AC_SUBST(OMP_NEST_LOCK_SIZE) +AC_SUBST(OMP_NEST_LOCK_ALIGN) +AC_SUBST(OMP_LOCK_KIND) +AC_SUBST(OMP_NEST_LOCK_KIND) +CFLAGS="$save_CFLAGS" + +AC_CONFIG_FILES(omp.h omp_lib.h omp_lib.f90 libgomp_f.h) AC_CONFIG_FILES(Makefile testsuite/Makefile libgomp.spec) AC_OUTPUT