Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 2 | # |
| 3 | # Kbuild for top-level directory of the kernel |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 4 | |
Masahiro Yamada | ed7ceac | 2022-08-20 18:15:28 +0900 | [diff] [blame] | 5 | # Prepare global headers and check sanity before descending into sub-directories |
| 6 | # --------------------------------------------------------------------------- |
| 7 | |
Masahiro Yamada | 01d509a | 2019-02-19 18:33:03 +0900 | [diff] [blame] | 8 | # Generate bounds.h |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 9 | |
| 10 | bounds-file := include/generated/bounds.h |
| 11 | |
Masahiro Yamada | 8a58e16 | 2015-03-26 20:59:52 +0900 | [diff] [blame] | 12 | targets := kernel/bounds.s |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 13 | |
Masahiro Yamada | 11fda14 | 2018-12-22 18:50:35 +0900 | [diff] [blame] | 14 | $(bounds-file): kernel/bounds.s FORCE |
Michal Marek | 70a4fd6 | 2015-03-11 11:01:01 +0100 | [diff] [blame] | 15 | $(call filechk,offsets,__LINUX_BOUNDS_H__) |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 16 | |
Masahiro Yamada | 01d509a | 2019-02-19 18:33:03 +0900 | [diff] [blame] | 17 | # Generate timeconst.h |
Nicholas Mc Guire | 0a22798 | 2015-05-18 14:19:12 +0200 | [diff] [blame] | 18 | |
| 19 | timeconst-file := include/generated/timeconst.h |
| 20 | |
Masahiro Yamada | ba97df4 | 2019-01-03 10:16:54 +0900 | [diff] [blame] | 21 | filechk_gentimeconst = echo $(CONFIG_HZ) | bc -q $< |
Nicholas Mc Guire | 0a22798 | 2015-05-18 14:19:12 +0200 | [diff] [blame] | 22 | |
Masahiro Yamada | 11fda14 | 2018-12-22 18:50:35 +0900 | [diff] [blame] | 23 | $(timeconst-file): kernel/time/timeconst.bc FORCE |
Nicholas Mc Guire | 0a22798 | 2015-05-18 14:19:12 +0200 | [diff] [blame] | 24 | $(call filechk,gentimeconst) |
| 25 | |
Masahiro Yamada | 01d509a | 2019-02-19 18:33:03 +0900 | [diff] [blame] | 26 | # Generate asm-offsets.h |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 27 | |
| 28 | offsets-file := include/generated/asm-offsets.h |
| 29 | |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 30 | targets += arch/$(SRCARCH)/kernel/asm-offsets.s |
| 31 | |
Masahiro Yamada | 11fda14 | 2018-12-22 18:50:35 +0900 | [diff] [blame] | 32 | arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file) |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 33 | |
Masahiro Yamada | 11fda14 | 2018-12-22 18:50:35 +0900 | [diff] [blame] | 34 | $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE |
Michal Marek | 70a4fd6 | 2015-03-11 11:01:01 +0100 | [diff] [blame] | 35 | $(call filechk,offsets,__ASM_OFFSETS_H__) |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 36 | |
Masahiro Yamada | 01d509a | 2019-02-19 18:33:03 +0900 | [diff] [blame] | 37 | # Check for missing system calls |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 38 | |
| 39 | quiet_cmd_syscalls = CALL $< |
David Daney | 44656fa | 2011-11-08 10:20:10 -0800 | [diff] [blame] | 40 | cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags) |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 41 | |
Masahiro Yamada | ed7ceac | 2022-08-20 18:15:28 +0900 | [diff] [blame] | 42 | PHONY += missing-syscalls |
| 43 | missing-syscalls: scripts/checksyscalls.sh $(offsets-file) |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 44 | $(call cmd,syscalls) |
Christoph Lameter | 1cdf25d | 2008-04-28 02:12:44 -0700 | [diff] [blame] | 45 | |
Masahiro Yamada | b10fdee | 2022-08-20 18:15:29 +0900 | [diff] [blame] | 46 | # Check the manual modification of atomic headers |
Mark Rutland | 8d32588 | 2018-09-04 11:48:29 +0100 | [diff] [blame] | 47 | |
Masahiro Yamada | b10fdee | 2022-08-20 18:15:29 +0900 | [diff] [blame] | 48 | quiet_cmd_check_sha1 = CHKSHA1 $< |
| 49 | cmd_check_sha1 = \ |
| 50 | if ! command -v sha1sum >/dev/null; then \ |
| 51 | echo "warning: cannot check the header due to sha1sum missing"; \ |
| 52 | exit 0; \ |
| 53 | fi; \ |
| 54 | if [ "$$(sed -n '$$s:// ::p' $<)" != \ |
| 55 | "$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \ |
| 56 | echo "error: $< has been modified." >&2; \ |
| 57 | exit 1; \ |
| 58 | fi; \ |
| 59 | touch $@ |
Mark Rutland | 8d32588 | 2018-09-04 11:48:29 +0100 | [diff] [blame] | 60 | |
Masahiro Yamada | b10fdee | 2022-08-20 18:15:29 +0900 | [diff] [blame] | 61 | atomic-checks += $(addprefix $(obj)/.checked-, \ |
| 62 | atomic-arch-fallback.h \ |
| 63 | atomic-instrumented.h \ |
| 64 | atomic-long.h) |
Mark Rutland | 8d32588 | 2018-09-04 11:48:29 +0100 | [diff] [blame] | 65 | |
Masahiro Yamada | b10fdee | 2022-08-20 18:15:29 +0900 | [diff] [blame] | 66 | targets += $(atomic-checks) |
| 67 | $(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE |
| 68 | $(call if_changed,check_sha1) |
Masahiro Yamada | ed7ceac | 2022-08-20 18:15:28 +0900 | [diff] [blame] | 69 | |
| 70 | # A phony target that depends on all the preparation targets |
| 71 | |
| 72 | PHONY += prepare |
Masahiro Yamada | b10fdee | 2022-08-20 18:15:29 +0900 | [diff] [blame] | 73 | prepare: $(offsets-file) missing-syscalls $(atomic-checks) |
Masahiro Yamada | ed7ceac | 2022-08-20 18:15:28 +0900 | [diff] [blame] | 74 | @: |
Masahiro Yamada | 5750121 | 2022-09-25 03:19:10 +0900 | [diff] [blame] | 75 | |
| 76 | # Ordinary directory descending |
| 77 | # --------------------------------------------------------------------------- |
| 78 | |
| 79 | obj-y += init/ |
| 80 | obj-y += usr/ |
| 81 | obj-y += arch/$(SRCARCH)/ |
| 82 | obj-y += $(ARCH_CORE) |
| 83 | obj-y += kernel/ |
| 84 | obj-y += certs/ |
| 85 | obj-y += mm/ |
| 86 | obj-y += fs/ |
| 87 | obj-y += ipc/ |
| 88 | obj-y += security/ |
| 89 | obj-y += crypto/ |
| 90 | obj-$(CONFIG_BLOCK) += block/ |
| 91 | obj-$(CONFIG_IO_URING) += io_uring/ |
Linus Torvalds | 8afc66e | 2022-10-10 12:00:45 -0700 | [diff] [blame] | 92 | obj-$(CONFIG_RUST) += rust/ |
Masahiro Yamada | 5750121 | 2022-09-25 03:19:10 +0900 | [diff] [blame] | 93 | obj-y += $(ARCH_LIB) |
| 94 | obj-y += drivers/ |
| 95 | obj-y += sound/ |
| 96 | obj-$(CONFIG_SAMPLES) += samples/ |
| 97 | obj-$(CONFIG_NET) += net/ |
| 98 | obj-y += virt/ |
| 99 | obj-y += $(ARCH_DRIVERS) |