Skip to content

Commit 53e6892

Browse files
committed
kbuild: Allow to override LINUX_COMPILE_BY and LINUX_COMPILE_HOST macros
Make it possible to override the user@host string displayed during boot and in /proc/version by the environment variables KBUILD_BUILD_USER and KBUILD_BUILD_HOST. Several distributions patch scripts/mkcompile_h to achieve this, so let's provide an official way. Also, document the KBUILD_BUILD_TIMESTAMP variable while at it. Signed-off-by: Michal Marek <[email protected]>
1 parent 061296d commit 53e6892

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Documentation/kbuild/kbuild.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,15 @@ KBUILD_ENABLE_EXTRA_GCC_CHECKS
201201
--------------------------------------------------
202202
If enabled over the make command line with "W=1", it turns on additional
203203
gcc -W... options for more extensive build-time checking.
204+
205+
KBUILD_BUILD_TIMESTAMP
206+
--------------------------------------------------
207+
Setting this to a date string overrides the timestamp used in the
208+
UTS_VERSION definition (uname -v in the running kernel). The default value
209+
is the output of the date command at one point during build.
210+
211+
KBUILD_BUILD_USER, KBUILD_BUILD_HOST
212+
--------------------------------------------------
213+
These two variables allow to override the user@host string displayed during
214+
boot and in /proc/version. The default value is the output of the commands
215+
whoami and host, respectively.

scripts/mkcompile_h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then
4242
else
4343
TIMESTAMP=$KBUILD_BUILD_TIMESTAMP
4444
fi
45+
if test -z "$KBUILD_BUILD_USER"; then
46+
LINUX_COMPILE_BY=`whoami`
47+
else
48+
LINUX_COMPILE_BY=$KBUILD_BUILD_USER
49+
fi
50+
if test -z "$KBUILD_BUILD_HOST"; then
51+
LINUX_COMPILE_HOST=`hostname`
52+
else
53+
LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST
54+
fi
4555

4656
UTS_VERSION="#$VERSION"
4757
CONFIG_FLAGS=""
@@ -63,8 +73,8 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
6373

6474
echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
6575

66-
echo \#define LINUX_COMPILE_BY \"`whoami`\"
67-
echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
76+
echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
77+
echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
6878

6979
echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\"
7080
) > .tmpcompile

0 commit comments

Comments
 (0)