blob: 914a2a97e9427f73ae69fded3d2b6c21684dad27 [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
43local_javac_flags=-encoding UTF-8
44#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
45local_javac_flags+=-Xmaxwarns 9999999
46
Kenny Root18ed3be2014-11-24 10:57:37 -080047core_cflags := -Wall -Wextra -Werror -Wunused
48core_cppflags := -std=gnu++11 -Wall -Wextra -Werror -Wunused
Kenny Root0e27f2a2013-09-16 13:58:19 -070049
50#
51# Build for the target (device).
52#
53
Kenny Root1cfba2b2014-05-27 18:44:53 +000054# Create the conscrypt library
55include $(CLEAR_VARS)
56LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
Kenny Root39deada2014-05-30 13:15:27 -070057LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
Brian Carlstromecd29ab2014-06-18 15:11:01 -070058LOCAL_JAVA_LIBRARIES := core-libart
Kenny Root1cfba2b2014-05-27 18:44:53 +000059LOCAL_NO_STANDARD_LIBRARIES := true
60LOCAL_JAVACFLAGS := $(local_javac_flags)
61LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
62LOCAL_MODULE_TAGS := optional
63LOCAL_MODULE := conscrypt
64LOCAL_REQUIRED_MODULES := libjavacrypto
65LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
66include $(BUILD_JAVA_LIBRARY)
67
68# Create the conscrypt library without jarjar for tests
69include $(CLEAR_VARS)
Kenny Root0e27f2a2013-09-16 13:58:19 -070070LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
Kenny Root39deada2014-05-30 13:15:27 -070071LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
Brian Carlstromecd29ab2014-06-18 15:11:01 -070072LOCAL_JAVA_LIBRARIES := core-libart
Kenny Root0e27f2a2013-09-16 13:58:19 -070073LOCAL_NO_STANDARD_LIBRARIES := true
74LOCAL_JAVACFLAGS := $(local_javac_flags)
75LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -070076LOCAL_MODULE := conscrypt-nojarjar
Kenny Root0e27f2a2013-09-16 13:58:19 -070077LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
78include $(BUILD_STATIC_JAVA_LIBRARY)
79
80ifeq ($(LIBCORE_SKIP_TESTS),)
81# Make the conscrypt-tests library.
82include $(CLEAR_VARS)
83LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java)
84LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstromecd29ab2014-06-18 15:11:01 -070085LOCAL_JAVA_LIBRARIES := core-libart core-junit bouncycastle
Kenny Root0e27f2a2013-09-16 13:58:19 -070086LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support conscrypt-nojarjar
87LOCAL_JAVACFLAGS := $(local_javac_flags)
88LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -070089LOCAL_MODULE := conscrypt-tests
Kenny Root0e27f2a2013-09-16 13:58:19 -070090LOCAL_REQUIRED_MODULES := libjavacrypto
91LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
92LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
93include $(BUILD_STATIC_JAVA_LIBRARY)
94endif
95
96# Platform conscrypt crypto JNI library
97include $(CLEAR_VARS)
Adam Langley24144a82015-01-26 14:54:30 -080098ifneq (,$(wildcard $(TOP)/external/boringssl/flavor.mk))
99 include $(TOP)/external/boringssl/flavor.mk
100else
101 include $(TOP)/external/openssl/flavor.mk
102endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700103LOCAL_CFLAGS += $(core_cflags)
104LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/"
105LOCAL_CPPFLAGS += $(core_cppflags)
106LOCAL_SRC_FILES := \
107 src/main/native/org_conscrypt_NativeCrypto.cpp
Kenny Root0a84a212013-10-01 17:48:03 -0700108LOCAL_C_INCLUDES += \
109 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700110 external/openssl \
Kenny Root0a84a212013-10-01 17:48:03 -0700111 libcore/include \
Kenny Root0e27f2a2013-09-16 13:58:19 -0700112 libcore/luni/src/main/native
Kenny Root0a84a212013-10-01 17:48:03 -0700113LOCAL_SHARED_LIBRARIES := libcrypto libjavacore liblog libnativehelper libssl libz
Adam Langleyde5225d2014-10-06 15:55:30 -0700114ifeq ($(OPENSSL_FLAVOR),BoringSSL)
115 LOCAL_SHARED_LIBRARIES += libkeystore-engine
116else
117 LOCAL_SHARED_LIBRARIES += libkeystore
118endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700119LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700120LOCAL_MODULE := libjavacrypto
Kenny Root0e27f2a2013-09-16 13:58:19 -0700121LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
122include $(BUILD_SHARED_LIBRARY)
123
Kenny Root3e46e4e2014-05-23 13:35:10 -0700124# Unbundled Conscrypt jar
125include $(CLEAR_VARS)
Kenny Root39deada2014-05-30 13:15:27 -0700126LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
127LOCAL_SRC_FILES += $(call all-java-files-under,src/compat/java)
Kenny Root3e46e4e2014-05-23 13:35:10 -0700128LOCAL_SDK_VERSION := 9
129LOCAL_JAVACFLAGS := $(local_javac_flags)
130LOCAL_MODULE_TAGS := optional
Kenny Root031510f2014-05-29 13:53:05 -0700131LOCAL_MODULE := conscrypt_unbundled
Kenny Root3e46e4e2014-05-23 13:35:10 -0700132LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
133include $(BUILD_STATIC_JAVA_LIBRARY)
134
135# Unbundled Conscrypt crypto JNI library
136include $(CLEAR_VARS)
137LOCAL_CFLAGS += $(core_cflags)
138LOCAL_CPPFLAGS += $(core_cppflags)
139LOCAL_SRC_FILES := \
140 src/main/native/org_conscrypt_NativeCrypto.cpp \
Kenny Rootf24ba062014-06-09 10:37:46 -0700141 src/compat/native/JNIHelp.cpp
Kenny Root3e46e4e2014-05-23 13:35:10 -0700142LOCAL_C_INCLUDES += \
143 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700144 external/openssl \
145 external/conscrypt/src/compat/native
Adam Langleyde5225d2014-10-06 15:55:30 -0700146# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
147# the keystore ENGINE. It is not available in this build configuration.
148LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root031510f2014-05-29 13:53:05 -0700149LOCAL_LDFLAGS := -llog -lz -ldl
Kenny Root3e46e4e2014-05-23 13:35:10 -0700150LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
151LOCAL_MODULE_TAGS := optional
152LOCAL_MODULE := libconscrypt_jni
153LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
154LOCAL_SDK_VERSION := 9
155include $(BUILD_SHARED_LIBRARY)
156
Justin Moreye66dbe52014-06-10 14:35:13 -0500157# Static unbundled Conscrypt crypto JNI library
158include $(CLEAR_VARS)
159LOCAL_CFLAGS += $(core_cflags)
160LOCAL_CPPFLAGS += $(core_cppflags) -DJNI_JARJAR_PREFIX="com/google/android/gms/" -DCONSCRYPT_UNBUNDLED -DSTATIC_LIB
161LOCAL_SRC_FILES := \
162 src/main/native/org_conscrypt_NativeCrypto.cpp \
163 src/compat/native/JNIHelp.cpp
164LOCAL_C_INCLUDES += \
165 external/openssl/include \
166 external/openssl \
167 external/conscrypt/src/compat/native
168LOCAL_MODULE_TAGS := optional
169LOCAL_MODULE := libconscrypt_static
170LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langley0ccc17a2015-02-25 11:37:23 -0800171LOCAL_STATIC_LIBRARIES := libssl_static libcrypto_static
Justin Moreye66dbe52014-06-10 14:35:13 -0500172LOCAL_SDK_VERSION := 9
173include $(BUILD_STATIC_LIBRARY)
174
Kenny Root0e27f2a2013-09-16 13:58:19 -0700175#
176# Build for the host.
177#
178
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800179ifeq ($(HOST_OS),linux)
180
Ian Rogers3a03c732014-05-23 11:53:18 -0700181# Make the conscrypt-hostdex library
182include $(CLEAR_VARS)
183LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
184LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
185LOCAL_JAVACFLAGS := $(local_javac_flags)
186LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
187LOCAL_MODULE_TAGS := optional
188LOCAL_MODULE := conscrypt-hostdex
189LOCAL_REQUIRED_MODULES := libjavacrypto
190LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
191include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root1cfba2b2014-05-27 18:44:53 +0000192
Ian Rogers3a03c732014-05-23 11:53:18 -0700193# Make the conscrypt-hostdex-nojarjar for tests
194include $(CLEAR_VARS)
195LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
196LOCAL_SRC_FILES += $(call all-java-files-under,src/platform/java)
197LOCAL_JAVACFLAGS := $(local_javac_flags)
198LOCAL_BUILD_HOST_DEX := true
199LOCAL_MODULE_TAGS := optional
200LOCAL_MODULE := conscrypt-hostdex-nojarjar
201LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
202include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700203
Ian Rogers3a03c732014-05-23 11:53:18 -0700204# Make the conscrypt-tests library.
205ifeq ($(LIBCORE_SKIP_TESTS),)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700206 include $(CLEAR_VARS)
207 LOCAL_SRC_FILES := $(call all-java-files-under,src/test/java)
Narayan Kamathb32d6792013-10-28 14:22:43 +0000208 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex conscrypt-hostdex-nojarjar
Kenny Root0e27f2a2013-09-16 13:58:19 -0700209 LOCAL_JAVACFLAGS := $(local_javac_flags)
210 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700211 LOCAL_MODULE := conscrypt-tests-hostdex
Kenny Root0e27f2a2013-09-16 13:58:19 -0700212 LOCAL_REQUIRED_MODULES := libjavacrypto
213 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Narayan Kamathb32d6792013-10-28 14:22:43 +0000214 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Ian Rogers3a03c732014-05-23 11:53:18 -0700215endif
Kenny Root0e27f2a2013-09-16 13:58:19 -0700216
Ian Rogers3a03c732014-05-23 11:53:18 -0700217# Conscrypt native library for host
218include $(CLEAR_VARS)
219LOCAL_CLANG := true
220LOCAL_SRC_FILES += \
221 src/main/native/org_conscrypt_NativeCrypto.cpp
222LOCAL_C_INCLUDES += \
223 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700224 external/openssl \
Ian Rogers3a03c732014-05-23 11:53:18 -0700225 libcore/include \
226 libcore/luni/src/main/native
227LOCAL_CPPFLAGS += $(core_cppflags)
228LOCAL_LDLIBS += -lpthread
229LOCAL_MODULE_TAGS := optional
230LOCAL_MODULE := libjavacrypto
231LOCAL_CFLAGS += -DJNI_JARJAR_PREFIX="com/android/"
Adam Langleyde5225d2014-10-06 15:55:30 -0700232# NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to support
233# the keystore ENGINE. It is not available in this build configuration.
234LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Ian Rogers3a03c732014-05-23 11:53:18 -0700235LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
236LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700237LOCAL_MULTILIB := both
Ian Rogers3a03c732014-05-23 11:53:18 -0700238include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700239
Ian Rogers3a03c732014-05-23 11:53:18 -0700240# Conscrypt native library for nojarjar'd version
241# Don't build this for unbundled conscrypt build
242ifeq (,$(TARGET_BUILD_APPS))
Kenny Root0e27f2a2013-09-16 13:58:19 -0700243 include $(CLEAR_VARS)
Ian Rogers3a03c732014-05-23 11:53:18 -0700244 LOCAL_CLANG := true
Kenny Root0e27f2a2013-09-16 13:58:19 -0700245 LOCAL_SRC_FILES += \
246 src/main/native/org_conscrypt_NativeCrypto.cpp
Kenny Root0a84a212013-10-01 17:48:03 -0700247 LOCAL_C_INCLUDES += \
248 external/openssl/include \
Kenny Rootf24ba062014-06-09 10:37:46 -0700249 external/openssl \
Kenny Root0a84a212013-10-01 17:48:03 -0700250 libcore/include \
Kenny Root0e27f2a2013-09-16 13:58:19 -0700251 libcore/luni/src/main/native
Kenny Root3e46e4e2014-05-23 13:35:10 -0700252 LOCAL_CPPFLAGS += $(core_cppflags) -DCONSCRYPT_NOT_UNBUNDLED
Kenny Root0e27f2a2013-09-16 13:58:19 -0700253 LOCAL_LDLIBS += -lpthread
254 LOCAL_MODULE_TAGS := optional
Kenny Root92b12a82013-10-02 16:44:41 -0700255 LOCAL_MODULE := libconscrypt_jni
Kenny Root0e27f2a2013-09-16 13:58:19 -0700256 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
Adam Langleyde5225d2014-10-06 15:55:30 -0700257 # NO_KEYSTORE_ENGINE instructs the BoringSSL build of Conscrypt not to
258 # support the keystore ENGINE. It is not available in this build
259 # configuration.
260 LOCAL_CFLAGS += -DNO_KEYSTORE_ENGINE
Kenny Root7150e322013-10-01 19:54:34 -0700261 LOCAL_SHARED_LIBRARIES := libcrypto-host libjavacore liblog libnativehelper libssl-host
Elliott Hughes759b1982014-10-28 13:24:26 -0700262 LOCAL_MULTILIB := both
Kenny Root0e27f2a2013-09-16 13:58:19 -0700263 include $(BUILD_HOST_SHARED_LIBRARY)
Kenny Root0e27f2a2013-09-16 13:58:19 -0700264endif
Kenny Root18ed3be2014-11-24 10:57:37 -0800265
Elliott Hughesd9b323c2014-12-17 13:29:43 -0800266endif # HOST_OS == linux
267
Kenny Root18ed3be2014-11-24 10:57:37 -0800268# clear out local variables
269core_cflags :=
270core_cppflags :=
271local_javac_flags :=