xref: /openbmc/linux/Kbuild (revision 643d1f7f)
1#
2# Kbuild for top-level directory of the kernel
3# This file takes care of the following:
4# 1) Generate asm-offsets.h
5# 2) Check for missing system calls
6
7#####
8# 1) Generate asm-offsets.h
9#
10
11offsets-file := include/asm-$(SRCARCH)/asm-offsets.h
12
13always  := $(offsets-file)
14targets := $(offsets-file)
15targets += arch/$(SRCARCH)/kernel/asm-offsets.s
16clean-files := $(addprefix $(objtree)/,$(targets))
17
18# Default sed regexp - multiline due to syntax constraints
19define sed-y
20	"/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
21endef
22# Override default regexp for specific architectures
23sed-$(CONFIG_MIPS) := "/^@@@/{s/^@@@//; s/ \#.*\$$//; p;}"
24
25quiet_cmd_offsets = GEN     $@
26define cmd_offsets
27	(set -e; \
28	 echo "#ifndef __ASM_OFFSETS_H__"; \
29	 echo "#define __ASM_OFFSETS_H__"; \
30	 echo "/*"; \
31	 echo " * DO NOT MODIFY."; \
32	 echo " *"; \
33	 echo " * This file was generated by Kbuild"; \
34	 echo " *"; \
35	 echo " */"; \
36	 echo ""; \
37	 sed -ne $(sed-y) $<; \
38	 echo ""; \
39	 echo "#endif" ) > $@
40endef
41
42# We use internal kbuild rules to avoid the "is up to date" message from make
43arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c FORCE
44	$(Q)mkdir -p $(dir $@)
45	$(call if_changed_dep,cc_s_c)
46
47$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
48	$(Q)mkdir -p $(dir $@)
49	$(call cmd,offsets)
50
51#####
52# 2) Check for missing system calls
53#
54
55quiet_cmd_syscalls = CALL    $<
56      cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags)
57
58PHONY += missing-syscalls
59missing-syscalls: scripts/checksyscalls.sh FORCE
60	$(call cmd,syscalls)
61