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. #always += $(timeconst-file)
  46. targets += $(timeconst-file)
  47. quiet_cmd_gentimeconst = GEN $@
  48. define cmd_gentimeconst
  49. (echo $(CONFIG_HZ) | bc -q $< ) > $@
  50. endef
  51. define filechk_gentimeconst
  52. (echo $(CONFIG_HZ) | bc -q $< )
  53. endef
  54. $(obj)/$(timeconst-file): kernel/time/timeconst.bc FORCE
  55. $(call filechk,gentimeconst)
  56. #####
  57. # 3) Generate asm-offsets.h
  58. #
  59. offsets-file := include/generated/asm-offsets.h
  60. always += $(offsets-file)
  61. targets += arch/$(SRCARCH)/kernel/asm-offsets.s
  62. # We use internal kbuild rules to avoid the "is up to date" message from make
  63. arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
  64. $(obj)/$(timeconst-file) $(obj)/$(bounds-file) FORCE
  65. $(Q)mkdir -p $(dir $@)
  66. $(call if_changed_dep,cc_s_c)
  67. $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
  68. $(call filechk,offsets,__ASM_OFFSETS_H__)
  69. #####
  70. # 4) Check for missing system calls
  71. #
  72. always += missing-syscalls
  73. targets += missing-syscalls
  74. quiet_cmd_syscalls = CALL $<
  75. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
  76. missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
  77. $(call cmd,syscalls)
  78. # Keep these three files during make clean
  79. no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)