Kbuild 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/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. $(call cmd,offsets)
  71. #####
  72. # 3) Check for missing system calls
  73. #
  74. quiet_cmd_syscalls = CALL $<
  75. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags)
  76. PHONY += missing-syscalls
  77. missing-syscalls: scripts/checksyscalls.sh FORCE
  78. $(call cmd,syscalls)
  79. # Delete all targets during make clean
  80. clean-files := $(addprefix $(objtree)/,$(filter-out $(bounds-file) $(offsets-file),$(targets)))