From a399bdf2ce326066f951050abacdcdd7e9c968b0 Mon Sep 17 00:00:00 2001 From: Nils Goroll Date: Mon, 2 Mar 2015 11:53:35 +0100 Subject: [PATCH] autocrap magic to find varnish.m4 via pkg-config Fixes #6 (github issue) --- Makefile.am | 2 +- README.rst | 19 +++++++++++++++---- autogen.sh | 4 +++- configure.ac | 4 +++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Makefile.am b/Makefile.am index c086dbc..989e705 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -ACLOCAL_AMFLAGS = -I m4 +ACLOCAL_AMFLAGS = -I m4 -I ${LIBVARNISHAPI_DATAROOTDIR}/aclocal SUBDIRS = src diff --git a/README.rst b/README.rst index 7736191..7f35b1f 100644 --- a/README.rst +++ b/README.rst @@ -51,14 +51,18 @@ using the ``varnishtest`` tool. Building requires the Varnish header files and uses pkg-config to find the necessary paths. -If you have installed Varnish to a non-standard directory, you may need to -override PKG_CONFIG_PATH so configure can find varnishapi.pc. - Usage:: ./autogen.sh ./configure +If you have installed Varnish to a non-standard directory, call +``autogen.sh`` and ``configure`` with ``PKG_CONFIG_PATH`` pointing to +the appropriate path. For example, when varnishd configure was called +with ``--prefix=$PREFIX``, use + + PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig + export PKG_CONFIG_PATH Make targets: @@ -68,7 +72,7 @@ Make targets: * make distcheck - run check and prepare a tarball of the vmod. In your VCL you could then use this vmod along the following lines:: - + import example; sub vcl_deliver { @@ -76,3 +80,10 @@ In your VCL you could then use this vmod along the following lines:: set resp.http.hello = example.hello("World"); } +COMMON PROBLEMS +=============== + +* configure: error: Need varnish.m4 -- see README.rst + + Check if ``PKG_CONFIG_PATH`` has been set correctly before calling + ``autogen.sh`` and ``configure`` diff --git a/autogen.sh b/autogen.sh index 9a12ef5..1745b66 100755 --- a/autogen.sh +++ b/autogen.sh @@ -37,7 +37,9 @@ fi set -ex -aclocal -I m4 +# check for varnishapi.m4 in custom paths +dataroot=$(pkg-config --variable=datarootdir varnishapi) +aclocal -I m4 -I ${dataroot}/aclocal $LIBTOOLIZE --copy --force autoheader automake --add-missing --copy --foreign diff --git a/configure.ac b/configure.ac index 3721368..c118b15 100644 --- a/configure.ac +++ b/configure.ac @@ -2,6 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2011-2015 Varnish Software AS]) AC_INIT([libvmod-example], [trunk]) AC_CONFIG_MACRO_DIR([m4]) +m4_ifndef([VARNISH_VMOD_INCLUDES], AC_MSG_ERROR([Need varnish.m4 -- see README.rst])) AC_CONFIG_SRCDIR(src/vmod_example.vcc) AM_CONFIG_HEADER(config.h) @@ -33,8 +34,9 @@ AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"]) AC_HEADER_STDC AC_CHECK_HEADERS([sys/stdlib.h]) - PKG_CHECK_MODULES([libvarnishapi], [varnishapi]) +PKG_CHECK_VAR([LIBVARNISHAPI_DATAROOTDIR], [varnishapi], [datarootdir]) +AC_SUBST([LIBVARNISHAPI_DATAROOTDIR]) # Varnish include files tree VARNISH_VMOD_INCLUDES