blob: 0f849466b7da86e6218cfb1f218371abd9cde4ee [file] [log] [blame]
Michael Bestas3952f6c2016-08-26 01:12:08 +03001#----------------------------------------------------------------------
2# Generate device tree image (dt.img)
3#----------------------------------------------------------------------
4ifeq ($(strip $(BOARD_CUSTOM_BOOTIMG_MK)),)
5ifeq ($(strip $(BOARD_KERNEL_SEPARATED_DT)),true)
6ifneq ($(strip $(BOARD_KERNEL_PREBUILT_DT)),true)
7ifeq ($(strip $(BUILD_TINY_ANDROID)),true)
8include device/qcom/common/dtbtool/Android.mk
9endif
10
11ifeq ($(strip $(TARGET_CUSTOM_DTBTOOL)),)
12DTBTOOL_NAME := dtbToolCM
13else
14DTBTOOL_NAME := $(TARGET_CUSTOM_DTBTOOL)
15endif
16
17DTBTOOL := $(HOST_OUT_EXECUTABLES)/$(DTBTOOL_NAME)$(HOST_EXECUTABLE_SUFFIX)
18
19INSTALLED_DTIMAGE_TARGET := $(PRODUCT_OUT)/dt.img
20
21ifeq ($(strip $(TARGET_CUSTOM_DTBTOOL)),)
22# dtbToolCM will search subdirectories
23possible_dtb_dirs = $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/
24else
25# Most specific paths must come first in possible_dtb_dirs
26possible_dtb_dirs = $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/dts/ $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/
27endif
28
29define build-dtimage-target
30 $(call pretty,"Target dt image: $@")
31 $(hide) for dir in $(possible_dtb_dirs); do \
32 if [ -d "$$dir" ]; then \
33 dtb_dir="$$dir"; \
34 break; \
35 fi; \
36 done; \
37 $(DTBTOOL) $(BOARD_DTBTOOL_ARGS) -o $@ -s $(BOARD_KERNEL_PAGESIZE) -p $(KERNEL_OUT)/scripts/dtc/ "$$dtb_dir";
38 $(hide) chmod a+r $@
39endef
40
41$(INSTALLED_DTIMAGE_TARGET): $(DTBTOOL) $(INSTALLED_KERNEL_TARGET)
42 $(build-dtimage-target)
43 @echo "Made DT image: $@"
44
45ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DTIMAGE_TARGET)
46ALL_MODULES.$(LOCAL_MODULE).INSTALLED += $(INSTALLED_DTIMAGE_TARGET)
47
48.PHONY: dtimage
49dtimage: $(INSTALLED_DTIMAGE_TARGET)
50
51endif
52endif
53endif