blob: 94f3ea9cbcff69fd5fc7e2bb845d130adf8962c8 [file] [log] [blame]
Marc Bouchere6869a82000-03-20 06:03:29 +00001#! /usr/bin/make
2
Harald Welte2aa84a42003-01-12 20:30:46 +00003# WARNING:
4# only add extensions here that are either present in the kernel, or whose
5# header files are present in the include/linux directory of this iptables
6# package (HW)
7#
Yasuyuki KOZAKAI1ff0b8d2007-08-04 08:09:51 +00008PF_EXT_SLIB:=ah addrtype conntrack ecn helper icmp iprange owner policy realm tos ttl unclean CLASSIFY DNAT DSCP ECN LOG MASQUERADE MIRROR NETMAP REDIRECT REJECT SAME SNAT TOS TTL TRACE ULOG
9PF6_EXT_SLIB:=eui64 hl icmp6 owner policy HL LOG TRACE
10PFX_EXT_SLIB:=connmark connlimit comment dscp esp hashlimit length limit mac mark multiport physdev pkttype sctp state standard tcp tcpmss udp CONNMARK MARK NFQUEUE NOTRACK TCPMSS
Rusty Russell008a83f2001-02-28 11:21:53 +000011
James Morrisc81a3f32006-05-24 16:11:58 +000012ifeq ($(DO_SELINUX), 1)
Yasuyuki KOZAKAI56799582007-08-04 08:05:46 +000013PF_EXT_SE_SLIB:=
14PF6_EXT_SE_SLIB:=
15PFX_EXT_SE_SLIB:=CONNSECMARK SECMARK
James Morrisc81a3f32006-05-24 16:11:58 +000016endif
17
Rusty Russell52451822000-08-27 07:47:46 +000018# Optionals
19PF_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-test),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))
20PF6_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-test6),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +000021PFX_EXT_SLIB_OPTS:=$(foreach T,$(wildcard extensions/.*-testx),$(shell KERNEL_DIR=$(KERNEL_DIR) $(T)))
Rusty Russell52451822000-08-27 07:47:46 +000022
Henrik Nordstromc2794132004-01-22 15:04:24 +000023PF_EXT_ALL_SLIB:=$(patsubst extensions/libipt_%.c, %, $(wildcard extensions/libipt_*.c))
Martin Josefssonc9dd71a2004-04-07 13:00:43 +000024PF6_EXT_ALL_SLIB:=$(patsubst extensions/libip6t_%.c, %, $(wildcard extensions/libip6t_*.c))
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +000025PFX_EXT_ALL_SLIB:=$(patsubst extensions/libxt_%.c, %, $(wildcard extensions/libxt_*.c))
Henrik Nordstromc2794132004-01-22 15:04:24 +000026
27PF_EXT_MAN_ALL_MATCHES:=$(foreach T,$(PF_EXT_ALL_SLIB),$(shell test -f extensions/libipt_$(T).man && grep -q register_match extensions/libipt_$(T).c && echo $(T)))
28PF_EXT_MAN_ALL_TARGETS:=$(foreach T,$(PF_EXT_ALL_SLIB),$(shell test -f extensions/libipt_$(T).man && grep -q register_target extensions/libipt_$(T).c && echo $(T)))
29PF6_EXT_MAN_ALL_MATCHES:=$(foreach T,$(PF6_EXT_ALL_SLIB),$(shell test -f extensions/libip6t_$(T).man && grep -q register_match6 extensions/libip6t_$(T).c && echo $(T)))
30PF6_EXT_MAN_ALL_TARGETS:=$(foreach T,$(PF6_EXT_ALL_SLIB),$(shell test -f extensions/libip6t_$(T).man && grep -q register_target6 extensions/libip6t_$(T).c && echo $(T)))
31
32PF_EXT_MAN_MATCHES:=$(filter $(PF_EXT_ALL_SLIB), $(PF_EXT_MAN_ALL_MATCHES))
33PF_EXT_MAN_TARGETS:=$(filter $(PF_EXT_ALL_SLIB), $(PF_EXT_MAN_ALL_TARGETS))
34PF_EXT_MAN_EXTRA_MATCHES:=$(filter-out $(PF_EXT_MAN_MATCHES), $(PF_EXT_MAN_ALL_MATCHES))
35PF_EXT_MAN_EXTRA_TARGETS:=$(filter-out $(PF_EXT_MAN_TARGETS), $(PF_EXT_MAN_ALL_TARGETS))
36PF6_EXT_MAN_MATCHES:=$(filter $(PF6_EXT_ALL_SLIB), $(PF6_EXT_MAN_ALL_MATCHES))
37PF6_EXT_MAN_TARGETS:=$(filter $(PF6_EXT_ALL_SLIB), $(PF6_EXT_MAN_ALL_TARGETS))
38PF6_EXT_MAN_EXTRA_MATCHES:=$(filter-out $(PF6_EXT_MAN_MATCHES), $(PF6_EXT_MAN_ALL_MATCHES))
39PF6_EXT_MAN_EXTRA_TARGETS:=$(filter-out $(PF6_EXT_MAN_TARGETS), $(PF6_EXT_MAN_ALL_TARGETS))
40
41
42allman:
43 @echo ALL_SLIB: $(PF_EXT_ALL_SLIB)
44 @echo ALL_MATCH: $(PF_EXT_MAN_ALL_MATCHES)
45 @echo ALL_TARGET: $(PF_EXT_MAN_ALL_TARGETS)
46
Rusty Russell52451822000-08-27 07:47:46 +000047PF_EXT_SLIB+=$(PF_EXT_SLIB_OPTS)
48PF6_EXT_SLIB+=$(PF6_EXT_SLIB_OPTS)
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +000049PFX_EXT_SLIB+=$(PFX_EXT_SLIB_OPTS)
Rusty Russell52451822000-08-27 07:47:46 +000050
51OPTIONALS+=$(patsubst %,IPv4:%,$(PF_EXT_SLIB_OPTS))
52OPTIONALS+=$(patsubst %,IPv6:%,$(PF6_EXT_SLIB_OPTS))
53
Harald Welte3efb6ea2001-08-06 18:50:21 +000054ifndef NO_SHARED_LIBS
Marc Bouchere6869a82000-03-20 06:03:29 +000055SHARED_LIBS+=$(foreach T,$(PF_EXT_SLIB),extensions/libipt_$(T).so)
James Morrisc81a3f32006-05-24 16:11:58 +000056SHARED_SE_LIBS+=$(foreach T,$(PF_EXT_SE_SLIB),extensions/libipt_$(T).so)
Yasuyuki KOZAKAIdbda07b2007-07-24 06:08:05 +000057EXTRA_INSTALLS+=$(foreach T, $(PF_EXT_SLIB), $(DEST_IPT_LIBDIR)/libipt_$(T).so)
58EXTRA_INSTALLS+=$(foreach T, $(PF_EXT_SE_SLIB), $(DEST_IPT_LIBDIR)/libipt_$(T).so)
Rusty Russella138ba42001-06-05 11:56:17 +000059
Harald Welte2354d922003-03-04 23:15:42 +000060ifeq ($(DO_IPV6), 1)
Rusty Russella138ba42001-06-05 11:56:17 +000061SHARED_LIBS+=$(foreach T,$(PF6_EXT_SLIB),extensions/libip6t_$(T).so)
James Morrisc81a3f32006-05-24 16:11:58 +000062SHARED_SE_LIBS+=$(foreach T,$(PF6_EXT_SE_SLIB),extensions/libip6t_$(T).so)
Yasuyuki KOZAKAIdbda07b2007-07-24 06:08:05 +000063EXTRA_INSTALLS+=$(foreach T, $(PF6_EXT_SLIB), $(DEST_IPT_LIBDIR)/libip6t_$(T).so)
64EXTRA_INSTALLS+=$(foreach T, $(PF6_EXT_SE_SLIB), $(DEST_IPT_LIBDIR)/libip6t_$(T).so)
Rusty Russella138ba42001-06-05 11:56:17 +000065endif
Yasuyuki KOZAKAIdbda07b2007-07-24 06:08:05 +000066
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +000067SHARED_LIBS+=$(foreach T,$(PFX_EXT_SLIB),extensions/libxt_$(T).so)
Yasuyuki KOZAKAIfa00a732007-07-24 07:27:02 +000068SHARED_SE_LIBS+=$(foreach T,$(PFX_EXT_SE_SLIB),extensions/libxt_$(T).so)
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +000069EXTRA_INSTALLS+=$(foreach T, $(PFX_EXT_SLIB), $(DEST_IPT_LIBDIR)/libxt_$(T).so)
Yasuyuki KOZAKAIfa00a732007-07-24 07:27:02 +000070EXTRA_INSTALLS+=$(foreach T, $(PFX_EXT_SE_SLIB), $(DEST_IPT_LIBDIR)/libxt_$(T).so)
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +000071
Harald Welte3efb6ea2001-08-06 18:50:21 +000072else # NO_SHARED_LIBS
73EXT_OBJS+=$(foreach T,$(PF_EXT_SLIB),extensions/libipt_$(T).o)
James Morrisc81a3f32006-05-24 16:11:58 +000074EXT_OBJS+=$(foreach T,$(PF_EXT_SE_SLIB),extensions/libipt_$(T).o)
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +000075EXT_OBJS+=$(foreach T,$(PFX_EXT_SLIB),extensions/libxt_$(T).o)
Yasuyuki KOZAKAIfa00a732007-07-24 07:27:02 +000076EXT_OBJS+=$(foreach T,$(PFX_EXT_SE_SLIB),extensions/libxt_$(T).o)
Harald Welte3efb6ea2001-08-06 18:50:21 +000077EXT_FUNC+=$(foreach T,$(PF_EXT_SLIB),ipt_$(T))
James Morrisc81a3f32006-05-24 16:11:58 +000078EXT_FUNC+=$(foreach T,$(PF_EXT_SE_SLIB),ipt_$(T))
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +000079EXT_FUNC+=$(foreach T,$(PFX_EXT_SLIB),xt_$(T))
Yasuyuki KOZAKAIfa00a732007-07-24 07:27:02 +000080EXT_FUNC+=$(foreach T,$(PFX_EXT_SE_SLIB),xt_$(T))
Harald Welte3efb6ea2001-08-06 18:50:21 +000081EXT_OBJS+= extensions/initext.o
Harald Welte9c8cdd42003-03-05 11:39:31 +000082ifeq ($(DO_IPV6), 1)
Harald Welte3efb6ea2001-08-06 18:50:21 +000083EXT6_OBJS+=$(foreach T,$(PF6_EXT_SLIB),extensions/libip6t_$(T).o)
James Morrisc81a3f32006-05-24 16:11:58 +000084EXT6_OBJS+=$(foreach T,$(PF6_EXT_SE_SLIB),extensions/libip6t_$(T).o)
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +000085EXT6_OBJS+=$(foreach T,$(PFX_EXT_SLIB),extensions/libxt_$(T).o)
Harald Welte3efb6ea2001-08-06 18:50:21 +000086EXT6_FUNC+=$(foreach T,$(PF6_EXT_SLIB),ip6t_$(T))
James Morrisc81a3f32006-05-24 16:11:58 +000087EXT6_FUNC+=$(foreach T,$(PF6_EXT_SE_SLIB),ip6t_$(T))
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +000088EXT6_FUNC+=$(foreach T,$(PFX_EXT_SLIB),xt_$(T))
Yasuyuki KOZAKAIfa00a732007-07-24 07:27:02 +000089EXT6_OBJS+=$(foreach T,$(PFX_EXT_SE_SLIB),extensions/libxt_$(T).o)
90EXT6_FUNC+=$(foreach T,$(PFX_EXT_SE_SLIB),xt_$(T))
Harald Welte3efb6ea2001-08-06 18:50:21 +000091EXT6_OBJS+= extensions/initext6.o
Harald Welte9c8cdd42003-03-05 11:39:31 +000092endif # DO_IPV6
93endif # NO_SHARED_LIBS
Marc Bouchere6869a82000-03-20 06:03:29 +000094
95ifndef TOPLEVEL_INCLUDED
96local:
James Morrisc81a3f32006-05-24 16:11:58 +000097 cd .. && $(MAKE) $(SHARED_LIBS) $(SHARED_SE_LIBS)
Marc Bouchere6869a82000-03-20 06:03:29 +000098endif
99
Harald Welte3efb6ea2001-08-06 18:50:21 +0000100ifdef NO_SHARED_LIBS
101extensions/libext.a: $(EXT_OBJS)
102 rm -f $@; ar crv $@ $(EXT_OBJS)
103
104extensions/libext6.a: $(EXT6_OBJS)
105 rm -f $@; ar crv $@ $(EXT6_OBJS)
106
107extensions/initext.o: extensions/initext.c
108extensions/initext6.o: extensions/initext6.c
109
110extensions/initext.c: extensions/Makefile
111 echo "" > $@
112 for i in $(EXT_FUNC); do \
113 echo "extern void $${i}_init(void);" >> $@; \
114 done
115 echo "void init_extensions(void) {" >> $@
116 for i in $(EXT_FUNC); do \
117 echo " $${i}_init();" >> $@; \
118 done
119 echo "}" >> $@
120
121extensions/initext6.c: extensions/Makefile
122 echo "" > $@
123 for i in $(EXT6_FUNC); do \
124 echo "extern void $${i}_init(void);" >> $@; \
125 done
126 echo "void init_extensions(void) {" >> $@
127 for i in $(EXT6_FUNC); do \
128 echo " $${i}_init();" >> $@; \
129 done
130 echo "}" >> $@
131
132extensions/lib%.o: extensions/lib%.c
133 $(CC) $(CFLAGS) -D_INIT=$*_init -c -o $@ $<
134
135endif
136
Henrik Nordstromc2794132004-01-22 15:04:24 +0000137EXTRAS += extensions/libipt_targets.man
138extensions/libipt_targets.man: $(patsubst %,extensions/libipt_%.man,$(PF_EXT_MAN_ALL_TARGETS))
139 @for ext in $(PF_EXT_MAN_TARGETS); do \
140 echo ".SS $$ext" ;\
141 cat extensions/libipt_$$ext.man ;\
142 done >extensions/libipt_targets.man
143 @if [ -n "$(PF_EXT_MAN_EXTRA_TARGETS)" ]; then \
Joszef Kadlecsike4077d02004-06-17 09:02:35 +0000144 extra=$(PF_EXT_MAN_EXTRA_TARGETS) ;\
Joszef Kadlecsikd566c9b2004-06-17 08:48:30 +0000145 for ext in $${extra:-""}; do \
Henrik Nordstromc2794132004-01-22 15:04:24 +0000146 echo ".SS $$ext (not supported, see Patch-O-Matic)" ;\
147 cat extensions/libipt_$$ext.man ;\
148 done ;\
149 fi >>extensions/libipt_targets.man
150
151EXTRAS += extensions/libipt_matches.man
152extensions/libipt_matches.man: $(patsubst %,extensions/libipt_%.man,$(PF_EXT_MAN_ALL_MATCHES))
153 @for ext in $(PF_EXT_MAN_MATCHES); do \
154 echo ".SS $$ext" ;\
155 cat extensions/libipt_$$ext.man ;\
156 done >extensions/libipt_matches.man
157 @if [ -n "$(PF_EXT_MAN_EXTRA_MATCHES)" ]; then \
Joszef Kadlecsike4077d02004-06-17 09:02:35 +0000158 extra=$(PF_EXT_MAN_EXTRA_MATCHES) ;\
Joszef Kadlecsikd566c9b2004-06-17 08:48:30 +0000159 for ext in $${extra:-""}; do \
Henrik Nordstromc2794132004-01-22 15:04:24 +0000160 echo ".SS $$ext (not supported, see Patch-O-Matic)" ;\
161 cat extensions/libipt_$$ext.man ;\
162 done ;\
163 fi >>extensions/libipt_matches.man
164
165EXTRAS += extensions/libip6t_targets.man
166extensions/libip6t_targets.man: $(patsubst %, extensions/libip6t_%.man, $(PF6_EXT_MAN_ALL_TARGETS))
167 @for ext in $(PF6_EXT_MAN_TARGETS); do \
168 echo ".SS $$ext" ;\
169 cat extensions/libip6t_$$ext.man ;\
170 done >extensions/libip6t_targets.man
171 @if [ -n "$(PF6_EXT_MAN_EXTRA_TARGETS)" ]; then \
Joszef Kadlecsike4077d02004-06-17 09:02:35 +0000172 extra=$(PF6_EXT_MAN_EXTRA_TARGETS) ;\
Joszef Kadlecsikd566c9b2004-06-17 08:48:30 +0000173 for ext in $${extra:-""}; do \
Henrik Nordstromc2794132004-01-22 15:04:24 +0000174 echo ".SS $$ext (not supported, see Patch-O-Matic)" ;\
175 cat extensions/libip6t_$$ext.man ;\
176 done ;\
177 fi >>extensions/libip6t_targets.man
178
179EXTRAS += extensions/libip6t_matches.man
180extensions/libip6t_matches.man: $(patsubst %, extensions/libip6t_%.man, $(PF6_EXT_MAN_ALL_MATCHES))
181 @for ext in $(PF6_EXT_MAN_MATCHES); do \
182 echo ".SS $$ext" ;\
183 cat extensions/libip6t_$$ext.man ;\
184 done >extensions/libip6t_matches.man
185 @if [ -n "$(PF6_EXT_MAN_EXTRA_MATCHES)" ]; then \
Joszef Kadlecsike4077d02004-06-17 09:02:35 +0000186 extra=$(PF6_EXT_MAN_EXTRA_MATCHES) ;\
Joszef Kadlecsikd566c9b2004-06-17 08:48:30 +0000187 for ext in $${extra:-""}; do \
Henrik Nordstromc2794132004-01-22 15:04:24 +0000188 echo ".SS $$ext (not supported, see Patch-O-Matic)" ;\
189 cat extensions/libip6t_$$ext.man ;\
190 done ;\
191 fi >>extensions/libip6t_matches.man
192
Yasuyuki KOZAKAIdbda07b2007-07-24 06:08:05 +0000193$(DEST_IPT_LIBDIR)/libipt_%.so: extensions/libipt_%.so
194 @[ -d $(DEST_IPT_LIBDIR)/ ] || mkdir -p $(DEST_IPT_LIBDIR)/
Marc Bouchere6869a82000-03-20 06:03:29 +0000195 cp $< $@
Philip Blundell57e07af2000-06-04 17:25:33 +0000196
Yasuyuki KOZAKAIdbda07b2007-07-24 06:08:05 +0000197$(DEST_IPT_LIBDIR)/libip6t_%.so: extensions/libip6t_%.so
198 @[ -d $(DEST_IPT_LIBDIR)/ ] || mkdir -p $(DEST_IPT_LIBDIR)/
Philip Blundell57e07af2000-06-04 17:25:33 +0000199 cp $< $@
Yasuyuki KOZAKAI68c79152007-07-24 06:09:15 +0000200
201$(DEST_IPT_LIBDIR)/libxt_%.so: extensions/libxt_%.so
202 @[ -d $(DEST_IPT_LIBDIR)/ ] || mkdir -p $(DEST_IPT_LIBDIR)/
203 cp $< $@