m5: Add aml_upgrade build target
[GitHub/LineageOS/G12/android_device_bananapi_m5.git] / factory.mk
CommitLineData
53954460
JA
1#
2# Copyright (C) 2021 The LineageOS 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
17FACTORY_PATH := device/bananapi/m5/factory
18
19PRODUCT_UPGRADE_OUT := $(PRODUCT_OUT)/upgrade
20PACKAGE_CONFIG_FILE := $(PRODUCT_UPGRADE_OUT)/image.cfg
21AML_IMAGE_TOOL := $(HOST_OUT_EXECUTABLES)/aml_image_packer$(HOST_EXECUTABLE_SUFFIX)
22
23INSTALLED_AML_UPGRADE_PACKAGE_TARGET := $(PRODUCT_OUT)/aml_upgrade_package.img
24
25define aml-symlink-file
26 $(hide) ln -f $(1) $(PRODUCT_UPGRADE_OUT)/$(strip $(if $(2), $(2), $(notdir $(1))))
27endef
28
29NEEDED_IMAGES := \
30 boot.img \
31 recovery.img \
32 dtbo.img \
33 vbmeta.img \
34 super.img
35
36$(INSTALLED_AML_UPGRADE_PACKAGE_TARGET): $(addprefix $(PRODUCT_OUT)/,$(NEEDED_IMAGES)) $(AML_IMAGE_TOOL)
37 $(hide) mkdir -p $(PRODUCT_UPGRADE_OUT)
38ifeq ("$(wildcard $(FACTORY_PATH)/u-boot.bin)","")
39 $(error "no u-boot.bin found in $(FACTORY_PATH)")
40else
41 $(hide) $(call aml-symlink-file, $(FACTORY_PATH)/u-boot.bin)
42endif
43 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/logo.img)
44 $(hide) $(call aml-symlink-file, $(FACTORY_PATH)/aml_sdc_burn.ini)
45 $(hide) $(call aml-symlink-file, $(FACTORY_PATH)/image.cfg)
46 $(hide) $(call aml-symlink-file, $(FACTORY_PATH)/platform.conf)
47 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/boot.img)
48 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/recovery.img)
49 $(hide) $(call aml-symlink-file, $(INSTALLED_2NDBOOTLOADER_TARGET), dtb.img)
50 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/dtbo.img)
51 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/super.img)
52 $(hide) $(call aml-symlink-file, $(PRODUCT_OUT)/vbmeta.img)
53 $(hide) $(AML_IMAGE_TOOL) -r $(PACKAGE_CONFIG_FILE) $(PRODUCT_UPGRADE_OUT)/ $@
54 $(hide) rm -rf $(PRODUCT_UPGRADE_OUT)
55 $(hide) echo " $@ created"
56
57.PHONY: aml_upgrade
58aml_upgrade: $(INSTALLED_AML_UPGRADE_PACKAGE_TARGET)