blob: bd33fdd8103a753492fab63e84044b0270f6e68e [file] [log] [blame]
Kenny Root0e27f2a2013-09-16 13:58:19 -07001# -*- 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
Colin Crossb77aef42015-03-30 17:23:41 -070043local_javac_flags:=-Xmaxwarns 9999999
Kenny Root0e27f2a2013-09-16 13:58:19 -070044#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
Kenny Root0e27f2a2013-09-16 13:58:19 -070045
Kenny Root18ed3be2014-11-24 10:57:37 -080046core_cflags := -Wall -Wextra -Werror -Wunused
47core_cppflags := -std=gnu++11 -Wall -Wextra -Werror -Wunused
Kenny Root0e27f2a2013-09-16 13:58:19 -070048
49#
50# Build for the target (device).
51#
52
Kenny Root1cfba2b2014-05-27 18:44:53 +000053# Create the conscrypt library
54include $(CLEAR_VARS)
55LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
Kenny Root39deada2014-05-30 13:15:27 -070056LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
Brian Carlstromecd29ab2014-06-18 15:11:01 -070057LOCAL_JAVA_LIBRARIES := core-libart
Kenny Root1cfba2b2014-05-27 18:44:53 +000058LOCAL_NO_STANDARD_LIBRARIES := true
59LOCAL_JAVACFLAGS := $(local_javac_flags)
60LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
61LOCAL_MODULE_TAGS := optional
62LOCAL_MODULE := conscrypt
63LOCAL_REQUIRED_MODULES := libjavacrypto
64LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
65include $(BUILD_JAVA_LIBRARY)
66
67# Create the conscrypt library without jarjar for tests
68include $(CLEAR_VARS)
Kenny Root0e27f2a2013-09-16 13:58:19 -070069LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
Kenny Root39deada2014-05-30 13:15:27 -070070LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
Brian Carlstromecd29ab2014-06-18 15:11:01 -070071LOCAL_JAVA_LIBRARIES := core-libart
Kenny Root0e27f2a2013-09-16 13:58:19 -070072LOCAL_NO_STANDARD_LIBRARIES := true
73LOCAL_JAVACFLAGS := $(local_javac_flags)
74LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -070075LOCAL_MODULE := conscrypt-nojarjar
Kenny Root0e27f2a2013-09-16 13:58:19 -070076LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
77include $(BUILD_STATIC_JAVA_LIBRARY)
78
79ifeq ($(LIBCORE_SKIP_TESTS),)
80# Make the conscrypt-tests library.
81include $(CLEAR_VARS)
82LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java)
83LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstromecd29ab2014-06-18 15:11:01 -070084LOCAL_JAVA_LIBRARIES := core-libart core-junit bouncycastle
Kenny Root0e27f2a2013-09-16 13:58:19 -070085LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support conscrypt-nojarjar
86LOCAL_JAVACFLAGS := $(local_javac_flags)
87LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -070088LOCAL_MODULE := conscrypt-tests
Kenny Root0e27f2a2013-09-16 13:58:19 -070089LOCAL_REQUIRED_MODULES := libjavacrypto
90LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
91LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
92include $(BUILD_STATIC_JAVA_LIBRARY)
93endif
94
95# Platform conscrypt crypto JNI library
96include $(CLEAR_VARS)
Adam Langley24144a82015-01-26 14:54:30 -080097ifneq (,$(wildcard $(TOP)/external/boringssl/flavor.mk))
98 include $(TOP)/external/boringssl/flavor.mk
99else
100 include $(TOP)/external/openssl/flavor.mk
101endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700102LOCAL_CFLAGS += $(core_cflags)
103LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/"
104LOCAL_CPPFLAGS += $(core_cppflags)
105LOCAL_SRC_FILES := \
106 src/main/native/org_conscrypt_NativeCrypto.cpp
Kenny Root0a84a212013-10-01 17:48:03 -0700107LOCAL_C_INCLUDES += \
108 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700109 external/openssl \
Kenny Root0a84a212013-10-01 17:48:03 -0700110 libcore/include \
Kenny Root0e27f2a2013-09-16 13:58:19 -0700111 libcore/luni/src/main/native
Kenny Root0a84a212013-10-01 17:48:03 -0700112LOCAL_SHARED_LIBRARIES := libcrypto libjavacore liblog libnativehelper libssl libz
Adam Langleyde5225d2014-10-06 15:55:30 -0700113ifeq ($(OPENSSL_FLAVOR),BoringSSL)
114 LOCAL_SHARED_LIBRARIES += libkeystore-engine
Adam Langleyde5225d2014-10-06 15:55:30 -0700115endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700116LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700117LOCAL_MODULE := libjavacrypto
Kenny Root0e27f2a2013-09-16 13:58:19 -0700118LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
119include $(BUILD_SHARED_LIBRARY)
120
Kenny Root3e46e4e2014-05-23 13:35:10 -0700121# Unbundled Conscrypt jar
122include $(CLEAR_VARS)
Kenny Root39deada2014-05-30 13:15:27 -0700123LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
124LOCAL_SRC_FILES += $(call all-java-files-under,src/compat/java)
Kenny Root3e46e4e2014-05-23 13:35:10 -0700125LOCAL_SDK_VERSION := 9
126LOCAL_JAVACFLAGS := $(local_javac_flags)
127LOCAL_MODULE_TAGS := optional
Kenny Root031510f2014-05-29 13:53:05 -0700128LOCAL_MODULE := conscrypt_unbundled
Chad Brubaker62190cd2015-04-03 12:17:33 -0700129LOCAL_JAVA_LIBRARIES := conscrypt-stubs
Kenny Root3e46e4e2014-05-23 13:35:10 -0700130LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
131include $(BUILD_STATIC_JAVA_LIBRARY)
132
Chad Brubaker62190cd2015-04-03 12:17:33 -0700133# Stub library for unbundled builds
134include $(CLEAR_VARS)
135LOCAL_SRC_FILES := $(call all-java-files-under,src/stub/java)
Kenny Root7cb0a4a2015-04-22 16:36:16 -0700136LOCAL_SDK_VERSION := 9
137LOCAL_JAVACFLAGS := $(local_javac_flags)
Chad Brubaker62190cd2015-04-03 12:17:33 -0700138LOCAL_MODULE := conscrypt-stubs
Kenny Root7cb0a4a2015-04-22 16:36:16 -0700139LOCAL_JACK_FLAGS := -D jack.classpath.default-libraries=false
Chad Brubaker62190cd2015-04-03 12:17:33 -0700140include $(BUILD_STATIC_JAVA_LIBRARY)
141
Kenny Root3e46e4e2014-05-23 13:35:10 -0700142# Unbundled Conscrypt crypto JNI library
143include $(CLEAR_VARS)
144LOCAL_CFLAGS += $(core_cflags)
145LOCAL_CPPFLAGS += $(core_cppflags)
146LOCAL_SRC_FILES := \
147 src/main/native/org_conscrypt_NativeCrypto.cpp \
Kenny Rootf24ba062014-06-09 10:37:46 -0700148 src/compat/native/JNIHelp.cpp
Kenny Root3e46e4e2014-05-23 13:35:10 -0700149LOCAL_C_INCLUDES += \
150 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700151 external/openssl \
152 external/conscrypt/src/compat/native
Adam Langleyde5225d2014-10-06 15:55:30 -0700153# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
154# the keystore ENGINE. It is not available in this build configuration.
155LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root031510f2014-05-29 13:53:05 -0700156LOCAL_LDFLAGS := -llog -lz -ldl
Kenny Root3e46e4e2014-05-23 13:35:10 -0700157LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
158LOCAL_MODULE_TAGS := optional
159LOCAL_MODULE := libconscrypt_jni
160LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
161LOCAL_SDK_VERSION := 9
162include $(BUILD_SHARED_LIBRARY)
163
Justin Moreye66dbe52014-06-10 14:35:13 -0500164# Static unbundled Conscrypt crypto JNI library
165include $(CLEAR_VARS)
166LOCAL_CFLAGS += $(core_cflags)
167LOCAL_CPPFLAGS += $(core_cppflags) -DJNI_JARJAR_PREFIX="com/google/android/gms/" -DCONSCRYPT_UNBUNDLED -DSTATIC_LIB
168LOCAL_SRC_FILES := \
169 src/main/native/org_conscrypt_NativeCrypto.cpp \
170 src/compat/native/JNIHelp.cpp
171LOCAL_C_INCLUDES += \
172 external/openssl/include \
173 external/openssl \
174 external/conscrypt/src/compat/native
175LOCAL_MODULE_TAGS := optional
176LOCAL_MODULE := libconscrypt_static
177LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langley0ccc17a2015-02-25 11:37:23 -0800178LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
Justin Moreye66dbe52014-06-10 14:35:13 -0500179LOCAL_SDK_VERSION := 9
180include $(BUILD_STATIC_LIBRARY)
181
Kenny Root0e27f2a2013-09-16 13:58:19 -0700182#
183# Build for the host.
184#
185
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800186ifeq ($(HOST_OS),linux)
187
Ian Rogers3a03c732014-05-23 11:53:18 -0700188# Make the conscrypt-hostdex library
189include $(CLEAR_VARS)
190LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
191LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
192LOCAL_JAVACFLAGS := $(local_javac_flags)
193LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
194LOCAL_MODULE_TAGS := optional
195LOCAL_MODULE := conscrypt-hostdex
196LOCAL_REQUIRED_MODULES := libjavacrypto
197LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
198include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root1cfba2b2014-05-27 18:44:53 +0000199
Ian Rogers3a03c732014-05-23 11:53:18 -0700200# Make the conscrypt-hostdex-nojarjar for tests
201include $(CLEAR_VARS)
202LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
203LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
204LOCAL_JAVACFLAGS := $(local_javac_flags)
205LOCAL_BUILD_HOST_DEX := true
206LOCAL_MODULE_TAGS := optional
207LOCAL_MODULE := conscrypt-hostdex-nojarjar
208LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
209include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700210
Ian Rogers3a03c732014-05-23 11:53:18 -0700211# Make the conscrypt-tests library.
212ifeq ($(LIBCORE_SKIP_TESTS),)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700213 include $(CLEAR_VARS)
214 LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java)
Narayan Kamathb32d6792013-10-28 14:22:43 +0000215 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex conscrypt-hostdex-nojarjar
Kenny Root0e27f2a2013-09-16 13:58:19 -0700216 LOCAL_JAVACFLAGS := $(local_javac_flags)
217 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700218 LOCAL_MODULE := conscrypt-tests-hostdex
Kenny Root0e27f2a2013-09-16 13:58:19 -0700219 LOCAL_REQUIRED_MODULES := libjavacrypto
220 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Narayan Kamathb32d6792013-10-28 14:22:43 +0000221 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Ian Rogers3a03c732014-05-23 11:53:18 -0700222endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700223
Ian Rogers3a03c732014-05-23 11:53:18 -0700224# Conscrypt native library for host
225include $(CLEAR_VARS)
226LOCAL_CLANG := true
227LOCAL_SRC_FILES += \
228 src/main/native/org_conscrypt_NativeCrypto.cpp
229LOCAL_C_INCLUDES += \
230 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700231 external/openssl \
Ian Rogers3a03c732014-05-23 11:53:18 -0700232 libcore/include \
233 libcore/luni/src/main/native
234LOCAL_CPPFLAGS += $(core_cppflags)
235LOCAL_LDLIBS += -lpthread
236LOCAL_MODULE_TAGS := optional
237LOCAL_MODULE := libjavacrypto
238LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/"
Adam Langleyde5225d2014-10-06 15:55:30 -0700239# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
240# the keystore ENGINE. It is not available in this build configuration.
241LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Ian Rogers3a03c732014-05-23 11:53:18 -0700242LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
243LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700244LOCAL_MULTILIB := both
Ian Rogers3a03c732014-05-23 11:53:18 -0700245include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700246
Ian Rogers3a03c732014-05-23 11:53:18 -0700247# Conscrypt native library for nojarjar'd version
248# Don't build this for unbundled conscrypt build
249ifeq (,$(TARGET_BUILD_APPS))
Kenny Root0e27f2a2013-09-16 13:58:19 -0700250 include $(CLEAR_VARS)
Ian Rogers3a03c732014-05-23 11:53:18 -0700251 LOCAL_CLANG := true
Kenny Root0e27f2a2013-09-16 13:58:19 -0700252 LOCAL_SRC_FILES += \
253 src/main/native/org_conscrypt_NativeCrypto.cpp
Kenny Root0a84a212013-10-01 17:48:03 -0700254 LOCAL_C_INCLUDES += \
255 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700256 external/openssl \
Kenny Root0a84a212013-10-01 17:48:03 -0700257 libcore/include \
Kenny Root0e27f2a2013-09-16 13:58:19 -0700258 libcore/luni/src/main/native
Kenny Root3e46e4e2014-05-23 13:35:10 -0700259 LOCAL_CPPFLAGS += $(core_cppflags) -DCONSCRYPT_NOT_UNBUNDLED
Kenny Root0e27f2a2013-09-16 13:58:19 -0700260 LOCAL_LDLIBS += -lpthread
261 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700262 LOCAL_MODULE := libconscrypt_jni
Kenny Root0e27f2a2013-09-16 13:58:19 -0700263 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langleyde5225d2014-10-06 15:55:30 -0700264 # NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to
265 # support the keystore ENGINE. It is not available in this build
266 # configuration.
267 LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root7150e322013-10-01 19:54:34 -0700268 LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700269 LOCAL_MULTILIB := both
Kenny Root0e27f2a2013-09-16 13:58:19 -0700270 include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700271endif
Kenny Root18ed3be2014-11-24 10:57:37 -0800272
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800273endif # HOST_OS == linux
274
Kenny Root18ed3be2014-11-24 10:57:37 -0800275# clear out local variables
276core_cflags :=
277core_cppflags :=
278local_javac_flags :=