build: minor cleanup of redundant code
[openwrt/openwrt.git] / include / image-legacy.mk
index 3acf2b9760fff70108e8f7a245e11d0402822f7c..9ace98fbe57e7047a0b231251c3d7be2cc66442c 100644 (file)
@@ -1,7 +1,42 @@
+ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),)
+    define Image/mkfs/ubifs/generate
+       $(CP) ./ubinize$(1).cfg $(KDIR)
+       ( cd $(KDIR); \
+               $(STAGING_DIR_HOST)/bin/ubinize \
+               $(if $($(PROFILE)_UBI_OPTS),$($(PROFILE)_UBI_OPTS),$(shell echo $(UBI_OPTS))) \
+               -o $(KDIR)/root$(1).ubi \
+               ubinize$(1).cfg \
+       )
+    endef
+
+    define Image/mkfs/ubifs/legacy
+
+        $(if $($(PROFILE)_UBIFS_OPTS)$(UBIFS_OPTS),
+               $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
+                       $(if $($(PROFILE)_UBIFS_OPTS),$($(PROFILE)_UBIFS_OPTS),$(UBIFS_OPTS)) \
+                       $(if $(CONFIG_TARGET_UBIFS_FREE_SPACE_FIXUP),--space-fixup) \
+                       $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_NONE),--force-compr=none) \
+                       $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_LZO),--force-compr=lzo) \
+                       $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB),--force-compr=zlib) \
+                       $(if $(shell echo $(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)),--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)) \
+                       --squash-uids \
+                       -o $(KDIR)/root.ubifs \
+                       -d $(TARGET_DIR)
+       )
+       $(call Image/Build,ubifs)
+
+        $(if $($(PROFILE)_UBI_OPTS)$(UBI_OPTS),
+               $(if $(wildcard ./ubinize.cfg),$(call Image/mkfs/ubifs/generate,))
+               $(if $(wildcard ./ubinize-overlay.cfg),$(call Image/mkfs/ubifs/generate,-overlay))
+       )
+       $(if $(wildcard ./ubinize.cfg),$(call Image/Build,ubi))
+    endef
+endif
+
 LegacyDevice/Dump = $(Device/Dump)
 
 define LegacyDevice/Check
-  _PROFILE_SET = $$(strip $$(foreach profile,$$(PROFILES) DEVICE_$(1),$$(call DEVICE_CHECK_PROFILE,$$(profile))))
+  $(Device/Check/Common)
   _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)