blob: a2522442863fb15c334a4dafef0b349470b85b8d [file] [log] [blame]
Joe Onorato6396e702012-05-31 23:21:46 -07001# Copyright (C) 2007 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080014
Joe Onorato6396e702012-05-31 23:21:46 -070015LOCAL_PATH := $(call my-dir)
Ethan Yonker58f21322018-08-24 11:17:36 -050016commands_TWRP_local_path := $(LOCAL_PATH)
Joe Onorato6396e702012-05-31 23:21:46 -070017
Ethan Yonker66bcd492018-12-20 09:03:17 -060018ifneq ($(project-path-for),)
Matt Mower66766fe2014-10-06 18:03:39 -050019 ifeq ($(LOCAL_PATH),$(call project-path-for,recovery))
20 PROJECT_PATH_AGREES := true
Andrea Mennillof591c872015-11-03 20:58:11 +010021 BOARD_SEPOLICY_DIRS += $(call project-path-for,recovery)/sepolicy
Matt Mower66766fe2014-10-06 18:03:39 -050022 endif
23else
24 ifeq ($(LOCAL_PATH),bootable/recovery)
25 PROJECT_PATH_AGREES := true
Ethan Yonker11309e92015-07-01 07:58:56 -050026 BOARD_SEPOLICY_DIRS += bootable/recovery/sepolicy
Ethan Yonkerf0a7e592019-04-04 10:06:41 -050027 else
28 ifeq ($(LOCAL_PATH),bootable/recovery-twrp)
29 ifeq ($(RECOVERY_VARIANT),twrp)
30 PROJECT_PATH_AGREES := true
31 BOARD_SEPOLICY_DIRS += bootable/recovery-twrp/sepolicy
32 endif
33 endif
Matt Mower66766fe2014-10-06 18:03:39 -050034 endif
Matt Mower55c75ca2014-08-31 11:30:15 -050035endif
36
Matt Mower66766fe2014-10-06 18:03:39 -050037ifeq ($(PROJECT_PATH_AGREES),true)
Matt Mower55c75ca2014-08-31 11:30:15 -050038
Matt Mower047723c2015-12-10 01:31:15 -060039ifneq (,$(filter $(PLATFORM_SDK_VERSION), 21 22))
Ethan Yonker11309e92015-07-01 07:58:56 -050040# Make recovery domain permissive for TWRP
that8e213fd2015-10-17 00:17:53 +020041 BOARD_SEPOLICY_UNION += twrp.te
42endif
Ethan Yonker11309e92015-07-01 07:58:56 -050043
Michael Bestas0cc23762018-07-13 21:37:56 +030044ifeq ($(CM_PLATFORM_SDK_VERSION),)
45 CM_PLATFORM_SDK_VERSION := 0
46endif
47
Motorhead199175b6f662014-06-12 15:58:33 -070048include $(CLEAR_VARS)
49
Matt Mower1777cdc2015-09-26 15:56:56 -050050TWRES_PATH := /twres/
Dees Troy3454ade2015-01-20 19:21:04 +000051TWHTCD_PATH := $(TWRES_PATH)htcd/
52
Dees_Troy51a0e822012-09-05 15:24:24 -040053TARGET_RECOVERY_GUI := true
Joe Onorato6396e702012-05-31 23:21:46 -070054
bigbiff bigbiff584b9772016-12-08 21:21:17 -050055ifneq ($(TW_DEVICE_VERSION),)
56 LOCAL_CFLAGS += -DTW_DEVICE_VERSION='"-$(TW_DEVICE_VERSION)"'
57else
58 LOCAL_CFLAGS += -DTW_DEVICE_VERSION='"-0"'
59endif
dianlujitao4879b372018-12-03 18:45:47 +080060LOCAL_CFLAGS += -DPLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
bigbiff bigbiff584b9772016-12-08 21:21:17 -050061
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080062LOCAL_SRC_FILES := \
Dees_Troy2673cec2013-04-02 20:22:16 +000063 twrp.cpp \
Ethan Yonkerb5fab762016-01-28 14:03:33 -060064 fixContexts.cpp \
bigbiff bigbiff9c754052013-01-09 09:09:08 -050065 twrpTar.cpp \
Ethan Yonker3fdcda42016-11-30 12:29:37 -060066 exclude.cpp \
Ethan Yonker1b7a31b2014-07-03 15:09:22 -050067 find_file.cpp \
bigbiff bigbiff56cf5642016-08-19 17:43:45 -040068 infomanager.cpp \
Dees_Troy51a0e822012-09-05 15:24:24 -040069 data.cpp \
Dees_Troy51a0e822012-09-05 15:24:24 -040070 partition.cpp \
71 partitionmanager.cpp \
Ethan Yonker472f5062016-02-25 13:47:30 -060072 progresstracking.cpp \
Dees_Troy32c8eb82012-09-11 15:28:06 -040073 twinstall.cpp \
Dees_Troy812660f2012-09-20 09:55:17 -040074 twrp-functions.cpp \
bigbiff bigbiff56cf5642016-08-19 17:43:45 -040075 twrpDigestDriver.cpp \
Dees_Troye34c1332013-02-06 19:13:00 +000076 openrecoveryscript.cpp \
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -040077 tarWrite.c \
78 twrpAdbBuFifo.cpp
Dees_Troy51a0e822012-09-05 15:24:24 -040079
Dees_Troya58bead2012-09-27 09:49:29 -040080ifneq ($(TARGET_RECOVERY_REBOOT_SRC),)
Dees_Troy51a0e822012-09-05 15:24:24 -040081 LOCAL_SRC_FILES += $(TARGET_RECOVERY_REBOOT_SRC)
82endif
83
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080084LOCAL_MODULE := recovery
85
Dees_Troy51a0e822012-09-05 15:24:24 -040086#LOCAL_FORCE_STATIC_EXECUTABLE := true
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080087
Ethan Yonker34ae4832016-08-24 15:32:18 -050088#ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
Ethan Yonkera1674162014-11-06 08:35:10 -060089#ifeq ($(HOST_OS),linux)
90#LOCAL_REQUIRED_MODULES := mkfs.f2fs
91#endif
Ethan Yonker34ae4832016-08-24 15:32:18 -050092#endif
JP Abgrall37aedb32014-06-16 19:07:39 -070093
Doug Zongkere08991e2010-02-02 13:09:52 -080094RECOVERY_API_VERSION := 3
Ken Sumrallf35d1ce2013-02-13 12:59:35 -080095RECOVERY_FSTAB_VERSION := 2
Doug Zongkerfb2e3af2009-06-17 17:29:40 -070096LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
Doug Zongker0d32f252014-02-13 15:07:56 -080097LOCAL_CFLAGS += -Wno-unused-parameter
Tao Bao80e46e02015-06-03 10:49:29 -070098LOCAL_CLANG := true
Doug Zongkerfb2e3af2009-06-17 17:29:40 -070099
Dees_Troy51a0e822012-09-05 15:24:24 -0400100#LOCAL_STATIC_LIBRARIES := \
Dees_Troy1669f892013-09-04 18:35:08 +0000101# libext4_utils_static \
102# libsparse_static \
Dees_Troy51a0e822012-09-05 15:24:24 -0400103# libminzip \
Dees_Troy1669f892013-09-04 18:35:08 +0000104# libz \
Dees_Troy51a0e822012-09-05 15:24:24 -0400105# libmtdutils \
106# libmincrypt \
107# libminadbd \
Dees_Troy1669f892013-09-04 18:35:08 +0000108# libminui \
109# libpixelflinger_static \
110# libpng \
111# libfs_mgr \
112# libcutils \
113# liblog \
114# libselinux \
115# libstdc++ \
116# libm \
117# libc
Dees_Troy51a0e822012-09-05 15:24:24 -0400118
Dan Albert1ddd3502015-02-18 15:58:15 -0800119LOCAL_C_INCLUDES += \
120 system/vold \
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500121 system/extras \
Dan Albert1ddd3502015-02-18 15:58:15 -0800122 system/core/adb \
bigbiffce8f83c2015-12-12 18:30:21 -0500123 system/core/libsparse \
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500124 external/zlib \
125 $(LOCAL_PATH)/bootloader_message_twrp/include
Adrien Grassein3cd669f2014-11-06 14:53:50 +0100126
bigbiff bigbiff56cf5642016-08-19 17:43:45 -0400127LOCAL_C_INCLUDES += bionic
Xing0af1ac12015-11-27 11:19:37 -0800128ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
bigbiff bigbiff56cf5642016-08-19 17:43:45 -0400129 LOCAL_C_INCLUDES += external/stlport/stlport external/openssl/include
Ethan Yonker58f21322018-08-24 11:17:36 -0500130 LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22
bigbiff bigbiff56cf5642016-08-19 17:43:45 -0400131else
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500132 LOCAL_C_INCLUDES += external/boringssl/include external/libcxx/include
Xing0af1ac12015-11-27 11:19:37 -0800133endif
Dees_Troy51a0e822012-09-05 15:24:24 -0400134
135LOCAL_STATIC_LIBRARIES :=
136LOCAL_SHARED_LIBRARIES :=
137
Ethan Yonkerbcc502c2014-11-10 11:22:10 -0600138LOCAL_STATIC_LIBRARIES += libguitwrp
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500139LOCAL_SHARED_LIBRARIES += libaosprecovery libz libc libcutils libstdc++ libtar libblkid libminuitwrp libminadbd libmtdutils libtwadbbu libbootloader_message_twrp
140LOCAL_SHARED_LIBRARIES += libcrecovery libtwadbbu libtwrpdigest libc++
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500141
Xing0af1ac12015-11-27 11:19:37 -0800142ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
Ethan Yonker534d4e02016-08-26 10:05:03 -0500143 LOCAL_SHARED_LIBRARIES += libstlport
bigbiff bigbiff56cf5642016-08-19 17:43:45 -0400144 LOCAL_CFLAGS += -DTW_NO_SHA2_LIBRARY
Ethan Yonker534d4e02016-08-26 10:05:03 -0500145endif
146ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
147 LOCAL_SHARED_LIBRARIES += libmincrypttwrp
Ethan Yonkerf1179622016-08-25 15:32:21 -0500148 LOCAL_C_INCLUDES += $(LOCAL_PATH)/libmincrypt/includes
149 LOCAL_CFLAGS += -DUSE_OLD_VERIFIER
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500150else
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500151 LOCAL_SHARED_LIBRARIES += libcrypto
Ethan Yonkerf1179622016-08-25 15:32:21 -0500152endif
153
154ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0)
155 LOCAL_SHARED_LIBRARIES += libbase
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500156endif
Doug Zongker49c73a72010-06-29 17:36:28 -0700157
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500158ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
159 LOCAL_SHARED_LIBRARIES += libziparchive
Ethan Yonker58f21322018-08-24 11:17:36 -0500160 LOCAL_C_INCLUDES += $(LOCAL_PATH)/otautil/include
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500161else
162 LOCAL_SHARED_LIBRARIES += libminzip
163 LOCAL_CFLAGS += -DUSE_MINZIP
164endif
165
Dees_Troy4546fe72013-01-10 14:33:27 +0000166ifneq ($(wildcard system/core/libsparse/Android.mk),)
167LOCAL_SHARED_LIBRARIES += libsparse
168endif
169
Ethan Yonker7af51ce2014-04-04 13:33:30 -0500170ifeq ($(TW_OEM_BUILD),true)
171 LOCAL_CFLAGS += -DTW_OEM_BUILD
172 BOARD_HAS_NO_REAL_SDCARD := true
173 TW_USE_TOOLBOX := true
bigbiff bigbiffc7eee6f2014-09-02 18:59:01 -0400174 TW_EXCLUDE_MTP := true
Ethan Yonker7af51ce2014-04-04 13:33:30 -0500175endif
Yabin Cui99281df2016-02-17 12:21:52 -0800176
Doug Zongker49c73a72010-06-29 17:36:28 -0700177ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500178 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 28; echo $$?),0)
179 LOCAL_CFLAGS += -DUSE_EXT4
180 LOCAL_C_INCLUDES += system/extras/ext4_utils
181 LOCAL_SHARED_LIBRARIES += libext4_utils
182 ifneq ($(wildcard external/lz4/Android.mk),)
183 #LOCAL_STATIC_LIBRARIES += liblz4
184 endif
Tom Marshall56fe5e72015-04-17 05:23:00 -0700185 endif
Doug Zongker49c73a72010-06-29 17:36:28 -0700186endif
Matt Mower87413642017-01-17 21:14:46 -0600187LOCAL_C_INCLUDES += external/libselinux/include
188LOCAL_SHARED_LIBRARIES += libselinux
Doug Zongker49c73a72010-06-29 17:36:28 -0700189
Elliott Hughes01fcbe12016-05-23 17:43:41 -0700190ifeq ($(AB_OTA_UPDATER),true)
191 LOCAL_CFLAGS += -DAB_OTA_UPDATER=1
bigbiff bigbiffc630cee2019-01-03 20:14:06 -0500192 LOCAL_SHARED_LIBRARIES += libhardware android.hardware.boot@1.0
Ethan Yonker58f21322018-08-24 11:17:36 -0500193 LOCAL_REQUIRED_MODULES += libhardware
Elliott Hughes01fcbe12016-05-23 17:43:41 -0700194endif
195
Ying Wang5a50b1b2015-03-10 11:56:56 -0700196LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800197
Dees_Troy1669f892013-09-04 18:35:08 +0000198#ifeq ($(TARGET_RECOVERY_UI_LIB),)
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500199# LOCAL_SRC_FILES += default_device.cpp
Dees_Troy1669f892013-09-04 18:35:08 +0000200#else
201# LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UI_LIB)
202#endif
Ethan Yonker93382822018-11-01 15:25:31 -0500203ifeq ($(TARGET_RECOVERY_TWRP_LIB),)
204 LOCAL_SRC_FILES += BasePartition.cpp
205else
206 LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_TWRP_LIB)
207endif
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800208
Doug Zongkercc8cd3f2010-09-20 12:16:13 -0700209LOCAL_C_INCLUDES += system/extras/ext4_utils
210
that0e2140e2016-08-10 21:04:26 +0200211tw_git_revision := $(shell git -C $(LOCAL_PATH) rev-parse --short=8 HEAD 2>/dev/null)
212ifeq ($(shell git -C $(LOCAL_PATH) diff --quiet; echo $$?),1)
213 tw_git_revision := $(tw_git_revision)-dirty
214endif
215LOCAL_CFLAGS += -DTW_GIT_REVISION='"$(tw_git_revision)"'
216
bigbiff bigbiffaf32bb92018-12-18 18:39:53 -0500217ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
218ifeq ($(TW_EXCLUDE_MTP),)
219 LOCAL_SHARED_LIBRARIES += libtwrpmtp-ffs
220endif
221else
222ifeq ($(TW_EXCLUDE_MTP),)
223 LOCAL_CFLAGS += -DTW_HAS_LEGACY_MTP
224 LOCAL_SHARED_LIBRARIES += libtwrpmtp-legacy
225endif
226endif
227
Dees_Troy51a0e822012-09-05 15:24:24 -0400228#TWRP Build Flags
bigbiff bigbiffc7eee6f2014-09-02 18:59:01 -0400229ifeq ($(TW_EXCLUDE_MTP),)
bigbiff bigbiffc7eee6f2014-09-02 18:59:01 -0400230 LOCAL_CFLAGS += -DTW_HAS_MTP
231endif
Ricardo Gomezc9ecd442013-07-05 16:13:52 -0700232ifneq ($(TW_NO_SCREEN_TIMEOUT),)
233 LOCAL_CFLAGS += -DTW_NO_SCREEN_TIMEOUT
234endif
Dees_Troy51a0e822012-09-05 15:24:24 -0400235ifeq ($(BOARD_HAS_NO_REAL_SDCARD), true)
236 LOCAL_CFLAGS += -DBOARD_HAS_NO_REAL_SDCARD
237endif
Dees_Troy51a0e822012-09-05 15:24:24 -0400238ifneq ($(RECOVERY_SDCARD_ON_DATA),)
239 LOCAL_CFLAGS += -DRECOVERY_SDCARD_ON_DATA
240endif
241ifneq ($(TW_INCLUDE_DUMLOCK),)
242 LOCAL_CFLAGS += -DTW_INCLUDE_DUMLOCK
243endif
244ifneq ($(TW_INTERNAL_STORAGE_PATH),)
245 LOCAL_CFLAGS += -DTW_INTERNAL_STORAGE_PATH=$(TW_INTERNAL_STORAGE_PATH)
246endif
247ifneq ($(TW_INTERNAL_STORAGE_MOUNT_POINT),)
248 LOCAL_CFLAGS += -DTW_INTERNAL_STORAGE_MOUNT_POINT=$(TW_INTERNAL_STORAGE_MOUNT_POINT)
249endif
250ifneq ($(TW_EXTERNAL_STORAGE_PATH),)
251 LOCAL_CFLAGS += -DTW_EXTERNAL_STORAGE_PATH=$(TW_EXTERNAL_STORAGE_PATH)
252endif
253ifneq ($(TW_EXTERNAL_STORAGE_MOUNT_POINT),)
254 LOCAL_CFLAGS += -DTW_EXTERNAL_STORAGE_MOUNT_POINT=$(TW_EXTERNAL_STORAGE_MOUNT_POINT)
255endif
ChampionSwimmercf33e4d2013-02-03 13:59:22 +0530256ifeq ($(TW_HAS_NO_BOOT_PARTITION), true)
257 LOCAL_CFLAGS += -DTW_HAS_NO_BOOT_PARTITION
258endif
Dees_Troy51a0e822012-09-05 15:24:24 -0400259ifeq ($(TW_NO_REBOOT_BOOTLOADER), true)
260 LOCAL_CFLAGS += -DTW_NO_REBOOT_BOOTLOADER
261endif
262ifeq ($(TW_NO_REBOOT_RECOVERY), true)
263 LOCAL_CFLAGS += -DTW_NO_REBOOT_RECOVERY
264endif
265ifeq ($(TW_NO_BATT_PERCENT), true)
266 LOCAL_CFLAGS += -DTW_NO_BATT_PERCENT
267endif
Jenkins1710bf22014-10-02 20:22:21 -0400268ifeq ($(TW_NO_CPU_TEMP), true)
269 LOCAL_CFLAGS += -DTW_NO_CPU_TEMP
270endif
Dees_Troy51a0e822012-09-05 15:24:24 -0400271ifneq ($(TW_CUSTOM_POWER_BUTTON),)
272 LOCAL_CFLAGS += -DTW_CUSTOM_POWER_BUTTON=$(TW_CUSTOM_POWER_BUTTON)
273endif
274ifeq ($(TW_ALWAYS_RMRF), true)
275 LOCAL_CFLAGS += -DTW_ALWAYS_RMRF
276endif
277ifeq ($(TW_NEVER_UNMOUNT_SYSTEM), true)
278 LOCAL_CFLAGS += -DTW_NEVER_UNMOUNT_SYSTEM
279endif
280ifeq ($(TW_NO_USB_STORAGE), true)
281 LOCAL_CFLAGS += -DTW_NO_USB_STORAGE
282endif
283ifeq ($(TW_INCLUDE_INJECTTWRP), true)
284 LOCAL_CFLAGS += -DTW_INCLUDE_INJECTTWRP
285endif
286ifeq ($(TW_INCLUDE_BLOBPACK), true)
287 LOCAL_CFLAGS += -DTW_INCLUDE_BLOBPACK
288endif
Dees_Troy51a0e822012-09-05 15:24:24 -0400289ifneq ($(TARGET_USE_CUSTOM_LUN_FILE_PATH),)
290 LOCAL_CFLAGS += -DCUSTOM_LUN_FILE=\"$(TARGET_USE_CUSTOM_LUN_FILE_PATH)\"
291endif
292ifneq ($(BOARD_UMS_LUNFILE),)
293 LOCAL_CFLAGS += -DCUSTOM_LUN_FILE=\"$(BOARD_UMS_LUNFILE)\"
294endif
Dees_Troy51a0e822012-09-05 15:24:24 -0400295ifeq ($(TW_HAS_DOWNLOAD_MODE), true)
296 LOCAL_CFLAGS += -DTW_HAS_DOWNLOAD_MODE
297endif
mauronofrioe9a49ef2018-10-03 13:38:16 +0200298ifeq ($(TW_HAS_EDL_MODE), true)
299 LOCAL_CFLAGS += -DTW_HAS_EDL_MODE
300endif
bigbiff bigbiff87940362013-03-09 09:58:50 -0500301ifeq ($(TW_NO_SCREEN_BLANK), true)
302 LOCAL_CFLAGS += -DTW_NO_SCREEN_BLANK
303endif
Dees_Troy51a0e822012-09-05 15:24:24 -0400304ifeq ($(TW_SDEXT_NO_EXT4), true)
305 LOCAL_CFLAGS += -DTW_SDEXT_NO_EXT4
306endif
Dees_Troyfdf5fcc2012-09-11 10:27:01 -0400307ifeq ($(TW_FORCE_CPUINFO_FOR_DEVICE_ID), true)
308 LOCAL_CFLAGS += -DTW_FORCE_CPUINFO_FOR_DEVICE_ID
309endif
Dees_Troy3f5c4e82013-02-01 15:16:59 +0000310ifeq ($(TW_NO_EXFAT_FUSE), true)
311 LOCAL_CFLAGS += -DTW_NO_EXFAT_FUSE
312endif
bigbiff bigbiff3ed778a2019-03-12 19:28:31 -0400313ifeq ($(TW_NO_HAPTICS), true)
314 LOCAL_CFLAGS += -DTW_NO_HAPTICS
315endif
Dees_Troy51a0e822012-09-05 15:24:24 -0400316ifeq ($(TW_INCLUDE_JB_CRYPTO), true)
Ethan Yonker253368a2014-11-25 15:00:52 -0600317 TW_INCLUDE_CRYPTO := true
Dees_Troy51a0e822012-09-05 15:24:24 -0400318endif
Ethan Yonker4eca40d2014-11-11 14:52:28 -0600319ifeq ($(TW_INCLUDE_L_CRYPTO), true)
Ethan Yonker253368a2014-11-25 15:00:52 -0600320 TW_INCLUDE_CRYPTO := true
321endif
322ifeq ($(TW_INCLUDE_CRYPTO), true)
Ethan Yonker4eca40d2014-11-11 14:52:28 -0600323 LOCAL_CFLAGS += -DTW_INCLUDE_CRYPTO
Ethan Yonker98661c12018-10-17 08:39:28 -0500324 LOCAL_SHARED_LIBRARIES += libcryptfsfde libgpt_twrp
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500325 LOCAL_C_INCLUDES += external/boringssl/src/include
Ethan Yonkerbd7492d2016-12-07 13:55:01 -0600326 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0)
327 TW_INCLUDE_CRYPTO_FBE := true
328 LOCAL_CFLAGS += -DTW_INCLUDE_FBE
329 LOCAL_SHARED_LIBRARIES += libe4crypt
Ethan Yonker93382822018-11-01 15:25:31 -0500330 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
331 LOCAL_CFLAGS += -DTW_INCLUDE_FBE_METADATA_DECRYPT
332 endif
Ethan Yonkerbd7492d2016-12-07 13:55:01 -0600333 endif
nkk7171c6c502017-01-05 23:55:05 +0200334 ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),)
335 ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),false)
336 LOCAL_CFLAGS += -DTW_CRYPTO_USE_SYSTEM_VOLD
337 LOCAL_STATIC_LIBRARIES += libvolddecrypt
338 endif
339 endif
Ethan Yonker4eca40d2014-11-11 14:52:28 -0600340endif
D. Andrei Măceșb29a5e22016-12-22 06:19:44 -0500341WITH_CRYPTO_UTILS := \
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500342 $(if $(wildcard system/core/libcrypto_utils/android_pubkey.c),true)
Anatoly Smaznov10c11f62013-02-12 13:33:40 +0700343ifeq ($(TW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID), true)
344 LOCAL_CFLAGS += -DTW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID
345endif
lambdadroidfc0b16d2017-08-04 17:16:53 +0200346ifeq ($(TW_USE_SERIALNO_PROPERTY_FOR_DEVICE_ID), true)
347 LOCAL_CFLAGS += -DTW_USE_SERIALNO_PROPERTY_FOR_DEVICE_ID
348endif
Dees_Troy2f9117a2013-02-17 19:52:09 -0600349ifneq ($(TW_BRIGHTNESS_PATH),)
350 LOCAL_CFLAGS += -DTW_BRIGHTNESS_PATH=$(TW_BRIGHTNESS_PATH)
351endif
xNUTxe85f02d2014-07-18 01:30:58 +0200352ifneq ($(TW_SECONDARY_BRIGHTNESS_PATH),)
353 LOCAL_CFLAGS += -DTW_SECONDARY_BRIGHTNESS_PATH=$(TW_SECONDARY_BRIGHTNESS_PATH)
354endif
Dees_Troy2f9117a2013-02-17 19:52:09 -0600355ifneq ($(TW_MAX_BRIGHTNESS),)
356 LOCAL_CFLAGS += -DTW_MAX_BRIGHTNESS=$(TW_MAX_BRIGHTNESS)
357endif
Greg Wallace36ade452015-11-08 13:54:25 -0500358ifneq ($(TW_DEFAULT_BRIGHTNESS),)
359 LOCAL_CFLAGS += -DTW_DEFAULT_BRIGHTNESS=$(TW_DEFAULT_BRIGHTNESS)
360endif
Dees_Troyf33b4902013-03-01 00:51:39 +0000361ifneq ($(TW_CUSTOM_BATTERY_PATH),)
362 LOCAL_CFLAGS += -DTW_CUSTOM_BATTERY_PATH=$(TW_CUSTOM_BATTERY_PATH)
363endif
Jenkins1710bf22014-10-02 20:22:21 -0400364ifneq ($(TW_CUSTOM_CPU_TEMP_PATH),)
365 LOCAL_CFLAGS += -DTW_CUSTOM_CPU_TEMP_PATH=$(TW_CUSTOM_CPU_TEMP_PATH)
366endif
Dees_Troy83bd4832013-05-04 12:39:56 +0000367ifneq ($(TW_EXCLUDE_ENCRYPTED_BACKUPS), true)
368 LOCAL_SHARED_LIBRARIES += libopenaes
369else
370 LOCAL_CFLAGS += -DTW_EXCLUDE_ENCRYPTED_BACKUPS
371endif
Vojtech Bocekd0e38bc2014-02-03 23:36:57 +0100372ifeq ($(TARGET_RECOVERY_QCOM_RTC_FIX),)
Michael Bestas4a185582017-04-28 15:45:26 +0300373 ifneq ($(filter msm8226 msm8x26 msm8610 msm8974 msm8x74 msm8084 msm8x84 apq8084 msm8909 msm8916 msm8992 msm8994 msm8952 msm8996 msm8937 msm8953 msm8998,$(TARGET_BOARD_PLATFORM)),)
374 LOCAL_CFLAGS += -DQCOM_RTC_FIX
375 else ifeq ($(TARGET_CPU_VARIANT),krait)
Vojtech Bocekd0e38bc2014-02-03 23:36:57 +0100376 LOCAL_CFLAGS += -DQCOM_RTC_FIX
377 endif
378else ifeq ($(TARGET_RECOVERY_QCOM_RTC_FIX),true)
379 LOCAL_CFLAGS += -DQCOM_RTC_FIX
380endif
Matt Mower6883d732014-03-20 17:28:13 -0500381ifneq ($(TW_NO_LEGACY_PROPS),)
382 LOCAL_CFLAGS += -DTW_NO_LEGACY_PROPS
383endif
Dees Troy4159aed2014-02-28 17:24:43 +0000384ifneq ($(wildcard bionic/libc/include/sys/capability.h),)
385 LOCAL_CFLAGS += -DHAVE_CAPABILITIES
386endif
Matt Mowerec009e82015-01-30 13:00:49 -0600387ifneq ($(TARGET_RECOVERY_INITRC),)
388 TW_EXCLUDE_DEFAULT_USB_INIT := true
389endif
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500390ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
391 LOCAL_CFLAGS += -DTW_USE_NEW_MINADBD
392endif
Ethan Yonker74db1572015-10-28 12:44:49 -0500393ifneq ($(TW_DEFAULT_LANGUAGE),)
394 LOCAL_CFLAGS += -DTW_DEFAULT_LANGUAGE=$(TW_DEFAULT_LANGUAGE)
395else
396 LOCAL_CFLAGS += -DTW_DEFAULT_LANGUAGE=en
397endif
Phoenix591e444d112018-02-03 07:23:54 +0000398ifneq ($(TW_CLOCK_OFFSET),)
399 LOCAL_CFLAGS += -DTW_CLOCK_OFFSET=$(TW_CLOCK_OFFSET)
400endif
Ethan Yonker58f21322018-08-24 11:17:36 -0500401LOCAL_REQUIRED_MODULES += \
Matt Mower031163b2014-11-01 15:13:03 -0500402 dump_image \
403 erase_image \
404 flash_image \
Matt Mower031163b2014-11-01 15:13:03 -0500405 mke2fs.conf \
Matt Mower031163b2014-11-01 15:13:03 -0500406 pigz \
407 teamwin \
Ethan Yonkerf1179622016-08-25 15:32:21 -0500408 toolbox_symlinks \
Matt Mower031163b2014-11-01 15:13:03 -0500409 twrp \
Matt Mower18794c82015-11-11 16:22:45 -0600410 fsck.fat \
411 fatlabel \
412 mkfs.fat \
HashBanged974bb2016-01-30 14:20:09 -0500413 permissive.sh \
Ethan Yonkerf1179622016-08-25 15:32:21 -0500414 simg2img_twrp \
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500415 libbootloader_message_twrp \
416 init.recovery.hlthchrg.rc \
Ethan Yonkerf1179622016-08-25 15:32:21 -0500417 init.recovery.service.rc
Matt Mower031163b2014-11-01 15:13:03 -0500418
Ethan Yonkerbcc502c2014-11-10 11:22:10 -0600419ifneq ($(TARGET_ARCH), arm64)
Ethan Yonker4f6a9762015-03-09 13:58:54 -0500420 ifneq ($(TARGET_ARCH), x86_64)
421 LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker
422 else
423 LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64
424 endif
Ethan Yonker1902c792014-12-03 16:48:36 -0600425else
426 LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64
Ethan Yonkerbcc502c2014-11-10 11:22:10 -0600427endif
428ifneq ($(TW_USE_TOOLBOX), true)
Matt Mower84057612017-01-08 13:32:18 -0600429 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
430 LOCAL_POST_INSTALL_CMD := \
431 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sbin && \
432 ln -sf /sbin/busybox $(TARGET_RECOVERY_ROOT_OUT)/sbin/sh
433 endif
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500434else
435 ifneq ($(wildcard external/toybox/Android.mk),)
Ethan Yonker58f21322018-08-24 11:17:36 -0500436 LOCAL_REQUIRED_MODULES += toybox_symlinks
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500437 endif
dianlujitaoce608ab2015-12-28 23:51:19 +0800438 ifneq ($(wildcard external/zip/Android.mk),)
Ethan Yonker58f21322018-08-24 11:17:36 -0500439 LOCAL_REQUIRED_MODULES += zip
dianlujitaoce608ab2015-12-28 23:51:19 +0800440 endif
441 ifneq ($(wildcard external/unzip/Android.mk),)
Ethan Yonker58f21322018-08-24 11:17:36 -0500442 LOCAL_REQUIRED_MODULES += unzip
dianlujitaoce608ab2015-12-28 23:51:19 +0800443 endif
Ethan Yonkerbcc502c2014-11-10 11:22:10 -0600444endif
Matt Mower84057612017-01-08 13:32:18 -0600445
Matt Mower20172792014-11-14 10:54:03 -0600446ifneq ($(TW_NO_EXFAT), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500447 LOCAL_REQUIRED_MODULES += mkexfatfs fsckexfat
Ethan Yonker34741d92016-02-06 13:22:45 -0600448 ifneq ($(TW_NO_EXFAT_FUSE), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500449 LOCAL_REQUIRED_MODULES += exfat-fuse
Ethan Yonker34741d92016-02-06 13:22:45 -0600450 endif
Matt Mower20172792014-11-14 10:54:03 -0600451endif
Matt Mower031163b2014-11-01 15:13:03 -0500452ifeq ($(BOARD_HAS_NO_REAL_SDCARD),)
Ethan Yonker483e9f42016-01-11 22:21:18 -0600453 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
Ethan Yonker58f21322018-08-24 11:17:36 -0500454 LOCAL_REQUIRED_MODULES += sgdisk
Ethan Yonker483e9f42016-01-11 22:21:18 -0600455 else
Ethan Yonker58f21322018-08-24 11:17:36 -0500456 LOCAL_REQUIRED_MODULES += sgdisk_static
Ethan Yonker483e9f42016-01-11 22:21:18 -0600457 endif
Matt Mower031163b2014-11-01 15:13:03 -0500458endif
459ifneq ($(TW_EXCLUDE_ENCRYPTED_BACKUPS), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500460 LOCAL_REQUIRED_MODULES += openaes openaes_license
Matt Mower031163b2014-11-01 15:13:03 -0500461endif
462ifeq ($(TW_INCLUDE_DUMLOCK), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500463 LOCAL_REQUIRED_MODULES += \
Matt Mower031163b2014-11-01 15:13:03 -0500464 htcdumlock htcdumlocksys flash_imagesys dump_imagesys libbmlutils.so \
465 libflashutils.so libmmcutils.so libmtdutils.so HTCDumlock.apk
466endif
Matt Mower031163b2014-11-01 15:13:03 -0500467ifeq ($(TW_INCLUDE_FB2PNG), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500468 LOCAL_REQUIRED_MODULES += fb2png
Matt Mower031163b2014-11-01 15:13:03 -0500469endif
470ifneq ($(TW_OEM_BUILD),true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500471 LOCAL_REQUIRED_MODULES += orscmd
Matt Mower031163b2014-11-01 15:13:03 -0500472endif
473ifeq ($(BOARD_USES_BML_OVER_MTD),true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500474 LOCAL_REQUIRED_MODULES += bml_over_mtd
Matt Mower031163b2014-11-01 15:13:03 -0500475endif
476ifeq ($(TW_INCLUDE_INJECTTWRP), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500477 LOCAL_REQUIRED_MODULES += injecttwrp
Matt Mower031163b2014-11-01 15:13:03 -0500478endif
Matt Mowerec009e82015-01-30 13:00:49 -0600479ifneq ($(TW_EXCLUDE_DEFAULT_USB_INIT), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500480 LOCAL_REQUIRED_MODULES += init.recovery.usb.rc
Matt Mowerec009e82015-01-30 13:00:49 -0600481endif
Captain Throwback1f127752016-01-19 17:30:20 -0500482ifeq ($(TWRP_INCLUDE_LOGCAT), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500483 LOCAL_REQUIRED_MODULES += logcat
Ethan Yonkere5a288c2016-02-15 09:23:57 -0600484 ifeq ($(TARGET_USES_LOGD), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500485 LOCAL_REQUIRED_MODULES += logd libsysutils libnl init.recovery.logd.rc
Ethan Yonkere5a288c2016-02-15 09:23:57 -0600486 endif
Captain Throwback1f127752016-01-19 17:30:20 -0500487endif
Matt Mower031163b2014-11-01 15:13:03 -0500488# Allow devices to specify device-specific recovery dependencies
489ifneq ($(TARGET_RECOVERY_DEVICE_MODULES),)
Ethan Yonker58f21322018-08-24 11:17:36 -0500490 LOCAL_REQUIRED_MODULES += $(TARGET_RECOVERY_DEVICE_MODULES)
Matt Mower031163b2014-11-01 15:13:03 -0500491endif
Dees Troy3454ade2015-01-20 19:21:04 +0000492LOCAL_CFLAGS += -DTWRES=\"$(TWRES_PATH)\"
493LOCAL_CFLAGS += -DTWHTCD_PATH=\"$(TWHTCD_PATH)\"
Ethan Yonkerb81d9052015-07-09 13:20:53 -0500494ifeq ($(TW_INCLUDE_NTFS_3G),true)
Jason Riordan6c28ee82016-05-12 09:06:57 -0400495ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
Ethan Yonker58f21322018-08-24 11:17:36 -0500496 LOCAL_REQUIRED_MODULES += \
Greg Wallaceb39e6c62015-12-29 00:55:26 -0500497 mount.ntfs \
498 fsck.ntfs \
499 mkfs.ntfs
500else
Ethan Yonker58f21322018-08-24 11:17:36 -0500501 LOCAL_REQUIRED_MODULES += \
Ethan Yonkerb81d9052015-07-09 13:20:53 -0500502 ntfs-3g \
503 ntfsfix \
504 mkntfs
505endif
Greg Wallaceb39e6c62015-12-29 00:55:26 -0500506endif
Matt Mower58294912015-12-10 11:54:28 -0600507ifeq ($(TARGET_USERIMAGES_USE_F2FS), true)
508ifeq ($(shell test $(CM_PLATFORM_SDK_VERSION) -ge 3; echo $$?),0)
Ethan Yonker58f21322018-08-24 11:17:36 -0500509 LOCAL_REQUIRED_MODULES += \
Matt Mower58294912015-12-10 11:54:28 -0600510 fsck.f2fs \
511 mkfs.f2fs
512endif
Ethan Yonker93382822018-11-01 15:25:31 -0500513ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
514 LOCAL_REQUIRED_MODULES += sload.f2fs
515endif
Matt Mower58294912015-12-10 11:54:28 -0600516endif
Matt Mower031163b2014-11-01 15:13:03 -0500517
Andreas Blaesius38d2d522019-01-29 14:00:56 +0100518ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
Ethan Yonker58f21322018-08-24 11:17:36 -0500519 LOCAL_REQUIRED_MODULES += file_contexts_text
Andreas Blaesius38d2d522019-01-29 14:00:56 +0100520else ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 25; echo $$?),0)
521 LOCAL_ADDITIONAL_DEPENDENCIES += file_contexts_text
Matt Mowerd821c962017-02-15 12:36:18 -0600522endif
523
Mark Salyzyn13aca592016-03-09 14:58:16 -0800524ifeq ($(BOARD_CACHEIMAGE_PARTITION_SIZE),)
oshmoun9220dba2018-11-24 11:26:01 +0100525LOCAL_REQUIRED_MODULES += recovery-persist recovery-refresh
Mark Salyzyn13aca592016-03-09 14:58:16 -0800526endif
527
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800528include $(BUILD_EXECUTABLE)
529
Matt Mowerd821c962017-02-15 12:36:18 -0600530# Symlink for file_contexts
531include $(CLEAR_VARS)
532
Captain Throwback3184b2f2017-03-07 12:07:40 -0500533LOCAL_MODULE := file_contexts_text
Matt Mowerd821c962017-02-15 12:36:18 -0600534LOCAL_MODULE_TAGS := optional
Captain Throwback3184b2f2017-03-07 12:07:40 -0500535LOCAL_REQUIRED_MODULES := file_contexts.bin
Matt Mowerd821c962017-02-15 12:36:18 -0600536LOCAL_POST_INSTALL_CMD := \
Ethan Yonker58f21322018-08-24 11:17:36 -0500537 $(hide) cp -f $(PRODUCT_OUT)/obj/ETC/file_contexts.bin_intermediates/file_contexts.concat.tmp $(TARGET_RECOVERY_ROOT_OUT)/file_contexts
Matt Mowerd821c962017-02-15 12:36:18 -0600538
539include $(BUILD_PHONY_PACKAGE)
540
Ethan Yonker5c933692014-04-04 11:26:32 -0500541ifneq ($(TW_USE_TOOLBOX), true)
Doug Zongker73ae31c2009-12-09 17:01:45 -0800542include $(CLEAR_VARS)
Dees_Troyc04dcf72012-10-02 10:46:37 -0400543# Create busybox symlinks... gzip and gunzip are excluded because those need to link to pigz instead
544BUSYBOX_LINKS := $(shell cat external/busybox/busybox-full.links)
Matt Mower18794c82015-11-11 16:22:45 -0600545exclude := tune2fs mke2fs mkdosfs mkfs.vfat gzip gunzip
Matt Mower81742fb2014-09-01 14:40:52 -0500546
Ethan Yonkera60c7862016-02-25 15:32:06 -0600547# Having /sbin/modprobe present on 32 bit devices with can cause a massive
548# performance problem if the kernel has CONFIG_MODULES=y
549ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
550 ifneq ($(TARGET_ARCH), arm64)
551 ifneq ($(TARGET_ARCH), x86_64)
552 exclude += modprobe
553 endif
554 endif
555endif
556
Matt Mower81742fb2014-09-01 14:40:52 -0500557# If busybox does not have restorecon, assume it does not have SELinux support.
558# Then, let toolbox provide 'ls' so -Z is available to list SELinux contexts.
Matt Mower87413642017-01-17 21:14:46 -0600559ifeq ($(filter restorecon, $(notdir $(BUSYBOX_LINKS))),)
560 exclude += ls
Dees Troy8d66f8b2013-10-08 14:04:55 +0000561endif
Matt Mower81742fb2014-09-01 14:40:52 -0500562
563RECOVERY_BUSYBOX_TOOLS := $(filter-out $(exclude), $(notdir $(BUSYBOX_LINKS)))
564RECOVERY_BUSYBOX_SYMLINKS := $(addprefix $(TARGET_RECOVERY_ROOT_OUT)/sbin/, $(RECOVERY_BUSYBOX_TOOLS))
Dees_Troyc04dcf72012-10-02 10:46:37 -0400565$(RECOVERY_BUSYBOX_SYMLINKS): BUSYBOX_BINARY := busybox
566$(RECOVERY_BUSYBOX_SYMLINKS): $(LOCAL_INSTALLED_MODULE)
567 @echo "Symlink: $@ -> $(BUSYBOX_BINARY)"
568 @mkdir -p $(dir $@)
569 @rm -rf $@
570 $(hide) ln -sf $(BUSYBOX_BINARY) $@
571
Matt Mower031163b2014-11-01 15:13:03 -0500572include $(CLEAR_VARS)
573LOCAL_MODULE := busybox_symlinks
574LOCAL_MODULE_TAGS := optional
575LOCAL_ADDITIONAL_DEPENDENCIES := $(RECOVERY_BUSYBOX_SYMLINKS)
Dees Troyb47f28b2014-12-11 17:20:59 +0000576ifneq (,$(filter $(PLATFORM_SDK_VERSION),16 17 18))
577ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_BUSYBOX_SYMLINKS)
578endif
Matt Mower031163b2014-11-01 15:13:03 -0500579include $(BUILD_PHONY_PACKAGE)
580RECOVERY_BUSYBOX_SYMLINKS :=
581endif # !TW_USE_TOOLBOX
Dees_Troyc04dcf72012-10-02 10:46:37 -0400582
Mark Salyzyn13aca592016-03-09 14:58:16 -0800583# recovery-persist (system partition dynamic executable run after /data mounts)
584# ===============================
Ethan Yonkerf1179622016-08-25 15:32:21 -0500585ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0)
586 include $(CLEAR_VARS)
Ethan Yonkerd9918b72017-09-15 08:17:42 -0500587 LOCAL_SRC_FILES := \
588 recovery-persist.cpp \
589 rotate_logs.cpp
Ethan Yonkerf1179622016-08-25 15:32:21 -0500590 LOCAL_MODULE := recovery-persist
591 LOCAL_SHARED_LIBRARIES := liblog libbase
592 LOCAL_CFLAGS := -Werror
593 LOCAL_INIT_RC := recovery-persist.rc
594 include $(BUILD_EXECUTABLE)
595endif
Doug Zongker73ae31c2009-12-09 17:01:45 -0800596
Mark Salyzyn13aca592016-03-09 14:58:16 -0800597# recovery-refresh (system partition dynamic executable run at init)
598# ===============================
Ethan Yonkerf1179622016-08-25 15:32:21 -0500599ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 24; echo $$?),0)
600 include $(CLEAR_VARS)
Ethan Yonkerd9918b72017-09-15 08:17:42 -0500601 LOCAL_SRC_FILES := \
602 recovery-refresh.cpp \
603 rotate_logs.cpp
Ethan Yonkerf1179622016-08-25 15:32:21 -0500604 LOCAL_MODULE := recovery-refresh
Ethan Yonkerd9918b72017-09-15 08:17:42 -0500605 LOCAL_SHARED_LIBRARIES := liblog libbase
Ethan Yonkerf1179622016-08-25 15:32:21 -0500606 LOCAL_CFLAGS := -Werror
607 LOCAL_INIT_RC := recovery-refresh.rc
608 include $(BUILD_EXECUTABLE)
609endif
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800610
Ethan Yonker34ae4832016-08-24 15:32:18 -0500611# shared libfusesideload
612# ===============================
613include $(CLEAR_VARS)
Ethan Yonker34ae4832016-08-24 15:32:18 -0500614LOCAL_CLANG := true
Ethan Yonker58f21322018-08-24 11:17:36 -0500615LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
Ethan Yonker34ae4832016-08-24 15:32:18 -0500616LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
617
618LOCAL_MODULE_TAGS := optional
619LOCAL_MODULE := libfusesideload
Ethan Yonkerf1179622016-08-25 15:32:21 -0500620LOCAL_SHARED_LIBRARIES := libcutils libc
Ethan Yonker99af7662016-09-15 14:48:29 -0500621ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
Ethan Yonkerf1179622016-08-25 15:32:21 -0500622 LOCAL_C_INCLUDES := $(LOCAL_PATH)/libmincrypt/includes
623 LOCAL_SHARED_LIBRARIES += libmincrypttwrp
624 LOCAL_CFLAGS += -DUSE_MINCRYPT
625else
626 LOCAL_SHARED_LIBRARIES += libcrypto
627endif
Ethan Yonker58f21322018-08-24 11:17:36 -0500628ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
629 LOCAL_SRC_FILES := fuse_sideload22.cpp
630 LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22
631else
632 LOCAL_SRC_FILES := fuse_sideload.cpp
633endif
Ethan Yonker34ae4832016-08-24 15:32:18 -0500634include $(BUILD_SHARED_LIBRARY)
635
Ethan Yonkerecbd3e82017-12-14 14:43:59 -0600636# static libfusesideload
637# =============================== (required to fix build errors in 8.1 due to use by tests)
638include $(CLEAR_VARS)
Ethan Yonkerecbd3e82017-12-14 14:43:59 -0600639LOCAL_CLANG := true
Ethan Yonker58f21322018-08-24 11:17:36 -0500640LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
Ethan Yonkerecbd3e82017-12-14 14:43:59 -0600641LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
642
643LOCAL_MODULE_TAGS := optional
644LOCAL_MODULE := libfusesideload
645LOCAL_SHARED_LIBRARIES := libcutils libc
646ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
647 LOCAL_C_INCLUDES := $(LOCAL_PATH)/libmincrypt/includes
648 LOCAL_STATIC_LIBRARIES += libmincrypttwrp
649 LOCAL_CFLAGS += -DUSE_MINCRYPT
650else
651 LOCAL_STATIC_LIBRARIES += libcrypto_static
652endif
Ethan Yonker58f21322018-08-24 11:17:36 -0500653ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
654 LOCAL_SRC_FILES := fuse_sideload22.cpp
655 LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22
656else
657 LOCAL_SRC_FILES := fuse_sideload.cpp
658endif
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800659include $(BUILD_STATIC_LIBRARY)
660
Elliott Hughes63a31922016-06-09 17:41:22 -0700661# libmounts (static library)
662# ===============================
663include $(CLEAR_VARS)
664LOCAL_SRC_FILES := mounts.cpp
Tao Bao5f85d1f2017-03-28 21:12:36 -0700665LOCAL_CFLAGS := \
666 -Wall \
667 -Werror
Elliott Hughes63a31922016-06-09 17:41:22 -0700668LOCAL_MODULE := libmounts
Tao Bao5f85d1f2017-03-28 21:12:36 -0700669LOCAL_STATIC_LIBRARIES := libbase
Elliott Hughes63a31922016-06-09 17:41:22 -0700670include $(BUILD_STATIC_LIBRARY)
671
Tao Bao62e0bc72017-04-10 16:55:57 -0700672# librecovery (static library)
673# ===============================
674include $(CLEAR_VARS)
675LOCAL_SRC_FILES := \
676 install.cpp
Tao Baob24510c2017-04-20 17:54:27 -0700677LOCAL_CFLAGS := -Wall -Werror
Tao Bao62e0bc72017-04-10 16:55:57 -0700678LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
Tao Bao25dbe172017-04-12 23:52:20 -0700679
680ifeq ($(AB_OTA_UPDATER),true)
681 LOCAL_CFLAGS += -DAB_OTA_UPDATER=1
682endif
683
Tao Bao62e0bc72017-04-10 16:55:57 -0700684LOCAL_MODULE := librecovery
685LOCAL_STATIC_LIBRARIES := \
686 libminui \
Tao Baocfe53c22017-10-03 14:37:21 -0700687 libotautil \
Tao Baoda320ac2017-04-10 16:55:57 -0700688 libvintf_recovery \
Tao Bao62e0bc72017-04-10 16:55:57 -0700689 libcrypto_utils \
690 libcrypto \
Elliott Hughese1bb7a52017-06-28 08:00:17 -0700691 libbase \
692 libziparchive \
Tao Bao62e0bc72017-04-10 16:55:57 -0700693
694include $(BUILD_STATIC_LIBRARY)
695
Ethan Yonker34ae4832016-08-24 15:32:18 -0500696# shared libaosprecovery for Apache code
697# ===============================
Dees_Troy2673cec2013-04-02 20:22:16 +0000698include $(CLEAR_VARS)
699
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800700
Dees_Troy2673cec2013-04-02 20:22:16 +0000701LOCAL_MODULE := libaosprecovery
Matt Mowerdb220442014-10-31 22:43:59 -0500702LOCAL_MODULE_TAGS := eng optional
Ethan Yonkerf1179622016-08-25 15:32:21 -0500703LOCAL_CFLAGS := -std=gnu++0x
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500704LOCAL_SRC_FILES := adb_install.cpp legacy_property_service.cpp set_metadata.cpp tw_atomic.cpp installcommand.cpp zipwrap.cpp
Ethan Yonker941a8992016-12-05 09:04:30 -0600705LOCAL_SHARED_LIBRARIES += libc liblog libcutils libmtdutils libfusesideload libselinux libminzip
706LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)
Ethan Yonkerf1179622016-08-25 15:32:21 -0500707ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
Ethan Yonker534d4e02016-08-26 10:05:03 -0500708 LOCAL_SHARED_LIBRARIES += libstdc++ libstlport
Ethan Yonker941a8992016-12-05 09:04:30 -0600709 LOCAL_C_INCLUDES += bionic external/stlport/stlport
Ethan Yonker58f21322018-08-24 11:17:36 -0500710 LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22
Ethan Yonker534d4e02016-08-26 10:05:03 -0500711else
712 LOCAL_SHARED_LIBRARIES += libc++
713endif
714ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
715 LOCAL_SHARED_LIBRARIES += libmincrypttwrp
Ethan Yonker941a8992016-12-05 09:04:30 -0600716 LOCAL_C_INCLUDES += $(LOCAL_PATH)/libmincrypt/includes
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500717 LOCAL_SRC_FILES += verifier24/verifier.cpp verifier24/asn1_decoder.cpp
Ethan Yonkerf1179622016-08-25 15:32:21 -0500718 LOCAL_CFLAGS += -DUSE_OLD_VERIFIER
719else
Ethan Yonker941a8992016-12-05 09:04:30 -0600720 LOCAL_SHARED_LIBRARIES += libcrypto libbase
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500721 LOCAL_SRC_FILES += verifier.cpp asn1_decoder.cpp
Ethan Yonker58f21322018-08-24 11:17:36 -0500722 LOCAL_C_INCLUDES += $(LOCAL_PATH)/otautil/include
Ethan Yonkerf1179622016-08-25 15:32:21 -0500723endif
Tao Baoa92d8fb2017-06-20 18:11:21 -0700724
Ethan Yonker941a8992016-12-05 09:04:30 -0600725ifeq ($(AB_OTA_UPDATER),true)
726 LOCAL_CFLAGS += -DAB_OTA_UPDATER=1
727endif
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500728ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
Ethan Yonker58f21322018-08-24 11:17:36 -0500729 LOCAL_SRC_FILES += otautil/ZipUtil.cpp otautil/SysUtil.cpp otautil/DirUtil.cpp
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500730 LOCAL_SHARED_LIBRARIES += libziparchive libext4_utils libcrypto libcrypto_utils
731 LOCAL_STATIC_LIBRARIES += libvintf_recovery libfs_mgr liblogwrap libavb libvintf libtinyxml2 libz
Ethan Yonker58f21322018-08-24 11:17:36 -0500732 LOCAL_C_INCLUDES += $(LOCAL_PATH)/otautil/include
733 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 27; echo $$?),0)
734 # Android 9.0 needs c++17 for libvintf
735 LOCAL_CPPFLAGS += -std=c++17
736 # Android 9.0's libvintf also needs this library
737 LOCAL_STATIC_LIBRARIES += libhidl-gen-utils
738 endif
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -0800739else
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500740 LOCAL_CFLAGS += -DUSE_MINZIP
Doug Zongker73ae31c2009-12-09 17:01:45 -0800741endif
Dees_Troy2673cec2013-04-02 20:22:16 +0000742
743include $(BUILD_SHARED_LIBRARY)
Tao Baod80a9982016-03-03 11:43:47 -0800744# libverifier (static library)
745# ===============================
Kenny Root7a4adb52013-10-09 10:14:35 -0700746include $(CLEAR_VARS)
Tao Bao80e46e02015-06-03 10:49:29 -0700747LOCAL_CLANG := true
Kenny Root7a4adb52013-10-09 10:14:35 -0700748LOCAL_MODULE := libverifier
Kenny Root7a4adb52013-10-09 10:14:35 -0700749LOCAL_SRC_FILES := \
Kenny Root7a4adb52013-10-09 10:14:35 -0700750 asn1_decoder.cpp \
Tao Baod7bf82e2017-03-18 09:24:11 -0700751 verifier.cpp
Tao Bao0ecbd762017-01-16 21:16:58 -0800752LOCAL_STATIC_LIBRARIES := \
Tao Bao09e468f2017-09-29 14:39:33 -0700753 libotautil \
Tao Bao0ecbd762017-01-16 21:16:58 -0800754 libcrypto_utils \
755 libcrypto \
756 libbase
Tianjie Xuc89d1e72017-08-28 14:15:07 -0700757LOCAL_CFLAGS := -Wall -Werror
Jed Estep43291862016-02-03 17:02:09 -0800758include $(BUILD_STATIC_LIBRARY)
Doug Zongker73ae31c2009-12-09 17:01:45 -0800759
Tao Bao016120f2017-08-02 17:11:04 -0700760# Wear default device
761# ===============================
762include $(CLEAR_VARS)
763LOCAL_SRC_FILES := wear_device.cpp
Tianjie Xuc89d1e72017-08-28 14:15:07 -0700764LOCAL_CFLAGS := -Wall -Werror
Tao Bao016120f2017-08-02 17:11:04 -0700765
766# Should match TARGET_RECOVERY_UI_LIB in BoardConfig.mk.
767LOCAL_MODULE := librecovery_ui_wear
768
769include $(BUILD_STATIC_LIBRARY)
770
Luke Songa44dba72017-06-12 16:08:33 -0700771# vr headset default device
772# ===============================
773include $(CLEAR_VARS)
774
775LOCAL_SRC_FILES := vr_device.cpp
Tianjie Xuc89d1e72017-08-28 14:15:07 -0700776LOCAL_CFLAGS := -Wall -Werror
Luke Songa44dba72017-06-12 16:08:33 -0700777
778# should match TARGET_RECOVERY_UI_LIB set in BoardConfig.mk
779LOCAL_MODULE := librecovery_ui_vr
780
781include $(BUILD_STATIC_LIBRARY)
782
Dees_Troy51a0e822012-09-05 15:24:24 -0400783commands_recovery_local_path := $(LOCAL_PATH)
Ethan Yonkerecbd3e82017-12-14 14:43:59 -0600784
Ethan Yonker58f21322018-08-24 11:17:36 -0500785# $(LOCAL_PATH)/edify/Android.mk
786# $(LOCAL_PATH)/otafault/Android.mk
787# $(LOCAL_PATH)/bootloader_message/Android.mk
Yabin Cui2f272c02016-06-24 18:22:02 -0700788include \
Ethan Yonker58f21322018-08-24 11:17:36 -0500789 $(commands_TWRP_local_path)/boot_control/Android.mk \
790 $(commands_TWRP_local_path)/tests/Android.mk \
791 $(commands_TWRP_local_path)/tools/Android.mk \
792 $(commands_TWRP_local_path)/updater/Android.mk \
793 $(commands_TWRP_local_path)/update_verifier/Android.mk \
794 $(commands_TWRP_local_path)/bootloader_message_twrp/Android.mk
795
796ifeq ($(shell test $(PLATFORM_SDK_VERSION) -le 25; echo $$?),0)
797include $(commands_TWRP_local_path)/bootloader_message/Android.mk
798endif
Dees_Troy51a0e822012-09-05 15:24:24 -0400799
bigbiff bigbiffaf32bb92018-12-18 18:39:53 -0500800ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
801 include $(commands_TWRP_local_path)/mtp/ffs/Android.mk
802else
803 include $(commands_TWRP_local_path)/mtp/legacy/Android.mk
804endif
805
Matt Mowerf746dbb2015-05-13 22:56:31 -0500806ifeq ($(wildcard system/core/uncrypt/Android.mk),)
Ethan Yonker58f21322018-08-24 11:17:36 -0500807 #include $(commands_TWRP_local_path)/uncrypt/Android.mk
Matt Mowerf746dbb2015-05-13 22:56:31 -0500808endif
809
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500810ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
Ethan Yonker8373cfe2017-09-08 06:50:54 -0500811 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 26; echo $$?),0)
812 TARGET_GLOBAL_CFLAGS += -DTW_USE_MINUI_WITH_DATA
813 CLANG_TARGET_GLOBAL_CFLAGS += -DTW_USE_MINUI_WITH_DATA
814 endif
Ethan Yonker58f21322018-08-24 11:17:36 -0500815 include $(commands_TWRP_local_path)/minadbd/Android.mk \
816 $(commands_TWRP_local_path)/minui/Android.mk
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500817else
Ethan Yonker84d61ce2017-05-10 16:11:35 -0500818 TARGET_GLOBAL_CFLAGS += -DTW_USE_MINUI_21
Ethan Yonker58f21322018-08-24 11:17:36 -0500819 include $(commands_TWRP_local_path)/minadbd21/Android.mk \
820 $(commands_TWRP_local_path)/minui21/Android.mk
Ethan Yonkerc798c9c2015-10-09 11:15:26 -0500821endif
822
Ethan Yonker58f21322018-08-24 11:17:36 -0500823#$(commands_TWRP_local_path)/otautil/Android.mk
Dees_Troy51a0e822012-09-05 15:24:24 -0400824#includes for TWRP
Ethan Yonker58f21322018-08-24 11:17:36 -0500825include $(commands_TWRP_local_path)/injecttwrp/Android.mk \
826 $(commands_TWRP_local_path)/htcdumlock/Android.mk \
827 $(commands_TWRP_local_path)/gui/Android.mk \
828 $(commands_TWRP_local_path)/mmcutils/Android.mk \
829 $(commands_TWRP_local_path)/bmlutils/Android.mk \
830 $(commands_TWRP_local_path)/prebuilt/Android.mk \
831 $(commands_TWRP_local_path)/mtdutils/Android.mk \
832 $(commands_TWRP_local_path)/flashutils/Android.mk \
833 $(commands_TWRP_local_path)/pigz/Android.mk \
834 $(commands_TWRP_local_path)/libtar/Android.mk \
835 $(commands_TWRP_local_path)/libcrecovery/Android.mk \
836 $(commands_TWRP_local_path)/libblkid/Android.mk \
837 $(commands_TWRP_local_path)/minuitwrp/Android.mk \
838 $(commands_TWRP_local_path)/openaes/Android.mk \
839 $(commands_TWRP_local_path)/toolbox/Android.mk \
840 $(commands_TWRP_local_path)/twrpTarMain/Android.mk \
Ethan Yonker58f21322018-08-24 11:17:36 -0500841 $(commands_TWRP_local_path)/minzip/Android.mk \
842 $(commands_TWRP_local_path)/dosfstools/Android.mk \
843 $(commands_TWRP_local_path)/etc/Android.mk \
844 $(commands_TWRP_local_path)/toybox/Android.mk \
845 $(commands_TWRP_local_path)/simg2img/Android.mk \
846 $(commands_TWRP_local_path)/adbbu/Android.mk \
847 $(commands_TWRP_local_path)/libpixelflinger/Android.mk \
848 $(commands_TWRP_local_path)/twrpDigest/Android.mk \
849 $(commands_TWRP_local_path)/attr/Android.mk
Ethan Yonkerbcc502c2014-11-10 11:22:10 -0600850
Ethan Yonker534d4e02016-08-26 10:05:03 -0500851ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 24; echo $$?),0)
Ethan Yonker58f21322018-08-24 11:17:36 -0500852 include $(commands_TWRP_local_path)/libmincrypt/Android.mk
Ethan Yonkerf1179622016-08-25 15:32:21 -0500853endif
854
Ethan Yonker253368a2014-11-25 15:00:52 -0600855ifeq ($(TW_INCLUDE_CRYPTO), true)
Ethan Yonker98661c12018-10-17 08:39:28 -0500856 include $(commands_TWRP_local_path)/crypto/fde/Android.mk
Ethan Yonker58f21322018-08-24 11:17:36 -0500857 include $(commands_TWRP_local_path)/crypto/scrypt/Android.mk
Ethan Yonkerbd7492d2016-12-07 13:55:01 -0600858 ifeq ($(TW_INCLUDE_CRYPTO_FBE), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500859 include $(commands_TWRP_local_path)/crypto/ext4crypt/Android.mk
Ethan Yonkerbd7492d2016-12-07 13:55:01 -0600860 endif
nkk7171c6c502017-01-05 23:55:05 +0200861 ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),)
862 ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),false)
Ethan Yonker58f21322018-08-24 11:17:36 -0500863 include $(commands_TWRP_local_path)/crypto/vold_decrypt/Android.mk
nkk7171c6c502017-01-05 23:55:05 +0200864 endif
865 endif
Ethan Yonker58f21322018-08-24 11:17:36 -0500866 include $(commands_TWRP_local_path)/gpt/Android.mk
Ethan Yonker4eca40d2014-11-11 14:52:28 -0600867endif
Vojtech Bocek7cc278b2013-02-24 01:40:19 +0100868ifeq ($(BUILD_ID), GINGERBREAD)
869 TW_NO_EXFAT := true
870endif
Dees_Troyb05ddee2013-01-28 20:24:50 +0000871ifneq ($(TW_NO_EXFAT), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500872 include $(commands_TWRP_local_path)/exfat/mkfs/Android.mk \
873 $(commands_TWRP_local_path)/exfat/fsck/Android.mk \
874 $(commands_TWRP_local_path)/fuse/Android.mk \
875 $(commands_TWRP_local_path)/exfat/libexfat/Android.mk
Ethan Yonker34741d92016-02-06 13:22:45 -0600876 ifneq ($(TW_NO_EXFAT_FUSE), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500877 include $(commands_TWRP_local_path)/exfat/fuse/Android.mk
Ethan Yonker34741d92016-02-06 13:22:45 -0600878 endif
Captain Throwback6a1acf22014-09-18 12:46:35 -0400879endif
Ethan Yonker03a42f62014-08-08 11:03:51 -0500880ifneq ($(TW_OEM_BUILD),true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500881 include $(commands_TWRP_local_path)/orscmd/Android.mk
Ethan Yonker03a42f62014-08-08 11:03:51 -0500882endif
bigbiff bigbiff9c754052013-01-09 09:09:08 -0500883
Talustus3019a912013-04-06 11:50:07 +0200884# FB2PNG
885ifeq ($(TW_INCLUDE_FB2PNG), true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500886 include $(commands_TWRP_local_path)/fb2png/Android.mk
Talustus3019a912013-04-06 11:50:07 +0200887endif
Matt Mower55c75ca2014-08-31 11:30:15 -0500888
Matt Mower55c75ca2014-08-31 11:30:15 -0500889endif
Ethan Yonker58f21322018-08-24 11:17:36 -0500890
891commands_TWRP_local_path :=