blob: c9956da83b69c2979e9fb219d0af9038240add4d [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
Yohann Rousseleaa28762015-04-10 00:57:26 +0200130LOCAL_JACK_FLAGS := -D jack.classpath.default-libraries=false
Kenny Root3e46e4e2014-05-23 13:35:10 -0700131include $(BUILD_STATIC_JAVA_LIBRARY)
132
133# Unbundled Conscrypt crypto JNI library
134include $(CLEAR_VARS)
135LOCAL_CFLAGS += $(core_cflags)
136LOCAL_CPPFLAGS += $(core_cppflags)
137LOCAL_SRC_FILES := \
138 src/main/native/org_conscrypt_NativeCrypto.cpp \
Kenny Rootf24ba062014-06-09 10:37:46 -0700139 src/compat/native/JNIHelp.cpp
Kenny Root3e46e4e2014-05-23 13:35:10 -0700140LOCAL_C_INCLUDES += \
141 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700142 external/openssl \
143 external/conscrypt/src/compat/native
Adam Langleyde5225d2014-10-06 15:55:30 -0700144# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
145# the keystore ENGINE. It is not available in this build configuration.
146LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root031510f2014-05-29 13:53:05 -0700147LOCAL_LDFLAGS := -llog -lz -ldl
Kenny Root3e46e4e2014-05-23 13:35:10 -0700148LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
149LOCAL_MODULE_TAGS := optional
150LOCAL_MODULE := libconscrypt_jni
151LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
152LOCAL_SDK_VERSION := 9
153include $(BUILD_SHARED_LIBRARY)
154
Justin Moreye66dbe52014-06-10 14:35:13 -0500155# Static unbundled Conscrypt crypto JNI library
156include $(CLEAR_VARS)
157LOCAL_CFLAGS += $(core_cflags)
158LOCAL_CPPFLAGS += $(core_cppflags) -DJNI_JARJAR_PREFIX="com/google/android/gms/" -DCONSCRYPT_UNBUNDLED -DSTATIC_LIB
159LOCAL_SRC_FILES := \
160 src/main/native/org_conscrypt_NativeCrypto.cpp \
161 src/compat/native/JNIHelp.cpp
162LOCAL_C_INCLUDES += \
163 external/openssl/include \
164 external/openssl \
165 external/conscrypt/src/compat/native
166LOCAL_MODULE_TAGS := optional
167LOCAL_MODULE := libconscrypt_static
168LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langley0ccc17a2015-02-25 11:37:23 -0800169LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
Justin Moreye66dbe52014-06-10 14:35:13 -0500170LOCAL_SDK_VERSION := 9
171include $(BUILD_STATIC_LIBRARY)
172
Kenny Root0e27f2a2013-09-16 13:58:19 -0700173#
174# Build for the host.
175#
176
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800177ifeq ($(HOST_OS),linux)
178
Ian Rogers3a03c732014-05-23 11:53:18 -0700179# Make the conscrypt-hostdex library
180include $(CLEAR_VARS)
181LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
182LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
183LOCAL_JAVACFLAGS := $(local_javac_flags)
184LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
185LOCAL_MODULE_TAGS := optional
186LOCAL_MODULE := conscrypt-hostdex
187LOCAL_REQUIRED_MODULES := libjavacrypto
188LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
189include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root1cfba2b2014-05-27 18:44:53 +0000190
Ian Rogers3a03c732014-05-23 11:53:18 -0700191# Make the conscrypt-hostdex-nojarjar for tests
192include $(CLEAR_VARS)
193LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
194LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
195LOCAL_JAVACFLAGS := $(local_javac_flags)
196LOCAL_BUILD_HOST_DEX := true
197LOCAL_MODULE_TAGS := optional
198LOCAL_MODULE := conscrypt-hostdex-nojarjar
199LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
200include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700201
Ian Rogers3a03c732014-05-23 11:53:18 -0700202# Make the conscrypt-tests library.
203ifeq ($(LIBCORE_SKIP_TESTS),)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700204 include $(CLEAR_VARS)
205 LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java)
Narayan Kamathb32d6792013-10-28 14:22:43 +0000206 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex conscrypt-hostdex-nojarjar
Kenny Root0e27f2a2013-09-16 13:58:19 -0700207 LOCAL_JAVACFLAGS := $(local_javac_flags)
208 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700209 LOCAL_MODULE := conscrypt-tests-hostdex
Kenny Root0e27f2a2013-09-16 13:58:19 -0700210 LOCAL_REQUIRED_MODULES := libjavacrypto
211 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Narayan Kamathb32d6792013-10-28 14:22:43 +0000212 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Ian Rogers3a03c732014-05-23 11:53:18 -0700213endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700214
Ian Rogers3a03c732014-05-23 11:53:18 -0700215# Conscrypt native library for host
216include $(CLEAR_VARS)
217LOCAL_CLANG := true
218LOCAL_SRC_FILES += \
219 src/main/native/org_conscrypt_NativeCrypto.cpp
220LOCAL_C_INCLUDES += \
221 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700222 external/openssl \
Ian Rogers3a03c732014-05-23 11:53:18 -0700223 libcore/include \
224 libcore/luni/src/main/native
225LOCAL_CPPFLAGS += $(core_cppflags)
226LOCAL_LDLIBS += -lpthread
227LOCAL_MODULE_TAGS := optional
228LOCAL_MODULE := libjavacrypto
229LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/"
Adam Langleyde5225d2014-10-06 15:55:30 -0700230# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
231# the keystore ENGINE. It is not available in this build configuration.
232LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Ian Rogers3a03c732014-05-23 11:53:18 -0700233LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
234LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700235LOCAL_MULTILIB := both
Ian Rogers3a03c732014-05-23 11:53:18 -0700236include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700237
Ian Rogers3a03c732014-05-23 11:53:18 -0700238# Conscrypt native library for nojarjar'd version
239# Don't build this for unbundled conscrypt build
240ifeq (,$(TARGET_BUILD_APPS))
Kenny Root0e27f2a2013-09-16 13:58:19 -0700241 include $(CLEAR_VARS)
Ian Rogers3a03c732014-05-23 11:53:18 -0700242 LOCAL_CLANG := true
Kenny Root0e27f2a2013-09-16 13:58:19 -0700243 LOCAL_SRC_FILES += \
244 src/main/native/org_conscrypt_NativeCrypto.cpp
Kenny Root0a84a212013-10-01 17:48:03 -0700245 LOCAL_C_INCLUDES += \
246 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700247 external/openssl \
Kenny Root0a84a212013-10-01 17:48:03 -0700248 libcore/include \
Kenny Root0e27f2a2013-09-16 13:58:19 -0700249 libcore/luni/src/main/native
Kenny Root3e46e4e2014-05-23 13:35:10 -0700250 LOCAL_CPPFLAGS += $(core_cppflags) -DCONSCRYPT_NOT_UNBUNDLED
Kenny Root0e27f2a2013-09-16 13:58:19 -0700251 LOCAL_LDLIBS += -lpthread
252 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700253 LOCAL_MODULE := libconscrypt_jni
Kenny Root0e27f2a2013-09-16 13:58:19 -0700254 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langleyde5225d2014-10-06 15:55:30 -0700255 # NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to
256 # support the keystore ENGINE. It is not available in this build
257 # configuration.
258 LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root7150e322013-10-01 19:54:34 -0700259 LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700260 LOCAL_MULTILIB := both
Kenny Root0e27f2a2013-09-16 13:58:19 -0700261 include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700262endif
Kenny Root18ed3be2014-11-24 10:57:37 -0800263
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800264endif # HOST_OS == linux
265
Kenny Root18ed3be2014-11-24 10:57:37 -0800266# clear out local variables
267core_cflags :=
268core_cppflags :=
269local_javac_flags :=