Blame view
scripts/mkcompile_h
2.48 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 |
|
1da177e4c
|
12 13 |
# Do not expand names set -f |
87c94bfb8
|
14 15 16 17 18 |
# Fix the language to get consistent output LC_ALL=C export LC_ALL if [ -z "$KBUILD_BUILD_VERSION" ]; then |
37131ec4f
|
19 |
VERSION=$(cat .version 2>/dev/null || echo 1) |
1da177e4c
|
20 |
else |
87c94bfb8
|
21 |
VERSION=$KBUILD_BUILD_VERSION |
1da177e4c
|
22 |
fi |
87c94bfb8
|
23 24 25 26 27 |
if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then TIMESTAMP=`date` else TIMESTAMP=$KBUILD_BUILD_TIMESTAMP fi |
53e6892c0
|
28 |
if test -z "$KBUILD_BUILD_USER"; then |
f07726048
|
29 |
LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/') |
53e6892c0
|
30 31 32 33 |
else LINUX_COMPILE_BY=$KBUILD_BUILD_USER fi if test -z "$KBUILD_BUILD_HOST"; then |
1e66d50ad
|
34 |
LINUX_COMPILE_HOST=`uname -n` |
53e6892c0
|
35 36 37 |
else LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST fi |
1da177e4c
|
38 39 |
UTS_VERSION="#$VERSION" |
bd5bdd875
|
40 41 42 |
CONFIG_FLAGS="" if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi |
4b950bb9a
|
43 |
if [ -n "$PREEMPT_RT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT_RT"; fi |
1da177e4c
|
44 45 |
# Truncate to maximum length |
1da177e4c
|
46 |
UTS_LEN=64 |
e8193650b
|
47 |
UTS_VERSION="$(echo $UTS_VERSION $CONFIG_FLAGS $TIMESTAMP | cut -b -$UTS_LEN)" |
1da177e4c
|
48 49 |
# Generate a temporary compile.h |
b79c6aa6a
|
50 |
{ echo /\* This file is auto generated, version $VERSION \*/ |
bd5bdd875
|
51 |
if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi |
38385f8f0
|
52 |
|
1da177e4c
|
53 |
echo \#define UTS_MACHINE \"$ARCH\" |
e8193650b
|
54 |
echo \#define UTS_VERSION \"$UTS_VERSION\" |
1da177e4c
|
55 |
|
c8f3dea90
|
56 57 |
printf '#define LINUX_COMPILE_BY "%s" ' "$LINUX_COMPILE_BY" |
e8193650b
|
58 |
echo \#define LINUX_COMPILE_HOST \"$LINUX_COMPILE_HOST\" |
1da177e4c
|
59 |
|
4dcc9a884
|
60 61 62 63 |
LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \ | sed 's/[[:space:]]*$//') printf '#define LINUX_COMPILER "%s" ' "$CC_VERSION, $LD_VERSION" |
b79c6aa6a
|
64 |
} > .tmpcompile |
1da177e4c
|
65 66 67 68 |
# Only replace the real compile.h if the new one is different, # in order to preserve the timestamp and avoid unnecessary # recompilations. |
a979522a1
|
69 70 71 |
# We don't consider the file changed if only the date/time changed, # unless KBUILD_BUILD_TIMESTAMP was explicitly set (e.g. for # reproducible builds with that value referring to a commit timestamp). |
1da177e4c
|
72 |
# A kernel config change will increase the generation number, thus |
38385f8f0
|
73 |
# causing compile.h to be updated (including date/time) due to the |
1da177e4c
|
74 75 |
# changed comment in the # first line. |
a979522a1
|
76 77 78 79 80 |
if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then IGNORE_PATTERN="UTS_VERSION" else IGNORE_PATTERN="NOT_A_PATTERN_TO_BE_MATCHED" fi |
1da177e4c
|
81 |
if [ -r $TARGET ] && \ |
a979522a1
|
82 83 |
grep -v $IGNORE_PATTERN $TARGET > .tmpver.1 && \ grep -v $IGNORE_PATTERN .tmpcompile > .tmpver.2 && \ |
1da177e4c
|
84 85 86 |
cmp -s .tmpver.1 .tmpver.2; then rm -f .tmpcompile else |
c39013ee6
|
87 |
echo " UPD $TARGET" |
1da177e4c
|
88 89 90 |
mv -f .tmpcompile $TARGET fi rm -f .tmpver.1 .tmpver.2 |