- diff --git a/configure.ac b/configure.ac
- index ae5e0a8..3e0f0ea 100644
- --- a/configure.ac
- +++ b/configure.ac
- @@ -39,30 +39,31 @@ AC_CHECK_HEADERS([sys/stdlib.h])
- # Check for python
- AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build this vmod, please install python.])])
- -# Varnish source tree
- -AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree (mandatory)])
- -if test "x$VARNISHSRC" = x; then
- - AC_MSG_ERROR([No Varnish source tree specified])
- -fi
- -VARNISHSRC=`cd $VARNISHSRC && pwd`
- -AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h],
- +# Check for Varnish
- +AC_SUBST(VARNISH_BINDIR, `$PKG_CONFIG --variable=bindir varnishapi`)
- +AC_SUBST(VARNISH_SBINDIR, `$PKG_CONFIG --variable=sbindir varnishapi`)
- +AC_SUBST(VARNISH_PKGDATA, `$PKG_CONFIG --variable=pkgdatadir varnishapi`)
- +AC_SUBST(VMOD_INCLUDE, `$PKG_CONFIG --variable=pkgdataincludedir varnishapi`)
- +AC_SUBST(VMOD_DIR, `$PKG_CONFIG --variable=vmoddir varnishapi`)
- +AC_SUBST(VMOD_TOOL, $VARNISH_PKGDATA/vmodtool.py)
- +AC_CHECK_FILE([$VARNISH_SBINDIR/varnishd],
- + [AC_SUBST(VARNISHD, "$VARNISH_SBINDIR/varnishd")],
- + [AC_MSG_FAILURE([Can't find "$VARNISH_SBINDIR/varnishd"])]
- +)
- +AC_CHECK_FILE([$VARNISH_BINDIR/varnishtest],
- + [AC_SUBST(VARNISHTEST, "$VARNISH_BINDIR/varnishtest")],
- + [AC_MSG_FAILURE([Can't find "$VARNISH_BINDIR/varnishtest"])]
- +)
- +AC_CHECK_FILE([$VMOD_TOOL],
- [],
- - [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]
- + [AC_MSG_FAILURE([Can't find "$VMOD_TOOL"])]
- )
- -
- -# Check that varnishtest is built in the varnish source directory
- -AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest],
- +AC_CHECK_FILE([$VMOD_INCLUDE/cache/cache.h],
- [],
- - [AC_MSG_FAILURE([Can't find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])]
- + [AC_MSG_FAILURE([Can't find "$VMOD_INCLUDE/cache/cache.h"])]
- )
- -
- -# vmod installation dir
- -AC_ARG_VAR([VMODDIR], [vmod installation directory @<:@LIBDIR/varnish/vmods@:>@])
- -if test "x$VMODDIR" = x; then
- - VMODDIR=`pkg-config --variable=vmoddir varnishapi`
- - if test "x$VMODDIR" = x; then
- - AC_MSG_FAILURE([Can't determine vmod installation directory])
- - fi
- +if test ! -d "$VMOD_DIR"; then
- + AC_MSG_FAILURE([Can't determine vmod installation directory])
- fi
- AC_CONFIG_FILES([
- diff --git a/src/Makefile.am b/src/Makefile.am
- index c8f8088..985ad57 100644
- --- a/src/Makefile.am
- +++ b/src/Makefile.am
- @@ -1,6 +1,6 @@
- -INCLUDES = -I$(VARNISHSRC)/include -I$(VARNISHSRC)
- +INCLUDES = -I$(VMOD_INCLUDE)
- -vmoddir = $(VMODDIR)
- +vmoddir = $(VMOD_DIR)
- vmod_LTLIBRARIES = libvmod_example.la
- libvmod_example_la_LDFLAGS = -module -export-dynamic -avoid-version
- @@ -10,14 +10,14 @@ libvmod_example_la_SOURCES = \
- vcc_if.h \
- vmod_example.c
- -vcc_if.c vcc_if.h: $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod_example.vcc
- - @PYTHON@ $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod_example.vcc
- +vcc_if.c vcc_if.h: $(VMOD_TOOL) $(top_srcdir)/src/vmod_example.vcc
- + @PYTHON@ $(VMOD_TOOL) $(top_srcdir)/src/vmod_example.vcc
- VMOD_TESTS = tests/*.vtc
- .PHONY: $(VMOD_TESTS)
- tests/*.vtc:
- - $(VARNISHSRC)/bin/varnishtest/varnishtest -Dvarnishd=$(VARNISHSRC)/bin/varnishd/varnishd -Dvmod_topbuild=$(abs_top_builddir) $@
- + $(VARNISHTEST) -Dvarnishd=$(VARNISHD) -Dvmod_topbuild=$(abs_top_builddir) $@
- check: $(VMOD_TESTS)
- diff --git a/src/vmod_example.c b/src/vmod_example.c
- index 468fa75..082f38e 100644
- --- a/src/vmod_example.c
- +++ b/src/vmod_example.c
- @@ -1,7 +1,8 @@
- #include <stdlib.h>
- +#include <stdio.h>
- #include "vrt.h"
- -#include "bin/varnishd/cache.h"
- +#include "cache/cache.h"
- #include "vcc_if.h"
- @@ -17,16 +18,16 @@ vmod_hello(struct sess *sp, const char *name)
- char *p;
- unsigned u, v;
- - u = WS_Reserve(sp->wrk->ws, 0); /* Reserve some work space */
- - p = sp->wrk->ws->f; /* Front of workspace area */
- + u = WS_Reserve(sp->req->ws, 0); /* Reserve some work space */
- + p = sp->req->ws->f; /* Front of workspace area */
- v = snprintf(p, u, "Hello, %s", name);
- v++;
- if (v > u) {
- /* No space, reset and leave */
- - WS_Release(sp->wrk->ws, 0);
- + WS_Release(sp->req->ws, 0);
- return (NULL);
- }
- /* Update work space with what we've used */
- - WS_Release(sp->wrk->ws, v);
- + WS_Release(sp->req->ws, v);
- return (p);
- }