From 040db59768d54e5957697a0e29306fe5ff220928 Mon Sep 17 00:00:00 2001 From: Will Date: Sun, 20 Mar 2016 17:03:36 +0900 Subject: [PATCH] generate version from git describe --- Makefile | 8 +++++++- src/wrk.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index da3492e..a4276d3 100644 --- a/Makefile +++ b/Makefile @@ -20,9 +20,10 @@ endif SRC := wrk.c net.c ssl.c aprintf.c stats.c script.c units.c \ ae.c zmalloc.c http_parser.c BIN := wrk +VER ?= $(shell git describe --tags --always --dirty) ODIR := obj -OBJ := $(patsubst %.c,$(ODIR)/%.o,$(SRC)) $(ODIR)/bytecode.o +OBJ := $(patsubst %.c,$(ODIR)/%.o,$(SRC)) $(ODIR)/bytecode.o $(ODIR)/version.o LIBS := -lluajit-5.1 $(LIBS) DEPS := @@ -61,6 +62,9 @@ $(ODIR)/bytecode.o: src/wrk.lua @echo LUAJIT $< @$(SHELL) -c 'PATH=obj/bin:$(PATH) luajit -b $(CURDIR)/$< $(CURDIR)/$@' +$(ODIR)/version.o: + @echo 'const char *VERSION="$(VER)";' | $(CC) -xc -c -o $@ - + $(ODIR)/%.o : %.c @echo CC $< @$(CC) $(CFLAGS) -c -o $@ $< @@ -94,6 +98,8 @@ endif # ------------ .PHONY: all clean +.PHONY: $(ODIR)/version.o + .SUFFIXES: .SUFFIXES: .c .o .lua diff --git a/src/wrk.h b/src/wrk.h index 2c7951c..3fe77f1 100644 --- a/src/wrk.h +++ b/src/wrk.h @@ -16,13 +16,14 @@ #include "ae.h" #include "http_parser.h" -#define VERSION "4.0.0" #define RECVBUF 8192 #define MAX_THREAD_RATE_S 10000000 #define SOCKET_TIMEOUT_MS 2000 #define RECORD_INTERVAL_MS 100 +extern const char *VERSION; + typedef struct { pthread_t thread; aeEventLoop *loop;