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/$(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 9kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild 10-include $(kbuild-file) 11 12include scripts/Kbuild.include 13 14# Create output directory if not already present 15_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) 16 17# Stale wrappers when the corresponding files are removed from generic-y 18# need removing. 19generated-y := $(generic-y) $(generated-y) 20all-files := $(patsubst %, $(obj)/%, $(generated-y)) 21old-headers := $(wildcard $(obj)/*.h) 22unwanted := $(filter-out $(all-files),$(old-headers)) 23 24quiet_cmd_wrap = WRAP $@ 25cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ 26 27quiet_cmd_remove = REMOVE $(unwanted) 28cmd_remove = rm -f $(unwanted) 29 30all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE 31 $(if $(unwanted),$(call cmd,remove),) 32 @: 33 34$(obj)/%.h: 35 $(call cmd,wrap) 36 37PHONY += FORCE 38.PHONY: $(PHONY) 39FORCE: ; 40