186feeaa8SSam Ravnborg# 286feeaa8SSam Ravnborg# Kbuild for top-level directory of the kernel 386feeaa8SSam Ravnborg# This file takes care of the following: 41cdf25d7SChristoph Lameter# 1) Generate bounds.h 51cdf25d7SChristoph Lameter# 2) Generate asm-offsets.h (may need bounds.h) 61cdf25d7SChristoph Lameter# 3) Check for missing system calls 786feeaa8SSam Ravnborg 8048eb582SSam Ravnborg# Default sed regexp - multiline due to syntax constraints 9048eb582SSam Ravnborgdefine sed-y 10bf2ae2b3SChristoph Lameter "/^->/{s:->#\(.*\):/* \1 */:; \ 1195a2f6f7SDavid Howells s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ 12a22dcdb0SAlexander van Heukelum s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ 13bf2ae2b3SChristoph Lameter s:->::; p;}" 14048eb582SSam Ravnborgendef 15048eb582SSam Ravnborg 1670a4fd6cSMichal Marek# Use filechk to avoid rebuilds when a header changes, but the resulting file 1770a4fd6cSMichal Marek# does not 1870a4fd6cSMichal Marekdefine filechk_offsets 1986feeaa8SSam Ravnborg (set -e; \ 2039664e2fSMasahiro Yamada echo "#ifndef $2"; \ 2139664e2fSMasahiro Yamada echo "#define $2"; \ 2286feeaa8SSam Ravnborg echo "/*"; \ 2386feeaa8SSam Ravnborg echo " * DO NOT MODIFY."; \ 2486feeaa8SSam Ravnborg echo " *"; \ 2565ff22eeSOlaf Hering echo " * This file was generated by Kbuild"; \ 2686feeaa8SSam Ravnborg echo " */"; \ 2786feeaa8SSam Ravnborg echo ""; \ 2870a4fd6cSMichal Marek sed -ne $(sed-y); \ 2986feeaa8SSam Ravnborg echo ""; \ 3070a4fd6cSMichal Marek echo "#endif" ) 3186feeaa8SSam Ravnborgendef 3286feeaa8SSam Ravnborg 3339664e2fSMasahiro Yamada##### 3439664e2fSMasahiro Yamada# 1) Generate bounds.h 3539664e2fSMasahiro Yamada 3639664e2fSMasahiro Yamadabounds-file := include/generated/bounds.h 3739664e2fSMasahiro Yamada 3839664e2fSMasahiro Yamadaalways := $(bounds-file) 39*8a58e162SMasahiro Yamadatargets := kernel/bounds.s 4039664e2fSMasahiro Yamada 4139664e2fSMasahiro Yamada# We use internal kbuild rules to avoid the "is up to date" message from make 4239664e2fSMasahiro Yamadakernel/bounds.s: kernel/bounds.c FORCE 4339664e2fSMasahiro Yamada $(Q)mkdir -p $(dir $@) 4439664e2fSMasahiro Yamada $(call if_changed_dep,cc_s_c) 4539664e2fSMasahiro Yamada 4670a4fd6cSMichal Marek$(obj)/$(bounds-file): kernel/bounds.s FORCE 4770a4fd6cSMichal Marek $(call filechk,offsets,__LINUX_BOUNDS_H__) 4839664e2fSMasahiro Yamada 4939664e2fSMasahiro Yamada##### 5039664e2fSMasahiro Yamada# 2) Generate asm-offsets.h 5139664e2fSMasahiro Yamada# 5239664e2fSMasahiro Yamada 5339664e2fSMasahiro Yamadaoffsets-file := include/generated/asm-offsets.h 5439664e2fSMasahiro Yamada 5539664e2fSMasahiro Yamadaalways += $(offsets-file) 5639664e2fSMasahiro Yamadatargets += arch/$(SRCARCH)/kernel/asm-offsets.s 5739664e2fSMasahiro Yamada 5886feeaa8SSam Ravnborg# We use internal kbuild rules to avoid the "is up to date" message from make 591cdf25d7SChristoph Lameterarch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ 601cdf25d7SChristoph Lameter $(obj)/$(bounds-file) FORCE 6186feeaa8SSam Ravnborg $(Q)mkdir -p $(dir $@) 6286feeaa8SSam Ravnborg $(call if_changed_dep,cc_s_c) 6386feeaa8SSam Ravnborg 6470a4fd6cSMichal Marek$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE 6570a4fd6cSMichal Marek $(call filechk,offsets,__ASM_OFFSETS_H__) 6686feeaa8SSam Ravnborg 67c53aeca0SSam Ravnborg##### 681cdf25d7SChristoph Lameter# 3) Check for missing system calls 69c53aeca0SSam Ravnborg# 70c53aeca0SSam Ravnborg 715f7efb4cSArnaud Lacombealways += missing-syscalls 725f7efb4cSArnaud Lacombetargets += missing-syscalls 735f7efb4cSArnaud Lacombe 74c53aeca0SSam Ravnborgquiet_cmd_syscalls = CALL $< 7544656fa0SDavid Daney cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags) 76c53aeca0SSam Ravnborg 775f7efb4cSArnaud Lacombemissing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE 78c53aeca0SSam Ravnborg $(call cmd,syscalls) 791cdf25d7SChristoph Lameter 80ef8ff89bSMichal Marek# Keep these two files during make clean 81ef8ff89bSMichal Marekno-clean-files := $(bounds-file) $(offsets-file) 82