-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
103 lines (85 loc) · 3.8 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
101
102
# SPDX-FileCopyrightText: (c) 2023-2024 Ring Zero Desenvolvimento de Software LTDA
# SPDX-License-Identifier: MIT OR GPL-2.0-only
KERNEL_RELEASE ?= ${shell uname -r}
MODULES_INSTALL_PATH = /lib/modules/${KERNEL_RELEASE}
SCRIPTS_INSTALL_PATH = /lib/modules/lua
LUNATIK_INSTALL_PATH = /usr/local/sbin
LUNATIK_EBPF_INSTALL_PATH = /usr/local/lib/bpf/lunatik
MOONTASTIK_RELEASE ?= v0.1c
LUA_API = lua/lua.h lua/lauxlib.h lua/lualib.h
KDIR ?= ${MODULES_INSTALL_PATH}/build
RM = rm -f
MKDIR = mkdir -p -m 0755
INSTALL = install -o root -g root
all: lunatik_sym.h
${MAKE} -C ${KDIR} M=${PWD} CONFIG_LUNATIK=m \
CONFIG_LUNATIK_RUN=m CONFIG_LUNATIK_RUNTIME=y CONFIG_LUNATIK_DEVICE=m \
CONFIG_LUNATIK_LINUX=m CONFIG_LUNATIK_NOTIFIER=m CONFIG_LUNATIK_SOCKET=m \
CONFIG_LUNATIK_RCU=m CONFIG_LUNATIK_THREAD=m CONFIG_LUNATIK_FIB=m \
CONFIG_LUNATIK_DATA=m CONFIG_LUNATIK_PROBE=m CONFIG_LUNATIK_SYSCALL=m \
CONFIG_LUNATIK_XDP=m CONFIG_LUNATIK_FIFO=m CONFIG_LUNATIK_XTABLE=m \
CONFIG_LUNATIK_NETFILTER=m CONFIG_LUNATIK_COMPLETION=m
clean:
${MAKE} -C ${KDIR} M=${PWD} clean
${MAKE} -C examples/filter clean
${RM} lunatik_sym.h
scripts_install:
${MKDIR} ${SCRIPTS_INSTALL_PATH} ${SCRIPTS_INSTALL_PATH}/lunatik
${MKDIR} ${SCRIPTS_INSTALL_PATH} ${SCRIPTS_INSTALL_PATH}/socket
${MKDIR} ${SCRIPTS_INSTALL_PATH} ${SCRIPTS_INSTALL_PATH}/syscall
${INSTALL} -m 0644 driver.lua ${SCRIPTS_INSTALL_PATH}/
${INSTALL} -m 0644 lib/mailbox.lua ${SCRIPTS_INSTALL_PATH}/
${INSTALL} -m 0644 lib/lunatik/*.lua ${SCRIPTS_INSTALL_PATH}/lunatik
${INSTALL} -m 0644 lib/socket/*.lua ${SCRIPTS_INSTALL_PATH}/socket
${INSTALL} -m 0644 lib/syscall/*.lua ${SCRIPTS_INSTALL_PATH}/syscall
${INSTALL} -m 0755 bin/lunatik ${LUNATIK_INSTALL_PATH}
scripts_uninstall:
${RM} ${SCRIPTS_INSTALL_PATH}/driver.lua
${RM} ${SCRIPTS_INSTALL_PATH}/runner.lua
${RM} ${SCRIPTS_INSTALL_PATH}/mailbox.lua
${RM} -r ${SCRIPTS_INSTALL_PATH}/lunatik
${RM} -r ${SCRIPTS_INSTALL_PATH}/socket
${RM} -r ${SCRIPTS_INSTALL_PATH}/syscall
${RM} ${LUNATIK_INSTALL_PATH}/lunatik
examples_install:
${MKDIR} ${SCRIPTS_INSTALL_PATH}/examples
${INSTALL} -m 0644 examples/*.lua ${SCRIPTS_INSTALL_PATH}/examples
${MKDIR} ${SCRIPTS_INSTALL_PATH}/examples/echod
${INSTALL} -m 0644 examples/echod/*.lua ${SCRIPTS_INSTALL_PATH}/examples/echod
${MKDIR} ${SCRIPTS_INSTALL_PATH}/examples/filter
${INSTALL} -m 0644 examples/filter/*.lua ${SCRIPTS_INSTALL_PATH}/examples/filter
${MKDIR} ${SCRIPTS_INSTALL_PATH}/examples/dnsblock
${INSTALL} -m 0644 examples/dnsblock/*.lua ${SCRIPTS_INSTALL_PATH}/examples/dnsblock
${MKDIR} ${SCRIPTS_INSTALL_PATH}/examples/dnsdoctor
${INSTALL} -m 0644 examples/dnsdoctor/*.lua ${SCRIPTS_INSTALL_PATH}/examples/dnsdoctor
.PHONY: ebpf
examples:
${MAKE} -C examples/filter
ebpf_install:
${MKDIR} ${LUNATIK_EBPF_INSTALL_PATH}
${INSTALL} -m 0644 examples/filter/https.o ${LUNATIK_EBPF_INSTALL_PATH}/
examples_uninstall:
${RM} -r ${SCRIPTS_INSTALL_PATH}/examples
${RM} -r ${LUNATIK_EBPF_INSTALL_PATH}
modules_install:
${MKDIR} ${MODULES_INSTALL_PATH}/lunatik
${INSTALL} -m 0644 *.ko lib/*.ko ${MODULES_INSTALL_PATH}/lunatik
btf_install:
cp /sys/kernel/btf/vmlinux ${KDIR}
modules_uninstall:
${RM} -r ${MODULES_INSTALL_PATH}/lunatik
install: scripts_install modules_install
depmod -a
uninstall: scripts_uninstall modules_uninstall
depmod -a
lunatik_sym.h: $(LUA_API)
${shell ./gensymbols.sh $(LUA_API) > lunatik_sym.h}
moontastik_install_%:
[ $* ] || (echo "usage: make moontastik_install_TARGET" ; exit 1)
wget https://github.com/luainkernel/moontastik/releases/download/${MOONTASTIK_RELEASE}/moontastik_lua.zip -O moontastik_lua.zip
[ -d moontastik_lua ] && ${RM} -r moontastik_lua || true
unzip moontastik_lua.zip
cd moontastik_lua/"$*" && ./install.sh ; cd -
moontastik_uninstall_%:
[ $* ] || (echo "usage: make moontastik_uninstall_TARGET" ; exit 1)
${RM} -r ${SCRIPTS_INSTALL_PATH}/$*