| 1 | # Copyright (C) 2009 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| 15 | # |
| 16 | LOCAL_PATH := $(call my-dir) |
| 17 | ROOT_PATH := $(LOCAL_PATH) |
| 18 | |
| 19 | BUILD_SHARED_EXECUTABLE := $(LOCAL_PATH)/build-shared-executable.mk |
| 20 | |
| 21 | ######################################################## |
| 22 | ## libsodium |
| 23 | ######################################################## |
| 24 | |
| 25 | include $(CLEAR_VARS) |
| 26 | |
| 27 | SODIUM_SOURCE := \ |
| 28 | crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c \ |
| 29 | crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c \ |
| 30 | crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c \ |
| 31 | crypto_core/ed25519/ref10/ed25519_ref10.c \ |
| 32 | crypto_core/hchacha20/core_hchacha20.c \ |
| 33 | crypto_core/salsa/ref/core_salsa_ref.c \ |
| 34 | crypto_generichash/blake2b/ref/blake2b-compress-ref.c \ |
| 35 | crypto_generichash/blake2b/ref/blake2b-ref.c \ |
| 36 | crypto_generichash/blake2b/ref/generichash_blake2b.c \ |
| 37 | crypto_onetimeauth/poly1305/onetimeauth_poly1305.c \ |
| 38 | crypto_onetimeauth/poly1305/donna/poly1305_donna.c \ |
| 39 | crypto_pwhash/crypto_pwhash.c \ |
| 40 | crypto_pwhash/argon2/argon2-core.c \ |
| 41 | crypto_pwhash/argon2/argon2.c \ |
| 42 | crypto_pwhash/argon2/argon2-encoding.c \ |
| 43 | crypto_pwhash/argon2/argon2-fill-block-ref.c \ |
| 44 | crypto_pwhash/argon2/blake2b-long.c \ |
| 45 | crypto_pwhash/argon2/pwhash_argon2i.c \ |
| 46 | crypto_scalarmult/curve25519/scalarmult_curve25519.c \ |
| 47 | crypto_scalarmult/curve25519/ref10/x25519_ref10.c \ |
| 48 | crypto_stream/chacha20/stream_chacha20.c \ |
| 49 | crypto_stream/chacha20/ref/chacha20_ref.c \ |
| 50 | crypto_stream/salsa20/stream_salsa20.c \ |
| 51 | crypto_stream/salsa20/ref/salsa20_ref.c \ |
| 52 | crypto_verify/sodium/verify.c \ |
| 53 | randombytes/randombytes.c \ |
| 54 | randombytes/sysrandom/randombytes_sysrandom.c \ |
| 55 | sodium/core.c \ |
| 56 | sodium/runtime.c \ |
| 57 | sodium/utils.c \ |
| 58 | sodium/version.c |
| 59 | |
| 60 | LOCAL_MODULE := sodium |
| 61 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/libsodium/src/libsodium/include \ |
| 62 | -I$(LOCAL_PATH)/include \ |
| 63 | -I$(LOCAL_PATH)/include/sodium \ |
| 64 | -I$(LOCAL_PATH)/libsodium/src/libsodium/include/sodium \ |
| 65 | -DPACKAGE_NAME=\"libsodium\" -DPACKAGE_TARNAME=\"libsodium\" \ |
| 66 | -DPACKAGE_VERSION=\"1.0.15\" -DPACKAGE_STRING=\"libsodium-1.0.15\" \ |
| 67 | -DPACKAGE_BUGREPORT=\"https://github.com/jedisct1/libsodium/issues\" \ |
| 68 | -DPACKAGE_URL=\"https://github.com/jedisct1/libsodium\" \ |
| 69 | -DPACKAGE=\"libsodium\" -DVERSION=\"1.0.15\" \ |
| 70 | -DHAVE_PTHREAD=1 \ |
| 71 | -DSTDC_HEADERS=1 \ |
| 72 | -DHAVE_SYS_TYPES_H=1 \ |
| 73 | -DHAVE_SYS_STAT_H=1 \ |
| 74 | -DHAVE_STDLIB_H=1 \ |
| 75 | -DHAVE_STRING_H=1 \ |
| 76 | -DHAVE_MEMORY_H=1 \ |
| 77 | -DHAVE_STRINGS_H=1 \ |
| 78 | -DHAVE_INTTYPES_H=1 \ |
| 79 | -DHAVE_STDINT_H=1 \ |
| 80 | -DHAVE_UNISTD_H=1 \ |
| 81 | -D__EXTENSIONS__=1 \ |
| 82 | -D_ALL_SOURCE=1 \ |
| 83 | -D_GNU_SOURCE=1 \ |
| 84 | -D_POSIX_PTHREAD_SEMANTICS=1 \ |
| 85 | -D_TANDEM_SOURCE=1 \ |
| 86 | -DHAVE_DLFCN_H=1 \ |
| 87 | -DLT_OBJDIR=\".libs/\" \ |
| 88 | -DHAVE_SYS_MMAN_H=1 \ |
| 89 | -DNATIVE_LITTLE_ENDIAN=1 \ |
| 90 | -DASM_HIDE_SYMBOL=.hidden \ |
| 91 | -DHAVE_WEAK_SYMBOLS=1 \ |
| 92 | -DHAVE_ATOMIC_OPS=1 \ |
| 93 | -DHAVE_ARC4RANDOM=1 \ |
| 94 | -DHAVE_ARC4RANDOM_BUF=1 \ |
| 95 | -DHAVE_MMAP=1 \ |
| 96 | -DHAVE_MLOCK=1 \ |
| 97 | -DHAVE_MADVISE=1 \ |
| 98 | -DHAVE_MPROTECT=1 \ |
| 99 | -DHAVE_NANOSLEEP=1 \ |
| 100 | -DHAVE_POSIX_MEMALIGN=1 \ |
| 101 | -DHAVE_GETPID=1 \ |
| 102 | -DCONFIGURED=1 |
| 103 | |
| 104 | LOCAL_SRC_FILES := $(addprefix libsodium/src/libsodium/,$(SODIUM_SOURCE)) |
| 105 | |
| 106 | include $(BUILD_STATIC_LIBRARY) |
| 107 | |
| 108 | ######################################################## |
| 109 | ## libancillary |
| 110 | ######################################################## |
| 111 | |
| 112 | include $(CLEAR_VARS) |
| 113 | |
| 114 | ANCILLARY_SOURCE := fd_recv.c fd_send.c |
| 115 | |
| 116 | LOCAL_MODULE := libancillary |
| 117 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/libancillary |
| 118 | |
| 119 | LOCAL_SRC_FILES := $(addprefix libancillary/, $(ANCILLARY_SOURCE)) |
| 120 | |
| 121 | include $(BUILD_STATIC_LIBRARY) |
| 122 | |
| 123 | ######################################################## |
| 124 | ## libipset |
| 125 | ######################################################## |
| 126 | |
| 127 | include $(CLEAR_VARS) |
| 128 | |
| 129 | bdd_src = bdd/assignments.c bdd/basics.c bdd/bdd-iterator.c bdd/expanded.c \ |
| 130 | bdd/reachable.c bdd/read.c bdd/write.c |
| 131 | map_src = map/allocation.c map/inspection.c map/ipv4_map.c map/ipv6_map.c \ |
| 132 | map/storage.c |
| 133 | set_src = set/allocation.c set/inspection.c set/ipv4_set.c set/ipv6_set.c \ |
| 134 | set/iterator.c set/storage.c |
| 135 | |
| 136 | IPSET_SOURCE := general.c $(bdd_src) $(map_src) $(set_src) |
| 137 | |
| 138 | LOCAL_MODULE := libipset |
| 139 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/shadowsocks-libev/libipset/include \ |
| 140 | -I$(LOCAL_PATH)/shadowsocks-libev/libcork/include |
| 141 | |
| 142 | LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/libipset/,$(IPSET_SOURCE)) |
| 143 | |
| 144 | include $(BUILD_STATIC_LIBRARY) |
| 145 | |
| 146 | ######################################################## |
| 147 | ## libcork |
| 148 | ######################################################## |
| 149 | |
| 150 | include $(CLEAR_VARS) |
| 151 | |
| 152 | cli_src := cli/commands.c |
| 153 | core_src := core/allocator.c core/error.c core/gc.c \ |
| 154 | core/hash.c core/ip-address.c core/mempool.c \ |
| 155 | core/timestamp.c core/u128.c |
| 156 | ds_src := ds/array.c ds/bitset.c ds/buffer.c ds/dllist.c \ |
| 157 | ds/file-stream.c ds/hash-table.c ds/managed-buffer.c \ |
| 158 | ds/ring-buffer.c ds/slice.c |
| 159 | posix_src := posix/directory-walker.c posix/env.c posix/exec.c \ |
| 160 | posix/files.c posix/process.c posix/subprocess.c |
| 161 | pthreads_src := pthreads/thread.c |
| 162 | |
| 163 | CORK_SOURCE := $(cli_src) $(core_src) $(ds_src) $(posix_src) $(pthreads_src) |
| 164 | |
| 165 | LOCAL_MODULE := libcork |
| 166 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/shadowsocks-libev/libcork/include \ |
| 167 | -DCORK_API=CORK_LOCAL |
| 168 | |
| 169 | LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/libcork/,$(CORK_SOURCE)) |
| 170 | |
| 171 | include $(BUILD_STATIC_LIBRARY) |
| 172 | |
| 173 | ######################################################## |
| 174 | ## libudns |
| 175 | ######################################################## |
| 176 | |
| 177 | include $(CLEAR_VARS) |
| 178 | |
| 179 | UDNS_SOURCES := udns_dn.c udns_dntosp.c udns_parse.c udns_resolver.c udns_init.c \ |
| 180 | udns_misc.c udns_XtoX.c \ |
| 181 | udns_rr_a.c udns_rr_ptr.c udns_rr_mx.c udns_rr_txt.c udns_bl.c \ |
| 182 | udns_rr_srv.c udns_rr_naptr.c udns_codes.c udns_jran.c |
| 183 | |
| 184 | LOCAL_MODULE := libudns |
| 185 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/shadowsocks-libev/libudns \ |
| 186 | -DHAVE_DECL_INET_NTOP |
| 187 | |
| 188 | LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/libudns/,$(UDNS_SOURCES)) |
| 189 | |
| 190 | include $(BUILD_STATIC_LIBRARY) |
| 191 | |
| 192 | ######################################################## |
| 193 | ## libev |
| 194 | ######################################################## |
| 195 | |
| 196 | include $(CLEAR_VARS) |
| 197 | |
| 198 | LOCAL_MODULE := libev |
| 199 | LOCAL_CFLAGS += -I$(LOCAL_PATH)/include/libev |
| 200 | LOCAL_SRC_FILES := \ |
| 201 | shadowsocks-libev/libev/ev.c \ |
| 202 | shadowsocks-libev/libev/event.c |
| 203 | |
| 204 | include $(BUILD_STATIC_LIBRARY) |
| 205 | |
| 206 | ######################################################## |
| 207 | ## shadowsocks-libev local |
| 208 | ######################################################## |
| 209 | |
| 210 | include $(CLEAR_VARS) |
| 211 | |
| 212 | SHADOWSOCKS_SOURCES := local.c cache.c udprelay.c encrypt.c \ |
| 213 | utils.c netutils.c json.c jconf.c acl.c http.c tls.c rule.c \ |
| 214 | android.c |
| 215 | |
| 216 | LOCAL_MODULE := ssr-local |
| 217 | LOCAL_SRC_FILES := $(addprefix shadowsocks-libev/src/, $(SHADOWSOCKS_SOURCES)) |
| 218 | LOCAL_CFLAGS := -Wall -fno-strict-aliasing -DMODULE_LOCAL \ |
| 219 | -DUSE_CRYPTO_MBEDTLS -DANDROID -DHAVE_CONFIG_H \ |
| 220 | -DCONNECT_IN_PROGRESS=EINPROGRESS \ |
| 221 | -I$(LOCAL_PATH)/include/shadowsocks-libev \ |
| 222 | -I$(LOCAL_PATH)/include \ |
| 223 | -I$(LOCAL_PATH)/libancillary \ |
| 224 | -I$(LOCAL_PATH)/mbedtls/include \ |
| 225 | -I$(LOCAL_PATH)/pcre \ |
| 226 | -I$(LOCAL_PATH)/shadowsocks-libev/libudns \ |
| 227 | -I$(LOCAL_PATH)/shadowsocks-libev/libcork/include \ |
| 228 | -I$(LOCAL_PATH)/libsodium/src/libsodium/include \ |
| 229 | -I$(LOCAL_PATH)/libsodium/src/libsodium/include/sodium \ |
| 230 | -I$(LOCAL_PATH)/shadowsocks-libev/libipset/include \ |
| 231 | -I$(LOCAL_PATH)/shadowsocks-libev/libev \ |
| 232 | -I$(LOCAL_PATH)/shadowsocks-libev/src |
| 233 | |
| 234 | LOCAL_STATIC_LIBRARIES := libev libmbedtls libipset libcork libudns \ |
| 235 | libsodium libancillary libpcre |
| 236 | |
| 237 | LOCAL_LDLIBS := -llog |
| 238 | |
| 239 | include $(BUILD_SHARED_EXECUTABLE) |
| 240 | |
| 241 | ######################################################## |
| 242 | ## mbed TLS |
| 243 | ######################################################## |
| 244 | |
| 245 | include $(CLEAR_VARS) |
| 246 | |
| 247 | LOCAL_MODULE := mbedtls |
| 248 | |
| 249 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/mbedtls/include |
| 250 | |
| 251 | MBEDTLS_SOURCES := $(wildcard $(LOCAL_PATH)/mbedtls/library/*.c) |
| 252 | |
| 253 | LOCAL_SRC_FILES := $(MBEDTLS_SOURCES:$(LOCAL_PATH)/%=%) |
| 254 | |
| 255 | include $(BUILD_STATIC_LIBRARY) |
| 256 | |
| 257 | ######################################################## |
| 258 | ## pcre |
| 259 | ######################################################## |
| 260 | |
| 261 | include $(CLEAR_VARS) |
| 262 | |
| 263 | LOCAL_MODULE := pcre |
| 264 | |
| 265 | LOCAL_CFLAGS += -DHAVE_CONFIG_H |
| 266 | |
| 267 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/pcre/dist $(LOCAL_PATH)/pcre |
| 268 | |
| 269 | libpcre_src_files := \ |
| 270 | dist/pcre_byte_order.c \ |
| 271 | dist/pcre_compile.c \ |
| 272 | dist/pcre_config.c \ |
| 273 | dist/pcre_dfa_exec.c \ |
| 274 | dist/pcre_exec.c \ |
| 275 | dist/pcre_fullinfo.c \ |
| 276 | dist/pcre_get.c \ |
| 277 | dist/pcre_globals.c \ |
| 278 | dist/pcre_jit_compile.c \ |
| 279 | dist/pcre_maketables.c \ |
| 280 | dist/pcre_newline.c \ |
| 281 | dist/pcre_ord2utf8.c \ |
| 282 | dist/pcre_refcount.c \ |
| 283 | dist/pcre_string_utils.c \ |
| 284 | dist/pcre_study.c \ |
| 285 | dist/pcre_tables.c \ |
| 286 | dist/pcre_ucd.c \ |
| 287 | dist/pcre_valid_utf8.c \ |
| 288 | dist/pcre_version.c \ |
| 289 | dist/pcre_xclass.c |
| 290 | |
| 291 | LOCAL_SRC_FILES := $(addprefix pcre/, $(libpcre_src_files)) $(LOCAL_PATH)/patch/pcre/pcre_chartables.c |
| 292 | |
| 293 | include $(BUILD_STATIC_LIBRARY) |