Kbuild 2.5 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
2 3 4
#
# Kbuild for top-level directory of the kernel
# This file takes care of the following:
5
# 1) Generate bounds.h
6 7 8
# 2) Generate timeconst.h
# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
# 4) Check for missing system calls
9 10
# 5) check atomics headers are up-to-date
# 6) Generate constants.py (may need bounds.h)
11

12 13 14 15 16 17
#####
# 1) Generate bounds.h

bounds-file := include/generated/bounds.h

always  := $(bounds-file)
18
targets := kernel/bounds.s
19

20 21 22 23
# We use internal kbuild rules to avoid the "is up to date" message from make
kernel/bounds.s: kernel/bounds.c FORCE
	$(call if_changed_dep,cc_s_c)

24 25
$(obj)/$(bounds-file): kernel/bounds.s FORCE
	$(call filechk,offsets,__LINUX_BOUNDS_H__)
26 27

#####
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
# 2) Generate timeconst.h

timeconst-file := include/generated/timeconst.h

targets += $(timeconst-file)

quiet_cmd_gentimeconst = GEN     $@
define cmd_gentimeconst
	(echo $(CONFIG_HZ) | bc -q $< ) > $@
endef
define filechk_gentimeconst
	(echo $(CONFIG_HZ) | bc -q $< )
endef

$(obj)/$(timeconst-file): kernel/time/timeconst.bc FORCE
	$(call filechk,gentimeconst)

#####
# 3) Generate asm-offsets.h
47 48
#

49
offsets-file := include/generated/asm-offsets.h
50

51
always  += $(offsets-file)
52
targets += arch/$(SRCARCH)/kernel/asm-offsets.s
53

54
# We use internal kbuild rules to avoid the "is up to date" message from make
55
arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
56
                                      $(obj)/$(timeconst-file) $(obj)/$(bounds-file) FORCE
57 58
	$(call if_changed_dep,cc_s_c)

59 60
$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
	$(call filechk,offsets,__ASM_OFFSETS_H__)
61

62
#####
63
# 4) Check for missing system calls
64 65
#

66 67 68
always += missing-syscalls
targets += missing-syscalls

69
quiet_cmd_syscalls = CALL    $<
70
      cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
71

72
missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
73
	$(call cmd,syscalls)
74

75
#####
76 77 78 79 80 81 82 83 84 85 86 87 88 89
# 5) Check atomic headers are up-to-date
#

always += old-atomics
targets += old-atomics

quiet_cmd_atomics = CALL    $<
      cmd_atomics = $(CONFIG_SHELL) scripts/atomic/check-atomics.sh

old-atomics: scripts/atomic/check-atomics.sh FORCE
	$(call cmd,atomics)

#####
# 6) Generate constants for Python GDB integration
90 91 92 93 94 95 96
#

extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py

build_constants_py: $(obj)/$(timeconst-file) $(obj)/$(bounds-file)
	@$(MAKE) $(build)=scripts/gdb/linux $@

97 98
# Keep these three files during make clean
no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)