1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4UTS_MACHINE=$1
5CC_VERSION="$2"
6LD=$3
7
8if test -z "$KBUILD_BUILD_USER"; then
9	LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
10else
11	LINUX_COMPILE_BY=$KBUILD_BUILD_USER
12fi
13if test -z "$KBUILD_BUILD_HOST"; then
14	LINUX_COMPILE_HOST=`uname -n`
15else
16	LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST
17fi
18
19LD_VERSION=$(LC_ALL=C $LD -v | head -n1 |
20		sed -e 's/(compatible with [^)]*)//' -e 's/[[:space:]]*$//')
21
22cat <<EOF
23#define UTS_MACHINE		"${UTS_MACHINE}"
24#define LINUX_COMPILE_BY	"${LINUX_COMPILE_BY}"
25#define LINUX_COMPILE_HOST	"${LINUX_COMPILE_HOST}"
26#define LINUX_COMPILER		"${CC_VERSION}, ${LD_VERSION}"
27EOF
28