mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-16 18:46:44 +07:00
919987318a
Some time ago, Sam pointed out a certain degree of overwrap between generic-y and mandatory-y. (https://lkml.org/lkml/2017/7/10/121) I tweaked the meaning of mandatory-y a little bit; now it defines the minimum set of ASM headers that all architectures must have. If arch does not have specific implementation of a mandatory header, Kbuild will let it fallback to the asm-generic one by automatically generating a wrapper. This will allow to drop lots of redundant generic-y defines. Previously, "mandatory" was used in the context of UAPI, but I guess this can be extended to kernel space ASM headers. Suggested-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Sam Ravnborg <sam@ravnborg.org>
48 lines
1.4 KiB
Makefile
48 lines
1.4 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
# include/asm-generic contains a lot of files that are used
|
|
# verbatim by several architectures.
|
|
#
|
|
# This Makefile reads the file arch/$(SRCARCH)/include/(uapi/)/asm/Kbuild
|
|
# and for each file listed in this file with generic-y creates
|
|
# a small wrapper file in arch/$(SRCARCH)/include/generated/(uapi/)/asm.
|
|
|
|
PHONY := all
|
|
all:
|
|
|
|
src := $(subst /generated,,$(obj))
|
|
-include $(src)/Kbuild
|
|
|
|
include scripts/Kbuild.include
|
|
|
|
# If arch does not implement mandatory headers, fallback to asm-generic ones.
|
|
mandatory-y := $(filter-out $(generated-y), $(mandatory-y))
|
|
generic-y += $(foreach f, $(mandatory-y), $(if $(wildcard $(srctree)/$(src)/$(f)),,$(f)))
|
|
|
|
generic-y := $(addprefix $(obj)/, $(generic-y))
|
|
generated-y := $(addprefix $(obj)/, $(generated-y))
|
|
|
|
# Remove stale wrappers when the corresponding files are removed from generic-y
|
|
old-headers := $(wildcard $(obj)/*.h)
|
|
unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers))
|
|
|
|
quiet_cmd_wrap = WRAP $@
|
|
cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@
|
|
|
|
quiet_cmd_remove = REMOVE $(unwanted)
|
|
cmd_remove = rm -f $(unwanted)
|
|
|
|
all: $(generic-y)
|
|
$(if $(unwanted),$(call cmd,remove))
|
|
@:
|
|
|
|
$(obj)/%.h:
|
|
$(call cmd,wrap)
|
|
|
|
# Create output directory. Skip it if at least one old header exists
|
|
# since we know the output directory already exists.
|
|
ifeq ($(old-headers),)
|
|
$(shell mkdir -p $(obj))
|
|
endif
|
|
|
|
.PHONY: $(PHONY)
|