X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=scripts%2FMakefile.headersinst;h=095cfc8b9dbfbddff4cbbbc3437019e8b2996255;hb=d911df7b8d44de41661363a4e29ee710180ba025;hp=12e1daf875c832931202467011e292bcd3575c0a;hpb=b512217736049cef3e681bbd3ff6696c1cca567d;p=safe%2Fjmp%2Flinux-2.6 diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 12e1daf..095cfc8 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst @@ -1,160 +1,100 @@ # ========================================================================== # Installing headers # -# header-y files will be installed verbatim -# unifdef-y are the files where unifdef will be run before installing files -# objhdr-y are generated files that will be installed verbatim +# header-y - list files to be installed. They are preprocessed +# to remove __KERNEL__ section of the file +# unifdef-y - Same as header-y. Obsolete +# objhdr-y - Same as header-y but for generated files # # ========================================================================== -UNIFDEF := unifdef -U__KERNEL__ - -# Eliminate the contents of (and inclusions of) compiler.h -HDRSED := sed -e "s/ inline / __inline__ /g" \ - -e "s/[[:space:]]__user[[:space:]]\+/ /g" \ - -e "s/(__user[[:space:]]\+/ (/g" \ - -e "s/[[:space:]]__force[[:space:]]\+/ /g" \ - -e "s/(__force[[:space:]]\+/ (/g" \ - -e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \ - -e "s/(__iomem[[:space:]]\+/ (/g" \ - -e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \ - -e "s/[[:space:]]__attribute_const__$$//" \ - -e "/^\#include /d" - +# called may set destination dir (when installing to asm/) _dst := $(if $(dst),$(dst),$(obj)) -.PHONY: __headersinst -__headersinst: - - -ifeq (,$(patsubst include/asm/%,,$(obj)/)) -# For producing the generated stuff in include/asm for biarch builds, include -# both sets of Kbuild files; we'll generate anything which is mentioned in -# _either_ arch, and recurse into subdirectories which are mentioned in either -# arch. Since some directories may exist in one but not the other, we must -# use '-include'. -GENASM := 1 -archasm := $(subst include/asm,asm-$(ARCH),$(obj)) -altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj)) --include $(srctree)/include/$(archasm)/Kbuild --include $(srctree)/include/$(altarchasm)/Kbuild -else -include $(srctree)/$(obj)/Kbuild -endif +kbuild-file := $(srctree)/$(obj)/Kbuild +include $(kbuild-file) + +_dst := $(if $(destination-y),$(destination-y),$(_dst)) include scripts/Kbuild.include -# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then -# override $(_dst) so that we install to include/asm directly. -ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)) - _dst := include/asm -endif +install := $(INSTALL_HDR_PATH)/$(_dst) -header-y := $(sort $(header-y)) -unifdef-y := $(sort $(unifdef-y)) -subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) -header-y := $(filter-out %/, $(header-y)) -header-y := $(filter-out $(unifdef-y),$(header-y)) +header-y := $(sort $(header-y) $(unifdef-y)) +subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) +header-y := $(filter-out %/, $(header-y)) -ifdef ALTARCH -ifeq ($(obj),include/asm-$(ARCH)) -altarch-y := altarch-dir -endif -endif +# files used to track state of install/check +install-file := $(install)/.install +check-file := $(install)/.check -# Make the definitions visible for recursive make invocations -export ALTARCH -export ARCHDEF -export ALTARCHDEF - -quiet_cmd_o_hdr_install = INSTALL $(_dst)/$@ - cmd_o_hdr_install = cp $(objtree)/$(obj)/$@ $(INSTALL_HDR_PATH)/$(_dst) - -quiet_cmd_headers_install = INSTALL $(_dst)/$@ - cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \ - > $(INSTALL_HDR_PATH)/$(_dst)/$@ - -quiet_cmd_unifdef = UNIFDEF $(_dst)/$@ - cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \ - > $(INSTALL_HDR_PATH)/$(_dst)/$@ || : - -quiet_cmd_check = CHECK $(_dst)/$@ - cmd_check = $(srctree)/scripts/hdrcheck.sh \ - $(INSTALL_HDR_PATH)/include \ - $(INSTALL_HDR_PATH)/$(_dst)/$@ - -quiet_cmd_mkdir = MKDIR $@ - cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@ - -quiet_cmd_gen = GEN $(_dst)/$@ - cmd_gen = \ -STUBDEF=__ASM_STUB_`echo $@ | tr a-z. A-Z_`; \ -(echo "/* File autogenerated by 'make headers_install' */" ; \ -echo "\#ifndef $$STUBDEF" ; \ -echo "\#define $$STUBDEF" ; \ -echo "\# if $(ARCHDEF)" ; \ -if [ -r $(INSTALL_HDR_PATH)/include/$(archasm)/$@ ]; then \ - echo "\# include <$(archasm)/$@>" ; \ -else \ - echo "\# error $(archasm)/$@ does not exist in" \ - "the $(ARCH) architecture" ; \ -fi ; \ -echo "\# elif $(ALTARCHDEF)" ; \ -if [ -r $(INSTALL_HDR_PATH)/include/$(altarchasm)/$@ ]; then \ - echo "\# include <$(altarchasm)/$@>" ; \ -else \ - echo "\# error $(altarchasm)/$@ does not exist in" \ - "the $(ALTARCH) architecture" ; \ -fi ; \ -echo "\# else" ; \ -echo "\# warning This machine appears to be" \ - "neither $(ARCH) nor $(ALTARCH)." ; \ -echo "\# endif" ; \ -echo "\#endif /* $$STUBDEF */" ; \ -) > $(INSTALL_HDR_PATH)/$(_dst)/$@ - -__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y) - -.PHONY: $(header-y) $(unifdef-y) $(subdir-y) - -ifdef HDRCHECK -# Rules for checking headers -$(objhdr-y) $(header-y) $(unifdef-y): - $(call cmd,check) -else -# Rules for installing headers +# all headers files for this dir +all-files := $(header-y) $(objhdr-y) +input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ + $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) +output-files := $(addprefix $(install)/, $(all-files)) + +# Work out what needs to be removed +oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h)) +unwanted := $(filter-out $(all-files),$(oldheaders)) -$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst) +# Prefix unwanted with full paths to $(INSTALL_HDR_PATH) +unwanted-file := $(addprefix $(install)/, $(unwanted)) -.PHONY: $(_dst) -$(_dst): - $(call cmd,mkdir) +printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) -ifdef GENASM -$(objhdr-y) $(header-y) $(unifdef-y): - $(call cmd,gen) +quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ + file$(if $(word 2, $(all-files)),s)) + cmd_install = \ + $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ + $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ + touch $@ + +quiet_cmd_remove = REMOVE $(unwanted) + cmd_remove = rm -f $(unwanted-file) + +quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) + cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \ + $(addprefix $(install)/, $(all-files)); \ + touch $@ + +PHONY += __headersinst __headerscheck + +ifndef HDRCHECK +# Rules for installing headers +__headersinst: $(subdirs) $(install-file) + @: + +targets += $(install-file) +$(install-file): scripts/headers_install.pl $(input-files) FORCE + $(if $(unwanted),$(call cmd,remove),) + $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) + $(call if_changed,install) else -$(objhdr-y): - $(call cmd,o_hdr_install) +__headerscheck: $(subdirs) $(check-file) + @: -$(header-y): - $(call cmd,headers_install) +targets += $(check-file) +$(check-file): scripts/headers_check.pl $(output-files) FORCE + $(call if_changed,check) -$(unifdef-y): - $(call cmd,unifdef) -endif endif -hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj +# Recursion +hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj +.PHONY: $(subdirs) +$(subdirs): + $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@ -.PHONY: altarch-dir -# All the files in the normal arch dir must be created first, since we test -# for their existence. -altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y) - $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH) - $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm +targets := $(wildcard $(sort $(targets))) +cmd_files := $(wildcard \ + $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) -# Recursion -$(subdir-y): - $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) +ifneq ($(cmd_files),) + include $(cmd_files) +endif + +.PHONY: $(PHONY) +PHONY += FORCE +FORCE: ;