blob: ab8ded92e870f55290d4d8283e4cbb1b849f8a58 [file] [log] [blame]
Sam Ravnborg86feeaa2005-09-09 19:28:28 +02001#
2# Kbuild for top-level directory of the kernel
3# This file takes care of the following:
Christoph Lameter1cdf25d2008-04-28 02:12:44 -07004# 1) Generate bounds.h
5# 2) Generate asm-offsets.h (may need bounds.h)
6# 3) Check for missing system calls
Sam Ravnborg86feeaa2005-09-09 19:28:28 +02007
Sam Ravnborg048eb582005-09-09 22:32:31 +02008# Default sed regexp - multiline due to syntax constraints
9define sed-y
Christoph Lameterbf2ae2b2008-04-28 02:12:45 -070010 "/^->/{s:->#\(.*\):/* \1 */:; \
David Howells95a2f6f2010-10-27 17:28:32 +010011 s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
Alexander van Heukeluma22dcdb2010-10-21 23:30:49 +020012 s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
Christoph Lameterbf2ae2b2008-04-28 02:12:45 -070013 s:->::; p;}"
Sam Ravnborg048eb582005-09-09 22:32:31 +020014endef
Sam Ravnborg048eb582005-09-09 22:32:31 +020015
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020016quiet_cmd_offsets = GEN $@
17define cmd_offsets
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020018 (set -e; \
Masahiro Yamada39664e22015-01-05 15:57:15 +090019 echo "#ifndef $2"; \
20 echo "#define $2"; \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020021 echo "/*"; \
22 echo " * DO NOT MODIFY."; \
23 echo " *"; \
Olaf Hering65ff22e2006-07-25 18:42:26 -070024 echo " * This file was generated by Kbuild"; \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020025 echo " */"; \
26 echo ""; \
Brian Gerstac448af2006-01-06 18:28:45 -050027 sed -ne $(sed-y) $<; \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020028 echo ""; \
29 echo "#endif" ) > $@
30endef
31
Masahiro Yamada39664e22015-01-05 15:57:15 +090032#####
33# 1) Generate bounds.h
34
35bounds-file := include/generated/bounds.h
36
37always := $(bounds-file)
38targets := $(bounds-file) kernel/bounds.s
39
40# We use internal kbuild rules to avoid the "is up to date" message from make
41kernel/bounds.s: kernel/bounds.c FORCE
42 $(Q)mkdir -p $(dir $@)
43 $(call if_changed_dep,cc_s_c)
44
45$(obj)/$(bounds-file): kernel/bounds.s Kbuild
46 $(Q)mkdir -p $(dir $@)
47 $(call cmd,offsets,__LINUX_BOUNDS_H__)
48
49#####
50# 2) Generate asm-offsets.h
51#
52
53offsets-file := include/generated/asm-offsets.h
54
55always += $(offsets-file)
56targets += $(offsets-file)
57targets += arch/$(SRCARCH)/kernel/asm-offsets.s
58
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020059# We use internal kbuild rules to avoid the "is up to date" message from make
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070060arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
61 $(obj)/$(bounds-file) FORCE
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020062 $(Q)mkdir -p $(dir $@)
63 $(call if_changed_dep,cc_s_c)
64
Thomas Gleixner6752ed92007-10-11 11:11:36 +020065$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
Masahiro Yamada39664e22015-01-05 15:57:15 +090066 $(call cmd,offsets,__ASM_OFFSETS_H__)
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020067
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020068#####
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070069# 3) Check for missing system calls
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020070#
71
Arnaud Lacombe5f7efb42011-08-24 21:03:30 -040072always += missing-syscalls
73targets += missing-syscalls
74
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020075quiet_cmd_syscalls = CALL $<
David Daney44656fa2011-11-08 10:20:10 -080076 cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020077
Arnaud Lacombe5f7efb42011-08-24 21:03:30 -040078missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020079 $(call cmd,syscalls)
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070080
Michal Marekef8ff892010-03-09 16:00:20 +010081# Keep these two files during make clean
82no-clean-files := $(bounds-file) $(offsets-file)