mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 18:13:51 +07:00
7ff4f0805e
Since commitd5470d1443
("kbuild: re-implement Makefile.headersinst without recursion"), headers_install emits an ugly warning. $ make headers_install [ snip ] UPD include/generated/uapi/linux/version.h find: ‘./include/uapi/Kbuild’: No such file or directory HDRINST usr/include/video/uvesafb.h ... This happens for GNU Make <= 4.2.1 When I wrote that commit, I missed this warning because I was using the state-of-the-art Make version compiled from the git tree. $(wildcard $(src)/*/) is intended to match to only existing directories since it has a trailing slash, but actually matches to regular files too. (include/uapi/Kbuild in this case) This is a bug of GNU Make, and was fixed by: | commit b7acb10e86dc8f5fdf2a2bbd87e1059c315e31d6 | Author: spagoveanu@gmail.com <spagoveanu@gmail.com> | Date: Wed Jun 20 02:03:48 2018 +0300 | | * src/dir.c: Preserve glob d_type field We need to cater to old Make versions. Add '$(filter %/,...) to filter out the regular files. Fixes:d5470d1443
("kbuild: re-implement Makefile.headersinst without recursion") Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
103 lines
3.2 KiB
Makefile
103 lines
3.2 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
# ==========================================================================
|
|
# Installing headers
|
|
#
|
|
# All headers under include/uapi, include/generated/uapi,
|
|
# arch/<arch>/include/uapi and arch/<arch>/include/generated/uapi are
|
|
# exported.
|
|
# They are preprocessed to remove __KERNEL__ section of the file.
|
|
#
|
|
# ==========================================================================
|
|
|
|
PHONY := __headers
|
|
__headers:
|
|
|
|
include scripts/Kbuild.include
|
|
|
|
src := $(srctree)/$(obj)
|
|
gen := $(objtree)/$(subst include/,include/generated/,$(obj))
|
|
dst := usr/include
|
|
|
|
-include $(src)/Kbuild
|
|
|
|
# $(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))
|
|
|
|
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))
|
|
|
|
# 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)))
|
|
|
|
gen-headers := $(filter-out $(duplicated), $(gen-headers))
|
|
|
|
# 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)
|
|
|
|
# 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))
|
|
|
|
# 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)))
|
|
|
|
# Rules
|
|
|
|
ifndef HDRCHECK
|
|
|
|
quiet_cmd_install = HDRINST $@
|
|
cmd_install = $(CONFIG_SHELL) $(srctree)/scripts/headers_install.sh $< $@
|
|
|
|
$(src-headers): $(dst)/%.h: $(src)/%.h $(srctree)/scripts/headers_install.sh FORCE
|
|
$(call if_changed,install)
|
|
|
|
$(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)
|
|
|
|
__headers: $(all-headers)
|
|
ifneq ($(unwanted),)
|
|
$(call cmd,remove)
|
|
endif
|
|
@:
|
|
|
|
existing-headers := $(filter $(old-headers), $(all-headers))
|
|
|
|
-include $(foreach f,$(existing-headers),$(dir $(f)).$(notdir $(f)).cmd)
|
|
|
|
else
|
|
|
|
quiet_cmd_check = HDRCHK $<
|
|
cmd_check = $(PERL) $(srctree)/scripts/headers_check.pl $(dst) $(SRCARCH) $<; touch $@
|
|
|
|
check-files := $(addsuffix .chk, $(all-headers))
|
|
|
|
$(check-files): $(dst)/%.chk : $(dst)/% $(srctree)/scripts/headers_check.pl
|
|
$(call cmd,check)
|
|
|
|
__headers: $(check-files)
|
|
@:
|
|
|
|
endif
|
|
|
|
PHONY += FORCE
|
|
FORCE:
|
|
|
|
.PHONY: $(PHONY)
|