Makefile.asm-generic 1.2 KB

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