ramips/mt76x8: add initramfs support for tplink 841n v13
[openwrt/staging/wigyori.git] / include / image-legacy.mk
index 1b8a911..1ccaec0 100644 (file)
@@ -3,10 +3,7 @@ ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),)
        $(CP) ./ubinize$(1).cfg $(KDIR)
        ( cd $(KDIR); \
                $(STAGING_DIR_HOST)/bin/ubinize \
-               $(if $($(PROFILE)_UBI_OPTS), \
-                       $(shell echo $($(PROFILE)_UBI_OPTS)), \
-                       $(shell echo $(UBI_OPTS)) \
-               ) \
+               $(if $($(PROFILE)_UBI_OPTS),$($(PROFILE)_UBI_OPTS),$(shell echo $(UBI_OPTS))) \
                -o $(KDIR)/root$(1).ubi \
                ubinize$(1).cfg \
        )
@@ -16,14 +13,11 @@ ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),)
 
         $(if $($(PROFILE)_UBIFS_OPTS)$(UBIFS_OPTS),
                $(STAGING_DIR_HOST)/bin/mkfs.ubifs \
-                       $(if $($(PROFILE)_UBIFS_OPTS), \
-                               $(shell echo $($(PROFILE)_UBIFS_OPTS)), \
-                               $(shell echo $(UBIFS_OPTS)) \
-                       ) \
+                       $(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 $(CONFIG_TARGET_UBIFS_COMPRESSION_NONE),--compr=none) \
+                       $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_LZO),--compr=lzo) \
+                       $(if $(CONFIG_TARGET_UBIFS_COMPRESSION_ZLIB),--compr=zlib) \
                        $(if $(shell echo $(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)),--jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE)) \
                        --squash-uids \
                        -o $(KDIR)/root.ubifs \
@@ -42,15 +36,25 @@ 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)
   ifndef IB
-    $$(if $$(_PROFILE_SET),mkfs_prepare: legacy-images-prepare-make)
+    $$(if $$(_PROFILE_SET),kernel_prepare: legacy-images-prepare-make)
   endif
 endef
 
+ifdef TARGET_PER_DEVICE_ROOTFS
+  define Image/Build/Profile/Filesystem
+       cp $(KDIR)/root.$(2)+pkg=$(3) $(KDIR)/root.$(2)
+       $(call Image/Build/$(2),$(2))
+       $(call Image/Build/Profile,$(1),$(2))
+  endef
+else
+  Image/Build/Profile/Filesystem = $(Image/Build/Profile)
+endif
+
 define LegacyDevice/Build
   $$(_TARGET): legacy-image-$(1)
   $$(_TARGET_PREPARE): legacy-image-prepare-$(1)
@@ -59,10 +63,21 @@ define LegacyDevice/Build
   legacy-image-prepare-$(1):
        $$(call Image/Prepare/Profile,$(1))
 
+  ifndef IB
+    ifdef CONFIG_TARGET_PER_DEVICE_ROOTFS
+      ROOTFS/$(1) := $(foreach fs,$(TARGET_FILESYSTEMS), \
+        $(KDIR)/root.$(fs)$$(strip $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),+pkg=$$(ROOTFS_ID/$(1)))) \
+      )
+
+      $$(ROOTFS/$(1)): target-dir-$$(ROOTFS_ID/$(1))
+      legacy-images-make: $$(if $$(_PROFILE_SET),$$(ROOTFS/$(1)))
+    endif
+  endif
+
   legacy-image-$(1):
        $$(call Image/BuildKernel/Profile,$(1))
        $(foreach fs,$(TARGET_FILESYSTEMS),
-               $$(call Image/Build/Profile,$(1),$(fs))
+               $$(call Image/Build/Profile/Filesystem,$(1),$(fs),$$(ROOTFS_ID/$(1)))
        )
 
 endef
@@ -76,5 +91,3 @@ define LegacyDevice
   $(call LegacyDevice/$(if $(DUMP),Dump,Build),$(1))
 
 endef
-
-