From 99840ed7daa2f3a0430059f6c3fabbb894b6b35c Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Wed, 25 Feb 2015 17:42:04 +0000 Subject: [PATCH] GRIB-446 and GRIB-693: Missing version information in grib_api header files --- configure.ac | 30 ++++++++++++++--------- eccodes_config.h.in | 10 ++++---- make_dist_definitions | 2 +- src/CMakeLists.txt | 3 +++ src/Makefile.am | 2 +- src/eccodes.h | 2 +- src/eccodes_version.h.in | 21 ++++++++++++++++ src/grib_accessor_class_library_version.c | 6 ++--- src/grib_api.h | 3 +-- src/grib_api_internal.h | 5 ---- src/grib_context.c | 10 ++++---- tools/codes_info.c | 8 +++--- tools/grib_to_netcdf.c | 6 ++--- version.sh | 6 ++--- 14 files changed, 70 insertions(+), 44 deletions(-) create mode 100644 src/eccodes_version.h.in diff --git a/configure.ac b/configure.ac index 32c3ac2a4..61f1641ca 100755 --- a/configure.ac +++ b/configure.ac @@ -15,11 +15,18 @@ AC_CONFIG_MACRO_DIR([m4]) . ${srcdir}/version.sh -GRIB_API_MAIN_VERSION="${GRIB_API_MAJOR_VERSION}.${GRIB_API_MINOR_VERSION}.${GRIB_API_REVISION_VERSION}" - echo $GRIB_API_MAIN_VERSION +ECCODES_MAIN_VERSION="${ECCODES_MAJOR_VERSION}.${ECCODES_MINOR_VERSION}.${ECCODES_REVISION_VERSION}" + echo $ECCODES_MAIN_VERSION + +PACKAGE_VERSION="${ECCODES_MAIN_VERSION}" +ECCODES_VERSION_STR="${ECCODES_MAIN_VERSION}" +ECCODES_PATCH_VERSION="${ECCODES_REVISION_VERSION}" +AC_SUBST(ECCODES_MAIN_VERSION) +AC_SUBST(ECCODES_VERSION_STR) +AC_SUBST(ECCODES_MAJOR_VERSION) +AC_SUBST(ECCODES_MINOR_VERSION) +AC_SUBST(ECCODES_PATCH_VERSION) -PACKAGE_VERSION="${GRIB_API_MAIN_VERSION}" -AC_SUBST(GRIB_API_MAIN_VERSION) AC_SUBST(GRIB_ABI_CURRENT) AC_SUBST(GRIB_ABI_REVISION) AC_SUBST(GRIB_ABI_AGE) @@ -31,6 +38,7 @@ AM_SANITY_CHECK AC_CONFIG_SRCDIR([src/grib_api.h]) AC_CONFIG_HEADER([src/config.h]) +AC_CONFIG_FILES([src/eccodes_version.h]) AC_CONFIG_FILES([rpms/eccodes.pc rpms/eccodes.spec rpms/eccodes_f90.pc]) AM_INIT_AUTOMAKE($PACKAGE_NAME,[${PACKAGE_VERSION}],[http://www.ecmwf.int]) @@ -39,14 +47,14 @@ samples_files_path="${datadir}/eccodes/samples" ifs_samples_files_path="${datadir}/eccodes/ifs_samples" default_perl_install="${prefix}/perl" -AC_DEFINE_UNQUOTED(GRIB_API_MAIN_VERSION,$GRIB_API_MAIN_VERSION,Grib Api version) -AC_DEFINE_UNQUOTED(GRIB_API_MAJOR_VERSION,$GRIB_API_MAJOR_VERSION,Grib Api Major release) -AC_DEFINE_UNQUOTED(GRIB_API_MINOR_VERSION,$GRIB_API_MINOR_VERSION,Grib Api Minor release) -AC_DEFINE_UNQUOTED(GRIB_API_REVISION_VERSION,$GRIB_API_REVISION_VERSION,Grib Api Revision release) +AC_DEFINE_UNQUOTED(ECCODES_MAIN_VERSION,$ECCODES_MAIN_VERSION,ecCodes version) +AC_DEFINE_UNQUOTED(ECCODES_MAJOR_VERSION,$ECCODES_MAJOR_VERSION,ecCodes Major release) +AC_DEFINE_UNQUOTED(ECCODES_MINOR_VERSION,$ECCODES_MINOR_VERSION,ecCodes Minor release) +AC_DEFINE_UNQUOTED(ECCODES_REVISION_VERSION,$ECCODES_REVISION_VERSION,ecCodes Revision release) -AC_DEFINE_UNQUOTED(GRIB_ABI_CURRENT,$GRIB_ABI_CURRENT,Grib Api Current ABI version) -AC_DEFINE_UNQUOTED(GRIB_ABI_REVISION,$GRIB_ABI_REVISION,Grib Api Revision ABI version) -AC_DEFINE_UNQUOTED(GRIB_ABI_AGE,$GRIB_ABI_AGE,Grib Api Age of ABI version) +AC_DEFINE_UNQUOTED(GRIB_ABI_CURRENT,$GRIB_ABI_CURRENT,ecCodes Current ABI version) +AC_DEFINE_UNQUOTED(GRIB_ABI_REVISION,$GRIB_ABI_REVISION,ecCodes Revision ABI version) +AC_DEFINE_UNQUOTED(GRIB_ABI_AGE,$GRIB_ABI_AGE,ecCodes Age of ABI version) AH_TEMPLATE([_LARGE_FILE_API], diff --git a/eccodes_config.h.in b/eccodes_config.h.in index 593c90cd7..d09883a1c 100644 --- a/eccodes_config.h.in +++ b/eccodes_config.h.in @@ -13,13 +13,13 @@ #include "eccodes_ecbuild_config.h" /* generated by ecbuild */ -#define GRIB_API_VERSION_STR "@ECCODES_VERSION_STR@" +#define ECCODES_VERSION_STR "@ECCODES_VERSION_STR@" -/* GRIB_API_VERSION is defined in grib_api.h from the 3 version components below */ +/* ECCODES_VERSION is defined in grib_api.h from the 3 version components below */ -#define GRIB_API_MAJOR_VERSION @ECCODES_MAJOR_VERSION@ -#define GRIB_API_MINOR_VERSION @ECCODES_MINOR_VERSION@ -#define GRIB_API_REVISION_VERSION @ECCODES_PATCH_VERSION@ +#define ECCODES_MAJOR_VERSION @ECCODES_MAJOR_VERSION@ +#define ECCODES_MINOR_VERSION @ECCODES_MINOR_VERSION@ +#define ECCODES_REVISION_VERSION @ECCODES_PATCH_VERSION@ #define ECCODES_DEFINITION_PATH "@ECCODES_DEFINITION_PATH@" diff --git a/make_dist_definitions b/make_dist_definitions index 8dd1ed760..7dc3598e4 100755 --- a/make_dist_definitions +++ b/make_dist_definitions @@ -2,7 +2,7 @@ set -e make dist . ./version.sh -libraryVersion=$GRIB_API_MAJOR_VERSION.$GRIB_API_MINOR_VERSION.$GRIB_API_REVISION_VERSION +libraryVersion=$ECCODES_MAJOR_VERSION.$ECCODES_MINOR_VERSION.$ECCODES_REVISION_VERSION tar=grib_api-$libraryVersion.tar.gz dir=grib_api-$libraryVersion diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9ccc5fd01..5b6c0dd64 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -368,6 +368,7 @@ list( APPEND grib_api_extra_srcs ) configure_file( grib_api_version.c.in grib_api_version.c @ONLY ) +configure_file( eccodes_version.h.in eccodes_version.h @ONLY ) # We ship our own generated lex/yacc C files #ecbuild_generate_yy(YYPREFIX grib_yy @@ -390,3 +391,5 @@ ecbuild_add_library(TARGET eccodes install( FILES grib_api.h eccodes.h eccodes_windef.h DESTINATION include ) +install( FILES ${CMAKE_CURRENT_BINARY_DIR}/eccodes_version.h DESTINATION include ) + diff --git a/src/Makefile.am b/src/Makefile.am index 08d8991af..b5aeffce3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = -DECCODES_SAMPLES_PATH=\"$(ECCODES_SAMPLES_PATH)\" \ lib_LTLIBRARIES = libeccodes.la -include_HEADERS = grib_api.h eccodes.h eccodes_windef.h +include_HEADERS = grib_api.h eccodes.h eccodes_windef.h eccodes_version.h libeccodes_la_prototypes= \ action.c \ diff --git a/src/eccodes.h b/src/eccodes.h index 9444ed89d..9d0be058d 100644 --- a/src/eccodes.h +++ b/src/eccodes.h @@ -24,7 +24,7 @@ extern "C" { #include "grib_api.h" -#define CODES_VERSION GRIB_API_VERSION +#define CODES_VERSION ECCODES_VERSION /* sections */ #define CODES_SECTION_PRODUCT GRIB_SECTION_PRODUCT diff --git a/src/eccodes_version.h.in b/src/eccodes_version.h.in new file mode 100644 index 000000000..fc141da91 --- /dev/null +++ b/src/eccodes_version.h.in @@ -0,0 +1,21 @@ +/* + * Copyright 2005-2015 ECMWF. + * + * This software is licensed under the terms of the Apache Licence Version 2.0 + * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. + * + * In applying this licence, ECMWF does not waive the privileges and immunities granted to it by + * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. + */ + +#ifndef eccodes_version_H +#define eccodes_version_H + +#define ECCODES_VERSION_STR "@ECCODES_VERSION_STR@" + +#define ECCODES_MAJOR_VERSION @ECCODES_MAJOR_VERSION@ +#define ECCODES_MINOR_VERSION @ECCODES_MINOR_VERSION@ +#define ECCODES_REVISION_VERSION @ECCODES_PATCH_VERSION@ +#define ECCODES_VERSION (ECCODES_MAJOR_VERSION*10000+ECCODES_MINOR_VERSION*100+ECCODES_REVISION_VERSION) + +#endif /* eccodes_version_H */ diff --git a/src/grib_accessor_class_library_version.c b/src/grib_accessor_class_library_version.c index c27c468d5..791465036 100644 --- a/src/grib_accessor_class_library_version.c +++ b/src/grib_accessor_class_library_version.c @@ -135,9 +135,9 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len) char result[30]={0,}; size_t size; - int major=GRIB_API_MAJOR_VERSION; - int minor=GRIB_API_MINOR_VERSION; - int revision=GRIB_API_REVISION_VERSION; + int major=ECCODES_MAJOR_VERSION; + int minor=ECCODES_MINOR_VERSION; + int revision=ECCODES_REVISION_VERSION; sprintf(result,"%d.%d.%d",major,minor,revision); size=sizeof(result); diff --git a/src/grib_api.h b/src/grib_api.h index d8dfb46aa..36a311610 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -41,8 +41,7 @@ extern "C" { typedef enum ProductKind {PRODUCT_GRIB, PRODUCT_BUFR, PRODUCT_ANY} ProductKind; - -#define GRIB_API_VERSION (GRIB_API_MAJOR_VERSION*10000+GRIB_API_MINOR_VERSION*100+GRIB_API_REVISION_VERSION) +#include "eccodes_version.h" /* sections */ #define GRIB_SECTION_PRODUCT (1<<0) diff --git a/src/grib_api_internal.h b/src/grib_api_internal.h index 2a0215dde..d850c4060 100644 --- a/src/grib_api_internal.h +++ b/src/grib_api_internal.h @@ -74,11 +74,6 @@ extern "C" { /* Replace Unix rint() for Windows */ double rint(double x); - /* define version numbers here on Windows */ - #define GRIB_API_MAJOR_VERSION 0 - #define GRIB_API_MINOR_VERSION 10 - #define GRIB_API_REVISION_VERSION 0 - #ifndef S_ISREG #define S_ISREG(mode) (mode & S_IFREG) #endif diff --git a/src/grib_context.c b/src/grib_context.c index cb79b5a80..4d0eaa6bc 100644 --- a/src/grib_context.c +++ b/src/grib_context.c @@ -221,16 +221,16 @@ void grib_context_set_logging_proc(grib_context* c, grib_log_proc p) long grib_get_api_version() { - return GRIB_API_VERSION; + return ECCODES_VERSION; } void grib_print_api_version(FILE* out) { fprintf(out,"%d.%d.%d", - GRIB_API_MAJOR_VERSION, - GRIB_API_MINOR_VERSION, - GRIB_API_REVISION_VERSION); - if (GRIB_API_MAJOR_VERSION < 1) { + ECCODES_MAJOR_VERSION, + ECCODES_MINOR_VERSION, + ECCODES_REVISION_VERSION); + if (ECCODES_MAJOR_VERSION < 1) { fprintf(out, "%s", " PRE-RELEASE"); } } diff --git a/tools/codes_info.c b/tools/codes_info.c index b9c7a094b..251d906ac 100644 --- a/tools/codes_info.c +++ b/tools/codes_info.c @@ -30,9 +30,9 @@ int main( int argc,char* argv[]) int c=0; int nfiles=0; unsigned long print_flags=0; - int major=GRIB_API_MAJOR_VERSION; - int minor=GRIB_API_MINOR_VERSION; - int revision=GRIB_API_REVISION_VERSION; + int major=ECCODES_MAJOR_VERSION; + int minor=ECCODES_MINOR_VERSION; + int revision=ECCODES_REVISION_VERSION; while (1) { c = getopt (argc, argv, "vds"); @@ -62,7 +62,7 @@ int main( int argc,char* argv[]) printf("\n"); printf("eccodes Version %d.%d.%d", major,minor,revision); - if (GRIB_API_MAJOR_VERSION < 1) printf(" PRE-RELEASE"); + if (ECCODES_MAJOR_VERSION < 1) printf(" PRE-RELEASE"); printf("\n"); printf("\n"); #if GRIB_PTHREADS diff --git a/tools/grib_to_netcdf.c b/tools/grib_to_netcdf.c index b7137c2a8..d1cf72f50 100644 --- a/tools/grib_to_netcdf.c +++ b/tools/grib_to_netcdf.c @@ -3046,9 +3046,9 @@ static int define_netcdf_dimensions(hypercube *h, fieldset *fs, int ncid, datase } else { - int major = GRIB_API_MAJOR_VERSION; - int minor = GRIB_API_MINOR_VERSION; - int revision = GRIB_API_REVISION_VERSION; + int major = ECCODES_MAJOR_VERSION; + int minor = ECCODES_MINOR_VERSION; + int revision = ECCODES_REVISION_VERSION; time(&now); strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S GMT", gmtime(&now)); diff --git a/version.sh b/version.sh index a5af3189b..de5db9130 100644 --- a/version.sh +++ b/version.sh @@ -13,9 +13,9 @@ PACKAGE_NAME='eccodes' # Package version -GRIB_API_MAJOR_VERSION=0 -GRIB_API_MINOR_VERSION=10 -GRIB_API_REVISION_VERSION=0 +ECCODES_MAJOR_VERSION=0 +ECCODES_MINOR_VERSION=10 +ECCODES_REVISION_VERSION=0 GRIB_ABI_CURRENT=1 GRIB_ABI_REVISION=0