-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
43 lines (32 loc) · 1.05 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
# SPDX-License-Identifier: GPL-2.0
#
# Makefile for so iptables module.
#
KVER ?= $(shell uname -r)
KDIR ?= /lib/modules/$(KVER)/build/
DEPMOD = /sbin/depmod -a
CC ?= gcc
XFLAGS ?= $(shell pkg-config xtables --cflags 2>/dev/null)
XDIR ?= $(shell pkg-config --variable xtlibdir xtables)
VERSION = $(shell git -C $M describe --dirty)
VOPT = '-DVERSION="$(VERSION)"'
obj-m = xt_so.o
CFLAGS_xt_so.o = -DDEBUG $(VOPT)
all: xt_so.ko libxt_so.so
xt_so.ko: xt_so.c xt_so.h
make -C $(KDIR) M=$(CURDIR) modules CONFIG_DEBUG_INFO=y
install: install-mod install-lib
install-mod: xt_so.ko
make -C $(KDIR) M=$(CURDIR) modules_install INSTALL_MOD_PATH=$(DESTDIR)
install-lib: libxt_so.so
install -D $< $(DESTDIR)$(shell pkg-config --variable xtlibdir xtables)/$<
test:
./tests.sh test
%.so: %_sh.o
gcc -shared -o $@ $< $(shell pkg-config xtables --libs)
%_sh.o: libxt_so.c xt_so.h
gcc -O2 -Wall -Wunused -fPIC ${XFLAGS} ${CFLAGS} -o $@ -c $<
clean:
-make -C $(KDIR) M=$(CURDIR) clean
-rm -f *.so *.o modules.order
.PHONY: clean all install install-mod install-lib test