blob: 6f0d82a9245d897c89a63819e857f474ab93066e [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
Michal Marek70a4fd62015-03-11 11:01:01 +010016# Use filechk to avoid rebuilds when a header changes, but the resulting file
17# does not
18define filechk_offsets
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020019 (set -e; \
Masahiro Yamada39664e22015-01-05 15:57:15 +090020 echo "#ifndef $2"; \
21 echo "#define $2"; \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020022 echo "/*"; \
23 echo " * DO NOT MODIFY."; \
24 echo " *"; \
Olaf Hering65ff22e2006-07-25 18:42:26 -070025 echo " * This file was generated by Kbuild"; \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020026 echo " */"; \
27 echo ""; \
Michal Marek70a4fd62015-03-11 11:01:01 +010028 sed -ne $(sed-y); \
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020029 echo ""; \
Michal Marek70a4fd62015-03-11 11:01:01 +010030 echo "#endif" )
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020031endef
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)
Masahiro Yamada8a58e162015-03-26 20:59:52 +090039targets := kernel/bounds.s
Masahiro Yamada39664e22015-01-05 15:57:15 +090040
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
Michal Marek70a4fd62015-03-11 11:01:01 +010046$(obj)/$(bounds-file): kernel/bounds.s FORCE
47 $(call filechk,offsets,__LINUX_BOUNDS_H__)
Masahiro Yamada39664e22015-01-05 15:57:15 +090048
49#####
50# 2) Generate asm-offsets.h
51#
52
53offsets-file := include/generated/asm-offsets.h
54
55always += $(offsets-file)
Masahiro Yamada39664e22015-01-05 15:57:15 +090056targets += arch/$(SRCARCH)/kernel/asm-offsets.s
57
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020058# We use internal kbuild rules to avoid the "is up to date" message from make
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070059arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
60 $(obj)/$(bounds-file) FORCE
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020061 $(Q)mkdir -p $(dir $@)
62 $(call if_changed_dep,cc_s_c)
63
Michal Marek70a4fd62015-03-11 11:01:01 +010064$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
65 $(call filechk,offsets,__ASM_OFFSETS_H__)
Sam Ravnborg86feeaa2005-09-09 19:28:28 +020066
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020067#####
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070068# 3) Check for missing system calls
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020069#
70
Arnaud Lacombe5f7efb42011-08-24 21:03:30 -040071always += missing-syscalls
72targets += missing-syscalls
73
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020074quiet_cmd_syscalls = CALL $<
David Daney44656fa2011-11-08 10:20:10 -080075 cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020076
Arnaud Lacombe5f7efb42011-08-24 21:03:30 -040077missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
Sam Ravnborgc53aeca2007-03-27 22:50:29 +020078 $(call cmd,syscalls)
Christoph Lameter1cdf25d2008-04-28 02:12:44 -070079
Michal Marekef8ff892010-03-09 16:00:20 +010080# Keep these two files during make clean
81no-clean-files := $(bounds-file) $(offsets-file)