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 | |
Masahiro Yamada | a7d34df | 2017-10-11 12:52:29 +0900 | [diff] [blame] | 9 | PHONY := all |
| 10 | all: |
| 11 | |
Catalin Marinas | 3c5994c | 2012-10-17 12:25:44 +0100 | [diff] [blame] | 12 | kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild |
Michal Marek | 7a04fc9 | 2011-05-02 18:01:06 +0200 | [diff] [blame] | 13 | -include $(kbuild-file) |
Sam Ravnborg | d8ecc5c | 2011-04-27 22:29:49 +0200 | [diff] [blame] | 14 | |
| 15 | include scripts/Kbuild.include |
| 16 | |
| 17 | # Create output directory if not already present |
| 18 | _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) |
| 19 | |
James Hogan | cda2c65 | 2016-06-24 23:42:24 +0100 | [diff] [blame] | 20 | # Stale wrappers when the corresponding files are removed from generic-y |
| 21 | # need removing. |
Masahiro Yamada | ae3f415 | 2017-06-09 17:29:52 +0900 | [diff] [blame] | 22 | generated-y := $(generic-y) $(generated-y) |
James Hogan | cda2c65 | 2016-06-24 23:42:24 +0100 | [diff] [blame] | 23 | all-files := $(patsubst %, $(obj)/%, $(generated-y)) |
| 24 | old-headers := $(wildcard $(obj)/*.h) |
| 25 | unwanted := $(filter-out $(all-files),$(old-headers)) |
| 26 | |
Sam Ravnborg | d8ecc5c | 2011-04-27 22:29:49 +0200 | [diff] [blame] | 27 | quiet_cmd_wrap = WRAP $@ |
| 28 | cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ |
| 29 | |
James Hogan | cda2c65 | 2016-06-24 23:42:24 +0100 | [diff] [blame] | 30 | quiet_cmd_remove = REMOVE $(unwanted) |
| 31 | cmd_remove = rm -f $(unwanted) |
| 32 | |
| 33 | all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE |
| 34 | $(if $(unwanted),$(call cmd,remove),) |
Peter Foley | 181e976 | 2011-06-08 20:58:32 -0400 | [diff] [blame] | 35 | @: |
Sam Ravnborg | d8ecc5c | 2011-04-27 22:29:49 +0200 | [diff] [blame] | 36 | |
| 37 | $(obj)/%.h: |
| 38 | $(call cmd,wrap) |
James Hogan | cda2c65 | 2016-06-24 23:42:24 +0100 | [diff] [blame] | 39 | |
| 40 | PHONY += FORCE |
| 41 | .PHONY: $(PHONY) |
| 42 | FORCE: ; |