1 LOCAL_PATH:= $(call my-dir) 2 #---------------------------------------------------------------- 3 ## extension 4 5 MY_srcdir:=$(LOCAL_PATH) 6 # Exclude some modules that are problematic to compile (types/header). 7 MY_excluded_modules:=TCPOPTSTRIP 8 9 MY_pfx_build_mod := $(patsubst ${MY_srcdir}/libxt_%.c,%,$(wildcard ${MY_srcdir}/libxt_*.c)) 10 MY_pf4_build_mod := $(patsubst ${MY_srcdir}/libipt_%.c,%,$(wildcard ${MY_srcdir}/libipt_*.c)) 11 MY_pf6_build_mod := $(patsubst ${MY_srcdir}/libip6t_%.c,%,$(wildcard ${MY_srcdir}/libip6t_*.c)) 12 MY_pfx_build_mod := $(filter-out ${MY_excluded_modules} dccp ipvs,${MY_pfx_build_mod}) 13 MY_pf4_build_mod := $(filter-out ${MY_excluded_modules} dccp ipvs,${MY_pf4_build_mod}) 14 MY_pf6_build_mod := $(filter-out ${MY_excluded_modules} dccp ipvs,${MY_pf6_build_mod}) 15 MY_pfx_objs := $(patsubst %,libxt_%.o,${MY_pfx_build_mod}) 16 MY_pf4_objs := $(patsubst %,libipt_%.o,${MY_pf4_build_mod}) 17 MY_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 23 include $(CLEAR_VARS) 24 25 LOCAL_MODULE_TAGS:= 26 LOCAL_MODULE:=libext 27 28 # LOCAL_MODULE_CLASS must be defined before calling $(local-intermediates-dir) 29 # 30 LOCAL_MODULE_CLASS := STATIC_LIBRARIES 31 MY_intermediates := $(call local-intermediates-dir) 32 33 # LOCAL_PATH needed because of dirty #include "blabla.c" 34 LOCAL_C_INCLUDES:= \ 35 $(LOCAL_PATH)/../include/ \ 36 $(KERNEL_HEADERS) \ 37 $(MY_intermediates) \ 38 $(LOCAL_PATH) 39 40 LOCAL_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 43 LOCAL_CFLAGS+=-DXTABLES_INTERNAL 44 # Accommodate arm-eabi-4.4.3 tools that don't set __ANDROID__ 45 LOCAL_CFLAGS+=-D__ANDROID__ 46 47 MY_initext_func := $(addprefix xt_,${MY_pfx_build_mod}) 48 MY_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 65 MY_lib_sources:= \ 66 $(patsubst %,$(LOCAL_PATH)/libxt_%.c,${MY_pfx_build_mod}) 67 68 MY_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 79 LOCAL_GENERATED_SOURCES:= $(MY_GEN_INITEXT) $(MY_gen_lib_sources) 80 81 include $(BUILD_STATIC_LIBRARY) 82 83 #---------------------------------------------------------------- 84 # libext4 85 86 include $(CLEAR_VARS) 87 88 LOCAL_MODULE_TAGS:= 89 LOCAL_MODULE:=libext4 90 91 # LOCAL_MODULE_CLASS must be defined before calling $(local-intermediates-dir) 92 # 93 LOCAL_MODULE_CLASS := STATIC_LIBRARIES 94 MY_intermediates := $(call local-intermediates-dir) 95 96 # LOCAL_PATH needed because of dirty #include "blabla.c" 97 LOCAL_C_INCLUDES:= \ 98 $(LOCAL_PATH)/../include/ \ 99 $(KERNEL_HEADERS) \ 100 $(MY_intermediates)/ \ 101 $(LOCAL_PATH)/ 102 103 LOCAL_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 106 LOCAL_CFLAGS+=-DXTABLES_INTERNAL 107 # Accommodate arm-eabi-4.4.3 tools that don't set __ANDROID__ 108 LOCAL_CFLAGS+=-D__ANDROID__ 109 110 MY_initext4_func := $(addprefix ipt_,${MY_pf4_build_mod}) 111 MY_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 128 MY_lib_sources:= \ 129 $(patsubst %,$(LOCAL_PATH)/libipt_%.c,${MY_pf4_build_mod}) 130 131 MY_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 142 LOCAL_GENERATED_SOURCES:= $(MY_GEN_INITEXT4) ${MY_gen_lib_sources} 143 144 include $(BUILD_STATIC_LIBRARY) 145 146 #---------------------------------------------------------------- 147 # libext6 148 149 include $(CLEAR_VARS) 150 151 LOCAL_MODULE_TAGS:= 152 LOCAL_MODULE:=libext6 153 154 # LOCAL_MODULE_CLASS must be defined before calling $(local-intermediates-dir) 155 # 156 LOCAL_MODULE_CLASS := STATIC_LIBRARIES 157 MY_intermediates := $(call local-intermediates-dir) 158 159 # LOCAL_PATH needed because of dirty #include "blabla.c" 160 LOCAL_C_INCLUDES:= \ 161 $(LOCAL_PATH)/../include/ \ 162 $(KERNEL_HEADERS) \ 163 $(MY_intermediates) \ 164 $(LOCAL_PATH) 165 166 LOCAL_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 169 LOCAL_CFLAGS+=-DXTABLES_INTERNAL 170 # Accommodate arm-eabi-4.4.3 tools that don't set __ANDROID__ 171 LOCAL_CFLAGS+=-D__ANDROID__ 172 173 MY_initext6_func := $(addprefix ip6t_,${MY_pf6_build_mod}) 174 MY_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 191 MY_lib_sources:= \ 192 $(patsubst %,$(LOCAL_PATH)/libip6t_%.c,${MY_pf6_build_mod}) 193 194 MY_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 205 LOCAL_GENERATED_SOURCES:= $(MY_GEN_INITEXT6) $(MY_gen_lib_sources) 206 207 include $(BUILD_STATIC_LIBRARY) 208 209 #---------------------------------------------------------------- 210