From 1eaad0a8c4cab227685a6a8768e539df2f1f4dac Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 18 Mar 2013 15:31:34 +0100 Subject: Provide GCRYPT_VERSION_NUMBER macro, add build info to the binary. * src/gcrypt.h.in (GCRYPT_VERSION_NUMBER): New. * configure.ac (VERSION_NUMBER): New ac_subst. * src/global.c (_gcry_vcontrol): Move call to above function ... (gcry_check_version): .. here. * configure.ac (BUILD_REVISION, BUILD_FILEVERSION) (BUILD_TIMESTAMP): Define on all platforms. * compat/compat.c (_gcry_compat_identification): Include revision and timestamp. --- NEWS | 1 + compat/compat.c | 3 +++ configure.ac | 32 +++++++++++++++++++++----------- src/gcrypt.h.in | 5 +++++ src/global.c | 5 +++-- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index 429f6664..0d75680c 100644 --- a/NEWS +++ b/NEWS @@ -57,6 +57,7 @@ Noteworthy changes in version 1.6.0 (unreleased) gcry_mpi_ec_mul NEW. GCRYMPI_FLAG_IMMUTABLE NEW. GCRYMPI_FLAG_CONST NEW. + GCRYPT_VERSION_NUMBER NEW. Noteworthy changes in version 1.5.0 (2011-06-29) diff --git a/compat/compat.c b/compat/compat.c index 96889d32..d2591304 100644 --- a/compat/compat.c +++ b/compat/compat.c @@ -30,6 +30,9 @@ _gcry_compat_identification (void) "This is Libgcrypt " PACKAGE_VERSION " - The GNU Crypto Library\n" "Copyright 2000, 2002, 2003, 2004, 2007, 2008, 2009,\n" " 2010, 2011, 2012 Free Software Foundation, Inc.\n" + "Copyright 2012, 2013 g10 Code GmbH\n" + "\n" + "(" BUILD_REVISION " " BUILD_TIMESTAMP ")\n" "\n\n"; return blurb; } diff --git a/configure.ac b/configure.ac index 7afd83d1..7504d76c 100644 --- a/configure.ac +++ b/configure.ac @@ -28,12 +28,16 @@ min_automake_version="1.10" # bump the version number immediately after the release and do another # commit and push so that the git magic is able to work. See below # for the LT versions. -m4_define(mym4_version, [1.6.0]) +m4_define(mym4_version_major, [1]) +m4_define(mym4_version_minor, [6]) +m4_define(mym4_version_micro, [0]) # Below is m4 magic to extract and compute the revision number, the # decimalized short revision number, a beta version string, and a flag # indicating a development version (mym4_isgit). Note that the m4 # processing is done by autoconf and not during the configure run. +m4_define(mym4_version, + [mym4_version_major.mym4_version_minor.mym4_version_micro]) m4_define([mym4_revision], m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r'])) m4_define([mym4_revision_dec], @@ -125,6 +129,9 @@ AC_SUBST(PACKAGE) AC_SUBST(VERSION) AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package]) +VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x%02x" mym4_version_major \ + mym4_version_minor mym4_version_micro) +AC_SUBST(VERSION_NUMBER) ###################### @@ -1341,21 +1348,24 @@ esac AC_SUBST([GCRYPT_HWF_MODULES]) -# Generate extended version information for W32. -if test "$have_w32_system" = yes; then - BUILD_TIMESTAMP=`date --iso-8601=minutes` - changequote(,)dnl - BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'` - changequote([,])dnl - BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec" -fi +# +# Provide information about the build. +# BUILD_REVISION="mym4_revision" AC_SUBST(BUILD_REVISION) -AC_SUBST(BUILD_TIMESTAMP) -AC_SUBST(BUILD_FILEVERSION) AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION", [GIT commit id revision used to build this package]) +changequote(,)dnl +BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'` +changequote([,])dnl +BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec" +AC_SUBST(BUILD_FILEVERSION) + +BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date` +AC_SUBST(BUILD_TIMESTAMP) +AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP", + [The time this package was configured for a build]) # And create the files. diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in index ad4da049..83437991 100644 --- a/src/gcrypt.h.in +++ b/src/gcrypt.h.in @@ -66,6 +66,11 @@ extern "C" { matches the installed library. */ #define GCRYPT_VERSION "@VERSION@" +/* The version number of this header. It may be used to handle minor + API incompatibilities. */ +#define GCRYPT_VERSION_NUMBER @VERSION_NUMBER@ + + /* Internal: We can't use the convenience macros for the multi precision integer functions when building this library. */ #ifdef _GCRYPT_IN_LIBGCRYPT diff --git a/src/global.c b/src/global.c index 0c6fbbdd..f8738975 100644 --- a/src/global.c +++ b/src/global.c @@ -247,6 +247,9 @@ gcry_check_version( const char *req_version ) int rq_major, rq_minor, rq_micro; const char *my_plvl; + if (req_version && req_version[0] == 1 && req_version[1] == 1) + return _gcry_compat_identification (); + /* Initialize library. */ global_init (); @@ -686,8 +689,6 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr) default: _gcry_set_preferred_rng_type (0); - /* A call to make sure that the dummy code is linked in. */ - _gcry_compat_identification (); err = GPG_ERR_INV_OP; } -- cgit v1.2.1