| 1 | # |
| 2 | # Kbuild for top-level directory of the kernel |
| 3 | # This file takes care of the following: |
| 4 | # 1) Generate bounds.h |
| 5 | # 2) Generate asm-offsets.h (may need bounds.h) |
| 6 | # 3) Check for missing system calls |
| 7 | |
| 8 | # Default sed regexp - multiline due to syntax constraints |
| 9 | define sed-y |
| 10 | "/^->/{s:->#\(.*\):/* \1 */:; \ |
| 11 | s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ |
| 12 | s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ |
| 13 | s:->::; p;}" |
| 14 | endef |
| 15 | |
| 16 | quiet_cmd_offsets = GEN $@ |
| 17 | define cmd_offsets |
| 18 | (set -e; \ |
| 19 | echo "#ifndef $2"; \ |
| 20 | echo "#define $2"; \ |
| 21 | echo "/*"; \ |
| 22 | echo " * DO NOT MODIFY."; \ |
| 23 | echo " *"; \ |
| 24 | echo " * This file was generated by Kbuild"; \ |
| 25 | echo " */"; \ |
| 26 | echo ""; \ |
| 27 | sed -ne $(sed-y) $<; \ |
| 28 | echo ""; \ |
| 29 | echo "#endif" ) > $@ |
| 30 | endef |
| 31 | |
| 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 | |
| 59 | # We use internal kbuild rules to avoid the "is up to date" message from make |
| 60 | arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ |
| 61 | $(obj)/$(bounds-file) FORCE |
| 62 | $(Q)mkdir -p $(dir $@) |
| 63 | $(call if_changed_dep,cc_s_c) |
| 64 | |
| 65 | $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild |
| 66 | $(call cmd,offsets,__ASM_OFFSETS_H__) |
| 67 | |
| 68 | ##### |
| 69 | # 3) Check for missing system calls |
| 70 | # |
| 71 | |
| 72 | always += missing-syscalls |
| 73 | targets += missing-syscalls |
| 74 | |
| 75 | quiet_cmd_syscalls = CALL $< |
| 76 | cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags) |
| 77 | |
| 78 | missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE |
| 79 | $(call cmd,syscalls) |
| 80 | |
| 81 | # Keep these two files during make clean |
| 82 | no-clean-files := $(bounds-file) $(offsets-file) |