summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2009-09-30 04:24:27 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2009-09-30 04:24:27 (GMT)
commita228881ea7508dccdd863c270910bfc6370fcf2a (patch)
tree46c0f046d3b950e22f981a99f4d26a4ea82dbefa
parente35f27461437c7c66051afd909dbe29e7de5cf45 (diff)
downloadhdf5-a228881ea7508dccdd863c270910bfc6370fcf2a.zip
hdf5-a228881ea7508dccdd863c270910bfc6370fcf2a.tar.gz
hdf5-a228881ea7508dccdd863c270910bfc6370fcf2a.tar.bz2
[svn-r17558] New feature(Bug 230):
Embed the content of libhdf5.settings into the hdf5 executables so that an "orphaned" executables can display (via the Unix strings command, for example) the library settings used to build the executables. configure.in: Added the --disable-embedded-libinfo option to disable this feature. configure: src/H5config.h.in: fortran/configure c++/configure Generated by autotools like automake. src/H5detect.c: Implement insert_libhdf5_settings() to insert the contents of libhdf5.settings into the library as an extern string variable so that it is included in all HDF5 executable. test/Makefile.in: Added test scripts testlibinfo.sh and testcheck_version.sh, test program tcheck_version. Needed to introduce $PROGS so that tcheck_version is built but not run automatically. test/testlibinfo.sh.in: A new test added to verify the library information is indeed included in the executables. H5.c: added code to print the embedded library information when there is a library versions mis-match occurs. This ensures the library information string is included in the executable. Also modifies the code so that the Library mismatch warning string is included only once in the executable. H5private.h: Added a global reference to the libinfo string variable to prepare for possible stage 3 implementation of a public API. New test: (Bug ID 1656): Add new tests (tcheck_version, testcheck_version.sh) to verify H5check_version() does issue warnings and abort accordingly. Changed H5check_version() to suppress the warning message totally if $HDF5_DISABLE_VERSION_CHECK is 2 or higher. (Old behavior treated 3 or higher the same as 1, that is to print a warning and allows the program to continue. MANIFEST: updated with the newly added files. Tested: h5committest passed. Also passed jam in serial mode, --enable-static-exec, --disable-embedded-libinfo.
-rw-r--r--MANIFEST5
-rwxr-xr-xc++/configure2
-rwxr-xr-xconfigure53
-rw-r--r--configure.in24
-rwxr-xr-xfortran/configure2
-rw-r--r--src/H5.c36
-rw-r--r--src/H5config.h.in3
-rw-r--r--src/H5detect.c96
-rw-r--r--src/H5private.h1
-rw-r--r--test/Makefile.in15
-rw-r--r--test/tcheck_version.c99
-rw-r--r--test/testcheck_version.sh.in258
-rw-r--r--test/testlibinfo.sh.in128
13 files changed, 692 insertions, 30 deletions
diff --git a/MANIFEST b/MANIFEST
index 604ef3b..3b4b16d 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1554,11 +1554,14 @@
./test/tattr.c
./test/tbad_msg_count.h5
./test/tbogus.h5
+./test/tcheck_version.c
./test/tconfig.c
./test/tcoords.c
+./test/testcheck_version.sh.in
./test/testframe.c
./test/testhdf5.c
./test/testhdf5.h
+./test/testlibinfo.sh.in
./test/testmeta.c
./test/tfile.c
./test/tgenprop.c
@@ -1572,9 +1575,9 @@
./test/tmtimen.h5
./test/tmtimeo.h5
./test/tnullspace.h5
-./test/ttime.c
./test/trefer.c
./test/trefstr.c
+./test/ttime.c
./test/tselect.c
./test/tskiplist.c
./test/ttst.c
diff --git a/c++/configure b/c++/configure
index 0ebd476..c4a7717 100755
--- a/c++/configure
+++ b/c++/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From c++/configure.in Id: configure.in 17436 2009-08-30 19:21:21Z lrknox .
+# From c++/configure.in Id: configure.in 17539 2009-09-27 19:39:19Z lrknox .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for HDF5 C++ 1.6.9-snap8.
#
diff --git a/configure b/configure
index ab97fa2..9ffc5a7 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Id: configure.in 17436 2009-08-30 19:21:21Z lrknox .
+# From configure.in Id: configure.in 17539 2009-09-27 19:39:19Z lrknox .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for HDF5 1.6.9-snap8.
#
@@ -833,6 +833,7 @@ EXEEXT
OBJEXT
config_dirs
subdirs
+STATIC_EXEC
LT_STATIC_EXEC
PERL
AR
@@ -873,6 +874,8 @@ CONFIG_MODE
BYTESEX
WORDS_BIGENDIAN
STATIC_SHARED
+enable_shared
+enable_static
CC_VERSION
ROOT
DYNAMIC_DIRS
@@ -1511,6 +1514,8 @@ Optional Features:
--enable-strict-format-checks
Enable strict file format checks, default=yes if
debug flag is enabled, no otherwise
+ --enable-embedded-libinfo
+ Enable embedded library information [default=yes]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -3202,6 +3207,7 @@ fi
subdirs="$subdirs ${config_dirs}"
+ STATIC_EXEC=no
{ echo "$as_me:$LINENO: checking if should build only statically linked executables" >&5
echo $ECHO_N "checking if should build only statically linked executables... $ECHO_C" >&6; }
# Check whether --enable-static_exec was given.
@@ -5273,7 +5279,7 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
case $host in
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 5276 "configure"' > conftest.$ac_ext
+ echo '#line 5282 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -5830,7 +5836,7 @@ chmod -w .
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
compiler_c_o=no
-if { (eval echo configure:5833: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+if { (eval echo configure:5839: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
if test -s out/conftest.err; then
@@ -7705,7 +7711,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 7708 "configure"
+#line 7714 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -7803,7 +7809,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 7806 "configure"
+#line 7812 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -32206,6 +32212,8 @@ fi
+
+
if (grep '^build_libtool_libs=yes' libtool >/dev/null); then
enable_shared=yes
else
@@ -32345,6 +32353,30 @@ echo "${ECHO_T}no" >&6; }
esac
+{ echo "$as_me:$LINENO: checking Whether to have library information embedded in the executables" >&5
+echo $ECHO_N "checking Whether to have library information embedded in the executables... $ECHO_C" >&6; }
+# Check whether --enable-embedded-libinfo was given.
+if test "${enable_embedded_libinfo+set}" = set; then
+ enableval=$enable_embedded_libinfo; enable_embedded_libinfo=$enableval
+else
+ enable_embedded_libinfo=yes
+fi
+
+
+ if test "${enable_embedded_libinfo}" = "yes"; then
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_EMBEDDED_LIBINFO 1
+_ACEOF
+
+ else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+ fi
+
+
COMMENCE=config/commence
CONCLUDE=config/conclude
@@ -32392,7 +32424,7 @@ if test "X$HDF5_HL" = "Xyes"; then
hl/tools/gif2h5/Makefile"
fi
-ac_config_files="$ac_config_files src/libhdf5.settings config/depend1 config/depend2 config/depend3 config/depend4 config/dependN config/commence config/conclude Makefile src/Makefile test/Makefile $PARALLEL_MAKE perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5diff/Makefile tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5ls/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc examples/Makefile examples/testh5cc.sh doc/Makefile doc/html/Makefile doc/html/ed_libs/Makefile doc/html/ed_styles/Makefile doc/html/ADGuide/Makefile doc/html/Graphics/Makefile doc/html/Intro/Makefile doc/html/PSandPDF/Makefile doc/html/TechNotes/Makefile doc/html/cpplus/Makefile doc/html/cpplus_RM/Makefile doc/html/cpplus_RM/header_files/Makefile doc/html/fortran/Makefile $HL_FILES"
+ac_config_files="$ac_config_files src/libhdf5.settings config/depend1 config/depend2 config/depend3 config/depend4 config/dependN config/commence config/conclude Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testlibinfo.sh $PARALLEL_MAKE perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5diff/Makefile tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5ls/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc examples/Makefile examples/testh5cc.sh doc/Makefile doc/html/Makefile doc/html/ed_libs/Makefile doc/html/ed_styles/Makefile doc/html/ADGuide/Makefile doc/html/Graphics/Makefile doc/html/Intro/Makefile doc/html/PSandPDF/Makefile doc/html/TechNotes/Makefile doc/html/cpplus/Makefile doc/html/cpplus_RM/Makefile doc/html/cpplus_RM/header_files/Makefile doc/html/fortran/Makefile $HL_FILES"
cat >confcache <<\_ACEOF
@@ -32970,6 +33002,8 @@ do
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
"test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
+ "test/testcheck_version.sh") CONFIG_FILES="$CONFIG_FILES test/testcheck_version.sh" ;;
+ "test/testlibinfo.sh") CONFIG_FILES="$CONFIG_FILES test/testlibinfo.sh" ;;
"$PARALLEL_MAKE") CONFIG_FILES="$CONFIG_FILES $PARALLEL_MAKE" ;;
"perform/Makefile") CONFIG_FILES="$CONFIG_FILES perform/Makefile" ;;
"tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
@@ -33126,6 +33160,7 @@ EXEEXT!$EXEEXT$ac_delim
OBJEXT!$OBJEXT$ac_delim
config_dirs!$config_dirs$ac_delim
subdirs!$subdirs$ac_delim
+STATIC_EXEC!$STATIC_EXEC$ac_delim
LT_STATIC_EXEC!$LT_STATIC_EXEC$ac_delim
PERL!$PERL$ac_delim
AR!$AR$ac_delim
@@ -33156,7 +33191,6 @@ INSTRUMENT_LIBRARY!$INSTRUMENT_LIBRARY$ac_delim
CLEARFILEBUF!$CLEARFILEBUF$ac_delim
MPE!$MPE$ac_delim
MPI_GET_SIZE!$MPI_GET_SIZE$ac_delim
-FILTERS!$FILTERS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 88; then
@@ -33210,6 +33244,7 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
+FILTERS!$FILTERS$ac_delim
USE_FILTER_SHUFFLE!$USE_FILTER_SHUFFLE$ac_delim
USE_FILTER_FLETCHER32!$USE_FILTER_FLETCHER32$ac_delim
H5_VERSION!$H5_VERSION$ac_delim
@@ -33219,6 +33254,8 @@ CONFIG_MODE!$CONFIG_MODE$ac_delim
BYTESEX!$BYTESEX$ac_delim
WORDS_BIGENDIAN!$WORDS_BIGENDIAN$ac_delim
STATIC_SHARED!$STATIC_SHARED$ac_delim
+enable_shared!$enable_shared$ac_delim
+enable_static!$enable_static$ac_delim
CC_VERSION!$CC_VERSION$ac_delim
ROOT!$ROOT$ac_delim
DYNAMIC_DIRS!$DYNAMIC_DIRS$ac_delim
@@ -33230,7 +33267,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 18; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 21; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/configure.in b/configure.in
index c3d7166..7908ddb 100644
--- a/configure.in
+++ b/configure.in
@@ -262,6 +262,7 @@ AC_CONFIG_SUBDIRS([${config_dirs}])
dnl ----------------------------------------------------------------------
dnl If we should build only static executables
dnl
+AC_SUBST(STATIC_EXEC) STATIC_EXEC=no
AC_MSG_CHECKING([if should build only statically linked executables])
AC_ARG_ENABLE([static_exec],
[AC_HELP_STRING([--enable-static-exec],
@@ -2068,6 +2069,8 @@ dnl Therefore we have to look in the generated `libtool' shell script for
dnl lines that set the value of `build_libtool_libs' (shared) and
dnl `build_old_libs' (static).
AC_SUBST([STATIC_SHARED])
+AC_SUBST([enable_shared])
+AC_SUBST([enable_static])
if (grep '^build_libtool_libs=yes' libtool >/dev/null); then
enable_shared=yes
else
@@ -2229,6 +2232,25 @@ esac
dnl ----------------------------------------------------------------------
+dnl Enable embedded library information
+dnl
+AC_MSG_CHECKING([Whether to have library information embedded in the executables])
+AC_ARG_ENABLE([embedded-libinfo],
+ [AC_HELP_STRING([--enable-embedded-libinfo],
+ [Enable embedded library information [default=yes]])],
+ [enable_embedded_libinfo=$enableval],
+ [enable_embedded_libinfo=yes])
+
+ if test "${enable_embedded_libinfo}" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_EMBEDDED_LIBINFO], [1],
+ [Define if library information should be embedded in the executables])
+ else
+ AC_MSG_RESULT([no])
+ fi
+
+
+dnl ----------------------------------------------------------------------
dnl Build the Makefiles. Almost every Makefile.in will begin with the line
dnl `@COMMENCE@' and end with the line `@CONCLUDE@'. These lines insert
dnl various files from the config directory into the Makefile.
@@ -2300,6 +2322,8 @@ AC_CONFIG_FILES([src/libhdf5.settings
Makefile
src/Makefile
test/Makefile
+ test/testcheck_version.sh
+ test/testlibinfo.sh
$PARALLEL_MAKE
perform/Makefile
tools/Makefile
diff --git a/fortran/configure b/fortran/configure
index df336d9..ca8717f 100755
--- a/fortran/configure
+++ b/fortran/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From fortran/configure.in Id: configure.in 17436 2009-08-30 19:21:21Z lrknox .
+# From fortran/configure.in Id: configure.in 17539 2009-09-27 19:39:19Z lrknox .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for HDF5 Fortran 1.6.9-snap8.
#
diff --git a/src/H5.c b/src/H5.c
index 3afd0a5..5e73408 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -578,10 +578,11 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
char lib_str[256];
char substr[] = H5_VERS_SUBRELEASE;
static int checked = 0; /* If we've already checked the version info */
- static int disable_version_check = 0; /* Set if the version check should be disabled */
+ static unsigned int disable_version_check = 0; /* Set if the version check should be disabled */
herr_t ret_value=SUCCEED; /* Return value */
+ static char *version_mismatch_warning=VERSION_MISMATCH_WARNING;
- FUNC_ENTER_API_NOINIT(H5check_version)
+ FUNC_ENTER_API_NOINIT_NOFS(H5check_version)
H5TRACE3("e","IuIuIu",majnum,minnum,relnum);
/* Don't check again, if we already have */
@@ -594,39 +595,44 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
s = HDgetenv ("HDF5_DISABLE_VERSION_CHECK");
if (s && HDisdigit(*s))
- disable_version_check = (int)HDstrtol (s, NULL, 0);
+ disable_version_check = (unsigned int)HDstrtol (s, NULL, 0);
}
if (H5_VERS_MAJOR!=majnum || H5_VERS_MINOR!=minnum ||
H5_VERS_RELEASE!=relnum) {
switch (disable_version_check) {
case 0:
- HDfputs (VERSION_MISMATCH_WARNING
+ HDfprintf(stderr, "%s%s", version_mismatch_warning,
"You can, at your own risk, disable this warning by setting the environment\n"
"variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.\n"
- "Setting it to 2 will suppress the warning messages totally.\n",
- stderr);
+ "Setting it to 2 or higher will suppress the warning messages totally.\n");
/* Mention the versions we are referring to */
HDfprintf (stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n",
majnum, minnum, relnum,
(unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE);
+ /* Show library settings if available */
+ HDfprintf (stderr, "%s", H5libhdf5_settings);
/* Bail out now. */
HDfputs ("Bye...\n", stderr);
HDabort ();
- case 2:
- /* continue silently */
- break;
- default:
+ case 1:
/* continue with a warning */
- HDfprintf (stderr, VERSION_MISMATCH_WARNING
- "'HDF5_DISABLE_VERSION_CHECK' "
+ /* Note that the warning message is embedded in the format string.*/
+ HDfprintf (stderr,
+ "%s'HDF5_DISABLE_VERSION_CHECK' "
"environment variable is set to %d, application will\n"
- "continue at your own risk.\n", disable_version_check);
+ "continue at your own risk.\n",
+ version_mismatch_warning, disable_version_check);
/* Mention the versions we are referring to */
HDfprintf (stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n",
majnum, minnum, relnum,
(unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE);
+ /* Show library settings if available */
+ HDfprintf (stderr, "%s", H5libhdf5_settings);
+ break;
+ default:
+ /* 2 or higer: continue silently */
break;
} /* end switch */
@@ -664,8 +670,8 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
}
done:
- FUNC_LEAVE_API(ret_value)
-}
+ FUNC_LEAVE_API_NOFS(ret_value)
+} /* end H5check_version() */
/*-------------------------------------------------------------------------
diff --git a/src/H5config.h.in b/src/H5config.h.in
index e337a92..8303a56 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -36,6 +36,9 @@
/* Define to 1 if you have the <dmalloc.h> header file. */
#undef HAVE_DMALLOC_H
+/* Define if library information should be embedded in the executables */
+#undef HAVE_EMBEDDED_LIBINFO
+
/* Define to 1 if you have the <features.h> header file. */
#undef HAVE_FEATURES_H
diff --git a/src/H5detect.c b/src/H5detect.c
index 5018347..36e7c40 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -492,6 +492,99 @@ sigbus_handler(int UNUSED signo)
/*-------------------------------------------------------------------------
+ * Function: insert_libhdf5_settings
+ *
+ * Purpose: insert the contents of libhdf5.settings into a file
+ * represented by flibinfo.
+ * Make it an empty string if H5_HAVE_EMBEDDED_LIBINFO is not
+ * defined, i.e., not enabled.
+ *
+ * Return: void
+ *
+ * Programmer: Albert Cheng
+ * Apr 20, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+#define LIBSETTINGSFNAME "libhdf5.settings"
+static void
+insert_libhdf5_settings(FILE *flibinfo)
+{
+#ifdef H5_HAVE_EMBEDDED_LIBINFO
+ FILE *fsettings; /* for files libhdf5.settings */
+ int inchar;
+ int bol=0; /* indicates the beginning of a new line */
+
+ if (NULL==(fsettings=HDfopen(LIBSETTINGSFNAME, "r"))){
+ perror(LIBSETTINGSFNAME);
+ exit(1);
+ }
+ /* print variable definition and the string */
+ fprintf(flibinfo, "char H5libhdf5_settings[]=\n");
+ bol++;
+ while (EOF != (inchar = getc(fsettings))){
+ if (bol){
+ /* Start a new line */
+ fprintf(flibinfo, "\t\"");
+ bol = 0;
+ }
+ if (inchar == '\n'){
+ /* end of a line */
+ fprintf(flibinfo, "\\n\"\n");
+ bol++;
+ }else{
+ putc(inchar, flibinfo);
+ }
+ }
+ if (feof(fsettings)){
+ /* wrap up */
+ if (!bol){
+ /* EOF found without a new line */
+ fprintf(flibinfo, "\\n\"\n");
+ };
+ fprintf(flibinfo, ";\n\n");
+ }else{
+ fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME);
+ exit(1);
+ }
+ if (0 != fclose(fsettings)){
+ perror(LIBSETTINGSFNAME);
+ exit(1);
+ }
+#else
+ /* print variable definition and an empty string */
+ fprintf(flibinfo, "char H5libhdf5_settings[]=\"\";\n");
+#endif
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: make_libinfo
+ *
+ * Purpose: Create the embedded library information definition.
+ * This sets up for a potential extension that the declaration
+ * is printed to a file different from stdout.
+ *
+ * Return: void
+ *
+ * Programmer: Albert Cheng
+ * Sep 15, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static void
+make_libinfo(void)
+{
+ /* print variable definition and then the string as a macro. */
+ insert_libhdf5_settings(stdout);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: print_results
*
* Purpose: Prints information about the detected data types.
@@ -524,6 +617,9 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
\n\
\n");
+ /* Generate embedded library information variable definition */
+ make_libinfo();
+
/* The interface initialization function */
printf("\n\
herr_t\n\
diff --git a/src/H5private.h b/src/H5private.h
index 6be0cfa..e4f0a73 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -948,6 +948,7 @@ typedef struct H5_debug_t {
extern H5_debug_t H5_debug_g;
#define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream)
+extern char H5libhdf5_settings[]; /* embedded library information */
/*-------------------------------------------------------------------------
* Purpose: These macros are inserted automatically just after the
diff --git a/test/Makefile.in b/test/Makefile.in
index 6f859e9..8eb54c6 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -31,7 +31,11 @@ TEST_PROGS=testhdf5 lheap ohdr stab gheap cache hyperslab istore bittests \
ttsafe getname file_handle \
ntypes dangle reserved err_vers
+# Test scripts.
+TEST_SCRIPTS = testlibinfo.sh testcheck_version.sh
+
TIMINGS=testmeta
+PROGS=$(TEST_PROGS) tcheck_version
## The libh5test.a library provides common support code for the tests. We link
## this library statically because some systems can only link executables to
@@ -74,8 +78,8 @@ CLEAN=$(TIMINGS)
TEST_SRC=big.c bittests.c cache.c cmpd_dset.c dsets.c dtypes.c extend.c \
external.c fillval.c flush1.c flush2.c gheap.c h5test.c hyperslab.c \
- istore.c lheap.c links.c mount.c mtime.c ohdr.c stab.c tarray.c \
- tattr.c tconfig.c tcoords.c testhdf5.c testmeta.c tfile.c \
+ istore.c lheap.c links.c mount.c mtime.c ohdr.c stab.c tarray.c tattr.c \
+ tcheck_version.c tconfig.c tcoords.c testhdf5.c testmeta.c tfile.c \
tgenprop.c th5s.c theap.c titerate.c tmeta.c tmisc.c trefer.c trefstr.c \
tselect.c tskiplist.c ttime.c ttst.c tvltypes.c tvlstr.c \
unlink.c enum.c ttsafe.c ttsafe_dcreate.c ttsafe_error.c \
@@ -104,10 +108,10 @@ flush2.chkexe_: flush1.chkexe_
## Programs have to be built before they can be tested!
##
-check test _test: $(TEST_PROGS)
+check test _test: $(PROGS)
## How to build the tests... They all depend on the test and hdf5 libraries.
-$(TEST_PROGS): $(LIB) $(LIBHDF5)
+$(PROGS): $(LIB) $(LIBHDF5)
TESTHDF5_OBJ=testhdf5.lo tarray.lo tattr.lo tconfig.lo tfile.lo \
tgenprop.lo th5s.lo tcoords.lo theap.lo titerate.lo tmeta.lo tmisc.lo \
@@ -186,6 +190,9 @@ flush2: flush2.lo
enum: enum.lo
@$(LT_LINK_EXE) $(CFLAGS) -o $@ enum.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS)
+tcheck_version: tcheck_version.lo
+ @$(LT_LINK_EXE) $(CFLAGS) -o $@ tcheck_version.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS)
+
ttsafe: $(TTS_OBJ)
@$(LT_LINK_EXE) $(CFLAGS) -o $@ $(TTS_OBJ) $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS)
diff --git a/test/tcheck_version.c b/test/tcheck_version.c
new file mode 100644
index 0000000..7a34b26
--- /dev/null
+++ b/test/tcheck_version.c
@@ -0,0 +1,99 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * This tests the h5check_version() function.
+ *
+ * The default is to call the h5check_version() with the version information
+ * in the header file and should incur no warnings or abort.
+ * Options provided to call it with incorrect versions to test
+ * if it will indeed issue the warning message and aborts. With environment
+ * variable $HDF5_DISABLE_VERSION_CHECK sets to 1, it should issue warnings
+ * but no abort. If it is 2, no warning or abort.
+ *
+ * Programmer: Albert Cheng
+ * September 20, 2009
+ */
+
+
+#include <stdlib.h>
+#include "hdf5.h"
+
+#define progname "tcheck_version"
+
+/* global variables */
+unsigned major = H5_VERS_MAJOR;
+unsigned minor = H5_VERS_MINOR;
+unsigned release = H5_VERS_RELEASE;
+
+void
+showhelp(void)
+{
+ printf("Usage: " progname " [-h] [-t<vers>]\n");
+ printf("\t-h\tShow this page and version information\n");
+ printf("\t-t<vers>: Test by changing (adding 1 to) the <vers> to trigger\n");
+ printf("\t\t the warning. <vers> can be:\n");
+ printf("\t\t\tM for Major version number (%d)\n", H5_VERS_MAJOR);
+ printf("\t\t\tm for Minor version number (%d)\n", H5_VERS_MINOR);
+ printf("\t\t\tr for Release number (%d)\n", H5_VERS_RELEASE);
+}
+
+
+void
+parse(int ac, char **av)
+{
+ char *pt;
+
+ while (--ac > 0){
+ pt = *(++av);
+ if (*pt != '-') {
+ fprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
+ exit(1);
+ }else{
+ switch(*(++pt)) {
+ case 't': /* option -t */
+ switch(*(++pt)) {
+ case 'M':
+ major++;
+ break;
+ case 'm':
+ minor++;
+ break;
+ case 'r':
+ release++;
+ break;
+ default:
+ fprintf(stderr, "Unknown -v parameter (%s). Aborted.\n", *av);
+ exit(1);
+ }
+ break;
+ case 'h': /* help page */
+ showhelp();
+ exit(0);
+ default:
+ fprintf(stderr, "Unknown option(%s). Aborted.\n", *av);
+ exit(1);
+ }
+ }
+ }
+}
+
+int
+main(int ac, char **av)
+{
+ parse(ac, av);
+ H5check_version(major, minor, release);
+ return 0;
+}
diff --git a/test/testcheck_version.sh.in b/test/testcheck_version.sh.in
new file mode 100644
index 0000000..e2fa44c
--- /dev/null
+++ b/test/testcheck_version.sh.in
@@ -0,0 +1,258 @@
+#! /bin/sh
+#
+# Copyright by The HDF Group.
+# Copyright by the Board of Trustees of the University of Illinois.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the files COPYING and Copyright.html. COPYING can be found at the root
+# of the source code distribution tree; Copyright.html can be found at the
+# root level of an installed copy of the electronic HDF5 document set and
+# is linked from the top-level documents page. It can also be found at
+# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
+# access to either file, you may request a copy from help@hdfgroup.org.
+
+#
+# Tests for the H5check_version function.
+#
+# Programmer: Albert Cheng
+# Sep 28, 2009
+
+# Variables filled in by the configure process.
+# Determine the configure options of the hdf5 library and executables.
+Shared_Lib=@enable_shared@
+Static_Lib=@enable_static@
+Static_exec=@STATIC_EXEC@
+
+CMP='cmp -s'
+DIFF='diff -c'
+RM='rm -f'
+
+# Function definitions
+#
+# Show the purpose of this test script and a note about the abort messages.
+PURPOSE() {
+ echo "Tests for the H5check_version function."
+ echo "Note that abort messages may appear due to the expected termination"
+ echo "of the program when it is tested with mis-matched version numnbers."
+}
+
+# Print a line-line message left justified in a field of 70 characters.
+#
+LINEMSG() {
+ SPACES=" "
+ echo "$* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+
+# Print a "SKIP" message
+SKIP() {
+ LINEMSG $*
+ echo " -SKIP-"
+}
+
+
+# Print warning message of version mismatch.
+WarnMesg(){
+ echo "Warning! ***HDF5 library version mismatched error***"
+ echo "The HDF5 header files used to compile this application do not match"
+ echo "the version used by the HDF5 library to which this application is linked."
+ echo "Data corruption or segmentation faults may occur if the application continues."
+ echo "This can happen when an application was compiled by one version of HDF5 but"
+ echo "linked with a different version of static or shared HDF5 library."
+ echo "You should recompile the application or check your shared library related"
+ echo "settings such as 'LD_LIBRARY_PATH'."
+ echo "You can, at your own risk, disable this warning by setting the environment"
+ echo "variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'."
+ echo "Setting it to 2 or higher will suppress the warning messages totally."
+ echo "Headers are $xxh5versmajor.$xxh5versminor.$xxh5versrelease, library is $h5versmajor.$h5versminor.$h5versrelease"
+ test -n "$H5_HAVE_EMBEDDED_LIBINFO" && cat $h5libsettings
+ echo "Bye..."
+}
+
+
+# Print warning message2 of version mismatch.
+WarnMesg2(){
+ echo "Warning! ***HDF5 library version mismatched error***"
+ echo "The HDF5 header files used to compile this application do not match"
+ echo "the version used by the HDF5 library to which this application is linked."
+ echo "Data corruption or segmentation faults may occur if the application continues."
+ echo "This can happen when an application was compiled by one version of HDF5 but"
+ echo "linked with a different version of static or shared HDF5 library."
+ echo "You should recompile the application or check your shared library related"
+ echo "settings such as 'LD_LIBRARY_PATH'."
+ echo "'HDF5_DISABLE_VERSION_CHECK' environment variable is set to 1, application will"
+ echo "continue at your own risk."
+ echo "Headers are $xxh5versmajor.$xxh5versminor.$xxh5versrelease, library is $h5versmajor.$h5versminor.$h5versrelease"
+ test -n "$H5_HAVE_EMBEDDED_LIBINFO" && cat $h5libsettings
+}
+
+
+# Run a test and print PASS or *FAIL*. If a test fails then increment
+# the `nerrors' global variable and (if $verbose is set) display the
+# difference between the actual output and the expected output. The
+# expected output generated according to the parameter values and compared
+# against actual output.
+# The expected and actual output files are removed unless $HDF5_NOCLEANUP
+# has a non-zero value.
+# $1: the set value of $HDF5_DISABLE_VERSION_CHECK. (unset means not to set
+# it at all.
+# $2: Change the version number(s) to cause a mismatch. (none means no
+# mismatch).
+#
+# Expected results:
+# Value of $HDF5_DISABLE_VERSION_CHECK
+# unset "" -1 0 1 2 3
+# Matched OK OK OK OK OK OK OK
+# Mismatched W/A W/A W/A W/A W2/OK OK W2/OK
+# Result codes:
+# OK: No warning, exit 0.
+# W/A: Warning, abort and exit non-0.
+# W2/OK: Different Warning, exit 0.
+#
+# Implemented only exit code matching. Still need to match output.
+TESTING() {
+ DEBUGPRINT command is $0 $*
+ TEST_NAME=tcheck_version # The test name
+ TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary
+
+ expect=${TEST_NAME}_expect.out
+ actual=${TEST_NAME}_actual.out
+ actual_err=${TEST_NAME}_actual.err
+ arguments=
+
+ h5DisableVersion="$1"
+ wrongversionnumbers="$2"
+ xxh5versmajor=$h5versmajor
+ xxh5versminor=$h5versminor
+ xxh5versrelease=$h5versrelease
+
+ if [ "$h5DisableVersion" = unset ]; then
+ envcmd="" # noop
+ else
+ envcmd="env HDF5_DISABLE_VERSION_CHECK=$h5DisableVersion"
+ fi
+
+ if [ "$wrongversionnumbers" = none ]; then
+ # OK: No warning, exit 0
+ cp /dev/null $expect
+ expect_code=0
+ else
+ arguments=-t"$wrongversionnumbers"
+ # calculate mismatched version numbers by listing.
+ case $wrongversionnumbers in
+ "M") xxh5versmajor=`expr $h5versmajor + 1`
+ ;;
+ "m") xxh5versminor=`expr $h5versminor + 1`
+ ;;
+ "r") xxh5versrelease=`expr $h5versrelease + 1`
+ ;;
+ esac
+ case "$h5DisableVersion" in
+ 1)
+ # W2/OK: Different Warning, exit 0.
+ WarnMesg2 > $expect
+ expect_code=0
+ ;;
+ [2-9]|[1-9][0-9]*)
+ # OK: No warning, exit 0
+ cp /dev/null $expect
+ expect_code=0
+ ;;
+ *) # W/A: Warning, abort and exit non-0.
+ WarnMesg > $expect
+ expect_code=134 # Signal Abort exit code (128+6)
+ ;;
+ esac
+ fi
+
+ # Run test.
+ LINEMSG $envcmd $TEST_NAME $arguments
+ (
+ $envcmd $RUNSERIAL $TEST_BIN $arguments
+ ) >$actual 2>$actual_err
+ ret_code=$?
+ cat $actual_err >> $actual
+
+ if [ \( $expect_code -ne $ret_code \) ]; then
+ echo "*FAILED*"
+ echo " Expected exit code ($expect_code) differs from actual code ($ret_code)"
+ nerrors="`expr $nerrors + 1`"
+ elif $CMP $expect $actual; then
+ echo " PASSED"
+ else
+ echo "*FAILED*"
+ echo " Expected result differs from actual result"
+ nerrors="`expr $nerrors + 1`"
+ test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /'
+ fi
+
+ # Clean up output file.
+ # Also clean the core file generated by H5check_version's abort.
+ if test -z "$HDF5_NOCLEANUP"; then
+ $RM $expect $actual $actual_err
+ $RM core
+ fi
+}
+
+
+# Echo parameters for debugging if verbose mode is on.
+DEBUGPRINT() {
+ if [ -n "$debugmode" ]; then
+ echo $*
+ fi
+}
+
+
+# MAIN Body
+nerrors=0
+verbose=yes # default on
+debugmode= # default off
+H5_HAVE_EMBEDDED_LIBINFO=`grep '#define H5_HAVE_EMBEDDED_LIBINFO ' ../src/H5pubconf.h`
+h5libsettings=../src/libhdf5.settings
+
+PURPOSE
+
+# The build (current) directory might be different than the source directory.
+if test -z "$srcdir"; then
+ srcdir=.
+fi
+
+# Figure out library version numbers from the header file.
+h5versmajor=`grep '#define H5_VERS_MAJOR' $srcdir/../src/H5public.h | cut -f2`
+h5versminor=`grep '#define H5_VERS_MINOR' $srcdir/../src/H5public.h | cut -f2`
+h5versrelease=`grep '#define H5_VERS_RELEASE' $srcdir/../src/H5public.h | cut -f2`
+DEBUGPRINT $h5versmajor.$h5versminor.$h5versrelease
+case "$h5versmajor$h5versminor$h5versrelease" in
+ [0-9]*) # good. noop.
+ ;;
+ *)
+ echo "Illegal library version numbers($h5versmajor.$h5versminor.$h5versrelease)"
+ echo "Test aborted"
+ exit 1
+ ;;
+esac
+
+# Three Categories of tests:
+# Normal: where the version numbers all matched (wrong_version == none).
+# Mismatched version numbers (could be Major or minor version
+# or release numbers or a combination of all three.)
+# Test all the above with different values of the environment variable,
+# HDF5_DISABLE_VERSION_CHECK, as unset, "", -1, 0, 1, 2, 3
+
+for val_disable_version_check in unset "" -1 0 1 2 3; do
+ for wrong_version in none M m r; do
+ TESTING "$val_disable_version_check" "$wrong_version"
+ done
+done
+
+
+# Check and report results.
+if [ $nerrors -gt 0 ]; then
+ echo "***$nerrors errors encountered***"
+ exit 1
+else
+ echo "No error encountered"
+ exit 0
+fi
diff --git a/test/testlibinfo.sh.in b/test/testlibinfo.sh.in
new file mode 100644
index 0000000..97fb59d
--- /dev/null
+++ b/test/testlibinfo.sh.in
@@ -0,0 +1,128 @@
+#! /bin/sh
+#
+# Copyright by The HDF Group.
+# Copyright by the Board of Trustees of the University of Illinois.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the files COPYING and Copyright.html. COPYING can be found at the root
+# of the source code distribution tree; Copyright.html can be found at the
+# root level of an installed copy of the electronic HDF5 document set and
+# is linked from the top-level documents page. It can also be found at
+# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have
+# access to either file, you may request a copy from help@hdfgroup.org.
+
+
+#
+# Tests for the embedded library information feature.
+# Part 1:
+# Verify the HDF5 library does contains an exact copy of the content of the
+# libhdf5.settings file.
+# Part 2:
+# If executable is linked with the static hdf5 library (how to determine?),
+# verify an executable indeed contains an exact copy of hte content of the
+# libhdf5.settings file.
+#
+# Programmer: Albert Cheng
+# Sep 18, 2009
+
+# Determine the configure options of the hdf5 library and executables.
+
+Shared_Lib=@enable_shared@
+Static_Lib=@enable_static@
+Static_exec=@STATIC_EXEC@
+
+
+# Print a line-line message left justified in a field of 70 characters.
+#
+LINEMSG() {
+ SPACES=" "
+ echo "Check file $* $SPACES" | cut -c1-70 | tr -d '\012'
+}
+
+
+# Print a "SKIP" message
+SKIP() {
+ LINEMSG $*
+ echo " -SKIP-"
+}
+
+# Function definitions
+CHECK_LIBINFO(){
+ LINEMSG $1
+ if strings $1 | grep "SUMMARY OF THE HDF5 CONFIGURATION" > /dev/null; then
+ echo " PASSED"
+ else
+ echo " FAILED"
+ nerrors=`expr $nerrors + 1`
+ fi
+}
+
+
+# MAIN Body
+nerrors=0
+H5_HAVE_EMBEDDED_LIBINFO=`grep '#define H5_HAVE_EMBEDDED_LIBINFO ' ../src/H5pubconf.h`
+
+# Skip the rest if embedded-libinfo is not enabled.
+if [ -z "$H5_HAVE_EMBEDDED_LIBINFO" ]; then
+ echo "embedded-libinfo is not enabled. Test skipped."
+ exit 0
+fi
+
+# The location of HDF library file(s) depends on whether shared lib is
+# built too.
+if [ -n $Shared_Lib ]; then
+ h5libdir=../src/.libs
+else
+ h5libdir=../src
+fi
+
+# Different OS uses different naming for shared libs.
+case `uname -s` in
+ Darwin) # MacOS
+ shlibsuffix=.dylib
+ break
+ ;;
+ *) # default
+ shlibsuffix=.so
+ break
+ ;;
+esac
+
+h5libsettings=../src/libhdf5.settings
+
+# Part 1:
+# Verify the HDF5 library does contains an exact copy of the content of the
+# libhdf5.settings file.
+# Check dynamic library file if built.
+if [ x-$Shared_Lib = x-yes ]; then
+ CHECK_LIBINFO ${h5libdir}/libhdf5${shlibsuffix}
+else
+ SKIP ${h5libdir}/libhdf5${shlibsuffix}
+fi
+
+# Though rare, libhdf5.a may not have been built.
+if [ x-$Static_Lib = x-yes ]; then
+ CHECK_LIBINFO ${h5libdir}/libhdf5.a
+else
+ SKIP ${h5libdir}/libhdf5.a
+fi
+
+# Check if executables has the lib information only if shared lib is not
+# built or static-exec is used. (Don't care static-exec since it affects
+# tools binary only.)
+if [ x-$Shared_Lib != x-yes ]; then
+ CHECK_LIBINFO testhdf5
+else
+ SKIP testhdf5
+fi
+
+
+if [ $nerrors -gt 0 ]; then
+ echo "***$nerrors errors encountered***"
+ exit 1
+else
+ echo "No error encountered"
+ exit 0
+fi