diff options
-rw-r--r-- | varnishapi.m4 | 69 |
1 files changed, 49 insertions, 20 deletions
diff --git a/varnishapi.m4 b/varnishapi.m4 index 8a00c8f..129d66a 100644 --- a/varnishapi.m4 +++ b/varnishapi.m4 @@ -1,5 +1,5 @@ ## Autoconf macros for writing Varnish modules -## Copyright (C) 2016,2017 Sergey Poznyakoff +## Copyright (C) 2016-2020 Sergey Poznyakoff ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ ## You should have received a copy of the GNU General Public License ## along with this program. If not, see <http://www.gnu.org/licenses/>. -## serial 2 +## serial 3 ## VAPI_CHECK_VER([MAJOR], [MINOR], [PATCH]) - Check version ## @@ -33,18 +33,15 @@ m4_define([VAPI_CHECK_VER],[ varnishapi_version_diff=newer m4_if([$2],,,[elif test $VARNISHAPI_MINOR -lt $2; then varnishapi_version_diff=older - elif test $VARNISHAPI_MINOR -gt $2; then + ])elif test $VARNISHAPI_MINOR -gt m4_if([$2],,0,[$2]); then varnishapi_version_diff=newer - ])m4_if([$3],,,[elif test $VARNISHAPI_PATCH -lt $3; then + m4_if([$3],,,[elif test $VARNISHAPI_PATCH -lt $3; then varnishapi_version_diff=older - elif test $VARNISHAPI_PATCH -gt $3; then + ])elif test $VARNISHAPI_PATCH -gt m4_if([$3],,0,[$3]); then varnishapi_version_diff=newer - ])else + else varnishapi_version_diff=same fi - if test $varnishapi_version_diff = older; then - AC_MSG_ERROR([unsupported varnishapi version $VARNISHAPI_MAJOR.$VARNISHAPI_MINOR.$VARNISHAPI_PATCH]) - fi ])]) ## AM_VARNISHAPI([MIN-VERSION],[MAX-VERSION]) @@ -65,25 +62,27 @@ m4_define([VAPI_CHECK_VER],[ ## VMODDIR the path of the varnish module directory. ## VARNISH_MAJOR, VARNISH_MINOR, and VARNISH_PATCH ## the corresponding numbers of the varnish API version. -## VARNISHD full pathname of the varnishd binary -## VARNISHTEST full pathname of the varnishtest binary +## VARNISHD full pathname of the varnishd binary. +## VARNISHTEST full pathname of the varnishtest binary. ## VARNISHAPI_PKGDATADIR -## varnish API package data directory +## varnish API package data directory. ## VARNISHAPI_VMODTOOL -## full pathname of the vmodtool.py script +## full pathname of the vmodtool.py script. +## PYTHON full pathname of the python 3 binary. +## RST2MAN full pathname of the rst2man or rst2man.py script. ## AC_DEFUN([AM_VARNISHAPI], [ # Check for pkg-config PKG_PROG_PKG_CONFIG # Check for python - AC_CHECK_PROGS(PYTHON, [python], [AC_MSG_ERROR([python is not found.])]) - - # Varnish source tree (deprecated) - AC_ARG_WITH([varnish-source], - [], - [AC_MSG_ERROR([the --with-varnish-source option has been withdrawn])]) + AM_PATH_PYTHON([3.5]) + # Check for rst2man.py or rst2man + AC_PATH_PROGS(RST2MAN, [rst2man.py rst2man], + [\$(abs_top_srcdir)/build-aux/missing rst2man.py]) + AC_SUBST([RST2MAN]) + # pkg-config PKG_PROG_PKG_CONFIG PKG_CHECK_MODULES([VARNISHAPI], [varnishapi]) @@ -105,6 +104,9 @@ AC_DEFUN([AM_VARNISHAPI], m4_pushdef([ver],[m4_bpatsubst(AC_PACKAGE_VERSION,[.*-\([0-9]\.[0-9]\.[0-9]\)$],[\1])]) VAPI_CHECK_VER(m4_unquote(m4_split(m4_if([ver],AC_PACKAGE_VERSION,[$1],[$1],,[ver],[$1]),\.))) + if test $varnishapi_version_diff = older; then + AC_MSG_ERROR([varnishapi version too old: $VARNISHAPI_MAJOR.$VARNISHAPI_MINOR.$VARNISHAPI_PATCH; required at least $1]) + fi m4_if([$2],,[m4_if(ver,AC_PACKAGE_VERSION,[# Suppress the warning message varnishapi_version_diff=same])],dnl @@ -115,6 +117,33 @@ AC_DEFUN([AM_VARNISHAPI], else AC_MSG_ERROR([unknown varnishapi version]) fi + + if test "$VARNISHAPI_MAJOR" -eq 6; then + save_cflags=$CFLAGS + CFLAGS=$VARNISHAPI_CFLAGS + AC_CHECK_DECLS([WS_ReserveAll,WS_ReserveSize],[],[], + [#include <cache/cache.h> +#include <vcl.h> +]) + CFLAGS=$save_cflags + AH_BOTTOM([/* + * The two functions below appeared in 6.0 and were removed in + * versions 6.1 and 6.2 only to resurge in 6.3, with the additional + * notice that they are going to replace the WS_Reserve function, + * which will be removed after 2020-09-15. + * (see http://varnish-cache.org/docs/trunk/whats-new/upgrading-6.3.html) + * These macros work around this vacillation. + */ +#if VARNISHAPI_MAJOR == 6 +# if !HAVE_DECL_WS_RESERVEALL +# define WS_ReserveAll(ws) WS_Reserve(ws,0) +# endif +# if !HAVE_DECL_WS_RESERVESIZE +# define WS_ReserveSize(ws,sz) WS_Reserve(ws,sz) +# endif +#endif +]) + fi # vmod installation dir AC_ARG_VAR([VMODDIR], [vmod installation directory]) @@ -162,7 +191,7 @@ echo "Building for Varnish version $version" if test "$varnishapi_version_diff" = newer; then fmt <<EOT WARNING: This version is newer than the latest version for which -$PACKAGE_STRING was tested. If it doesn't compile, please send a mail to +$PACKAGE_STRING was tested ($2). If it doesn't compile, please report it to <$PACKAGE_BUGREPORT>. EOT fi |