forked from mer-hybris/hybris-boot
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Android.mk
358 lines (288 loc) · 14.3 KB
/
Android.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#
# Copyright (C) 2014 Jolla Oy
# Contact: <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
LOCAL_PATH:= $(call my-dir)
HYBRIS_PATH:=$(LOCAL_PATH)
# We use the commandline and kernel configuration varables from
# build/core/Makefile to be consistent. Support for boot/recovery
# image specific kernel COMMANDLINE vars is provided but whether it
# works or not is down to your bootloader.
HYBRIS_BOOTIMG_COMMANDLINE :=
HYBRIS_RECOVERYIMG_COMMANDLINE := bootmode=debug
HYBRIS_BOOTLOGO :=
# BOOT
HYBRIS_B_DEFAULT_OS := sailfishos
HYBRIS_B_ALWAYSDEBUG :=
# RECOVERY
HYBRIS_R_DEFAULT_OS := sailfishos
HYBRIS_R_ALWAYSDEBUG := 1
## All manual "config" should be done above this line
# Force deferred assignment
HYBRIS_FIXUP_MOUNTS := $(shell ls -1 $(LOCAL_PATH)/../fixup-mountpoints $(LOCAL_PATH)/fixup-mountpoints 2> /dev/null | head -n1)
# Find any fstab files for required partition information.
# in AOSP we could use TARGET_VENDOR
# TARGET_VENDOR := $(shell echo $(PRODUCT_MANUFACTURER) | tr '[:upper:]' '[:lower:]')
# but Cyanogenmod seems to use device/*/$(TARGET_DEVICE) in config.mk so we will too.
HYBRIS_FSTABS := $(shell find device/*/$(TARGET_DEVICE) -name *fstab* | grep -v goldfish)
# If fstab files were not found from primary device repo then they might be in
# some other device repo so try to search for them first in device/PRODUCT_MANUFACTURER.
# In many cases PRODUCT_MANUFACTURER is the short vendor name used in folder names.
ifeq "$(HYBRIS_FSTABS)" ""
TARGET_VENDOR := "$(shell echo $(PRODUCT_MANUFACTURER) | tr '[:upper:]' '[:lower:]')"
HYBRIS_FSTABS := $(shell find device/$(TARGET_VENDOR) -name *fstab* | grep -v goldfish)
endif
# Some devices devices have the short vendor name in PRODUCT_BRAND so try to
# search from device/PRODUCT_BRAND if fstab files are still not found.
ifeq "$(HYBRIS_FSTABS)" ""
TARGET_VENDOR := "$(shell echo $(PRODUCT_BRAND) | tr '[:upper:]' '[:lower:]')"
HYBRIS_FSTABS := $(shell find device/$(TARGET_VENDOR) -name *fstab* | grep -v goldfish)
endif
# Some devices are inside subfolders
ifeq "$(HYBRIS_FSTABS)" ""
HYBRIS_FSTABS := $(shell find device/*/*/$(TARGET_DEVICE) -name *fstab* | grep -v goldfish)
endif
# Get the unique /dev field(s) from the line(s) containing the fs mount point
# Note the perl one-liner uses double-$ as per Makefile syntax
HYBRIS_BOOT_PART := $(shell /usr/bin/perl -w -e '$$fs=shift; if ($$ARGV[0]) { while (<>) { next unless /^$$fs\s|\s$$fs\s/;for (split) {next unless m(^/dev); print "$$_\n"; }}} else { print "ERROR: *fstab* not found\n";}' /boot $(HYBRIS_FSTABS) | sort -u)
HYBRIS_DATA_PART := $(shell /usr/bin/perl -w -e '$$fs=shift; if ($$ARGV[0]) { while (<>) { next unless /^$$fs\s|\s$$fs\s/;for (split) {next unless m(^/dev); print "$$_\n"; }}} else { print "ERROR: *fstab* not found\n";}' /data $(HYBRIS_FSTABS) | sort -u)
$(warning ********************* /boot appears to live on $(HYBRIS_BOOT_PART))
$(warning ********************* /data appears to live on $(HYBRIS_DATA_PART))
ifneq ($(words $(HYBRIS_DATA_PART)),1)
$(error There should be a one and only one device entry for HYBRIS_DATA_PART)
endif
BB_STATIC := $(PRODUCT_OUT)/utilities/busybox
ifneq ($(strip $(TARGET_NO_KERNEL)),true)
INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
else
INSTALLED_KERNEL_TARGET :=
endif
HYBRIS_BOOTIMAGE_ARGS := \
$(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
--kernel $(INSTALLED_KERNEL_TARGET)
BOOTIMAGE_EXTRA_DEPS :=
ifeq ($(BOARD_KERNEL_SEPARATED_DT),true)
INSTALLED_DTIMAGE_TARGET := $(PRODUCT_OUT)/dt.img
HYBRIS_BOOTIMAGE_ARGS += --dt $(INSTALLED_DTIMAGE_TARGET)
BOOTIMAGE_EXTRA_DEPS += $(INSTALLED_DTIMAGE_TARGET)
endif
ifeq ($(BOARD_KERNEL_SEPARATED_DTBO),true)
INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
BOOTIMAGE_EXTRA_DEPS += $(INSTALLED_DTBIMAGE_TARGET)
endif
ifeq ($(BOARD_INCLUDE_DTB_IN_BOOTIMG),true)
INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
HYBRIS_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
BOOTIMAGE_EXTRA_DEPS += $(INSTALLED_DTBIMAGE_TARGET)
endif
ifdef BOARD_KERNEL_BASE
HYBRIS_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
endif
ifdef BOARD_KERNEL_PAGESIZE
HYBRIS_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
endif
# Specify the BOOT/RECOVERY vars here as they're not impacted by
# CLEAR_VARS and it makes it easier to keep them consistent.
HYBRIS_RECOVERYIMAGE_ARGS := $(HYBRIS_BOOTIMAGE_ARGS)
# Strip lead/trail " from broken BOARD_KERNEL_CMDLINEs :(
HYBRIS_BOARD_KERNEL_CMDLINE := $(shell echo '$(BOARD_KERNEL_CMDLINE)' | sed -e 's/^"//' -e 's/"$$//')
ifneq "" "$(strip $(HYBRIS_BOARD_KERNEL_CMDLINE) $(HYBRIS_BOOTIMG_COMMANDLINE))"
HYBRIS_BOOTIMAGE_ARGS += --cmdline "$(strip $(HYBRIS_BOARD_KERNEL_CMDLINE) $(HYBRIS_BOOTIMG_COMMANDLINE))"
endif
ifneq "" "$(strip $(HYBRIS_BOARD_KERNEL_CMDLINE) $(HYBRIS_RECOVERYIMG_COMMANDLINE))"
HYBRIS_RECOVERYIMAGE_ARGS += --cmdline "$(strip $(HYBRIS_BOARD_KERNEL_CMDLINE) $(HYBRIS_RECOVERYIMG_COMMANDLINE))"
endif
include $(CLEAR_VARS)
LOCAL_MODULE:= hybris-boot
# Here we'd normally include $(BUILD_SHARED_LIBRARY) or something
# but nothing seems suitable for making an img like this
LOCAL_MODULE_CLASS := ROOT
LOCAL_MODULE_SUFFIX := .img
LOCAL_MODULE_PATH := $(PRODUCT_OUT)
include $(BUILD_SYSTEM)/base_rules.mk
BOOT_INTERMEDIATE := $(call intermediates-dir-for,ROOT,$(LOCAL_MODULE),)
BOOT_RAMDISK := $(BOOT_INTERMEDIATE)/boot-initramfs.gz
BOOT_RAMDISK_SRC := $(LOCAL_PATH)/initramfs
BOOT_RAMDISK_INIT_SRC := $(LOCAL_PATH)/init-script
BOOT_RAMDISK_INIT := $(BOOT_INTERMEDIATE)/init
BOOT_RAMDISK_FILES := $(shell find $(BOOT_RAMDISK_SRC) -type f) $(BOOT_RAMDISK_INIT)
$(LOCAL_BUILT_MODULE): $(INSTALLED_KERNEL_TARGET) $(BOOT_RAMDISK) $(MKBOOTIMG) $(BOOTIMAGE_EXTRA_DEPS)
@echo "Making hybris-boot.img in $(dir $@) using $(INSTALLED_KERNEL_TARGET) $(BOOT_RAMDISK)"
@mkdir -p $(dir $@)
@rm -rf $@
$(hide)$(MKBOOTIMG) --ramdisk $(BOOT_RAMDISK) $(HYBRIS_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
$(BOOT_RAMDISK): $(BOOT_RAMDISK_FILES) $(BB_STATIC)
@echo "Making initramfs : $@"
@rm -rf $(BOOT_INTERMEDIATE)/initramfs
@mkdir -p $(BOOT_INTERMEDIATE)/initramfs
@cp -a $(BOOT_RAMDISK_SRC)/* $(BOOT_INTERMEDIATE)/initramfs
# Deliberately do an mv to force rebuild of init every time since it's
# really hard to depend on things which may affect init.
@mv $(BOOT_RAMDISK_INIT) $(BOOT_INTERMEDIATE)/initramfs/init
@cp $(BB_STATIC) $(BOOT_INTERMEDIATE)/initramfs/bin/
@(cd $(BOOT_INTERMEDIATE)/initramfs && find . | cpio -H newc -o ) | gzip -9 > $@
$(BOOT_RAMDISK_INIT): $(BOOT_RAMDISK_INIT_SRC) $(ALL_PREBUILT)
@mkdir -p $(dir $@)
@sed -e 's %DATA_PART% $(HYBRIS_DATA_PART) g' \
-e 's %BOOTLOGO% $(HYBRIS_BOOTLOGO) g' \
-e 's %DEFAULT_OS% $(HYBRIS_B_DEFAULT_OS) g' \
-e 's %ALWAYSDEBUG% $(HYBRIS_B_ALWAYSDEBUG) g' $(BOOT_RAMDISK_INIT_SRC) > $@
$(HYBRIS_FIXUP_MOUNTS) "$(TARGET_DEVICE)" "$@"
@chmod +x $@
################################################################
include $(CLEAR_VARS)
LOCAL_MODULE:= hybris-recovery
LOCAL_MODULE_CLASS := ROOT
LOCAL_MODULE_SUFFIX := .img
LOCAL_MODULE_PATH := $(PRODUCT_OUT)
include $(BUILD_SYSTEM)/base_rules.mk
RECOVERY_INTERMEDIATE := $(call intermediates-dir-for,ROOT,$(LOCAL_MODULE),)
RECOVERY_RAMDISK := $(RECOVERY_INTERMEDIATE)/recovery-initramfs.gz
RECOVERY_RAMDISK_SRC := $(LOCAL_PATH)/initramfs
RECOVERY_RAMDISK_INIT_SRC := $(LOCAL_PATH)/init-script
RECOVERY_RAMDISK_INIT := $(RECOVERY_INTERMEDIATE)/init
RECOVERY_RAMDISK_FILES := $(shell find $(RECOVERY_RAMDISK_SRC) -type f) $(RECOVERY_RAMDISK_INIT)
$(LOCAL_BUILT_MODULE): $(INSTALLED_KERNEL_TARGET) $(RECOVERY_RAMDISK) $(MKBOOTIMG) $(BOOTIMAGE_EXTRA_DEPS)
@echo "Making hybris-recovery.img in $(dir $@) using $(INSTALLED_KERNEL_TARGET) $(RECOVERY_RAMDISK)"
@mkdir -p $(dir $@)
@rm -rf $@
$(hide)$(MKBOOTIMG) --ramdisk $(RECOVERY_RAMDISK) $(HYBRIS_RECOVERYIMAGE_ARGS) $(BOARD_MKRECOVERYIMG_ARGS) --output $@
$(RECOVERY_RAMDISK): $(RECOVERY_RAMDISK_FILES) $(BB_STATIC)
@echo "Making initramfs : $@"
@rm -rf $(RECOVERY_INTERMEDIATE)/initramfs
@mkdir -p $(RECOVERY_INTERMEDIATE)/initramfs
@cp -a $(RECOVERY_RAMDISK_SRC)/* $(RECOVERY_INTERMEDIATE)/initramfs
@mv $(RECOVERY_RAMDISK_INIT) $(RECOVERY_INTERMEDIATE)/initramfs/init
@cp $(BB_STATIC) $(RECOVERY_INTERMEDIATE)/initramfs/bin/
@(cd $(RECOVERY_INTERMEDIATE)/initramfs && find . | cpio -H newc -o ) | gzip -9 > $@
$(RECOVERY_RAMDISK_INIT): $(RECOVERY_RAMDISK_INIT_SRC) $(ALL_PREBUILT)
@mkdir -p $(dir $@)
@sed -e 's %DATA_PART% $(HYBRIS_DATA_PART) g' \
-e 's %BOOTLOGO% $(HYBRIS_BOOTLOGO) g' \
-e 's %DEFAULT_OS% $(HYBRIS_R_DEFAULT_OS) g' \
-e 's %ALWAYSDEBUG% $(HYBRIS_R_ALWAYSDEBUG) g' $(RECOVERY_RAMDISK_INIT_SRC) > $@
$(HYBRIS_FIXUP_MOUNTS) "$(TARGET_DEVICE)" "$@"
@chmod +x $@
################################################################
include $(CLEAR_VARS)
LOCAL_MODULE := hybris-updater-script
LOCAL_MODULE_CLASS := ROOT
LOCAL_MODULE_PATH := $(PRODUCT_OUT)
include $(BUILD_SYSTEM)/base_rules.mk
UPDATER_INTERMEDIATE := $(call intermediates-dir-for,ROOT,$(LOCAL_MODULE),)
UPDATER_SCRIPT_SRC := $(LOCAL_PATH)/updater-script
ANDROID_VERSION_MAJOR := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
ANDROID_VERSION_MINOR := $(word 2, $(subst ., , $(PLATFORM_VERSION)))
ifeq ($(ANDROID_VERSION_MINOR),)
ANDROID_VERSION_MINOR := 0
endif
ifeq ($(TARGET_OTA_ASSERT_DEVICE),)
ASSERT_DEVICE := assert(getprop("ro.product.device") == "$(TARGET_DEVICE)" \|\| getprop("ro.build.product") == "$(TARGET_DEVICE)" \|\| getprop("ro.cm.device") == "$(TARGET_DEVICE)");
else
ASSERT_DEVICE := $(subst |,\|,$(shell $(LOCAL_PATH)/assert-device $(TARGET_OTA_ASSERT_DEVICE)))
endif
USE_SET_METADATA := $(shell test $(ANDROID_VERSION_MAJOR) -eq 4 -a $(ANDROID_VERSION_MINOR) -ge 4 -o $(ANDROID_VERSION_MAJOR) -ge 5 && echo true)
ifeq ($(USE_SET_METADATA),true)
SET_PERMISSIONS := set_metadata("/tmp/updater-unpack.sh", "uid", 0, "gid", 0, "mode", 0755);
else
SET_PERMISSIONS := set_perm(0, 0, 755, "/tmp/updater-unpack.sh");
endif
$(LOCAL_BUILT_MODULE): $(UPDATER_SCRIPT_SRC)
@echo "Installing updater .zip script resources."
mkdir -p $(dir $@)
rm -rf $@
@sed -e 's %DEVICE% $(TARGET_DEVICE) g' \
-e 's %BOOT_PART% $(HYBRIS_BOOT_PART) g' \
-e 's %DATA_PART% $(HYBRIS_DATA_PART) g' \
-e 's|%ASSERT_DEVICE%|$(ASSERT_DEVICE)|' \
-e 's|%SET_PERMISSIONS%|$(SET_PERMISSIONS)|' \
$(UPDATER_SCRIPT_SRC) > $@
HYBRIS_UPDATER_SCRIPT := $(LOCAL_BUILD_MODULE)
#---------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := hybris-updater-unpack
LOCAL_MODULE_CLASS := ROOT
LOCAL_MODULE_SUFFIX := .sh
LOCAL_MODULE_PATH := $(PRODUCT_OUT)
include $(BUILD_SYSTEM)/base_rules.mk
UPDATER_INTERMEDIATE := $(call intermediates-dir-for,ROOT,$(LOCAL_MODULE),)
UPDATER_UNPACK_SRC := $(LOCAL_PATH)/updater-unpack.sh
$(LOCAL_BUILT_MODULE): $(UPDATER_UNPACK_SRC)
@echo "Installing updater .zip script resources."
mkdir -p $(dir $@)
rm -rf $@
@sed -e 's %DEVICE% $(TARGET_DEVICE) g' \
$(UPDATER_UNPACK_SRC) > $@
HYBRIS_UPDATER_UNPACK := $(LOCAL_BUILD_MODULE)
.PHONY: hybris-hal hybris-common droidmedia audioflingerglue
HYBRIS_INIT_TARGETS := init
ifeq ($(shell test $(ANDROID_VERSION_MAJOR) -ge 10 && echo true),true)
# init is split of into early and second stage init starting with android 10
HYBRIS_INIT_TARGETS := init_second_stage init.rc
ifeq ($(shell test $(ANDROID_VERSION_MAJOR) -eq 10 && echo true),true)
HYBRIS_INIT_TARGETS += com.android.runtime.release
else
HYBRIS_INIT_TARGETS += com.android.runtime
endif
endif
HYBRIS_INIT_TARGETS += $(filter ueventd% fstab.%,$(PRODUCT_PACKAGES))
HYBRIS_COMMON_TARGETS := bootimage hybris-updater-unpack hybris-recovery hybris-boot servicemanager logcat updater adb adbd linker libc libEGL libGLESv1_CM libGLESv2 $(HYBRIS_INIT_TARGETS)
ifneq ($(HYBRIS_BOOT_PART),)
HYBRIS_COMMON_TARGETS += hybris-updater-script
else
$(warning Skipping build of hybris-updater-script since HYBRIS_BOOT_PART is not specified)
endif
HYBRIS_COMMON_ANDROID8_TARGETS := verity_signer boot_signer e2fsdroid vendorimage ramdisk libsurfaceflinger libhwc2_compat_layer bootctl fec
ifeq ($(shell test $(ANDROID_VERSION_MAJOR) -ge 8 && echo true),true)
HYBRIS_COMMON_TARGETS += $(HYBRIS_COMMON_ANDROID8_TARGETS)
ifeq ($(shell test -d */selinux_stubs && echo true),true)
# Device needs selinux_stubs if its hybris adaptation doesn't have SELinux enabled
HYBRIS_COMMON_TARGETS += libselinux_stubs
endif
# for 64 bit Android, also include the 32 bit variants that we need.
HYBRIS_COMMON_64_BIT_EXTRA_TARGETS = linker_32 libc_32 libEGL_32 libGLESv1_CM_32 libGLESv2_32 libhwc2_compat_layer_32
else
# for 64 bit Android, also include the 32 bit variants that we need.
HYBRIS_COMMON_64_BIT_EXTRA_TARGETS = linker_32 libc_32 libEGL_32 libGLESv1_CM_32 libGLESv2_32
endif
hybris-common: $(HYBRIS_COMMON_TARGETS)
ifeq ("$(TARGET_ARCH)", "arm64")
HYBRIS_TARGETS := $(HYBRIS_COMMON_TARGETS) $(HYBRIS_COMMON_64_BIT_EXTRA_TARGETS)
else
HYBRIS_TARGETS := $(HYBRIS_COMMON_TARGETS)
endif
ifeq ($(shell test $(ANDROID_VERSION_MAJOR) -ge 7 && echo true),true)
PROVIDE_POWER_PROFILE := 1
PROFILES=$(shell find $(DEVICE_PACKAGE_OVERLAYS) -name power_profile.xml | wc -l)
ifneq ($(PROFILES),1)
ifeq ($(PROFILES),0)
$(warning Missing power_profile.xml file)
else
$(error Multiple power_profile.xml files)
endif
PROVIDE_POWER_PROFILE := 0
endif
ifeq ($(strip $(PROVIDE_POWER_PROFILE)),1)
POWER_PROFILE := $(foreach d, $(DEVICE_PACKAGE_OVERLAYS), \
$(shell find $(d) -name power_profile.xml) \
)
BATTERY_CAPACITY := $(shell xmllint --xpath 'string(/device[@name="Android"]/item[@name="battery.capacity"])' $(POWER_PROFILE))
$(shell mkdir -p $(PRODUCT_OUT)/system/etc/init)
$(shell echo -e "on boot\n setprop ro.hybris.battery.capacity $(BATTERY_CAPACITY)" > $(PRODUCT_OUT)/system/etc/init/hybris_extras.rc)
endif
endif
hybris-hal: $(HYBRIS_TARGETS)
droidmedia: $(shell external/droidmedia/detect_build_targets.sh $(PORT_ARCH) $(TARGET_ARCH))
audioflingerglue: $(shell external/audioflingerglue/detect_build_targets.sh $(PORT_ARCH) $(TARGET_ARCH))