Kbuild 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 timeconst.h
  6. # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
  7. # 4) Check for missing system calls
  8. # Default sed regexp - multiline due to syntax constraints
  9. define sed-y
  10. "/^->/{s:->#\(.*\):/* \1 */:; \
  11. s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
  12. s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
  13. s:->::; p;}"
  14. endef
  15. # Use filechk to avoid rebuilds when a header changes, but the resulting file
  16. # does not
  17. define filechk_offsets
  18. (set -e; \
  19. echo "#ifndef $2"; \
  20. echo "#define $2"; \
  21. echo "/*"; \
  22. echo " * DO NOT MODIFY."; \
  23. echo " *"; \
  24. echo " * This file was generated by Kbuild"; \
  25. echo " */"; \
  26. echo ""; \
  27. sed -ne $(sed-y); \
  28. echo ""; \
  29. echo "#endif" )
  30. endef
  31. #####
  32. # 1) Generate bounds.h
  33. bounds-file := include/generated/bounds.h
  34. always := $(bounds-file)
  35. targets := kernel/bounds.s
  36. # We use internal kbuild rules to avoid the "is up to date" message from make
  37. kernel/bounds.s: kernel/bounds.c FORCE
  38. $(Q)mkdir -p $(dir $@)
  39. $(call if_changed_dep,cc_s_c)
  40. $(obj)/$(bounds-file): kernel/bounds.s FORCE
  41. $(call filechk,offsets,__LINUX_BOUNDS_H__)
  42. #####
  43. # 2) Generate timeconst.h
  44. timeconst-file := include/generated/timeconst.h
  45. targets += $(timeconst-file)
  46. quiet_cmd_gentimeconst = GEN $@
  47. define cmd_gentimeconst
  48. (echo $(CONFIG_HZ) | bc -q $< ) > $@
  49. endef
  50. define filechk_gentimeconst
  51. (echo $(CONFIG_HZ) | bc -q $< )
  52. endef
  53. $(obj)/$(timeconst-file): kernel/time/timeconst.bc FORCE
  54. $(call filechk,gentimeconst)
  55. #####
  56. # 3) Generate asm-offsets.h
  57. #
  58. offsets-file := include/generated/asm-offsets.h
  59. always += $(offsets-file)
  60. targets += arch/$(SRCARCH)/kernel/asm-offsets.s
  61. # We use internal kbuild rules to avoid the "is up to date" message from make
  62. arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
  63. $(obj)/$(timeconst-file) $(obj)/$(bounds-file) FORCE
  64. $(Q)mkdir -p $(dir $@)
  65. $(call if_changed_dep,cc_s_c)
  66. $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
  67. $(call filechk,offsets,__ASM_OFFSETS_H__)
  68. #####
  69. # 4) Check for missing system calls
  70. #
  71. always += missing-syscalls
  72. targets += missing-syscalls
  73. quiet_cmd_syscalls = CALL $<
  74. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
  75. missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
  76. $(call cmd,syscalls)
  77. # Keep these three files during make clean
  78. no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)