Makefile.asm-generic 1.1 KB

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