Permalink
Browse files

Switch to libtool versioning system

It has been a request that multiple libnl versions should be installabe
in parallel.

In order to achieve this, the basename of the library was changed to
libnl-3 which reflects the 3rd generation of libnl APIs. It also means
that release based library versioning is left behind and libtool
versioning is used instead.

Projects using pkgconfig will automatically link against the new library
basename and will not notice a difference.

The SO versioning is based on the glib model:
  current := 100 * minor + micro - revision
  revision := revision
  age := age (number of backwards compatible versions)
  • Loading branch information...
Thomas Graf
Thomas Graf committed Sep 13, 2011
1 parent a73cb2f commit 4c210adcb572d8950fdc6b5135406e06e55f8b56
View
@@ -10,10 +10,10 @@ endif
SUBDIRS = include lib doc man python $(OPT_DIRS)
-pkgconfig_DATA = libnl-3.pc \
- libnl-route-3.pc \
- libnl-genl-3.pc \
- libnl-nf-3.pc
+pkgconfig_DATA = libnl-3.0.pc \
+ libnl-route-3.0.pc \
+ libnl-genl-3.0.pc \
+ libnl-nf-3.0.pc
pkgsysconfdir = ${sysconfdir}/libnl
pkgsysconf_DATA = etc/pktloc etc/classid
View
@@ -9,16 +9,43 @@
# Copyright (c) 2003-2011 Thomas Graf <tgraf@suug.ch>
#
-AC_INIT(libnl, 3.2, tgraf@suug.ch)
+
+# copied from glib
+m4_define([libnl_major_version], [3])
+m4_define([libnl_minor_version], [2])
+m4_define([libnl_micro_version], [0]) # bump for every release unless minor was bumped
+m4_define([libnl_lt_revision], [0]) # bump or reset to 0 if interfaces were added
+m4_define([libnl_lt_age], [0]) # bump whenever a release is backwards compatible
+ # bump with +100 if a minor release is compatible
+ # reset to 0 if interfaces were removed
+
+m4_define([libnl_version],
+ [libnl_major_version.libnl_minor_version.libnl_micro_version])
+
+m4_define([libnl_lt_current],
+ [m4_eval(100 * libnl_minor_version + libnl_micro_version - libnl_lt_revision)])
+
+AC_INIT(libnl, [libnl_version], [http://www.infradead.org/~tgr/libnl/])
AC_CONFIG_HEADERS([lib/defs.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)], [])
-MAJ_VERSION=3
-AC_SUBST([MAJ_VERSION])
-MIN_VERSION=2
-AC_SUBST([MIN_VERSION])
+MAJ_VERSION=libnl_major_version
+AC_SUBST(MAJ_VERSION)
+MIN_VERSION=libnl_minor_version
+AC_SUBST(MIN_VERSION)
+MIC_VERSION=libnl_micro_version
+AC_SUBST(MIC_VERSION)
+LIBNL_VERSION=libnl_version
+AC_SUBST(LIBNL_VERSION)
+
+LT_CURRENT=libnl_lt_current
+AC_SUBST(LT_CURRENT)
+LT_REVISION=libnl_lt_revision
+AC_SUBST(LT_REVISION)
+LT_AGE=libnl_lt_age
+AC_SUBST(LT_AGE)
AC_PROG_CC
AM_PROG_CC_C_O
@@ -43,25 +70,39 @@ AM_CONDITIONAL([ENABLE_CLI], [test "$enable_cli" = "yes"])
AC_CHECK_LIB([m], [pow], [], AC_MSG_ERROR([libm is required]))
AC_CHECK_LIB([pthread], [pthread_mutex_lock], [], AC_MSG_ERROR([libpthread is required]))
-AC_CONFIG_FILES([Makefile doc/Doxyfile doc/Makefile lib/Makefile
- include/Makefile src/Makefile src/lib/Makefile man/Makefile
- libnl-3.pc libnl-route-3.pc libnl-genl-3.pc libnl-nf-3.pc
- python/Makefile python/setup.py python/netlink/Makefile
- python/netlink/route/Makefile
- include/netlink/version.h])
+AC_CONFIG_FILES([
+Makefile
+libnl-3.0.pc
+libnl-route-3.0.pc
+libnl-genl-3.0.pc
+libnl-nf-3.0.pc
+doc/Doxyfile
+doc/Makefile
+lib/Makefile
+include/Makefile
+src/Makefile
+src/lib/Makefile
+man/Makefile
+python/Makefile
+python/setup.py
+python/netlink/Makefile
+python/netlink/route/Makefile
+include/netlink/version.h
+])
+
AC_OUTPUT
-echo -------------------------------------------------------------------------------
-echo NOTE
-echo
-echo Headers will be installed in ${includedir}/libnl${MAJ_VERSION} starting with
-echo version 3.2. If you are using pkg-config things should continue to work as
-echo expected, otherwise you will have to extend the CLFAGS of your project with
-echo
-echo -I${includedir}/libnl${MAJ_VERSION}
-echo
-echo Also, pkg-config files for sub libraries have been added, so you can
-echo verify their presence
-echo
-echo -------------------------------------------------------------------------------
+echo "-------------------------------------------------------------------------------"
+echo " NOTE"
+echo ""
+echo " Headers will be installed in ${includedir}/libnl${MAJ_VERSION} starting with"
+echo " version 3.2. If you are using pkg-config things should continue to work as"
+echo " expected, otherwise you will have to extend the CLFAGS of your project with"
+echo ""
+echo " -I${includedir}/libnl${MAJ_VERSION}"
+echo ""
+echo " Also, pkg-config files for sub libraries have been added, so you can"
+echo " verify their presence"
+echo ""
+echo "-------------------------------------------------------------------------------"
View
@@ -7,7 +7,7 @@
Netlink Library (libnl)
=======================
Thomas Graf <tgraf@suug.ch>
-3.1, Aug 11 2011:
+3.2, Sep 13 2011:
:numbered:
== Introduction
@@ -59,6 +59,25 @@ The low level APIs are described in:
=== Linking to this Library
+.Checking the presence using autoconf
+
+Projects using autoconf may use +PKG_CHECK_MODULES()+ to check if
+a specific version of libnl is available on the system. The example
+below also shows how to retrieve the +CFLAGS+ and linking dependencies
+required to link against the library.
+
+[source]
+----
+PKG_CHECK_MODULES(LIBNL3, libnl-3.0 >= 3.1, [have_libnl3=yes], [have_libnl3=no])
+if (test "${have_libnl3}" = "yes"); then
+ CFLAGS += "$LIBNL3_CFLAGS"
+ LIBS += "$LIBNL3_LIBS"
+fi
+----
+
+NOTE: The pkgconfig file is named +libnl-3.0.pc+ for historic reasons, it also
+ covers library versions >= 3.1.
+
.Main Header
The main header is `<netlink/netlink.h>`. Additional headers need to
@@ -77,7 +96,7 @@ makes use of.
.Linking to libnl
-----
-$ gcc myprogram.c -o myprogram -lnl
+$ gcc myprogram.c -o myprogram $(pkgconfig --cflags --libs libnl-3.0)
-----
=== Debugging
@@ -20,4 +20,8 @@
#define LIBNL_VER(maj,min) ((maj) << 8 | (min))
#define LIBNL_VER_NUM LIBNL_VER(LIBNL_VER_MAJ, LIBNL_VER_MIN)
+#define LIBNL_CURRENT @LT_CURRENT@
+#define LIBNL_REVISION @LT_REVISION@
+#define LIBNL_AGE @LT_AGE@
+
#endif
View
@@ -1,21 +1,30 @@
# -*- Makefile -*-
-AM_CPPFLAGS = -Wall -I${top_srcdir}/include -I${top_builddir}/include -I${builddir}/route -I${builddir}/route/cls -D_GNU_SOURCE -DSYSCONFDIR=\"$(sysconfdir)/libnl\"
-AM_LDFLAGS = -version-info @MAJ_VERSION@:@MIN_VERSION@:0
+AM_CPPFLAGS = \
+ -Wall \
+ -I${top_srcdir}/include \
+ -I${top_builddir}/include \
+ -I${builddir}/route \
+ -I${builddir}/route/cls \
+ -D_GNU_SOURCE \
+ -DSYSCONFDIR=\"$(sysconfdir)/libnl\"
+
+AM_LDFLAGS = \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
lib_LTLIBRARIES = \
- libnl.la libnl-genl.la libnl-route.la libnl-nf.la
+ libnl-3.la libnl-genl-3.la libnl-route-3.la libnl-nf-3.la
-libnl_la_SOURCES = \
+libnl_3_la_SOURCES = \
addr.c attr.c cache.c cache_mngr.c cache_mngt.c data.c \
error.c handlers.c msg.c nl.c object.c socket.c utils.c
-libnl_genl_la_LIBADD = libnl.la
-libnl_genl_la_SOURCES = \
+libnl_genl_3_la_LIBADD = libnl-3.la
+libnl_genl_3_la_SOURCES = \
genl/ctrl.c genl/family.c genl/genl.c genl/mngt.c
-libnl_nf_la_LIBADD = libnl-route.la
-libnl_nf_la_SOURCES = \
+libnl_nf_3_la_LIBADD = libnl-route-3.la
+libnl_nf_3_la_SOURCES = \
netfilter/ct.c netfilter/ct_obj.c netfilter/log.c \
netfilter/log_msg.c netfilter/log_msg_obj.c netfilter/log_obj.c \
netfilter/netfilter.c netfilter/nfnl.c netfilter/queue.c \
@@ -41,8 +50,8 @@ route/cls/ematch_grammar.c: route/cls/ematch_grammar.l
route/cls/ematch_syntax.c: route/cls/ematch_syntax.y
$(AM_V_GEN) $(YACC) -d $(YFLAGS) -o $@ $^
-libnl_route_la_LIBADD = libnl.la
-libnl_route_la_SOURCES = \
+libnl_route_3_la_LIBADD = libnl-3.la
+libnl_route_3_la_SOURCES = \
route/addr.c route/class.c route/cls.c route/link.c \
route/neigh.c route/neightbl.c route/nexthop.c route/qdisc.c \
route/route.c route/route_obj.c route/route_utils.c route/rtnl.c \
@@ -69,7 +78,7 @@ libnl_route_la_SOURCES = \
\
route/pktloc.c
-nodist_libnl_route_la_SOURCES = \
+nodist_libnl_route_3_la_SOURCES = \
route/pktloc_syntax.c route/pktloc_syntax.h \
route/pktloc_grammar.c route/pktloc_grammar.h \
route/cls/ematch_syntax.c route/cls/ematch_syntax.h \
@@ -6,5 +6,5 @@ includedir=@includedir@
Name: libnl
Description: Convenience library for netlink sockets
Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lnl
+Libs: -L${libdir} -lnl-@MAJ_VERSION@
Cflags: -I${includedir}/libnl@MAJ_VERSION@
@@ -6,6 +6,6 @@ includedir=@includedir@
Name: libnl-genl
Description: Generic Netlink Library
Version: @PACKAGE_VERSION@
-Requires: libnl-3
-Libs: -L${libdir} -lnl-genl
+Requires: libnl-3.0
+Libs: -L${libdir} -lnl-genl-@MAJ_VERSION@
Cflags: -I${includedir}/libnl@MAJ_VERSION@
@@ -6,6 +6,6 @@ includedir=@includedir@
Name: libnl-nf
Description: Netfilter Netlink Library
Version: @PACKAGE_VERSION@
-Requires: libnl-3
-Libs: -L${libdir} -lnl-nf
+Requires: libnl-route-3.0
+Libs: -L${libdir} -lnl-nf-@MAJ_VERSION@
Cflags: -I${includedir}/libnl@MAJ_VERSION@
@@ -6,6 +6,6 @@ includedir=@includedir@
Name: libnl-route
Description: Netlink Routing Family Library
Version: @PACKAGE_VERSION@
-Requires: libnl-3
-Libs: -L${libdir} -lnl-route
+Requires: libnl-3.0
+Libs: -L${libdir} -lnl-route-@MAJ_VERSION@
Cflags: -I${includedir}/libnl@MAJ_VERSION@
View
@@ -1,7 +1,10 @@
# -*- Makefile -*-
AM_CPPFLAGS = -Wall -I${top_srcdir}/include -I${top_builddir}/include -D_GNU_SOURCE -DPKGLIBDIR=\"$(pkglibdir)\" -DSYSCONFDIR=\"$(sysconfdir)\" -rdynamic
-AM_LDFLAGS = -L${top_builddir}/lib -ldl -version-info 3:0:0
+AM_LDFLAGS = \
+ -L${top_builddir}/lib \
+ -ldl \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
#nobase_pkglib_LTLIBRARIES = cls/basic.la cls/ematch/cmp.la
#cls_basic_la_LDFLAGS = -module -version-info 2:0:0
@@ -26,14 +29,14 @@ AM_LDFLAGS = -L${top_builddir}/lib -ldl -version-info 3:0:0
# cls/pktloc_syntax.c cls/pktloc_syntax.h
lib_LTLIBRARIES = \
- libnl-cli.la
+ libnl-cli-3.la
-libnl_cli_la_LIBADD = ${top_builddir}/lib/libnl.la \
- ${top_builddir}/lib/libnl-route.la \
- ${top_builddir}/lib/libnl-nf.la \
- ${top_builddir}/lib/libnl-genl.la
+libnl_cli_3_la_LIBADD = ${top_builddir}/lib/libnl-3.la \
+ ${top_builddir}/lib/libnl-route-3.la \
+ ${top_builddir}/lib/libnl-nf-3.la \
+ ${top_builddir}/lib/libnl-genl-3.la
-libnl_cli_la_SOURCES = \
+libnl_cli_3_la_SOURCES = \
utils.c addr.c ct.c link.c neigh.c rule.c route.c \
tc.c qdisc.c class.c cls.c
# cls/ematch_syntax.c cls/ematch_grammar.c cls/ematch.c

0 comments on commit 4c210ad

Please sign in to comment.