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