18d730cfbSDavid Woodhouse# ========================================================================== 28d730cfbSDavid Woodhouse# Installing headers 38d730cfbSDavid Woodhouse# 47712401aSSam Ravnborg# header-y - list files to be installed. They are preprocessed 57712401aSSam Ravnborg# to remove __KERNEL__ section of the file 67712401aSSam Ravnborg# unifdef-y - Same as header-y. Obsolete 77712401aSSam Ravnborg# objhdr-y - Same as header-y but for generated files 88d730cfbSDavid Woodhouse# 98d730cfbSDavid Woodhouse# ========================================================================== 108d730cfbSDavid Woodhouse 117712401aSSam Ravnborg# called may set destination dir (when installing to asm/) 128d730cfbSDavid Woodhouse_dst := $(if $(dst),$(dst),$(obj)) 138d730cfbSDavid Woodhouse 14283039fbSSam Ravnborgkbuild-file := $(srctree)/$(obj)/Kbuild 15283039fbSSam Ravnborginclude $(kbuild-file) 16de789125SDavid Woodhouse 178d730cfbSDavid Woodhouseinclude scripts/Kbuild.include 188d730cfbSDavid Woodhouse 1962284a37SSam Ravnborginstall := $(INSTALL_HDR_PATH)/$(_dst) 2062284a37SSam Ravnborg 214e420aa9SSam Ravnborgheader-y := $(sort $(header-y) $(unifdef-y)) 227712401aSSam Ravnborgsubdirs := $(patsubst %/,%,$(filter %/, $(header-y))) 238d730cfbSDavid Woodhouseheader-y := $(filter-out %/, $(header-y)) 248d730cfbSDavid Woodhouse 257712401aSSam Ravnborg# files used to track state of install/check 267712401aSSam Ravnborginstall-file := $(install)/.install 277712401aSSam Ravnborgcheck-file := $(install)/.check 287712401aSSam Ravnborg 297712401aSSam Ravnborg# all headers files for this dir 307712401aSSam Ravnborgall-files := $(header-y) $(objhdr-y) 317712401aSSam Ravnborginput-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ 327712401aSSam Ravnborg $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) 337712401aSSam Ravnborgoutput-files := $(addprefix $(install)/, $(all-files)) 34de789125SDavid Woodhouse 35de789125SDavid Woodhouse# Work out what needs to be removed 3662284a37SSam Ravnborgoldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) 377712401aSSam Ravnborgunwanted := $(filter-out $(all-files),$(oldheaders)) 38de789125SDavid Woodhouse 397712401aSSam Ravnborg# Prefix unwanted with full paths to $(INSTALL_HDR_PATH) 407712401aSSam Ravnborgunwanted-file := $(addprefix $(install)/, $(unwanted)) 41de789125SDavid Woodhouse 427712401aSSam Ravnborgprintdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) 43de789125SDavid Woodhouse 447712401aSSam Ravnborgquiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ 457712401aSSam Ravnborg file$(if $(word 2, $(all-files)),s)) 46*db1bec4fSSam Ravnborg cmd_install = \ 47*db1bec4fSSam Ravnborg $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ 48*db1bec4fSSam Ravnborg $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ 497712401aSSam Ravnborg touch $@ 508d730cfbSDavid Woodhouse 517712401aSSam Ravnborgquiet_cmd_remove = REMOVE $(unwanted) 527712401aSSam Ravnborg cmd_remove = rm -f $(unwanted-file) 538d730cfbSDavid Woodhouse 547712401aSSam Ravnborgquiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) 557712401aSSam Ravnborg cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \ 567712401aSSam Ravnborg $(addprefix $(install)/, $(all-files)); \ 577712401aSSam Ravnborg touch $@ 5868475359SDavid Woodhouse 597712401aSSam RavnborgPHONY += __headersinst __headerscheck 608d730cfbSDavid Woodhouse 617712401aSSam Ravnborgifndef HDRCHECK 627712401aSSam Ravnborg# Rules for installing headers 637712401aSSam Ravnborg__headersinst: $(subdirs) $(install-file) 647712401aSSam Ravnborg @: 65de789125SDavid Woodhouse 667712401aSSam Ravnborgtargets += $(install-file) 677712401aSSam Ravnborg$(install-file): scripts/headers_install.pl $(input-files) FORCE 687712401aSSam Ravnborg $(if $(unwanted),$(call cmd,remove),) 697712401aSSam Ravnborg $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) 707712401aSSam Ravnborg $(call if_changed,install) 71de789125SDavid Woodhouse 7268475359SDavid Woodhouseelse 737712401aSSam Ravnborg__headerscheck: $(subdirs) $(check-file) 747712401aSSam Ravnborg @: 758d730cfbSDavid Woodhouse 767712401aSSam Ravnborgtargets += $(check-file) 777712401aSSam Ravnborg$(check-file): scripts/headers_check.pl $(output-files) FORCE 787712401aSSam Ravnborg $(call if_changed,check) 794e420aa9SSam Ravnborg 808d730cfbSDavid Woodhouseendif 818d730cfbSDavid Woodhouse 828d730cfbSDavid Woodhouse# Recursion 837712401aSSam Ravnborghdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj 847712401aSSam Ravnborg.PHONY: $(subdirs) 857712401aSSam Ravnborg$(subdirs): 8662284a37SSam Ravnborg $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ 877712401aSSam Ravnborg 887712401aSSam Ravnborgtargets := $(wildcard $(sort $(targets))) 897712401aSSam Ravnborgcmd_files := $(wildcard \ 907712401aSSam Ravnborg $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) 917712401aSSam Ravnborg 927712401aSSam Ravnborgifneq ($(cmd_files),) 937712401aSSam Ravnborg include $(cmd_files) 947712401aSSam Ravnborgendif 957712401aSSam Ravnborg 967712401aSSam Ravnborg.PHONY: $(PHONY) 977712401aSSam RavnborgPHONY += FORCE 987712401aSSam RavnborgFORCE: ; 99