endif
ifneq ($(LINUX_FIRMWARE_FILES),)
+define LINUX_FIRMWARE_INSTALL_FILES
+ $(TAR) c -C $(@D) $(sort $(LINUX_FIRMWARE_FILES)) | \
+ $(TAR) x -C $(TARGET_DIR)/lib/firmware
+endef
+endif
+
+ifneq ($(LINUX_FIRMWARE_DIRS),)
+# We need to rm-rf the destination directory to avoid copying
+# into it in itself, should we re-install the package.
+define LINUX_FIRMWARE_INSTALL_DIRS
+ $(foreach d,$(LINUX_FIRMWARE_DIRS), \
+ rm -rf $(TARGET_DIR)/lib/firmware/$(d); \
+ cp -a $(@D)/$(d) $(TARGET_DIR)/lib/firmware/$(d)$(sep))
+endef
+endif
+
+ifneq ($(LINUX_FIRMWARE_FILES)$(LINUX_FIRMWARE_DIRS),)
# Most firmware files are under a proprietary license, so no need to
# repeat it for every selections above. Those firmwares that have more
# duplicates
LINUX_FIRMWARE_LICENSE_FILES = $(sort $(LINUX_FIRMWARE_ALL_LICENSE_FILES))
+endif
+
define LINUX_FIRMWARE_INSTALL_TARGET_CMDS
mkdir -p $(TARGET_DIR)/lib/firmware
- $(TAR) c -C $(@D) $(sort $(LINUX_FIRMWARE_FILES)) | \
- $(TAR) x -C $(TARGET_DIR)/lib/firmware
+ $(LINUX_FIRMWARE_INSTALL_FILES)
+ $(LINUX_FIRMWARE_INSTALL_DIRS)
endef
-endif
-
$(eval $(generic-package))