2
0
mirror of https://github.com/HDFGroup/hdf5.git synced 2025-04-12 17:31:09 +08:00

[svn-r18415] Description:

Move the libhdf5.settings information out of src/H5Tinit.c and into a
separate header file (src/H5lib_settings.h), which is generated at build time
(not configure time) with the src/H5make_libsettings generator program.

Tested on:
    Linux/32 2.6 (jam)
    Mac OS X/32 10.6.2 (amazon)
This commit is contained in:
Quincey Koziol 2010-03-17 21:44:26 -05:00
parent 0ac03c7890
commit 0a7809a659
7 changed files with 326 additions and 109 deletions

2
configure vendored

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Id: configure.in 18406 2010-03-14 15:04:16Z hdftest .
# From configure.in Id: configure.in 18413 2010-03-17 21:38:20Z koziol .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.64 for HDF5 1.9.63.
#

@ -22,6 +22,8 @@
/* Headers */
/***********/
#include "H5private.h" /* Generic Functions */
#include "H5lib_settings.h" /* Library build setings */
#include "H5ACprivate.h" /* Metadata cache */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */

@ -109,7 +109,6 @@ static void detect_C99_integers32(void);
static void detect_C99_integers64(void);
static void detect_alignments(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;
@ -502,99 +501,6 @@ sigbus_handler(int UNUSED signo)
#endif /* H5_HAVE_SIGLONGJMP */
}
/*-------------------------------------------------------------------------
* 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
@ -677,9 +583,6 @@ 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\
\n\
@ -1154,8 +1057,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
*

278
src/H5make_libsettings.c Normal file

@ -0,0 +1,278 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*keep this declaration near the top of this file -RPM*/
static const char *FileHeader = "\n\
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\
* Copyright by The HDF Group. *\n\
* Copyright by the Board of Trustees of the University of Illinois. *\n\
* All rights reserved. *\n\
* *\n\
* This file is part of HDF5. The full HDF5 copyright notice, including *\n\
* terms governing use, modification, and redistribution, is contained in *\n\
* the files COPYING and Copyright.html. COPYING can be found at the root *\n\
* of the source code distribution tree; Copyright.html can be found at the *\n\
* root level of an installed copy of the electronic HDF5 document set and *\n\
* is linked from the top-level documents page. It can also be found at *\n\
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *\n\
* access to either file, you may request a copy from help@hdfgroup.org. *\n\
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *";
/*
*
* Created: H5make_libsettings.c
* 17 Mar 2010
* Quincey Koziol
*
* Purpose: Generate the H5libsettings.h header file from the
* libhdf5.settings file.
*
*-------------------------------------------------------------------------
*/
#include <stdio.h>
#include <time.h>
#include "H5private.h"
#define LIBSETTINGSFNAME "libhdf5.settings"
/*-------------------------------------------------------------------------
* 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
*
*-------------------------------------------------------------------------
*/
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, "static const 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, "static const char H5libhdf5_settings[]=\"\";\n");
#endif
} /* insert_libhdf5_settings() */
/*-------------------------------------------------------------------------
* 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
*
*-------------------------------------------------------------------------
*/
static void
make_libinfo(void)
{
/* print variable definition and then the string as a macro. */
insert_libhdf5_settings(stdout);
}
/*-------------------------------------------------------------------------
* Function: print_header
*
* Purpose: Prints the C file header for the generated file.
*
* Return: void
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Mar 12 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
print_header(void)
{
time_t now = time(NULL);
struct tm *tm = localtime(&now);
char real_name[30];
char host_name[256];
int i;
const char *s;
#ifdef H5_HAVE_GETPWUID
struct passwd *pwd = NULL;
#else
int pwd = 1;
#endif
static const char *month_name[] =
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
static const char *purpose = "\
This machine-generated source code contains\n\
information about the library build configuration\n";
/*
* The real name is the first item from the passwd gecos field.
*/
#ifdef H5_HAVE_GETPWUID
{
size_t n;
char *comma;
if ((pwd = getpwuid(getuid()))) {
if ((comma = strchr(pwd->pw_gecos, ','))) {
n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos));
strncpy(real_name, pwd->pw_gecos, n);
real_name[n] = '\0';
} else {
strncpy(real_name, pwd->pw_gecos, sizeof(real_name));
real_name[sizeof(real_name) - 1] = '\0';
}
} else {
real_name[0] = '\0';
}
}
#else
real_name[0] = '\0';
#endif
/*
* The FQDM of this host or the empty string.
*/
#ifdef H5_HAVE_GETHOSTNAME
if (gethostname(host_name, sizeof(host_name)) < 0) {
host_name[0] = '\0';
}
#else
host_name[0] = '\0';
#endif
/*
* The file header: warning, copyright notice, build information.
*/
printf("/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n");
puts(FileHeader); /*the copyright notice--see top of this file */
printf(" *\n * Created:\t\t%s %2d, %4d\n",
month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year);
if (pwd || real_name[0] || host_name[0]) {
printf(" *\t\t\t");
if (real_name[0]) printf("%s <", real_name);
#ifdef H5_HAVE_GETPWUID
if (pwd) fputs(pwd->pw_name, stdout);
#endif
if (host_name[0]) printf("@%s", host_name);
if (real_name[0]) printf(">");
putchar('\n');
}
printf(" *\n * Purpose:\t\t");
for (s = purpose; *s; s++) {
putchar(*s);
if ('\n' == *s && s[1]) printf(" *\t\t\t");
}
printf(" *\n * Modifications:\n *\n");
printf(" *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
printf(" *\tIt was generated by code in `H5make_libsettings.c'.\n");
printf(" *\n *");
for (i = 0; i < 73; i++) putchar('-');
printf("\n */\n\n");
}
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Main entry point.
*
* Return: Success: exit(0)
*
* Failure: exit(1)
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Jun 12, 1996
*
* Modifications:
* Albert Cheng, 2004/05/20
* Some compilers, e.g., Intel C v7.0, took a long time to compile
* with optimization when a module routine contains many code lines.
* Divide up all those types detections macros into subroutines, both
* to avoid the compiler optimization error and cleaner codes.
*
*-------------------------------------------------------------------------
*/
int
main(void)
{
print_header();
/* Generate embedded library information variable definition */
make_libinfo();
return 0;
}

