Commit 9ad8b8bb authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Out-of-tree vmod skeleton

parents
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src
This is an example skeleton for developing out-of-tree Varnish vmods.
When running configure, specify the location of your Varnish source tree like this:
./configure VARNISHSRC=DIR
Optionally you can also set the vmod install dir by adding VMODDIR=DIR (defaults to LIBDIR/varnish/vmods, which would become /usr/local/lib/varnish/vmods on most platforms).
#!/bin/sh
warn() {
echo "WARNING: $@" 1>&2
}
case `uname -s` in
Darwin)
LIBTOOLIZE=glibtoolize
;;
FreeBSD)
LIBTOOLIZE=libtoolize
;;
Linux)
LIBTOOLIZE=libtoolize
;;
SunOS)
LIBTOOLIZE=libtoolize
;;
*)
warn "unrecognized platform:" `uname -s`
LIBTOOLIZE=libtoolize
esac
automake_version=`automake --version | tr ' ' '\n' | egrep '^[0-9]\.[0-9a-z.-]+'`
if [ -z "$automake_version" ] ; then
warn "unable to determine automake version"
else
case $automake_version in
0.*|1.[0-8]|1.[0-8][.-]*)
warn "automake ($automake_version) detected; 1.9 or newer recommended"
;;
*)
;;
esac
fi
set -ex
aclocal -I m4
$LIBTOOLIZE --copy --force
autoheader
automake --add-missing --copy --foreign
autoconf
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (c) 2011 Varnish Software AS])
AC_INIT([libvmod_example], [0.1])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/vmod.vcc)
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_SYSTEM
AC_LANG(C)
AM_INIT_AUTOMAKE([foreign])
AC_GNU_SOURCE
AC_PROG_CC
AC_PROG_CC_STDC
if test "x$ac_cv_prog_cc_c99" = xno; then
AC_MSG_ERROR([Could not find a C99 compatible compiler])
fi
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
# 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
AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h],
[],
[AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]
)
# vmod installation dir
AC_ARG_VAR([VMODDIR], [vmod installation directory @<:@LIBDIR/varnish/vmods@:>@])
if test "x$VMODDIR" = x; then
VMODDIR=$libdir/varnish/vmods
fi
AC_CONFIG_FILES([
Makefile
src/Makefile
])
AC_OUTPUT
INCLUDES = -I$(VARNISHSRC)/include -I$(VARNISHSRC)
vmoddir = $(VMODDIR)
vmod_LTLIBRARIES = libvmod_example.la
libvmod_example_la_LDFLAGS = -version-info 1:0:0
libvmod_example_la_SOURCES = \
vcc_if.c \
vcc_if.h \
vmod.c
vcc_if.c vcc_if.h: $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod.vcc
@PYTHON@ $(VARNISHSRC)/lib/libvmod_std/vmod.py $(top_srcdir)/src/vmod.vcc
EXTRA_DIST = vmod.vcc
CLEANFILES = $(builddir)vcc_if.c $(builddir)/vcc_if.h
#include <stdlib.h>
#include "vrt.h"
#include "bin/varnishd/cache.h"
#include "vcc_if.h"
int
init_function(struct vmod_priv *priv, const struct VCL_conf *conf)
{
return (0);
}
int
vmod_abs(struct sess *sp, int val)
{
return (abs(val));
}
Module example
Init init_function
Function INT abs(INT)
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