Change the various version numbers to the new scheme.

* configure.ac: Rename my_foo variables to mym4_foo variables to make
clear that they are processed by m4.
(VERSION_NUMBER): New ac_subst.
(AH_BOTTOM): Add CRIGHTBLURB macro.
(BUILD_REVISION, BUILD_FILEVERSION, BUILD_TIMESTAMP): Change them to
work similar to libgpg-error et al.
* src/versioninfo.rc.in: Remove use of BUILD_NUMBER and get it in line
with gpg-error et al.
* src/version.c (cright_blurb): New.
(gpgme_check_version_internal): Add magic to display the above
information.
* tests/t-version.c (main): Add option --verbose.
This commit is contained in:
Werner Koch 2013-02-26 17:10:18 +01:00
parent 863c0f2a3e
commit d8b46c919f
4 changed files with 124 additions and 53 deletions

View File

@ -22,31 +22,32 @@
AC_PREREQ(2.59)
min_automake_version="1.11"
# Version number: Remember to change it immediately *after* a release.
# Make sure to run "svn up" and "./autogen.sh --force"
# before a "make dist". See below for the LT versions.
# Never do a binary build with the same version number
# in another year; this would mess up the build number.
#
# The GIT version is usually the next intended release version with
# the string "-gitNNNNNN" appended. The reason for this is that tests
# for a specific feature can already be done under the assumption that
# the GIT version is the most recent one in a branch. To disable the
# GIT version for the real release, set the my_isgit macro to no.
m4_define(my_version_major, [1])
m4_define(my_version_minor, [4])
m4_define(my_version_micro, [0])
m4_define(my_isgit, [yes])
# To build a release you need to create a tag with the version number
# (git tag -s gpgme-n.m.k) and run "./autogen.sh --force". Please
# 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_major, [1])
m4_define(mym4_version_minor, [4])
m4_define(mym4_version_micro, [0])
m4_define(my_version, [my_version_major.my_version_minor.my_version_micro])
m4_define([svn_revision], m4_esyscmd([printf "%d" $( (svn info 2>/dev/null \
|| echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')]))
m4_define([git_revision],
# 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([my_full_version], [my_version[]m4_if(my_isgit,[yes],
[m4_if(git_revision,[],[-svn[]svn_revision],[-git[]git_revision])])])
m4_define([mym4_revision_dec],
m4_esyscmd_s([echo $((0x$(echo ]mym4_revision[|head -c 4)))]))
m4_define([mym4_betastring],
m4_esyscmd_s([git describe --match 'gpgme-[0-9].*[0-9]' --long|\
awk -F- '$3!=0{print"-beta"$3}']))
m4_define([mym4_isgit],m4_if(mym4_betastring,[],[no],[yes]))
m4_define([mym4_full_version],[mym4_version[]mym4_betastring])
AC_INIT([gpgme],[my_full_version],[http://bugs.gnupg.org])
AC_INIT([gpgme],[mym4_full_version],[http://bugs.gnupg.org])
# LT Version numbers, remember to change them just *before* a release.
# (Code changed: REVISION++)
@ -67,10 +68,7 @@ GPGME_CONFIG_API_VERSION=1
NEED_LIBASSUAN_API=2
NEED_LIBASSUAN_VERSION=2.0.2
m4_define([git_brevis],m4_esyscmd(printf "%u" 0x[]m4_substr(git_revision,0,4)))
BUILD_REVISION=m4_if(git_revision,[],[svn_revision],[git_brevis])
VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x%02x" \
my_version_major my_version_minor my_version_micro)
PACKAGE=$PACKAGE_NAME
VERSION=$PACKAGE_VERSION
@ -106,9 +104,11 @@ AC_SUBST(LIBGPGME_LT_REVISION)
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
AC_SUBST(VERSION_NUMBER)
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)
# Don't default to build static libs.
LT_PREREQ([2.2.6])
@ -232,6 +232,27 @@ AM_CONDITIONAL(BUILD_W32_QT, test "$build_w32_qt" = yes)
AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes")
#
# Provide information about the build.
#
BUILD_REVISION="mym4_revision"
AC_SUBST(BUILD_REVISION)
AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
[GIT commit id revision used to build this package])
changequote(,)dnl
BUILD_FILEVERSION=`echo "$PACKAGE_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])
# Checks for header files.
AC_CHECK_HEADERS_ONCE([locale.h sys/select.h sys/uio.h argp.h
@ -868,23 +889,6 @@ fi
AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no")
# Generate values for the DLL version info
dnl Windows uses an internal build number. We use the last day of the
dnl year concatenated with the hour for it. WARNING: You should not
dnl do a build with the same version number in another year.
if test "$have_w32_system" = yes; then
BUILD_TIMESTAMP=`date --iso-8601=minutes`
BUILD_NUMBER="$(date -u '+%j%H' | sed 's/^0*\(.*\)/\1/')"
changequote(,)dnl
BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
changequote([,])dnl
BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_NUMBER}"
fi
AC_SUBST(BUILD_NUMBER)
AC_SUBST(BUILD_TIMESTAMP)
AC_SUBST(BUILD_FILEVERSION)
# Add a few constants to help porting to W32
AH_VERBATIM([SEPCONSTANTS],
[
@ -906,6 +910,9 @@ AH_BOTTOM([
/* Under WindowsCE we need gpg-error's strerror macro. */
#define GPG_ERR_ENABLE_ERRNO_MACROS 1
#define CRIGHTBLURB "Copyright (C) 2000 Werner Koch\n" \
"Copyright (C) 2001--2013 g10 Code GmbH\n"
])
@ -977,7 +984,7 @@ AC_OUTPUT
echo "
GPGME v${VERSION} has been configured as follows:
Revision: git_revision (git_brevis)
Revision: mym4_revision (mym4_revision_dec)
Platform: $host
GnuPG path: $GPG

View File

@ -83,6 +83,21 @@ do_subsystem_inits (void)
}
/* Put vesion information into the binary. */
static const char *
cright_blurb (void)
{
static const char blurb[] =
"\n\n"
"This is GPGME " PACKAGE_VERSION " - The GnuPG Made Easy library\n"
CRIGHTBLURB
"\n"
"(" BUILD_REVISION " " BUILD_TIMESTAMP ")\n"
"\n\n";
return blurb;
}
/* Read the next number in the version string STR and return it in
*NUMBER. Return a pointer to the tail of STR after parsing, or
*NULL if the version string was invalid. */
@ -208,6 +223,8 @@ gpgme_check_version_internal (const char *req_version,
{
const char *result;
if (req_version && req_version[0] == 1 && req_version[1] == 1)
return cright_blurb ();
result = gpgme_check_version (req_version);
if (result == NULL)
return result;

View File

@ -18,7 +18,7 @@
VS_VERSION_INFO VERSIONINFO
FILEVERSION @LIBGPGME_LT_CURRENT@,@LIBGPGME_LT_AGE@,@LIBGPGME_LT_REVISION@,@BUILD_NUMBER@
FILEVERSION @BUILD_FILEVERSION@
PRODUCTVERSION @BUILD_FILEVERSION@
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
@ -37,9 +37,9 @@ BEGIN
VALUE "Comments", "Provided under the terms of the GNU Lesser General Public License.\0"
VALUE "CompanyName", "g10 Code GmbH\0"
VALUE "FileDescription", "GPGME - GnuPG Made Easy\0"
VALUE "FileVersion", "@LIBGPGME_LT_CURRENT@.@LIBGPGME_LT_AGE@.@LIBGPGME_LT_REVISION@.@BUILD_NUMBER@\0"
VALUE "FileVersion", "@LIBGPGME_LT_CURRENT@.@LIBGPGME_LT_AGE@.@LIBGPGME_LT_REVISION@.@BUILD_REVISION@\0"
VALUE "InternalName", "gpgme\0"
VALUE "LegalCopyright", "Copyright © 2005 g10 Code GmbH\0"
VALUE "LegalCopyright", "Copyright © 2001-2013 g10 Code GmbH\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "gpgme.dll\0"
VALUE "PrivateBuild", "\0"

View File

@ -22,24 +22,71 @@
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gpgme.h>
static int verbose;
static int debug;
int
main (int argc, char **argv)
{
int ret;
const char *null_result;
const char *current_result;
const char *future_result;
int last_argc = -1;
if (argc)
{
argc--; argv++;
}
while (argc && last_argc != argc )
{
last_argc = argc;
if (!strcmp (*argv, "--help"))
{
puts ("usage: ./t-version [options]\n"
"\n"
"Options:\n"
" --verbose Show what is going on\n"
);
exit (0);
}
if (!strcmp (*argv, "--verbose"))
{
verbose = 1;
argc--; argv++;
}
else if (!strcmp (*argv, "--debug"))
{
verbose = debug = 1;
argc--; argv++;
}
}
null_result = gpgme_check_version (NULL);
current_result = gpgme_check_version (VERSION);
future_result = gpgme_check_version (VERSION ".1");
return !(null_result
&& ! strcmp (null_result, VERSION)
&& current_result
&& ! strcmp (current_result, VERSION)
&& ! future_result);
ret = !(null_result
&& ! strcmp (null_result, VERSION)
&& current_result
&& ! strcmp (current_result, VERSION)
&& ! future_result);
if (verbose || ret)
{
printf ("Version from header: %s (0x%06x)\n",
GPGME_VERSION, GPGME_VERSION_NUMBER);
printf ("Version from binary: %s\n", gpgme_check_version (NULL));
printf ("Copyright blurb ...:%s\n", gpgme_check_version ("\x01\x01"));
}
return ret;
}