Messages in this thread Patch in this message | | | Subject | Re: [patch 1/8] extend make headers_check to detect more problems | From | David Woodhouse <> | Date | Thu, 21 Sep 2006 16:13:27 +0100 |
| |
On Mon, 2006-09-18 at 07:45 +0100, David Woodhouse wrote: > I'd like to move to a scheme where we do headers_install and > headers_check _without_ starting with a rm -rf > $(HDR_INSTALL_PATH)/include. > > We could probably do it by adding a rule along the lines of > $(filter-out $(unifdef-y) $(header-y),$(wildcard > $(INSTALL_HDR_PATH)/$(dst)/*.h): > rm $@ > ... i.e. remove every .h file from the destination directory except > the > ones we just created. > > Then we can make $(INSTALL_HDR_PATH)/$(dst)/%.h depend on > $(srctree)/$(src)/%.h so that it doesn't get re-exported unless it's > changed. And we can keep a stamp file around (or the output of the > test > compilation after Arnd's patch) which shows that the _check_ step has > been done too. Something like .checked.%.h > > After we do that, a second invocation of 'make headers_check' should > have nothing to do, which will encourage people to keep using it.
How does this look? Need to sort out dependencies for the .check.$FOO.h files, but it does 'headers_install' relatively sanely with dependencies, and also implements 'headers_install_all' with which we can make a release tarball of linux-kernel-headers.
Oh, and I buggered the autogenerated files for biarch, but I'll fix that later this evening.
diff --git a/Makefile b/Makefile index 33074e8..fa72626 100644 --- a/Makefile +++ b/Makefile @@ -892,18 +892,26 @@ # Kernel headers INSTALL_HDR_PATH=$(objtree)/usr export INSTALL_HDR_PATH +HDRARCHES=$(filter-out generic,$(patsubst $(srctree)/include/asm-%/Kbuild,%,$(wildcard $(srctree)/include/asm-*/Kbuild))) + +PHONY += headers_install_all +headers_install_all: include/linux/version.h + $(Q)unifdef -Ux /dev/null + $(Q)for arch in $(HDRARCHES); do \ + $(MAKE) ARCH=$$arch -rR -f $(srctree)/scripts/Makefile.headersinst obj=include BIASMDIR=-bi-$$arch __headersinst ;\ + done + PHONY += headers_install headers_install: include/linux/version.h @if [ ! -r include/asm-$(ARCH)/Kbuild ]; then \ echo '*** Error: Headers not exportable for this architecture ($(ARCH))'; \ exit 1 ; fi $(Q)unifdef -Ux /dev/null - $(Q)rm -rf $(INSTALL_HDR_PATH)/include - $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.headersinst obj=include + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.headersinst obj=include __headersinst PHONY += headers_check headers_check: headers_install - $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.headersinst obj=include HDRCHECK=1 + $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.headersinst obj=include __headerscheck # --------------------------------------------------------------------------- # Modules diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c diff --git a/include/Kbuild b/include/Kbuild diff --git a/include/asm-i386/Kbuild b/include/asm-i386/Kbuild diff --git a/include/asm-powerpc/auxvec.h b/include/asm-powerpc/auxvec.h diff --git a/include/asm-powerpc/signal.h b/include/asm-powerpc/signal.h diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 12e1daf..c47a9ec 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst @@ -24,8 +24,6 @@ HDRSED := sed -e "s/ inline / __inline _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 @@ -36,17 +34,18 @@ # 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 +KBUILDFILES := $(srctree)/include/$(archasm)/Kbuild $(srctree)/include/$(altarchasm)/Kbuild +-include $(KBUILDFILES) else -include $(srctree)/$(obj)/Kbuild +KBUILDFILES := $(srctree)/$(obj)/Kbuild +include $(KBUILDFILES) endif 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)) +ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)$(BIASMDIR)) _dst := include/asm endif @@ -56,6 +55,20 @@ subdir-y := $(patsubst %/,%,$(filter %/, header-y := $(filter-out %/, $(header-y)) header-y := $(filter-out $(unifdef-y),$(header-y)) +# Work out what needs to be removed +oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h)) +unwanted := $(filter-out $(header-y) $(unifdef-y) $(objhdr-y),$(oldheaders)) + +# stamp files for header checks +check-y := $(patsubst %,.check.%,$(header-y) $(unifdef-y) $(objhdr-y)) + +# Prefix them all with full paths to $(INSTALL_HDR_PATH) +header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y)) +unifdef-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(unifdef-y)) +objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y)) +check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y)) + + ifdef ALTARCH ifeq ($(obj),include/asm-$(ARCH)) altarch-y := altarch-dir @@ -67,43 +80,47 @@ 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_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) + cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \ + $(INSTALL_HDR_PATH)/$(_dst) -quiet_cmd_headers_install = INSTALL $(_dst)/$@ - cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \ - > $(INSTALL_HDR_PATH)/$(_dst)/$@ +quiet_cmd_headers_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) + cmd_headers_install = $(HDRSED) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \ + > $@ -quiet_cmd_unifdef = UNIFDEF $(_dst)/$@ - cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \ - > $(INSTALL_HDR_PATH)/$(_dst)/$@ || : +quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) + cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \ + | $(HDRSED) > $@ || : -quiet_cmd_check = CHECK $(_dst)/$@ +quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@) cmd_check = $(srctree)/scripts/hdrcheck.sh \ - $(INSTALL_HDR_PATH)/include \ - $(INSTALL_HDR_PATH)/$(_dst)/$@ + $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) + +quiet_cmd_remove = REMOVE $(_dst)/$@ + cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@ -quiet_cmd_mkdir = MKDIR $@ - cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@ +quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) + cmd_mkdir = mkdir -p $@ -quiet_cmd_gen = GEN $(_dst)/$@ +quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@) cmd_gen = \ +FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@) \ 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)/$@>" ; \ +if [ -r $(subst /$(_dst)/,/$(archasm),$@) ]; then \ + echo "\# include <$(archasm)/$$FNAME>" ; \ else \ - echo "\# error $(archasm)/$@ does not exist in" \ + echo "\# error $(archasm)/$$FNAME does not exist in" \ "the $(ARCH) architecture" ; \ fi ; \ echo "\# elif $(ALTARCHDEF)" ; \ -if [ -r $(INSTALL_HDR_PATH)/include/$(altarchasm)/$@ ]; then \ - echo "\# include <$(altarchasm)/$@>" ; \ +if [ -r $(subst /$(_dst)/,/$(altarchasm),$@) ]; then \ + echo "\# include <$(altarchasm)/$$FNAME>" ; \ else \ - echo "\# error $(altarchasm)/$@ does not exist in" \ + echo "\# error $(altarchasm)/$$FNAME does not exist in" \ "the $(ALTARCH) architecture" ; \ fi ; \ echo "\# else" ; \ @@ -111,39 +128,45 @@ echo "\# warning This machine appears t "neither $(ARCH) nor $(ALTARCH)." ; \ echo "\# endif" ; \ echo "\#endif /* $$STUBDEF */" ; \ -) > $(INSTALL_HDR_PATH)/$(_dst)/$@ +) > $@ __headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y) + @true -.PHONY: $(header-y) $(unifdef-y) $(subdir-y) +__headerscheck: $(subdir-y) $(check-y) + @true -ifdef HDRCHECK -# Rules for checking headers -$(objhdr-y) $(header-y) $(unifdef-y): +# Leave $(check-y) as .PHONY for now till we sort out proper deps for it +.PHONY: $(check-y) +$(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h $(call cmd,check) -else + @touch $@ + # Rules for installing headers -$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst) +$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted) -.PHONY: $(_dst) -$(_dst): +$(INSTALL_HDR_PATH)/$(_dst): $(call cmd,mkdir) +.PHONY: $(unwanted) +$(unwanted): + $(call cmd,remove) + ifdef GENASM -$(objhdr-y) $(header-y) $(unifdef-y): +$(objhdr-y) $(header-y) $(unifdef-y): $(KBUILDFILES) $(call cmd,gen) else -$(objhdr-y): +$(objhdr-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) $(call cmd,o_hdr_install) -$(header-y): +$(header-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) $(call cmd,headers_install) -$(unifdef-y): +$(unifdef-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) $(call cmd,unifdef) -endif + endif hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj @@ -152,9 +175,11 @@ hdrinst := -rR -f $(srctree)/scripts/Mak # 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 + $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH) $(MAKECMDGOALS) + $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm$(BIASMDIR) $(MAKECMDGOALS) # Recursion +.PHONY: $(subdir-y) $(subdir-y): - $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) + $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) $(MAKECMDGOALS) +
-- dwmw2
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |