~martijnbraam/public-inbox

among-sus: Print version of among-sus on client connection v2 PROPOSED

Ultracoolguy
Ultracoolguy: 1
 Print version of among-sus on client connection

 2 files changed, 12 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~martijnbraam/public-inbox/patches/15046/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH among-sus v2] Print version of among-sus on client connection Export this patch

Ultracoolguy
---
Use ifneq instead.

 Makefile | 6 ++++++
 main.c   | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/Makefile b/Makefile
index ae01955..736377a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,10 @@
.POSIX:
GIT_VERSION:=$(shell git rev-parse --short HEAD 2> /dev/null || false)

ifneq ($(strip $(GIT_VERSION)),)
	CFLAGS+=-DVERSION=\"$(GIT_VERSION)\"
endif

all:
	$(CC) -o among-sus $(CFLAGS) main.c $(LDFLAGS)

diff --git a/main.c b/main.c
index 8f7ed26..33f8e35 100644
--- a/main.c
+++ b/main.c
@@ -17,6 +17,9 @@
#include <unistd.h>
#include <getopt.h>

#ifndef VERSION
#define VERSION "uknown"
#endif
#define NUM_PLAYERS 10
#define NUM_SHORT 6
#define NUM_LONG 2
@@ -1371,6 +1374,9 @@ welcome_player(int fd)
			continue;
		}

		snprintf(buf, sizeof(buf), "among-sus server: version %s\n", VERSION);
		write(fd, buf, strlen(buf));

		if(state.stage != STAGE_LOBBY) {
			snprintf(buf, sizeof(buf), "There is a game in progress, waiting for the match to finish...\n");
			write(fd, buf, strlen(buf));
--
2.29.2
This doesn't work with BSD make:

bmake: "/home/ecs/src/among-sus/Makefile" line 4: Missing dependency operator
bmake: "/home/ecs/src/among-sus/Makefile" line 6: Need an operator
bmake: Fatal errors encountered -- cannot continue
bmake: stopped in /home/ecs/src/among-sus

I think it's cause ifneq isn't supported, can you replace that bit with
something like:

$(CC) -o among-sus $(CFLAGS) $$(git rev-parse --short HEAD &>/dev/null && printf -- "-DVERSION=%s" "$$(git rev-parse --short HEAD) main.c $$(LDFLAGS)