Commit 298d83fc authored by Nils Goroll's avatar Nils Goroll

modernise build infrastructure to current state libvmod-example

parent 78786ad8
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4 -I ${LIBVARNISHAPI_DATAROOTDIR}/aclocal
SUBDIRS = src SUBDIRS = src
EXTRA_DIST = README.rst DISTCHECK_CONFIGURE_FLAGS = \
VMOD_DIR='$${libdir}/varnish/vmods'
EXTRA_DIST = README.rst LICENSE vmod-example.spec debian
doc_DATA = README.rst LICENSE
dist_man_MANS = vmod_vslp.3 dist_man_MANS = vmod_vslp.3
MAINTAINERCLEANFILES = $(dist_man_MANS) MAINTAINERCLEANFILES = $(dist_man_MANS)
vmod_vslp.3: README.rst vmod_vslp.3: README.rst
%.1 %.2 %.3 %.4 %.5 %.6 %.7 %.8 %.9:
if HAVE_RST2MAN if HAVE_RST2MAN
${RST2MAN} README.rst $@ ${RST2MAN} $< $@
else else
@echo "========================================" @echo "========================================"
@echo "You need rst2man installed to make dist" @echo "You need rst2man installed to make dist"
......
...@@ -180,24 +180,30 @@ INSTALLATION ...@@ -180,24 +180,30 @@ INSTALLATION
The source tree is based on autotools to configure the building, and The source tree is based on autotools to configure the building, and
does also have the necessary bits in place to do functional unit tests does also have the necessary bits in place to do functional unit tests
using the varnishtest tool. using the ``varnishtest`` tool.
Building requires the Varnish header files and uses pkg-config to find
the necessary paths.
Usage:: Usage::
./configure VARNISHSRC=DIR [VMODDIR=DIR] ./autogen.sh
./configure
`VARNISHSRC` is the directory of the Varnish source tree for which to If you have installed Varnish to a non-standard directory, call
compile your vmod. ``autogen.sh`` and ``configure`` with ``PKG_CONFIG_PATH`` pointing to
the appropriate path. For example, when varnishd configure was called
with ``--prefix=$PREFIX``, use
Optionally you can also set the vmod install directory by adding PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
`VMODDIR=DIR` (defaults to the pkg-config discovered directory from your export PKG_CONFIG_PATH
Varnish installation).
Make targets: Make targets:
* make - builds the vmod * make - builds the vmod.
* make install - installs your vmod in `VMODDIR` * make install - installs your vmod.
* make check - runs the unit tests in ``src/tests/*.vtc`` * make check - runs the unit tests in ``src/tests/*.vtc``
* make distcheck - run check and prepare a tarball of the vmod.
MISSING MISSING
...@@ -212,7 +218,8 @@ Version 1.0: Initial version. ...@@ -212,7 +218,8 @@ Version 1.0: Initial version.
ACKNOWLEDGEMENTS ACKNOWLEDGEMENTS
================ ================
Development of this module was partially sponsored by Deutsche Telekom AG – Products & Innovation Development of this module was partly sponsored by Deutsche Telekom AG
– Products & Innovation
COPYRIGHT COPYRIGHT
...@@ -221,5 +228,5 @@ COPYRIGHT ...@@ -221,5 +228,5 @@ COPYRIGHT
This document is licensed under the same license as the This document is licensed under the same license as the
libvmod-vslp project. See LICENSE for details. libvmod-vslp project. See LICENSE for details.
Copyright (c) 2013 UPLEX Nils Goroll Systemoptimierung. All rights Copyright (c) 2013-2015 UPLEX Nils Goroll Systemoptimierung. All rights
reserved. reserved.
#!/bin/sh #!/bin/sh
#
# $Id$
#
warn() { warn() {
echo "WARNING: $@" 1>&2 echo "WARNING: $@" 1>&2
...@@ -9,38 +6,47 @@ warn() { ...@@ -9,38 +6,47 @@ warn() {
case `uname -s` in case `uname -s` in
Darwin) Darwin)
LIBTOOLIZE=glibtoolize LIBTOOLIZE=glibtoolize
;; ;;
FreeBSD) FreeBSD)
LIBTOOLIZE=libtoolize LIBTOOLIZE=libtoolize
;; ;;
Linux) Linux)
LIBTOOLIZE=libtoolize LIBTOOLIZE=libtoolize
;; ;;
SunOS) SunOS)
LIBTOOLIZE=libtoolize LIBTOOLIZE=libtoolize
;; ;;
*) *)
warn "unrecognized platform:" `uname -s` warn "unrecognized platform:" `uname -s`
LIBTOOLIZE=libtoolize LIBTOOLIZE=libtoolize
esac esac
automake_version=`automake --version | tr ' ' '\n' | egrep '^[0-9]\.[0-9a-z.-]+'` automake_version=`automake --version | tr ' ' '\n' | egrep '^[0-9]\.[0-9a-z.-]+'`
if [ -z "$automake_version" ] ; then if [ -z "$automake_version" ] ; then
warn "unable to determine automake version" warn "unable to determine automake version"
else else
case $automake_version in case $automake_version in
0.*|1.[0-8]|1.[0-8][.-]*) 0.*|1.[0-8]|1.[0-8][.-]*)
warn "automake ($automake_version) detected; 1.9 or newer recommended" warn "automake ($automake_version) detected; 1.9 or newer recommended"
;; ;;
*) *)
;; ;;
esac esac
fi fi
# check for varnishapi.m4 in custom paths
dataroot=$(pkg-config --variable=datarootdir varnishapi 2>/dev/null)
if [ -z "$dataroot" ] ; then
cat >&2 <<'EOF'
Package varnishapi was not found in the pkg-config search path.
Perhaps you should add the directory containing `varnishapi.pc'
to the PKG_CONFIG_PATH environment variable
EOF
exit 1
fi
set -ex set -ex
aclocal -I m4 -I ${dataroot}/aclocal
aclocal
$LIBTOOLIZE --copy --force $LIBTOOLIZE --copy --force
autoheader autoheader
automake --add-missing --copy --foreign automake --add-missing --copy --foreign
......
AC_PREREQ(2.59) AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (c) 2013 UPLEX - Nils Goroll Systemoptimierung, 2011 Varnish Software AS]) AC_COPYRIGHT([Copyright (c) 2013-2015 UPLEX - Nils Goroll Systemoptimierung])
AC_INIT([libvmod-vslp], [master]) AC_INIT([libvmod-vslp], [master])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
m4_ifndef([VARNISH_VMOD_INCLUDES], AC_MSG_ERROR([Need varnish.m4 -- see README.rst]))
AC_CONFIG_SRCDIR(src/vmod_vslp.vcc) AC_CONFIG_SRCDIR(src/vmod_vslp.vcc)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
...@@ -29,41 +30,43 @@ if test "x$RST2MAN" = "xno"; then ...@@ -29,41 +30,43 @@ 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 # backwards compat with older pkg-config
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.])]) # - pull in AC_DEFUN from pkg.m4
m4_ifndef([PKG_CHECK_VAR], [
# Varnish source tree # PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree (mandatory)]) # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
if test "x$VARNISHSRC" = x; then # -------------------------------------------
AC_MSG_ERROR([No Varnish source tree specified]) # Retrieves the value of the pkg-config variable for the given module.
fi AC_DEFUN([PKG_CHECK_VAR],
VARNISHSRC=`cd $VARNISHSRC && pwd` [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_CHECK_FILE([$VARNISHSRC/include/vrt.h], AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
[],
[AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])] _PKG_CONFIG([$1], [variable="][$3]["], [$2])
) AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])# PKG_CHECK_VAR
])
# Check that varnishtest is built in the varnish source directory PKG_CHECK_MODULES([libvarnishapi], [varnishapi])
AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], PKG_CHECK_VAR([LIBVARNISHAPI_DATAROOTDIR], [varnishapi], [datarootdir])
[], PKG_CHECK_VAR([LIBVARNISHAPI_BINDIR], [varnishapi], [bindir])
[AC_MSG_FAILURE([Can't find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])] PKG_CHECK_VAR([LIBVARNISHAPI_SBINDIR], [varnishapi], [sbindir])
) AC_SUBST([LIBVARNISHAPI_DATAROOTDIR])
# vmod installation dir # Varnish include files tree
AC_ARG_VAR([VMODDIR], [vmod installation directory @<:@LIBDIR/varnish/vmods@:>@]) VARNISH_VMOD_INCLUDES
if test "x$VMODDIR" = x; then VARNISH_VMOD_DIR
VMODDIR=`pkg-config --variable=vmoddir varnishapi` VARNISH_VMODTOOL
if test "x$VMODDIR" = x; then
AC_MSG_FAILURE([Can't determine vmod installation directory]) AC_PATH_PROG([VARNISHTEST], [varnishtest], [],
fi [$LIBVARNISHAPI_BINDIR:$LIBVARNISHAPI_SBINDIR:$PATH])
fi AC_PATH_PROG([VARNISHD], [varnishd], [],
[$LIBVARNISHAPI_SBINDIR:$LIBVARNISHAPI_BINDIR:$PATH])
# This corresponds to FreeBSD's WARNS level 6 # This corresponds to FreeBSD's WARNS level 6
DEVELOPER_CFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wformat" DEVELOPER_CFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wformat"
......
AM_CPPFLAGS = @VMOD_INCLUDES@ -Wall -Werror
# -I$(VARNISHSRC)/include \
# -I$(VARNISHSRC)/bin/varnishd \
# -I$(VARNISHSRC)/lib/libvgz
AM_CPPFLAGS = \ vmoddir = @VMOD_DIR@
-I$(VARNISHSRC)/include \
-I$(VARNISHSRC)/bin/varnishd \
-I$(VARNISHSRC)/lib/libvgz
AM_LDFLAGS = $(AM_LT_LDFLAGS)
vmoddir = $(VMODDIR)
vmod_LTLIBRARIES = libvmod_vslp.la vmod_LTLIBRARIES = libvmod_vslp.la
vmod_srcdir = $(top_srcdir)/src
vmodtool = $(VARNISHSRC)/lib/libvcc/vmodtool.py
libvmod_vslp_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared libvmod_vslp_la_LDFLAGS = -module -export-dynamic -avoid-version -shared
libvmod_vslp_la_SOURCES = \ libvmod_vslp_la_SOURCES = \
vmod_vslp.c \ vmod_vslp.c \
...@@ -22,24 +17,27 @@ nodist_libvmod_vslp_la_SOURCES = \ ...@@ -22,24 +17,27 @@ nodist_libvmod_vslp_la_SOURCES = \
vcc_if.c \ vcc_if.c \
vcc_if.h vcc_if.h
# BUILT_SOURCES is only a hack and dependency tracking does not help for the first build vmod_vslp.lo: vcc_if.c vcc_if.h
vmod_vslp.lo: vcc_if.h
vcc_if.c vcc_if.h: $(vmodtool) $(vmod_srcdir)/vmod_vslp.vcc vcc_if.c: vcc_if.h
@PYTHON@ $(vmodtool) $(vmod_srcdir)/vmod_vslp.vcc
VMOD_TESTS = tests/*.vtc vcc_if.h: @VMODTOOL@ $(top_srcdir)/src/vmod_vslp.vcc
@VMODTOOL@ $(top_srcdir)/src/vmod_vslp.vcc
VMOD_TESTS = $(top_srcdir)/src/tests/*.vtc
.PHONY: $(VMOD_TESTS)
check: $(VARNISHSRC)/bin/varnishtest/varnishtest $(top_srcdir)/src/tests/*.vtc: libvmod_vslp.la
$(VARNISHSRC)/bin/varnishtest/varnishtest \ @VARNISHTEST@ -Dvarnishd=@VARNISHD@ -Dvmod_topbuild=$(abs_top_builddir) $@
-Dvarnishd=$(VARNISHSRC)/bin/varnishd/varnishd \
-Dvmod_topbuild=$(abs_top_builddir) \ check: $(VMOD_TESTS)
tests/*.vtc
EXTRA_DIST = \ EXTRA_DIST = \
vmod_vslp.vcc \ vmod_vslp.vcc \
$(VMOD_TESTS) $(VMOD_TESTS)
CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h CLEANFILES = \
$(builddir)/vcc_if.c \
$(builddir)/vcc_if.h \
$(builddir)/vmod_vslp.rst \
$(builddir)/vmod_vslp.man.rst
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