diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-12 16:03:16 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-12 16:03:16 -0700 |
commit | 39ceda5ce1b002e30563fcb8ad1bb5ac8e4d59ee (patch) | |
tree | 18751f981a3a540379b9f4b01292e1b4f401aa38 /scripts/Makefile.headersinst | |
parent | 5f26f1143678d0fed8115afdcc0de99ee7cc9675 (diff) | |
parent | d4a74bbfee03acf7bbddc77b9c9236462c744fc7 (diff) | |
download | linux-39ceda5ce1b002e30563fcb8ad1bb5ac8e4d59ee.tar.bz2 |
Merge tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada:
- remove headers_{install,check}_all targets
- remove unreasonable 'depends on !UML' from CONFIG_SAMPLES
- re-implement 'make headers_install' more cleanly
- add new header-test-y syntax to compile-test headers
- compile-test exported headers to ensure they are compilable in
user-space
- compile-test headers under include/ to ensure they are self-contained
- remove -Waggregate-return, -Wno-uninitialized, -Wno-unused-value
flags
- add -Werror=unknown-warning-option for Clang
- add 128-bit built-in types support to genksyms
- fix missed rebuild of modules.builtin
- propagate 'No space left on device' error in fixdep to Make
- allow Clang to use its integrated assembler
- improve some coccinelle scripts
- add a new flag KBUILD_ABS_SRCTREE to request Kbuild to use absolute
path for $(srctree).
- do not ignore errors when compression utility is missing
- misc cleanups
* tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (49 commits)
kbuild: use -- separater intead of $(filter-out ...) for cc-cross-prefix
kbuild: Inform user to pass ARCH= for make mrproper
kbuild: fix compression errors getting ignored
kbuild: add a flag to force absolute path for srctree
kbuild: replace KBUILD_SRCTREE with boolean building_out_of_srctree
kbuild: remove src and obj from the top Makefile
scripts/tags.sh: remove unused environment variables from comments
scripts/tags.sh: drop SUBARCH support for ARM
kbuild: compile-test kernel headers to ensure they are self-contained
kheaders: include only headers into kheaders_data.tar.xz
kheaders: remove meaningless -R option of 'ls'
kbuild: support header-test-pattern-y
kbuild: do not create wrappers for header-test-y
kbuild: compile-test exported headers to ensure they are self-contained
init/Kconfig: add CONFIG_CC_CAN_LINK
kallsyms: exclude kasan local symbols on s390
kbuild: add more hints about SUBDIRS replacement
coccinelle: api/stream_open: treat all wait_.*() calls as blocking
coccinelle: put_device: Add a cast to an expression for an assignment
coccinelle: put_device: Adjust a message construction
...
Diffstat (limited to 'scripts/Makefile.headersinst')
-rw-r--r-- | scripts/Makefile.headersinst | 134 |
1 files changed, 57 insertions, 77 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 3d1ebaabd1b6..1b405a7ed14f 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst @@ -14,109 +14,89 @@ __headers: include scripts/Kbuild.include -srcdir := $(srctree)/$(obj) +src := $(srctree)/$(obj) +gen := $(objtree)/$(subst include/,include/generated/,$(obj)) +dst := usr/include -# When make is run under a fakechroot environment, the function -# $(wildcard $(srcdir)/*/.) doesn't only return directories, but also regular -# files. So, we are using a combination of sort/dir/wildcard which works -# with fakechroot. -subdirs := $(patsubst $(srcdir)/%/,%,\ - $(filter-out $(srcdir)/,\ - $(sort $(dir $(wildcard $(srcdir)/*/))))) +-include $(src)/Kbuild -# Recursion -__headers: $(subdirs) +# $(filter %/, ...) is a workaround for GNU Make <= 4.2.1, where +# $(wildcard $(src)/*/) contains not only directories but also regular files. +src-subdirs := $(patsubst $(src)/%/,%,$(filter %/, $(wildcard $(src)/*/))) +gen-subdirs := $(patsubst $(gen)/%/,%,$(filter %/, $(wildcard $(gen)/*/))) +all-subdirs := $(sort $(src-subdirs) $(gen-subdirs)) -PHONY += $(subdirs) -$(subdirs): - $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(dst)/$@ +src-headers := $(if $(src-subdirs), $(shell cd $(src) && find $(src-subdirs) -name '*.h')) +src-headers := $(filter-out $(no-export-headers), $(src-headers)) +gen-headers := $(if $(gen-subdirs), $(shell cd $(gen) && find $(gen-subdirs) -name '*.h')) +gen-headers := $(filter-out $(no-export-headers), $(gen-headers)) -# Skip header install/check for include/uapi and arch/$(SRCARCH)/include/uapi. -# We have only sub-directories there. -skip-inst := $(if $(filter %/uapi,$(obj)),1) +# If the same header is exported from source and generated directories, +# the former takes precedence, but this should be warned. +duplicated := $(filter $(gen-headers), $(src-headers)) +$(if $(duplicated), $(warning duplicated header export: $(duplicated))) -ifeq ($(skip-inst),) +gen-headers := $(filter-out $(duplicated), $(gen-headers)) -# Kbuild file is optional -kbuild-file := $(srctree)/$(obj)/Kbuild --include $(kbuild-file) +# Add dst path prefix +all-subdirs := $(addprefix $(dst)/, $(all-subdirs)) +src-headers := $(addprefix $(dst)/, $(src-headers)) +gen-headers := $(addprefix $(dst)/, $(gen-headers)) +all-headers := $(src-headers) $(gen-headers) -installdir := $(INSTALL_HDR_PATH)/$(dst) -gendir := $(objtree)/$(subst include/,include/generated/,$(obj)) -header-files := $(notdir $(wildcard $(srcdir)/*.h)) -header-files := $(filter-out $(no-export-headers), $(header-files)) -genhdr-files := $(notdir $(wildcard $(gendir)/*.h)) -genhdr-files := $(filter-out $(header-files), $(genhdr-files)) +# Work out what needs to be removed +old-subdirs := $(wildcard $(all-subdirs)) +old-headers := $(if $(old-subdirs),$(shell find $(old-subdirs) -name '*.h')) +unwanted := $(filter-out $(all-headers), $(old-headers)) -# files used to track state of install/check -install-file := $(installdir)/.install -check-file := $(installdir)/.check +# Create directories +existing-dirs := $(sort $(dir $(old-headers))) +wanted-dirs := $(sort $(dir $(all-headers))) +new-dirs := $(filter-out $(existing-dirs), $(wanted-dirs)) +$(if $(new-dirs), $(shell mkdir -p $(new-dirs))) -# all headers files for this dir -all-files := $(header-files) $(genhdr-files) -output-files := $(addprefix $(installdir)/, $(all-files)) +# Rules -# Work out what needs to be removed -oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) -unwanted := $(filter-out $(all-files),$(oldheaders)) +ifndef HDRCHECK -# Prefix unwanted with full paths to $(INSTALL_HDR_PATH) -unwanted-file := $(addprefix $(installdir)/, $(unwanted)) +quiet_cmd_install = HDRINST $@ + cmd_install = $(CONFIG_SHELL) $(srctree)/scripts/headers_install.sh $< $@ -printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) +$(src-headers): $(dst)/%.h: $(src)/%.h $(srctree)/scripts/headers_install.sh FORCE + $(call if_changed,install) -quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ - file$(if $(word 2, $(all-files)),s)) - cmd_install = \ - $(CONFIG_SHELL) $< $(installdir) $(srcdir) $(header-files); \ - $(CONFIG_SHELL) $< $(installdir) $(gendir) $(genhdr-files); \ - touch $@ +$(gen-headers): $(dst)/%.h: $(gen)/%.h $(srctree)/scripts/headers_install.sh FORCE + $(call if_changed,install) quiet_cmd_remove = REMOVE $(unwanted) - cmd_remove = rm -f $(unwanted-file) - -quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files) -# Headers list can be pretty long, xargs helps to avoid -# the "Argument list too long" error. - cmd_check = for f in $(all-files); do \ - echo "$(installdir)/$${f}"; done \ - | xargs \ - $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH); \ - touch $@ + cmd_remove = rm -f $(unwanted) -ifndef HDRCHECK -# Rules for installing headers -__headers: $(install-file) +__headers: $(all-headers) +ifneq ($(unwanted),) + $(call cmd,remove) +endif @: -targets += $(install-file) -$(install-file): scripts/headers_install.sh \ - $(addprefix $(srcdir)/,$(header-files)) \ - $(addprefix $(gendir)/,$(genhdr-files)) FORCE - $(if $(unwanted),$(call cmd,remove),) - $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) - $(call if_changed,install) +existing-headers := $(filter $(old-headers), $(all-headers)) + +-include $(foreach f,$(existing-headers),$(dir $(f)).$(notdir $(f)).cmd) else -__headers: $(check-file) - @: -targets += $(check-file) -$(check-file): scripts/headers_check.pl $(output-files) FORCE - $(call if_changed,check) +quiet_cmd_check = HDRCHK $< + cmd_check = $(PERL) $(srctree)/scripts/headers_check.pl $(dst) $(SRCARCH) $<; touch $@ -endif +check-files := $(addsuffix .chk, $(all-headers)) -cmd_files := $(wildcard \ - $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) +$(check-files): $(dst)/%.chk : $(dst)/% $(srctree)/scripts/headers_check.pl + $(call cmd,check) -ifneq ($(cmd_files),) - include $(cmd_files) -endif +__headers: $(check-files) + @: -endif # skip-inst +endif PHONY += FORCE -FORCE: ; +FORCE: .PHONY: $(PHONY) |