Commit 28869d5e authored by Tollef Fog Heen's avatar Tollef Fog Heen Committed by Tollef Fog Heen

Update for varnish 4.0, including reworking the build system

parent 477f1ff5
...@@ -29,41 +29,18 @@ if test "x$RST2MAN" = "xno"; then ...@@ -29,41 +29,18 @@ if test "x$RST2MAN" = "xno"; then
fi fi
AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"]) AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"])
# Check for pkg-config
PKG_PROG_PKG_CONFIG
# Checks for header files. # Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS([sys/stdlib.h]) AC_CHECK_HEADERS([sys/stdlib.h])
# Check for python # Varnish include files tree
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_VMOD_INCLUDES
VARNISH_VMOD_DIR
# Varnish source tree VARNISH_VMODTOOL
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],
[],
[AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]
)
# Check that varnishtest is built in the varnish source directory # Check that varnishtest is built in the varnish source directory
AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], AC_PATH_PROG([VARNISHTEST], [varnishtest])
[], AC_PATH_PROG([VARNISHD], [varnishd])
[AC_MSG_FAILURE([Can't find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])]
)
# 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
fi
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile Makefile
......
INCLUDES = -I$(VARNISHSRC)/include -I$(VARNISHSRC) AM_CPPFLAGS = @VMOD_INCLUDES@
vmoddir = $(VMODDIR) vmoddir = @VMOD_DIR@
vmod_LTLIBRARIES = libvmod_example.la vmod_LTLIBRARIES = libvmod_example.la
libvmod_example_la_LDFLAGS = -module -export-dynamic -avoid-version -shared libvmod_example_la_LDFLAGS = -module -export-dynamic -avoid-version -shared
...@@ -10,14 +10,14 @@ libvmod_example_la_SOURCES = \ ...@@ -10,14 +10,14 @@ libvmod_example_la_SOURCES = \
vcc_if.h \ vcc_if.h \
vmod_example.c vmod_example.c
vcc_if.c vcc_if.h: $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod_example.vcc vcc_if.c vcc_if.h: @VMODTOOL@ $(top_srcdir)/src/vmod_example.vcc
@PYTHON@ $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod_example.vcc @VMODTOOL@ $(top_srcdir)/src/vmod_example.vcc
VMOD_TESTS = tests/*.vtc VMOD_TESTS = tests/*.vtc
.PHONY: $(VMOD_TESTS) .PHONY: $(VMOD_TESTS)
tests/*.vtc: 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) check: $(VMOD_TESTS)
......
#include <stdlib.h> #include <stdlib.h>
#include "vrt.h" #include "vrt.h"
#include "bin/varnishd/cache.h" #include "cache/cache.h"
#include "vcc_if.h" #include "vcc_if.h"
...@@ -11,22 +11,22 @@ init_function(struct vmod_priv *priv, const struct VCL_conf *conf) ...@@ -11,22 +11,22 @@ init_function(struct vmod_priv *priv, const struct VCL_conf *conf)
return (0); return (0);
} }
const char * VCL_STRING
vmod_hello(struct sess *sp, const char *name) vmod_hello(const struct vrt_ctx *ctx, VCL_STRING name)
{ {
char *p; char *p;
unsigned u, v; unsigned u, v;
u = WS_Reserve(sp->wrk->ws, 0); /* Reserve some work space */ u = WS_Reserve(ctx->ws, 0); /* Reserve some work space */
p = sp->wrk->ws->f; /* Front of workspace area */ p = ctx->ws->f; /* Front of workspace area */
v = snprintf(p, u, "Hello, %s", name); v = snprintf(p, u, "Hello, %s", name);
v++; v++;
if (v > u) { if (v > u) {
/* No space, reset and leave */ /* No space, reset and leave */
WS_Release(sp->wrk->ws, 0); WS_Release(ctx->ws, 0);
return (NULL); return (NULL);
} }
/* Update work space with what we've used */ /* Update work space with what we've used */
WS_Release(sp->wrk->ws, v); WS_Release(ctx->ws, v);
return (p); return (p);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment