From 7a4727d80c8b4f160105cb0dea174256fee9bd1e Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 21 Mar 2014 10:19:07 -0500 Subject: [svn-r24857] --enable-threadsafe no longer requires --with-pthreads if Pthreads can be found in the standard include and library paths. Tested on: 32-bit LE linux (jam) SunOS 5.11 (emu) 64-bit Darwin 12.5 (kite) 64-bit FreeBSD 8.2 (freedom) Testing focused on making sure that Pthreads could be found on different platforms and investigating the interaction of Fortran/C++/thread-safe options. --- configure | 256 +++++++++++++++++++++++++++-------------------------------- configure.ac | 162 ++++++++++++++++++------------------- 2 files changed, 200 insertions(+), 218 deletions(-) diff --git a/configure b/configure index 6d0c172..4db05b1 100755 --- a/configure +++ b/configure @@ -911,8 +911,8 @@ with_fnord with_dmalloc with_zlib with_szlib -with_pthread enable_threadsafe +with_pthread enable_gpfs enable_debug enable_codestack @@ -1595,7 +1595,7 @@ Optional Features: Disable use of the '=Wl,-rpath' linker option --enable-production Determines how to run the compiler. --disable-largefile omit support for large files - --enable-threadsafe Enable thread safe capability + --enable-threadsafe Enable thread-safe capability --enable-gpfs Enable GPFS hints for the MPI/POSIX file driver. [default=no] --enable-debug=all Turn on debugging in all packages. One may also @@ -1669,7 +1669,8 @@ Optional Packages: [default=yes] --with-szlib=DIR Use szlib library for external szlib I/O filter [default=no] - --with-pthread=DIR Use the Pthreads library [default=no] + --with-pthread=DIR Specify alternative path to Pthreads library when + thread-safe capability is built --with-mpe=DIR Use MPE instrumentation [default=no] --with-default-vfd=driver Specify default file driver [default=sec2] @@ -26205,25 +26206,79 @@ fi rm -f confcache ## ---------------------------------------------------------------------- -## Is the Pthreads library present? It has a header file `pthread.h' and -## a library `-lpthread' and their locations might be specified with the -## `--with-pthread' command-line switch. The value is an include path -## and/or a library path. If the library path is specified then it must -## be preceded by a comma. +## Enable thread-safe version of library. It requires Pthreads support +## on POSIX systems. ## - HAVE_PTHREAD=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for thread safe support" >&5 +$as_echo_n "checking for thread safe support... " >&6; } +# Check whether --enable-threadsafe was given. +if test "${enable_threadsafe+set}" = set; then : + enableval=$enable_threadsafe; THREADSAFE=$enableval +fi + + +## The --enable-threadsafe flag is not compatible with --enable-cxx. +## If the user tried to specify both flags, throw an error, unless +## they also provided the --enable-unsupported flag. +if test "X${ALLOW_UNSUPPORTED}" != "Xyes"; then + if test "X${HDF_CXX}" = "Xyes" -a "X${enable_threadsafe}" = "Xyes"; then + as_fn_error $? "--enable-cxx and --enable-threadsafe flags are incompatible. Use --enable-unsupported to override this error." "$LINENO" 5 + fi +fi + +## --enable-threadsafe is also incompatible with --enable-fortran, unless +## --enable-unsupported has been specified on the configure line. +if test "X${ALLOW_UNSUPPORTED}" != "Xyes"; then + if test "X${HDF_FORTRAN}" = "Xyes" -a "X${enable_threadsafe}" = "Xyes"; then + as_fn_error $? "--enable-fortran and --enable-threadsafe flags are incompatible. Use --enable-unsupported to override this error." "$LINENO" 5 + fi +fi + +case "X-$THREADSAFE" in + X-|X-no) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; + X-yes) + THREADSAFE=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 +$as_echo "error" >&6; } + as_fn_error $? "\'$enableval\' is not a valid threadsafe type" "$LINENO" 5 + ;; +esac + +if test "X$THREADSAFE" = "Xyes"; then + +$as_echo "#define HAVE_THREADSAFE 1" >>confdefs.h + + + ## ---------------------------------------------------------------------- + ## Is the pthreads library present? It has a header file `pthread.h' and + ## a library `-lpthread' and their locations might be specified with the + ## `--with-pthread' command-line switch. The value is an include path + ## and/or a library path. If the library path is specified then it must + ## be preceded by a comma. + ## + ## Thread-safety in HDF5 only uses Pthreads via configure, so the + ## default is "yes", though this only has an effect when + ## --enable-threadsafe is specified. + HAVE_PTHREAD=yes # Check whether --with-pthread was given. if test "${with_pthread+set}" = set; then : withval=$with_pthread; else - withval=no + withval=yes fi -case "$withval" in - yes) - for ac_header in pthread.h + case "$withval" in + yes) + for ac_header in pthread.h do : ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : @@ -26237,8 +26292,8 @@ fi done - if test "x$HAVE_PTHREAD" = "xyes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5 + if test "x$HAVE_PTHREAD" = "xyes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5 $as_echo_n "checking for pthread_self in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_self+:} false; then : $as_echo_n "(cached) " >&6 @@ -26293,44 +26348,44 @@ else unset HAVE_PTHREAD fi - fi - ;; - no) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread" >&5 + fi + ;; + no) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread" >&5 $as_echo_n "checking for pthread... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5 $as_echo "suppressed" >&6; } - unset HAVE_PTHREAD - ;; - *) - case "$withval" in - *,*) - pthread_inc="`echo $withval | cut -f1 -d,`" - pthread_lib="`echo $withval | cut -f2 -d, -s`" + unset HAVE_PTHREAD ;; *) - if test -n "$withval"; then - pthread_inc="$withval/include" - pthread_lib="$withval/lib" - fi - ;; - esac + case "$withval" in + *,*) + pthread_inc="`echo $withval | cut -f1 -d,`" + pthread_lib="`echo $withval | cut -f2 -d, -s`" + ;; + *) + if test -n "$withval"; then + pthread_inc="$withval/include" + pthread_lib="$withval/lib" + fi + ;; + esac - ## Trying to include -I/usr/include and -L/usr/lib is redundant and - ## can mess some compilers up. - if test "X$pthread_inc" = "X/usr/include"; then - pthread_inc="" - fi - if test "X$pthread_lib" = "X/usr/lib"; then - pthread_lib="" - fi + ## Trying to include -I/usr/include and -L/usr/lib is redundant and + ## can mess some compilers up. + if test "X$pthread_inc" = "X/usr/include"; then + pthread_inc="" + fi + if test "X$pthread_lib" = "X/usr/lib"; then + pthread_lib="" + fi - if test -n "$pthread_inc"; then - saved_CPPFLAGS="$CPPFLAGS" - saved_AM_CPPFLAGS="$AM_CPPFLAGS" - CPPFLAGS="$CPPFLAGS -I$pthread_inc" - AM_CPPFLAGS="$AM_CPPFLAGS -I$pthread_inc" - for ac_header in pthread.h + if test -n "$pthread_inc"; then + saved_CPPFLAGS="$CPPFLAGS" + saved_AM_CPPFLAGS="$AM_CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$pthread_inc" + AM_CPPFLAGS="$AM_CPPFLAGS -I$pthread_inc" + for ac_header in pthread.h do : ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : @@ -26344,8 +26399,8 @@ fi done - else - for ac_header in pthread.h + else + for ac_header in pthread.h do : ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" if test "x$ac_cv_header_pthread_h" = xyes; then : @@ -26359,15 +26414,15 @@ fi done - fi + fi - if test "x$HAVE_PTHREAD" = "xyes"; then - if test -n "$pthread_lib"; then - saved_LDFLAGS="$LDFLAGS" - saved_AM_LDFLAGS="$AM_LDFLAGS" - LDFLAGS="$LDFLAGS -L$pthread_lib" - AM_LDFLAGS="$AM_LDFLAGS -L$pthread_lib" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5 + if test "x$HAVE_PTHREAD" = "xyes"; then + if test -n "$pthread_lib"; then + saved_LDFLAGS="$LDFLAGS" + saved_AM_LDFLAGS="$AM_LDFLAGS" + LDFLAGS="$LDFLAGS -L$pthread_lib" + AM_LDFLAGS="$AM_LDFLAGS -L$pthread_lib" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5 $as_echo_n "checking for pthread_self in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_self+:} false; then : $as_echo_n "(cached) " >&6 @@ -26422,8 +26477,8 @@ else LDFLAGS="$saved_LDFLAGS"; AM_LDFLAGS="$saved_AM_LDFLAGS"; unset HAVE_PTHREAD fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lpthread" >&5 $as_echo_n "checking for pthread_self in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_self+:} false; then : $as_echo_n "(cached) " >&6 @@ -26478,85 +26533,10 @@ else unset HAVE_PTHREAD fi - fi - fi - ;; -esac - -## ---------------------------------------------------------------------- -## Enable thread-safe version of library. It requires Pthreads support. -## -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for thread safe support" >&5 -$as_echo_n "checking for thread safe support... " >&6; } -# Check whether --enable-threadsafe was given. -if test "${enable_threadsafe+set}" = set; then : - enableval=$enable_threadsafe; THREADSAFE=$enableval -fi - - -## The --enable-threadsafe flag is not compatible with --enable-cxx. -## If the user tried to specify both flags, throw an error, unless -## they also provided the --enable-unsupported flag. -if test "X${ALLOW_UNSUPPORTED}" != "Xyes"; then - if test "X${HDF_CXX}" = "Xyes" -a "X${enable_threadsafe}" = "Xyes"; then - as_fn_error $? "--enable-cxx and --enable-threadsafe flags are incompatible. Use --enable-unsupported to override this error." "$LINENO" 5 - fi -fi - -## --enable-threadsafe is also incompatible with --enable-fortran, unless -## --enable-unsupported has been specified on the configure line. -if test "X${ALLOW_UNSUPPORTED}" != "Xyes"; then - if test "X${HDF_FORTRAN}" = "Xyes" -a "X${enable_threadsafe}" = "Xyes"; then - as_fn_error $? "--enable-fortran and --enable-threadsafe flags are incompatible. Use --enable-unsupported to override this error." "$LINENO" 5 - fi -fi - -case "X-$THREADSAFE" in - X-|X-no) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ;; - X-yes) - ## Check that we can link a simple Pthread program. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef FC_DUMMY_MAIN -#ifndef FC_DUMMY_MAIN_EQ_F77 -# ifdef __cplusplus - extern "C" -# endif - int FC_DUMMY_MAIN() { return 1; } -#endif -#endif -int -main () -{ -pthread_self() - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; }; THREADSAFE=yes -else - as_fn_error $? "needed pthread library not available" "$LINENO" 5 -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 -$as_echo "error" >&6; } - as_fn_error $? "\'$enableval\' is not a valid threadsafe type" "$LINENO" 5 - ;; -esac - -if test "X$THREADSAFE" = "Xyes"; then - -$as_echo "#define HAVE_THREADSAFE 1" >>confdefs.h - + fi + fi + ;; + esac fi ## ---------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index 8121326..31381ab 100644 --- a/configure.ac +++ b/configure.ac @@ -1932,85 +1932,13 @@ AM_CONDITIONAL([BUILD_SHARED_SZIP_CONDITIONAL], [test "X$USE_FILTER_SZIP" = "Xye AC_CACHE_SAVE ## ---------------------------------------------------------------------- -## Is the Pthreads library present? It has a header file `pthread.h' and -## a library `-lpthread' and their locations might be specified with the -## `--with-pthread' command-line switch. The value is an include path -## and/or a library path. If the library path is specified then it must -## be preceded by a comma. -## -AC_SUBST([HAVE_PTHREAD]) HAVE_PTHREAD=yes -AC_ARG_WITH([pthread], - [AS_HELP_STRING([--with-pthread=DIR], - [Use the Pthreads library [default=no]])],, - [withval=no]) - -case "$withval" in - yes) - AC_CHECK_HEADERS([pthread.h],, [unset HAVE_PTHREAD]) - if test "x$HAVE_PTHREAD" = "xyes"; then - AC_CHECK_LIB([pthread], [pthread_self],, [unset HAVE_PTHREAD]) - fi - ;; - no) - AC_MSG_CHECKING([for pthread]) - AC_MSG_RESULT([suppressed]) - unset HAVE_PTHREAD - ;; - *) - case "$withval" in - *,*) - pthread_inc="`echo $withval | cut -f1 -d,`" - pthread_lib="`echo $withval | cut -f2 -d, -s`" - ;; - *) - if test -n "$withval"; then - pthread_inc="$withval/include" - pthread_lib="$withval/lib" - fi - ;; - esac - - ## Trying to include -I/usr/include and -L/usr/lib is redundant and - ## can mess some compilers up. - if test "X$pthread_inc" = "X/usr/include"; then - pthread_inc="" - fi - if test "X$pthread_lib" = "X/usr/lib"; then - pthread_lib="" - fi - - if test -n "$pthread_inc"; then - saved_CPPFLAGS="$CPPFLAGS" - saved_AM_CPPFLAGS="$AM_CPPFLAGS" - CPPFLAGS="$CPPFLAGS -I$pthread_inc" - AM_CPPFLAGS="$AM_CPPFLAGS -I$pthread_inc" - AC_CHECK_HEADERS([pthread.h],, [CPPFLAGS="$saved_CPPFLAGS"; AM_CPPFLAGS="$saved_AM_CPPFLAGS"; unset HAVE_PTHREAD]) - else - AC_CHECK_HEADERS([pthread.h],, [unset HAVE_PTHREAD]) - fi - - if test "x$HAVE_PTHREAD" = "xyes"; then - if test -n "$pthread_lib"; then - saved_LDFLAGS="$LDFLAGS" - saved_AM_LDFLAGS="$AM_LDFLAGS" - LDFLAGS="$LDFLAGS -L$pthread_lib" - AM_LDFLAGS="$AM_LDFLAGS -L$pthread_lib" - AC_CHECK_LIB([pthread], [pthread_self],, - [LDFLAGS="$saved_LDFLAGS"; AM_LDFLAGS="$saved_AM_LDFLAGS"; unset HAVE_PTHREAD]) - else - AC_CHECK_LIB([pthread], [pthread_self],, [unset HAVE_PTHREAD]) - fi - fi - ;; -esac - -## ---------------------------------------------------------------------- -## Enable thread-safe version of library. It requires Pthreads support. +## Enable thread-safe version of library. It requires Pthreads support +## on POSIX systems. ## AC_MSG_CHECKING([for thread safe support]) AC_ARG_ENABLE([threadsafe], [AS_HELP_STRING([--enable-threadsafe], - [Enable thread safe capability])], + [Enable thread-safe capability])], [THREADSAFE=$enableval]) ## The --enable-threadsafe flag is not compatible with --enable-cxx. @@ -2035,10 +1963,8 @@ case "X-$THREADSAFE" in AC_MSG_RESULT([no]) ;; X-yes) - ## Check that we can link a simple Pthread program. - AC_TRY_LINK(, [pthread_self()], - [AC_MSG_RESULT([yes]); THREADSAFE=yes], - [AC_MSG_ERROR([needed pthread library not available])]) + THREADSAFE=yes + AC_MSG_RESULT([yes]) ;; *) AC_MSG_RESULT([error]) @@ -2047,7 +1973,83 @@ case "X-$THREADSAFE" in esac if test "X$THREADSAFE" = "Xyes"; then - AC_DEFINE([HAVE_THREADSAFE], [1], [Define if we have thread safe support]) + AC_DEFINE([HAVE_THREADSAFE], [1], [Define if we have thread safe support]) + + ## ---------------------------------------------------------------------- + ## Is the pthreads library present? It has a header file `pthread.h' and + ## a library `-lpthread' and their locations might be specified with the + ## `--with-pthread' command-line switch. The value is an include path + ## and/or a library path. If the library path is specified then it must + ## be preceded by a comma. + ## + ## Thread-safety in HDF5 only uses Pthreads via configure, so the + ## default is "yes", though this only has an effect when + ## --enable-threadsafe is specified. + AC_SUBST([HAVE_PTHREAD]) HAVE_PTHREAD=yes + AC_ARG_WITH([pthread], + [AS_HELP_STRING([--with-pthread=DIR], + [Specify alternative path to Pthreads library when thread-safe capability is built])],, + [withval=yes]) + + case "$withval" in + yes) + AC_CHECK_HEADERS([pthread.h],, [unset HAVE_PTHREAD]) + if test "x$HAVE_PTHREAD" = "xyes"; then + AC_CHECK_LIB([pthread], [pthread_self],, [unset HAVE_PTHREAD]) + fi + ;; + no) + AC_MSG_CHECKING([for pthread]) + AC_MSG_RESULT([suppressed]) + unset HAVE_PTHREAD + ;; + *) + case "$withval" in + *,*) + pthread_inc="`echo $withval | cut -f1 -d,`" + pthread_lib="`echo $withval | cut -f2 -d, -s`" + ;; + *) + if test -n "$withval"; then + pthread_inc="$withval/include" + pthread_lib="$withval/lib" + fi + ;; + esac + + ## Trying to include -I/usr/include and -L/usr/lib is redundant and + ## can mess some compilers up. + if test "X$pthread_inc" = "X/usr/include"; then + pthread_inc="" + fi + if test "X$pthread_lib" = "X/usr/lib"; then + pthread_lib="" + fi + + if test -n "$pthread_inc"; then + saved_CPPFLAGS="$CPPFLAGS" + saved_AM_CPPFLAGS="$AM_CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$pthread_inc" + AM_CPPFLAGS="$AM_CPPFLAGS -I$pthread_inc" + AC_CHECK_HEADERS([pthread.h],, [CPPFLAGS="$saved_CPPFLAGS"; AM_CPPFLAGS="$saved_AM_CPPFLAGS"; unset HAVE_PTHREAD]) + else + AC_CHECK_HEADERS([pthread.h],, [unset HAVE_PTHREAD]) + fi + + if test "x$HAVE_PTHREAD" = "xyes"; then + if test -n "$pthread_lib"; then + saved_LDFLAGS="$LDFLAGS" + saved_AM_LDFLAGS="$AM_LDFLAGS" + LDFLAGS="$LDFLAGS -L$pthread_lib" + AM_LDFLAGS="$AM_LDFLAGS -L$pthread_lib" + AC_CHECK_LIB([pthread], [pthread_self],, + [LDFLAGS="$saved_LDFLAGS"; AM_LDFLAGS="$saved_AM_LDFLAGS"; unset HAVE_PTHREAD]) + else + AC_CHECK_LIB([pthread], [pthread_self],, [unset HAVE_PTHREAD]) + fi + fi + ;; + esac fi ## ---------------------------------------------------------------------- -- cgit v0.12