blob: 524eeedc8d25d2d5a2233329b8b73acb39fd72ac [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#
Cao jin64236e32017-08-22 21:09:53 +08005# This Makefile reads the file arch/$(SRCARCH)/include/$(src)/Kbuild
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +02006# and for each file listed in this file with generic-y creates
Cao jin64236e32017-08-22 21:09:53 +08007# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src))
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +02008
Catalin Marinas3c5994c2012-10-17 12:25:44 +01009kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild
Michal Marek7a04fc92011-05-02 18:01:06 +020010-include $(kbuild-file)
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +020011
12include scripts/Kbuild.include
13
14# Create output directory if not already present
15_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
16
James Hogancda2c652016-06-24 23:42:24 +010017# Stale wrappers when the corresponding files are removed from generic-y
18# need removing.
Masahiro Yamadaae3f4152017-06-09 17:29:52 +090019generated-y := $(generic-y) $(generated-y)
James Hogancda2c652016-06-24 23:42:24 +010020all-files := $(patsubst %, $(obj)/%, $(generated-y))
21old-headers := $(wildcard $(obj)/*.h)
22unwanted := $(filter-out $(all-files),$(old-headers))
23
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +020024quiet_cmd_wrap = WRAP $@
25cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
26
James Hogancda2c652016-06-24 23:42:24 +010027quiet_cmd_remove = REMOVE $(unwanted)
28cmd_remove = rm -f $(unwanted)
29
30all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE
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
37PHONY += FORCE
38.PHONY: $(PHONY)
39FORCE: ;