• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1LOCAL_PATH:= $(call my-dir)
2#----------------------------------------------------------------
3## extension
4
5MY_srcdir:=$(LOCAL_PATH)
6# Exclude some modules that are problematic to compile (types/header).
7MY_excluded_modules:=TCPOPTSTRIP
8
9MY_pfx_build_mod := $(patsubst ${MY_srcdir}/libxt_%.c,%,$(wildcard ${MY_srcdir}/libxt_*.c))
10MY_pf4_build_mod := $(patsubst ${MY_srcdir}/libipt_%.c,%,$(wildcard ${MY_srcdir}/libipt_*.c))
11MY_pf6_build_mod := $(patsubst ${MY_srcdir}/libip6t_%.c,%,$(wildcard ${MY_srcdir}/libip6t_*.c))
12MY_pfx_build_mod := $(filter-out ${MY_excluded_modules} dccp ipvs,${MY_pfx_build_mod})
13MY_pf4_build_mod := $(filter-out ${MY_excluded_modules} dccp ipvs,${MY_pf4_build_mod})
14MY_pf6_build_mod := $(filter-out ${MY_excluded_modules} dccp ipvs,${MY_pf6_build_mod})
15MY_pfx_objs      := $(patsubst %,libxt_%.o,${MY_pfx_build_mod})
16MY_pf4_objs      := $(patsubst %,libipt_%.o,${MY_pf4_build_mod})
17MY_pf6_objs      := $(patsubst %,libip6t_%.o,${MY_pf6_build_mod})
18
19#----------------------------------------------------------------
20# libext
21# TODO(jpa): Trun this into a function/macro as libext{,4,6} are all the same.
22
23include $(CLEAR_VARS)
24
25LOCAL_MODULE_TAGS:=
26LOCAL_MODULE:=libext
27
28# LOCAL_MODULE_CLASS must be defined before calling $(local-intermediates-dir)
29#
30LOCAL_MODULE_CLASS := STATIC_LIBRARIES
31MY_intermediates := $(call local-intermediates-dir)
32
33# LOCAL_PATH needed because of dirty #include "blabla.c"
34LOCAL_C_INCLUDES:= \
35	$(LOCAL_PATH)/../include/ \
36	$(KERNEL_HEADERS) \
37	$(MY_intermediates) \
38	$(LOCAL_PATH)
39
40LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
41# The $* does not work as expected. It ends up empty. Even with SECONDEXPANSION.
42# LOCAL_CFLAGS+=-D_INIT=lib$*_init
43LOCAL_CFLAGS+=-DXTABLES_INTERNAL
44# Accommodate arm-eabi-4.4.3 tools that don't set __ANDROID__
45LOCAL_CFLAGS+=-D__ANDROID__
46
47MY_initext_func := $(addprefix xt_,${MY_pfx_build_mod})
48MY_GEN_INITEXT:= $(MY_intermediates)/initext.c
49$(MY_GEN_INITEXT):
50	@mkdir -p $(dir $@)
51	@( \
52	echo "" >$@; \
53	for i in ${MY_initext_func}; do \
54		echo "extern void lib$${i}_init(void);" >>$@; \
55	done; \
56	echo "void init_extensions(void);" >>$@; \
57	echo "void init_extensions(void)" >>$@; \
58	echo "{" >>$@; \
59	for i in ${MY_initext_func}; do \
60		echo " ""lib$${i}_init();" >>$@; \
61	done; \
62	echo "}" >>$@; \
63	);
64
65MY_lib_sources:= \
66	$(patsubst %,$(LOCAL_PATH)/libxt_%.c,${MY_pfx_build_mod})
67
68MY_gen_lib_sources:= $(patsubst $(LOCAL_PATH)/%,${MY_intermediates}/%,${MY_lib_sources})
69
70${MY_gen_lib_sources}: PRIVATE_PATH := $(LOCAL_PATH)
71${MY_gen_lib_sources}: PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/filter_init $(PRIVATE_PATH)/$(notdir $@) > $@
72${MY_gen_lib_sources}: PRIVATE_MODULE := $(LOCAL_MODULE)
73${MY_gen_lib_sources}: PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
74${MY_gen_lib_sources}: $(MY_lib_sources)
75	$(transform-generated-source)
76
77$(MY_intermediates)/initext.o : $(MY_GEN_INITEXT) $(MY_gen_lib_sources)
78
79LOCAL_GENERATED_SOURCES:= $(MY_GEN_INITEXT) $(MY_gen_lib_sources)
80
81include $(BUILD_STATIC_LIBRARY)
82
83#----------------------------------------------------------------
84# libext4
85
86include $(CLEAR_VARS)
87
88LOCAL_MODULE_TAGS:=
89LOCAL_MODULE:=libext4
90
91# LOCAL_MODULE_CLASS must be defined before calling $(local-intermediates-dir)
92#
93LOCAL_MODULE_CLASS := STATIC_LIBRARIES
94MY_intermediates := $(call local-intermediates-dir)
95
96# LOCAL_PATH needed because of dirty #include "blabla.c"
97LOCAL_C_INCLUDES:= \
98	$(LOCAL_PATH)/../include/ \
99	$(KERNEL_HEADERS) \
100	$(MY_intermediates)/ \
101	$(LOCAL_PATH)/
102
103LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
104# The $* does not work as expected. It ends up empty. Even with SECONDEXPANSION.
105# LOCAL_CFLAGS+=-D_INIT=lib$*_init
106LOCAL_CFLAGS+=-DXTABLES_INTERNAL
107# Accommodate arm-eabi-4.4.3 tools that don't set __ANDROID__
108LOCAL_CFLAGS+=-D__ANDROID__
109
110MY_initext4_func  := $(addprefix ipt_,${MY_pf4_build_mod})
111MY_GEN_INITEXT4:= $(MY_intermediates)/initext4.c
112$(MY_GEN_INITEXT4):
113	@mkdir -p $(dir $@)
114	@( \
115	echo "" >$@; \
116	for i in ${MY_initext4_func}; do \
117		echo "extern void lib$${i}_init(void);" >>$@; \
118	done; \
119	echo "void init_extensions4(void);" >>$@; \
120	echo "void init_extensions4(void)" >>$@; \
121	echo "{" >>$@; \
122	for i in ${MY_initext4_func}; do \
123		echo  " ""lib$${i}_init();" >>$@; \
124	done; \
125	echo "}" >>$@; \
126	);
127
128MY_lib_sources:= \
129	$(patsubst %,$(LOCAL_PATH)/libipt_%.c,${MY_pf4_build_mod})
130
131MY_gen_lib_sources:= $(patsubst $(LOCAL_PATH)/%,${MY_intermediates}/%,${MY_lib_sources})
132
133${MY_gen_lib_sources}: PRIVATE_PATH := $(LOCAL_PATH)
134${MY_gen_lib_sources}: PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/filter_init $(PRIVATE_PATH)/$(notdir $@) > $@
135${MY_gen_lib_sources}: PRIVATE_MODULE := $(LOCAL_MODULE)
136${MY_gen_lib_sources}: PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
137${MY_gen_lib_sources}: $(MY_lib_sources)
138	$(transform-generated-source)
139
140$(MY_intermediates)/initext4.o : $(MY_GEN_INITEXT4) $(MY_gen_lib_sources)
141
142LOCAL_GENERATED_SOURCES:= $(MY_GEN_INITEXT4) ${MY_gen_lib_sources}
143
144include $(BUILD_STATIC_LIBRARY)
145
146#----------------------------------------------------------------
147# libext6
148
149include $(CLEAR_VARS)
150
151LOCAL_MODULE_TAGS:=
152LOCAL_MODULE:=libext6
153
154# LOCAL_MODULE_CLASS must be defined before calling $(local-intermediates-dir)
155#
156LOCAL_MODULE_CLASS := STATIC_LIBRARIES
157MY_intermediates := $(call local-intermediates-dir)
158
159# LOCAL_PATH needed because of dirty #include "blabla.c"
160LOCAL_C_INCLUDES:= \
161	$(LOCAL_PATH)/../include/ \
162	$(KERNEL_HEADERS) \
163	$(MY_intermediates) \
164	$(LOCAL_PATH)
165
166LOCAL_CFLAGS:=-DNO_SHARED_LIBS=1
167# The $* does not work as expected. It ends up empty. Even with SECONDEXPANSION.
168# LOCAL_CFLAGS+=-D_INIT=lib$*_init
169LOCAL_CFLAGS+=-DXTABLES_INTERNAL
170# Accommodate arm-eabi-4.4.3 tools that don't set __ANDROID__
171LOCAL_CFLAGS+=-D__ANDROID__
172
173MY_initext6_func := $(addprefix ip6t_,${MY_pf6_build_mod})
174MY_GEN_INITEXT6:= $(MY_intermediates)/initext6.c
175$(MY_GEN_INITEXT6):
176	@mkdir -p $(dir $@)
177	@( \
178	echo "" >$@; \
179	for i in ${MY_initext6_func}; do \
180		echo "extern void lib$${i}_init(void);" >>$@; \
181	done; \
182	echo "void init_extensions6(void);" >>$@; \
183	echo "void init_extensions6(void)" >>$@; \
184	echo "{" >>$@; \
185	for i in ${MY_initext6_func}; do \
186		echo " ""lib$${i}_init();" >>$@; \
187	done; \
188	echo "}" >>$@; \
189	);
190
191MY_lib_sources:= \
192	$(patsubst %,$(LOCAL_PATH)/libip6t_%.c,${MY_pf6_build_mod})
193
194MY_gen_lib_sources:= $(patsubst $(LOCAL_PATH)/%,${MY_intermediates}/%,${MY_lib_sources})
195
196${MY_gen_lib_sources}: PRIVATE_PATH := $(LOCAL_PATH)
197${MY_gen_lib_sources}: PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/filter_init $(PRIVATE_PATH)/$(notdir $@) > $@
198${MY_gen_lib_sources}: PRIVATE_MODULE := $(LOCAL_MODULE)
199${MY_gen_lib_sources}: PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
200${MY_gen_lib_sources}: $(MY_lib_sources)
201	$(transform-generated-source)
202
203$(MY_intermediates)/initext6.o : $(MY_GEN_INITEXT6) $(MY_gen_lib_sources)
204
205LOCAL_GENERATED_SOURCES:= $(MY_GEN_INITEXT6) $(MY_gen_lib_sources)
206
207include $(BUILD_STATIC_LIBRARY)
208
209#----------------------------------------------------------------
210