forked from varnish/libvmod-header
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9ad8b8b
Showing
7 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ACLOCAL_AMFLAGS = -I m4 | ||
|
||
SUBDIRS = src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Module example | ||
Init init_function | ||
Function INT abs(INT) |