[master] 94c9a54 Package-wide and per-VMOD vcldir support in varnish.m4

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Mar 15 13:55:07 CET 2017


commit 94c9a54ace34125d3fab6925651d192e5cb9e160
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Sat Mar 11 11:21:12 2017 +0100

    Package-wide and per-VMOD vcldir support in varnish.m4
    
    Refs #2251

diff --git a/varnish.m4 b/varnish.m4
index b2157ce..31a5c8f 100644
--- a/varnish.m4
+++ b/varnish.m4
@@ -81,6 +81,7 @@ AC_DEFUN([_VARNISH_PKG_CONFIG], [
 	PKG_CHECK_VAR([VARNISHAPI_LIBDIR], [varnishapi], [libdir])
 	PKG_CHECK_VAR([VARNISHAPI_BINDIR], [varnishapi], [bindir])
 	PKG_CHECK_VAR([VARNISHAPI_SBINDIR], [varnishapi], [sbindir])
+	PKG_CHECK_VAR([VARNISHAPI_VCLDIR], [varnishapi], [vcldir])
 	PKG_CHECK_VAR([VARNISHAPI_VMODDIR], [varnishapi], [vmoddir])
 
 	PKG_CHECK_VAR([VMODTOOL], [varnishapi], [vmodtool])
@@ -90,6 +91,19 @@ AC_DEFUN([_VARNISH_PKG_CONFIG], [
 
 	AC_SUBST([VARNISH_TEST_PATH],
 		[$VARNISHAPI_SBINDIR:$VARNISHAPI_BINDIR:$PATH])
+
+	dnl Define the VCL directory for automake
+	AS_CASE([$prefix],
+		[NONE], [
+			vcldir=$VARNISHAPI_VCLDIR
+			ac_default_prefix=$VARNISHAPI_PREFIX],
+		[vcldir=$($PKG_CONFIG --define-variable=datadir=$datadir \
+			--variable=vcldir varnishapi)]
+	)
+	AC_SUBST([vcldir])
+
+	dnl Define the VCL directory for this package
+	AC_SUBST([pkgvcldir], [\${vcldir}/\${PACKAGE}])
 ])
 
 # _VARNISH_CHECK_DEVEL
@@ -183,6 +197,9 @@ AC_DEFUN([_VARNISH_VMOD], [
 	VMOD_IMPORT="$1 from \\\"$VMOD_FILE\\\""
 	AC_SUBST(m4_toupper(VMOD_$1), [$VMOD_IMPORT])
 
+	dnl Define the VCL directory for automake
+	AC_SUBST([vmod_$1_vcldir], [\${vcldir}/$1])
+
 	VMOD_RULES="
 
 vmod_$1.lo: vcc_$1_if.c vcc_$1_if.h
@@ -214,6 +231,9 @@ clean-vmod-$1:
 # --------------------
 # Since: Varnish 4.1.4
 #
+# Since Varnish 5.1.0:
+# - vmod_*_vcldir added
+#
 # Set up the VMOD tool-chain to build the collection of NAMES modules. The
 # definition of key variables is made available for use in Makefile rules
 # to build the modules:
@@ -222,6 +242,7 @@ clean-vmod-$1:
 # - VMOD_TEST_PATH (an alias for VARNISH_TEST_PATH)
 # - VMODTOOL (to generate a VMOD's interface)
 # - vmoddir (the install prefix for VMODs)
+# - vmod_*_vcldir (the install prefix for the VMODs VCL files)
 #
 # Configuring your VMOD build with libtool can be as simple as:
 #
@@ -267,7 +288,8 @@ clean-vmod-$1:
 # hand python detection is done and the resulting PYTHON variable to use
 # the VMODTOOL. Since nothing requires RST2MAN to be written in python, it
 # is left outside of the scope. You may even define a phony RST2MAN to
-# skip man page generation as it is often the case from a dist archive.
+# skip man page generation as it is often the case from a dist archive
+# (usually /bin/true when the manual is distributed).
 #
 # Two notable variables are exposed from Varnish's pkg-config:
 #
@@ -322,6 +344,22 @@ clean-vmod-$1:
 #
 #     EXTRA_DIST = vmod_foo.vcc vmod_bar.vcc $(TESTS)
 #
+# If a VMOD is actually a combination of both a library and VCL sub-routines,
+# automake directories are available for installation:
+#
+#     vmod_foo_vcl_DATA = some_addition.vcl
+#
+# This way the end-user's VCL only needs few lines of code to start using both
+# VMODs and VCLs assuming Varnish's default vmod_path and vcl_path were not
+# changed:
+#
+#     vcl 4.0;
+#
+#     import foo;
+#     import bar;
+#
+#     include "foo/some_addition.vcl";
+#
 # Now, you can focus on writing this VMOD of yours.
 #
 AC_DEFUN([VARNISH_VMODS], [
@@ -338,6 +376,9 @@ AC_DEFUN([VARNISH_VMODS], [
 # - VARNISH_TEST_PATH added
 # - VARNISH_LIBRARY_PATH added
 # - VARNISHAPI_LIBDIR added
+# - VARNISHAPI_VCLDIR added
+# - vcldir added
+# - pkgvcldir added
 #
 # Verify that the version of Varnish Cache found by pkg-config is at least
 # MINIMUM-VERSION. If MAXIMUM-VERSION is specified, verify that the version
@@ -360,9 +401,23 @@ AC_DEFUN([VARNISH_VMODS], [
 # - VARNISHAPI_LIBDIR
 # - VARNISHAPI_BINDIR
 # - VARNISHAPI_SBINDIR
+# - VARNISHAPI_VCLDIR
 # - VARNISHAPI_VMODDIR
 # - VMODTOOL
 #
+# In addition, two directories are set up for installation in automake:
+#
+# - vcldir
+# - pkgvcldir
+#
+# The vcldir is where Varnish will by default look up VCL files using relative
+# paths not found in its sysconfdir (by default /etc/varnish). The pkgvcldir on
+# the other hand is a recommended location for your package's VCL files, it
+# defaults to "${vcldir}/${PACKAGE}".
+#
+# This provides a namespace facility for installed VCL files needing including
+# other VCL files, which can be overridden if the package name is not desired.
+#
 AC_DEFUN([VARNISH_PREREQ], [
 	AC_REQUIRE([_VARNISH_PKG_CONFIG])
 	AC_REQUIRE([_VARNISH_CHECK_EXPLICIT_BZERO])



More information about the varnish-commit mailing list