Kbuild 1.9 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
2 3 4
#
# Kbuild for top-level directory of the kernel

5 6 7
# Prepare global headers and check sanity before descending into sub-directories
# ---------------------------------------------------------------------------

8
# Generate bounds.h
9 10 11

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

12
targets := kernel/bounds.s
13

14
$(bounds-file): kernel/bounds.s FORCE
15
	$(call filechk,offsets,__LINUX_BOUNDS_H__)
16

17
# Generate timeconst.h
18 19 20

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

21
filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $<
22

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

26
# Generate asm-offsets.h
27

28
offsets-file := include/generated/asm-offsets.h
29

30
targets += arch/$(SRCARCH)/kernel/asm-offsets.s
31

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

34
$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
35
	$(call filechk,offsets,__ASM_OFFSETS_H__)
36

37
# Check for missing system calls
38 39

quiet_cmd_syscalls = CALL    $<
40
      cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
41

42 43
PHONY += missing-syscalls
missing-syscalls: scripts/checksyscalls.sh $(offsets-file)
44
	$(call cmd,syscalls)
45

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
# Check the manual modification of atomic headers

quiet_cmd_check_sha1 = CHKSHA1 $<
      cmd_check_sha1 = \
	if ! command -v sha1sum >/dev/null; then \
		echo "warning: cannot check the header due to sha1sum missing"; \
		exit 0; \
	fi; \
	if [ "$$(sed -n '$$s:// ::p' $<)" != \
	     "$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \
		echo "error: $< has been modified." >&2; \
		exit 1; \
	fi; \
	touch $@

atomic-checks += $(addprefix $(obj)/.checked-, \
	  atomic-arch-fallback.h \
	  atomic-instrumented.h \
	  atomic-long.h)

targets += $(atomic-checks)
$(atomic-checks): $(obj)/.checked-%: include/linux/atomic/%  FORCE
	$(call if_changed,check_sha1)
69 70 71 72

# A phony target that depends on all the preparation targets

PHONY += prepare
73
prepare: $(offsets-file) missing-syscalls $(atomic-checks)
74
	@: