On Sun, Jan 11, 2015 at 3:14 PM, Niels Möller <[email protected]> wrote:
> Nikos Mavrogiannopoulos <[email protected]> writes:
>
>>  This patch adds a definition in nettle-meta.h with nettle's version
>> number. That way applications can be easily modified to support both the
>> 2.7 and the 3.x API. I didn't add for hogweed because it didn't seem to
>> make sense, the API version is fully determined by nettle only.
>
> Sorry for the late reply. It seems reasonable to me to include the
> package version in some header file. However, I'm not sure nettle-meta.h
> is the right file.
>
> I'd prefer either a separate file nettle/version.h [...]
> And I'm also not sure I like the way major and minor numbers are
> combined into a single value. Can't they be kept separate, say
> NETTLE_VERSION, NETTLE_MINOR_VERSION, NETTLE_PATCHLEVEL or so?
> What do other packages do? E.g., gcc uses

I went this path, and now there is a version.h which defines,
NETTLE_VERSION (combo), NETTLE_VERSION_MAJOR and NETTLE_VERSION_MINOR.

regards,
Nikos
From 023b4f2e44bc3551a83666b74d0c4cf424cea946 Mon Sep 17 00:00:00 2001
From: Nikos Mavrogiannopoulos <[email protected]>
Date: Tue, 17 Mar 2015 13:12:13 +0100
Subject: [PATCH] Added version.h with library versioning information

---
 Makefile.in  |  2 +-
 configure.ac |  8 +++++++-
 version.h.in | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 2 deletions(-)
 create mode 100644 version.h.in

diff --git a/Makefile.in b/Makefile.in
index abba3cd..e39fd15 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -195,7 +195,7 @@ HEADERS = aes.h arcfour.h arctwo.h asn1.h blowfish.h \
 	  md5.h md5-compat.h \
 	  memxor.h \
 	  nettle-meta.h nettle-types.h \
-	  pbkdf2.h \
+	  pbkdf2.h version.h \
 	  pgp.h pkcs1.h realloc.h ripemd160.h rsa.h \
 	  salsa20.h sexp.h \
 	  serpent.h sha.h sha1.h sha2.h sha3.h twofish.h \
diff --git a/configure.ac b/configure.ac
index 51ab3b3..d320b35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,6 +16,12 @@ LIBNETTLE_MINOR=0
 LIBHOGWEED_MAJOR=4
 LIBHOGWEED_MINOR=0
 
+MAJOR_VERSION=`echo $PACKAGE_VERSION | sed 's/\(.*\)\..*/\1/g'`
+MINOR_VERSION=`echo $PACKAGE_VERSION | sed 's/.*\.\(.*\)/\1/g'`
+AC_SUBST([NUMBER_VERSION], `printf "0x%02x%02x" $MAJOR_VERSION $MINOR_VERSION`)
+AC_SUBST([MAJOR_VERSION])
+AC_SUBST([MINOR_VERSION])
+
 AC_CANONICAL_HOST
 
 # Command line options
@@ -895,7 +901,7 @@ if test x$GCC = xyes ; then
 # inttypes.h.
 fi
 
-AC_CONFIG_FILES([config.make config.m4 Makefile bignum.h])
+AC_CONFIG_FILES([config.make config.m4 Makefile bignum.h version.h])
 AC_CONFIG_FILES([tools/Makefile testsuite/Makefile examples/Makefile])
 AC_CONFIG_FILES([nettle.pc hogweed.pc libnettle.map libhogweed.map])
 
diff --git a/version.h.in b/version.h.in
new file mode 100644
index 0000000..406d029
--- /dev/null
+++ b/version.h.in
@@ -0,0 +1,54 @@
+/* version.h
+
+   Information about library version.
+
+   Copyright (C) 2015 Red Hat, Inc.
+
+   This file is part of GNU Nettle.
+
+   GNU Nettle is free software: you can redistribute it and/or
+   modify it under the terms of either:
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at your
+       option) any later version.
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at your
+       option) any later version.
+
+   or both in parallel, as here.
+
+   GNU Nettle is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see http://www.gnu.org/licenses/.
+*/
+
+#ifndef NETTLE_VERSION_H_INCLUDED
+#define NETTLE_VERSION_H_INCLUDED
+
+#include "nettle-types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The combined version in hex */
+#define NETTLE_VERSION @NUMBER_VERSION@
+
+/* Individual version numbers in decimal */
+#define NETTLE_VERSION_MAJOR @MAJOR_VERSION@
+#define NETTLE_VERSION_MINOR @MINOR_VERSION@
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NETTLE_VERSION_H_INCLUDED */
-- 
2.1.0

_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to