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