aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile10
1 files changed, 9 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index fb247c1..a86e04f 100644
--- a/Makefile
+++ b/Makefile
@@ -16,13 +16,21 @@
.PHONY: default debug install defconfig rmconfig clean uninstall
+GIT_HASH := $(shell git rev-parse --short HEAD)
+GIT_DATE := $(shell git log -1 --format='%ad' --date='format:%y.%m.%d')
+GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
+GIT_REMOTE := $(shell git remote get-url origin)
+GIT_TAG := $(shell git describe --tags --exact-match HEAD 2>/dev/null)
+VERSION := $(if $(GIT_TAG),$(GIT_TAG),$(GIT_DATE)_$(GIT_BRANCH) ($(GIT_HASH)))
+
CC ?= cc
RM = rm -f
PREFIX ?= /usr/local
OBJDIR = obj
SRCS = $(wildcard src/*.c)
OBJS = $(SRCS:src/%.c=$(OBJDIR)/%.o)
-CFLAGS += $(shell pkg-config --cflags luajit) -I./include -Wno-format-truncation -std=c99
+CFLAGS += $(shell pkg-config --cflags luajit) -I./include
+CFLAGS += -Wno-format-truncation -std=c99 -DVERSION='"$(VERSION)"'
# pretty print for compilation. To enable verbose (show commands), run with
# `make V=1`