Kbuild 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #
  2. # Kbuild for top-level directory of the kernel
  3. # This file takes care of the following:
  4. # 1) Generate bounds.h
  5. # 2) Generate asm-offsets.h (may need bounds.h)
  6. # 3) Check for missing system calls
  7. #####
  8. # 1) Generate bounds.h
  9. bounds-file := include/linux/bounds.h
  10. always := $(bounds-file)
  11. targets := $(bounds-file) kernel/bounds.s
  12. quiet_cmd_bounds = GEN $@
  13. define cmd_bounds
  14. (set -e; \
  15. echo "#ifndef __LINUX_BOUNDS_H__"; \
  16. echo "#define __LINUX_BOUNDS_H__"; \
  17. echo "/*"; \
  18. echo " * DO NOT MODIFY."; \
  19. echo " *"; \
  20. echo " * This file was generated by Kbuild"; \
  21. echo " *"; \
  22. echo " */"; \
  23. echo ""; \
  24. sed -ne $(sed-y) $<; \
  25. echo ""; \
  26. echo "#endif" ) > $@
  27. endef
  28. # We use internal kbuild rules to avoid the "is up to date" message from make
  29. kernel/bounds.s: kernel/bounds.c FORCE
  30. $(Q)mkdir -p $(dir $@)
  31. $(call if_changed_dep,cc_s_c)
  32. $(obj)/$(bounds-file): kernel/bounds.s Kbuild
  33. $(Q)mkdir -p $(dir $@)
  34. $(call cmd,bounds)
  35. #####
  36. # 2) Generate asm-offsets.h
  37. #
  38. offsets-file := include/asm-$(SRCARCH)/asm-offsets.h
  39. always += $(offsets-file)
  40. targets += $(offsets-file)
  41. targets += arch/$(SRCARCH)/kernel/asm-offsets.s
  42. # Default sed regexp - multiline due to syntax constraints
  43. define sed-y
  44. "/^->/{s:->#\(.*\):/* \1 */:; \
  45. s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
  46. s:->::; p;}"
  47. endef
  48. quiet_cmd_offsets = GEN $@
  49. define cmd_offsets
  50. (set -e; \
  51. echo "#ifndef __ASM_OFFSETS_H__"; \
  52. echo "#define __ASM_OFFSETS_H__"; \
  53. echo "/*"; \
  54. echo " * DO NOT MODIFY."; \
  55. echo " *"; \
  56. echo " * This file was generated by Kbuild"; \
  57. echo " *"; \
  58. echo " */"; \
  59. echo ""; \
  60. sed -ne $(sed-y) $<; \
  61. echo ""; \
  62. echo "#endif" ) > $@
  63. endef
  64. # We use internal kbuild rules to avoid the "is up to date" message from make
  65. arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
  66. $(obj)/$(bounds-file) FORCE
  67. $(Q)mkdir -p $(dir $@)
  68. $(call if_changed_dep,cc_s_c)
  69. $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
  70. $(Q)mkdir -p $(dir $@)
  71. $(call cmd,offsets)
  72. #####
  73. # 3) Check for missing system calls
  74. #
  75. quiet_cmd_syscalls = CALL $<
  76. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags)
  77. PHONY += missing-syscalls
  78. missing-syscalls: scripts/checksyscalls.sh FORCE
  79. $(call cmd,syscalls)
  80. # Delete all targets during make clean
  81. clean-files := $(addprefix $(objtree)/,$(filter-out $(bounds-file) $(offsets-file),$(targets)))