@ -1535,7 +1535,6 @@ 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

@ -26,7 +26,7 @@ include $(top_srcdir)/config/lt_vers.am
# Use -g to force no optimization since many compilers (e.g., Intel) takes
# a long time to compile it with any optimization on. H5detect is used
# to generate H5Tinit.c once. So, optimization is not critical.
noinst_PROGRAMS = H5detect
noinst_PROGRAMS = H5detect H5make_libsettings
H5detect_CFLAGS = -g $(AM_CFLAGS)
# Our main target, the HDF5 library
@ -36,7 +36,7 @@ lib_LTLIBRARIES=libhdf5.la
libhdf5_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS)
# H5Tinit.c is a generated file, and should be cleaned.
MOSTLYCLEANFILES=H5Tinit.c
MOSTLYCLEANFILES=H5Tinit.c H5lib_settings.h
# H5pubconf.h is generated by configure, and should be cleaned.
DISTCLEANFILES=H5pubconf.h
@ -127,13 +127,27 @@ settings_DATA=libhdf5.settings
# Things should have been all set during H5detect making.
# Remove the generated .c file if errors occur unless HDF5_Make_Ignore
# is set to ignore the error.
H5Tinit.c: H5detect$(EXEEXT) libhdf5.settings
H5Tinit.c: H5detect$(EXEEXT)
LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \
sed -e 's/-L/:/g' -e 's/ //g'`" \
$(RUNSERIAL) ./H5detect$(EXEEXT) > H5Tinit.c || \
(test $$HDF5_Make_Ignore && echo "*** Error ignored") || \
($(RM) $@ ; exit 1)
H5.o H5.lo: H5lib_settings.h
# Build configuration header file generation
# The LD_LIBRARY_PATH setting is a kludge.
# Things should have been all set during H5make_libsettings making.
# Remove the generated .h file if errors occur unless HDF5_Make_Ignore
# is set to ignore the error.
H5lib_settings.h: H5make_libsettings$(EXEEXT) libhdf5.settings
LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \
sed -e 's/-L/:/g' -e 's/ //g'`" \
$(RUNSERIAL) ./H5make_libsettings$(EXEEXT) > H5lib_settings.h || \
(test $$HDF5_Make_Ignore && echo "*** Error ignored") || \
($(RM) $@ ; exit 1)
# Error header generation
#
# Actually, H5Einit.h, H5Eterm.h, H5Edefin.h and H5Epubgen.h all

