From f365af1acaed41948572ff78df55300d87132e64 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 3 Jan 2024 12:19:19 -0500 Subject: Define version only in the Makefile. --- Makefile | 26 +++++++++++++++++++------- VERSION | 1 + hcalc.h | 6 +++--- hcalc.rst | 2 +- version.h | 1 + version.rst | 1 + 6 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 VERSION create mode 100644 version.h create mode 100644 version.rst diff --git a/Makefile b/Makefile index 5f57395..9c52c75 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ GZIP = gzip # End of user-ovverideable stuff. No user-serviceable parts below this line. PROJ = hcalc +VERSION = 1.2u1 MANPAGE = $(PROJ).1 DOCS = README CHANGES TODO COPYING OBJS = \ @@ -38,22 +39,33 @@ OBJS = \ all: $(PROJ) $(MANPAGE) -hcalc.o: hcalc.c hcalc.h +hcalc.o: hcalc.c hcalc.h version.h -input.o: input.c hcalc.h +input.o: input.c hcalc.h version.h -setupx.o: setupx.c hcalc.h +setupx.o: setupx.c hcalc.h version.h -draw.o: draw.c hcalc.h +draw.o: draw.c hcalc.h version.h -config.o: config.c hcalc.h +config.o: config.c hcalc.h version.h -images.o: images.c hcalc.h xpm/*.xpm +images.o: images.c hcalc.h xpm/*.xpm version.h + +VERSION: +ifneq ($(shell cat VERSION 2>/dev/null),$(VERSION)) + echo "$(VERSION)" > VERSION +endif + +version.rst: VERSION + echo ".. |version| replace:: $(VERSION)" > version.rst + +version.h: VERSION + echo '#define VERSION "$(VERSION)"' > version.h $(PROJ): $(OBJS) $(CC) -o $@ $^ $(LDFLAGS) -lXpm -lX11 $(LIBS) -$(MANPAGE): $(PROJ).rst +$(MANPAGE): $(PROJ).rst version.rst rst2man $(PROJ).rst > $(MANPAGE) clean: diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..ef5a3f9 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.2u1 diff --git a/hcalc.h b/hcalc.h index db70249..a469c9a 100644 --- a/hcalc.h +++ b/hcalc.h @@ -6,15 +6,15 @@ More revisions copyright 2023, B. Watson */ -#define SELF "HCalc" -#define VERSION "1.2u1" - #include #include #include #include #include +#define SELF "HCalc" +#include "version.h" + extern Display *display; extern int screen; extern Visual *visual; diff --git a/hcalc.rst b/hcalc.rst index ef7a715..0dd2235 100644 --- a/hcalc.rst +++ b/hcalc.rst @@ -1,7 +1,7 @@ .. RST source for hcalc(1) man page. Convert with: .. rst2man.py hcalc.rst > hcalc.1 -.. |version| replace:: 1.2u1 +.. include:: version.rst .. |date| date:: ===== diff --git a/version.h b/version.h new file mode 100644 index 0000000..1ab0b17 --- /dev/null +++ b/version.h @@ -0,0 +1 @@ +#define VERSION "1.2u1" diff --git a/version.rst b/version.rst new file mode 100644 index 0000000..1fba6c0 --- /dev/null +++ b/version.rst @@ -0,0 +1 @@ +.. |version| replace:: 1.2u1 -- cgit v1.2.3