diff --git a/README.rst b/README.rst index 6b40d3e..d28b2f9 100644 --- a/README.rst +++ b/README.rst @@ -190,11 +190,7 @@ Usage:: ./autogen.sh # Execute configure script - ./configure VARNISHSRC=DIR [VMODDIR=DIR] - -`VARNISHSRC` is the directory of the Varnish source tree for which to -compile your vmod. Both the `VARNISHSRC` and `VARNISHSRC/include` -will be added to the include search paths for your module. + ./configure Optionally you can also set the vmod install directory by adding `VMODDIR=DIR` (defaults to the pkg-config discovered directory from your diff --git a/configure.ac b/configure.ac index 7d43f70..29c2944 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.59) -AC_COPYRIGHT([Copyright (c) 2011 Varnish Software AS]) +AC_COPYRIGHT([Copyright (c) 2011-2013 Varnish Software AS]) AC_INIT([libvmod-statsd], [trunk]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR(src/vmod_statsd.vcc) @@ -29,43 +29,18 @@ if test "x$RST2MAN" = "xno"; then fi AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"]) -# Check for pkg-config -PKG_PROG_PKG_CONFIG - # Checks for header files. AC_HEADER_STDC 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], - [], - [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])] -) -AM_CONDITIONAL(HAVE_VARNISHSRC, [test -n $VARNISHSRC]) +# Varnish include files tree +VARNISH_VMOD_INCLUDES +VARNISH_VMOD_DIR +VARNISH_VMODTOOL # Check that varnishtest is built in the varnish source directory -AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], - [], - [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 -AM_CONDITIONAL(HAVE_VMODDIR, [test -n $VMODDIR]) +AC_PATH_PROG([VARNISHTEST], [varnishtest]) +AC_PATH_PROG([VARNISHD], [varnishd]) AC_CONFIG_FILES([ Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 32a5f77..abfcac8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,40 +1,23 @@ -# if VARNISHSRC is defined on the command-line, use that. Otherwise, build -# this the same as the modules that come with varnish (i.e. we're building -# within the varnish src dir itself, and $(top_srcdir) is the varnish source). -# -if HAVE_VARNISHSRC -SRC = $(VARNISHSRC) -DIR_PREFIX = / -else -SRC = $(top_srcdir) -DIR_PREFIX = lib/libvmod-statsd/ -endif - -INCLUDES = -I$(SRC)/include -I$(SRC) - -if HAVE_VMODDIR -vmoddir = $(VMODDIR) -else -vmoddir = $(pkglibdir)/vmods -endif +AM_CPPFLAGS = @VMOD_INCLUDES@ +vmoddir = @VMOD_DIR@ vmod_LTLIBRARIES = libvmod_statsd.la -libvmod_statsd_la_LDFLAGS = -module -export-dynamic -avoid-version +libvmod_statsd_la_LDFLAGS = -module -export-dynamic -avoid-version -shared libvmod_statsd_la_SOURCES = \ vcc_if.c \ vcc_if.h \ vmod_statsd.c -vcc_if.c vcc_if.h: $(SRC)/lib/libvmod_std/vmod.py $(top_srcdir)/$(DIR_PREFIX)src/vmod_statsd.vcc - @PYTHON@ $(SRC)/lib/libvmod_std/vmod.py $(top_srcdir)/$(DIR_PREFIX)src/vmod_statsd.vcc +vcc_if.c vcc_if.h: @VMODTOOL@ $(top_srcdir)/src/vmod_statsd.vcc + @VMODTOOL@ $(top_srcdir)/src/vmod_statsd.vcc VMOD_TESTS = tests/*.vtc .PHONY: $(VMOD_TESTS) tests/*.vtc: - $(SRC)/bin/varnishtest/varnishtest -Dvarnishd=$(SRC)/bin/varnishd/varnishd -Dvmod_topbuild=$(abs_top_builddir) $@ + @VARNISHTEST@ -Dvarnishd=@VARNISHD@ -Dvmod_topbuild=$(abs_top_builddir) $@ check: $(VMOD_TESTS) @@ -42,4 +25,7 @@ EXTRA_DIST = \ vmod_statsd.vcc \ $(VMOD_TESTS) -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_statsd.man.rst \ + $(builddir)/vmod_statsd.rst \ + $(builddir)/../vmod_statsd.3 \ No newline at end of file diff --git a/src/vmod_statsd.c b/src/vmod_statsd.c index bff5101..63aa968 100644 --- a/src/vmod_statsd.c +++ b/src/vmod_statsd.c @@ -3,7 +3,7 @@ #include #include "vrt.h" -#include "bin/varnishd/cache.h" +#include "cache/cache.h" #include "vcc_if.h" @@ -108,14 +108,14 @@ init_function(struct vmod_priv *priv, const struct VCL_conf *conf) { /** The following may ONLY be called from VCL_init **/ void -vmod_prefix( struct sess *sp, struct vmod_priv *priv, const char *prefix ) { +vmod_prefix( const struct vrt_ctx *ctx, struct vmod_priv *priv, VCL_STRING prefix ) { config_t *cfg = priv->priv; cfg->prefix = _strip_newline( strdup( prefix ) ); } /** The following may ONLY be called from VCL_init **/ void -vmod_suffix( struct sess *sp, struct vmod_priv *priv, const char *suffix ) { +vmod_suffix( const struct vrt_ctx *ctx, struct vmod_priv *priv, VCL_STRING suffix ) { config_t *cfg = priv->priv; cfg->suffix = _strip_newline( strdup( suffix ) ); @@ -123,7 +123,7 @@ vmod_suffix( struct sess *sp, struct vmod_priv *priv, const char *suffix ) { /** The following may ONLY be called from VCL_init **/ void -vmod_server( struct sess *sp, struct vmod_priv *priv, const char *host, const char *port ) { +vmod_server( const struct vrt_ctx *ctx, struct vmod_priv *priv, VCL_STRING host, VCL_STRING port ) { // ****************************** // Configuration @@ -224,7 +224,7 @@ _connect_to_statsd( struct vmod_priv *priv ) { } int -_send_to_statsd( struct vmod_priv *priv, const char *key, const char *val ) { +_send_to_statsd( struct vmod_priv *priv, VCL_STRING key, VCL_STRING val ) { _DEBUG && fprintf( stderr, "vmod-statsd: pre config\n" ); config_t *cfg = priv->priv; @@ -327,7 +327,7 @@ _send_to_statsd( struct vmod_priv *priv, const char *key, const char *val ) { void -vmod_incr( struct sess *sp, struct vmod_priv *priv, const char *key ) { +vmod_incr( const struct vrt_ctx *ctx, struct vmod_priv *priv, VCL_STRING key ) { _DEBUG && fprintf( stderr, "vmod-statsd: incr: %s\n", key ); // Incremenet is straight forward - just add the count + type @@ -335,7 +335,7 @@ vmod_incr( struct sess *sp, struct vmod_priv *priv, const char *key ) { } void -vmod_timing( struct sess *sp, struct vmod_priv *priv, const char *key, int num ) { +vmod_timing( const struct vrt_ctx *ctx, struct vmod_priv *priv, VCL_STRING key, VCL_INT num ) { _DEBUG && fprintf( stderr, "vmod-statsd: timing: %s = %d\n", key, num ); // Get the buffer ready. 10 for the maximum lenghth of an int and +5 for metadata @@ -348,7 +348,7 @@ vmod_timing( struct sess *sp, struct vmod_priv *priv, const char *key, int num ) } void -vmod_counter( struct sess *sp, struct vmod_priv *priv, const char *key, int num ) { +vmod_counter( const struct vrt_ctx *ctx, struct vmod_priv *priv, VCL_STRING key, VCL_INT num ) { _DEBUG && fprintf( stderr, "vmod-statsd: counter: %s = %d\n", key, num ); // Get the buffer ready. 10 for the maximum lenghth of an int and +5 for metadata @@ -361,7 +361,7 @@ vmod_counter( struct sess *sp, struct vmod_priv *priv, const char *key, int num } void -vmod_gauge( struct sess *sp, struct vmod_priv *priv, const char *key, int num ) { +vmod_gauge( const struct vrt_ctx *ctx, struct vmod_priv *priv, VCL_STRING key, VCL_INT num ) { _DEBUG && fprintf( stderr, "vmod-statsd: gauge: %s = %d\n", key, num ); // Get the buffer ready. 10 for the maximum lenghth of an int and +5 for metadata diff --git a/src/vmod_statsd.vcc b/src/vmod_statsd.vcc index 7d5a787..8266c05 100644 --- a/src/vmod_statsd.vcc +++ b/src/vmod_statsd.vcc @@ -1,9 +1,9 @@ -Module statsd -Init init_function -Function VOID server( PRIV_VCL, STRING, STRING ) -Function VOID prefix( PRIV_VCL, STRING ) -Function VOID suffix( PRIV_VCL, STRING ) -Function VOID incr( PRIV_VCL, STRING ) -Function VOID gauge( PRIV_VCL, STRING, INT ) -Function VOID timing( PRIV_VCL, STRING, INT ) -Function VOID counter( PRIV_VCL, STRING, INT ) +$Module statsd 3 StatsD VMOD for Varnish +$Init init_function +$Function VOID server( PRIV_VCL, STRING, STRING ) +$Function VOID prefix( PRIV_VCL, STRING ) +$Function VOID suffix( PRIV_VCL, STRING ) +$Function VOID incr( PRIV_VCL, STRING ) +$Function VOID gauge( PRIV_VCL, STRING, INT ) +$Function VOID timing( PRIV_VCL, STRING, INT ) +$Function VOID counter( PRIV_VCL, STRING, INT )