build: fix uImage fake header command
[openwrt/openwrt.git] / include / image-legacy.mk
1 ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),)
2 define Image/mkfs/ubifs/generate
3 $(CP) ./ubinize$(1).cfg $(KDIR)
4 ( cd $(KDIR); \
5 $(STAGING_DIR_HOST)/bin/ubinize \
6 $(if $($(PROFILE)_UBI_OPTS),$($(PROFILE)_UBI_OPTS),$(shell echo $(UBI_OPTS))) \
7 -o $(KDIR)/root$(1).ubi \
8 ubinize$(1).cfg \
9 )
10 endef
11
12 define Image/mkfs/ubifs/legacy
13
14 $(if $($(PROFILE)_UBIFS_OPTS)$(UBIFS_OPTS),
15 $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
16 $(if $($(PROFILE)_UBIFS_OPTS),$($(PROFILE)_UBIFS_OPTS),$(UBIFS_OPTS)) \
17 $(if $(CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP),--space-fixup) \
18 $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_NONE),--compr=none) \
19 $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_LZO),--compr=lzo) \
20 $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB),--compr=zlib) \
21 $(if $(shell echo $(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)),--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)) \
22 --squash-uids \
23 -o $(KDIR)/root.ubifs \
24 -d $(TARGET_DIR)
25 )
26 $(call Image/Build,ubifs)
27
28 $(if $($(PROFILE)_UBI_OPTS)$(UBI_OPTS),
29 $(if $(wildcard ./ubinize.cfg),$(call Image/mkfs/ubifs/generate,))
30 $(if $(wildcard ./ubinize-overlay.cfg),$(call Image/mkfs/ubifs/generate,-overlay))
31 )
32 $(if $(wildcard ./ubinize.cfg),$(call Image/Build,ubi))
33 endef
34 endif
35
36 LegacyDevice/Dump = $(Device/Dump)
37
38 define LegacyDevice/Check
39 $(Device/Check/Common)
40 _TARGET_PREPARE := $$(if $$(_PROFILE_SET),legacy-images-prepare,prepare-disabled)
41 _TARGET := $$(if $$(_PROFILE_SET),legacy-images,install-disabled)
42 $$(if $$(_PROFILE_SET),install: legacy-images-make)
43 ifndef IB
44 $$(if $$(_PROFILE_SET),kernel_prepare: legacy-images-prepare-make)
45 endif
46 endef
47
48 ifdef TARGET_PER_DEVICE_ROOTFS
49 define Image/Build/Profile/Filesystem
50 cp $(KDIR)/root.$(2)+pkg=$(3) $(KDIR)/root.$(2)
51 $(call Image/Build/$(2),$(2))
52 $(call Image/Build/Profile,$(1),$(2))
53 endef
54 else
55 Image/Build/Profile/Filesystem = $(Image/Build/Profile)
56 endif
57
58 define LegacyDevice/Build
59 $$(_TARGET): legacy-image-$(1)
60 $$(_TARGET_PREPARE): legacy-image-prepare-$(1)
61 .PHONY: legacy-image-prepare-$(1) legacy-image-$(1)
62
63 legacy-image-prepare-$(1):
64 $$(call Image/Prepare/Profile,$(1))
65
66 ifndef IB
67 ifdef CONFIG_TARGET_PER_DEVICE_ROOTFS
68 ROOTFS/$(1) := $(foreach fs,$(TARGET_FILESYSTEMS), \
69 $(KDIR)/root.$(fs)$$(strip $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),+pkg=$$(ROOTFS_ID/$(1)))) \
70 )
71
72 $$(ROOTFS/$(1)): target-dir-$$(ROOTFS_ID/$(1))
73 legacy-images-make: $$(if $$(_PROFILE_SET),$$(ROOTFS/$(1)))
74 endif
75 endif
76
77 legacy-image-$(1):
78 $$(call Image/BuildKernel/Profile,$(1))
79 $(foreach fs,$(TARGET_FILESYSTEMS),
80 $$(call Image/Build/Profile/Filesystem,$(1),$(fs),$$(ROOTFS_ID/$(1)))
81 )
82
83 endef
84
85 define LegacyDevice
86 $(call Device/InitProfile,$(1))
87 $(call Device/Default,$(1))
88 $(call LegacyDevice/Default,$(1))
89 $(call LegacyDevice/$(1),$(1))
90 $(call LegacyDevice/Check,$(1))
91 $(call LegacyDevice/$(if $(DUMP),Dump,Build),$(1))
92
93 endef