[Swan-dev] proposed patch to re-create version.c every time

Antony Antony antony at phenome.org
Wed Jul 31 12:55:12 UTC 2019

tangential to "make showversion" discussion, there is an issue that annoys 
me. Now I have a fix for it! If there is no violent opposition against this 
proposed patch I would like to apply the attached patch.

version.c dependency is broken while developing and testing continuously from 
one directory. Current dependency works great if you always build from a 
clean git tree or run 'make clean' first or build from a tar ball. However, 
less ideal for continuous development and testing.

Here is the case where it breaks.
You run "make base install-base" starting with a clean git tree.
Now make changes to the code and commit those changes.
then "make base install-base". Now the  version.c would be stale.
ie. pluto --version would not change even though the code changed, and 
commit id, or "make showversion" changed.

./OBJ.linux.x86_64/programs/pluto/pluto --version
Libreswan v3.28-526-g5c9063def5-master-s2 XFRM(netkey) esp-hw-offload FORK 

With this proposed patch version.c will be always (re)created.
"make base' or make programs will have the correct version string.
It would help me a lot. Are there any side effects if version.c is 
(re)created every time?

Currently I use a work around, "make clean". it has two disadvantages.
It would add another 30 - 180 sec delay for when you make a change 
re-compile.  Often I forget that and have back track double check.

Let me know what you think. If there are no major objections to this patch I 
will apply it, if no comment in week I will apply it:) 
See the attached patch.

-------------- next part --------------
>From 5c9063def5e299bbfd3a72a58e8307569b1fbcac Mon Sep 17 00:00:00 2001
From: Antony Antony <antony at phenome.org>
Date: Tue, 30 Jul 2019 12:15:15 +0000
Subject: [PATCH] libswan: re-create version.c every time run a make

this would help to keep the pluto --version upto date while developing
if change something and commit it and rebuild pluto version wouldn't
change. Now it will.

diff --git a/lib/libswan/Makefile b/lib/libswan/Makefile
index 6c054deccd..07c8b4ebc4 100644
--- a/lib/libswan/Makefile
+++ b/lib/libswan/Makefile
@@ -211,8 +211,13 @@ CFLAGS+=${CROSSFLAGS}
 OBJS += $(abs_builddir)/version.o
+# re-create version.c every time would keep pluto --version uptodate
+.PHONY: rm-version.c
+	rm -f $(abs_builddir)/version.c
 # build version.c using version number from Makefile.ver
-$(abs_builddir)/version.c: $(srcdir)/version.in.c $(top_srcdir)/Makefile.ver
+$(abs_builddir)/version.c: $(srcdir)/version.in.c $(top_srcdir)/Makefile.ver rm-version.c
 	rm -f $@.tmp
 	sed -e '/"/s/@IPSECVERSION@/$(IPSECVERSION)/' \

More information about the Swan-dev mailing list