[master] b2d840cf1 Build VSC generated sources in lib/libvsc

Martin Blix Grydeland martin at varnish-software.com
Mon Oct 4 13:18:07 UTC 2021


commit b2d840cf1b2b93b13d49172d95b5058dad981747
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Thu Sep 16 15:09:24 2021 +0200

    Build VSC generated sources in lib/libvsc
    
    This is to resolve the chicken and egg problem of the VSC headers being
    generated only once bin/varnishd is built, while they are used in several
    VMODs and libraries.
    
    This moves the generation of the VSC .c and .h header files to a directory
    in lib that can be built earlier than its dependencies.
    
    Also Don't AC_SUBST the vsc files. The complete list of vsc files is known
    and listed in the .am file when automake is run, so there is no need to
    have configure.ac help with making lists.

diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index af04e2995..0e564a9bc 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -4,7 +4,8 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/lib/libvgz \
 	-I$(top_builddir)/bin/varnishd \
-	-I$(top_builddir)/include
+	-I$(top_builddir)/include \
+	-I$(top_builddir)/lib/libvsc
 
 sbin_PROGRAMS = varnishd
 
@@ -178,6 +179,7 @@ varnishd_LDFLAGS = -export-dynamic
 varnishd_LDADD = \
 	$(top_builddir)/lib/libvcc/libvcc.la \
 	$(top_builddir)/lib/libvarnish/libvarnish.la \
+	$(top_builddir)/lib/libvsc/libvsc.la \
 	$(top_builddir)/lib/libvgz/libvgz.la \
 	@JEMALLOC_LDADD@ \
 	${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${RT_LIBS} ${LIBM}
@@ -250,28 +252,3 @@ DISTCLEANFILES = builtin_vcl.c
 
 BUILT_SOURCES	=	vhp_hufdec.h
 DISTCLEANFILES	+=	vhp_hufdec.h
-
-#######################################################################
-
-.vsc.c:
-	$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $<
-
-VSC_SRC = \
-	VSC_lck.vsc \
-	VSC_main.vsc \
-	VSC_mempool.vsc \
-	VSC_mgt.vsc \
-	VSC_sma.vsc \
-	VSC_smf.vsc \
-	VSC_smu.vsc \
-	VSC_vbe.vsc
-
-VSC_GEN_C = @VSC_GEN_C@
-VSC_GEN_H = @VSC_GEN_H@
-
-$(VSC_GEN_C): $(top_srcdir)/lib/libvcc/vsctool.py
-
-BUILT_SOURCES			+= $(VSC_GEN_C)
-CLEANFILES			= $(VSC_GEN_C) $(VSC_GEN_H)
-
-varnishd_SOURCES		+= $(VSC_SRC)
diff --git a/configure.ac b/configure.ac
index ca1a49c29..e5df08ab3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -824,14 +824,6 @@ VMOD_TESTS="$(cd $srcdir/vmod && echo tests/*.vtc)"
 AC_SUBST(VMOD_TESTS)
 AM_SUBST_NOTMAKE(VMOD_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])
 
