From 0c4e6b351ebcfd5aa4ce1d459dc9a1a069f7c53a Mon Sep 17 00:00:00 2001 From: Anthony Wharton Date: Thu, 21 Feb 2019 15:48:11 +0000 Subject: [PATCH] Add check for linux-header in kernel Makefile --- kernel/Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kernel/Makefile b/kernel/Makefile index 3998ecc..c899ae3 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,5 +1,14 @@ MODULE_NAME = nb +BUILD_DIR = /lib/modules/$(shell uname -r)/build +HEADERS_EXIST = $(shell if [ -d "${BUILD_DIR}" ]; then echo "${BUILD_DIR}"; \ + else echo ""; fi) + +ifneq (${HEADERS_EXIST}, ${BUILD_DIR}) + $(warning "Check you have linux headers installed") + $(error "${BUILD_DIR} does not exist!") +endif + SRC := nb_km.c ../common/nanoBench.c $(MODULE_NAME)-objs += $(SRC:.c=.o) @@ -17,4 +26,4 @@ all: clean: rm -f ../common/*.o ../common/*.ur-safe make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean - +