1# -*- mode: makefile -*- 2# Copyright (C) 2013 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16# 17# Definitions for building the Conscrypt Java library, native code, 18# and associated tests. 19# 20 21# 22# Common definitions for host and target. 23# 24 25# Conscrypt is divided into modules. 26# 27# The structure is: 28# 29# src/ 30# main/ # To be shipped on every device. 31# java/ # Java source for library code. 32# native/ # C++ source for library code. 33# resources/ # Support files. 34# test/ # Built only on demand, for testing. 35# java/ # Java source for tests. 36# native/ # C++ source for tests (rare). 37# resources/ # Support files. 38# 39# All subdirectories are optional (hence the "2> /dev/null"s below). 40 41LOCAL_PATH := $(call my-dir) 42 43local_javac_flags=-encoding UTF-8 44#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked 45local_javac_flags+=-Xmaxwarns 9999999 46 47core_cflags := -Wall -Wextra -Werror 48core_cppflags := -std=gnu++11 49 50# 51# Build for the target (device). 52# 53 54# Create the conscrypt library 55include $(CLEAR_VARS) 56LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java) 57LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java) 58LOCAL_JAVA_LIBRARIES := core-libart 59LOCAL_NO_STANDARD_LIBRARIES := true 60LOCAL_JAVACFLAGS := $(local_javac_flags) 61LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt 62LOCAL_MODULE_TAGS := optional 63LOCAL_MODULE := conscrypt 64LOCAL_REQUIRED_MODULES := libjavacrypto 65LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 66include $(BUILD_JAVA_LIBRARY) 67 68# Create the conscrypt library without jarjar for tests 69include $(CLEAR_VARS) 70LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java) 71LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java) 72LOCAL_JAVA_LIBRARIES := core-libart 73LOCAL_NO_STANDARD_LIBRARIES := true 74LOCAL_JAVACFLAGS := $(local_javac_flags) 75LOCAL_MODULE_TAGS := optional 76LOCAL_MODULE := conscrypt-nojarjar 77LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 78include $(BUILD_STATIC_JAVA_LIBRARY) 79 80ifeq ($(LIBCORE_SKIP_TESTS),) 81# Make the conscrypt-tests library. 82include $(CLEAR_VARS) 83LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java) 84LOCAL_NO_STANDARD_LIBRARIES := true 85LOCAL_JAVA_LIBRARIES := core-libart core-junit bouncycastle 86LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support conscrypt-nojarjar 87LOCAL_JAVACFLAGS := $(local_javac_flags) 88LOCAL_MODULE_TAGS := optional 89LOCAL_MODULE := conscrypt-tests 90LOCAL_REQUIRED_MODULES := libjavacrypto 91LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt 92LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 93include $(BUILD_STATIC_JAVA_LIBRARY) 94endif 95 96# Platform conscrypt crypto JNI library 97include $(CLEAR_VARS) 98LOCAL_CFLAGS += $(core_cflags) 99LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/" 100LOCAL_CPPFLAGS += $(core_cppflags) 101LOCAL_SRC_FILES := \ 102 src/main/native/org_conscrypt_NativeCrypto.cpp 103LOCAL_C_INCLUDES += \ 104 external/openssl/include \ 105 external/openssl \ 106 libcore/include \ 107 libcore/luni/src/main/native 108LOCAL_SHARED_LIBRARIES := libcrypto libjavacore liblog libnativehelper libssl libz 109LOCAL_MODULE_TAGS := optional 110LOCAL_MODULE := libjavacrypto 111LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 112include $(BUILD_SHARED_LIBRARY) 113 114# Unbundled Conscrypt jar 115include $(CLEAR_VARS) 116LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java) 117LOCAL_SRC_FILES += $(call all-java-files-under,src/compat/java) 118LOCAL_SDK_VERSION := 9 119LOCAL_JAVACFLAGS := $(local_javac_flags) 120LOCAL_MODULE_TAGS := optional 121LOCAL_MODULE := conscrypt_unbundled 122LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 123include $(BUILD_STATIC_JAVA_LIBRARY) 124 125# Unbundled Conscrypt crypto JNI library 126include $(CLEAR_VARS) 127LOCAL_CFLAGS += $(core_cflags) 128LOCAL_CPPFLAGS += $(core_cppflags) 129LOCAL_SRC_FILES := \ 130 src/main/native/org_conscrypt_NativeCrypto.cpp \ 131 src/compat/native/JNIHelp.cpp 132LOCAL_C_INCLUDES += \ 133 external/openssl/include \ 134 external/openssl \ 135 external/conscrypt/src/compat/native 136LOCAL_LDFLAGS := -llog -lz -ldl 137LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static 138LOCAL_MODULE_TAGS := optional 139LOCAL_MODULE := libconscrypt_jni 140LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 141LOCAL_SDK_VERSION := 9 142include $(BUILD_SHARED_LIBRARY) 143 144# Static unbundled Conscrypt crypto JNI library 145include $(CLEAR_VARS) 146LOCAL_CFLAGS += $(core_cflags) 147LOCAL_CPPFLAGS += $(core_cppflags) -DJNI_JARJAR_PREFIX="com/google/android/gms/" -DCONSCRYPT_UNBUNDLED -DSTATIC_LIB 148LOCAL_SRC_FILES := \ 149 src/main/native/org_conscrypt_NativeCrypto.cpp \ 150 src/compat/native/JNIHelp.cpp 151LOCAL_C_INCLUDES += \ 152 external/openssl/include \ 153 external/openssl \ 154 external/conscrypt/src/compat/native 155LOCAL_MODULE_TAGS := optional 156LOCAL_MODULE := libconscrypt_static 157LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 158LOCAL_SDK_VERSION := 9 159include $(BUILD_STATIC_LIBRARY) 160 161# 162# Build for the host. 163# 164 165# Make the conscrypt-hostdex library 166include $(CLEAR_VARS) 167LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java) 168LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java) 169LOCAL_JAVACFLAGS := $(local_javac_flags) 170LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt 171LOCAL_MODULE_TAGS := optional 172LOCAL_MODULE := conscrypt-hostdex 173LOCAL_REQUIRED_MODULES := libjavacrypto 174LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 175include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) 176 177# Make the conscrypt-hostdex-nojarjar for tests 178include $(CLEAR_VARS) 179LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java) 180LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java) 181LOCAL_JAVACFLAGS := $(local_javac_flags) 182LOCAL_BUILD_HOST_DEX := true 183LOCAL_MODULE_TAGS := optional 184LOCAL_MODULE := conscrypt-hostdex-nojarjar 185LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 186include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) 187 188# Make the conscrypt-tests library. 189ifeq ($(LIBCORE_SKIP_TESTS),) 190 include $(CLEAR_VARS) 191 LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java) 192 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex conscrypt-hostdex-nojarjar 193 LOCAL_JAVACFLAGS := $(local_javac_flags) 194 LOCAL_MODULE_TAGS := optional 195 LOCAL_MODULE := conscrypt-tests-hostdex 196 LOCAL_REQUIRED_MODULES := libjavacrypto 197 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 198 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) 199endif 200 201# Conscrypt native library for host 202include $(CLEAR_VARS) 203LOCAL_CLANG := true 204LOCAL_SRC_FILES += \ 205 src/main/native/org_conscrypt_NativeCrypto.cpp 206LOCAL_C_INCLUDES += \ 207 external/openssl/include \ 208 external/openssl \ 209 libcore/include \ 210 libcore/luni/src/main/native 211LOCAL_CPPFLAGS += $(core_cppflags) 212LOCAL_LDLIBS += -lpthread 213LOCAL_MODULE_TAGS := optional 214LOCAL_MODULE := libjavacrypto 215LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/" 216LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 217LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host 218include $(BUILD_HOST_SHARED_LIBRARY) 219 220# Conscrypt native library for nojarjar'd version 221# Don't build this for unbundled conscrypt build 222ifeq (,$(TARGET_BUILD_APPS)) 223 include $(CLEAR_VARS) 224 LOCAL_CLANG := true 225 LOCAL_SRC_FILES += \ 226 src/main/native/org_conscrypt_NativeCrypto.cpp 227 LOCAL_C_INCLUDES += \ 228 external/openssl/include \ 229 external/openssl \ 230 libcore/include \ 231 libcore/luni/src/main/native 232 LOCAL_CPPFLAGS += $(core_cppflags) -DCONSCRYPT_NOT_UNBUNDLED 233 LOCAL_LDLIBS += -lpthread 234 LOCAL_MODULE_TAGS := optional 235 LOCAL_MODULE := libconscrypt_jni 236 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 237 LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host 238 include $(BUILD_HOST_SHARED_LIBRARY) 239endif 240