blob: 124f151aab9dd0ba533a38483098ec6a940f2725 [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
Kenny Root3e46e4e2014-05-23 13:35:10 -0700129LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
130include $(BUILD_STATIC_JAVA_LIBRARY)
131
132# Unbundled Conscrypt crypto JNI library
133include $(CLEAR_VARS)
134LOCAL_CFLAGS += $(core_cflags)
135LOCAL_CPPFLAGS += $(core_cppflags)
136LOCAL_SRC_FILES := \
137 src/main/native/org_conscrypt_NativeCrypto.cpp \
Kenny Rootf24ba062014-06-09 10:37:46 -0700138 src/compat/native/JNIHelp.cpp
Kenny Root3e46e4e2014-05-23 13:35:10 -0700139LOCAL_C_INCLUDES += \
140 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700141 external/openssl \
142 external/conscrypt/src/compat/native
Adam Langleyde5225d2014-10-06 15:55:30 -0700143# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
144# the keystore ENGINE. It is not available in this build configuration.
145LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root031510f2014-05-29 13:53:05 -0700146LOCAL_LDFLAGS := -llog -lz -ldl
Kenny Root3e46e4e2014-05-23 13:35:10 -0700147LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
148LOCAL_MODULE_TAGS := optional
149LOCAL_MODULE := libconscrypt_jni
150LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
151LOCAL_SDK_VERSION := 9
152include $(BUILD_SHARED_LIBRARY)
153
Justin Moreye66dbe52014-06-10 14:35:13 -0500154# Static unbundled Conscrypt crypto JNI library
155include $(CLEAR_VARS)
156LOCAL_CFLAGS += $(core_cflags)
157LOCAL_CPPFLAGS += $(core_cppflags) -DJNI_JARJAR_PREFIX="com/google/android/gms/" -DCONSCRYPT_UNBUNDLED -DSTATIC_LIB
158LOCAL_SRC_FILES := \
159 src/main/native/org_conscrypt_NativeCrypto.cpp \
160 src/compat/native/JNIHelp.cpp
161LOCAL_C_INCLUDES += \
162 external/openssl/include \
163 external/openssl \
164 external/conscrypt/src/compat/native
165LOCAL_MODULE_TAGS := optional
166LOCAL_MODULE := libconscrypt_static
167LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langley0ccc17a2015-02-25 11:37:23 -0800168LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
Justin Moreye66dbe52014-06-10 14:35:13 -0500169LOCAL_SDK_VERSION := 9
170include $(BUILD_STATIC_LIBRARY)
171
Kenny Root0e27f2a2013-09-16 13:58:19 -0700172#
173# Build for the host.
174#
175
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800176ifeq ($(HOST_OS),linux)
177
Ian Rogers3a03c732014-05-23 11:53:18 -0700178# Make the conscrypt-hostdex library
179include $(CLEAR_VARS)
180LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
181LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
182LOCAL_JAVACFLAGS := $(local_javac_flags)
183LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
184LOCAL_MODULE_TAGS := optional
185LOCAL_MODULE := conscrypt-hostdex
186LOCAL_REQUIRED_MODULES := libjavacrypto
187LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
188include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root1cfba2b2014-05-27 18:44:53 +0000189
Ian Rogers3a03c732014-05-23 11:53:18 -0700190# Make the conscrypt-hostdex-nojarjar for tests
191include $(CLEAR_VARS)
192LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
193LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
194LOCAL_JAVACFLAGS := $(local_javac_flags)
195LOCAL_BUILD_HOST_DEX := true
196LOCAL_MODULE_TAGS := optional
197LOCAL_MODULE := conscrypt-hostdex-nojarjar
198LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
199include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700200
Ian Rogers3a03c732014-05-23 11:53:18 -0700201# Make the conscrypt-tests library.
202ifeq ($(LIBCORE_SKIP_TESTS),)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700203 include $(CLEAR_VARS)
204 LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java)
Narayan Kamathb32d6792013-10-28 14:22:43 +0000205 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex conscrypt-hostdex-nojarjar
Kenny Root0e27f2a2013-09-16 13:58:19 -0700206 LOCAL_JAVACFLAGS := $(local_javac_flags)
207 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700208 LOCAL_MODULE := conscrypt-tests-hostdex
Kenny Root0e27f2a2013-09-16 13:58:19 -0700209 LOCAL_REQUIRED_MODULES := libjavacrypto
210 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Narayan Kamathb32d6792013-10-28 14:22:43 +0000211 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Ian Rogers3a03c732014-05-23 11:53:18 -0700212endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700213
Ian Rogers3a03c732014-05-23 11:53:18 -0700214# Conscrypt native library for host
215include $(CLEAR_VARS)
216LOCAL_CLANG := true
217LOCAL_SRC_FILES += \
218 src/main/native/org_conscrypt_NativeCrypto.cpp
219LOCAL_C_INCLUDES += \
220 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700221 external/openssl \
Ian Rogers3a03c732014-05-23 11:53:18 -0700222 libcore/include \
223 libcore/luni/src/main/native
224LOCAL_CPPFLAGS += $(core_cppflags)
225LOCAL_LDLIBS += -lpthread
226LOCAL_MODULE_TAGS := optional
227LOCAL_MODULE := libjavacrypto
228LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/"
Adam Langleyde5225d2014-10-06 15:55:30 -0700229# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
230# the keystore ENGINE. It is not available in this build configuration.
231LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Ian Rogers3a03c732014-05-23 11:53:18 -0700232LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
233LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700234LOCAL_MULTILIB := both
Ian Rogers3a03c732014-05-23 11:53:18 -0700235include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700236
Ian Rogers3a03c732014-05-23 11:53:18 -0700237# Conscrypt native library for nojarjar'd version
238# Don't build this for unbundled conscrypt build
239ifeq (,$(TARGET_BUILD_APPS))
Kenny Root0e27f2a2013-09-16 13:58:19 -0700240 include $(CLEAR_VARS)
Ian Rogers3a03c732014-05-23 11:53:18 -0700241 LOCAL_CLANG := true
Kenny Root0e27f2a2013-09-16 13:58:19 -0700242 LOCAL_SRC_FILES += \
243 src/main/native/org_conscrypt_NativeCrypto.cpp
Kenny Root0a84a212013-10-01 17:48:03 -0700244 LOCAL_C_INCLUDES += \
245 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700246 external/openssl \
Kenny Root0a84a212013-10-01 17:48:03 -0700247 libcore/include \
Kenny Root0e27f2a2013-09-16 13:58:19 -0700248 libcore/luni/src/main/native
Kenny Root3e46e4e2014-05-23 13:35:10 -0700249 LOCAL_CPPFLAGS += $(core_cppflags) -DCONSCRYPT_NOT_UNBUNDLED
Kenny Root0e27f2a2013-09-16 13:58:19 -0700250 LOCAL_LDLIBS += -lpthread
251 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700252 LOCAL_MODULE := libconscrypt_jni
Kenny Root0e27f2a2013-09-16 13:58:19 -0700253 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langleyde5225d2014-10-06 15:55:30 -0700254 # NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to
255 # support the keystore ENGINE. It is not available in this build
256 # configuration.
257 LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root7150e322013-10-01 19:54:34 -0700258 LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700259 LOCAL_MULTILIB := both
Kenny Root0e27f2a2013-09-16 13:58:19 -0700260 include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700261endif
Kenny Root18ed3be2014-11-24 10:57:37 -0800262
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800263endif # HOST_OS == linux
264
Kenny Root18ed3be2014-11-24 10:57:37 -0800265# clear out local variables
266core_cflags :=
267core_cppflags :=
268local_javac_flags :=