+ifdef CONFIG_TARGET_IMAGES_GZIP
+ define Image/Gzip
+ rm -f $(1).gz
+ gzip -9n $(1)
+ endef
+endif
+
+
+# Disable noisy checks by default as in upstream
+ifeq ($(strip $(call kernel_patchver_ge,4.7.0)),1)
+ DTC_FLAGS += -Wno-unit_address_vs_reg
+endif
+ifeq ($(strip $(call kernel_patchver_ge,4.12.0)),1)
+ DTC_FLAGS += \
+ -Wno-unit_address_vs_reg \
+ -Wno-simple_bus_reg \
+ -Wno-unit_address_format \
+ -Wno-pci_bridge \
+ -Wno-pci_device_bus_num \
+ -Wno-pci_device_reg
+endif
+ifeq ($(strip $(call kernel_patchver_ge,4.17.0)),1)
+ DTC_FLAGS += \
+ -Wno-avoid_unnecessary_addr_size \
+ -Wno-alias_paths
+endif
+ifeq ($(strip $(call kernel_patchver_ge,4.18.0)),1)
+ DTC_FLAGS += \
+ -Wno-graph_child_address \
+ -Wno-graph_port \
+ -Wno-unique_unit_address
+endif
+
+define Image/pad-to
+ dd if=$(1) of=$(1).new bs=$(2) conv=sync
+ mv $(1).new $(1)
+endef
+
+ROOTFS_PARTSIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_PARTSIZE)*1024*1024)))
+
+define Image/pad-root-squashfs
+ $(call Image/pad-to,$(KDIR)/root.squashfs,$(if $(1),$(1),$(ROOTFS_PARTSIZE)))
+endef
+