image.mk: do not emit multiple target definitions for kernel images
[openwrt/svn-archive/archive.git] / include / image.mk
index b78576e03af0345b2e6b4c678c32422b2b98a902..bd6a88af61f2948947df79693d978680452ca11c 100644 (file)
@@ -244,8 +244,8 @@ endef
 
 define Image/mkfs/prepare/default
        # Use symbolic permissions to avoid clobbering SUID/SGID/sticky bits
-       - $(FIND) $(TARGET_DIR) -type f -not -perm +0100 -not -name 'ssh_host*' -not -name 'shadow' -print0 | $(XARGS) -0 chmod u+rw,g+r,o+r
-       - $(FIND) $(TARGET_DIR) -type f -perm +0100 -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
+       - $(FIND) $(TARGET_DIR) -type f -not -perm /0100 -not -name 'ssh_host*' -not -name 'shadow' -print0 | $(XARGS) -0 chmod u+rw,g+r,o+r
+       - $(FIND) $(TARGET_DIR) -type f -perm /0100 -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
        - $(FIND) $(TARGET_DIR) -type d -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
        $(INSTALL_DIR) $(TARGET_DIR)/tmp $(TARGET_DIR)/overlay
        chmod 1777 $(TARGET_DIR)/tmp
@@ -258,8 +258,7 @@ endef
 
 define Image/Checksum
        ( cd ${BIN_DIR} ; \
-               $(FIND) -maxdepth 1 -type f \! -name 'md5sums'  -printf "%P\n" | sort | xargs \
-               md5sum --binary > md5sums \
+               $(FIND) -maxdepth 1 -type f \! -name 'md5sums'  -printf "%P\n" | sort | xargs $1 > $2 \
        )
 endef
 
@@ -353,7 +352,10 @@ define Device/ExportVar
   $(1) : $(2):=$$($(2))
 
 endef
-Device/Export = $(foreach var,$(DEVICE_VARS) KERNEL,$(call Device/ExportVar,$(1),$(var)))
+define Device/Export
+  $(foreach var,$(DEVICE_VARS) KERNEL KERNEL_INITRAMFS,$(call Device/ExportVar,$(1),$(var)))
+  $(1) : FILESYSTEM:=$(2)
+endef
 
 define Device/Check
   _TARGET = $$(if $$(filter $(PROFILE),$$(PROFILES)),install,install-disabled)
@@ -378,6 +380,8 @@ define Device/Build/check_size
 endef
 
 define Device/Build/kernel
+  _KERNEL_IMAGES += $(KDIR)/$$(KERNEL_NAME)
+  $(KDIR)/$$(KERNEL_NAME): image_prepare
   $$(_TARGET): $$(if $$(KERNEL_INSTALL),$(BIN_DIR)/$$(KERNEL_IMAGE))
   $(BIN_DIR)/$$(KERNEL_IMAGE): $(KDIR)/$$(KERNEL_IMAGE)
        cp $$^ $$@
@@ -388,16 +392,16 @@ define Device/Build/kernel
 endef
 
 define Device/Build/image
-  FILESYSTEM := $(1)
   $$(_TARGET): $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
-  $(eval $(call Device/Export,$(KDIR)/$(KERNEL_IMAGE)))
-  $(eval $(call Device/Export,$(KDIR)/$(KERNEL_INITRAMFS_IMAGE)))
-  $(eval $(call Device/Export,$(KDIR)/$(call IMAGE_NAME,$(1),$(2))))
+  $(eval $(call Device/Export,$(KDIR)/$(KERNEL_IMAGE),$(1)))
+  $(eval $(call Device/Export,$(KDIR)/$(KERNEL_INITRAMFS_IMAGE),$(1)))
+  $(eval $(call Device/Export,$(KDIR)/$(call IMAGE_NAME,$(1),$(2)),$(1)))
   $(KDIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/$$(KERNEL_IMAGE) $(KDIR)/root.$(1)
        @rm -f $$@
        [ -f $$(word 1,$$^) -a -f $$(word 2,$$^) ]
        $$(call concat_cmd,$(if $(IMAGE/$(2)/$(1)),$(IMAGE/$(2)/$(1)),$(IMAGE/$(2))))
 
+  .IGNORE: $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
   $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/$(call IMAGE_NAME,$(1),$(2))
        cp $$^ $$@
 
@@ -452,11 +456,15 @@ define BuildImage
   $(foreach device,$(TARGET_DEVICES),$(call Device,$(device)))
   $(foreach fs,$(TARGET_FILESYSTEMS) $(fs-subtypes-y),$(call BuildImage/mkfs,$(fs)))
 
+  $$(sort $$(_KERNEL_IMAGES)):
+       @touch $$@
+
   install: kernel_prepare
        $(foreach fs,$(TARGET_FILESYSTEMS),
                $(call Image/Build,$(fs))
        )
        $(call Image/mkfs/ubifs)
-       $(call Image/Checksum)
+       $(call Image/Checksum,md5sum --binary,md5sums)
+       $(call Image/Checksum,openssl dgst -sha256,sha256sums)
 
 endef