Jesse Chan | 67a7444 | 2017-02-02 00:22:09 +0800 | [diff] [blame] | 1 | # Copyright (C) 2017 The LineageOS 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. |
| 14 | |
| 15 | LOCAL_PATH := $(call my-dir) |
| 16 | |
| 17 | ifeq ($(strip $(BOARD_KERNEL_SEPARATED_DT)),true) |
| 18 | ifneq ($(strip $(BOARD_KERNEL_PREBUILT_DT)),true) |
| 19 | ifeq ($(strip $(BUILD_TINY_ANDROID)),true) |
Michael Bestas | d5b988f | 2018-03-25 20:33:08 +0300 | [diff] [blame] | 20 | include system/tools/dtbtool/Android.mk |
Jesse Chan | 67a7444 | 2017-02-02 00:22:09 +0800 | [diff] [blame] | 21 | endif |
| 22 | |
| 23 | ifeq ($(strip $(TARGET_CUSTOM_DTBTOOL)),) |
LuK1337 | 977aee5 | 2017-08-28 22:24:35 +0200 | [diff] [blame] | 24 | DTBTOOL_NAME := dtbToolLineage |
Jesse Chan | 67a7444 | 2017-02-02 00:22:09 +0800 | [diff] [blame] | 25 | else |
| 26 | DTBTOOL_NAME := $(TARGET_CUSTOM_DTBTOOL) |
| 27 | endif |
| 28 | |
| 29 | DTBTOOL := $(HOST_OUT_EXECUTABLES)/$(DTBTOOL_NAME)$(HOST_EXECUTABLE_SUFFIX) |
| 30 | |
| 31 | INSTALLED_DTIMAGE_TARGET := $(PRODUCT_OUT)/dt.img |
| 32 | |
| 33 | ifeq ($(strip $(TARGET_CUSTOM_DTBTOOL)),) |
| 34 | # dtbToolCM will search subdirectories |
| 35 | possible_dtb_dirs = $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/ |
| 36 | else |
| 37 | # Most specific paths must come first in possible_dtb_dirs |
Jesse Chan | 9432ff3 | 2017-04-25 17:38:42 +0800 | [diff] [blame] | 38 | possible_dtb_dirs = $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/dts/exynos/ $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/dts/ $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/ |
Jesse Chan | 67a7444 | 2017-02-02 00:22:09 +0800 | [diff] [blame] | 39 | endif |
| 40 | |
| 41 | define build-dtimage-target |
| 42 | $(call pretty,"Target dt image: $@") |
| 43 | $(hide) for dir in $(possible_dtb_dirs); do \ |
| 44 | if [ -d "$$dir" ]; then \ |
| 45 | dtb_dir="$$dir"; \ |
| 46 | break; \ |
| 47 | fi; \ |
| 48 | done; \ |
| 49 | $(DTBTOOL) $(BOARD_DTBTOOL_ARGS) -o $@ -s $(BOARD_KERNEL_PAGESIZE) -p $(KERNEL_OUT)/scripts/dtc/ "$$dtb_dir"; |
| 50 | $(hide) chmod a+r $@ |
| 51 | endef |
| 52 | |
| 53 | $(INSTALLED_DTIMAGE_TARGET): $(DTBTOOL) $(INSTALLED_KERNEL_TARGET) |
| 54 | $(build-dtimage-target) |
| 55 | @echo "Made DT image: $@" |
| 56 | |
| 57 | .PHONY: dtimage |
| 58 | dtimage: $(INSTALLED_DTIMAGE_TARGET) |
| 59 | |
| 60 | endif |
| 61 | endif |
| 62 | |
Nolen Johnson | c03534e | 2019-08-11 20:46:48 +0000 | [diff] [blame] | 63 | ifeq ($(strip $(TARGET_NEEDS_LOKI)),true) |
Nolen Johnson | 802fd00 | 2019-08-07 23:56:48 -0400 | [diff] [blame] | 64 | LOKI_TOOL := loki_tool |
| 65 | else |
| 66 | LOKI_TOOL := echo |
| 67 | TARGET_LOKI_ABOOT_IMAGE := |
| 68 | endif |
| 69 | |
Jesse Chan | 67a7444 | 2017-02-02 00:22:09 +0800 | [diff] [blame] | 70 | $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOTIMAGE_EXTRA_DEPS) |
| 71 | $(call pretty,"Target boot image: $@") |
| 72 | $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@ |
| 73 | $(hide) echo -n "SEANDROIDENFORCE" >> $@ |
Nolen Johnson | 802fd00 | 2019-08-07 23:56:48 -0400 | [diff] [blame] | 74 | $(hide) $(LOKI_TOOL) patch boot $(TARGET_LOKI_ABOOT_IMAGE) $@ $@.lok |
| 75 | $(hide) cp $@.lok $@ || true |
Jesse Chan | 67a7444 | 2017-02-02 00:22:09 +0800 | [diff] [blame] | 76 | $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw) |
| 77 | @echo "Made boot image: $@" |
| 78 | |
| 79 | $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel) $(RECOVERYIMAGE_EXTRA_DEPS) |
| 80 | @echo "----- Making recovery image ------" |
| 81 | $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@ --id > $(RECOVERYIMAGE_ID_FILE) |
| 82 | $(hide) echo -n "SEANDROIDENFORCE" >> $@ |
Nolen Johnson | 802fd00 | 2019-08-07 23:56:48 -0400 | [diff] [blame] | 83 | $(hide) $(LOKI_TOOL) patch recovery $(TARGET_LOKI_ABOOT_IMAGE) $@ $@.lok |
| 84 | $(hide) cp $@.lok $@ || true |
Jesse Chan | 67a7444 | 2017-02-02 00:22:09 +0800 | [diff] [blame] | 85 | $(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE),raw) |
| 86 | @echo "Made recovery image: $@" |