blob: 3ec73e9c6a68dbdd8934c39d00398a8ad4427ba1 [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 " */"; \
27 echo ""; \
Brian Gerstac448af2006-01-06 18:28:45 -050028 sed -ne $(sed-y) $<; \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020029 echo ""; \
30 echo "#endif" ) > $@
31endef
32
Masahiro Yamada39664e22015-01-05 15:57:15 +090033#####
34# 1) Generate bounds.h
35
36bounds-file := include/generated/bounds.h
37
38always := $(bounds-file)
39targets := $(bounds-file) kernel/bounds.s
40
41# We use internal kbuild rules to avoid the "is up to date" message from make
42kernel/bounds.s: kernel/bounds.c FORCE
43 $(Q)mkdir -p $(dir $@)
44 $(call if_changed_dep,cc_s_c)
45
46$(obj)/$(bounds-file): kernel/bounds.s Kbuild
47 $(Q)mkdir -p $(dir $@)
48 $(call cmd,offsets,__LINUX_BOUNDS_H__)
49
50#####
51# 2) Generate asm-offsets.h
52#
53
54offsets-file := include/generated/asm-offsets.h
55
56always += $(offsets-file)
57targets += $(offsets-file)
58targets += arch/$(SRCARCH)/kernel/asm-offsets.s
59
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020060# We use internal kbuild rules to avoid the "is up to date" message from make
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070061arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
62 $(obj)/$(bounds-file) FORCE
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020063 $(Q)mkdir -p $(dir $@)
64 $(call if_changed_dep,cc_s_c)
65
Thomas Gleixner6752ed92007-10-11 11:11:36 +020066$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
Masahiro Yamada39664e22015-01-05 15:57:15 +090067 $(call cmd,offsets,__ASM_OFFSETS_H__)
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020068
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020069#####
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070070# 3) Check for missing system calls
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020071#
72
Arnaud Lacombe5f7efb42011-08-24 21:03:30 -040073always += missing-syscalls
74targets += missing-syscalls
75
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020076quiet_cmd_syscalls = CALL $<
David Daney44656fa2011-11-08 10:20:10 -080077 cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020078
Arnaud Lacombe5f7efb42011-08-24 21:03:30 -040079missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020080 $(call cmd,syscalls)
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070081
Michal Marekef8ff892010-03-09 16:00:20 +010082# Keep these two files during make clean
83no-clean-files := $(bounds-file) $(offsets-file)