summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2024-03-30 13:32:19 +0000
committerLuke Bratch <luke@bratch.co.uk>2024-03-30 13:32:19 +0000
commitef5ef17bab5581bc001da0e2a9ab77620a19ffb0 (patch)
tree88d2ca2ed43774391f618f49c78fd978e40e08cd
parent8450fa9418e3d0003a6990a5384437bde4ea76c0 (diff)
Pass VERSION at compile time based on "git describe". Add fallback VERSION file for if Git isn't installed.
-rw-r--r--INSTALL1
-rw-r--r--Makefile3
-rw-r--r--VERSION1
-rw-r--r--functions.h2
4 files changed, 5 insertions, 2 deletions
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.