libnl version #define LIBNL_VERSION

Thomas Graf tgraf at infradead.org
Wed Mar 16 08:47:57 EDT 2011


Jouni,

On Mon, Feb 21, 2011 at 11:36:30PM +0200, Jouni Malinen wrote:
> Would it be possible to add a bit more helpful define in
> netlink/version.h to allow C preprocessor to be used to select
> conditional code based on the libnl version that is installed on the
> system? Since the libnl API seems to be changing between versions in
> ways that require changes in programs using it, it would be convenient
> to be able to do this without having to use manual configuration or
> pkg-config.
> 
> Something like #define LIBNL_VERSION_NUM 0x0201 would make this easier.
> I think I can actually use #ifdef LIBNL_VERSION to distinguish 1.1 from
> 2.0, but I did not see any clear way of doing this between 2.0 and
> current git tree (2.1? 3.0?).

I've commited the following patch:

commit d8d67c0a4c348837ed3c3f8377b1f8a4e5574f5f
Author: Thomas Graf <tgraf at suug.ch>
Date:   Wed Mar 16 13:46:41 2011 +0100

    Provide numeric version defines

diff --git a/configure.in b/configure.in
index 34ece73..a0199d0 100644
--- a/configure.in
+++ b/configure.in
@@ -6,7 +6,7 @@
 #      License as published by the Free Software Foundation version 2.1
 #      of the License.
 #
-# Copyright (c) 2003-2010 Thomas Graf <tgraf at suug.ch>
+# Copyright (c) 2003-2011 Thomas Graf <tgraf at suug.ch>
 #
 
 AC_INIT(libnl, 2.1, tgraf at suug.ch)
@@ -15,6 +15,11 @@ AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)], [])
 
+MAJ_VERSION=2
+AC_SUBST([MAJ_VERSION])
+MIN_VERSION=1
+AC_SUBST([MIN_VERSION])
+
 AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_INSTALL
diff --git a/include/netlink/version.h.in b/include/netlink/version.h.in
index 7bd38cc..9deb365 100644
--- a/include/netlink/version.h.in
+++ b/include/netlink/version.h.in
@@ -6,7 +6,7 @@
  *     License as published by the Free Software Foundation version 2.1
  *     of the License.
  *
- * Copyright (c) 2008 Thomas Graf <tgraf at suug.ch>
+ * Copyright (c) 2008-2011 Thomas Graf <tgraf at suug.ch>
  */
 
 #ifndef NETLINK_VERSION_H_
@@ -15,4 +15,9 @@
 #define LIBNL_STRING "@PACKAGE_STRING@"
 #define LIBNL_VERSION "@PACKAGE_VERSION@"
 
+#define LIBNL_VER_MAJ          @MAJ_VERSION@
+#define LIBNL_VER_MIN          @MIN_VERSION@
+#define LIBNL_VER(maj,min)     ((maj) << 8 | (min))
+#define LIBNL_VER_NUM          LIBNL_VER(LIBNL_VER_MAJ, LIBNL_VER_MIN)
+
 #endif



More information about the libnl mailing list