Kbuild 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # SPDX-License-Identifier: GPL-2.0
  2. #
  3. # Kbuild for top-level directory of the kernel
  4. # This file takes care of the following:
  5. # 1) Generate bounds.h
  6. # 2) Generate timeconst.h
  7. # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
  8. # 4) Check for missing system calls
  9. # 5) Generate constants.py (may need bounds.h)
  10. #####
  11. # 1) Generate bounds.h
  12. bounds-file := include/generated/bounds.h
  13. always := $(bounds-file)
  14. targets := kernel/bounds.s
  15. # We use internal kbuild rules to avoid the "is up to date" message from make
  16. kernel/bounds.s: kernel/bounds.c FORCE
  17. $(Q)mkdir -p $(dir $@)
  18. $(call if_changed_dep,cc_s_c)
  19. $(obj)/$(bounds-file): kernel/bounds.s FORCE
  20. $(call filechk,offsets,__LINUX_BOUNDS_H__)
  21. #####
  22. # 2) Generate timeconst.h
  23. timeconst-file := include/generated/timeconst.h
  24. targets += $(timeconst-file)
  25. quiet_cmd_gentimeconst = GEN $@
  26. define cmd_gentimeconst
  27. (echo $(CONFIG_HZ) | bc -q $< ) > $@
  28. endef
  29. define filechk_gentimeconst
  30. (echo $(CONFIG_HZ) | bc -q $< )
  31. endef
  32. $(obj)/$(timeconst-file): kernel/time/timeconst.bc FORCE
  33. $(call filechk,gentimeconst)
  34. #####
  35. # 3) Generate asm-offsets.h
  36. #
  37. offsets-file := include/generated/asm-offsets.h
  38. always += $(offsets-file)
  39. targets += arch/$(SRCARCH)/kernel/asm-offsets.s
  40. # We use internal kbuild rules to avoid the "is up to date" message from make
  41. arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
  42. $(obj)/$(timeconst-file) $(obj)/$(bounds-file) FORCE
  43. $(Q)mkdir -p $(dir $@)
  44. $(call if_changed_dep,cc_s_c)
  45. $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
  46. $(call filechk,offsets,__ASM_OFFSETS_H__)
  47. #####
  48. # 4) Check for missing system calls
  49. #
  50. always += missing-syscalls
  51. targets += missing-syscalls
  52. quiet_cmd_syscalls = CALL $<
  53. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
  54. missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
  55. $(call cmd,syscalls)
  56. #####
  57. # 5) Generate constants for Python GDB integration
  58. #
  59. extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
  60. build_constants_py: $(obj)/$(timeconst-file) $(obj)/$(bounds-file)
  61. @$(MAKE) $(build)=scripts/gdb/linux $@
  62. # Keep these three files during make clean
  63. no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)