Kbuild 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. # Check for missing system calls
  23. quiet_cmd_syscalls = CALL $<
  24. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
  25. PHONY += missing-syscalls
  26. missing-syscalls: scripts/checksyscalls.sh $(offsets-file)
  27. $(call cmd,syscalls)
  28. # Check the manual modification of atomic headers
  29. quiet_cmd_check_sha1 = CHKSHA1 $<
  30. cmd_check_sha1 = \
  31. if ! command -v sha1sum >/dev/null; then \
  32. echo "warning: cannot check the header due to sha1sum missing"; \
  33. exit 0; \
  34. fi; \
  35. if [ "$$(sed -n '$$s:// ::p' $<)" != \
  36. "$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \
  37. echo "error: $< has been modified." >&2; \
  38. exit 1; \
  39. fi; \
  40. touch $@
  41. atomic-checks += $(addprefix $(obj)/.checked-, \
  42. atomic-arch-fallback.h \
  43. atomic-instrumented.h \
  44. atomic-long.h)
  45. targets += $(atomic-checks)
  46. $(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE
  47. $(call if_changed,check_sha1)
  48. # A phony target that depends on all the preparation targets
  49. PHONY += prepare
  50. prepare: $(offsets-file) missing-syscalls $(atomic-checks)
  51. @:
  52. # Ordinary directory descending
  53. # ---------------------------------------------------------------------------
  54. obj-y += init/
  55. obj-y += usr/
  56. obj-y += arch/$(SRCARCH)/
  57. obj-y += $(ARCH_CORE)
  58. obj-y += kernel/
  59. obj-y += certs/
  60. obj-y += mm/
  61. obj-y += fs/
  62. obj-y += ipc/
  63. obj-y += security/
  64. obj-y += crypto/
  65. obj-$(CONFIG_BLOCK) += block/
  66. obj-$(CONFIG_IO_URING) += io_uring/
  67. obj-$(CONFIG_RUST) += rust/
  68. obj-y += $(ARCH_LIB)
  69. obj-y += drivers/
  70. obj-y += sound/
  71. obj-$(CONFIG_SAMPLES) += samples/
  72. obj-$(CONFIG_NET) += net/
  73. obj-y += virt/
  74. obj-y += $(ARCH_DRIVERS)