]>
Commit | Line | Data |
---|---|---|
552b817b MT |
1 | ifneq ($(KERNELRELEASE),) |
2 | obj-m := ipt_ipp2p.o | |
3 | ||
4 | else | |
5 | ||
6 | KERNEL_SRC ?= $(firstword $(wildcard /lib/modules/$(shell uname -r)/build /usr/src/linux)) | |
7 | ifeq ($(KERNEL_SRC),) | |
8 | $(error You need to define KERNEL_SRC) | |
9 | endif | |
10 | ||
11 | ifneq ($wildcard $(KERNEL_SRC)/include/linux/modversions.h),) | |
12 | MODVERSIONS = -DMODVERSIONS | |
13 | endif | |
14 | ||
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) | |
19 | ||
20 | ifeq ($(KERNEL_SERIES), 2.6) | |
21 | TARGET=ipt_ipp2p.ko | |
22 | else | |
23 | TARGET=ipt_ipp2p.o | |
24 | endif | |
25 | ||
26 | SED = sed | |
27 | IPTABLES_BIN = iptables | |
28 | ||
29 | ifndef $(IPTABLES_SRC) | |
30 | IPTVER = \ | |
31 | $(shell $(IPTABLES_BIN) --version | $(SED) -e 's/^iptables v//') | |
32 | IPTABLES_SRC = $(wildcard /usr/src/iptables-$(IPTVER)) | |
33 | endif | |
34 | ||
35 | ifeq ($(IPTABLES_SRC),) | |
36 | $(warning You need to install iptables sources and maybe set IPTABLES_SRC) | |
37 | endif | |
38 | ||
39 | IPTABLES_INCLUDE = -I$(IPTABLES_SRC)/include | |
40 | ||
41 | ifneq ($(IPTVER),) | |
42 | IPTABLES_VERSION = $(IPTVER) | |
43 | else | |
44 | IPTABLES_VERSION = $(shell cat $(IPTABLES_SRC)/Makefile | grep -e '^IPTABLES_VERSION:=' | cut -d"=" -f2) | |
45 | endif | |
46 | ||
47 | IPTABLES_OPTION = -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" | |
48 | ||
49 | CC = gcc | |
50 | CFLAGS = -O2 -march=i586 -pipe -fomit-frame-pointer | |
51 | ||
52 | ||
53 | ||
54 | all: modules libipt_ipp2p.so | |
55 | ||
56 | modules: $(TARGET) | |
57 | ||
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) | |
60 | ||
61 | ipt_ipp2p.ko: ipt_ipp2p.h ipt_ipp2p.c | |
62 | $(MAKE) -C $(KERNEL_SRC) SUBDIRS=$(PWD) modules | |
63 | ||
64 | ||
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 | |
68 | ||
69 | clean: | |
70 | -rm -f *.o *.so *.ko .*.cmd *.mod.c | |
71 | endif |