@ -59,7 +59,7 @@ DIST_COMMON = $(include_HEADERS) $(srcdir)/H5config.h.in \
$(srcdir)/libhdf5.settings.in $(top_srcdir)/config/commence.am \
$(top_srcdir)/config/conclude.am \
$(top_srcdir)/config/lt_vers.am COPYING
noinst_PROGRAMS = H5detect$(EXEEXT)
noinst_PROGRAMS = H5detect$(EXEEXT) H5make_libsettings$(EXEEXT)
TESTS =
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -157,6 +157,9 @@ H5detect_LDADD = $(LDADD)
H5detect_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(H5detect_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
H5make_libsettings_SOURCES = H5make_libsettings.c
H5make_libsettings_OBJECTS = H5make_libsettings.$(OBJEXT)
H5make_libsettings_LDADD = $(LDADD)
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp
am__depfiles_maybe = depfiles
@ -170,8 +173,8 @@ CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(libhdf5_la_SOURCES) H5detect.c
DIST_SOURCES = $(libhdf5_la_SOURCES) H5detect.c
SOURCES = $(libhdf5_la_SOURCES) H5detect.c H5make_libsettings.c
DIST_SOURCES = $(libhdf5_la_SOURCES) H5detect.c H5make_libsettings.c
DATA = $(settings_DATA)
HEADERS = $(include_HEADERS)
ETAGS = etags
@ -451,7 +454,7 @@ lib_LTLIBRARIES = libhdf5.la
libhdf5_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS)
# H5Tinit.c is a generated file, and should be cleaned.
MOSTLYCLEANFILES = H5Tinit.c
MOSTLYCLEANFILES = H5Tinit.c H5lib_settings.h
# H5pubconf.h is generated by configure, and should be cleaned.
DISTCLEANFILES = H5pubconf.h
@ -652,6 +655,9 @@ clean-noinstPROGRAMS:
H5detect$(EXEEXT): $(H5detect_OBJECTS) $(H5detect_DEPENDENCIES)
@rm -f H5detect$(EXEEXT)
$(H5detect_LINK) $(H5detect_OBJECTS) $(H5detect_LDADD) $(LIBS)
H5make_libsettings$(EXEEXT): $(H5make_libsettings_OBJECTS) $(H5make_libsettings_DEPENDENCIES)
@rm -f H5make_libsettings$(EXEEXT)
$(LINK) $(H5make_libsettings_OBJECTS) $(H5make_libsettings_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@ -911,6 +917,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5checksum.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5dbg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5detect-H5detect.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5make_libsettings.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5system.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5timer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5trace.Plo@am__quote@
@ -1235,13 +1242,27 @@ help:
# Things should have been all set during H5detect making.
# Remove the generated .c file if errors occur unless HDF5_Make_Ignore
# is set to ignore the error.
H5Tinit.c: H5detect$(EXEEXT) libhdf5.settings
H5Tinit.c: H5detect$(EXEEXT)
LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \
sed -e 's/-L/:/g' -e 's/ //g'`" \
$(RUNSERIAL) ./H5detect$(EXEEXT) > H5Tinit.c || \
(test $$HDF5_Make_Ignore && echo "*** Error ignored") || \
($(RM) $@ ; exit 1)
H5.o H5.lo: H5lib_settings.h
# Build configuration header file generation
# The LD_LIBRARY_PATH setting is a kludge.
# Things should have been all set during H5make_libsettings making.
# Remove the generated .h file if errors occur unless HDF5_Make_Ignore
# is set to ignore the error.
H5lib_settings.h: H5make_libsettings$(EXEEXT) libhdf5.settings
LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \
sed -e 's/-L/:/g' -e 's/ //g'`" \
$(RUNSERIAL) ./H5make_libsettings$(EXEEXT) > H5lib_settings.h || \
(test $$HDF5_Make_Ignore && echo "*** Error ignored") || \
($(RM) $@ ; exit 1)
# Error header generation
#
# Actually, H5Einit.h, H5Eterm.h, H5Edefin.h and H5Epubgen.h all