Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame^] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Sam Ravnborg | d8ecc5c | 2011-04-27 22:29:49 +0200 | [diff] [blame] | 2 | # include/asm-generic contains a lot of files that are used |
| 3 | # verbatim by several architectures. |
| 4 | # |
Cao jin | 64236e3 | 2017-08-22 21:09:53 +0800 | [diff] [blame] | 5 | # This Makefile reads the file arch/$(SRCARCH)/include/$(src)/Kbuild |
Sam Ravnborg | d8ecc5c | 2011-04-27 22:29:49 +0200 | [diff] [blame] | 6 | # and for each file listed in this file with generic-y creates |
Cao jin | 64236e3 | 2017-08-22 21:09:53 +0800 | [diff] [blame] | 7 | # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src)) |
Sam Ravnborg | d8ecc5c | 2011-04-27 22:29:49 +0200 | [diff] [blame] | 8 | |
Catalin Marinas | 3c5994c | 2012-10-17 12:25:44 +0100 | [diff] [blame] | 9 | kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild |
Michal Marek | 7a04fc9 | 2011-05-02 18:01:06 +0200 | [diff] [blame] | 10 | -include $(kbuild-file) |
Sam Ravnborg | d8ecc5c | 2011-04-27 22:29:49 +0200 | [diff] [blame] | 11 | |
| 12 | include scripts/Kbuild.include |
| 13 | |
| 14 | # Create output directory if not already present |
| 15 | _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) |
| 16 | |
James Hogan | cda2c65 | 2016-06-24 23:42:24 +0100 | [diff] [blame] | 17 | # Stale wrappers when the corresponding files are removed from generic-y |
| 18 | # need removing. |
Masahiro Yamada | ae3f415 | 2017-06-09 17:29:52 +0900 | [diff] [blame] | 19 | generated-y := $(generic-y) $(generated-y) |
James Hogan | cda2c65 | 2016-06-24 23:42:24 +0100 | [diff] [blame] | 20 | all-files := $(patsubst %, $(obj)/%, $(generated-y)) |
| 21 | old-headers := $(wildcard $(obj)/*.h) |
| 22 | unwanted := $(filter-out $(all-files),$(old-headers)) |
| 23 | |
Sam Ravnborg | d8ecc5c | 2011-04-27 22:29:49 +0200 | [diff] [blame] | 24 | quiet_cmd_wrap = WRAP $@ |
| 25 | cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ |
| 26 | |
James Hogan | cda2c65 | 2016-06-24 23:42:24 +0100 | [diff] [blame] | 27 | quiet_cmd_remove = REMOVE $(unwanted) |
| 28 | cmd_remove = rm -f $(unwanted) |
| 29 | |
| 30 | all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE |
| 31 | $(if $(unwanted),$(call cmd,remove),) |
Peter Foley | 181e976 | 2011-06-08 20:58:32 -0400 | [diff] [blame] | 32 | @: |
Sam Ravnborg | d8ecc5c | 2011-04-27 22:29:49 +0200 | [diff] [blame] | 33 | |
| 34 | $(obj)/%.h: |
| 35 | $(call cmd,wrap) |
James Hogan | cda2c65 | 2016-06-24 23:42:24 +0100 | [diff] [blame] | 36 | |
| 37 | PHONY += FORCE |
| 38 | .PHONY: $(PHONY) |
| 39 | FORCE: ; |