build: move mkits.sh script to more common place
[openwrt.git] / include / image.mk
index e81ce4d..729929f 100644 (file)
@@ -20,9 +20,9 @@ IMG_PREFIX:=openwrt-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
 MKFS_DEVTABLE_OPT := -D $(INCLUDE_DIR)/device_table.txt
 
 ifneq ($(CONFIG_BIG_ENDIAN),)
-  JFFS2OPTS     :=  --pad --big-endian --squash-uids -v
+  JFFS2OPTS     :=  --big-endian --squash-uids -v
 else
-  JFFS2OPTS     :=  --pad --little-endian --squash-uids -v
+  JFFS2OPTS     :=  --little-endian --squash-uids -v
 endif
 
 ifeq ($(CONFIG_JFFS2_RTIME),y)
@@ -35,7 +35,7 @@ ifeq ($(CONFIG_JFFS2_LZMA),y)
   JFFS2OPTS += -X lzma --compression-mode=size
 endif
 ifneq ($(CONFIG_JFFS2_RTIME),y)
-  JFFS2OPTS +=  -x rtime
+  JFFS2OPTS += -x rtime
 endif
 ifneq ($(CONFIG_JFFS2_ZLIB),y)
   JFFS2OPTS += -x zlib
@@ -82,9 +82,22 @@ else
   endef
 endif
 
+define Image/BuildKernel/MkuImageARM
+       mkimage -A arm -O linux -T kernel -a $(1) -C none -e $(1) \
+               -n 'ARM OpenWrt Linux-$(LINUX_VERSION)' -d $(2) $(3)
+endef
+
+define Image/BuildKernel/MkFIT
+       $(TOPDIR)/scripts/mkits.sh \
+               -D $(1) -o $(KDIR)/fit-$(1).its -k $(2) -d $(3) -C $(4) -a $(5) -e $(6) \
+               -A $(ARCH) -v $(LINUX_VERSION)
+       PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(1).its $(KDIR)/fit-$(1)$(7).itb
+endef
+
 define Image/mkfs/jffs2/sub
                # FIXME: removing this line will cause strange behaviour in the foreach loop below
-               $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(3) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(2) -d $(TARGET_DIR) -v 2>&1 1>/dev/null | awk '/^.+$$$$/'
+               $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(3) --pad -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(2) -d $(TARGET_DIR) -v 2>&1 1>/dev/null | awk '/^.+$$$$/'
+               $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(3) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(2)-raw -d $(TARGET_DIR) -v 2>&1 1>/dev/null | awk '/^.+$$$$/'
                $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(2))
                $(call Image/Build,jffs2-$(2))
 endef
@@ -114,12 +127,36 @@ endif
 
 ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),)
     define Image/mkfs/ubifs
+
+        ifneq ($($(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 $(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) \
+                       --jrn-size=$(CONFIG_TARGET_UBIFS_JOURNAL_SIZE) \
+                       -o $(KDIR)/root.ubifs \
+                       -d $(TARGET_DIR)
+        endif
+       $(call Image/Build,ubifs)
+
+        ifneq ($($(PROFILE)_UBI_OPTS)$(UBI_OPTS),)
                $(CP) ./ubinize.cfg $(KDIR)
-               $(STAGING_DIR_HOST)/bin/mkfs.ubifs $(UBIFS_OPTS) $(MKFS_DEVTABLE_OPT) -o $(KDIR)/root.ubifs -d $(TARGET_DIR)
-               $(call Image/Build,ubifs)
-               (cd $(KDIR); \
-               $(STAGING_DIR_HOST)/bin/ubinize $(UBINIZE_OPTS) -o $(KDIR)/root.ubi ubinize.cfg)
-               $(call Image/Build,ubi)
+               ( cd $(KDIR); \
+               $(STAGING_DIR_HOST)/bin/ubinize \
+                       $(if $($(PROFILE)_UBI_OPTS), \
+                               $(shell echo $($(PROFILE)_UBI_OPTS)), \
+                               $(shell echo $(UBI_OPTS)) \
+                       ) \
+                       -o $(KDIR)/root.ubi \
+                       ubinize.cfg \
+               )
+        endif
+       $(call Image/Build,ubi)
     endef
 endif
 
@@ -132,7 +169,7 @@ endif
 ifneq ($(CONFIG_TARGET_ROOTFS_TARGZ),)
   define Image/mkfs/targz
                # Preserve permissions (-p) when building as non-root user
-               $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
+               $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE),-$(PROFILE))-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
   endef
 endif
 
@@ -197,6 +234,7 @@ define BuildImage
                $(call Image/mkfs/prepare)
                $(call Image/BuildKernel)
                $(call Image/BuildKernel/Initramfs)
+               $(call Image/InstallKernel)
                $(call Image/mkfs/cpiogz)
                $(call Image/mkfs/targz)
                $(call Image/mkfs/ext4)
@@ -210,6 +248,7 @@ define BuildImage
     install: compile install-targets
                $(call Image/BuildKernel)
                $(call Image/BuildKernel/Initramfs)
+               $(call Image/InstallKernel)
                $(call Image/mkfs/cpiogz)
                $(call Image/mkfs/targz)
                $(call Image/mkfs/ext4)