-
Notifications
You must be signed in to change notification settings - Fork 2
/
ndr.kmod.mk
51 lines (41 loc) · 1.37 KB
/
ndr.kmod.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
KMOD ?= $(NAME)
SRCDIR := $(NBE_ROOT)/$S
KVER ?= $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
EXTRA_CFLAGS += -I$(NBE_MK_INCPATH)
obj-m := $(KMOD).o
FILES_ORG := $(SRCS)
FILES_ORG += $(ASMS)
FILES :=
ifneq ($(origin KEXTS), undefined)
KEXT_DIRS += $(foreach KEXT_ITER, $(KEXTS), $(NBE_MK_KEXTPATH)/$(KEXT_ITER)/)
KEXT_FILES += $(foreach KEXT_ITER, $(KEXT_DIRS), $(shell ls $(KEXT_ITER)))
FILES += $(KEXT_FILES)
endif
FILES += $(FILES_ORG)
FILES := $(FILES:.c=.o)
FILES := $(FILES:.cc=.o)
FILES := $(FILES:.s=.o)
FILES := $(FILES:.asm=.o)
$(KMOD)-objs := $(FILES)
.PHONY: build
build: $(KEXTS) mkkmod cpkmod
.PHONY: depset
depset: mkdir $(HDRS)
mkdir::
#Output directories pre-init
@[ -d $(NBE_MK_INCPATH) ] || mkdir -p $(NBE_MK_INCPATH)
@[ -d $(NBE_MK_KBUILDPATH) ] || mkdir -p $(NBE_MK_KBUILDPATH)
@[ -d $(NBE_KMODPATH) ] || mkdir -p $(NBE_KMODPATH)
$(HDRS)::
@cp -f $(SRCDIR)/$@ $(NBE_MK_INCPATH)
$(KEXTS)::
@[ -d $(NBE_MK_KBUILDPATH)/$(KMOD) ] || mkdir -p $(NBE_MK_KBUILDPATH)/$(KMOD)
@cp -f $(NBE_MK_KEXTPATH)/$@/* $(NBE_MK_KBUILDPATH)/$(KMOD)
mkkmod::
@[ -d $(NBE_MK_KBUILDPATH)/$(KMOD) ] || mkdir -p $(NBE_MK_KBUILDPATH)/$(KMOD)
@cp -rf $(SRCDIR)/* $(NBE_MK_KBUILDPATH)/$(KMOD)
$(MAKE) -C $(KDIR) M=$(NBE_MK_KBUILDPATH)/$(KMOD) modules
@ln -s $(NBE_MK_KBUILDPATH)/$(KMOD) kbuilt-$(KMOD)
cpkmod::
@cp -f $(NBE_MK_KBUILDPATH)/$(KMOD)/$(KMOD).ko $(NBE_KMODPATH)