forked from free5gc/gtp5g
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (48 loc) · 1.31 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
RHEL8 := $(shell cat /etc/redhat-release 2>/dev/null | grep -c " 8." )
ifneq (,$(findstring 1, $(RHEL8)))
RHEL8FLAG := -DRHEL8
endif
PWD := $(shell pwd)
KVERSION := $(shell uname -r)
INCLUDE_DIR = /usr/lib/modules/$(KVERSION)/build/
CONFIG_MODULE_SIG=n
MODULE_NAME = gtp5g
MOD_KERNEL_PATH := kernel/drivers/net
ifeq ($(KVER),)
KVER := $(shell uname -r)
endif
ifeq ($(KDIR),)
KDIR := /lib/modules/$(KVER)/build
endif
ifneq ($(RHEL8FLAG),)
INSTALL := $(MAKE) -C $(KDIR) M=$$PWD INSTALL_MOD_PATH=$(DESTDIR) INSTALL_MOD_DIR=$(MOD_KERNEL_PATH) modules_install
else
INSTALL := cp $(MODULE_NAME).ko $(DESTDIR)/lib/modules/$(KVER)/$(MOD_KERNEL_PATH)
RUN_DEPMOD := true
endif
ifneq ($(RUN_DEPMOD),)
DEPMOD := /sbin/depmod -a
else
DEPMOD := true
endif
MY_CFLAGS += -g -DDEBUG $(RHEL8FLAG)
# MY_CFLAGS += -DMATCH_IP # match IP address(in F-TEID) or not
EXTRA_CFLAGS += -Wno-misleading-indentation -Wuninitialized
CC += ${MY_CFLAGS}
obj-m := $(MODULE_NAME).o
default: module
module:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
install:
$(INSTALL)
modprobe udp_tunnel
$(DEPMOD)
modprobe $(MODULE_NAME)
echo "gtp5g" >> /etc/modules
uninstall:
rm -f $(DESTDIR)/lib/modules/$(KVER)/$(MOD_KERNEL_PATH)/$(MODULE_NAME).ko
$(DEPMOD)
sed -zi "s/gtp5g\n//g" /etc/modules
rmmod -f $(MODULE_NAME)