Commit 32ec768d authored by Kai Germaschewski's avatar Kai Germaschewski

Makefile cleanup: Don't rebuild init/version.o on each build

init/version.o includes include/linux/compile.h. As compile.h was
regenerated each time make was run, init/version.o was recompiled each
time.

To avoid this, use the following solution: Generate a temporary new
compile.h, and only replace the old one if the new one is different.

We consider the files different if more than just date/time changed, since
otherwise we would have to rebuild every time anyway.

Still, the two files turned out to be different all the time, as we put
a generation number into them which is incremented at each invocation of 
"make". The generation number update is now only done when the kernel
config changes, which makes more sense, anyway.

So, the UTS_VERSION and generation number now relate to the time the 
kernel was configured, not the time the actual "make vmlinux" was run, 
which should be fine.
parent 29f3df7e
...@@ -56,7 +56,7 @@ ifeq (.config,$(wildcard .config)) ...@@ -56,7 +56,7 @@ ifeq (.config,$(wildcard .config))
include .config include .config
ifeq (.depend,$(wildcard .depend)) ifeq (.depend,$(wildcard .depend))
include .depend include .depend
do-it-all: Version vmlinux do-it-all: vmlinux
else else
CONFIGURATION = depend CONFIGURATION = depend
do-it-all: depend do-it-all: depend
...@@ -161,9 +161,6 @@ export NETWORKS DRIVERS LIBS HEAD LDFLAGS LINKFLAGS MAKEBOOT ASFLAGS ...@@ -161,9 +161,6 @@ export NETWORKS DRIVERS LIBS HEAD LDFLAGS LINKFLAGS MAKEBOOT ASFLAGS
# Build vmlinux / boot target # Build vmlinux / boot target
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
Version: dummy
@rm -f include/linux/compile.h
boot: vmlinux boot: vmlinux
@$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" -C arch/$(ARCH)/boot @$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" -C arch/$(ARCH)/boot
...@@ -216,17 +213,15 @@ symlinks: ...@@ -216,17 +213,15 @@ symlinks:
include/config/MARKER: scripts/split-include include/linux/autoconf.h include/config/MARKER: scripts/split-include include/linux/autoconf.h
scripts/split-include include/linux/autoconf.h include/config scripts/split-include include/linux/autoconf.h include/config
@ touch include/config/MARKER @ touch include/config/MARKER
. scripts/mkversion > .tmpversion
@mv -f .tmpversion .version
# Generate some files # Generate some files
$(TOPDIR)/include/linux/version.h: include/linux/version.h $(TOPDIR)/include/linux/version.h: include/linux/version.h
$(TOPDIR)/include/linux/compile.h: include/linux/compile.h $(TOPDIR)/include/linux/compile.h: include/linux/compile.h
newversion: include/linux/compile.h: $(CONFIGURATION) include/linux/version.h
. scripts/mkversion > .tmpversion
@mv -f .tmpversion .version
include/linux/compile.h: $(CONFIGURATION) include/linux/version.h newversion
@echo Generating $@ @echo Generating $@
@. scripts/mkcompile_h $@ "$(ARCH)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)" @. scripts/mkcompile_h $@ "$(ARCH)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)"
......
...@@ -5,7 +5,9 @@ CC=$4 ...@@ -5,7 +5,9 @@ CC=$4
# Generate a temporary compile.h # Generate a temporary compile.h
( echo \#define UTS_MACHINE \"$ARCH\" ( echo /\* This file is auto generated, version `cat .version` \*/
echo \#define UTS_MACHINE \"$ARCH\"
echo -n \#define UTS_VERSION \"\#`cat .version` echo -n \#define UTS_VERSION \"\#`cat .version`
if [ -n "$SMP" ] ; then echo -n " SMP"; fi if [ -n "$SMP" ] ; then echo -n " SMP"; fi
...@@ -26,4 +28,22 @@ CC=$4 ...@@ -26,4 +28,22 @@ CC=$4
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -1`\" echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -1`\"
) > .tmpcompile ) > .tmpcompile
mv -f .tmpcompile $TARGET # Only replace the real compile.h if the new one is different,
# in order to preserve the timestamp and avoid unnecessary
# recompilations.
# We don't consider the file changed if only the date/time changed.
# A kernel config change will increase the generation number, thus
# causing compile.h to be updated (including date/time) due to the
# changed comment in the
# first line.
if [ -r $TARGET ] && \
grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \
grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \
cmp -s .tmpver.1 .tmpver.2; then
echo $TARGET is unchanged;
rm -f .tmpcompile
else
mv -f .tmpcompile $TARGET
fi
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