blob: 96d062906c052fbb89d5b79ad8556a7a77772924 [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)
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
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)
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
Michal Marek70a4fd62015-03-11 11:01:01 +010065$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
66 $(call filechk,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)