From: gustavo panizzo <gfa@zumbi.com.ar>
Date: Tue, 31 Jul 2018 10:28:52 +0800
Subject: debian-ways

---
 Makefile | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index f6d69d3..021d836 100644
--- a/Makefile
+++ b/Makefile
@@ -14,11 +14,14 @@ RM		:= rm -rf
 CC ?= gcc
 CFLAGS ?= -g -O0
 CFLAGS += -Wall -Wextra -std=c99 -pedantic
-GIT_VERSION := $(shell git describe --abbrev=8 --dirty --always --tags)
-ifeq ($(GIT_VERSION),)
-    GIT_VERSION := $(shell cat VERSION)
-endif
-CFLAGS += -DPROGRAM_VERSION=\"$(GIT_VERSION)\"
+
+# # Gets the full version of the source package including debian version
+DEB_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
+DEB_NOEPOCH_VERSION := $(shell echo $(DEB_VERSION) | cut -d: -f2-)
+# # Gets only the upstream version of the package
+DEB_UPSTREAM_VERSION := $(shell echo $(DEB_NOEPOCH_VERSION) | sed 's/-[^-]*$$//')
+
+CFLAGS += -DPROGRAM_VERSION=\"$(DEB_UPSTREAM_VERSION)\"
 
 ifeq ($(UNAME_S),Linux)
 	LDFLAGS += -Wl,-z,relro -lusb-1.0
