GoogleGit

blob: b8b708ad6dc3815eb0d23bfea2c972d03b9477c0 [file] [log] [blame]
  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/generated/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/generated/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:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
  46. s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
  47. s:->::; p;}"
  48. endef
  49. quiet_cmd_offsets = GEN $@
  50. define cmd_offsets
  51. (set -e; \
  52. echo "#ifndef __ASM_OFFSETS_H__"; \
  53. echo "#define __ASM_OFFSETS_H__"; \
  54. echo "/*"; \
  55. echo " * DO NOT MODIFY."; \
  56. echo " *"; \
  57. echo " * This file was generated by Kbuild"; \
  58. echo " *"; \
  59. echo " */"; \
  60. echo ""; \
  61. sed -ne $(sed-y) $<; \
  62. echo ""; \
  63. echo "#endif" ) > $@
  64. endef
  65. # We use internal kbuild rules to avoid the "is up to date" message from make
  66. arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
  67. $(obj)/$(bounds-file) FORCE
  68. $(Q)mkdir -p $(dir $@)
  69. $(call if_changed_dep,cc_s_c)
  70. $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
  71. $(call cmd,offsets)
  72. #####
  73. # 3) Check for missing system calls
  74. #
  75. always += missing-syscalls
  76. targets += missing-syscalls
  77. quiet_cmd_syscalls = CALL $<
  78. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
  79. missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
  80. $(call cmd,syscalls)
  81. # Keep these two files during make clean
  82. no-clean-files := $(bounds-file) $(offsets-file)