From 3a83be48fb88572d675507a5d5cfbacb302f1ad7 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Fri, 18 Sep 2009 13:34:37 -0500 Subject: [svn-r17499] Purpose: Stage 2 implementation of embedded library information feature. 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. test/testlibinfo.sh.in: A new test added to verify the library information is indeed included in the executables. configure.in: configure: Added entry to auto-generate test/testlibinfo.sh. H5detect.c: Modified the libhdf5settings generating code to allow it to insert the strings to a file other than stdout. This maybe needed in stage 3 implementation. MANIFEST: updated with the newly added file of testlibinfo.sh.in. Tested: h5committest passed. Also passed jam in serial mode. --- MANIFEST | 1 + configure | 5 ++-- configure.in | 1 + src/H5.c | 20 ++++++++----- src/H5detect.c | 67 +++++++++++++++++++++++++++++++------------ src/H5private.h | 1 + test/Makefile.am | 2 +- test/Makefile.in | 9 ++++-- test/testlibinfo.sh.in | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ tools/lib/Makefile.in | 3 +- tools/misc/Makefile.in | 11 +++----- 11 files changed, 158 insertions(+), 39 deletions(-) create mode 100644 test/testlibinfo.sh.in diff --git a/MANIFEST b/MANIFEST index f9d89e5..9d736c5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -860,6 +860,7 @@ ./test/testframe.c ./test/testhdf5.c ./test/testhdf5.h +./test/testlibinfo.sh.in ./test/testmeta.c ./test/tfile.c ./test/tgenprop.c diff --git a/configure b/configure index e028cd9..1b36f75 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in 17453 2009-09-06 20:50:18Z lrknox . +# From configure.in Id: configure.in 17472 2009-09-13 20:49:59Z lrknox . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.64 for HDF5 1.8.3-snap11. # @@ -28208,7 +28208,7 @@ if test -n "$TESTPARALLEL"; then fi fi -ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testerror.sh testpar/Makefile testpar/testph5.sh perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumpxml.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/h5copy/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/examples/Makefile c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/tools/Makefile hl/tools/gif2h5/Makefile hl/examples/Makefile hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile" +ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testerror.sh test/testlibinfo.sh testpar/Makefile testpar/testph5.sh perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumpxml.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/h5copy/Makefile tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/examples/Makefile c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/tools/Makefile hl/tools/gif2h5/Makefile hl/examples/Makefile hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile" cat >confcache <<\_ACEOF @@ -29419,6 +29419,7 @@ do "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; "test/testerror.sh") CONFIG_FILES="$CONFIG_FILES test/testerror.sh" ;; + "test/testlibinfo.sh") CONFIG_FILES="$CONFIG_FILES test/testlibinfo.sh" ;; "testpar/Makefile") CONFIG_FILES="$CONFIG_FILES testpar/Makefile" ;; "testpar/testph5.sh") CONFIG_FILES="$CONFIG_FILES testpar/testph5.sh" ;; "perform/Makefile") CONFIG_FILES="$CONFIG_FILES perform/Makefile" ;; diff --git a/configure.in b/configure.in index 069ed65..58c5f9a 100644 --- a/configure.in +++ b/configure.in @@ -4003,6 +4003,7 @@ AC_CONFIG_FILES([src/libhdf5.settings src/Makefile test/Makefile test/testerror.sh + test/testlibinfo.sh testpar/Makefile testpar/testph5.sh perform/Makefile diff --git a/src/H5.c b/src/H5.c index b49db8d..f11e8b7 100644 --- a/src/H5.c +++ b/src/H5.c @@ -28,7 +28,7 @@ #include "H5Lprivate.h" /* Links */ #include "H5Pprivate.h" /* Property lists */ #include "H5Tprivate.h" /* Datatypes */ -#include "H5SLprivate.h" /* Skip lists */ +#include "H5SLprivate.h" /* Skip lists */ /****************/ @@ -623,6 +623,7 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) 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 */ herr_t ret_value=SUCCEED; /* Return value */ + static char *version_mismatch_warning=VERSION_MISMATCH_WARNING; FUNC_ENTER_API_NOINIT_NOFS(H5check_version) H5TRACE3("e", "IuIuIu", majnum, minnum, relnum); @@ -644,15 +645,16 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) 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 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); @@ -662,14 +664,18 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum) break; default: /* 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; } /* end switch */ diff --git a/src/H5detect.c b/src/H5detect.c index 8d7b93b..4dae076 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -108,7 +108,8 @@ 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 void insert_libhdf5_settings(FILE *flibinfo); +static void make_libinfo(void); static size_t align_g[] = {1, 2, 4, 8, 16}; static jmp_buf jbuf_g; @@ -505,8 +506,8 @@ sigbus_handler(int UNUSED signo) /*------------------------------------------------------------------------- * Function: insert_libhdf5_settings * - * Purpose: Insert contents of libhdf5.settings so that it is included - * in all hdf5 executables. + * Purpose: insert the contents of libhdf5.settings into a file + * represented by flibinfo. * * Return: void * @@ -519,9 +520,9 @@ sigbus_handler(int UNUSED signo) */ #define LIBSETTINGSFNAME "libhdf5.settings" static void -insert_libhdf5_settings(void) +insert_libhdf5_settings(FILE *flibinfo) { - FILE *fsettings; + FILE *fsettings; /* for files libhdf5.settings */ int inchar; int bol=0; /* indicates the beginning of a new line */ @@ -529,34 +530,62 @@ insert_libhdf5_settings(void) perror(LIBSETTINGSFNAME); exit(1); } - /* print variable definition */ - printf("extern char H5libhdf5_settings[]=\n"); + /* print variable definition and the string */ + fprintf(flibinfo, "char H5libhdf5_settings[]=\n"); bol++; while (EOF != (inchar = getc(fsettings))){ if (bol){ /* Start a new line */ - printf("\t\""); + fprintf(flibinfo, "\t\""); bol = 0; } if (inchar == '\n'){ /* end of a line */ - printf("\\n\"\n"); + fprintf(flibinfo, "\\n\"\n"); bol++; }else{ - putchar(inchar); + putc(inchar, flibinfo); } } if (feof(fsettings)){ /* wrap up */ if (!bol){ /* EOF found without a new line */ - printf("\\n\"\n"); + fprintf(flibinfo, "\\n\"\n"); }; - printf(";\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); + } +} + + +/*------------------------------------------------------------------------- + * 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); } @@ -623,11 +652,13 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) /********************/\n\ /* Public Variables */\n\ /********************/\n\ -\n\n\ +\n\ +\n\ /*****************************/\n\ /* Library Private Variables */\n\ /*****************************/\n\ -\n\n\ +\n\ +\n\ /*********************/\n\ /* Package Variables */\n\ /*********************/\n\ @@ -640,8 +671,8 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) \n"); #ifdef H5_HAVE_EMBEDDED_LIBINFO - /* Insert content of libhdf5.settings */ - insert_libhdf5_settings(); + /* Generate embedded library information files */ + make_libinfo(); #endif /* The interface initialization function */ @@ -1119,8 +1150,8 @@ find_bias(int epos, int esize, int *perm, void *_a) /*------------------------------------------------------------------------- * Function: print_header - * - * Purpose: Prints the C file header for the generated file. + * + * Purpose: Prints the C file header for the generated file. * * Return: void * diff --git a/src/H5private.h b/src/H5private.h index ccfbd5d..12af8e7 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1514,6 +1514,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.am b/test/Makefile.am index 958d4c5..f0aa131 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -24,7 +24,7 @@ include $(top_srcdir)/config/commence.am INCLUDES=-I$(top_srcdir)/src -I$(top_builddir)/src # Test script for error_test and err_compat -TEST_SCRIPT = testerror.sh +TEST_SCRIPT = testerror.sh testlibinfo.sh check_SCRIPTS = $(TEST_SCRIPT) SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) diff --git a/test/Makefile.in b/test/Makefile.in index b283fd2..15bc4e0 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -53,7 +53,8 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/testerror.sh.in $(top_srcdir)/config/commence.am \ + $(srcdir)/testerror.sh.in $(srcdir)/testlibinfo.sh.in \ + $(top_srcdir)/config/commence.am \ $(top_srcdir)/config/conclude.am COPYING check_PROGRAMS = $(am__EXEEXT_1) error_test$(EXEEXT) \ err_compat$(EXEEXT) testmeta$(EXEEXT) @@ -66,7 +67,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs CONFIG_HEADER = $(top_builddir)/src/H5config.h -CONFIG_CLEAN_FILES = testerror.sh +CONFIG_CLEAN_FILES = testerror.sh testlibinfo.sh CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libh5test_la_LIBADD = @@ -657,7 +658,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \ INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src # Test script for error_test and err_compat -TEST_SCRIPT = testerror.sh +TEST_SCRIPT = testerror.sh testlibinfo.sh check_SCRIPTS = $(TEST_SCRIPT) SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) @@ -764,6 +765,8 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): testerror.sh: $(top_builddir)/config.status $(srcdir)/testerror.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +testlibinfo.sh: $(top_builddir)/config.status $(srcdir)/testlibinfo.sh.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) diff --git a/test/testlibinfo.sh.in b/test/testlibinfo.sh.in new file mode 100644 index 0000000..df440ef --- /dev/null +++ b/test/testlibinfo.sh.in @@ -0,0 +1,77 @@ +#! /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@ + +# Function definitions +CHECK_LIBINFO(){ + echo Checking file $1 + strings $1 | grep "SUMMARY OF THE HDF5 CONFIGURATION" +} + + + + +# MAIN Body + +# 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 + +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.so +fi + +# Though rare, libhdf5.a may not have been built. +if [ x-$Static_Lib = x-yes ]; then + CHECK_LIBINFO ${h5libdir}/libhdf5.a +fi + +# Check if executables has the lib information only if shared lib is not +# built or static-exec is used. +if [ x-$Shared_Lib != x-yes -o x-$Static_exec = x-yes ]; then + CHECK_LIBINFO testhdf5 +fi + + +exit $? + diff --git a/tools/lib/Makefile.in b/tools/lib/Makefile.in index 14d9a6d..55785c7 100644 --- a/tools/lib/Makefile.in +++ b/tools/lib/Makefile.in @@ -72,6 +72,7 @@ am_libh5tools_la_OBJECTS = h5tools.lo h5tools_str.lo h5tools_utils.lo \ h5diff_util.lo h5trav.lo h5tools_filters.lo h5tools_ref.lo \ h5tools_type.lo libh5tools_la_OBJECTS = $(am_libh5tools_la_OBJECTS) +am__EXEEXT_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src depcomp = $(SHELL) $(top_srcdir)/bin/depcomp am__depfiles_maybe = depfiles @@ -354,7 +355,7 @@ libh5tools_la_SOURCES = h5tools.c h5tools_str.c h5tools_utils.c h5diff.c \ # Test program. Link using libhdf5 and libh5tools -TEST_PROG = +TEST_PROG = # Name libh5tools.la so that dependencies work out. Automake knows how # to build 'libh5tools.la', but not '../../tools/lib/libh5tools.la'. diff --git a/tools/misc/Makefile.in b/tools/misc/Makefile.in index 5f5d640..78a42b8 100644 --- a/tools/misc/Makefile.in +++ b/tools/misc/Makefile.in @@ -71,13 +71,6 @@ CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" am__EXEEXT_1 = h5repart_gentest$(EXEEXT) talign$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) -talign_SOURCES = talign.c -talign_OBJECTS = talign.$(OBJEXT) -talign_LDADD = $(LDADD) -talign_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5) -talign_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(talign_LDFLAGS) \ - $(LDFLAGS) -o $@ h5debug_SOURCES = h5debug.c h5debug_OBJECTS = h5debug.$(OBJEXT) h5debug_LDADD = $(LDADD) @@ -107,6 +100,10 @@ repart_test_SOURCES = repart_test.c repart_test_OBJECTS = repart_test.$(OBJEXT) repart_test_LDADD = $(LDADD) repart_test_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5) +talign_SOURCES = talign.c +talign_OBJECTS = talign.$(OBJEXT) +talign_LDADD = $(LDADD) +talign_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ -- cgit v0.12