image.mk: add LegacyDevice wrapper to allow legacy image building code to be used for device profiles

Signed-off-by: Felix Fietkau <nbd@nbd.name>
master
Felix Fietkau 9 years ago
parent ec86d2a605
commit 26c771452c
  1. 63
      include/image.mk

@ -294,12 +294,15 @@ define BuildImage/mkfs
endef endef
define Device/Init define Device/InitProfile
PROFILES := $(PROFILE) PROFILES := $(PROFILE)
DEVICE_NAME := $(1)
DEVICE_TITLE := DEVICE_TITLE :=
DEVICE_PACKAGES := DEVICE_PACKAGES :=
DEVICE_DESCRIPTION = Build firmware images for $$(DEVICE_TITLE) DEVICE_DESCRIPTION = Build firmware images for $$(DEVICE_TITLE)
endef
define Device/Init
DEVICE_NAME := $(1)
KERNEL:= KERNEL:=
KERNEL_INITRAMFS = $$(KERNEL) KERNEL_INITRAMFS = $$(KERNEL)
KERNEL_SIZE:= KERNEL_SIZE:=
@ -339,7 +342,7 @@ endif
define Device/Check define Device/Check
_PROFILE_SET = $$(strip $$(foreach profile,$$(PROFILES) DEVICE_$(1),$$(call DEVICE_CHECK_PROFILE,$$(profile)))) _PROFILE_SET = $$(strip $$(foreach profile,$$(PROFILES) DEVICE_$(1),$$(call DEVICE_CHECK_PROFILE,$$(profile))))
_TARGET := $$(if $$(_PROFILE_SET),install,install-disabled) _TARGET := $$(if $$(_PROFILE_SET),install-images,install-disabled)
ifndef IB ifndef IB
_COMPILE_TARGET := $$(if $(CONFIG_IB)$$(_PROFILE_SET),compile,compile-disabled) _COMPILE_TARGET := $$(if $(CONFIG_IB)$$(_PROFILE_SET),compile,compile-disabled)
endif endif
@ -432,8 +435,10 @@ endef
define Device/Dump define Device/Dump
$$(eval $$(if $$(DEVICE_TITLE),$$(info $$(call Device/DumpInfo,$(1))))) $$(eval $$(if $$(DEVICE_TITLE),$$(info $$(call Device/DumpInfo,$(1)))))
endef endef
LegacyDevice/Dump = $(Device/Dump)
define Device define Device
$(call Device/InitProfile,$(1))
$(call Device/Init,$(1)) $(call Device/Init,$(1))
$(call Device/Default,$(1)) $(call Device/Default,$(1))
$(call Device/$(1),$(1)) $(call Device/$(1),$(1))
@ -442,6 +447,42 @@ define Device
endef endef
define LegacyDevice/Check
_PROFILE_SET = $$(strip $$(foreach profile,$$(PROFILES) DEVICE_$(1),$$(call DEVICE_CHECK_PROFILE,$$(profile))))
_TARGET_PREPARE := $$(if $$(_PROFILE_SET),legacy-images-prepare,prepare-disabled)
_TARGET := $$(if $$(_PROFILE_SET),legacy-images,install-disabled)
$$(if $$(_PROFILE_SET),install: legacy-images-make)
ifndef IB
$$(if $$(_PROFILE_SET),compile: legacy-images-prepare-make)
endif
endef
define LegacyDevice/Build
$$(_TARGET): legacy-image-$(1)
$$(_TARGET_PREPARE): legacy-image-prepare-$(1)
.PHONY: legacy-image-prepare-$(1) legacy-image-$(1)
legacy-image-prepare-$(1):
$(foreach fs,$(TARGET_FILESYSTEMS),
$$(call Image/Prepare/Profile,$(1),$(fs))
)
legacy-image-$(1):
$(foreach fs,$(TARGET_FILESYSTEMS),
$$(call Image/Build/Profile,$(1),$(fs))
)
endef
define LegacyDevice
$(call Device/InitProfile,$(1))
$(call Device/Default,$(1))
$(call LegacyDevice/Default,$(1))
$(call LegacyDevice/$(1),$(1))
$(call LegacyDevice/Check,$(1))
$(call LegacyDevice/$(if $(DUMP),Dump,Build),$(1))
endef
define BuildImage define BuildImage
ifneq ($(DUMP),) ifneq ($(DUMP),)
@ -454,10 +495,12 @@ define BuildImage
prepare: prepare:
compile: compile:
clean: clean:
legacy-images-prepare:
legacy-images:
image_prepare: image_prepare:
ifeq ($(IB),) ifeq ($(IB),)
.PHONY: download prepare compile clean image_prepare mkfs_prepare kernel_prepare install .PHONY: download prepare compile clean image_prepare mkfs_prepare kernel_prepare install install-images
compile: compile:
$(call Build/Compile) $(call Build/Compile)
@ -467,6 +510,10 @@ define BuildImage
image_prepare: compile image_prepare: compile
mkdir -p $(BIN_DIR) $(KDIR)/tmp mkdir -p $(BIN_DIR) $(KDIR)/tmp
$(call Image/Prepare) $(call Image/Prepare)
legacy-images-prepare-make: image_prepare
$(MAKE) legacy-images-prepare
else else
image_prepare: image_prepare:
mkdir -p $(BIN_DIR) $(KDIR)/tmp mkdir -p $(BIN_DIR) $(KDIR)/tmp
@ -481,13 +528,19 @@ define BuildImage
$(call Image/InstallKernel) $(call Image/InstallKernel)
$(foreach device,$(TARGET_DEVICES),$(call Device,$(device))) $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))
$(foreach device,$(LEGACY_DEVICES),$(call LegacyDevice,$(device)))
$(foreach fs,$(TARGET_FILESYSTEMS) $(fs-subtypes-y),$(call BuildImage/mkfs,$(fs))) $(foreach fs,$(TARGET_FILESYSTEMS) $(fs-subtypes-y),$(call BuildImage/mkfs,$(fs)))
install: kernel_prepare install-images: kernel_prepare
$(foreach fs,$(TARGET_FILESYSTEMS), $(foreach fs,$(TARGET_FILESYSTEMS),
$(call Image/Build,$(fs)) $(call Image/Build,$(fs))
) )
$(call Image/mkfs/ubifs) $(call Image/mkfs/ubifs)
legacy-images-make: install-images
$(MAKE) legacy-images
install: install-images
$(call Image/Checksum,md5sum --binary,md5sums) $(call Image/Checksum,md5sum --binary,md5sums)
$(call Image/Checksum,openssl dgst -sha256,sha256sums) $(call Image/Checksum,openssl dgst -sha256,sha256sums)

Loading…
Cancel
Save