Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

use pkg-config in configure to locate varnishd and varnishtest #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Makefile.in

/src/vcc_if.c
/src/vcc_if.h
/src/vmod_urlcode.man.rst
/src/vmod_urlcode.rst
/vmod_urlcode.3
/nbproject/private/

28 changes: 26 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,32 @@ VARNISH_VMOD_INCLUDES
VARNISH_VMOD_DIR
VARNISH_VMODTOOL

AC_PATH_PROG([VARNISHTEST], [varnishtest])
AC_PATH_PROG([VARNISHD], [varnishd])
# 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
])

PKG_CHECK_MODULES([libvarnishapi], [varnishapi])
PKG_CHECK_VAR([LIBVARNISHAPI_BINDIR], [varnishapi], [bindir])
PKG_CHECK_VAR([LIBVARNISHAPI_SBINDIR], [varnishapi], [sbindir])

AC_PATH_PROG([VARNISHTEST], [varnishtest], [],
[$LIBVARNISHAPI_BINDIR:$LIBVARNISHAPI_SBINDIR:$PATH])
AC_PATH_PROG([VARNISHD], [varnishd], [],
[$LIBVARNISHAPI_SBINDIR:$LIBVARNISHAPI_BINDIR:$PATH])

AC_CONFIG_FILES([
Makefile
Expand Down
23 changes: 13 additions & 10 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ vmod_LTLIBRARIES = libvmod_urlcode.la

libvmod_urlcode_la_LDFLAGS = -module -export-dynamic -avoid-version

libvmod_urlcode_la_SOURCES = \
libvmod_urlcode_la_SOURCES = vmod_urlcode.c

nodist_libvmod_urlcode_la_SOURCES = \
vcc_if.c \
vcc_if.h \
vmod_urlcode.c
vcc_if.h

vcc_if.c vcc_if.h: @VMODTOOL@ $(top_srcdir)/src/vmod_urlcode.vcc
@VMODTOOL@ $(top_srcdir)/src/vmod_urlcode.vcc
vmod_urlcode.c: vcc_if.h

VMOD_TESTS = tests/*.vtc
.PHONY: $(VMOD_TESTS)
vmod_selector.lo: $(nodist_libvmod_selector_la_SOURCES)

tests/*.vtc:
@VARNISHTEST@ -Dvarnishd=@VARNISHD@ -Dvmod_topbuild=$(abs_top_builddir) $@
vcc_if.h: vcc_if.c

vcc_if.c: vmod_urlcode.vcc
@VMODTOOL@ $(top_srcdir)/src/vmod_urlcode.vcc

check: $(VMOD_TESTS)
check:
PATH=@LIBVARNISHAPI_SBINDIR@:$$PATH \
@VARNISHTEST@ -Dvmod_topbuild=$(abs_top_builddir) $(srcdir)/tests/*.vtc

EXTRA_DIST = \
vmod_urlcode.vcc \
Expand Down
5 changes: 2 additions & 3 deletions src/vmod_urlcode.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <stdlib.h>

#include "vrt.h"
#include "cache/cache.h"

#include "vcc_if.h"
Expand All @@ -20,7 +19,7 @@ vmod_encode(const struct vrt_ctx *ctx, const char *str, ...)

CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
u = WS_Reserve(ctx->ws, 0);
u = WS_ReserveAll(ctx->ws);
e = b = ctx->ws->f;
e += u;
va_start(ap, str);
Expand Down Expand Up @@ -78,7 +77,7 @@ vmod_decode(const struct vrt_ctx *ctx, const char *str, ...)

CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC);
u = WS_Reserve(ctx->ws, 0);
u = WS_ReserveAll(ctx->ws);
e = b = ctx->ws->f;
e += u;
va_start(ap, str);
Expand Down