Kbuild 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #
  2. # Kbuild for top-level directory of the kernel
  3. # This file takes care of the following:
  4. # 1) Generate asm-offsets.h
  5. #####
  6. # 1) Generate asm-offsets.h
  7. #
  8. offsets-file := include/asm-$(ARCH)/asm-offsets.h
  9. always := $(offsets-file)
  10. targets := $(offsets-file)
  11. targets += arch/$(ARCH)/kernel/asm-offsets.s
  12. # Default sed regexp - multiline due to syntax constraints
  13. define sed-y
  14. "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
  15. endef
  16. # Override default regexp for specific architectures
  17. sed-$(CONFIG_MIPS) := "/^@@@/s///p"
  18. quiet_cmd_offsets = GEN $@
  19. define cmd_offsets
  20. mkdir -p $(dir $@); \
  21. cat $< | \
  22. (set -e; \
  23. echo "#ifndef __ASM_OFFSETS_H__"; \
  24. echo "#define __ASM_OFFSETS_H__"; \
  25. echo "/*"; \
  26. echo " * DO NOT MODIFY."; \
  27. echo " *"; \
  28. echo " * This file was generated by $(srctree)/Kbuild"; \
  29. echo " *"; \
  30. echo " */"; \
  31. echo ""; \
  32. sed -ne $(sed-y); \
  33. echo ""; \
  34. echo "#endif" ) > $@
  35. endef
  36. # We use internal kbuild rules to avoid the "is up to date" message from make
  37. arch/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE
  38. $(Q)mkdir -p $(dir $@)
  39. $(call if_changed_dep,cc_s_c)
  40. $(obj)/$(offsets-file): arch/$(ARCH)/kernel/asm-offsets.s Kbuild
  41. $(call cmd,offsets)