Skip to content

Commit

Permalink
kbuild: merge bounds.h and asm-offsets.h rules
Browse files Browse the repository at this point in the history
The rules "cmd_bounds" and "cmd_offsets" are almost the same.
(The difference is only the include guards.)  They can be merged.

Signed-off-by: Masahiro Yamada <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
masahir0y authored and michal42 committed Jan 5, 2015
1 parent 34948e0 commit 39664e2
Showing 1 changed file with 21 additions and 39 deletions.
60 changes: 21 additions & 39 deletions Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
# 2) Generate asm-offsets.h (may need bounds.h)
# 3) Check for missing system calls

#####
# 1) Generate bounds.h

bounds-file := include/generated/bounds.h

always := $(bounds-file)
targets := $(bounds-file) kernel/bounds.s
# Default sed regexp - multiline due to syntax constraints
define sed-y
"/^->/{s:->#\(.*\):/* \1 */:; \
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:->::; p;}"
endef

quiet_cmd_bounds = GEN $@
define cmd_bounds
quiet_cmd_offsets = GEN $@
define cmd_offsets
(set -e; \
echo "#ifndef __LINUX_BOUNDS_H__"; \
echo "#define __LINUX_BOUNDS_H__"; \
echo "#ifndef $2"; \
echo "#define $2"; \
echo "/*"; \
echo " * DO NOT MODIFY."; \
echo " *"; \
Expand All @@ -30,14 +30,22 @@ define cmd_bounds
echo "#endif" ) > $@
endef

#####
# 1) Generate bounds.h

bounds-file := include/generated/bounds.h

always := $(bounds-file)
targets := $(bounds-file) kernel/bounds.s

# We use internal kbuild rules to avoid the "is up to date" message from make
kernel/bounds.s: kernel/bounds.c FORCE
$(Q)mkdir -p $(dir $@)
$(call if_changed_dep,cc_s_c)

$(obj)/$(bounds-file): kernel/bounds.s Kbuild
$(Q)mkdir -p $(dir $@)
$(call cmd,bounds)
$(call cmd,offsets,__LINUX_BOUNDS_H__)

#####
# 2) Generate asm-offsets.h
Expand All @@ -49,40 +57,14 @@ always += $(offsets-file)
targets += $(offsets-file)
targets += arch/$(SRCARCH)/kernel/asm-offsets.s


# Default sed regexp - multiline due to syntax constraints
define sed-y
"/^->/{s:->#\(.*\):/* \1 */:; \
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:->::; p;}"
endef

quiet_cmd_offsets = GEN $@
define cmd_offsets
(set -e; \
echo "#ifndef __ASM_OFFSETS_H__"; \
echo "#define __ASM_OFFSETS_H__"; \
echo "/*"; \
echo " * DO NOT MODIFY."; \
echo " *"; \
echo " * This file was generated by Kbuild"; \
echo " *"; \
echo " */"; \
echo ""; \
sed -ne $(sed-y) $<; \
echo ""; \
echo "#endif" ) > $@
endef

# We use internal kbuild rules to avoid the "is up to date" message from make
arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
$(obj)/$(bounds-file) FORCE
$(Q)mkdir -p $(dir $@)
$(call if_changed_dep,cc_s_c)

$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
$(call cmd,offsets)
$(call cmd,offsets,__ASM_OFFSETS_H__)

#####
# 3) Check for missing system calls
Expand Down

0 comments on commit 39664e2

Please sign in to comment.