Commit 6374f649 authored by Sam Ravnborg's avatar Sam Ravnborg

kbuild: Do not clutter output with make -jN

Added a new rule filechk used to check when a generated file
actually is changed. If there is no actual changes the file
is left without updating the timestamp.
When building a kernel from scratch two printouts occurs:
  CHK      file-to-generate
  UPD      file-to-generate

The first line tell that kbuild checks the file, second line tell that
the file is being updated (or created).
On successive runs only the first line is printed.
Output is the same in verbose and non-verbose mode.

This replaces the former update-if-changed which has been deleted.
generate-asm-offsets.h has been renamed as well.
All users are updated in next patch.
Output when generating compile.h follow above style
parent 5667cc2b
...@@ -478,17 +478,19 @@ include/linux/autoconf.h: .config scripts/fixdep ...@@ -478,17 +478,19 @@ include/linux/autoconf.h: .config scripts/fixdep
uts_len := 64 uts_len := 64
include/linux/version.h: Makefile define filechk_version.h
@if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \ if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \
echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
exit 1; \ exit 1; \
fi; fi;
@echo -n ' GEN $@' (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
@(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \ echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \ echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'; \
) > $@.tmp )
@$(update-if-changed) endef
include/linux/version.h: Makefile
$(call filechk,version.h)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
...@@ -557,7 +559,7 @@ endif # CONFIG_MODULES ...@@ -557,7 +559,7 @@ endif # CONFIG_MODULES
# Generate asm-offsets.h # Generate asm-offsets.h
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
define generate-asm-offsets.h define filechk_gen-asm-offsets
(set -e; \ (set -e; \
echo "#ifndef __ASM_OFFSETS_H__"; \ echo "#ifndef __ASM_OFFSETS_H__"; \
echo "#define __ASM_OFFSETS_H__"; \ echo "#define __ASM_OFFSETS_H__"; \
...@@ -573,7 +575,6 @@ define generate-asm-offsets.h ...@@ -573,7 +575,6 @@ define generate-asm-offsets.h
echo "#endif" ) echo "#endif" )
endef endef
else # ifdef include_config else # ifdef include_config
ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),) ifeq ($(filter-out $(noconfig_targets),$(MAKECMDGOALS)),)
...@@ -881,13 +882,27 @@ if_changed_rule = $(if $(strip $? \ ...@@ -881,13 +882,27 @@ if_changed_rule = $(if $(strip $? \
cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
define update-if-changed # filechk is used to check if the content of a generated file is updated.
if [ -r $@ ] && cmp -s $@ $@.tmp; then \ # Sample usage:
echo ' (unchanged)'; \ # define filechk_sample
rm -f $@.tmp; \ # echo $KERNELRELEASE
else \ # endef
echo ' (updated)'; \ # version.h : Makefile
mv -f $@.tmp $@; \ # $(call filechk,sample)
# The rule defined shall write to stdout the content of the new file.
# The existing file will be compared with the new one.
# - If no file exist it is created
# - If the content differ the new file is used
# - If they are equal no change, and no timestamp update
define filechk
@echo ' CHK $@';
@set -e; $(filechk_$(1)) > $@.tmp
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
rm -f $@.tmp; \
else \
echo ' UPD $@'; \
mv -f $@.tmp $@; \
fi fi
endef endef
......
...@@ -21,5 +21,5 @@ $(obj)/version.o: include/linux/compile.h ...@@ -21,5 +21,5 @@ $(obj)/version.o: include/linux/compile.h
# actual file if its content has changed. # actual file if its content has changed.
include/linux/compile.h: FORCE include/linux/compile.h: FORCE
@echo -n ' GEN $@' @echo ' CHK $@'
@sh $(srctree)/scripts/mkcompile_h $@ "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)" @sh $(srctree)/scripts/mkcompile_h $@ "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)"
...@@ -10,7 +10,7 @@ CC=$4 ...@@ -10,7 +10,7 @@ CC=$4
# do "compiled by root" # do "compiled by root"
if [ -r $TARGET -a ! -O include/linux/autoconf.h ]; then if [ -r $TARGET -a ! -O include/linux/autoconf.h ]; then
echo ' (not modified)' echo " SKIPPED $TARGET"
exit 0 exit 0
fi fi
...@@ -70,10 +70,9 @@ if [ -r $TARGET ] && \ ...@@ -70,10 +70,9 @@ if [ -r $TARGET ] && \
grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \ grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \
grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \ grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \
cmp -s .tmpver.1 .tmpver.2; then cmp -s .tmpver.1 .tmpver.2; then
echo ' (unchanged)'
rm -f .tmpcompile rm -f .tmpcompile
else else
echo ' (updated)' echo " UPD $TARGET"
mv -f .tmpcompile $TARGET mv -f .tmpcompile $TARGET
fi fi
#rm -f .tmpver.1 .tmpver.2 rm -f .tmpver.1 .tmpver.2
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment