From ef5ef17bab5581bc001da0e2a9ab77620a19ffb0 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sat, 30 Mar 2024 13:32:19 +0000 Subject: Pass VERSION at compile time based on "git describe". Add fallback VERSION file for if Git isn't installed. --- INSTALL | 1 + Makefile | 3 ++- VERSION | 1 + functions.h | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 VERSION diff --git a/INSTALL b/INSTALL index 84474c9..01234e4 100644 --- a/INSTALL +++ b/INSTALL @@ -9,6 +9,7 @@ To compile: - a C compiler - glibc - OpenSSL +- Git (optional - used to define VERSION if installed) To run: diff --git a/Makefile b/Makefile index c48a819..baa334c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ CC=gcc +GIT_VERSION := "$(shell git describe --abbrev=4 --dirty --always --tags || cat VERSION)" BINARY=blabouncer ifeq ($(PREFIX),) @@ -6,7 +7,7 @@ ifeq ($(PREFIX),) endif blabouncer: blabouncer.c functions.c sockets.c config.c replay.c logging.c message.c config.h functions.h logging.h message.h replay.h sockets.h structures.h - $(CC) -D_DEFAULT_SOURCE -D_BSD_SOURCE -std=gnu99 -Wall -Wextra -lssl -lcrypto -o $(BINARY) blabouncer.c functions.c sockets.c config.c replay.c logging.c message.c + $(CC) -D_DEFAULT_SOURCE -D_BSD_SOURCE -DVERSION=\"$(GIT_VERSION)\" -std=gnu99 -Wall -Wextra -lssl -lcrypto -o $(BINARY) blabouncer.c functions.c sockets.c config.c replay.c logging.c message.c .PHONY: clean clean: diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..60bce9f --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v0.2-git diff --git a/functions.h b/functions.h index 30ae4e4..6ec2c28 100644 --- a/functions.h +++ b/functions.h @@ -55,7 +55,7 @@ #define MAXTOKENS 100 // For strsep string splitting -#define VERSION "0.2-git" // Blabouncer version +//#define VERSION "" // VERSION is now passed via -DVERSION by the Makefile // Write debug string to file. // Debug level is provided by level, set to one of DEBUG_CRIT, DEBUG_SOME or DEBUG_FULL. -- cgit v1.2.3