Kbuild 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 asm-offsets.h (may need bounds.h)
  6. # 3) Check for missing system calls
  7. # Default sed regexp - multiline due to syntax constraints
  8. define sed-y
  9. "/^->/{s:->#\(.*\):/* \1 */:; \
  10. s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
  11. s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
  12. s:->::; p;}"
  13. endef
  14. # Use filechk to avoid rebuilds when a header changes, but the resulting file
  15. # does not
  16. define filechk_offsets
  17. (set -e; \
  18. echo "#ifndef $2"; \
  19. echo "#define $2"; \
  20. echo "/*"; \
  21. echo " * DO NOT MODIFY."; \
  22. echo " *"; \
  23. echo " * This file was generated by Kbuild"; \
  24. echo " */"; \
  25. echo ""; \
  26. sed -ne $(sed-y); \
  27. echo ""; \
  28. echo "#endif" )
  29. endef
  30. #####
  31. # 1) Generate bounds.h
  32. bounds-file := include/generated/bounds.h
  33. always := $(bounds-file)
  34. targets := kernel/bounds.s
  35. # We use internal kbuild rules to avoid the "is up to date" message from make
  36. kernel/bounds.s: kernel/bounds.c FORCE
  37. $(Q)mkdir -p $(dir $@)
  38. $(call if_changed_dep,cc_s_c)
  39. $(obj)/$(bounds-file): kernel/bounds.s FORCE
  40. $(call filechk,offsets,__LINUX_BOUNDS_H__)
  41. #####
  42. # 2) Generate asm-offsets.h
  43. #
  44. offsets-file := include/generated/asm-offsets.h
  45. always += $(offsets-file)
  46. targets += arch/$(SRCARCH)/kernel/asm-offsets.s
  47. # We use internal kbuild rules to avoid the "is up to date" message from make
  48. arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
  49. $(obj)/$(bounds-file) FORCE
  50. $(Q)mkdir -p $(dir $@)
  51. $(call if_changed_dep,cc_s_c)
  52. $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
  53. $(call filechk,offsets,__ASM_OFFSETS_H__)
  54. #####
  55. # 3) Check for missing system calls
  56. #
  57. always += missing-syscalls
  58. targets += missing-syscalls
  59. quiet_cmd_syscalls = CALL $<
  60. cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
  61. missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
  62. $(call cmd,syscalls)
  63. # Keep these two files during make clean
  64. no-clean-files := $(bounds-file) $(offsets-file)