Kbuild 1.7 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
# 5) Generate constants.py (may need bounds.h)
10

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

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

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

19
$(bounds-file): kernel/bounds.s FORCE
20
	$(call filechk,offsets,__LINUX_BOUNDS_H__)
21 22

#####
23 24 25 26 27 28
# 2) Generate timeconst.h

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

targets += $(timeconst-file)

29
filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $<
30

31
$(timeconst-file): kernel/time/timeconst.bc FORCE
32 33 34 35
	$(call filechk,gentimeconst)

#####
# 3) Generate asm-offsets.h
36 37
#

38
offsets-file := include/generated/asm-offsets.h
39

40
always  += $(offsets-file)
41
targets += arch/$(SRCARCH)/kernel/asm-offsets.s
42

43
arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file)
44

45
$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
46
	$(call filechk,offsets,__ASM_OFFSETS_H__)
47

48
#####
49
# 4) Check for missing system calls
50 51
#

52 53 54
always += missing-syscalls
targets += missing-syscalls

55
quiet_cmd_syscalls = CALL    $<
56
      cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
57

58
missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
59
	$(call cmd,syscalls)
60

61 62 63 64 65 66
#####
# 5) Generate constants for Python GDB integration
#

extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py

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

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