mb/amd/mandolin: Drop SPD eeproms in devicetree
[coreboot.git] / util / genbuild_h / genbuild_h.sh
blob3df3730ef2b29e54cd2942c5ae98caf2069b3a42
1 #!/bin/sh
3 # SPDX-License-Identifier: GPL-2.0-only
5 DATE=""
6 GITREV=""
7 TIMESOURCE=""
9 export LANG=C
10 export LC_ALL=C
11 export TZ=UTC0
13 XCOMPILE=$1
15 if [ -z "$XCOMPILE" ] || [ "$1" = "--help" ]; then
16 echo "usage: $0 <xcompile>" >&2
17 exit 1
20 # $1: format string
21 get_git_head_data() {
22 LANG= git log --no-show-signature -1 --format="format:$1" 2>/dev/null || \
23 LANG= git log -1 --format="format:$1"
26 if [ "${BUILD_TIMELESS}" = "1" ]; then
27 GITREV=Timeless
28 TIMESOURCE="fixed"
29 DATE=0
30 elif [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
31 GITREV=$(get_git_head_data %h)
32 TIMESOURCE=git
33 DATE=$(get_git_head_data %ct)
34 else
35 GITREV=Unknown
36 TIMESOURCE="date"
37 DATE=$(LANG= LC_ALL=C TZ=UTC0 date +%s)
40 our_date() {
41 case $(uname) in
42 NetBSD|OpenBSD|DragonFly|FreeBSD|Darwin)
43 date -r $1 $2
46 date -d @$1 $2
47 esac
50 IASL=util/crossgcc/xgcc/bin/iasl
51 eval $(grep ^IASL:= "$XCOMPILE" 2>/dev/null | sed s,:=,=,)
53 #Print out the information that goes into build.h
54 printf "/* build system definitions (autogenerated) */\n"
55 printf "#ifndef __BUILD_H\n"
56 printf "#define __BUILD_H\n\n"
57 printf "#define COREBOOT_VERSION %s\n" "\"$KERNELVERSION\""
59 #See if the build is running in a git repo and the git command is available
60 printf "/* timesource: $TIMESOURCE */\n"
61 printf "#define COREBOOT_VERSION_TIMESTAMP $DATE\n"
62 printf "#define COREBOOT_ORIGIN_GIT_REVISION \"$GITREV\"\n"
64 printf "#define COREBOOT_EXTRA_VERSION \"%s\"\n" "$COREBOOT_EXTRA_VERSION"
65 printf "#define COREBOOT_MAJOR_VERSION %d\n#define COREBOOT_MINOR_VERSION %d\n" `git describe --match [0-9].[0-9]* | sed 's/\([0-9]\)\.\([0-9]\+\).*/\1 \2/'`
66 printf "#define COREBOOT_BUILD \"$(our_date "$DATE")\"\n"
67 printf "#define COREBOOT_BUILD_YEAR_BCD 0x$(our_date "$DATE" +%y)\n"
68 printf "#define COREBOOT_BUILD_MONTH_BCD 0x$(our_date "$DATE" +%m)\n"
69 printf "#define COREBOOT_BUILD_DAY_BCD 0x$(our_date "$DATE" +%d)\n"
70 printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x$(our_date "$DATE" +%w)\n"
71 printf "#define COREBOOT_DMI_DATE \"$(our_date "$DATE" +%m/%d/%Y)\"\n"
72 printf "\n"
73 printf "#define COREBOOT_COMPILE_TIME \"$(our_date "$DATE" +%T)\"\n"
74 printf "#define ASL_VERSION 0x%d\n" `$IASL -v | grep version | sed 's/.*version //'`
75 printf "#endif\n"