Permalink
Browse files

ABI versioning made to match the libtool versioning terminology

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
  • Loading branch information...
sustrik committed Aug 14, 2013
1 parent c9ed552 commit 0a5ccfd5c7770c8122947d7e8895ee0e6d928403
Showing with 91 additions and 70 deletions.
  1. +7 −3 Makefile.am
  2. +15 −45 version.sh → abi_version.sh
  3. +9 −6 configure.ac
  4. +1 −1 libnanomsg.pc.in
  5. +40 −0 package_version.sh
  6. +3 −4 src/core/symbol.c
  7. +16 −11 src/nn.h
View
@@ -289,7 +289,7 @@ libnanomsg_la_SOURCES = \
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnanomsg.pc
-libnanomsg_la_LDFLAGS = -version-info @NN_LT_VERSION@
+libnanomsg_la_LDFLAGS = -version-info @NN_LIBTOOL_VERSION@
################################################################################
# documentation #
@@ -424,11 +424,15 @@ TESTS = $(check_PROGRAMS)
# additional packaging-related stuff #
################################################################################
+# There's no git availabe when building from the source package and thus
+# no way to obtain package version. Therefore, package version is saved into
+# a file when building a source package.
dist-hook:
- $(srcdir)/version.sh > $(distdir)/.version
+ $(srcdir)/package_version.sh > $(distdir)/.version
EXTRA_DIST += \
- ./version.sh \
+ ./abi_version.sh \
+ ./package_version.sh \
./src/CMakeLists.txt \
./CMakeLists.txt
@@ -19,53 +19,23 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+if [ ! -f src/nn.h ]; then
+ echo "abi_version.sh: error: src/nn.h does not exist" 1>&2
+ exit 1
+fi
-packageversion(){
- if [ -d .git ]; then
- VER=$(git describe --always | sed -e "s:v::")
- if [ x"$(git diff-index --name-only HEAD)" != x ]; then
- VER="${VER}-dirty"
- fi
- elif [ -f .version ]; then
- VER=$(< .version)
- else
- VER="Unknown"
- fi
+CURRENT=$(egrep '^#define +NN_VERSION_CURRENT +[0-9]+$' src/nn.h)
+REVISION=$(egrep '^#define +NN_VERSION_REVISION +[0-9]+$' src/nn.h)
+AGE=$(egrep '^#define +NN_VERSION_AGE +[0-9]+$' src/nn.h)
- echo -n $VER
-}
+if [ -z "$CURRENT" -o -z "$REVISION" -o -z "$AGE" ]; then
+ echo "abi_version.sh: error: could not extract version from src/nn.h" 1>&2
+ exit 1
+fi
-soversion(){
- if [ ! -f src/nn.h ]; then
- echo "version.sh: error: src/nn.h does not exist" 1>&2
- exit 1
- fi
+CURRENT=$(echo -n $CURRENT | awk '{ print $3 }')
+REVISION=$(echo -n $REVISION | awk '{ print $3 }')
+AGE=$(echo -n $AGE | awk '{ print $3 }')
- MAJOR=$(egrep '^#define +NN_VERSION_MAJOR +[0-9]+$' src/nn.h)
- MINOR=$(egrep '^#define +NN_VERSION_MINOR +[0-9]+$' src/nn.h)
- PATCH=$(egrep '^#define +NN_VERSION_PATCH +[0-9]+$' src/nn.h)
+echo -n $CURRENT.$REVISION.$AGE
- if [ -z "$MAJOR" -o -z "$MINOR" -o -z "$PATCH" ]; then
- echo "version.sh: error: could not extract version from src/nn.h" 1>&2
- exit 1
- fi
-
- MAJOR=$(echo -n $MAJOR | awk '{ print $3 }')
- MINOR=$(echo -n $MINOR | awk '{ print $3 }')
- PATCH=$(echo -n $PATCH | awk '{ print $3 }')
-
- echo -n $MAJOR$1$MINOR$1$PATCH
-}
-
-
-case $1 in
- -v)
- soversion ":"
- ;;
- -p)
- soversion "."
- ;;
- *)
- packageversion
- ;;
-esac
View
@@ -25,7 +25,7 @@
AC_PREREQ([2.53])
-AC_INIT([nanomsg], [m4_esyscmd([./version.sh])],
+AC_INIT([nanomsg], [m4_esyscmd([./package_version.sh])],
[nanomsg@freelists.org], [nanomsg], [http://nanomsg.org/])
AC_CONFIG_SRCDIR([src/nn.h])
AM_INIT_AUTOMAKE([1.6 foreign subdir-objects tar-ustar dist-zip])
@@ -42,13 +42,16 @@ AC_CANONICAL_HOST
AC_PROG_SED
AC_PROG_AWK
-NN_LT_VERSION=m4_esyscmd([./version.sh -v])
-NN_PC_VERSION=m4_esyscmd([./version.sh -p])
-NN_PACKAGE_VERSION=m4_esyscmd([./version.sh])
+NN_ABI_VERSION=m4_esyscmd([./abi_version.sh])
+NN_PACKAGE_VERSION=m4_esyscmd([./package_version.sh])
+NN_LIBTOOL_VERSION=m4_esyscmd([./abi_version.sh | sed -e y/./:/])
-AC_SUBST(NN_LT_VERSION)
-AC_SUBST(NN_PC_VERSION)
+AC_SUBST(NN_ABI_VERSION)
AC_SUBST(NN_PACKAGE_VERSION)
+AC_SUBST(NN_LIBTOOL_VERSION)
+
+AC_MSG_NOTICE([nanomsg package version: $NN_PACKAGE_VERSION])
+AC_MSG_NOTICE([nanomsg ABI version: $NN_ABI_VERSION])
################################################################################
# Check the compilers. #
View
@@ -6,7 +6,7 @@ includedir=@includedir@
Name: Nanomsg
Description: nanomsg library is a high-performance implementation of several scalability protocols.
URL: http://nanomsg.org/
-Version: @NN_PC_VERSION@
+Version: @NN_ABI_VERSION@
Requires:
Libs: -L${libdir} -lnanomsg
Cflags: -I${includedir}
View
@@ -0,0 +1,40 @@
+#!/bin/sh
+# Copyright (c) 2013 Luca Barbato
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom
+# the Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+if [ -d .git ]; then
+ # Retrieve the version from the last git tag.
+ VER=$(git describe --always | sed -e "s:v::")
+ if [ x"$(git diff-index --name-only HEAD)" != x ]; then
+ # If the sources have been changed locally, add -dirty to the version.
+ VER="${VER}-dirty"
+ fi
+elif [ -f .version ]; then
+ # If git is not available (e.g. when building from source package)
+ # we can extract the package version from .version file.
+ VER=$(< .version)
+else
+ # The package version cannot be retrieved.
+ VER="Unknown"
+fi
+
+echo -n $VER
+
+
View
@@ -41,10 +41,9 @@ struct sym_value_name {
static const struct sym_value_name sym_value_names [] = {
- {NN_VERSION_MAJOR, "NN_VERSION_MAJOR"},
- {NN_VERSION_MINOR, "NN_VERSION_MINOR"},
- {NN_VERSION_PATCH, "NN_VERSION_PATCH"},
- {NN_VERSION, "NN_VERSION"},
+ {NN_VERSION_CURRENT, "NN_VERSION_CURRENT"},
+ {NN_VERSION_REVISION, "NN_VERSION_REVISION"},
+ {NN_VERSION_AGE, "NN_VERSION_AGE"},
{AF_SP, "AF_SP"},
{AF_SP_RAW, "AF_SP_RAW"},
View
@@ -1,5 +1,6 @@
/*
Copyright (c) 2012-2013 250bpm s.r.o. All rights reserved.
+ Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
@@ -38,29 +39,33 @@ extern "C" {
# define NN_EXPORT __declspec(dllimport)
# endif
#else
-# if defined __SUNPRO_C || defined __SUNPRO_CC
+# if defined __SUNPRO_C
# define NN_EXPORT __global
-# elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER
+# elif (defined __GNUC__ && __GNUC__ >= 4) || \
+ defined __INTEL_COMPILER || defined __clang__
# define NN_EXPORT __attribute__ ((visibility("default")))
# else
# define NN_EXPORT
# endif
#endif
/******************************************************************************/
-/* Versioning support. */
+/* ABI versioning support. */
/******************************************************************************/
-/* Version macros for compile-time API version detection */
-#define NN_VERSION_MAJOR 0
-#define NN_VERSION_MINOR 0
-#define NN_VERSION_PATCH 0
+/* Don't change this unless you know exactly what you're doing and have */
+/* read and understand the following documents: */
+/* www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html */
+/* www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html */
-#define NN_MAKE_VERSION(major, minor, patch) \
- ((major) * 10000 + (minor) * 100 + (patch))
-#define NN_VERSION \
- NN_MAKE_VERSION(NN_VERSION_MAJOR, NN_VERSION_MINOR, NN_VERSION_PATCH)
+/* The current interface version. */
+#define NN_VERSION_CURRENT 0
+/* The latest revision of the current interface. */
+#define NN_VERSION_REVISION 0
+
+/* How many past interface versions are still supported. */
+#define NN_VERSION_AGE 0
/******************************************************************************/
/* Errors. */

0 comments on commit 0a5ccfd

Please sign in to comment.