Skip to content

Commit

Permalink
make: Detect kernel version in Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayknarayan committed Feb 5, 2019
1 parent ae1ef38 commit 96cf781
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ else
DEBFLAGS = -Ofast
endif

KERNEL_VERSION_MAJOR := $(shell uname -r | awk -F '.' '{print $$1}')
KERNEL_VERSION_MINOR := $(shell uname -r | awk -F '.' '{print $$2}')
EXTRA_CFLAGS += -D__KERNEL_VERSION_MINOR__=$(KERNEL_VERSION_MINOR)
EXTRA_CFLAGS += -D__IPC__=$(IPC)

ifeq ($(ONE_PIPE),y)
Expand All @@ -19,13 +22,15 @@ endif
EXTRA_CFLAGS += $(DEBFLAGS)
EXTRA_CFLAGS += -std=gnu99 -Wno-declaration-after-statement -fgnu89-inline -D__KERNEL__


TARGET = ccp
ccp-objs := libccp/serialize.o libccp/ccp_priv.o libccp/machine.o libccp/ccp.o ccpkp/ccpkp.o ccpkp/lfq/lfq.o tcp_ccp.o ccp_nl.o

obj-m := $(TARGET).o

all:
ifneq ($(KERNEL_VERSION_MAJOR),4)
$(error "Only kernel version 4 is supported: $(KERNEL_VERSION_MAJOR) $(KERNEL_VERSION_MINOR)")
endif
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(CURDIR) modules

clean:
Expand Down

0 comments on commit 96cf781

Please sign in to comment.