summaryrefslogtreecommitdiffstats
path: root/src/H5detect.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2009-04-21 02:02:46 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2009-04-21 02:02:46 (GMT)
commit9bca9d684bd7d5179f30fb92afa9dee1e53f69cd (patch)
tree477a51a4748744a839ad3cab9a7c8420a8ba5095 /src/H5detect.c
parentc60f5a8429f47fd8f0b013dc1a87b7f33eb6da95 (diff)
downloadhdf5-9bca9d684bd7d5179f30fb92afa9dee1e53f69cd.zip
hdf5-9bca9d684bd7d5179f30fb92afa9dee1e53f69cd.tar.gz
hdf5-9bca9d684bd7d5179f30fb92afa9dee1e53f69cd.tar.bz2
[svn-r16814] 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. This is a prototype implementation. Much improvement is needed. configure.in: Added the --disable-embedded-libinfo option to disable this feature. configure: src/H5config.h.in: 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. Much improvement is needed. fortran/src/Makefile.in: Auto-generated by bin/reconfigure. (i.e., I did make any changes to cause its direct regeneration). Tested: Jam serial, using default and --disable-embedded-libinfo, configure options.
Diffstat (limited to 'src/H5detect.c')
-rw-r--r--src/H5detect.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/H5detect.c b/src/H5detect.c
index b67c2b0..146750c 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -108,6 +108,7 @@ static void detect_C99_integers16(void);
static void detect_C99_integers32(void);
static void detect_C99_integers64(void);
static void detect_alignments(void);
+static void insert_libhdf5_settings(void);
static size_t align_g[] = {1, 2, 4, 8, 16};
static jmp_buf jbuf_g;
@@ -502,6 +503,64 @@ sigbus_handler(int UNUSED signo)
/*-------------------------------------------------------------------------
+ * Function: insert_libhdf5_settings
+ *
+ * Purpose: Insert contents of libhdf5.settings so that it is included
+ * in all hdf5 executables.
+ *
+ * Return: void
+ *
+ * Programmer: Albert Cheng
+ * Apr 20, 2009
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+#define LIBSETTINGSFNAME "libhdf5.settings"
+static void
+insert_libhdf5_settings(void)
+{
+ FILE *fsettings;
+ char inchar;
+ int bol=0; /* indicates the beginning of a new line */
+
+ if (NULL==(fsettings=HDfopen(LIBSETTINGSFNAME, "r"))){
+ perror(LIBSETTINGSFNAME);
+ exit(1);
+ }
+ /* print variable definition */
+ printf("extern char H5libhdf5_settings[]=\n");
+ bol++;
+ while (EOF != (inchar = getc(fsettings))){
+ if (bol){
+ /* Start a new line */
+ printf("\t\"");
+ bol = 0;
+ }
+ if (inchar == '\n'){
+ /* end of a line */
+ printf("\\n\"\n");
+ bol++;
+ }else{
+ putchar(inchar);
+ }
+ }
+ if (feof(fsettings)){
+ /* wrap up */
+ if (!bol){
+ /* EOF found without a new line */
+ printf("\\n\"\n");
+ };
+ printf(";\n\n");
+ }else{
+ fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME);
+ exit(1);
+ }
+}
+
+
+/*-------------------------------------------------------------------------
* Function: print_results
*
* Purpose: Prints information about the detected data types.
@@ -580,6 +639,11 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align)
/*******************/\n\
\n");
+#ifdef H5_HAVE_EMBEDDED_LIBINFO
+ /* Insert content of libhdf5.settings */
+ insert_libhdf5_settings();
+#endif
+
/* The interface initialization function */
printf("\n\
\n\