Android.mk revision 60b9051f64869434c5bab6739556cb1975232267
1ifneq ($(TARGET_SIMULATOR),true)
2  BUILD_IPTABLES_V14 := 1
3endif
4
5ifeq ($(BUILD_IPTABLES_V14),1)
6
7LOCAL_PATH:= $(call my-dir)
8
9#
10# Build libraries
11#
12
13#----------------------------------------------------------------
14# libip4tc
15
16include $(CLEAR_VARS)
17
18LOCAL_C_INCLUDES:= \
19	$(KERNEL_HEADERS) \
20	$(LOCAL_PATH)/include/
21
22LOCAL_CFLAGS:=
23
24LOCAL_SRC_FILES:= \
25	libiptc/libip4tc.c \
26
27
28LOCAL_MODULE_TAGS:=
29LOCAL_MODULE:=libip4tc
30
31include $(BUILD_STATIC_LIBRARY)
32
33
34#----------------------------------------------------------------
35# libip6tc
36
37include $(CLEAR_VARS)
38
39LOCAL_C_INCLUDES:= \
40	$(KERNEL_HEADERS) \
41	$(LOCAL_PATH)/include/
42
43LOCAL_CFLAGS:=
44
45LOCAL_SRC_FILES:= \
46	libiptc/libip6tc.c \
47
48
49LOCAL_MODULE_TAGS:=
50LOCAL_MODULE:=libip6tc
51
52include $(BUILD_STATIC_LIBRARY)
53
54#----------------------------------------------------------------
55# libiptc
56
57#include $(CLEAR_VARS)
58#
59#LOCAL_C_INCLUDES:= \
60#	$(KERNEL_HEADERS) \
61#	$(LOCAL_PATH)/include/
62#
63#LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
64#
65#LOCAL_SRC_FILES:=
66#
67#
68#LOCAL_MODULE_TAGS:=
69#LOCAL_MODULE:=libiptc
70#
71#LOCAL_STATIC_LIBRARIES := \
72#	libip4tc \
73#	libip6tc \
74#
75#include $(BUILD_STATIC_LIBRARY)
76
77#----------------------------------------------------------------
78# libxtables
79
80include $(CLEAR_VARS)
81
82LOCAL_C_INCLUDES:= \
83	$(LOCAL_PATH)/include/ \
84	$(KERNEL_HEADERS) \
85
86LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
87LOCAL_CFLAGS+=-DXTABLES_INTERNAL
88LOCAL_CFLAGS+=-DXTABLES_LIBDIR=\"xtables_libdir_not_used\"
89
90LOCAL_LDFLAGS:=-version-info 5:0:0
91LOCAL_SRC_FILES:= \
92	xtables.c xtoptions.c
93
94
95LOCAL_MODULE_TAGS:=
96LOCAL_MODULE:=libxtables
97
98include $(BUILD_STATIC_LIBRARY)
99
100#----------------------------------------------------------------
101#----------------------------------------------------------------
102## extentsion
103
104MY_srcdir:=$(LOCAL_PATH)/extensions
105# Exclude some modules that are problematic to compile (types/header).
106MY_excluded_modules:=TCPOPTSTRIP
107
108MY_pfx_build_mod := $(patsubst ${MY_srcdir}/libxt_%.c,%,$(wildcard ${MY_srcdir}/libxt_*.c))
109MY_pf4_build_mod := $(patsubst ${MY_srcdir}/libipt_%.c,%,$(wildcard ${MY_srcdir}/libipt_*.c))
110MY_pf6_build_mod := $(patsubst ${MY_srcdir}/libip6t_%.c,%,$(wildcard ${MY_srcdir}/libip6t_*.c))
111MY_pfx_build_mod := $(filter-out ${MY_excluded_modules} dccp ipvs,${MY_pfx_build_mod})
112MY_pf4_build_mod := $(filter-out ${MY_excluded_modules} dccp ipvs,${MY_pf4_build_mod})
113MY_pf6_build_mod := $(filter-out ${MY_excluded_modules} dccp ipvs,${MY_pf6_build_mod})
114MY_pfx_objs      := $(patsubst %,libxt_%.o,${MY_pfx_build_mod})
115MY_pf4_objs      := $(patsubst %,libipt_%.o,${MY_pf4_build_mod})
116MY_pf6_objs      := $(patsubst %,libip6t_%.o,${MY_pf6_build_mod})
117
118#----------------------------------------------------------------
119# libext
120# TODO(jpa): Trun this into a function/macro as libext{,4,6} are all the same.
121
122include $(CLEAR_VARS)
123
124LOCAL_MODULE_TAGS:=
125LOCAL_MODULE:=libext
126
127# LOCAL_MODULE_CLASS must be defined before calling $(local-intermediates-dir)
128#
129LOCAL_MODULE_CLASS := STATIC_LIBRARIES
130MY_intermediates := $(call local-intermediates-dir)
131
132# LOCAL_PATH/extensions needed because of dirty #include "blabla.c"
133LOCAL_C_INCLUDES:= \
134	$(LOCAL_PATH)/include/ \
135	$(KERNEL_HEADERS) \
136	$(MY_intermediates)/extensions/ \
137	$(LOCAL_PATH)/extensions/
138
139LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
140# The $* does not work as expected. It ends up empty. Even with SECONDEXPANSION.
141# LOCAL_CFLAGS+=-D_INIT=lib$*_init
142LOCAL_CFLAGS+=-DXTABLES_INTERNAL
143
144MY_initext_func := $(addprefix xt_,${MY_pfx_build_mod})
145MY_GEN_INITEXT:= $(MY_intermediates)/extensions/initext.c
146$(MY_GEN_INITEXT):
147	@mkdir -p $(dir $@)
148	@( \
149	echo "" >$@; \
150	for i in ${MY_initext_func}; do \
151		echo "extern void lib$${i}_init(void);" >>$@; \
152	done; \
153	echo "void init_extensions(void);" >>$@; \
154	echo "void init_extensions(void)" >>$@; \
155	echo "{" >>$@; \
156	for i in ${MY_initext_func}; do \
157		echo " ""lib$${i}_init();" >>$@; \
158	done; \
159	echo "}" >>$@; \
160	);
161
162MY_lib_sources:= \
163	$(patsubst %,$(LOCAL_PATH)/extensions/libxt_%.c,${MY_pfx_build_mod})
164
165MY_gen_lib_sources:= $(patsubst $(LOCAL_PATH)/%,${MY_intermediates}/%,${MY_lib_sources})
166
167${MY_gen_lib_sources}: PRIVATE_PATH := $(LOCAL_PATH)
168${MY_gen_lib_sources}: PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/extensions/filter_init $(PRIVATE_PATH)/extensions/$(notdir $@) > $@
169${MY_gen_lib_sources}: PRIVATE_MODULE := $(LOCAL_MODULE)
170${MY_gen_lib_sources}: PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
171${MY_gen_lib_sources}: $(MY_lib_sources)
172	$(transform-generated-source)
173
174$(MY_intermediates)/extensions/initext.o : $(MY_GEN_INITEXT) $(MY_gen_lib_sources)
175
176LOCAL_GENERATED_SOURCES:= $(MY_GEN_INITEXT) $(MY_gen_lib_sources)
177
178include $(BUILD_STATIC_LIBRARY)
179
180#----------------------------------------------------------------
181# libext4
182
183include $(CLEAR_VARS)
184
185LOCAL_MODULE_TAGS:=
186LOCAL_MODULE:=libext4
187
188# LOCAL_MODULE_CLASS must be defined before calling $(local-intermediates-dir)
189#
190LOCAL_MODULE_CLASS := STATIC_LIBRARIES
191MY_intermediates := $(call local-intermediates-dir)
192
193# LOCAL_PATH/extensions needed because of dirty #include "blabla.c"
194LOCAL_C_INCLUDES:= \
195	$(LOCAL_PATH)/include/ \
196	$(KERNEL_HEADERS) \
197	$(MY_intermediates)/extensions/ \
198	$(LOCAL_PATH)/extensions/
199
200LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
201# The $* does not work as expected. It ends up empty. Even with SECONDEXPANSION.
202# LOCAL_CFLAGS+=-D_INIT=lib$*_init
203LOCAL_CFLAGS+=-DXTABLES_INTERNAL
204
205MY_initext4_func  := $(addprefix ipt_,${MY_pf4_build_mod})
206MY_GEN_INITEXT4:= $(MY_intermediates)/extensions/initext4.c
207$(MY_GEN_INITEXT4):
208	@mkdir -p $(dir $@)
209	@( \
210	echo "" >$@; \
211	for i in ${MY_initext4_func}; do \
212		echo "extern void lib$${i}_init(void);" >>$@; \
213	done; \
214	echo "void init_extensions4(void);" >>$@; \
215	echo "void init_extensions4(void)" >>$@; \
216	echo "{" >>$@; \
217	for i in ${MY_initext4_func}; do \
218		echo  " ""lib$${i}_init();" >>$@; \
219	done; \
220	echo "}" >>$@; \
221	);
222
223MY_lib_sources:= \
224	$(patsubst %,$(LOCAL_PATH)/extensions/libipt_%.c,${MY_pf4_build_mod})
225
226MY_gen_lib_sources:= $(patsubst $(LOCAL_PATH)/%,${MY_intermediates}/%,${MY_lib_sources})
227
228${MY_gen_lib_sources}: PRIVATE_PATH := $(LOCAL_PATH)
229${MY_gen_lib_sources}: PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/extensions/filter_init $(PRIVATE_PATH)/extensions/$(notdir $@) > $@
230${MY_gen_lib_sources}: PRIVATE_MODULE := $(LOCAL_MODULE)
231${MY_gen_lib_sources}: PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
232${MY_gen_lib_sources}: $(MY_lib_sources)
233	$(transform-generated-source)
234
235$(MY_intermediates)/extensions/initext4.o : $(MY_GEN_INITEXT4) $(MY_gen_lib_sources)
236
237LOCAL_GENERATED_SOURCES:= $(MY_GEN_INITEXT4) ${MY_gen_lib_sources}
238
239include $(BUILD_STATIC_LIBRARY)
240
241#----------------------------------------------------------------
242# libext6
243
244include $(CLEAR_VARS)
245
246LOCAL_MODULE_TAGS:=
247LOCAL_MODULE:=libext6
248
249# LOCAL_MODULE_CLASS must be defined before calling $(local-intermediates-dir)
250#
251LOCAL_MODULE_CLASS := STATIC_LIBRARIES
252MY_intermediates := $(call local-intermediates-dir)
253
254# LOCAL_PATH/extensions needed because of dirty #include "blabla.c"
255LOCAL_C_INCLUDES:= \
256	$(LOCAL_PATH)/include/ \
257	$(KERNEL_HEADERS) \
258	$(MY_intermediates)/extensions/ \
259	$(LOCAL_PATH)/extensions/
260
261LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
262# The $* does not work as expected. It ends up empty. Even with SECONDEXPANSION.
263# LOCAL_CFLAGS+=-D_INIT=lib$*_init
264LOCAL_CFLAGS+=-DXTABLES_INTERNAL
265
266MY_initext6_func := $(addprefix ip6t_,${MY_pf6_build_mod})
267MY_GEN_INITEXT6:= $(MY_intermediates)/extensions/initext6.c
268$(MY_GEN_INITEXT6):
269	@mkdir -p $(dir $@)
270	@( \
271	echo "" >$@; \
272	for i in ${MY_initext6_func}; do \
273		echo "extern void lib$${i}_init(void);" >>$@; \
274	done; \
275	echo "void init_extensions6(void);" >>$@; \
276	echo "void init_extensions6(void)" >>$@; \
277	echo "{" >>$@; \
278	for i in ${MY_initext6_func}; do \
279		echo " ""lib$${i}_init();" >>$@; \
280	done; \
281	echo "}" >>$@; \
282	);
283
284MY_lib_sources:= \
285	$(patsubst %,$(LOCAL_PATH)/extensions/libip6t_%.c,${MY_pf6_build_mod})
286
287MY_gen_lib_sources:= $(patsubst $(LOCAL_PATH)/%,${MY_intermediates}/%,${MY_lib_sources})
288
289${MY_gen_lib_sources}: PRIVATE_PATH := $(LOCAL_PATH)
290${MY_gen_lib_sources}: PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/extensions/filter_init $(PRIVATE_PATH)/extensions/$(notdir $@) > $@
291${MY_gen_lib_sources}: PRIVATE_MODULE := $(LOCAL_MODULE)
292${MY_gen_lib_sources}: PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
293${MY_gen_lib_sources}: $(MY_lib_sources)
294	$(transform-generated-source)
295
296$(MY_intermediates)/extensions/initext6.o : $(MY_GEN_INITEXT6) $(MY_gen_lib_sources)
297
298LOCAL_GENERATED_SOURCES:= $(MY_GEN_INITEXT6) $(MY_gen_lib_sources)
299
300include $(BUILD_STATIC_LIBRARY)
301
302#----------------------------------------------------------------
303# iptables
304
305
306include $(CLEAR_VARS)
307
308LOCAL_C_INCLUDES:= \
309	$(LOCAL_PATH)/include/
310
311LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
312LOCAL_CFLAGS+=-DALL_INCLUSIVE
313LOCAL_CFLAGS+=-DXTABLES_INTERNAL
314
315LOCAL_SRC_FILES:= \
316	iptables-standalone.c iptables.c xshared.c
317
318
319LOCAL_MODULE_TAGS:=debug
320LOCAL_MODULE:=iptables
321
322LOCAL_STATIC_LIBRARIES := \
323	libext \
324	libext4 \
325	libip4tc \
326	libxtables
327
328include $(BUILD_EXECUTABLE)
329
330#----------------------------------------------------------------
331# ip6tables
332include $(CLEAR_VARS)
333
334LOCAL_C_INCLUDES:= \
335	$(LOCAL_PATH)/include/
336
337LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
338LOCAL_CFLAGS+=-DALL_INCLUSIVE
339LOCAL_CFLAGS+=-DXTABLES_INTERNAL
340
341LOCAL_SRC_FILES:= \
342	ip6tables-standalone.c ip6tables.c xshared.c
343
344
345LOCAL_MODULE_TAGS:=debug
346LOCAL_MODULE:=ip6tables
347
348LOCAL_STATIC_LIBRARIES := \
349	libext \
350	libext6 \
351	libip6tc \
352	libxtables
353
354include $(BUILD_EXECUTABLE)
355
356
357#----------------------------------------------------------------
358endif
359