blob: 4a4c47c38d1d8a725988bda065dd3dc6a6a9b035 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Sam Ravnborg86feeaa2005-09-09 19:28:28 +02002#
3# Kbuild for top-level directory of the kernel
4# This file takes care of the following:
Christoph Lameter1cdf25d2008-04-28 02:12:44 -07005# 1) Generate bounds.h
Nicholas Mc Guire0a227982015-05-18 14:19:12 +02006# 2) Generate timeconst.h
7# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
8# 4) Check for missing system calls
Mark Rutland8d325882018-09-04 11:48:29 +01009# 5) check atomics headers are up-to-date
10# 6) Generate constants.py (may need bounds.h)
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020011
Masahiro Yamada39664e22015-01-05 15:57:15 +090012#####
13# 1) Generate bounds.h
14
15bounds-file := include/generated/bounds.h
16
17always := $(bounds-file)
Masahiro Yamada8a58e162015-03-26 20:59:52 +090018targets := kernel/bounds.s
Masahiro Yamada39664e22015-01-05 15:57:15 +090019
Masahiro Yamada11fda142018-12-22 18:50:35 +090020$(bounds-file): kernel/bounds.s FORCE
Michal Marek70a4fd62015-03-11 11:01:01 +010021 $(call filechk,offsets,__LINUX_BOUNDS_H__)
Masahiro Yamada39664e22015-01-05 15:57:15 +090022
23#####
Nicholas Mc Guire0a227982015-05-18 14:19:12 +020024# 2) Generate timeconst.h
25
26timeconst-file := include/generated/timeconst.h
27
Nicholas Mc Guire0a227982015-05-18 14:19:12 +020028targets += $(timeconst-file)
29
Masahiro Yamadaba97df42019-01-03 10:16:54 +090030filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $<
Nicholas Mc Guire0a227982015-05-18 14:19:12 +020031
Masahiro Yamada11fda142018-12-22 18:50:35 +090032$(timeconst-file): kernel/time/timeconst.bc FORCE
Nicholas Mc Guire0a227982015-05-18 14:19:12 +020033 $(call filechk,gentimeconst)
34
35#####
36# 3) Generate asm-offsets.h
Masahiro Yamada39664e22015-01-05 15:57:15 +090037#
38
39offsets-file := include/generated/asm-offsets.h
40
41always += $(offsets-file)
Masahiro Yamada39664e22015-01-05 15:57:15 +090042targets += arch/$(SRCARCH)/kernel/asm-offsets.s
43
Masahiro Yamada11fda142018-12-22 18:50:35 +090044arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file)
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020045
Masahiro Yamada11fda142018-12-22 18:50:35 +090046$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
Michal Marek70a4fd62015-03-11 11:01:01 +010047 $(call filechk,offsets,__ASM_OFFSETS_H__)
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020048
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020049#####
Nicholas Mc Guire0a227982015-05-18 14:19:12 +020050# 4) Check for missing system calls
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020051#
52
Arnaud Lacombe5f7efb42011-08-24 21:03:30 -040053always += missing-syscalls
54targets += missing-syscalls
55
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020056quiet_cmd_syscalls = CALL $<
David Daney44656fa2011-11-08 10:20:10 -080057 cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020058
Arnaud Lacombe5f7efb42011-08-24 21:03:30 -040059missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020060 $(call cmd,syscalls)
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070061
Kieran Binghamf197d752016-05-23 16:24:40 -070062#####
Mark Rutland8d325882018-09-04 11:48:29 +010063# 5) Check atomic headers are up-to-date
64#
65
66always += old-atomics
67targets += old-atomics
68
69quiet_cmd_atomics = CALL $<
Borislav Petkovbdf37b42018-11-08 20:41:28 +010070 cmd_atomics = $(CONFIG_SHELL) $<
Mark Rutland8d325882018-09-04 11:48:29 +010071
72old-atomics: scripts/atomic/check-atomics.sh FORCE
73 $(call cmd,atomics)
74
75#####
76# 6) Generate constants for Python GDB integration
Kieran Binghamf197d752016-05-23 16:24:40 -070077#
78
79extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
80
Masahiro Yamada11fda142018-12-22 18:50:35 +090081build_constants_py: $(timeconst-file) $(bounds-file)
Kieran Binghamf197d752016-05-23 16:24:40 -070082 @$(MAKE) $(build)=scripts/gdb/linux $@
83
Nicholas Mc Guire0a227982015-05-18 14:19:12 +020084# Keep these three files during make clean
85no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)