Commit 5602713f authored by Nils Goroll's avatar Nils Goroll

Major overhaul of autocrap infrastructure and modernize varnish.m4 with varnish >= 4

- configure by pkg-config (new varnish4 / master standard - see vmod-example)
- make distcheck works now (working around dependency tracking issues with
  --disable-dependency-tracking )
- split out checks into a seperate subtree to ensure the build is complete
  before checking (parallel make wasn't working otherwise)
parent 274bf62b
......@@ -22,9 +22,8 @@ benchmark_results
/autom4te.cache/
/compile
/config.guess
/dcs_config.h
/dcs_config.h.in
/dcs_config.h.in~
/config.h
/config.h.in
/config.log
/config.status
/config.sub
......@@ -65,3 +64,5 @@ src/vcc_if.h
src/gen/dcs_classifier.checksum
src/*.rst
test-driver
dcs_classifier-*
src/gen/dbfile
if HAVE_VARNISH_M4
ACLOCAL_AMFLAGS = -I m4 -I ${LIBVARNISHAPI_DATAROOTDIR}/aclocal
else
ACLOCAL_AMFLAGS = -I m4
endif
# pass all given arguments
#
# --disable-dependency-tracking works around this issue which seems to
# be related to subdir-objects
DISTCHECK_CONFIGURE_FLAGS = \
DCS_KEY='$(DCS_KEY)' \
DCS_ACCOUNT='$(DCS_ACCOUNT)' \
DCS_DBFILE='$(DCS_DBFILE)' \
VMOD_DIR='$(VMOD_DIR)' \
VARNISHSRC='$(VARNISHSRC)' \
--disable-dependency-tracking
SUBDIRS = src
SUBDIRS = src check
dist_man_MANS = vmod_dcs.3
MAINTAINERCLEANFILES = $(dist_man_MANS)
......@@ -19,4 +36,4 @@ else
@false
endif
dist_data_DATA = dcs_config.h
dist_data_DATA = config.h
......@@ -242,7 +242,7 @@ above, the `VARNISHSRC` argument must be used as in
VARNISHSRC=/path/to/your/varnish/source/varnish-cache
Optionally, a custom vmod installation directory can be specified
using `VMODDIR=<dir>`
using `VMOD_DIR=<dir>`
When building the vmod, an additional
......
......@@ -35,10 +35,16 @@ else
esac
fi
# check for varnishapi.m4 in custom paths
dataroot=$(pkg-config --variable=datarootdir varnishapi 2>/dev/null)
# no error if this fails, we could be building for varnish2
if [ -z "${dataroot}" ] ; then
aclocal -I m4
else
aclocal -I m4 -I ${dataroot}/aclocal
fi
set -ex
$LIBTOOLIZE --copy --force
aclocal -I m4
autoheader
automake --add-missing --copy --foreign
autoconf
# check / Makefile.am
AUTOMAKE_OPTIONS = subdir-objects
VMOD_TESTS = $(srcdir)/@TESTDIR@/*.vtc
.PHONY: $(VMOD_TESTS)
$(srcdir)/@TESTDIR@/*.vtc:
@VARNISHTEST@ -Dvarnishd=@VARNISHD@ -Dvmod_topbuild=$(abs_top_builddir) $@
check: $(VMOD_TESTS)
EXTRA_DIST = \
$(VMOD_TESTS)
AC_PREREQ(2.69)
AC_COPYRIGHT([Copyright 2014 UPLEX - Nils Goroll Systemoptimierung])
AC_INIT([dcs_classifier], [0.4])
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright 2015 UPLEX - Nils Goroll Systemoptimierung])
AC_INIT([dcs_classifier], [trunk])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/gen/gen_dcs_classifier.pl)
AM_CONFIG_HEADER(dcs_config.h)
# vmodtool generates vcc_if.c which includes config.h, so though we
# would like to use a different name like dcs_config.h, we can't
# because this would further complicate vmodtool
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_SYSTEM
AC_LANG(C)
......@@ -11,6 +15,30 @@ AC_LANG(C)
AM_INIT_AUTOMAKE([1.13 foreign])
AM_EXTRA_RECURSIVE_TARGETS([fixup load])
############################################################
## autotools compat
# backwards compat with older pkg-config
# - pull in AC_DEFUN from pkg.m4
m4_ifndef([PKG_CHECK_VAR], [
# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# -------------------------------------------
# Retrieves the value of the pkg-config variable for the given module.
AC_DEFUN([PKG_CHECK_VAR],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
_PKG_CONFIG([$1], [variable="][$3]["], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])# PKG_CHECK_VAR
])
############################################################
## generic requirements
AC_GNU_SOURCE
AC_PROG_CC
AC_PROG_CC_STDC
......@@ -40,6 +68,158 @@ AC_CHECK_HEADERS([sys/stdlib.h])
AX_PROG_PERL_MODULES([Crypt::RC4 Digest::MD5 MIME::Base64], ,
AC_MSG_ERROR([required perl module(s) missing]))
############################################################
## Varnish version specific config
##
## we want to be compatible with
## - varnish 4 and newer - automagic config via pkg-config
## - varnish 3 - config via VARNISHSRC
## - varnish 2 install c sources
## overview of the following section
##
## MACRO_IF have_m4_macros for pkg-config
## if ! VARNISHSRC overrides
## configure using pkg-config
## else
## MACRO_ELSE
## if true
## MACRO_FI
## configure from VARNISHSRC
## fi
if test "x$VMODDIR" != x && test "x$VMOD_DIR" = x ; then
AC_MSG_FAILURE([VMODDIR is now called VMOD_DIR])
fi
AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree for vmod (varnish3)])
m4_ifdef([VARNISH_VMOD_INCLUDES],
[
if test "x$VARNISHSRC" = x; then
AM_CONDITIONAL([HAVE_VARNISH_M4], [true])
AC_MSG_NOTICE([Configuring from pkg-config (Varnish 4 or newer)])
# varnish4 and newer - use varnish.m4 macros
PKG_CHECK_MODULES([libvarnishapi], [varnishapi])
PKG_CHECK_VAR([LIBVARNISHAPI_DATAROOTDIR], [varnishapi], [datarootdir])
PKG_CHECK_VAR([LIBVARNISHAPI_BINDIR], [varnishapi], [bindir])
PKG_CHECK_VAR([LIBVARNISHAPI_SBINDIR], [varnishapi], [sbindir])
AC_SUBST([LIBVARNISHAPI_DATAROOTDIR])
# Varnish include files tree
VARNISH_VMOD_INCLUDES
VARNISH_VMOD_DIR
VARNISH_VMODTOOL
AC_PATH_PROG([VARNISHTEST], [varnishtest], [],
[$LIBVARNISHAPI_BINDIR:$LIBVARNISHAPI_SBINDIR:$PATH])
AC_PATH_PROG([VARNISHD], [varnishd], [],
[$LIBVARNISHAPI_SBINDIR:$LIBVARNISHAPI_BINDIR:$PATH])
AM_CONDITIONAL([BUILD_VMOD], [true])
AC_SUBST([VCCFILE], [vmod_dcs4.vcc])
AC_DEFINE([VARNISH_MAJOR], [4], [Define the Varnish major version we compile against])
AC_SUBST([TESTDIR], [tests4])
else
AM_CONDITIONAL([HAVE_VARNISH_M4], [false])
AC_MSG_NOTICE([VARNISHSRC overrides pkg-config])
AC_CHECK_FILE([$VARNISHSRC/lib/libvcc/vmodtool.py], [
AC_MSG_FAILURE([[VARNISHSRC seems to point to varnish4 sources.
This is now desupported. Instead, point pkg-config to the right path
and call autogen and configure with VARNISHSRC unset:
export PKG_CONFIG_PATH=.../pkgconfig
./autogen.sh && configure ...
]])
])
],[
AM_CONDITIONAL([HAVE_VARNISH_M4], [false])
if test "x$VARNISHSRC" = x; then
if test "x$enable_varnish2" = x; then
AC_MSG_WARN([[No Varnish source - wont build the vmod
hints:
- for Varnish 4, set PKG_CONFIG_PATH to location of your varnishapi.pc
and re-run autogen
export PKG_CONFIG_PATH ...
./autogen.sh && ./configure ...
- for Varnish 3, set VARNISHSRC to your varnish sources
]])
fi
AM_CONDITIONAL([BUILD_VMOD], [false])
else
])
# common else-body for varnish 3 config with and without pkg-config/m4
# present
AM_CONDITIONAL([BUILD_VMOD], [true])
if test "x$enable_shared" != "xyes"; then
AC_MSG_FAILURE([--enable-shared is required for building the vmod])
fi
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.])])
VARNISHSRC=`cd $VARNISHSRC && pwd`
Varnish_Version_MAJOR=
AC_CHECK_FILE([$VARNISHSRC/include/libvarnish.h], [
AC_SUBST([VMOD_INCLUDES],
['-I$(VARNISHSRC)/include -I$(VARNISHSRC)/bin/varnishd -I$(VARNISHSRC)'])
],[
AC_MSG_FAILURE([Could not find "$VARNISHSRC/include/libvarnish.h" - are your sources in VARNISHSRC complete?])
])
# vmod installation dir
AC_ARG_VAR([VMOD_DIR], [vmod installation directory @<:@LIBDIR/varnish/vmods@:>@])
if test "x$VMOD_DIR" = x; then
VMOD_DIR=`pkg-config --variable=vmoddir varnishapi`
if test "x$VMOD_DIR" = x; then
AC_MSG_FAILURE([Could not determine vmod installation directory])
fi
AC_SUBST([VMOD_DIR])
fi
# varnish3
AC_CHECK_FILE([$VARNISHSRC/lib/libvmod_std/vmod.py], [
AC_SUBST([VMODTOOL], [$VARNISHSRC/lib/libvmod_std/vmod.py])
],[
AC_MSG_FAILURE([Could not find vmod.py in VARNISHSRC])
])
AC_SUBST([VCCFILE], [vmod_dcs3.vcc])
AC_DEFINE([VARNISH_MAJOR], [3], [Define the Varnish major version we compile against])
AC_SUBST([TESTDIR], [tests])
# Check that varnishtest is built in the varnish source directory
AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], [
AC_SUBST([VARNISHTEST], [$VARNISHSRC/bin/varnishtest/varnishtest])
],[
AC_MSG_FAILURE([Could not find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])
])
# same for varnishd
AC_CHECK_FILE([$VARNISHSRC/bin/varnishd/varnishd], [
AC_SUBST([VARNISHD], [$VARNISHSRC/bin/varnishd/varnishd])
],[
AC_MSG_FAILURE([Could not find "$VARNISHSRC/bin/varnishd/varnishd". Please build your varnish source directory])
])
# Check vanish ABI version
AC_CHECK_FILE([$VARNISHSRC/include/vmod_abi.h],
[
AC_MSG_CHECKING([varnish ABI version])
[VMOD_ABI_Version=`cut -d ' ' -f 4 "$VARNISHSRC/include/vmod_abi.h"`]
AC_MSG_RESULT([$VMOD_ABI_Version])
],
[
[VMOD_ABI_Version=3.0.0]
AC_MSG_NOTICE([Could not find "$VARNISHSRC/include/vmod_abi.h". Assuming varnish 3.0.0 ABI version])
]
)
fi
############################################################
## DCS specifics
......@@ -52,17 +232,22 @@ AC_ARG_VAR([DCS_ACCOUNT], [your netbiscuits account - optional, for online updat
AC_ARG_VAR([DCS_DBFILE], [path to your DCS database file])
if test "x$DCS_DBFILE" = "xdcs_demo.db"; then
DCS_DBFILE=../dcs_demo.db
AM_CONDITIONAL([DCS_DBFILE_ABS], [false])
else
AC_CHECK_FILE([$DCS_DBFILE],
[],
[
# sh-ish for bash [[ ${DCS_DBFILE} == /* ]]
AM_CONDITIONAL([DCS_DBFILE_ABS], [test "x${DCS_DBFILE%%/*}" = "x"])
],
[if test "x$DCS_ACCOUNT" = x; then
AC_MSG_ERROR([Need existing DCS_DBFILE or dcs_demo.db if no DCS_ACCOUNT given])
fi
DCS_DBFILE=dcs.db
AM_CONDITIONAL([DCS_DBFILE_ABS], [true])
])
fi
############################################################
## DEVELOPER flags etc
......@@ -102,75 +287,12 @@ AC_ARG_ENABLE(varnish2,
AS_HELP_STRING([--enable-varnish2],[install code for varnish2 inline-C (default is NO)]))
AM_CONDITIONAL([INSTALL_VARNISH2], [test "x$enable_varnish2" != x])
############################################################
## VARNISH sources for vmod support
# Varnish source tree
AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree for vmod])
AM_CONDITIONAL([BUILD_VMOD], [test "x$VARNISHSRC" != x])
if test "x$VARNISHSRC" = x; then
AC_MSG_WARN([No Varnish source - wont build the vmod])
else
if test "x$enable_shared" != "xyes"; then
AC_MSG_FAILURE([--enable-shared is required for building the vmod])
fi
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.])])
VARNISHSRC=`cd $VARNISHSRC && pwd`
Varnish_Version_MAJOR=
# varnish3
AC_CHECK_FILE([$VARNISHSRC/lib/libvmod_std/vmod.py], [
AC_SUBST([VMODTOOL], ['$(VARNISHSRC)/lib/libvmod_std/vmod.py'])
AC_SUBST([VCCFILE], [vmod_dcs3.vcc])
AC_DEFINE([VARNISH_MAJOR], [3], [Define the Varnish major version we compile against])
AC_SUBST([TESTDIR], [tests])
])
# varnish4
AC_CHECK_FILE([$VARNISHSRC/lib/libvcc/vmodtool.py], [
AC_SUBST([VMODTOOL], ['$(VARNISHSRC)/lib/libvcc/vmodtool.py'])
AC_SUBST([VCCFILE], [vmod_dcs4.vcc])
AC_DEFINE([VARNISH_MAJOR], [4], [Define the Varnish major version we compile against])
AC_SUBST([TESTDIR], [tests4])
])
# Check that varnishtest is built in the varnish source directory
AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest],
[],
[AC_MSG_FAILURE([Could not find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])]
)
# Check vanish ABI version
AC_CHECK_FILE([$VARNISHSRC/include/vmod_abi.h],
[
AC_MSG_CHECKING([varnish ABI version])
[VMOD_ABI_Version=`cut -d ' ' -f 4 "$VARNISHSRC/include/vmod_abi.h"`]
AC_MSG_RESULT([$VMOD_ABI_Version])
],
[
[VMOD_ABI_Version=3.0.0]
AC_MSG_NOTICE([Could not find "$VARNISHSRC/include/vmod_abi.h". Assuming varnish 3.0.0 ABI version])
]
)
# 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([Could not determine vmod installation directory])
fi
fi
fi
############################################################
## FIN
AC_CONFIG_FILES([
Makefile
check/Makefile
src/Makefile
src/gen/Makefile
])
......
......@@ -43,7 +43,8 @@ dcs_test_SOURCES = \
# -
EXTRA_DIST = \
classes.conf
classes.conf \
dcs_demo.db
# included c source
if INSTALL_VARNISH2
......@@ -67,7 +68,7 @@ nodist_data_DATA = \
gen/dcs_type.c
endif
## varnish 3 vmod
## varnish 3/4 vmod
if BUILD_VMOD
......@@ -75,12 +76,12 @@ if BUILD_VMOD
# libvmod_dcs.so will include an own copy of the code without the
# overhead of library calls - at the cost of some memory overhead
vmoddir = $(VMODDIR)
vmoddir = $(VMOD_DIR)
vmod_LTLIBRARIES = libvmod_dcs.la
libvmod_dcs_la_CPPFLAGS = -Igen -I$(VARNISHSRC)/include -I$(VARNISHSRC)/bin/varnishd -I$(VARNISHSRC)
libvmod_dcs_la_CPPFLAGS = -Igen @VMOD_INCLUDES@
libvmod_dcs_la_LDFLAGS = -module -export-dynamic -avoid-version
libvmod_dcs_la_LDFLAGS = -module -export-dynamic -avoid-version -shared
libvmod_dcs_la_SOURCES = \
vmod_dcs.c
......@@ -89,31 +90,26 @@ nodist_libvmod_dcs_la_SOURCES = \
vcc_if.c \
vcc_if.h
vcc_if_INCLUDES = -I$(VARNISHSRC)/include -I$(VARNISHSRC)
libvmod_dcs.lo: dcs_varnish.c vcc_if.c vcc_if.h
vcc_dcs_INCLUDES = -I$(VARNISHSRC)/include -I$(VARNISHSRC)
#libvmod_dcs_la-vmod_dcs.lo: dcs_varnish.c vcc_if.c vcc_if.h
vcc_if.c vcc_if.h: @VMODTOOL@ @VCCFILE@
@PYTHON@ @VMODTOOL@ @VCCFILE@
vcc_if_INCLUDES = @VMOD_INCLUDES@
BUILT_SOURCES = \
vcc_if.c \
vcc_if.h
CLEANFILES = \
vcc_if.c \
vcc_if.h
vmod_dcs.rst vmod_dcs.man.rst vcc_if.c: vcc_if.h
VMOD_TESTS = @TESTDIR@/*.vtc
vcc_if.h: @VMODTOOL@ $(srcdir)/@VCCFILE@
@PYTHON@ @VMODTOOL@ $(srcdir)/@VCCFILE@
.PHONY: $(VMOD_TESTS)
@TESTDIR@/*.vtc: libvmod_dcs.la
$(VARNISHSRC)/bin/varnishtest/varnishtest -Dvarnishd=$(VARNISHSRC)/bin/varnishd/varnishd -Dvmod_topbuild=$(abs_top_builddir) $@
BUILT_SOURCES = \
vcc_if.c \
vcc_if.h \
vmod_dcs.rst \
vmod_dcs.man.rst
check: $(VMOD_TESTS)
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST += \
vmod_dcs.vcc \
$(VMOD_TESTS)
endif
@VCCFILE@
endif # BUILD_VMOD
......@@ -28,7 +28,7 @@
*
*/
#include "dcs_config.h"
#include "config.h"
#include <stdio.h>
#include <ctype.h>
#include "dcs_match.h"
......
......@@ -28,7 +28,7 @@
*
*/
#include "dcs_config.h"
#include "config.h"
#ifdef DEBUG_K_MATCH
#include <stdlib.h>
......
......@@ -28,7 +28,7 @@
*
*/
#include "dcs_config.h"
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
......
......@@ -28,7 +28,7 @@
*
*/
#include "dcs_config.h"
#include "config.h"
#include "dcs_varnish.c"
......
......@@ -4,19 +4,33 @@ BUILT_SOURCES = \
dcs_classifier.c \
dcs_classifier.h \
dcs_type.c \
dcs_match_mem.h
dcs_match_mem.h \
dbfile
EXTRA_DIST = \
gen_dcs_classifier.pl \
gen_dcs_match_mem.c
if DCS_DBFILE_ABS
dbfile: @DCS_DBFILE@
- rm $@
ln -s $< $@
else
dbfile: $(abs_top_srcdir)/src/@DCS_DBFILE@
- rm $@
ln -s $< $@
endif
# -- the classifier
dcs_classifier.c dcs_classifier.h dcs_type.c: gen_dcs_classifier.pl $(DCS_DBFILE) ../classes.conf
# serialize build
dcs_classifier.checksum dcs_classifier.h dcs_type.c: dcs_classifier.c
dcs_classifier.c: $(srcdir)/gen_dcs_classifier.pl dbfile $(srcdir)/../classes.conf
if [[ -f fixup.remove ]] && [[ -f fixup.reorder ]] ; then \
./gen_dcs_classifier.pl $(DCS_DBFILE) $(DCS_KEY) ../classes.conf fixup.remove fixup.reorder ; \
$(srcdir)/gen_dcs_classifier.pl dbfile $(DCS_KEY) $(srcdir)/../classes.conf fixup.remove fixup.reorder ; \
else \
./gen_dcs_classifier.pl $(DCS_DBFILE) $(DCS_KEY) ../classes.conf ; \
$(srcdir)/gen_dcs_classifier.pl dbfile $(DCS_KEY) $(srcdir)/../classes.conf ; \
fi
# -- gen_dcs_match_mem
......@@ -31,7 +45,9 @@ dcs_match_mem.h: gen_dcs_match_mem
./gen_dcs_match_mem >dcs_match_mem.h
# -- fixup db
fixup.remove fixup.reorder fixup.out:
fixup.remove fixup.reorder: fixup.out
fixup.out:
- rm fixup.remove fixup.reorder fixup.out
- rm dcs_classifier.c dcs_classifier.h dcs_type.c
$(MAKE) $(AM_MAKEFLAGS) dcs_classifier.c dcs_classifier.h dcs_type.c
......@@ -94,5 +110,6 @@ CLEANFILES = \
fixup.reorder \
fixup.out \
dcs.db \
dcs.db.tstamp
dcs.db.tstamp \
dbfile \
dcs_classifier.checksum
......@@ -1393,7 +1393,7 @@ dcs_register_subkey_match(struct dcs_matchstate *state, dcs_subkey_id_t subkey_i
EOF
_VCL (F_TYPE_C, VCL_TOP, <<'EOF');
#include "dcs_config.h"
#include "config.h"
#include <errno.h>
......
......@@ -28,7 +28,7 @@
*
*/
#include "dcs_config.h"
#include "config.h"
#include <stdio.h>
......
......@@ -28,7 +28,7 @@
*
*/
#include "dcs_config.h"
#include "config.h"
#include "vrt.h"
#include "vcc_if.h"
......
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