Kbuild 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. # 5) Generate constants.py (may need bounds.h)
  9. #####
  10. # 1) Generate bounds.h
  11. bounds-file := include/generated/bounds.h
  12. always := $(bounds-file)
  13. targets := kernel/bounds.s
  14. # We use internal kbuild rules to avoid the "is up to date" message from make
  15. kernel/bounds.s: kernel/bounds.c FORCE
  16. $(Q)mkdir -p $(dir $@)
  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. $(Q)mkdir -p $(dir $@)
  43. $(call if_changed_dep,cc_s_c)
  44. $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
  45. $(call filechk,offsets,__ASM_OFFSETS_H__)
  46. #####
  47. # 4) Check for missing system calls
  48. #
  49. always += missing-syscalls
  50. targets += missing-syscalls
  51. quiet_cmd_syscalls = CALL $<
  52. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
  53. missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
  54. $(call cmd,syscalls)
  55. #####
  56. # 5) Generate constants for Python GDB integration
  57. #
  58. extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
  59. build_constants_py: $(obj)/$(timeconst-file) $(obj)/$(bounds-file)
  60. @$(MAKE) $(build)=scripts/gdb/linux $@
  61. # Keep these three files during make clean
  62. no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)