@@ -854,6 +846,7 @@ AC_CONFIG_FILES([
     etc/Makefile
     include/Makefile
     lib/Makefile
+    lib/libvsc/Makefile
     lib/libvarnish/Makefile
     lib/libvarnishapi/Makefile
     lib/libvcc/Makefile
diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am
index cb4e42881..45ec33345 100644
--- a/doc/sphinx/Makefile.am
+++ b/doc/sphinx/Makefile.am
@@ -86,22 +86,21 @@ include/params.rst: $(top_builddir)/bin/varnishd/varnishd
 BUILT_SOURCES += include/params.rst
 
 COUNTERS = \
-	$(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)
+	$(top_srcdir)/lib/libvsc/VSC_main.vsc \
+	$(top_srcdir)/lib/libvsc/VSC_mgt.vsc \
+	$(top_srcdir)/lib/libvsc/VSC_mempool.vsc \
+	$(top_srcdir)/lib/libvsc/VSC_sma.vsc \
+	$(top_srcdir)/lib/libvsc/VSC_smu.vsc \
+	$(top_srcdir)/lib/libvsc/VSC_smf.vsc \
+	$(top_srcdir)/lib/libvsc/VSC_vbe.vsc \
+	$(top_srcdir)/lib/libvsc/VSC_lck.vsc
+
+include/counters.rst: $(top_srcdir)/lib/libvsc/vsctool.py $(COUNTERS)
 	echo -n '' > ${@}_
 	for i in $(COUNTERS); do \
-		$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -r $$i >> ${@}_ ; \
+		$(PYTHON) $(top_srcdir)/lib/libvsc/vsctool.py -r $$i >> ${@}_ ; \
 	done
 	mv -f ${@}_ ${@}
-
 BUILT_SOURCES += include/counters.rst
 
 include/varnishncsa_options.rst: $(top_builddir)/bin/varnishncsa/varnishncsa
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 0f6873c50..951bdf36b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,6 +1,7 @@
 #
 
 SUBDIRS = \
+	libvsc \
 	libvarnish \
 	libvarnishapi \
 	libvcc \
diff --git a/lib/libvcc/Makefile.am b/lib/libvcc/Makefile.am
index dc6037f2b..8731890da 100644
--- a/lib/libvcc/Makefile.am
+++ b/lib/libvcc/Makefile.am
@@ -36,8 +36,7 @@ dist_noinst_SCRIPTS = \
 	generate.py
 
 dist_pkgdata_SCRIPTS = \
-	vmodtool.py \
-	vsctool.py
+	vmodtool.py
 
 ## keep in sync with include/Makefile.am
 vcc_obj.c: \
diff --git a/lib/libvsc/Makefile.am b/lib/libvsc/Makefile.am
new file mode 100644
index 000000000..842515148
--- /dev/null
+++ b/lib/libvsc/Makefile.am
@@ -0,0 +1,32 @@
+#
+
+AM_CPPFLAGS = \
+	-I$(top_srcdir)/include \
+	-I$(top_builddir)/include
+
+VSC_SRC = \
+	VSC_lck.vsc \
+	VSC_main.vsc \
+	VSC_mempool.vsc \
+	VSC_mgt.vsc \
+	VSC_sma.vsc \
+	VSC_smf.vsc \
+	VSC_smu.vsc \
+	VSC_vbe.vsc
+
+VSC_GEN_C	= $(VSC_SRC:.vsc=.c)
+VSC_GEN_H	= $(VSC_SRC:.vsc=.h)
+
+$(VSC_GEN_C): vsctool.py
+
+.vsc.c:
+	$(PYTHON) $(srcdir)/vsctool.py -ch $<
+
+noinst_LTLIBRARIES = libvsc.la
+libvsc_la_SOURCES = $(VSC_SRC)
+
+dist_pkgdata_SCRIPTS = \
+	vsctool.py
+
+BUILT_SOURCES	= $(VSC_GEN_C)
+CLEANFILES	= $(VSC_GEN_C) $(VSC_GEN_H)
diff --git a/bin/varnishd/VSC_lck.vsc b/lib/libvsc/VSC_lck.vsc
similarity index 100%
rename from bin/varnishd/VSC_lck.vsc
rename to lib/libvsc/VSC_lck.vsc
diff --git a/bin/varnishd/VSC_main.vsc b/lib/libvsc/VSC_main.vsc
similarity index 100%
rename from bin/varnishd/VSC_main.vsc
rename to lib/libvsc/VSC_main.vsc
diff --git a/bin/varnishd/VSC_mempool.vsc b/lib/libvsc/VSC_mempool.vsc
similarity index 100%
rename from bin/varnishd/VSC_mempool.vsc
rename to lib/libvsc/VSC_mempool.vsc
diff --git a/bin/varnishd/VSC_mgt.vsc b/lib/libvsc/VSC_mgt.vsc
similarity index 100%
rename from bin/varnishd/VSC_mgt.vsc
rename to lib/libvsc/VSC_mgt.vsc
diff --git a/bin/varnishd/VSC_sma.vsc b/lib/libvsc/VSC_sma.vsc
similarity index 100%
rename from bin/varnishd/VSC_sma.vsc
rename to lib/libvsc/VSC_sma.vsc
diff --git a/bin/varnishd/VSC_smf.vsc b/lib/libvsc/VSC_smf.vsc
similarity index 100%
rename from bin/varnishd/VSC_smf.vsc
rename to lib/libvsc/VSC_smf.vsc
diff --git a/bin/varnishd/VSC_smu.vsc b/lib/libvsc/VSC_smu.vsc
similarity index 100%
rename from bin/varnishd/VSC_smu.vsc
rename to lib/libvsc/VSC_smu.vsc
diff --git a/bin/varnishd/VSC_vbe.vsc b/lib/libvsc/VSC_vbe.vsc
similarity index 100%
rename from bin/varnishd/VSC_vbe.vsc
rename to lib/libvsc/VSC_vbe.vsc
diff --git a/lib/libvcc/vsctool.py b/lib/libvsc/vsctool.py
similarity index 99%
rename from lib/libvcc/vsctool.py
rename to lib/libvsc/vsctool.py
index 9df1dc40d..c9254b090 100755
--- a/lib/libvcc/vsctool.py
+++ b/lib/libvsc/vsctool.py
@@ -66,7 +66,7 @@ def genhdr(fo, name):
     fo.write(' * NB:  This file is machine generated, DO NOT EDIT!\n')
     fo.write(' *\n')
     fo.write(' * Edit ' + name +
-             '.vsc and run lib/libvcc/vsctool.py instead.\n')
+             '.vsc and run lib/libvsc/vsctool.py instead.\n')
     fo.write(' */\n')
     fo.write('\n')
 
diff --git a/vmod/Makefile.am b/vmod/Makefile.am
index 957e069c4..29ffcf6bd 100644
--- a/vmod/Makefile.am
+++ b/vmod/Makefile.am
@@ -34,10 +34,10 @@ include $(srcdir)/automake_boilerplate_vtc.am
 #
 
 .vsc.c:
-	$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -c $<
+	$(PYTHON) $(top_srcdir)/lib/libvsc/vsctool.py -c $<
 
 .vsc.h:
-	$(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -h $<
+	$(PYTHON) $(top_srcdir)/lib/libvsc/vsctool.py -h $<
 
 EXTRA_DIST += VSC_debug.vsc
 nodist_libvmod_debug_la_SOURCES += \


More information about the varnish-commit mailing list