1*4882a593Smuzhiyun# ========================================================================== 2*4882a593Smuzhiyun# Installing firmware 3*4882a593Smuzhiyun# 4*4882a593Smuzhiyun# We don't include the .config, so all firmware files are in $(fw-shipped-) 5*4882a593Smuzhiyun# rather than in $(fw-shipped-y) or $(fw-shipped-m). 6*4882a593Smuzhiyun# ========================================================================== 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunINSTALL := install 9*4882a593Smuzhiyunsrc := $(obj) 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun# For modules_install installing firmware, we want to see .config 12*4882a593Smuzhiyun# But for firmware_install, we don't care, but don't want to require it. 13*4882a593Smuzhiyun-include $(objtree)/.config 14*4882a593Smuzhiyun 15*4882a593Smuzhiyuninclude scripts/Kbuild.include 16*4882a593Smuzhiyuninclude $(src)/Makefile 17*4882a593Smuzhiyun 18*4882a593Smuzhiyuninclude scripts/Makefile.host 19*4882a593Smuzhiyun 20*4882a593Smuzhiyunmod-fw := $(fw-shipped-m) 21*4882a593Smuzhiyun# If CONFIG_FIRMWARE_IN_KERNEL isn't set, then install the 22*4882a593Smuzhiyun# firmware for in-kernel drivers too. 23*4882a593Smuzhiyunifndef CONFIG_FIRMWARE_IN_KERNEL 24*4882a593Smuzhiyunmod-fw += $(fw-shipped-y) 25*4882a593Smuzhiyunendif 26*4882a593Smuzhiyun 27*4882a593Smuzhiyunifneq ($(KBUILD_SRC),) 28*4882a593Smuzhiyun# Create output directory if not already present 29*4882a593Smuzhiyun_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) 30*4882a593Smuzhiyun 31*4882a593Smuzhiyunfirmware-dirs := $(sort $(addprefix $(objtree)/$(obj)/,$(dir $(fw-external-y) $(fw-shipped-all)))) 32*4882a593Smuzhiyun# Create directories for firmware in subdirectories 33*4882a593Smuzhiyun_dummy := $(foreach d,$(firmware-dirs), $(shell [ -d $(d) ] || mkdir -p $(d))) 34*4882a593Smuzhiyunendif 35*4882a593Smuzhiyun 36*4882a593Smuzhiyuninstalled-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) 37*4882a593Smuzhiyun 38*4882a593Smuzhiyuninstalled-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) 39*4882a593Smuzhiyun 40*4882a593Smuzhiyunquiet_cmd_install = INSTALL $(subst $(srctree)/,,$@) 41*4882a593Smuzhiyun cmd_install = mkdir -p $(@D); $(INSTALL) -m0644 $< $@ 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% 44*4882a593Smuzhiyun $(call cmd,install) 45*4882a593Smuzhiyun 46*4882a593SmuzhiyunPHONY += __fw_install __fw_modinst FORCE 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun.PHONY: $(PHONY) 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun__fw_install: $(installed-fw) 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun__fw_modinst: $(installed-mod-fw) 53*4882a593Smuzhiyun @: 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun__fw_modbuild: $(addprefix $(obj)/,$(mod-fw)) 56*4882a593Smuzhiyun @: 57*4882a593Smuzhiyun 58*4882a593SmuzhiyunFORCE: 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun# Read all saved command lines and dependencies for the $(targets) we 61*4882a593Smuzhiyun# may be building using $(if_changed{,_dep}). As an optimization, we 62*4882a593Smuzhiyun# don't need to read them if the target does not exist; we will rebuild 63*4882a593Smuzhiyun# anyway in that case. 64*4882a593Smuzhiyun 65*4882a593Smuzhiyuntargets := $(wildcard $(sort $(targets))) 66*4882a593Smuzhiyuncmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) 67*4882a593Smuzhiyun 68*4882a593Smuzhiyunifneq ($(cmd_files),) 69*4882a593Smuzhiyun include $(cmd_files) 70*4882a593Smuzhiyunendif 71