Kbuild 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. $(call if_changed_dep,cc_s_c)
  18. $(obj)/$(bounds-file): kernel/bounds.s FORCE
  19. $(call filechk,offsets,__LINUX_BOUNDS_H__)
  20. #####
  21. # 2) Generate timeconst.h
  22. timeconst-file := include/generated/timeconst.h
  23. targets += $(timeconst-file)
  24. quiet_cmd_gentimeconst = GEN $@
  25. define cmd_gentimeconst
  26. (echo $(CONFIG_HZ) | bc -q $< ) > $@
  27. endef
  28. define filechk_gentimeconst
  29. (echo $(CONFIG_HZ) | bc -q $< )
  30. endef
  31. $(obj)/$(timeconst-file): kernel/time/timeconst.bc FORCE
  32. $(call filechk,gentimeconst)
  33. #####
  34. # 3) Generate asm-offsets.h
  35. #
  36. offsets-file := include/generated/asm-offsets.h
  37. always += $(offsets-file)
  38. targets += arch/$(SRCARCH)/kernel/asm-offsets.s
  39. # We use internal kbuild rules to avoid the "is up to date" message from make
  40. arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
  41. $(obj)/$(timeconst-file) $(obj)/$(bounds-file) FORCE
  42. $(call if_changed_dep,cc_s_c)
  43. $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
  44. $(call filechk,offsets,__ASM_OFFSETS_H__)
  45. #####
  46. # 4) Check for missing system calls
  47. #
  48. always += missing-syscalls
  49. targets += missing-syscalls
  50. quiet_cmd_syscalls = CALL $<
  51. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
  52. missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
  53. $(call cmd,syscalls)
  54. #####
  55. # 5) Generate constants for Python GDB integration
  56. #
  57. extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
  58. build_constants_py: $(obj)/$(timeconst-file) $(obj)/$(bounds-file)
  59. @$(MAKE) $(build)=scripts/gdb/linux $@
  60. # Keep these three files during make clean
  61. no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)