Makefile.asm-generic 1.17 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
2 3 4
# include/asm-generic contains a lot of files that are used
# verbatim by several architectures.
#
5
# This Makefile reads the file arch/$(SRCARCH)/include/$(src)/Kbuild
6
# and for each file listed in this file with generic-y creates
7
# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src))
8

9 10 11
PHONY := all
all:

12
kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild
13
-include $(kbuild-file)
14 15 16 17 18 19

include scripts/Kbuild.include

# Create output directory if not already present
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))

20 21
# Stale wrappers when the corresponding files are removed from generic-y
# need removing.
22
generated-y   := $(generic-y) $(generated-y)
23 24 25 26
all-files     := $(patsubst %, $(obj)/%, $(generated-y))
old-headers   := $(wildcard $(obj)/*.h)
unwanted      := $(filter-out $(all-files),$(old-headers))

27 28 29
quiet_cmd_wrap = WRAP    $@
cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@

30 31 32 33 34
quiet_cmd_remove = REMOVE  $(unwanted)
cmd_remove = rm -f $(unwanted)

all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE
	$(if $(unwanted),$(call cmd,remove),)
35
	@:
36 37 38

$(obj)/%.h:
	$(call cmd,wrap)
39 40 41 42

PHONY += FORCE
.PHONY: $(PHONY)
FORCE: ;