Skip to content

Commit 3795131

Browse files
committed
Parameterize KDIR
Let users point the sample Makefile at an arbitrary kernel build tree without editing paths, while retaining the default behavior that uses the running kernel headers.
1 parent 8727425 commit 3795131

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

examples/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ obj-m += static_key.o
3434
obj-m += led.o
3535
obj-m += dht11.o
3636

37+
KDIR ?= /lib/modules/$(shell uname -r)/build
3738
PWD := $(CURDIR)
3839

3940
ifeq ($(CONFIG_STATUS_CHECK_GCC),y)
@@ -42,10 +43,10 @@ ccflags-y += -fanalyzer
4243
endif
4344

4445
all:
45-
$(MAKE) -C /lib/modules/$(shell uname -r)/build CC=$(CC) M=$(PWD) modules
46+
$(MAKE) -C $(KDIR) CC=$(CC) M=$(PWD) modules
4647

4748
clean:
48-
$(MAKE) -C /lib/modules/$(shell uname -r)/build CC=$(CC) M=$(PWD) clean
49+
$(MAKE) -C $(KDIR) CC=$(CC) M=$(PWD) clean
4950
$(RM) other/cat_noblock *.plist
5051

5152
indent:

0 commit comments

Comments
 (0)