b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100 1) # SPDX-License-Identifier: GPL-2.0
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 2) # include/asm-generic contains a lot of files that are used
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 3) # verbatim by several architectures.
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 4) #
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 5) # This Makefile reads the file arch/$(SRCARCH)/include/(uapi/)/asm/Kbuild
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 6) # and for each file listed in this file with generic-y creates
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 7) # a small wrapper file in arch/$(SRCARCH)/include/generated/(uapi/)/asm.
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 8)
a7d34df3d12c3 (Masahiro Yamada 2017-10-11 12:52:29 +0900 9) PHONY := all
a7d34df3d12c3 (Masahiro Yamada 2017-10-11 12:52:29 +0900 10) all:
a7d34df3d12c3 (Masahiro Yamada 2017-10-11 12:52:29 +0900 11)
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 12) src := $(subst /generated,,$(obj))
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 13) -include $(src)/Kbuild
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 14)
037fc3368be46 (Masahiro Yamada 2019-03-17 11:01:09 +0900 15) # $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case.
037fc3368be46 (Masahiro Yamada 2019-03-17 11:01:09 +0900 16) ifneq ($(SRCARCH),um)
3204a7fb98a3b (Masahiro Yamada 2021-02-28 15:10:26 +0900 17) include $(srctree)/$(generic)/Kbuild
037fc3368be46 (Masahiro Yamada 2019-03-17 11:01:09 +0900 18) endif
037fc3368be46 (Masahiro Yamada 2019-03-17 11:01:09 +0900 19)
3204a7fb98a3b (Masahiro Yamada 2021-02-28 15:10:26 +0900 20) include $(srctree)/scripts/Kbuild.include
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 21)
7cbbbb8bc2974 (Masahiro Yamada 2019-03-17 11:01:08 +0900 22) redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y))
7cbbbb8bc2974 (Masahiro Yamada 2019-03-17 11:01:08 +0900 23) redundant += $(foreach f, $(generic-y), $(if $(wildcard $(srctree)/$(src)/$(f)),$(f)))
7cbbbb8bc2974 (Masahiro Yamada 2019-03-17 11:01:08 +0900 24) redundant := $(sort $(redundant))
7cbbbb8bc2974 (Masahiro Yamada 2019-03-17 11:01:08 +0900 25) $(if $(redundant),\
7cbbbb8bc2974 (Masahiro Yamada 2019-03-17 11:01:08 +0900 26) $(warning redundant generic-y found in $(src)/Kbuild: $(redundant)))
7cbbbb8bc2974 (Masahiro Yamada 2019-03-17 11:01:08 +0900 27)
919987318a129 (Masahiro Yamada 2019-01-03 10:10:38 +0900 28) # If arch does not implement mandatory headers, fallback to asm-generic ones.
919987318a129 (Masahiro Yamada 2019-01-03 10:10:38 +0900 29) mandatory-y := $(filter-out $(generated-y), $(mandatory-y))
919987318a129 (Masahiro Yamada 2019-01-03 10:10:38 +0900 30) generic-y += $(foreach f, $(mandatory-y), $(if $(wildcard $(srctree)/$(src)/$(f)),,$(f)))
919987318a129 (Masahiro Yamada 2019-01-03 10:10:38 +0900 31)
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 32) generic-y := $(addprefix $(obj)/, $(generic-y))
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 33) generated-y := $(addprefix $(obj)/, $(generated-y))
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 34)
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 35) # Remove stale wrappers when the corresponding files are removed from generic-y
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 36) old-headers := $(wildcard $(obj)/*.h)
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 37) unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers))
cda2c65f981d0 (James Hogan 2016-06-24 23:42:24 +0100 38)
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 39) quiet_cmd_wrap = WRAP $@
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 40) cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 41)
cda2c65f981d0 (James Hogan 2016-06-24 23:42:24 +0100 42) quiet_cmd_remove = REMOVE $(unwanted)
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 43) cmd_remove = rm -f $(unwanted)
cda2c65f981d0 (James Hogan 2016-06-24 23:42:24 +0100 44)
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 45) all: $(generic-y)
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 46) $(if $(unwanted),$(call cmd,remove))
181e976327cf3 (Peter Foley 2011-06-08 20:58:32 -0400 47) @:
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 48)
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 49) $(obj)/%.h:
d8ecc5cd8e227 (Sam Ravnborg 2011-04-27 22:29:49 +0200 50) $(call cmd,wrap)
cda2c65f981d0 (James Hogan 2016-06-24 23:42:24 +0100 51)
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 52) # Create output directory. Skip it if at least one old header exists
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 53) # since we know the output directory already exists.
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 54) ifeq ($(old-headers),)
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 55) $(shell mkdir -p $(obj))
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 56) endif
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 57)
cda2c65f981d0 (James Hogan 2016-06-24 23:42:24 +0100 58) .PHONY: $(PHONY)