Kbuild 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. # SPDX-License-Identifier: GPL-2.0
  2. #
  3. # Kbuild for top-level directory of the kernel
  4. # Prepare global headers and check sanity before descending into sub-directories
  5. # ---------------------------------------------------------------------------
  6. # Generate bounds.h
  7. bounds-file := include/generated/bounds.h
  8. targets := kernel/bounds.s
  9. $(bounds-file): kernel/bounds.s FORCE
  10. $(call filechk,offsets,__LINUX_BOUNDS_H__)
  11. # Generate timeconst.h
  12. timeconst-file := include/generated/timeconst.h
  13. filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $<
  14. $(timeconst-file): kernel/time/timeconst.bc FORCE
  15. $(call filechk,gentimeconst)
  16. # Generate asm-offsets.h
  17. offsets-file := include/generated/asm-offsets.h
  18. targets += arch/$(SRCARCH)/kernel/asm-offsets.s
  19. arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file)
  20. $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
  21. $(call filechk,offsets,__ASM_OFFSETS_H__)
  22. # Generate rq-offsets.h
  23. rq-offsets-file := include/generated/rq-offsets.h
  24. targets += kernel/sched/rq-offsets.s
  25. kernel/sched/rq-offsets.s: $(offsets-file)
  26. $(rq-offsets-file): kernel/sched/rq-offsets.s FORCE
  27. $(call filechk,offsets,__RQ_OFFSETS_H__)
  28. # Check for missing system calls
  29. quiet_cmd_syscalls = CALL $<
  30. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
  31. PHONY += missing-syscalls
  32. missing-syscalls: scripts/checksyscalls.sh $(rq-offsets-file)
  33. $(call cmd,syscalls)
  34. # Check the manual modification of atomic headers
  35. quiet_cmd_check_sha1 = CHKSHA1 $<
  36. cmd_check_sha1 = \
  37. if ! command -v sha1sum >/dev/null; then \
  38. echo "warning: cannot check the header due to sha1sum missing"; \
  39. exit 0; \
  40. fi; \
  41. if [ "$$(sed -n '$$s:// ::p' $<)" != \
  42. "$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \
  43. echo "error: $< has been modified." >&2; \
  44. exit 1; \
  45. fi; \
  46. touch $@
  47. atomic-checks += $(addprefix $(obj)/.checked-, \
  48. atomic-arch-fallback.h \
  49. atomic-instrumented.h \
  50. atomic-long.h)
  51. targets += $(atomic-checks)
  52. $(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE
  53. $(call if_changed,check_sha1)
  54. # A phony target that depends on all the preparation targets
  55. PHONY += prepare
  56. prepare: $(offsets-file) missing-syscalls $(atomic-checks)
  57. @:
  58. # Ordinary directory descending
  59. # ---------------------------------------------------------------------------
  60. obj-y += init/
  61. obj-y += usr/
  62. obj-y += arch/$(SRCARCH)/
  63. obj-y += $(ARCH_CORE)
  64. obj-y += kernel/
  65. obj-y += certs/
  66. obj-y += mm/
  67. obj-y += fs/
  68. obj-y += ipc/
  69. obj-y += security/
  70. obj-y += crypto/
  71. obj-$(CONFIG_BLOCK) += block/
  72. obj-$(CONFIG_IO_URING) += io_uring/
  73. obj-$(CONFIG_RUST) += rust/
  74. obj-y += $(ARCH_LIB)
  75. obj-y += drivers/
  76. obj-y += sound/
  77. obj-$(CONFIG_SAMPLES) += samples/
  78. obj-$(CONFIG_NET) += net/
  79. obj-y += virt/
  80. obj-y += $(ARCH_DRIVERS)
  81. obj-$(CONFIG_DRM_HEADER_TEST) += include/