Makefile.fwinst 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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-m).
  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 $(src)/Makefile
  14. include scripts/Makefile.host
  15. mod-fw := $(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 += $(fw-shipped-y)
  20. endif
  21. ifneq ($(KBUILD_SRC),)
  22. # Create output directory if not already present
  23. _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
  24. firmware-dirs := $(sort $(addprefix $(objtree)/$(obj)/,$(dir $(fw-external-y) $(fw-shipped-all))))
  25. # Create directories for firmware in subdirectories
  26. _dummy := $(foreach d,$(firmware-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
  27. endif
  28. installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw))
  29. installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all))
  30. quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@)
  31. cmd_install = mkdir -p $(@D); $(INSTALL) -m0644 $< $@
  32. $(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/%
  33. $(call cmd,install)
  34. PHONY += __fw_install __fw_modinst FORCE
  35. .PHONY: $(PHONY)
  36. __fw_install: $(installed-fw)
  37. __fw_modinst: $(installed-mod-fw)
  38. @:
  39. __fw_modbuild: $(addprefix $(obj)/,$(mod-fw))
  40. @:
  41. FORCE:
  42. # Read all saved command lines and dependencies for the $(targets) we
  43. # may be building using $(if_changed{,_dep}). As an optimization, we
  44. # don't need to read them if the target does not exist; we will rebuild
  45. # anyway in that case.
  46. targets := $(wildcard $(sort $(targets)))
  47. cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
  48. ifneq ($(cmd_files),)
  49. include $(cmd_files)
  50. endif