-
Notifications
You must be signed in to change notification settings - Fork 63
/
Makefile
100 lines (79 loc) · 2.16 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
RHEL8 := $(shell cat /etc/redhat-release 2>/dev/null | grep -c " 8." )
ifneq (,$(findstring 1, $(RHEL8)))
RHEL8FLAG := -DRHEL8
endif
PWD := $(shell pwd)
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIR := $(shell dirname $(MAKEFILE_PATH))
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}
EXTRA_CFLAGS += -I $(MAKEFILE_DIR)/include
5G_MOD := src/gtp5g.o
5G_LOG := src/log.o
5G_UTIL := src/util.o
5G_GTPU := src/gtpu/dev.o \
src/gtpu/encap.o \
src/gtpu/hash.o \
src/gtpu/link.o \
src/gtpu/net.o \
src/gtpu/pktinfo.o \
src/gtpu/trTCM.o
5G_GENL := src/genl/genl.o \
src/genl/genl_version.o \
src/genl/genl_pdr.o \
src/genl/genl_far.o \
src/genl/genl_qer.o \
src/genl/genl_urr.o \
src/genl/genl_report.o \
src/genl/genl_bar.o
5G_PFCP := src/pfcp/api_version.o \
src/pfcp/pdr.o \
src/pfcp/far.o \
src/pfcp/qer.o \
src/pfcp/urr.o \
src/pfcp/bar.o \
src/pfcp/seid.o
5G_PROC := src/proc.o
# Build files
obj-m += $(MODULE_NAME).o
$(MODULE_NAME)-objs := $(5G_MOD) $(5G_LOG) $(5G_UTIL) $(5G_GTPU) \
$(5G_GENL) $(5G_PFCP) $(5G_PROC)
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 "udp_tunnel" > /etc/modules-load.d/gtp5g.conf
echo "gtp5g" >> /etc/modules-load.d/gtp5g.conf
uninstall:
rm -f $(DESTDIR)/lib/modules/$(KVER)/$(MOD_KERNEL_PATH)/$(MODULE_NAME).ko
$(DEPMOD)
rm -f /etc/modules-load.d/gtp5g.conf
rmmod -f $(MODULE_NAME)