Kbuild 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. # Default sed regexp - multiline due to syntax constraints
  8. define sed-y
  9. "/^->/{s:->#\(.*\):/* \1 */:; \
  10. s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
  11. s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
  12. s:->::; p;}"
  13. endef
  14. quiet_cmd_offsets = GEN $@
  15. define cmd_offsets
  16. (set -e; \
  17. echo "#ifndef $2"; \
  18. echo "#define $2"; \
  19. echo "/*"; \
  20. echo " * DO NOT MODIFY."; \
  21. echo " *"; \
  22. echo " * This file was generated by Kbuild"; \
  23. echo " */"; \
  24. echo ""; \
  25. sed -ne $(sed-y) $<; \
  26. echo ""; \
  27. echo "#endif" ) > $@
  28. endef
  29. #####
  30. # 1) Generate bounds.h
  31. bounds-file := include/generated/bounds.h
  32. always := $(bounds-file)
  33. targets := $(bounds-file) kernel/bounds.s
  34. # We use internal kbuild rules to avoid the "is up to date" message from make
  35. kernel/bounds.s: kernel/bounds.c FORCE
  36. $(Q)mkdir -p $(dir $@)
  37. $(call if_changed_dep,cc_s_c)
  38. $(obj)/$(bounds-file): kernel/bounds.s Kbuild
  39. $(Q)mkdir -p $(dir $@)
  40. $(call cmd,offsets,__LINUX_BOUNDS_H__)
  41. #####
  42. # 2) Generate asm-offsets.h
  43. #
  44. offsets-file := include/generated/asm-offsets.h
  45. always += $(offsets-file)
  46. targets += $(offsets-file)
  47. targets += arch/$(SRCARCH)/kernel/asm-offsets.s
  48. # We use internal kbuild rules to avoid the "is up to date" message from make
  49. arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
  50. $(obj)/$(bounds-file) FORCE
  51. $(Q)mkdir -p $(dir $@)
  52. $(call if_changed_dep,cc_s_c)
  53. $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
  54. $(call cmd,offsets,__ASM_OFFSETS_H__)
  55. #####
  56. # 3) Check for missing system calls
  57. #
  58. always += missing-syscalls
  59. targets += missing-syscalls
  60. quiet_cmd_syscalls = CALL $<
  61. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
  62. missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
  63. $(call cmd,syscalls)
  64. # Keep these two files during make clean
  65. no-clean-files := $(bounds-file) $(offsets-file)