From 926d9d3963d11dd1a4e393f65ffa5d7d9473c996 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 1 Mar 2016 09:09:41 -0500 Subject: [PATCH] MT#17699 augment module makefile version detection Depending on the build environment, $M might refer to a subdirectory of the main source tree (i.e. debian directory is in $M/../debian) or the main directory of the source tree (debian is at $M/debian). Use a shell test to detect the correct file. Also take git revision into account as additional info, same as the daemon build system does. Change-Id: Ib82ff2f9b1a1b0c94697fd91d5b9e9c9bb8e61f2 --- kernel-module/Makefile | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/kernel-module/Makefile b/kernel-module/Makefile index 1c4ccc365..6900cd607 100644 --- a/kernel-module/Makefile +++ b/kernel-module/Makefile @@ -2,16 +2,27 @@ PWD := $(shell pwd) KSRC ?= /lib/modules/$(shell uname -r)/build KBUILD := $(KSRC) -ifneq ($(RTPENGINE_VERSION),) - EXTRA_CFLAGS += -DRTPENGINE_VERSION="\"$(RTPENGINE_VERSION)\"" -else +ifeq ($(RTPENGINE_VERSION),) DPKG_PRSCHNGLG= $(shell which dpkg-parsechangelog 2>/dev/null) + DEB_CHANGELOG=$(shell test -f $(M)/../debian/changelog && echo $(M)/../debian/changelog || echo $(M)/debian/changelog) ifneq ($(DPKG_PRSCHNGLG),) - EXTRA_CFLAGS += -DRTPENGINE_VERSION="\"$(shell dpkg-parsechangelog -l$(M)/debian/changelog | awk '/^Version: / {print $$2}')\"" - else - EXTRA_CFLAGS += -DRTPENGINE_VERSION="\"undefined\"" + DPKG_PRSCHNGLG=$(shell dpkg-parsechangelog -l$(DEB_CHANGELOG) | awk '/^Version: / {print $$2}') + endif + GIT_BR_COMMIT=$(shell git branch --no-color --no-column -v 2> /dev/null | awk '/^\*/ {OFS="-"; print "git", $$2, $$3}') + + ifneq ($(DPKG_PRSCHNGLG),) + RTPENGINE_VERSION+=$(DPKG_PRSCHNGLG) + endif + ifneq ($(GIT_BR_COMMIT),) + RTPENGINE_VERSION+=$(GIT_BR_COMMIT) + endif + + ifeq ($(RTPENGINE_VERSION),) + RTPENGINE_VERSION+=undefined endif endif +EXTRA_CFLAGS+= -DRTPENGINE_VERSION="\"$(RTPENGINE_VERSION)\"" + EXTRA_CFLAGS += -D__RE_EXTERNAL obj-m += xt_RTPENGINE.o