Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 1 | # |
| 2 | # Kbuild for top-level directory of the kernel |
| 3 | # This file takes care of the following: |
Christoph Lameter | 1cdf25d | 2008-04-28 02:12:44 -0700 | [diff] [blame] | 4 | # 1) Generate bounds.h |
| 5 | # 2) Generate asm-offsets.h (may need bounds.h) |
| 6 | # 3) Check for missing system calls |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 7 | |
Sam Ravnborg | 048eb58 | 2005-09-09 22:32:31 +0200 | [diff] [blame] | 8 | # Default sed regexp - multiline due to syntax constraints |
| 9 | define sed-y |
Christoph Lameter | bf2ae2b | 2008-04-28 02:12:45 -0700 | [diff] [blame] | 10 | "/^->/{s:->#\(.*\):/* \1 */:; \ |
David Howells | 95a2f6f | 2010-10-27 17:28:32 +0100 | [diff] [blame] | 11 | s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ |
Alexander van Heukelum | a22dcdb | 2010-10-21 23:30:49 +0200 | [diff] [blame] | 12 | s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ |
Christoph Lameter | bf2ae2b | 2008-04-28 02:12:45 -0700 | [diff] [blame] | 13 | s:->::; p;}" |
Sam Ravnborg | 048eb58 | 2005-09-09 22:32:31 +0200 | [diff] [blame] | 14 | endef |
Sam Ravnborg | 048eb58 | 2005-09-09 22:32:31 +0200 | [diff] [blame] | 15 | |
Michal Marek | 70a4fd6 | 2015-03-11 11:01:01 +0100 | [diff] [blame] | 16 | # Use filechk to avoid rebuilds when a header changes, but the resulting file |
| 17 | # does not |
| 18 | define filechk_offsets |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 19 | (set -e; \ |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 20 | echo "#ifndef $2"; \ |
| 21 | echo "#define $2"; \ |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 22 | echo "/*"; \ |
| 23 | echo " * DO NOT MODIFY."; \ |
| 24 | echo " *"; \ |
Olaf Hering | 65ff22e | 2006-07-25 18:42:26 -0700 | [diff] [blame] | 25 | echo " * This file was generated by Kbuild"; \ |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 26 | echo " */"; \ |
| 27 | echo ""; \ |
Michal Marek | 70a4fd6 | 2015-03-11 11:01:01 +0100 | [diff] [blame] | 28 | sed -ne $(sed-y); \ |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 29 | echo ""; \ |
Michal Marek | 70a4fd6 | 2015-03-11 11:01:01 +0100 | [diff] [blame] | 30 | echo "#endif" ) |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 31 | endef |
| 32 | |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 33 | ##### |
| 34 | # 1) Generate bounds.h |
| 35 | |
| 36 | bounds-file := include/generated/bounds.h |
| 37 | |
| 38 | always := $(bounds-file) |
Masahiro Yamada | 8a58e16 | 2015-03-26 20:59:52 +0900 | [diff] [blame] | 39 | targets := kernel/bounds.s |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 40 | |
| 41 | # We use internal kbuild rules to avoid the "is up to date" message from make |
| 42 | kernel/bounds.s: kernel/bounds.c FORCE |
| 43 | $(Q)mkdir -p $(dir $@) |
| 44 | $(call if_changed_dep,cc_s_c) |
| 45 | |
Michal Marek | 70a4fd6 | 2015-03-11 11:01:01 +0100 | [diff] [blame] | 46 | $(obj)/$(bounds-file): kernel/bounds.s FORCE |
| 47 | $(call filechk,offsets,__LINUX_BOUNDS_H__) |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 48 | |
| 49 | ##### |
| 50 | # 2) Generate asm-offsets.h |
| 51 | # |
| 52 | |
| 53 | offsets-file := include/generated/asm-offsets.h |
| 54 | |
| 55 | always += $(offsets-file) |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 56 | targets += arch/$(SRCARCH)/kernel/asm-offsets.s |
| 57 | |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 58 | # We use internal kbuild rules to avoid the "is up to date" message from make |
Christoph Lameter | 1cdf25d | 2008-04-28 02:12:44 -0700 | [diff] [blame] | 59 | arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ |
| 60 | $(obj)/$(bounds-file) FORCE |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 61 | $(Q)mkdir -p $(dir $@) |
| 62 | $(call if_changed_dep,cc_s_c) |
| 63 | |
Michal Marek | 70a4fd6 | 2015-03-11 11:01:01 +0100 | [diff] [blame] | 64 | $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE |
| 65 | $(call filechk,offsets,__ASM_OFFSETS_H__) |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 66 | |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 67 | ##### |
Christoph Lameter | 1cdf25d | 2008-04-28 02:12:44 -0700 | [diff] [blame] | 68 | # 3) Check for missing system calls |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 69 | # |
| 70 | |
Arnaud Lacombe | 5f7efb4 | 2011-08-24 21:03:30 -0400 | [diff] [blame] | 71 | always += missing-syscalls |
| 72 | targets += missing-syscalls |
| 73 | |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 74 | quiet_cmd_syscalls = CALL $< |
David Daney | 44656fa | 2011-11-08 10:20:10 -0800 | [diff] [blame] | 75 | cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags) |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 76 | |
Arnaud Lacombe | 5f7efb4 | 2011-08-24 21:03:30 -0400 | [diff] [blame] | 77 | missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 78 | $(call cmd,syscalls) |
Christoph Lameter | 1cdf25d | 2008-04-28 02:12:44 -0700 | [diff] [blame] | 79 | |
Michal Marek | ef8ff89 | 2010-03-09 16:00:20 +0100 | [diff] [blame] | 80 | # Keep these two files during make clean |
| 81 | no-clean-files := $(bounds-file) $(offsets-file) |