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# constants/ 30# src/gen # Generates NativeConstants.java. 31# common/ 32# src/main/java # Common Java source for all platforms. 33# src/jni/ 34# main # Common C++ source for all platforms. 35# unbundled # C++ source used for OpenJDK and unbundled Android. 36# android/ 37# src/main/java # Java source for unbundled Android. 38# openjdk/ 39# src/main/java # Java source for OpenJDK. 40# src/test 41# java/ # Java source for common tests. 42# resources/ # Support files for tests 43# platform/ 44# src/main/java # Java source for bundled Android. 45# src/test 46# java/ # Java source for bundled tests. 47# 48# All subdirectories are optional (hence the "2> /dev/null"s below). 49 50LOCAL_PATH := $(call my-dir) 51 52local_javac_flags:=-Xmaxwarns 9999999 53#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked 54 55core_cflags := -Wall -Wextra -Werror -Wunused -fvisibility=hidden 56core_cppflags := -Wall -Wextra -Werror -Wunused -fvisibility=hidden 57 58# 59# Build for the target (device). 60# 61 62include $(CLEAR_VARS) 63LOCAL_SRC_FILES := constants/src/gen/cpp/generate_constants.cpp 64LOCAL_MODULE := conscrypt_generate_constants 65LOCAL_SHARED_LIBRARIES := libcrypto libssl 66include $(BUILD_HOST_EXECUTABLE) 67 68conscrypt_generate_constants_exe := $(LOCAL_INSTALLED_MODULE) 69conscrypt_gen_java_files := $(TARGET_OUT_COMMON_GEN)/conscrypt/org/conscrypt/NativeConstants.java 70 71$(conscrypt_gen_java_files): $(conscrypt_generate_constants_exe) 72 mkdir -p $(dir $@) 73 $< > $@ 74 75common_java_files := $(call all-java-files-under,common/src/main/java) 76 77bundled_main_java_files := $(common_java_files) 78bundled_main_java_files += $(call all-java-files-under,platform/src/main/java) 79 80# Create the conscrypt library 81include $(CLEAR_VARS) 82LOCAL_SRC_FILES := $(bundled_main_java_files) 83LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files) 84LOCAL_JAVA_LIBRARIES := core-oj core-libart 85LOCAL_NO_STANDARD_LIBRARIES := true 86LOCAL_JAVACFLAGS := $(local_javac_flags) 87LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt 88LOCAL_MODULE_TAGS := optional 89LOCAL_MODULE := conscrypt 90LOCAL_REQUIRED_MODULES := libjavacrypto 91LOCAL_JAVA_LANGUAGE_VERSION := 1.7 92include $(BUILD_JAVA_LIBRARY) 93 94# A guaranteed unstripped version of conscrypt. 95# The build system may or may not strip the conscrypt jar, but this one will 96# not be stripped. See b/24535627. 97include $(CLEAR_VARS) 98LOCAL_SRC_FILES := $(bundled_main_java_files) 99LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files) 100LOCAL_JAVA_LIBRARIES := core-oj core-libart 101LOCAL_NO_STANDARD_LIBRARIES := true 102LOCAL_JAVACFLAGS := $(local_javac_flags) 103LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt 104LOCAL_MODULE_TAGS := optional 105LOCAL_MODULE := conscrypt-testdex 106LOCAL_REQUIRED_MODULES := libjavacrypto 107LOCAL_JAVA_LANGUAGE_VERSION := 1.7 108include $(BUILD_JAVA_LIBRARY) 109 110# Create the conscrypt library without jarjar for tests 111include $(CLEAR_VARS) 112LOCAL_SRC_FILES := $(bundled_main_java_files) 113LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files) 114LOCAL_JAVA_LIBRARIES := core-oj core-libart 115LOCAL_NO_STANDARD_LIBRARIES := true 116LOCAL_JAVACFLAGS := $(local_javac_flags) 117LOCAL_MODULE_TAGS := optional 118LOCAL_MODULE := conscrypt-nojarjar 119LOCAL_JAVA_LANGUAGE_VERSION := 1.7 120include $(BUILD_STATIC_JAVA_LIBRARY) 121 122bundled_test_java_files := $(call all-java-files-under,platform/src/test/java) 123bundled_test_java_files += $(call all-java-files-under,testing/src/main/java) 124bundled_test_java_files := $(foreach j,$(bundled_test_java_files),\ 125 $(if $(findstring testing/src/main/java/libcore/,$(j)),,$(j))) 126 127ifeq ($(LIBCORE_SKIP_TESTS),) 128# Make the conscrypt-tests library. 129include $(CLEAR_VARS) 130LOCAL_SRC_FILES := $(bundled_test_java_files) 131LOCAL_JAVA_RESOURCE_DIRS := openjdk/src/test/resources 132LOCAL_NO_STANDARD_LIBRARIES := true 133LOCAL_JAVA_LIBRARIES := core-oj core-libart junit bouncycastle mockito-target-minus-junit4 134LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support conscrypt-nojarjar 135LOCAL_JAVACFLAGS := $(local_javac_flags) 136LOCAL_MODULE_TAGS := optional 137LOCAL_MODULE := conscrypt-tests 138LOCAL_REQUIRED_MODULES := libjavacrypto 139LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt 140LOCAL_JAVA_LANGUAGE_VERSION := 1.7 141include $(BUILD_STATIC_JAVA_LIBRARY) 142endif 143 144# Platform conscrypt crypto JNI library 145include $(CLEAR_VARS) 146LOCAL_CFLAGS += $(core_cflags) 147LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/" 148LOCAL_CPPFLAGS += $(core_cppflags) 149LOCAL_SRC_FILES := $(call all-cpp-files-under,common/src/jni/main/cpp) 150LOCAL_C_INCLUDES += \ 151 external/openssl/include \ 152 external/openssl \ 153 libcore/include \ 154 libcore/luni/src/main/native \ 155 $(LOCAL_PATH)/common/src/jni/main/include 156LOCAL_SHARED_LIBRARIES := libcrypto libjavacore liblog libnativehelper libssl 157LOCAL_MODULE_TAGS := optional 158LOCAL_MODULE := libjavacrypto 159include $(BUILD_SHARED_LIBRARY) 160 161# Unbundled Conscrypt jar 162include $(CLEAR_VARS) 163LOCAL_SRC_FILES := $(common_java_files) 164LOCAL_SRC_FILES += $(call all-java-files-under,android/src/main/java) 165LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files) 166LOCAL_SDK_VERSION := current 167LOCAL_JAVACFLAGS := $(local_javac_flags) 168LOCAL_MODULE_TAGS := optional 169LOCAL_MODULE := conscrypt_unbundled 170LOCAL_JAVA_LIBRARIES := conscrypt-stubs 171LOCAL_JACK_FLAGS := -D jack.classpath.default-libraries=false 172LOCAL_JAVA_LANGUAGE_VERSION := 1.7 173include $(BUILD_STATIC_JAVA_LIBRARY) 174 175# Stub library for unbundled builds 176include $(CLEAR_VARS) 177LOCAL_SRC_FILES := $(call all-java-files-under,android-stub/src/main/java) 178LOCAL_SDK_VERSION := current 179LOCAL_JAVACFLAGS := $(local_javac_flags) 180LOCAL_MODULE := conscrypt-stubs 181LOCAL_JACK_FLAGS := -D jack.classpath.default-libraries=false 182LOCAL_JAVA_LANGUAGE_VERSION := 1.7 183include $(BUILD_STATIC_JAVA_LIBRARY) 184 185# Static unbundled Conscrypt crypto JNI library 186include $(CLEAR_VARS) 187LOCAL_CFLAGS += $(core_cflags) 188LOCAL_CPPFLAGS += $(core_cppflags) \ 189 -DJNI_JARJAR_PREFIX="com/google/android/gms/" \ 190 -DCONSCRYPT_UNBUNDLED \ 191 -DSTATIC_LIB 192LOCAL_SRC_FILES := $(call all-cpp-files-under,common/src/jni/main/cpp) 193LOCAL_C_INCLUDES += \ 194 external/openssl/include \ 195 external/openssl \ 196 $(LOCAL_PATH)/common/src/jni/main/include \ 197 $(LOCAL_PATH)/common/src/jni/unbundled/include 198LOCAL_MODULE_TAGS := optional 199LOCAL_MODULE := libconscrypt_static 200LOCAL_STATIC_LIBRARIES := libssl libcrypto 201LOCAL_SDK_VERSION := 9 202LOCAL_JAVA_LANGUAGE_VERSION := 1.7 203LOCAL_NDK_STL_VARIANT := c++_shared 204include $(BUILD_STATIC_LIBRARY) 205 206# 207# Build for the host. 208# 209 210ifeq ($(HOST_OS),linux) 211 212# Make the conscrypt-hostdex library 213include $(CLEAR_VARS) 214LOCAL_SRC_FILES := $(bundled_main_java_files) 215LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files) 216LOCAL_JAVACFLAGS := $(local_javac_flags) 217LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt 218LOCAL_MODULE_TAGS := optional 219LOCAL_MODULE := conscrypt-hostdex 220LOCAL_REQUIRED_MODULES := libjavacrypto 221LOCAL_JAVA_LANGUAGE_VERSION := 1.7 222include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) 223 224# Make the conscrypt-hostdex-nojarjar for tests 225include $(CLEAR_VARS) 226LOCAL_SRC_FILES := $(bundled_main_java_files) 227LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files) 228LOCAL_JAVACFLAGS := $(local_javac_flags) 229LOCAL_BUILD_HOST_DEX := true 230LOCAL_MODULE_TAGS := optional 231LOCAL_MODULE := conscrypt-hostdex-nojarjar 232LOCAL_JAVA_LANGUAGE_VERSION := 1.7 233include $(BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY) 234 235# Make the conscrypt-tests library. 236ifeq ($(LIBCORE_SKIP_TESTS),) 237 include $(CLEAR_VARS) 238 LOCAL_SRC_FILES := $(bundled_test_java_files) 239 LOCAL_JAVA_RESOURCE_DIRS := openjdk/src/test/resources 240 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex junit-hostdex core-tests-support-hostdex mockito-api-hostdex 241 LOCAL_STATIC_JAVA_LIBRARIES := conscrypt-hostdex-nojarjar 242 LOCAL_JAVACFLAGS := $(local_javac_flags) 243 LOCAL_MODULE_TAGS := optional 244 LOCAL_MODULE := conscrypt-tests-hostdex 245 LOCAL_REQUIRED_MODULES := libjavacrypto 246 LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt 247 LOCAL_JAVA_LANGUAGE_VERSION := 1.7 248 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) 249endif 250 251# Conscrypt native library for host 252include $(CLEAR_VARS) 253LOCAL_CLANG := true 254LOCAL_SRC_FILES := $(call all-cpp-files-under,common/src/jni/main/cpp) 255LOCAL_C_INCLUDES += \ 256 external/openssl/include \ 257 external/openssl \ 258 libcore/include \ 259 libcore/luni/src/main/native \ 260 $(LOCAL_PATH)/common/src/jni/main/include 261LOCAL_CPPFLAGS += $(core_cppflags) 262LOCAL_LDLIBS += -lpthread 263LOCAL_MODULE_TAGS := optional 264LOCAL_MODULE := libjavacrypto 265LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/" 266LOCAL_SHARED_LIBRARIES := libcrypto libjavacore liblog libnativehelper libssl 267LOCAL_MULTILIB := both 268include $(BUILD_HOST_SHARED_LIBRARY) 269 270endif # HOST_OS == linux 271 272# Conscrypt Java library for host OpenJDK 273include $(CLEAR_VARS) 274LOCAL_SRC_FILES := $(common_java_files) 275LOCAL_SRC_FILES += $(call all-java-files-under,openjdk/src/main/java) 276LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files) 277LOCAL_JAVACFLAGS := $(local_javac_flags) -XDignore.symbol.file 278LOCAL_MODULE_TAGS := optional 279LOCAL_MODULE := conscrypt-host 280LOCAL_JAVA_LANGUAGE_VERSION := 1.7 281include $(BUILD_HOST_JAVA_LIBRARY) 282 283# clear out local variables 284common_java_files := 285conscrypt_gen_java_files := 286conscrypt_generate_constants_exe := 287core_cflags := 288core_cppflags := 289local_javac_flags := 290bundled_test_java_files := 291