mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-18 08:35:08 +08:00
f84fdf8df1
This reverts a very old commit, which dates back to the pre-git era: |commit 5d1cfb5b12f72145d30ba0f53c9f238144b122b8 |Author: Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> |Date: Sat Jul 27 02:53:19 2002 -0500 | | kbuild: Fix compiling/installing as different users | | "make bzImage && sudo make install" had the problem that during | the "sudo make install" the build system would notice that the information | in include/linux/compile.h is not accurate (it says "compiled by <user>", | but we are root), thus causing compile.h to be updated and leading to | some recompiles. | | We now only update "compile.h" if the current user is the owner of | include/linux/autoconf.h, i.e. the user who did the "make *config". So the | above sequence will correctly state "compiled by <user>". | |diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h |index 6313db96172..cd956380978 100755 |--- a/scripts/mkcompile_h |+++ b/scripts/mkcompile_h |@@ -3,6 +3,17 @@ ARCH=$2 | SMP=$3 | CC=$4 | |+# If compile.h exists already and we don't own autoconf.h |+# (i.e. we're not the same user who did make *config), don't |+# modify compile.h |+# So "sudo make install" won't change the "compiled by <user>" |+# do "compiled by root" |+ |+if [ -r $TARGET -a ! -O ../include/linux/autoconf.h ]; then |+ echo ' (not modified)' |+ exit 0 |+fi |+ | if [ -r ../.version ]; then | VERSION=`cat ../.version` | else The 'make bzImage && sudo make install' problem no longer happens because commit1648e4f805
("x86, kbuild: make "make install" not depend on vmlinux") fixed the root cause. Commit19514fc665
("arm, kbuild: make "make install" not depend on vmlinux") fixed the similar issue on ARM, with detailed explanation. So, the rule is that the installation targets should never trigger the builds of any build artifact. By following it, this check is unneeded. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
86 lines
2.2 KiB
Bash
Executable File
86 lines
2.2 KiB
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
TARGET=$1
|
|
ARCH=$2
|
|
SMP=$3
|
|
PREEMPT=$4
|
|
PREEMPT_RT=$5
|
|
CC=$6
|
|
|
|
vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
|
|
|
|
# Do not expand names
|
|
set -f
|
|
|
|
# Fix the language to get consistent output
|
|
LC_ALL=C
|
|
export LC_ALL
|
|
|
|
if [ -z "$KBUILD_BUILD_VERSION" ]; then
|
|
VERSION=$(cat .version 2>/dev/null || echo 1)
|
|
else
|
|
VERSION=$KBUILD_BUILD_VERSION
|
|
fi
|
|
|
|
if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then
|
|
TIMESTAMP=`date`
|
|
else
|
|
TIMESTAMP=$KBUILD_BUILD_TIMESTAMP
|
|
fi
|
|
if test -z "$KBUILD_BUILD_USER"; then
|
|
LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
|
|
else
|
|
LINUX_COMPILE_BY=$KBUILD_BUILD_USER
|
|
fi
|
|
if test -z "$KBUILD_BUILD_HOST"; then
|
|
LINUX_COMPILE_HOST=`hostname`
|
|
else
|
|
LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST
|
|
fi
|
|
|
|
UTS_VERSION="#$VERSION"
|
|
CONFIG_FLAGS=""
|
|
if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi
|
|
if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi
|
|
if [ -n "$PREEMPT_RT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT_RT"; fi
|
|
|
|
# Truncate to maximum length
|
|
UTS_LEN=64
|
|
UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)"
|
|
|
|
# Generate a temporary compile.h
|
|
|
|
{ echo /\* This file is auto generated, version $VERSION \*/
|
|
if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi
|
|
|
|
echo \#define UTS_MACHINE \"$ARCH\"
|
|
|
|
echo \#define UTS_VERSION \"$UTS_VERSION\"
|
|
|
|
printf '#define LINUX_COMPILE_BY "%s"\n' "$LINUX_COMPILE_BY"
|
|
echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\"
|
|
|
|
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\"
|
|
} > .tmpcompile
|
|
|
|
# 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' $TARGET > .tmpver.1 && \
|
|
grep -v 'UTS_VERSION' .tmpcompile > .tmpver.2 && \
|
|
cmp -s .tmpver.1 .tmpver.2; then
|
|
rm -f .tmpcompile
|
|
else
|
|
vecho " UPD $TARGET"
|
|
mv -f .tmpcompile $TARGET
|
|
fi
|
|
rm -f .tmpver.1 .tmpver.2
|