1 ifneq ($(KERNELRELEASE
),)
6 KERNEL_SRC ?
= $(firstword $(wildcard /lib
/modules
/$(shell uname
-r
)/build
/usr
/src
/linux
))
8 $(error You need to
define KERNEL_SRC
)
11 ifneq ($wildcard $(KERNEL_SRC
)/include/linux
/modversions.h
),)
12 MODVERSIONS
= -DMODVERSIONS
15 _KVER
= $(strip $(shell cat
$(KERNEL_SRC
)/Makefile | grep
-e
'^VERSION' | cut
-d
"=" -f2
))
16 _KPL
= $(strip $(shell cat
$(KERNEL_SRC
)/Makefile | grep
-e
'^PATCHLEVEL' | cut
-d
"=" -f2
))
17 _KSUB
= $(strip $(shell cat
$(KERNEL_SRC
)/Makefile | grep
-e
'^SUBLEVEL' | cut
-d
"=" -f2
))
18 KERNEL_SERIES
=$(_KVER
).
$(_KPL
)
20 ifeq ($(KERNEL_SERIES
), 2.6)
27 IPTABLES_BIN
= iptables
29 ifndef $(IPTABLES_SRC
)
31 $(shell $(IPTABLES_BIN
) --version |
$(SED
) -e
's/^iptables v//')
32 IPTABLES_SRC
= $(wildcard /usr
/src
/iptables-
$(IPTVER
))
35 ifeq ($(IPTABLES_SRC
),)
36 $(warning You need to
install iptables sources and maybe set IPTABLES_SRC
)
39 IPTABLES_INCLUDE
= -I
$(IPTABLES_SRC
)/include
42 IPTABLES_VERSION
= $(IPTVER
)
44 IPTABLES_VERSION
= $(shell cat
$(IPTABLES_SRC
)/Makefile | grep
-e
'^IPTABLES_VERSION:=' | cut
-d
"=" -f2
)
47 IPTABLES_OPTION
= -DIPTABLES_VERSION
=\"$(IPTABLES_VERSION
)\"
50 CFLAGS
= -O2
-march
=i586
-pipe
-fomit-frame-pointer
54 all: modules libipt_ipp2p.so
58 ipt_ipp2p.o
: ipt_ipp2p.h ipt_ipp2p.c
59 $(CC
) $(CFLAGS
) -I
$(KERNEL_SRC
)/include -c ipt_ipp2p.c
-D__KERNEL__
-DMODULE
$(MODVERSIONS
)
61 ipt_ipp2p.ko
: ipt_ipp2p.h ipt_ipp2p.c
62 $(MAKE
) -C
$(KERNEL_SRC
) SUBDIRS
=$(PWD
) modules
65 libipt_ipp2p.so
: libipt_ipp2p.c ipt_ipp2p.h
66 $(CC
) $(CFLAGS
) $(IPTABLES_OPTION
) $(IPTABLES_INCLUDE
) -fPIC
-c libipt_ipp2p.c
67 ld -shared
-o libipt_ipp2p.so libipt_ipp2p.o
70 -rm -f
*.o
*.so
*.ko .
*.cmd
*.mod.c