1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 286feeaa8SSam Ravnborg# 386feeaa8SSam Ravnborg# Kbuild for top-level directory of the kernel 486feeaa8SSam Ravnborg 5ed7ceac1SMasahiro Yamada# Prepare global headers and check sanity before descending into sub-directories 6ed7ceac1SMasahiro Yamada# --------------------------------------------------------------------------- 7ed7ceac1SMasahiro Yamada 801d509a4SMasahiro Yamada# Generate bounds.h 939664e2fSMasahiro Yamada 1039664e2fSMasahiro Yamadabounds-file := include/generated/bounds.h 1139664e2fSMasahiro Yamada 128a58e162SMasahiro Yamadatargets := kernel/bounds.s 1339664e2fSMasahiro Yamada 1411fda148SMasahiro Yamada$(bounds-file): kernel/bounds.s FORCE 1570a4fd6cSMichal Marek $(call filechk,offsets,__LINUX_BOUNDS_H__) 1639664e2fSMasahiro Yamada 1701d509a4SMasahiro Yamada# Generate timeconst.h 180a227985SNicholas Mc Guire 190a227985SNicholas Mc Guiretimeconst-file := include/generated/timeconst.h 200a227985SNicholas Mc Guire 21ba97df45SMasahiro Yamadafilechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $< 220a227985SNicholas Mc Guire 2311fda148SMasahiro Yamada$(timeconst-file): kernel/time/timeconst.bc FORCE 240a227985SNicholas Mc Guire $(call filechk,gentimeconst) 250a227985SNicholas Mc Guire 2601d509a4SMasahiro Yamada# Generate asm-offsets.h 2739664e2fSMasahiro Yamada 2839664e2fSMasahiro Yamadaoffsets-file := include/generated/asm-offsets.h 2939664e2fSMasahiro Yamada 3039664e2fSMasahiro Yamadatargets += arch/$(SRCARCH)/kernel/asm-offsets.s 3139664e2fSMasahiro Yamada 3211fda148SMasahiro Yamadaarch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file) 3386feeaa8SSam Ravnborg 3411fda148SMasahiro Yamada$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE 3570a4fd6cSMichal Marek $(call filechk,offsets,__ASM_OFFSETS_H__) 3686feeaa8SSam Ravnborg 3701d509a4SMasahiro Yamada# Check for missing system calls 38c53aeca0SSam Ravnborg 39c53aeca0SSam Ravnborgquiet_cmd_syscalls = CALL $< 4044656fa0SDavid Daney cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags) 41c53aeca0SSam Ravnborg 42ed7ceac1SMasahiro YamadaPHONY += missing-syscalls 43ed7ceac1SMasahiro Yamadamissing-syscalls: scripts/checksyscalls.sh $(offsets-file) 44c53aeca0SSam Ravnborg $(call cmd,syscalls) 451cdf25d7SChristoph Lameter 46b10fdeeaSMasahiro Yamada# Check the manual modification of atomic headers 478d325880SMark Rutland 48b10fdeeaSMasahiro Yamadaquiet_cmd_check_sha1 = CHKSHA1 $< 49b10fdeeaSMasahiro Yamada cmd_check_sha1 = \ 50b10fdeeaSMasahiro Yamada if ! command -v sha1sum >/dev/null; then \ 51b10fdeeaSMasahiro Yamada echo "warning: cannot check the header due to sha1sum missing"; \ 52b10fdeeaSMasahiro Yamada exit 0; \ 53b10fdeeaSMasahiro Yamada fi; \ 54b10fdeeaSMasahiro Yamada if [ "$$(sed -n '$$s:// ::p' $<)" != \ 55b10fdeeaSMasahiro Yamada "$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \ 56b10fdeeaSMasahiro Yamada echo "error: $< has been modified." >&2; \ 57b10fdeeaSMasahiro Yamada exit 1; \ 58b10fdeeaSMasahiro Yamada fi; \ 59b10fdeeaSMasahiro Yamada touch $@ 608d325880SMark Rutland 61b10fdeeaSMasahiro Yamadaatomic-checks += $(addprefix $(obj)/.checked-, \ 62b10fdeeaSMasahiro Yamada atomic-arch-fallback.h \ 63b10fdeeaSMasahiro Yamada atomic-instrumented.h \ 64b10fdeeaSMasahiro Yamada atomic-long.h) 65b10fdeeaSMasahiro Yamada 66b10fdeeaSMasahiro Yamadatargets += $(atomic-checks) 67b10fdeeaSMasahiro Yamada$(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE 68b10fdeeaSMasahiro Yamada $(call if_changed,check_sha1) 69ed7ceac1SMasahiro Yamada 70ed7ceac1SMasahiro Yamada# A phony target that depends on all the preparation targets 71ed7ceac1SMasahiro Yamada 72ed7ceac1SMasahiro YamadaPHONY += prepare 73b10fdeeaSMasahiro Yamadaprepare: $(offsets-file) missing-syscalls $(atomic-checks) 74ed7ceac1SMasahiro Yamada @: 75*5750121aSMasahiro Yamada 76*5750121aSMasahiro Yamada# Ordinary directory descending 77*5750121aSMasahiro Yamada# --------------------------------------------------------------------------- 78*5750121aSMasahiro Yamada 79*5750121aSMasahiro Yamadaobj-y += init/ 80*5750121aSMasahiro Yamadaobj-y += usr/ 81*5750121aSMasahiro Yamadaobj-y += arch/$(SRCARCH)/ 82*5750121aSMasahiro Yamadaobj-y += $(ARCH_CORE) 83*5750121aSMasahiro Yamadaobj-y += kernel/ 84*5750121aSMasahiro Yamadaobj-y += certs/ 85*5750121aSMasahiro Yamadaobj-y += mm/ 86*5750121aSMasahiro Yamadaobj-y += fs/ 87*5750121aSMasahiro Yamadaobj-y += ipc/ 88*5750121aSMasahiro Yamadaobj-y += security/ 89*5750121aSMasahiro Yamadaobj-y += crypto/ 90*5750121aSMasahiro Yamadaobj-$(CONFIG_BLOCK) += block/ 91*5750121aSMasahiro Yamadaobj-$(CONFIG_IO_URING) += io_uring/ 92*5750121aSMasahiro Yamadaobj-$(CONFIG_RUST) += rust/ 93*5750121aSMasahiro Yamadaobj-y += $(ARCH_LIB) 94*5750121aSMasahiro Yamadaobj-y += drivers/ 95*5750121aSMasahiro Yamadaobj-y += sound/ 96*5750121aSMasahiro Yamadaobj-$(CONFIG_SAMPLES) += samples/ 97*5750121aSMasahiro Yamadaobj-$(CONFIG_NET) += net/ 98*5750121aSMasahiro Yamadaobj-y += virt/ 99obj-y += $(ARCH_DRIVERS) 100