commit 69f77f767e52e21b1a40182d03180da73f2f9021 Quentin Rameau <quinq@fifth.space> 2021-10-10 23:04:06 +0200 Add an ident version string to the binary This lets users get the current binary version using what(1) in an automated way.
Makefile | 2 +- config.mk | 5 +++++ sacc.c | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile index fc55c4b..f988ebd 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ uninstall: # Stock FLAGS SACCCFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -D_GNU_SOURCE \ - $(IOCFLAGS) $(CFLAGS) + -DVERSION=\"$(GETVER)\" $(IOCFLAGS) $(CFLAGS) .c.o: $(CC) $(SACCCFLAGS) -c $< diff --git a/config.mk b/config.mk index 62c1067..5882db8 100644 --- a/config.mk +++ b/config.mk @@ -2,6 +2,11 @@ PREFIX = /usr/local MANDIR = $(PREFIX)/share/man/man1 +# Version to put in the ident string +VERSION = "1.03" +GETVER = $$(git rev-parse --is-inside-work-tree >/dev/null 2>&1 && \ + git describe --tags || echo $(VERSION)) + # UI type # txt (textual) #UI=txt diff --git a/sacc.c b/sacc.c index 7a25fae..31b123e 100644 --- a/sacc.c +++ b/sacc.c @@ -22,6 +22,8 @@ #include "io.h" #include "config.h" +const char ident[] = "@(#) sacc(omys): " VERSION; + static char *mainurl; static Item *mainentry; static int devnullfd;