Makefile.fwinst 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # ==========================================================================
  2. # Installing firmware
  3. #
  4. # We don't include the .config, so all firmware files are in $(fw-shipped-)
  5. # rather than in $(fw-shipped-y) or $(fw-shipped-n).
  6. # ==========================================================================
  7. INSTALL := install
  8. src := $(obj)
  9. # For modules_install installing firmware, we want to see .config
  10. # But for firmware_install, we don't care, but don't want to require it.
  11. -include $(objtree)/.config
  12. include scripts/Kbuild.include
  13. include $(srctree)/$(obj)/Makefile
  14. include scripts/Makefile.host
  15. mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-m))
  16. # If CONFIG_FIRMWARE_IN_KERNEL isn't set, then install the
  17. # firmware for in-kernel drivers too.
  18. ifndef CONFIG_FIRMWARE_IN_KERNEL
  19. mod-fw += $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-y))
  20. endif
  21. installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all))
  22. installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/.
  23. # Workaround for make < 3.81, where .SECONDEXPANSION doesn't work.
  24. PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs
  25. $(INSTALL_FW_PATH)/$$(%): install-all-dirs
  26. @true
  27. install-all-dirs: $(installed-fw-dirs)
  28. @true
  29. quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@)
  30. cmd_install = $(INSTALL) -m0644 $< $@
  31. $(installed-fw-dirs):
  32. $(call cmd,mkdir)
  33. $(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $(INSTALL_FW_PATH)/$$(dir %)
  34. $(call cmd,install)
  35. PHONY += __fw_install __fw_modinst FORCE
  36. .PHONY: $(PHONY)
  37. __fw_install: $(installed-fw)
  38. __fw_modinst: $(mod-fw)
  39. FORCE:
  40. # Read all saved command lines and dependencies for the $(targets) we
  41. # may be building using $(if_changed{,_dep}). As an optimization, we
  42. # don't need to read them if the target does not exist; we will rebuild
  43. # anyway in that case.
  44. targets := $(wildcard $(sort $(targets)))
  45. cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
  46. ifneq ($(cmd_files),)
  47. include $(cmd_files)
  48. endif