Skip to content

Commit b10fdee

Browse files
committed
kbuild: check sha1sum just once for each atomic header
It is unneeded to check the sha1sum every time. Create the timestamp files to manage it. Add '.' to clean-dirs because 'make clean' must visit ./Kbuild to clean up the timestamp files. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent a3c4d4a commit b10fdee

File tree

3 files changed

+25
-43
lines changed

3 files changed

+25
-43
lines changed

Kbuild

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,32 @@ PHONY += missing-syscalls
4343
missing-syscalls: scripts/checksyscalls.sh $(offsets-file)
4444
$(call cmd,syscalls)
4545

46-
# Check atomic headers are up-to-date
47-
48-
quiet_cmd_atomics = CALL $<
49-
cmd_atomics = $(CONFIG_SHELL) $<
50-
51-
PHONY += old-atomics
52-
old-atomics: scripts/atomic/check-atomics.sh
53-
$(call cmd,atomics)
46+
# Check the manual modification of atomic headers
47+
48+
quiet_cmd_check_sha1 = CHKSHA1 $<
49+
cmd_check_sha1 = \
50+
if ! command -v sha1sum >/dev/null; then \
51+
echo "warning: cannot check the header due to sha1sum missing"; \
52+
exit 0; \
53+
fi; \
54+
if [ "$$(sed -n '$$s:// ::p' $<)" != \
55+
"$$(sed '$$d' $< | sha1sum | sed 's/ .*//')" ]; then \
56+
echo "error: $< has been modified." >&2; \
57+
exit 1; \
58+
fi; \
59+
touch $@
60+
61+
atomic-checks += $(addprefix $(obj)/.checked-, \
62+
atomic-arch-fallback.h \
63+
atomic-instrumented.h \
64+
atomic-long.h)
65+
66+
targets += $(atomic-checks)
67+
$(atomic-checks): $(obj)/.checked-%: include/linux/atomic/% FORCE
68+
$(call if_changed,check_sha1)
5469

5570
# A phony target that depends on all the preparation targets
5671

5772
PHONY += prepare
58-
prepare: $(offsets-file) missing-syscalls old-atomics
73+
prepare: $(offsets-file) missing-syscalls $(atomic-checks)
5974
@:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ vmlinux-dirs := $(patsubst %/,%,$(filter %/, \
11101110
$(libs-y) $(libs-m)))
11111111

11121112
build-dirs := $(vmlinux-dirs)
1113-
clean-dirs := $(sort $(vmlinux-dirs) Documentation \
1113+
clean-dirs := $(sort $(vmlinux-dirs) Documentation . \
11141114
$(patsubst %/,%,$(filter %/, $(core-) \
11151115
$(drivers-) $(libs-))))
11161116

scripts/atomic/check-atomics.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)