Kbuild 2.24 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 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
	$(Q)mkdir -p $(dir $@)
	$(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 59
	$(Q)mkdir -p $(dir $@)
	$(call if_changed_dep,cc_s_c)

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

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

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

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

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

76 77 78 79 80 81 82 83 84
#####
# 5) Generate constants for Python GDB integration
#

extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py

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

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