Skip to content

Commit

Permalink
Update version handling.
Browse files Browse the repository at this point in the history
* macros/neon.m4 (NE_MINIMUM_VERSION): New macro.
  (NE_REQUIRE_VERSIONS): Rejig to use NE_MINIMUM_VERSION. The first
  version given in minor releases is used as the minimum, all
  others now ignored.

* test/util-tests.c (versioning): Update versioning to assume 1.0 is
  maintains backwards-compat to 0.27.

* README.md: Note use of semver.
  • Loading branch information
notroj committed Jul 27, 2024
1 parent 3043da7 commit 43a2932
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

[![Travis CI Build Status](https://travis-ci.com/notroj/neon.svg?branch=master)](https://travis-ci.com/github/notroj/neon)
[![Build and test](https://github.com/notroj/neon/actions/workflows/ci.yml/badge.svg)](https://github.com/notroj/neon/actions/workflows/ci.yml)

# neon
Expand All @@ -9,7 +8,8 @@ _neon_ is an HTTP and WebDAV client library, with a C language API.
GitHub: https://github.com/notroj/neon | Web: https://notroj.github.io/neon/

The neon API and ABI are stable and maintain backwards compatibility
since 0.27 through to current releases.
since 0.27 through to 1.0.0. From neon 1.0.0 onwards, semantic
versioning will be used. https://semver.org/

Features:

Expand Down Expand Up @@ -43,7 +43,7 @@ The autoconf macros in the "macros" directory are under a less
restrictive license, see each file for details.

~~~
neon is Copyright (C) 1999-2023 Joe Orton
neon is Copyright (C) 1999-2024 Joe Orton
Portions are:
Copyright (C) Aleix Conchillo Flaque
Copyright (C) Arfrever Frehtes Taifersar Arahesis
Expand Down
44 changes: 31 additions & 13 deletions macros/neon.m4
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,26 @@ else
fi
])

dnl Define the minimum required versions, usage:
dnl NE_REQUIRE_VERSIONS([major-version], [minor-versions])
dnl e.g.
dnl NE_REQUIRE_VERSIONS([0], [24 25])
dnl to require neon 0.24.x or neon 0.25.x.
AC_DEFUN([NE_REQUIRE_VERSIONS], [
dnl Define the minimum required version, usage:
dnl NE_MINIMUM_VERSION([major-version], [minor-version])
dnl If a major-version of 0 is used, neon 1.x will be allowed
dnl as backward compatible. FOr example:
dnl NE_MINIMUM_VERSION([0], [27])
dnl require neon 0.27.x or later or any 1.x
AC_DEFUN([NE_MINIMUM_VERSION], [
m4_define([ne_require_major], [$1])
# ## ne_require_major $1
m4_define([ne_require_minor], [$2])
# ## ne_require_minor $2
])


dnl Deprecated.
AC_DEFUN([NE_REQUIRE_VERSIONS], [
# Extract the first minor version from the list:
NE_MINIMUM_VERSIONS([$1],m4_bregexp($2,[\([0-9]*\)\ .*],[\1]))
m4_warn([obsolete], [The `NE_REQUIRE_VERSIONS` macro is obsolete.
Update to use `NE_MINIMUM_VERSION`])
])

dnl Check that the external library found in a given location
Expand All @@ -189,26 +201,32 @@ m4_ifdef([ne_require_major], [
[AC_LANG_PROGRAM([[#include <ne_utils.h>]], [[ne_version_match(0, 0);]])],
[ne_cv_lib_neon=yes], [ne_cv_lib_neon=no])])
if test "$ne_cv_lib_neon" = "yes"; then
ne_libmajor=`echo $ne_libver | sed 's/\..*//g'`
ne_libminor=`echo $ne_libver | sed 's/.*\.\([[0-9]]*\)\..*/\1/g'`
ne_cv_lib_neonver=no
for v in ne_require_minor; do
case $ne_libver in
ne_require_major.$v.*) ne_cv_lib_neonver=yes ;;
esac
done
AC_MSG_NOTICE([found neon library version ${ne_libmajor}.${ne_libminor}.x, required ne_require_major[.]ne_require_minor[.x]])
# neon 1.x maintains backwards compat to neon 0.27.x
if test ne_require_major -eq 0 -a ne_require_minor -ge 27 \
-a $ne_libmajor = 1; then
ne_cv_lib_neonver=yes
elif test $ne_libmajor -eq ne_require_major \
-a $ne_libminor -ge ne_require_minor; then
ne_cv_lib_neonver=yes
fi
fi
ne_goodver=$ne_cv_lib_neonver
LIBS=$ne_save_LIBS
CFLAGS=$ne_save_CFLAGS
], [
# NE_REQUIRE_VERSIONS not used; presume all versions OK!
dnl NE_REQUIRE_VERSIONS/NE_MINIMUM_VERSION not used; anything goes.
ne_goodver=yes
])
if test "$ne_goodver" = "yes"; then
AC_MSG_NOTICE([using neon library $ne_libver])
$1
else
AC_MSG_NOTICE([incompatible neon library version $ne_libver: wanted ne_require_major.ne_require_minor])
AC_MSG_NOTICE([incompatible neon library version $ne_libver: minimum required ne_require_major.ne_require_minor])
$2
fi])

Expand Down
10 changes: 7 additions & 3 deletions test/util-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,22 @@ static int versioning(void)
GOOD(NE_VERSION_MAJOR, NE_VERSION_MINOR, "current version");
BAD(NE_VERSION_MAJOR + 1, 0, "later major");
BAD(NE_VERSION_MAJOR, NE_VERSION_MINOR + 1, "later minor");
#if NE_VERSION_MAJOR > 0

#if NE_VERSION_MAJOR > 1
BAD(NE_VERSION_MAJOR - 1, 0, "earlier major");
#if NE_VERSION_MINOR > 0
GOOD(NE_VERSION_MAJOR, NE_VERSION_MINOR - 1, "earlier minor");
#endif /* NE_VERSION_MINOR > 0 */
#else /* where NE_VERSION_MAJOR == 0 */
BAD(0, 26, "earlier minor for 0.x");

#else /* where NE_VERSION_MAJOR < 2; note that 0.28 thru 1.0 maintain
* backwards compatibility to 0.27 */
BAD(0, 26, "minor version before 0.27");
GOOD(0, 27, "current version back-compat to 0.27");
GOOD(0, 28, "current version back-compat to 0.28");
GOOD(0, 29, "current version back-compat to 0.29");
GOOD(0, 30, "current version back-compat to 0.30");
#endif

return OK;
}

Expand Down

0 comments on commit 43a2932

Please sign in to comment.