blob: 760323e70ebc7c56e543f80fe4ce8c70ddd8d453 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +02002# include/asm-generic contains a lot of files that are used
3# verbatim by several architectures.
4#
Masahiro Yamada7d0e5c22018-12-05 20:28:04 +09005# This Makefile reads the file arch/$(SRCARCH)/include/(uapi/)/asm/Kbuild
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +02006# and for each file listed in this file with generic-y creates
Masahiro Yamada7d0e5c22018-12-05 20:28:04 +09007# a small wrapper file in arch/$(SRCARCH)/include/generated/(uapi/)/asm.
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +02008
Masahiro Yamadaa7d34df2017-10-11 12:52:29 +09009PHONY := all
10all:
11
Masahiro Yamada7d0e5c22018-12-05 20:28:04 +090012src := $(subst /generated,,$(obj))
13-include $(src)/Kbuild
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +020014
15include scripts/Kbuild.include
16
Masahiro Yamada7d0e5c22018-12-05 20:28:04 +090017generic-y := $(addprefix $(obj)/, $(generic-y))
18generated-y := $(addprefix $(obj)/, $(generated-y))
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +020019
Masahiro Yamada7d0e5c22018-12-05 20:28:04 +090020# Remove stale wrappers when the corresponding files are removed from generic-y
21old-headers := $(wildcard $(obj)/*.h)
22unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers))
James Hogancda2c652016-06-24 23:42:24 +010023
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +020024quiet_cmd_wrap = WRAP $@
Masahiro Yamada7d0e5c22018-12-05 20:28:04 +090025 cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +020026
James Hogancda2c652016-06-24 23:42:24 +010027quiet_cmd_remove = REMOVE $(unwanted)
Masahiro Yamada7d0e5c22018-12-05 20:28:04 +090028 cmd_remove = rm -f $(unwanted)
James Hogancda2c652016-06-24 23:42:24 +010029
Masahiro Yamada7d0e5c22018-12-05 20:28:04 +090030all: $(generic-y)
31 $(if $(unwanted),$(call cmd,remove))
Peter Foley181e9762011-06-08 20:58:32 -040032 @:
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +020033
34$(obj)/%.h:
35 $(call cmd,wrap)
James Hogancda2c652016-06-24 23:42:24 +010036
Masahiro Yamada7d0e5c22018-12-05 20:28:04 +090037# Create output directory. Skip it if at least one old header exists
38# since we know the output directory already exists.
39ifeq ($(old-headers),)
40$(shell mkdir -p $(obj))
41endif
42
James Hogancda2c652016-06-24 23:42:24 +010043.PHONY: $(PHONY)