summaryrefslogtreecommitdiffstats
path: root/src
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 /src
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.
Diffstat (limited to 'src')
-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
4 files changed, 121 insertions, 15 deletions
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