1# SPDX-License-Identifier: GPL-2.0 2# include/asm-generic contains a lot of files that are used 3# verbatim by several architectures. 4# 5# This Makefile reads the file arch/$(SRCARCH)/include/(uapi/)/asm/Kbuild 6# and for each file listed in this file with generic-y creates 7# a small wrapper file in arch/$(SRCARCH)/include/generated/(uapi/)/asm. 8 9PHONY := all 10all: 11 12src := $(subst /generated,,$(obj)) 13-include $(src)/Kbuild 14 15include scripts/Kbuild.include 16 17generic-y := $(addprefix $(obj)/, $(generic-y)) 18generated-y := $(addprefix $(obj)/, $(generated-y)) 19 20# Remove stale wrappers when the corresponding files are removed from generic-y 21old-headers := $(wildcard $(obj)/*.h) 22unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers)) 23 24quiet_cmd_wrap = WRAP $@ 25 cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@ 26 27quiet_cmd_remove = REMOVE $(unwanted) 28 cmd_remove = rm -f $(unwanted) 29 30all: $(generic-y) 31 $(if $(unwanted),$(call cmd,remove)) 32 @: 33 34$(obj)/%.h: 35 $(call cmd,wrap) 36 37# Create output directory. Skip it if at least one old header exists 38# since we know the output directory already exists. 39ifeq ($(old-headers),) 40$(shell mkdir -p $(obj)) 41endif 42 43.PHONY: $(PHONY) 44