Commit 042a98bc authored by Nils Goroll's avatar Nils Goroll

Simplify make rules for vsc files and remove duplication

We use an implicit rule to tell make how to turn vsc into c and
manually define the vsc files in Makefile.am. The implicit rule tells
automake to add .vsc to SUFFIXES, which in turn allows us to add the
actual vscs to varnishd_SOURCES.

To avoid triple configuration of the list of built VSC .c and .h
files, we generate these in configure. AC_SUBSTing files into _SOURCES
is forbidden by autoconf for a good reason: Adding sources to the
build should remain an explicit process to avoid accidentally
compiling in code just because someone had files with a magic name
lying around.

As the implicit .vsc -> .c rule does not allow for additional
dependencies, we add in the dependency to vsctool using the
auto-generated list of c files.

BUILT_SOURCES is used to ensure that, for default make targets,
headers generated from vscs are always present before the actual
varnishd sources are being build, of which some depend on vsc
headers. For subsequent builds, include dependency tracking takes
over.

The Makefile rules are deliberately simple to hopefully cover all make
flavours available on the planet. Notice that, for example, if we
limited ourselves to gmake, we could use much simpler substitution
rules to generate VSC_GEN_C and _H instead of the de-tour via
configure.

Portability is also the reason for renaming all vsc files.
parent f6b9c11a
......@@ -218,112 +218,25 @@ DISTCLEANFILES += vhp_hufdec.h
#######################################################################
VSC_main.c: VSC_main.h
.vsc.c:
$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $<
VSC_main.h: $(srcdir)/main.vsc $(top_srcdir)/lib/libvcc/vsctool.py
$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/main.vsc
VSC_SRC = \
VSC_main.vsc \
VSC_lck.vsc \
VSC_vbe.vsc \
VSC_sma.vsc \
VSC_smu.vsc \
VSC_smf.vsc \
VSC_mempool.vsc \
VSC_mgt.vsc
$(varnishd_OBJECTS): VSC_main.c VSC_main.h
VSC_GEN_C = @VSC_GEN_C@
VSC_GEN_H = @VSC_GEN_H@
EXTRA_DIST += main.vsc
DISTCLEANFILES += VSC_main.c VSC_main.h
BUILT_SOURCES += VSC_main.c VSC_main.h
nodist_varnishd_SOURCES += VSC_main.c
$(VSC_GEN_C): $(top_srcdir)/lib/libvcc/vsctool.py
#######################################################################
VSC_lck.c: VSC_lck.h
VSC_lck.h: $(srcdir)/lck.vsc $(top_srcdir)/lib/libvcc/vsctool.py
$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/lck.vsc
$(varnishd_OBJECTS): VSC_lck.c VSC_lck.h
EXTRA_DIST += lck.vsc
DISTCLEANFILES += VSC_lck.c VSC_lck.h
BUILT_SOURCES += VSC_lck.c VSC_lck.h
nodist_varnishd_SOURCES += VSC_lck.c
#######################################################################
VSC_vbe.c: VSC_vbe.h
VSC_vbe.h: $(srcdir)/vbe.vsc $(top_srcdir)/lib/libvcc/vsctool.py
$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/vbe.vsc
$(varnishd_OBJECTS): VSC_vbe.c VSC_vbe.h
EXTRA_DIST += vbe.vsc
DISTCLEANFILES += VSC_vbe.c VSC_vbe.h
BUILT_SOURCES += VSC_vbe.c VSC_vbe.h
nodist_varnishd_SOURCES += VSC_vbe.c
#######################################################################
VSC_sma.c: VSC_sma.h
VSC_sma.h: $(srcdir)/sma.vsc $(top_srcdir)/lib/libvcc/vsctool.py
$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/sma.vsc
$(varnishd_OBJECTS): VSC_sma.c VSC_sma.h
EXTRA_DIST += sma.vsc
DISTCLEANFILES += VSC_sma.c VSC_sma.h
BUILT_SOURCES += VSC_sma.c VSC_sma.h
nodist_varnishd_SOURCES += VSC_sma.c
#######################################################################
VSC_smu.c: VSC_smu.h
VSC_smu.h: $(srcdir)/smu.vsc $(top_srcdir)/lib/libvcc/vsctool.py
$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/smu.vsc
$(varnishd_OBJECTS): VSC_smu.c VSC_smu.h
EXTRA_DIST += smu.vsc
DISTCLEANFILES += VSC_smu.c VSC_smu.h
BUILT_SOURCES += VSC_smu.c VSC_smu.h
nodist_varnishd_SOURCES += VSC_smu.c
#######################################################################
VSC_smf.c: VSC_smf.h
VSC_smf.h: $(srcdir)/smf.vsc $(top_srcdir)/lib/libvcc/vsctool.py
$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/smf.vsc
$(varnishd_OBJECTS): VSC_smf.c VSC_smf.h
EXTRA_DIST += smf.vsc
DISTCLEANFILES += VSC_smf.c VSC_smf.h
BUILT_SOURCES += VSC_smf.c VSC_smf.h
nodist_varnishd_SOURCES += VSC_smf.c
#######################################################################
VSC_mempool.c: VSC_mempool.h
VSC_mempool.h: $(srcdir)/mempool.vsc $(top_srcdir)/lib/libvcc/vsctool.py
$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/mempool.vsc
$(varnishd_OBJECTS): VSC_mempool.c VSC_mempool.h
EXTRA_DIST += mempool.vsc
DISTCLEANFILES += VSC_mempool.c VSC_mempool.h
BUILT_SOURCES += VSC_mempool.c VSC_mempool.h
nodist_varnishd_SOURCES += VSC_mempool.c
#######################################################################
VSC_mgt.c: VSC_mgt.h
VSC_mgt.h: $(srcdir)/mgt.vsc $(top_srcdir)/lib/libvcc/vsctool.py
$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $(srcdir)/mgt.vsc
$(varnishd_OBJECTS): VSC_mgt.c VSC_mgt.h
BUILT_SOURCES += $(VSC_GEN_C)
CLEANFILES = $(VSC_GEN_C) $(VSC_GEN_H)
EXTRA_DIST += mgt.vsc
DISTCLEANFILES += VSC_mgt.c VSC_mgt.h
BUILT_SOURCES += VSC_mgt.c VSC_mgt.h
nodist_varnishd_SOURCES += VSC_mgt.c
varnishd_SOURCES += $(VSC_SRC)
......@@ -688,6 +688,14 @@ AC_DEFINE_UNQUOTED([VCC_CC],"$VCC_CC",[C compiler command line for VCL code])
VTC_TESTS="$(cd $srcdir/bin/varnishtest && echo tests/*.vtc)"
AC_SUBST(VTC_TESTS)
VSC_SRC="$(cd $srcdir/bin/varnishd && echo *.vsc)"
VSC_GEN_C="$(echo $VSC_SRC | sed 's:\.vsc:.c:g')"
VSC_GEN_H="$(echo $VSC_SRC | sed 's:\.vsc:.h:g')"
# automake does not allow to AC_SUBST _SOURCES files (for a good
# reason), so we automate the cleanup at least
AC_SUBST(VSC_GEN_C)
AC_SUBST(VSC_GEN_H)
# Make sure this include dir exists
AC_CONFIG_COMMANDS([mkdir], [$MKDIR_P doc/sphinx/include])
......
......@@ -124,14 +124,14 @@ include/params.rst: $(top_builddir)/bin/varnishd/varnishd
BUILT_SOURCES += include/params.rst
COUNTERS = \
$(top_srcdir)/bin/varnishd/main.vsc \
$(top_srcdir)/bin/varnishd/mgt.vsc \
$(top_srcdir)/bin/varnishd/mempool.vsc \
$(top_srcdir)/bin/varnishd/sma.vsc \
$(top_srcdir)/bin/varnishd/smu.vsc \
$(top_srcdir)/bin/varnishd/smf.vsc \
$(top_srcdir)/bin/varnishd/vbe.vsc \
$(top_srcdir)/bin/varnishd/lck.vsc
$(top_srcdir)/bin/varnishd/VSC_main.vsc \
$(top_srcdir)/bin/varnishd/VSC_mgt.vsc \
$(top_srcdir)/bin/varnishd/VSC_mempool.vsc \
$(top_srcdir)/bin/varnishd/VSC_sma.vsc \
$(top_srcdir)/bin/varnishd/VSC_smu.vsc \
$(top_srcdir)/bin/varnishd/VSC_smf.vsc \
$(top_srcdir)/bin/varnishd/VSC_vbe.vsc \
$(top_srcdir)/bin/varnishd/VSC_lck.vsc
include/counters.rst: $(top_srcdir)/lib/libvcc/vsctool.py $(COUNTERS)
echo -n '' > $@
......
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