Back to home page

LXR

 
 

    


0001 #
0002 # Kbuild for top-level directory of the kernel
0003 # This file takes care of the following:
0004 # 1) Generate bounds.h
0005 # 2) Generate timeconst.h
0006 # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
0007 # 4) Check for missing system calls
0008 # 5) Generate constants.py (may need bounds.h)
0009 
0010 # Default sed regexp - multiline due to syntax constraints
0011 define sed-y
0012         "/^->/{s:->#\(.*\):/* \1 */:; \
0013         s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
0014         s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
0015         s:->::; p;}"
0016 endef
0017 
0018 # Use filechk to avoid rebuilds when a header changes, but the resulting file
0019 # does not
0020 define filechk_offsets
0021         (set -e; \
0022          echo "#ifndef $2"; \
0023          echo "#define $2"; \
0024          echo "/*"; \
0025          echo " * DO NOT MODIFY."; \
0026          echo " *"; \
0027          echo " * This file was generated by Kbuild"; \
0028          echo " */"; \
0029          echo ""; \
0030          sed -ne $(sed-y); \
0031          echo ""; \
0032          echo "#endif" )
0033 endef
0034 
0035 #####
0036 # 1) Generate bounds.h
0037 
0038 bounds-file := include/generated/bounds.h
0039 
0040 always  := $(bounds-file)
0041 targets := kernel/bounds.s
0042 
0043 # We use internal kbuild rules to avoid the "is up to date" message from make
0044 kernel/bounds.s: kernel/bounds.c FORCE
0045         $(Q)mkdir -p $(dir $@)
0046         $(call if_changed_dep,cc_s_c)
0047 
0048 $(obj)/$(bounds-file): kernel/bounds.s FORCE
0049         $(call filechk,offsets,__LINUX_BOUNDS_H__)
0050 
0051 #####
0052 # 2) Generate timeconst.h
0053 
0054 timeconst-file := include/generated/timeconst.h
0055 
0056 targets += $(timeconst-file)
0057 
0058 quiet_cmd_gentimeconst = GEN     $@
0059 define cmd_gentimeconst
0060         (echo $(CONFIG_HZ) | bc -q $< ) > $@
0061 endef
0062 define filechk_gentimeconst
0063         (echo $(CONFIG_HZ) | bc -q $< )
0064 endef
0065 
0066 $(obj)/$(timeconst-file): kernel/time/timeconst.bc FORCE
0067         $(call filechk,gentimeconst)
0068 
0069 #####
0070 # 3) Generate asm-offsets.h
0071 #
0072 
0073 offsets-file := include/generated/asm-offsets.h
0074 
0075 always  += $(offsets-file)
0076 targets += arch/$(SRCARCH)/kernel/asm-offsets.s
0077 
0078 # We use internal kbuild rules to avoid the "is up to date" message from make
0079 arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
0080                                       $(obj)/$(timeconst-file) $(obj)/$(bounds-file) FORCE
0081         $(Q)mkdir -p $(dir $@)
0082         $(call if_changed_dep,cc_s_c)
0083 
0084 $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
0085         $(call filechk,offsets,__ASM_OFFSETS_H__)
0086 
0087 #####
0088 # 4) Check for missing system calls
0089 #
0090 
0091 always += missing-syscalls
0092 targets += missing-syscalls
0093 
0094 quiet_cmd_syscalls = CALL    $<
0095       cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) $(missing_syscalls_flags)
0096 
0097 missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
0098         $(call cmd,syscalls)
0099 
0100 #####
0101 # 5) Generate constants for Python GDB integration
0102 #
0103 
0104 extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
0105 
0106 build_constants_py: $(obj)/$(timeconst-file) $(obj)/$(bounds-file)
0107         @$(MAKE) $(build)=scripts/gdb/linux $@
0108 
0109 # Keep these three files during make clean
0110 no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)