Commit | Line | Data |
---|---|---|
86feeaa8 SR |
1 | # |
2 | # Kbuild for top-level directory of the kernel | |
3 | # This file takes care of the following: | |
1cdf25d7 | 4 | # 1) Generate bounds.h |
0a227985 NMG |
5 | # 2) Generate timeconst.h |
6 | # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h) | |
7 | # 4) Check for missing system calls | |
f197d75f | 8 | # 5) Generate constants.py (may need bounds.h) |
86feeaa8 | 9 | |
70a4fd6c MM |
10 | # Use filechk to avoid rebuilds when a header changes, but the resulting file |
11 | # does not | |
12 | define filechk_offsets | |
1cdf25d7 | 13 | (set -e; \ |
39664e2f MY |
14 | echo "#ifndef $2"; \ |
15 | echo "#define $2"; \ | |
1cdf25d7 CL |
16 | echo "/*"; \ |
17 | echo " * DO NOT MODIFY."; \ | |
18 | echo " *"; \ | |
19 | echo " * This file was generated by Kbuild"; \ | |
1cdf25d7 | 20 | echo " */"; \ |
26a83b37 | 21 | sed -ne '/#define/{s/\$$//;s/#//2;s/$$/*\//;p;}'; \ |
70a4fd6c | 22 | echo "#endif" ) |
1cdf25d7 CL |
23 | endef |
24 | ||
39664e2f MY |
25 | ##### |
26 | # 1) Generate bounds.h | |
27 | ||
28 | bounds-file := include/generated/bounds.h | |
29 | ||
30 | always := $(bounds-file) | |
8a58e162 | 31 | targets := kernel/bounds.s |
39664e2f | 32 | |
1cdf25d7 CL |
33 | # We use internal kbuild rules to avoid the "is up to date" message from make |
34 | kernel/bounds.s: kernel/bounds.c FORCE | |
35 | $(Q)mkdir -p $(dir $@) | |
36 | $(call if_changed_dep,cc_s_c) | |
37 | ||
70a4fd6c MM |
38 | $(obj)/$(bounds-file): kernel/bounds.s FORCE |
39 | $(call filechk,offsets,__LINUX_BOUNDS_H__) | |
1cdf25d7 CL |
40 | |
41 | ##### | |
0a227985 NMG |
42 | # 2) Generate timeconst.h |
43 | ||
44 | timeconst-file := include/generated/timeconst.h | |
45 | ||
0a227985 NMG |
46 | targets += $(timeconst-file) |
47 | ||
48 | quiet_cmd_gentimeconst = GEN $@ | |
49 | define cmd_gentimeconst | |
50 | (echo $(CONFIG_HZ) | bc -q $< ) > $@ | |
51 | endef | |
52 | define filechk_gentimeconst | |
53 | (echo $(CONFIG_HZ) | bc -q $< ) | |
54 | endef | |
55 | ||
56 | $(obj)/$(timeconst-file): kernel/time/timeconst.bc FORCE | |
57 | $(call filechk,gentimeconst) | |
58 | ||
59 | ##### | |
60 | # 3) Generate asm-offsets.h | |
86feeaa8 SR |
61 | # |
62 | ||
559df2e0 | 63 | offsets-file := include/generated/asm-offsets.h |
86feeaa8 | 64 | |
1cdf25d7 | 65 | always += $(offsets-file) |
6752ed90 | 66 | targets += arch/$(SRCARCH)/kernel/asm-offsets.s |
1cdf25d7 | 67 | |
86feeaa8 | 68 | # We use internal kbuild rules to avoid the "is up to date" message from make |
1cdf25d7 | 69 | arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ |
0a227985 | 70 | $(obj)/$(timeconst-file) $(obj)/$(bounds-file) FORCE |
86feeaa8 SR |
71 | $(Q)mkdir -p $(dir $@) |
72 | $(call if_changed_dep,cc_s_c) | |
73 | ||
70a4fd6c MM |
74 | $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE |
75 | $(call filechk,offsets,__ASM_OFFSETS_H__) | |
86feeaa8 | 76 | |
c53aeca0 | 77 | ##### |
0a227985 | 78 | # 4) Check for missing system calls |
c53aeca0 SR |
79 | # |
80 | ||
5f7efb4c AL |
81 | always += missing-syscalls |
82 | targets += missing-syscalls | |
83 | ||
c53aeca0 | 84 | quiet_cmd_syscalls = CALL $< |
44656fa0 | 85 | cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags) |
c53aeca0 | 86 | |
5f7efb4c | 87 | missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE |
c53aeca0 | 88 | $(call cmd,syscalls) |
1cdf25d7 | 89 | |
f197d75f KB |
90 | ##### |
91 | # 5) Generate constants for Python GDB integration | |
92 | # | |
93 | ||
94 | extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py | |
95 | ||
96 | build_constants_py: $(obj)/$(timeconst-file) $(obj)/$(bounds-file) | |
97 | @$(MAKE) $(build)=scripts/gdb/linux $@ | |
98 | ||
0a227985 NMG |
99 | # Keep these three files during make clean |
100 | no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file) |