blob: 8359c2e8982da8beed2bc97ec714b340473abd91 [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)
136LOCAL_MODULE := conscrypt-stubs
137include $(BUILD_STATIC_JAVA_LIBRARY)
138
Kenny Root3e46e4e2014-05-23 13:35:10 -0700139# Unbundled Conscrypt crypto JNI library
140include $(CLEAR_VARS)
141LOCAL_CFLAGS += $(core_cflags)
142LOCAL_CPPFLAGS += $(core_cppflags)
143LOCAL_SRC_FILES := \
144 src/main/native/org_conscrypt_NativeCrypto.cpp \
Kenny Rootf24ba062014-06-09 10:37:46 -0700145 src/compat/native/JNIHelp.cpp
Kenny Root3e46e4e2014-05-23 13:35:10 -0700146LOCAL_C_INCLUDES += \
147 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700148 external/openssl \
149 external/conscrypt/src/compat/native
Adam Langleyde5225d2014-10-06 15:55:30 -0700150# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
151# the keystore ENGINE. It is not available in this build configuration.
152LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root031510f2014-05-29 13:53:05 -0700153LOCAL_LDFLAGS := -llog -lz -ldl
Kenny Root3e46e4e2014-05-23 13:35:10 -0700154LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
155LOCAL_MODULE_TAGS := optional
156LOCAL_MODULE := libconscrypt_jni
157LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
158LOCAL_SDK_VERSION := 9
159include $(BUILD_SHARED_LIBRARY)
160
Justin Moreye66dbe52014-06-10 14:35:13 -0500161# Static unbundled Conscrypt crypto JNI library
162include $(CLEAR_VARS)
163LOCAL_CFLAGS += $(core_cflags)
164LOCAL_CPPFLAGS += $(core_cppflags) -DJNI_JARJAR_PREFIX="com/google/android/gms/" -DCONSCRYPT_UNBUNDLED -DSTATIC_LIB
165LOCAL_SRC_FILES := \
166 src/main/native/org_conscrypt_NativeCrypto.cpp \
167 src/compat/native/JNIHelp.cpp
168LOCAL_C_INCLUDES += \
169 external/openssl/include \
170 external/openssl \
171 external/conscrypt/src/compat/native
172LOCAL_MODULE_TAGS := optional
173LOCAL_MODULE := libconscrypt_static
174LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langley0ccc17a2015-02-25 11:37:23 -0800175LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
Justin Moreye66dbe52014-06-10 14:35:13 -0500176LOCAL_SDK_VERSION := 9
177include $(BUILD_STATIC_LIBRARY)
178
Kenny Root0e27f2a2013-09-16 13:58:19 -0700179#
180# Build for the host.
181#
182
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800183ifeq ($(HOST_OS),linux)
184
Ian Rogers3a03c732014-05-23 11:53:18 -0700185# Make the conscrypt-hostdex library
186include $(CLEAR_VARS)
187LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
188LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
189LOCAL_JAVACFLAGS := $(local_javac_flags)
190LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
191LOCAL_MODULE_TAGS := optional
192LOCAL_MODULE := conscrypt-hostdex
193LOCAL_REQUIRED_MODULES := libjavacrypto
194LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
195include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root1cfba2b2014-05-27 18:44:53 +0000196
Ian Rogers3a03c732014-05-23 11:53:18 -0700197# Make the conscrypt-hostdex-nojarjar for tests
198include $(CLEAR_VARS)
199LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
200LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
201LOCAL_JAVACFLAGS := $(local_javac_flags)
202LOCAL_BUILD_HOST_DEX := true
203LOCAL_MODULE_TAGS := optional
204LOCAL_MODULE := conscrypt-hostdex-nojarjar
205LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
206include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700207
Ian Rogers3a03c732014-05-23 11:53:18 -0700208# Make the conscrypt-tests library.
209ifeq ($(LIBCORE_SKIP_TESTS),)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700210 include $(CLEAR_VARS)
211 LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java)
Narayan Kamathb32d6792013-10-28 14:22:43 +0000212 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex conscrypt-hostdex-nojarjar
Kenny Root0e27f2a2013-09-16 13:58:19 -0700213 LOCAL_JAVACFLAGS := $(local_javac_flags)
214 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700215 LOCAL_MODULE := conscrypt-tests-hostdex
Kenny Root0e27f2a2013-09-16 13:58:19 -0700216 LOCAL_REQUIRED_MODULES := libjavacrypto
217 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Narayan Kamathb32d6792013-10-28 14:22:43 +0000218 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Ian Rogers3a03c732014-05-23 11:53:18 -0700219endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700220
Ian Rogers3a03c732014-05-23 11:53:18 -0700221# Conscrypt native library for host
222include $(CLEAR_VARS)
223LOCAL_CLANG := true
224LOCAL_SRC_FILES += \
225 src/main/native/org_conscrypt_NativeCrypto.cpp
226LOCAL_C_INCLUDES += \
227 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700228 external/openssl \
Ian Rogers3a03c732014-05-23 11:53:18 -0700229 libcore/include \
230 libcore/luni/src/main/native
231LOCAL_CPPFLAGS += $(core_cppflags)
232LOCAL_LDLIBS += -lpthread
233LOCAL_MODULE_TAGS := optional
234LOCAL_MODULE := libjavacrypto
235LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/"
Adam Langleyde5225d2014-10-06 15:55:30 -0700236# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
237# the keystore ENGINE. It is not available in this build configuration.
238LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Ian Rogers3a03c732014-05-23 11:53:18 -0700239LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
240LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700241LOCAL_MULTILIB := both
Ian Rogers3a03c732014-05-23 11:53:18 -0700242include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700243
Ian Rogers3a03c732014-05-23 11:53:18 -0700244# Conscrypt native library for nojarjar'd version
245# Don't build this for unbundled conscrypt build
246ifeq (,$(TARGET_BUILD_APPS))
Kenny Root0e27f2a2013-09-16 13:58:19 -0700247 include $(CLEAR_VARS)
Ian Rogers3a03c732014-05-23 11:53:18 -0700248 LOCAL_CLANG := true
Kenny Root0e27f2a2013-09-16 13:58:19 -0700249 LOCAL_SRC_FILES += \
250 src/main/native/org_conscrypt_NativeCrypto.cpp
Kenny Root0a84a212013-10-01 17:48:03 -0700251 LOCAL_C_INCLUDES += \
252 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700253 external/openssl \
Kenny Root0a84a212013-10-01 17:48:03 -0700254 libcore/include \
Kenny Root0e27f2a2013-09-16 13:58:19 -0700255 libcore/luni/src/main/native
Kenny Root3e46e4e2014-05-23 13:35:10 -0700256 LOCAL_CPPFLAGS += $(core_cppflags) -DCONSCRYPT_NOT_UNBUNDLED
Kenny Root0e27f2a2013-09-16 13:58:19 -0700257 LOCAL_LDLIBS += -lpthread
258 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700259 LOCAL_MODULE := libconscrypt_jni
Kenny Root0e27f2a2013-09-16 13:58:19 -0700260 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langleyde5225d2014-10-06 15:55:30 -0700261 # NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to
262 # support the keystore ENGINE. It is not available in this build
263 # configuration.
264 LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root7150e322013-10-01 19:54:34 -0700265 LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700266 LOCAL_MULTILIB := both
Kenny Root0e27f2a2013-09-16 13:58:19 -0700267 include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700268endif
Kenny Root18ed3be2014-11-24 10:57:37 -0800269
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800270endif # HOST_OS == linux
271
Kenny Root18ed3be2014-11-24 10:57:37 -0800272# clear out local variables
273core_cflags :=
274core_cppflags :=
275local_javac_flags :=