blob: 044d9011951ad98c737608f535b57bf1ad19a737 [file] [log] [blame]
Martin Rothe2362042015-02-12 19:32:41 -07001#!/bin/sh
2
3# This file is part of the coreboot project.
4#
5# Copyright (C) 2014 Sage Electronic Engineering, LLC.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; version 2 of the License.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
Martin Rothe2362042015-02-12 19:32:41 -070016
Alexander Couzensa74d5692015-03-07 01:50:22 +010017DATE=""
18GITREV=""
19TIMESOURCE=""
Alexander Couzens4dc11972015-06-07 02:07:34 +020020
21export LANG=C
Alexander Couzens946bf932015-06-07 02:10:57 +020022export LC_ALL=C
Alexander Couzens4dc11972015-06-07 02:07:34 +020023export TZ=UTC
24
Patrick Georgic07b7832015-08-09 20:53:59 +020025top=`dirname $0`/../..
26
Martin Roth8ba235e2016-03-12 20:15:18 -070027if [ "${BUILD_TIMELESS}" = "1" ]; then
Nico Huber566dd352016-01-24 16:00:50 +010028 GITREV=Timeless
29 TIMESOURCE="fixed"
30 DATE=0
31elif [ -e "${top}/.git" -a -x "$(command -v git)" ]; then
Martin Roth4af36552015-12-26 19:55:31 -070032 GITREV=$(LANG= git log -1 --format=format:%h)
Alexander Couzensa74d5692015-03-07 01:50:22 +010033 TIMESOURCE=git
34 DATE=$(git log --pretty=format:%ct -1)
35else
36 GITREV=Unknown
Patrick Georgif260f512015-08-09 20:53:16 +020037 TIMESOURCE="date"
38 DATE=$(LANG= LC_ALL=C TZ=UTC date +%s)
Alexander Couzensa74d5692015-03-07 01:50:22 +010039fi
Alexander Couzens8448bd12015-03-07 01:34:55 +010040
Idwer Volleringb5589022015-03-27 00:15:20 +010041our_date() {
42case $(uname) in
zbao5e1fb2d2015-09-09 05:16:40 -040043NetBSD|OpenBSD|DragonFly|FreeBSD|Darwin)
Alexander Couzens4dc11972015-06-07 02:07:34 +020044 date -r $1 $2
Idwer Volleringb5589022015-03-27 00:15:20 +010045 ;;
46*)
Alexander Couzens4dc11972015-06-07 02:07:34 +020047 date -d @$1 $2
Idwer Volleringb5589022015-03-27 00:15:20 +010048esac
49}
50
Martin Rothe2362042015-02-12 19:32:41 -070051#Print out the information that goes into build.h
52printf "/* build system definitions (autogenerated) */\n"
53printf "#ifndef __BUILD_H\n"
54printf "#define __BUILD_H\n\n"
55printf "#define COREBOOT_VERSION %s\n" "\"$KERNELVERSION\""
56
57#See if the build is running in a git repo and the git command is available
Alexander Couzensa74d5692015-03-07 01:50:22 +010058printf "/* timesource: $TIMESOURCE */\n"
59printf "#define COREBOOT_VERSION_TIMESTAMP $DATE\n"
60printf "#define COREBOOT_ORIGIN_GIT_REVISION \"$GITREV\"\n"
Martin Rothe2362042015-02-12 19:32:41 -070061
62printf "#define COREBOOT_EXTRA_VERSION \"%s\"\n" "$COREBOOT_EXTRA_VERSION"
Alexander Couzens4dc11972015-06-07 02:07:34 +020063printf "#define COREBOOT_BUILD \"$(our_date "$DATE")\"\n"
Idwer Volleringb5589022015-03-27 00:15:20 +010064printf "#define COREBOOT_BUILD_YEAR_BCD 0x$(our_date "$DATE" +%y)\n"
65printf "#define COREBOOT_BUILD_MONTH_BCD 0x$(our_date "$DATE" +%m)\n"
66printf "#define COREBOOT_BUILD_DAY_BCD 0x$(our_date "$DATE" +%d)\n"
67printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x$(our_date "$DATE" +%w)\n"
68printf "#define COREBOOT_DMI_DATE \"$(our_date "$DATE" +%m/%d/%Y)\"\n"
Martin Rothe2362042015-02-12 19:32:41 -070069printf "\n"
Idwer Volleringb5589022015-03-27 00:15:20 +010070printf "#define COREBOOT_COMPILE_TIME \"$(our_date "$DATE" +%T)\"\n"
Martin Rothe2362042015-02-12 19:32:41 -070071printf "#endif\n"