Blame view
scripts/mkcompile_h
2.57 KB
17c5ca988 kbuild: mkcompile... |
1 |
#!/bin/sh |
b24413180 License cleanup: ... |
2 |
# SPDX-License-Identifier: GPL-2.0 |
17c5ca988 kbuild: mkcompile... |
3 |
|
1da177e4c Linux-2.6.12-rc2 |
4 5 6 |
TARGET=$1 ARCH=$2 SMP=$3 |
bd5bdd875 kbuild: "PREEMPT"... |
7 |
PREEMPT=$4 |
4b950bb9a Kbuild: Handle PR... |
8 9 |
PREEMPT_RT=$5 CC=$6 |
1da177e4c Linux-2.6.12-rc2 |
10 |
|
d03fab43c kbuild: kill outp... |
11 |
vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; } |
1da177e4c Linux-2.6.12-rc2 |
12 13 14 15 16 |
# 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" |
264a26838 kbuild: move auto... |
17 |
if [ -r $TARGET -a ! -O include/generated/autoconf.h ]; then |
d03fab43c kbuild: kill outp... |
18 |
vecho " SKIPPED $TARGET" |
1da177e4c Linux-2.6.12-rc2 |
19 20 21 22 23 |
exit 0 fi # Do not expand names set -f |
87c94bfb8 kbuild: override ... |
24 25 26 27 28 |
# Fix the language to get consistent output LC_ALL=C export LC_ALL if [ -z "$KBUILD_BUILD_VERSION" ]; then |
37131ec4f kbuild: mkcompile... |
29 |
VERSION=$(cat .version 2>/dev/null || echo 1) |
1da177e4c Linux-2.6.12-rc2 |
30 |
else |
87c94bfb8 kbuild: override ... |
31 |
VERSION=$KBUILD_BUILD_VERSION |
1da177e4c Linux-2.6.12-rc2 |
32 |
fi |
87c94bfb8 kbuild: override ... |
33 34 35 36 37 |
if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then TIMESTAMP=`date` else TIMESTAMP=$KBUILD_BUILD_TIMESTAMP fi |
53e6892c0 kbuild: Allow to ... |
38 |
if test -z "$KBUILD_BUILD_USER"; then |
f07726048 Fix handling of b... |
39 |
LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/') |
53e6892c0 kbuild: Allow to ... |
40 41 42 43 44 45 46 47 |
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 |
1da177e4c Linux-2.6.12-rc2 |
48 49 |
UTS_VERSION="#$VERSION" |
bd5bdd875 kbuild: "PREEMPT"... |
50 51 52 |
CONFIG_FLAGS="" if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi |
4b950bb9a Kbuild: Handle PR... |
53 |
if [ -n "$PREEMPT_RT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT_RT"; fi |
87c94bfb8 kbuild: override ... |
54 |
UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP" |
1da177e4c Linux-2.6.12-rc2 |
55 56 57 58 |
# Truncate to maximum length UTS_LEN=64 |
17c5ca988 kbuild: mkcompile... |
59 |
UTS_TRUNCATE="cut -b -$UTS_LEN" |
1da177e4c Linux-2.6.12-rc2 |
60 61 |
# Generate a temporary compile.h |
b79c6aa6a kbuild: remove un... |
62 |
{ echo /\* This file is auto generated, version $VERSION \*/ |
bd5bdd875 kbuild: "PREEMPT"... |
63 |
if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi |
38385f8f0 kbuild: trivial -... |
64 |
|
1da177e4c Linux-2.6.12-rc2 |
65 66 67 |
echo \#define UTS_MACHINE \"$ARCH\" echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" |
53e6892c0 kbuild: Allow to ... |
68 69 |
echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" |
1da177e4c Linux-2.6.12-rc2 |
70 |
|
adcc3f7ce scripts/mkcompile... |
71 |
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\" |
b79c6aa6a kbuild: remove un... |
72 |
} > .tmpcompile |
1da177e4c Linux-2.6.12-rc2 |
73 74 75 76 77 78 |
# 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 |
38385f8f0 kbuild: trivial -... |
79 |
# causing compile.h to be updated (including date/time) due to the |
1da177e4c Linux-2.6.12-rc2 |
80 81 82 83 |
# changed comment in the # first line. if [ -r $TARGET ] && \ |
061296dc2 kbuild: Drop unus... |
84 85 |
grep -v 'UTS_VERSION' $TARGET > .tmpver.1 && \ grep -v 'UTS_VERSION' .tmpcompile > .tmpver.2 && \ |
1da177e4c Linux-2.6.12-rc2 |
86 87 88 |
cmp -s .tmpver.1 .tmpver.2; then rm -f .tmpcompile else |
d03fab43c kbuild: kill outp... |
89 |
vecho " UPD $TARGET" |
1da177e4c Linux-2.6.12-rc2 |
90 91 92 |
mv -f .tmpcompile $TARGET fi rm -f .tmpver.1 .tmpver.2 |