-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathMakefile
69 lines (47 loc) · 1.51 KB
/
Makefile
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
MODULE_NAME := tpe
EXTRA_CFLAGS += -I$(src)
ifeq ($(KERNELRELEASE),)
# 'Out-of-kernel' part
MODULE_SOURCES := \
fopskit.c \
tpe_core.c \
tpe_module.c \
tpe_config.c
TESTS := tests/mmap-mprotect-test tests/setuid-test tests/setfattr-multi-test
KBUILD_DIR := $(shell sh ./scripts/find_kernel_src.sh)
UNAME := $(shell uname -r)
PWD := $(shell pwd)
all: $(MODULE_NAME).ko
$(MODULE_NAME).ko: $(MODULE_SOURCES)
$(MAKE) -C $(KBUILD_DIR) M=$(PWD) modules
test: $(MODULE_NAME).ko $(TESTS)
sudo bash ./scripts/run_tests.sh $(MODULE_NAME)
install_files: $(MODULE_NAME).ko
mkdir -p $(DESTDIR)/lib/modules/$(UNAME)/extra/tpe
mkdir -p $(DESTDIR)/etc/modprobe.d
mkdir -p $(DESTDIR)/etc/sysctl.d
install -m 644 conf/tpe.modprobe.conf $(DESTDIR)/etc/modprobe.d/tpe.conf
install -m 644 conf/tpe.sysctl $(DESTDIR)/etc/sysctl.d/tpe.conf
[ -d $(DESTDIR)/etc/sysconfig/modules ] && install -m 755 conf/tpe.sysconfig $(DESTDIR)/etc/sysconfig/modules/tpe.modules || :
install -m 755 $(MODULE_NAME).ko $(DESTDIR)/lib/modules/$(UNAME)/extra/tpe/
/sbin/depmod
install: install_files
rmmod $(MODULE_NAME) || :
modprobe $(MODULE_NAME)
tarball:
sh ./scripts/make_tarball.sh
clean:
$(MAKE) -C $(KBUILD_DIR) M=$(PWD) clean
rm -f Module* $(TESTS) tests.out
.PHONY: all clean install install_files test tarball
else
# KBuild part.
# It is used by the kernel build system to actually build the module.
ccflags-y := -I$(src)
obj-m := $(MODULE_NAME).o
$(MODULE_NAME)-y := \
fopskit.o \
tpe_core.o \
tpe_module.o \
tpe_config.o
endif