blob: 3e39a7eb8ca823e02c6453fce92fc51cc3f58357 [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
Adam Langleyf79c90d2015-04-24 11:11:36 -070053include $(CLEAR_VARS)
54LOCAL_CPP_EXTENSION := cc
55LOCAL_SRC_FILES := src/gen/native/generate_constants.cc
56LOCAL_MODULE := conscrypt_generate_constants
57LOCAL_SHARED_LIBRARIES := libcrypto-host libssl-host
58include $(BUILD_HOST_EXECUTABLE)
59
60conscrypt_generate_constants_exe := $(LOCAL_INSTALLED_MODULE)
61conscrypt_gen_java_files := $(TARGET_OUT_COMMON_GEN)/conscrypt/NativeConstants.java
62
63$(conscrypt_gen_java_files): $(conscrypt_generate_constants_exe)
64 mkdir -p $(dir $@)
65 $< > $@
66
Kenny Root1cfba2b2014-05-27 18:44:53 +000067# Create the conscrypt library
68include $(CLEAR_VARS)
69LOCAL_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)
Adam Langleyf79c90d2015-04-24 11:11:36 -070071LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files)
Brian Carlstromecd29ab2014-06-18 15:11:01 -070072LOCAL_JAVA_LIBRARIES := core-libart
Kenny Root1cfba2b2014-05-27 18:44:53 +000073LOCAL_NO_STANDARD_LIBRARIES := true
74LOCAL_JAVACFLAGS := $(local_javac_flags)
75LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
76LOCAL_MODULE_TAGS := optional
77LOCAL_MODULE := conscrypt
78LOCAL_REQUIRED_MODULES := libjavacrypto
79LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
80include $(BUILD_JAVA_LIBRARY)
81
82# Create the conscrypt library without jarjar for tests
83include $(CLEAR_VARS)
Kenny Root0e27f2a2013-09-16 13:58:19 -070084LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
Kenny Root39deada2014-05-30 13:15:27 -070085LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
Adam Langleyf79c90d2015-04-24 11:11:36 -070086LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files)
Brian Carlstromecd29ab2014-06-18 15:11:01 -070087LOCAL_JAVA_LIBRARIES := core-libart
Kenny Root0e27f2a2013-09-16 13:58:19 -070088LOCAL_NO_STANDARD_LIBRARIES := true
89LOCAL_JAVACFLAGS := $(local_javac_flags)
90LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -070091LOCAL_MODULE := conscrypt-nojarjar
Kenny Root0e27f2a2013-09-16 13:58:19 -070092LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
93include $(BUILD_STATIC_JAVA_LIBRARY)
94
95ifeq ($(LIBCORE_SKIP_TESTS),)
96# Make the conscrypt-tests library.
97include $(CLEAR_VARS)
98LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java)
99LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstromecd29ab2014-06-18 15:11:01 -0700100LOCAL_JAVA_LIBRARIES := core-libart core-junit bouncycastle
Kenny Root0e27f2a2013-09-16 13:58:19 -0700101LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support conscrypt-nojarjar
102LOCAL_JAVACFLAGS := $(local_javac_flags)
103LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700104LOCAL_MODULE := conscrypt-tests
Kenny Root0e27f2a2013-09-16 13:58:19 -0700105LOCAL_REQUIRED_MODULES := libjavacrypto
106LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
107LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
108include $(BUILD_STATIC_JAVA_LIBRARY)
109endif
110
111# Platform conscrypt crypto JNI library
112include $(CLEAR_VARS)
Adam Langley24144a82015-01-26 14:54:30 -0800113ifneq (,$(wildcard $(TOP)/external/boringssl/flavor.mk))
114 include $(TOP)/external/boringssl/flavor.mk
115else
116 include $(TOP)/external/openssl/flavor.mk
117endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700118LOCAL_CFLAGS += $(core_cflags)
119LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/"
120LOCAL_CPPFLAGS += $(core_cppflags)
121LOCAL_SRC_FILES := \
122 src/main/native/org_conscrypt_NativeCrypto.cpp
Kenny Root0a84a212013-10-01 17:48:03 -0700123LOCAL_C_INCLUDES += \
124 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700125 external/openssl \
Kenny Root0a84a212013-10-01 17:48:03 -0700126 libcore/include \
Kenny Root0e27f2a2013-09-16 13:58:19 -0700127 libcore/luni/src/main/native
Kenny Root0a84a212013-10-01 17:48:03 -0700128LOCAL_SHARED_LIBRARIES := libcrypto libjavacore liblog libnativehelper libssl libz
Adam Langleyde5225d2014-10-06 15:55:30 -0700129ifeq ($(OPENSSL_FLAVOR),BoringSSL)
130 LOCAL_SHARED_LIBRARIES += libkeystore-engine
Adam Langleyde5225d2014-10-06 15:55:30 -0700131endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700132LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700133LOCAL_MODULE := libjavacrypto
Kenny Root0e27f2a2013-09-16 13:58:19 -0700134LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
135include $(BUILD_SHARED_LIBRARY)
136
Kenny Root3e46e4e2014-05-23 13:35:10 -0700137# Unbundled Conscrypt jar
138include $(CLEAR_VARS)
Kenny Root39deada2014-05-30 13:15:27 -0700139LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
140LOCAL_SRC_FILES += $(call all-java-files-under,src/compat/java)
Adam Langleyf79c90d2015-04-24 11:11:36 -0700141LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files)
Kenny Root3e46e4e2014-05-23 13:35:10 -0700142LOCAL_SDK_VERSION := 9
143LOCAL_JAVACFLAGS := $(local_javac_flags)
144LOCAL_MODULE_TAGS := optional
Kenny Root031510f2014-05-29 13:53:05 -0700145LOCAL_MODULE := conscrypt_unbundled
Chad Brubaker62190cd2015-04-03 12:17:33 -0700146LOCAL_JAVA_LIBRARIES := conscrypt-stubs
Kenny Root3e46e4e2014-05-23 13:35:10 -0700147LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Yohann Rousseleaa28762015-04-10 00:57:26 +0200148LOCAL_JACK_FLAGS := -D jack.classpath.default-libraries=false
Kenny Root3e46e4e2014-05-23 13:35:10 -0700149include $(BUILD_STATIC_JAVA_LIBRARY)
150
Chad Brubaker62190cd2015-04-03 12:17:33 -0700151# Stub library for unbundled builds
152include $(CLEAR_VARS)
153LOCAL_SRC_FILES := $(call all-java-files-under,src/stub/java)
Kenny Root7cb0a4a2015-04-22 16:36:16 -0700154LOCAL_SDK_VERSION := 9
155LOCAL_JAVACFLAGS := $(local_javac_flags)
Chad Brubaker62190cd2015-04-03 12:17:33 -0700156LOCAL_MODULE := conscrypt-stubs
Kenny Root7cb0a4a2015-04-22 16:36:16 -0700157LOCAL_JACK_FLAGS := -D jack.classpath.default-libraries=false
Chad Brubaker62190cd2015-04-03 12:17:33 -0700158include $(BUILD_STATIC_JAVA_LIBRARY)
159
Kenny Root3e46e4e2014-05-23 13:35:10 -0700160# Unbundled Conscrypt crypto JNI library
161include $(CLEAR_VARS)
162LOCAL_CFLAGS += $(core_cflags)
163LOCAL_CPPFLAGS += $(core_cppflags)
164LOCAL_SRC_FILES := \
165 src/main/native/org_conscrypt_NativeCrypto.cpp \
Kenny Rootf24ba062014-06-09 10:37:46 -0700166 src/compat/native/JNIHelp.cpp
Kenny Root3e46e4e2014-05-23 13:35:10 -0700167LOCAL_C_INCLUDES += \
168 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700169 external/openssl \
170 external/conscrypt/src/compat/native
Adam Langleyde5225d2014-10-06 15:55:30 -0700171# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
172# the keystore ENGINE. It is not available in this build configuration.
173LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root031510f2014-05-29 13:53:05 -0700174LOCAL_LDFLAGS := -llog -lz -ldl
Kenny Root3e46e4e2014-05-23 13:35:10 -0700175LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
176LOCAL_MODULE_TAGS := optional
177LOCAL_MODULE := libconscrypt_jni
178LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
179LOCAL_SDK_VERSION := 9
180include $(BUILD_SHARED_LIBRARY)
181
Justin Moreye66dbe52014-06-10 14:35:13 -0500182# Static unbundled Conscrypt crypto JNI library
183include $(CLEAR_VARS)
184LOCAL_CFLAGS += $(core_cflags)
185LOCAL_CPPFLAGS += $(core_cppflags) -DJNI_JARJAR_PREFIX="com/google/android/gms/" -DCONSCRYPT_UNBUNDLED -DSTATIC_LIB
186LOCAL_SRC_FILES := \
187 src/main/native/org_conscrypt_NativeCrypto.cpp \
188 src/compat/native/JNIHelp.cpp
189LOCAL_C_INCLUDES += \
190 external/openssl/include \
191 external/openssl \
192 external/conscrypt/src/compat/native
193LOCAL_MODULE_TAGS := optional
194LOCAL_MODULE := libconscrypt_static
195LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langley0ccc17a2015-02-25 11:37:23 -0800196LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
Justin Moreye66dbe52014-06-10 14:35:13 -0500197LOCAL_SDK_VERSION := 9
198include $(BUILD_STATIC_LIBRARY)
199
Kenny Root0e27f2a2013-09-16 13:58:19 -0700200#
201# Build for the host.
202#
203
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800204ifeq ($(HOST_OS),linux)
205
Ian Rogers3a03c732014-05-23 11:53:18 -0700206# Make the conscrypt-hostdex library
207include $(CLEAR_VARS)
208LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
209LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
Adam Langleyf79c90d2015-04-24 11:11:36 -0700210LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files)
Ian Rogers3a03c732014-05-23 11:53:18 -0700211LOCAL_JAVACFLAGS := $(local_javac_flags)
212LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
213LOCAL_MODULE_TAGS := optional
214LOCAL_MODULE := conscrypt-hostdex
215LOCAL_REQUIRED_MODULES := libjavacrypto
216LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
217include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root1cfba2b2014-05-27 18:44:53 +0000218
Ian Rogers3a03c732014-05-23 11:53:18 -0700219# Make the conscrypt-hostdex-nojarjar for tests
220include $(CLEAR_VARS)
221LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
222LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
Adam Langleyf79c90d2015-04-24 11:11:36 -0700223LOCAL_GENERATED_SOURCES := $(conscrypt_gen_java_files)
Ian Rogers3a03c732014-05-23 11:53:18 -0700224LOCAL_JAVACFLAGS := $(local_javac_flags)
225LOCAL_BUILD_HOST_DEX := true
226LOCAL_MODULE_TAGS := optional
227LOCAL_MODULE := conscrypt-hostdex-nojarjar
228LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
229include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700230
Ian Rogers3a03c732014-05-23 11:53:18 -0700231# Make the conscrypt-tests library.
232ifeq ($(LIBCORE_SKIP_TESTS),)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700233 include $(CLEAR_VARS)
234 LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java)
Narayan Kamathb32d6792013-10-28 14:22:43 +0000235 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex conscrypt-hostdex-nojarjar
Kenny Root0e27f2a2013-09-16 13:58:19 -0700236 LOCAL_JAVACFLAGS := $(local_javac_flags)
237 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700238 LOCAL_MODULE := conscrypt-tests-hostdex
Kenny Root0e27f2a2013-09-16 13:58:19 -0700239 LOCAL_REQUIRED_MODULES := libjavacrypto
240 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Narayan Kamathb32d6792013-10-28 14:22:43 +0000241 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Ian Rogers3a03c732014-05-23 11:53:18 -0700242endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700243
Ian Rogers3a03c732014-05-23 11:53:18 -0700244# Conscrypt native library for host
245include $(CLEAR_VARS)
246LOCAL_CLANG := true
247LOCAL_SRC_FILES += \
248 src/main/native/org_conscrypt_NativeCrypto.cpp
249LOCAL_C_INCLUDES += \
250 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700251 external/openssl \
Ian Rogers3a03c732014-05-23 11:53:18 -0700252 libcore/include \
253 libcore/luni/src/main/native
254LOCAL_CPPFLAGS += $(core_cppflags)
255LOCAL_LDLIBS += -lpthread
256LOCAL_MODULE_TAGS := optional
257LOCAL_MODULE := libjavacrypto
258LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/"
Adam Langleyde5225d2014-10-06 15:55:30 -0700259# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
260# the keystore ENGINE. It is not available in this build configuration.
261LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Ian Rogers3a03c732014-05-23 11:53:18 -0700262LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
263LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700264LOCAL_MULTILIB := both
Ian Rogers3a03c732014-05-23 11:53:18 -0700265include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700266
Ian Rogers3a03c732014-05-23 11:53:18 -0700267# Conscrypt native library for nojarjar'd version
268# Don't build this for unbundled conscrypt build
269ifeq (,$(TARGET_BUILD_APPS))
Kenny Root0e27f2a2013-09-16 13:58:19 -0700270 include $(CLEAR_VARS)
Ian Rogers3a03c732014-05-23 11:53:18 -0700271 LOCAL_CLANG := true
Kenny Root0e27f2a2013-09-16 13:58:19 -0700272 LOCAL_SRC_FILES += \
273 src/main/native/org_conscrypt_NativeCrypto.cpp
Kenny Root0a84a212013-10-01 17:48:03 -0700274 LOCAL_C_INCLUDES += \
275 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700276 external/openssl \
Kenny Root0a84a212013-10-01 17:48:03 -0700277 libcore/include \
Kenny Root0e27f2a2013-09-16 13:58:19 -0700278 libcore/luni/src/main/native
Kenny Root3e46e4e2014-05-23 13:35:10 -0700279 LOCAL_CPPFLAGS += $(core_cppflags) -DCONSCRYPT_NOT_UNBUNDLED
Kenny Root0e27f2a2013-09-16 13:58:19 -0700280 LOCAL_LDLIBS += -lpthread
281 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700282 LOCAL_MODULE := libconscrypt_jni
Kenny Root0e27f2a2013-09-16 13:58:19 -0700283 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langleyde5225d2014-10-06 15:55:30 -0700284 # NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to
285 # support the keystore ENGINE. It is not available in this build
286 # configuration.
287 LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root7150e322013-10-01 19:54:34 -0700288 LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700289 LOCAL_MULTILIB := both
Kenny Root0e27f2a2013-09-16 13:58:19 -0700290 include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700291endif
Kenny Root18ed3be2014-11-24 10:57:37 -0800292
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800293endif # HOST_OS == linux
294
Kenny Root18ed3be2014-11-24 10:57:37 -0800295# clear out local variables
296core_cflags :=
297core_cppflags :=
298local_javac_flags :=