blob: 32ad8e93fbe15c44216ea76c63fcbf87f687445e [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
Masahiro Yamadaa7d34df2017-10-11 12:52:29 +09009PHONY := all
10all:
11
Catalin Marinas3c5994c2012-10-17 12:25:44 +010012kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild
Michal Marek7a04fc92011-05-02 18:01:06 +020013-include $(kbuild-file)
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +020014
15include scripts/Kbuild.include
16
17# Create output directory if not already present
18_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
19
James Hogancda2c652016-06-24 23:42:24 +010020# Stale wrappers when the corresponding files are removed from generic-y
21# need removing.
Masahiro Yamadaae3f4152017-06-09 17:29:52 +090022generated-y := $(generic-y) $(generated-y)
James Hogancda2c652016-06-24 23:42:24 +010023all-files := $(patsubst %, $(obj)/%, $(generated-y))
24old-headers := $(wildcard $(obj)/*.h)
25unwanted := $(filter-out $(all-files),$(old-headers))
26
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +020027quiet_cmd_wrap = WRAP $@
28cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
29
James Hogancda2c652016-06-24 23:42:24 +010030quiet_cmd_remove = REMOVE $(unwanted)
31cmd_remove = rm -f $(unwanted)
32
33all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE
34 $(if $(unwanted),$(call cmd,remove),)
Peter Foley181e9762011-06-08 20:58:32 -040035 @:
Sam Ravnborgd8ecc5c2011-04-27 22:29:49 +020036
37$(obj)/%.h:
38 $(call cmd,wrap)
James Hogancda2c652016-06-24 23:42:24 +010039
40PHONY += FORCE
41.PHONY: $(PHONY)
42FORCE: ;