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 | |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 16 | quiet_cmd_offsets = GEN $@ |
| 17 | define cmd_offsets |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 18 | (set -e; \ |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 19 | echo "#ifndef $2"; \ |
| 20 | echo "#define $2"; \ |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 21 | echo "/*"; \ |
| 22 | echo " * DO NOT MODIFY."; \ |
| 23 | echo " *"; \ |
Olaf Hering | 65ff22e | 2006-07-25 18:42:26 -0700 | [diff] [blame] | 24 | echo " * This file was generated by Kbuild"; \ |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 25 | echo " */"; \ |
| 26 | echo ""; \ |
Brian Gerst | ac448af | 2006-01-06 18:28:45 -0500 | [diff] [blame] | 27 | sed -ne $(sed-y) $<; \ |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 28 | echo ""; \ |
| 29 | echo "#endif" ) > $@ |
| 30 | endef |
| 31 | |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 32 | ##### |
| 33 | # 1) Generate bounds.h |
| 34 | |
| 35 | bounds-file := include/generated/bounds.h |
| 36 | |
| 37 | always := $(bounds-file) |
| 38 | targets := $(bounds-file) kernel/bounds.s |
| 39 | |
| 40 | # We use internal kbuild rules to avoid the "is up to date" message from make |
| 41 | kernel/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 | |
| 53 | offsets-file := include/generated/asm-offsets.h |
| 54 | |
| 55 | always += $(offsets-file) |
| 56 | targets += $(offsets-file) |
| 57 | targets += arch/$(SRCARCH)/kernel/asm-offsets.s |
| 58 | |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 59 | # 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] | 60 | arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ |
| 61 | $(obj)/$(bounds-file) FORCE |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 62 | $(Q)mkdir -p $(dir $@) |
| 63 | $(call if_changed_dep,cc_s_c) |
| 64 | |
Thomas Gleixner | 6752ed9 | 2007-10-11 11:11:36 +0200 | [diff] [blame] | 65 | $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild |
Masahiro Yamada | 39664e2 | 2015-01-05 15:57:15 +0900 | [diff] [blame] | 66 | $(call cmd,offsets,__ASM_OFFSETS_H__) |
Sam Ravnborg | 86feeaa | 2005-09-09 19:28:28 +0200 | [diff] [blame] | 67 | |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 68 | ##### |
Christoph Lameter | 1cdf25d | 2008-04-28 02:12:44 -0700 | [diff] [blame] | 69 | # 3) Check for missing system calls |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 70 | # |
| 71 | |
Arnaud Lacombe | 5f7efb4 | 2011-08-24 21:03:30 -0400 | [diff] [blame] | 72 | always += missing-syscalls |
| 73 | targets += missing-syscalls |
| 74 | |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 75 | quiet_cmd_syscalls = CALL $< |
David Daney | 44656fa | 2011-11-08 10:20:10 -0800 | [diff] [blame] | 76 | cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags) |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 77 | |
Arnaud Lacombe | 5f7efb4 | 2011-08-24 21:03:30 -0400 | [diff] [blame] | 78 | missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE |
Sam Ravnborg | c53aeca | 2007-03-27 22:50:29 +0200 | [diff] [blame] | 79 | $(call cmd,syscalls) |
Christoph Lameter | 1cdf25d | 2008-04-28 02:12:44 -0700 | [diff] [blame] | 80 | |
Michal Marek | ef8ff89 | 2010-03-09 16:00:20 +0100 | [diff] [blame] | 81 | # Keep these two files during make clean |
| 82 | no-clean-files := $(bounds-file) $(offsets-file) |