From 497234f8e36c0d4597b5ed77b4a2fa1a5621b02b Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Wed, 25 Sep 2013 17:04:18 -0500 Subject: [svn-r24201] Merged changes from trunk revisions 23431, 23527 and 24077. Switched default to link to shared lib files when HDF5 is configure with --disable-static. This addressed HDFFV-8141, h5cc failed because it defaulted to link to lib*.a files which aren't built with --disable-static. -help message also updated. Tested in trunk. Merged code tested with h5committest. --- c++/src/h5c++.in | 42 +++++++++++++++++++++++++++++------------- fortran/src/h5fc.in | 20 ++++++++++++++++---- tools/misc/h5cc.in | 43 +++++++++++++++++++++++++++++-------------- 3 files changed, 74 insertions(+), 31 deletions(-) diff --git a/c++/src/h5c++.in b/c++/src/h5c++.in index 20435eb..a4aaf52 100644 --- a/c++/src/h5c++.in +++ b/c++/src/h5c++.in @@ -83,11 +83,12 @@ CXXLINKERBASE="@CXX@" # CXXFLAGS, CPPFLAGS and LDFLAGS are reserved for use by the script user. # FLAGS brought from the hdf5 build are put in H5BLD_*FLAGS. -# User's CPPFLAGS and CXXFLAGS come after their H5BLD counterparts to override -# them. User's LDFLAGS come just before clibpath, user's LIBS come after -# $link_objs and before the hdf5 libraries in $link_args, followed by any -# external library paths and libraries from AM_LDFLAGS, LDFLAGS, AM_LIBS -# or LIBS carried in from the hdf5 build. +# User's CPPFLAGS and CXXFLAGS come after their H5BLD counterparts. User's +# LDFLAGS come just before clibpath, user's LIBS come after $link_objs and +# before the hdf5 libraries in $link_args, followed by any external library +# paths and libraries from AM_LDFLAGS, LDFLAGS, AM_LIBS or LIBS carried in +# from the hdf5 build. The order of the flags is intended to give precedence +# to the user's flags. H5BLD_CXXFLAGS="@AM_CXXFLAGS@ @CXXFLAGS@" H5BLD_CPPFLAGS="@AM_CPPFLAGS@ @CPPFLAGS@" H5BLD_LDFLAGS="@AM_LDFLAGS@ @LDFLAGS@" @@ -100,7 +101,16 @@ CPPFLAGS="${HDF5_CPPFLAGS:-$CPPFLAGSBASE}" LDFLAGS="${HDF5_LDFLAGS:-$LDFLAGSBASE}" LIBS="${HDF5_LIBS:-$LIBSBASE}" -USE_SHARED_LIB="${HDF5_USE_SHLIB:-no}" +# If a static library is available, the default will be to use it. If the only +# available library is shared, it will be used by default. The user can +# override either default, although choosing an unavailable library will result +# in link errors. +STATIC_AVAILABLE="@enable_static@" +if test "${STATIC_AVAILABLE}" = "yes"; then + USE_SHARED_LIB="${HDF5_USE_SHLIB:-no}" +else + USE_SHARED_LIB="${HDF5_USE_SHLIB:-yes}" +fi usage() { # A wonderfully informative "usage" message. @@ -112,8 +122,10 @@ usage() { echo " subdirectories [default: $prefix]" echo " -show Show the commands without executing them" echo " -showconfig Show the HDF5 library configuration summary" - echo " -shlib Compile with shared HDF5 libraries" - echo " -noshlib Compile with static HDF5 libraries [default]" + echo " -shlib Compile with shared HDF5 libraries [default for hdf5 built" + echo " without static libraries]" + echo " -noshlib Compile with static HDF5 libraries [default for hdf5 built" + echo " with static libraries]" echo " " echo " - the normal compile line options for your compiler." echo " $prog_name uses the same compiler you used to compile" @@ -126,6 +138,9 @@ usage() { echo " " echo " HDF5_CXX - use a different C++ compiler" echo " HDF5_CXXLINKER - use a different linker" + echo " HDF5_USE_SHLIB=[yes|no] - use shared or static version of the HDF5 library" + echo " [default: no except when built with only" + echo " shared libraries]" echo " You can also add or change paths and flags to the compile line using" echo " the following environment varibles or by assigning them to their counterparts" echo " in the 'Things You Can Modify to Override...'" section of $prog_name @@ -365,11 +380,12 @@ if test "x$do_link" = "xyes"; then # module. It's okay if they're included twice in the compile line. link_args="$link_args $H5BLD_LDFLAGS $H5BLD_LIBS" - # User's CPPFLAGS and CXXFLAGS come after their H5BLD counterparts to override - # them. User's LDFLAGS come just before clibpath, user's LIBS come after - # $link_objs and before the hdf5 libraries in $link_args, followed by any - # external library paths and libraries from AM_LDFLAGS, LDFLAGS, AM_LIBS - # or LIBS carried in from the hdf5 build. + # User's CPPFLAGS and CXXFLAGS come after their H5BLD counterparts. User's + # LDFLAGS come just before clibpath, user's LIBS come after $link_objs and + # before the hdf5 libraries in $link_args, followed by any external library + # paths and libraries from AM_LDFLAGS, LDFLAGS, AM_LIBS or LIBS carried in + # from the hdf5 build. The order of the flags is intended to give precedence + # to the user's flags. $SHOW $CXXLINKER $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS $LDFLAGS $clibpath $link_objs $LIBS $link_args $shared_link diff --git a/fortran/src/h5fc.in b/fortran/src/h5fc.in index b220e8b..b5a6486 100644 --- a/fortran/src/h5fc.in +++ b/fortran/src/h5fc.in @@ -97,7 +97,16 @@ FCFLAGS="${HDF5_FCFLAGS:-$FCFLAGSBASE}" LDFLAGS="${HDF5_LDFLAGS:-$LDFLAGSBASE}" LIBS="${HDF5_LIBS:-$LIBSBASE}" -USE_SHARED_LIB="${HDF5_USE_SHLIB:-no}" +# If a static library is available, the default will be to use it. If the only +# available library is shared, it will be used by default. The user can +# override either default, although choosing an unavailable library will result +# in link errors. +STATIC_AVAILABLE="@enable_static@" +if test "${STATIC_AVAILABLE}" = "yes"; then + USE_SHARED_LIB="${HDF5_USE_SHLIB:-no}" +else + USE_SHARED_LIB="${HDF5_USE_SHLIB:-yes}" +fi usage() { # A wonderfully informative "usage" message. @@ -109,8 +118,10 @@ usage() { echo " subdirectories [default: $prefix]" echo " -show Show the commands without executing them" echo " -showconfig Show the HDF5 library configuration summary" - echo " -shlib Compile with shared HDF5 libraries" - echo " -noshlib Compile with static HDF5 libraries [default]" + echo " -shlib Compile with shared HDF5 libraries [default for hdf5 built" + echo " without static libraries]" + echo " -noshlib Compile with static HDF5 libraries [default for hdf5 built" + echo " with static libraries]" echo " " echo " - the normal compile line options for your compiler." echo " $prog_name uses the same compiler you used to compile" @@ -123,7 +134,8 @@ usage() { echo " HDF5_FC - use a different Fortran 90 or 95 compiler" echo " HDF5_FLINKER - use a different linker" echo " HDF5_USE_SHLIB=[yes|no] - use shared or static version of the HDF5 library" - echo " [default: no]" + echo " [default: no except when built with only" + echo " shared libraries]" echo " " echo " You can also add or change paths and flags to the compile line using" echo " the following environment varibles or by assigning them to their counterparts" diff --git a/tools/misc/h5cc.in b/tools/misc/h5cc.in index 233c80a..da1a26d 100644 --- a/tools/misc/h5cc.in +++ b/tools/misc/h5cc.in @@ -85,11 +85,12 @@ CLINKERBASE="@CC@" # CFLAGS, CPPFLAGS and LDFLAGS are reserved for use by the script user. # FLAGS brought from the hdf5 build are put in H5BLD_*FLAGS. -# User's CPPFLAGS and CFLAGS come after their H5BLD counterparts to override -# them. User's LDFLAGS come just before clibpath, user's LIBS come after -# $link_objs and before the hdf5 libraries in $link_args, followed by any -# external library paths and libraries from AM_LDFLAGS, LDFLAGS, AM_LIBS -# or LIBS carried in from the hdf5 build. +# User's CPPFLAGS and CFLAGS come after their H5BLD counterparts. User's +# LDFLAGS come just before clibpath, user's LIBS come after $link_objs and +# before the hdf5 libraries in $link_args, followed by any external library +# paths and libraries from AM_LDFLAGS, LDFLAGS, AM_LIBS or LIBS carried in +# from the hdf5 build. The order of the flags is intended to give precedence +# to the user's flags. H5BLD_CFLAGS="@AM_CFLAGS@ @CFLAGS@" H5BLD_CPPFLAGS="@AM_CPPFLAGS@ @CPPFLAGS@" H5BLD_LDFLAGS="@AM_LDFLAGS@ @LDFLAGS@" @@ -102,7 +103,17 @@ CPPFLAGS="${HDF5_CPPFLAGS:-$CPPFLAGSBASE}" LDFLAGS="${HDF5_LDFLAGS:-$LDFLAGSBASE}" LIBS="${HDF5_LIBS:-$LIBSBASE}" -USE_SHARED_LIB="${HDF5_USE_SHLIB:-no}" +# If a static library is available, the default will be to use it. If the only +# available library is shared, it will be used by default. The user can +# override either default, although choosing an unavailable library will result +# in link errors. +STATIC_AVAILABLE="@enable_static@" +if test "${STATIC_AVAILABLE}" = "yes"; then + USE_SHARED_LIB="${HDF5_USE_SHLIB:-no}" +else + USE_SHARED_LIB="${HDF5_USE_SHLIB:-yes}" +fi + usage() { # A wonderfully informative "usage" message. @@ -121,8 +132,10 @@ usage() { echo " subdirectories [default: $prefix]" echo " -show Show the commands without executing them" echo " -showconfig Show the HDF5 library configuration summary" - echo " -shlib Compile with shared HDF5 libraries" - echo " -noshlib Compile with static HDF5 libraries [default]" + echo " -shlib Compile with shared HDF5 libraries [default for hdf5 built" + echo " without static libraries]" + echo " -noshlib Compile with static HDF5 libraries [default for hdf5 built" + echo " with static libraries]" echo " " echo " - the normal compile line options for your compiler." echo " $prog_name uses the same compiler you used to compile" @@ -136,7 +149,8 @@ usage() { echo " HDF5_CC - use a different C compiler" echo " HDF5_CLINKER - use a different linker" echo " HDF5_USE_SHLIB=[yes|no] - use shared or static version of the HDF5 library" - echo " [default: no]" + echo " [default: no except when built with only" + echo " shared libraries]" echo " " echo " You can also add or change paths and flags to the compile line using" echo " the following environment varibles or by assigning them to their counterparts" @@ -374,11 +388,12 @@ if test "x$do_link" = "xyes"; then # module. It's okay if they're included twice in the compile line. link_args="$link_args $H5BLD_LDFLAGS $H5BLD_LIBS" - # User's CPPFLAGS and CFLAGS come after their H5BLD counterparts to override - # them. User's LDFLAGS come just before clibpath, user's LIBS come after - # $link_objs and before the hdf5 libraries in $link_args, followed by any - # external library paths and libraries from AM_LDFLAGS, LDFLAGS, AM_LIBS - # or LIBS carried in from the hdf5 build. + # User's CPPFLAGS and CFLAGS come after their H5BLD counterparts. User's + # LDFLAGS come just before clibpath, user's LIBS come after $link_objs and + # before the hdf5 libraries in $link_args, followed by any external library + # paths and libraries from AM_LDFLAGS, LDFLAGS, AM_LIBS or LIBS carried in + # from the hdf5 build. The order of the flags is intended to give precedence + # to the user's flags. $SHOW $CLINKER $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CFLAGS $CFLAGS $LDFLAGS $clibpath $link_objs $LIBS $link_args $shared_link status=$? fi -- cgit v0.12