Martin Roth | e236204 | 2015-02-12 19:32:41 -0700 | [diff] [blame] | 1 | #!/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 Roth | e236204 | 2015-02-12 19:32:41 -0700 | [diff] [blame] | 16 | |
Alexander Couzens | a74d569 | 2015-03-07 01:50:22 +0100 | [diff] [blame] | 17 | DATE="" |
| 18 | GITREV="" |
| 19 | TIMESOURCE="" |
Alexander Couzens | 4dc1197 | 2015-06-07 02:07:34 +0200 | [diff] [blame] | 20 | |
| 21 | export LANG=C |
Alexander Couzens | 946bf93 | 2015-06-07 02:10:57 +0200 | [diff] [blame] | 22 | export LC_ALL=C |
Alexander Couzens | 4dc1197 | 2015-06-07 02:07:34 +0200 | [diff] [blame] | 23 | export TZ=UTC |
| 24 | |
Patrick Georgi | c07b783 | 2015-08-09 20:53:59 +0200 | [diff] [blame] | 25 | top=`dirname $0`/../.. |
| 26 | |
Nico Huber | 566dd35 | 2016-01-24 16:00:50 +0100 | [diff] [blame] | 27 | if [ "${BUILD_TIMELESS}" -eq 1 ]; then |
| 28 | GITREV=Timeless |
| 29 | TIMESOURCE="fixed" |
| 30 | DATE=0 |
| 31 | elif [ -e "${top}/.git" -a -x "$(command -v git)" ]; then |
Martin Roth | 4af3655 | 2015-12-26 19:55:31 -0700 | [diff] [blame] | 32 | GITREV=$(LANG= git log -1 --format=format:%h) |
Alexander Couzens | a74d569 | 2015-03-07 01:50:22 +0100 | [diff] [blame] | 33 | TIMESOURCE=git |
| 34 | DATE=$(git log --pretty=format:%ct -1) |
| 35 | else |
| 36 | GITREV=Unknown |
Patrick Georgi | f260f51 | 2015-08-09 20:53:16 +0200 | [diff] [blame] | 37 | TIMESOURCE="date" |
| 38 | DATE=$(LANG= LC_ALL=C TZ=UTC date +%s) |
Alexander Couzens | a74d569 | 2015-03-07 01:50:22 +0100 | [diff] [blame] | 39 | fi |
Alexander Couzens | 8448bd1 | 2015-03-07 01:34:55 +0100 | [diff] [blame] | 40 | |
Idwer Vollering | b558902 | 2015-03-27 00:15:20 +0100 | [diff] [blame] | 41 | our_date() { |
| 42 | case $(uname) in |
zbao | 5e1fb2d | 2015-09-09 05:16:40 -0400 | [diff] [blame] | 43 | NetBSD|OpenBSD|DragonFly|FreeBSD|Darwin) |
Alexander Couzens | 4dc1197 | 2015-06-07 02:07:34 +0200 | [diff] [blame] | 44 | date -r $1 $2 |
Idwer Vollering | b558902 | 2015-03-27 00:15:20 +0100 | [diff] [blame] | 45 | ;; |
| 46 | *) |
Alexander Couzens | 4dc1197 | 2015-06-07 02:07:34 +0200 | [diff] [blame] | 47 | date -d @$1 $2 |
Idwer Vollering | b558902 | 2015-03-27 00:15:20 +0100 | [diff] [blame] | 48 | esac |
| 49 | } |
| 50 | |
Martin Roth | e236204 | 2015-02-12 19:32:41 -0700 | [diff] [blame] | 51 | #Print out the information that goes into build.h |
| 52 | printf "/* build system definitions (autogenerated) */\n" |
| 53 | printf "#ifndef __BUILD_H\n" |
| 54 | printf "#define __BUILD_H\n\n" |
| 55 | printf "#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 Couzens | a74d569 | 2015-03-07 01:50:22 +0100 | [diff] [blame] | 58 | printf "/* timesource: $TIMESOURCE */\n" |
| 59 | printf "#define COREBOOT_VERSION_TIMESTAMP $DATE\n" |
| 60 | printf "#define COREBOOT_ORIGIN_GIT_REVISION \"$GITREV\"\n" |
Martin Roth | e236204 | 2015-02-12 19:32:41 -0700 | [diff] [blame] | 61 | |
| 62 | printf "#define COREBOOT_EXTRA_VERSION \"%s\"\n" "$COREBOOT_EXTRA_VERSION" |
Alexander Couzens | 4dc1197 | 2015-06-07 02:07:34 +0200 | [diff] [blame] | 63 | printf "#define COREBOOT_BUILD \"$(our_date "$DATE")\"\n" |
Idwer Vollering | b558902 | 2015-03-27 00:15:20 +0100 | [diff] [blame] | 64 | printf "#define COREBOOT_BUILD_YEAR_BCD 0x$(our_date "$DATE" +%y)\n" |
| 65 | printf "#define COREBOOT_BUILD_MONTH_BCD 0x$(our_date "$DATE" +%m)\n" |
| 66 | printf "#define COREBOOT_BUILD_DAY_BCD 0x$(our_date "$DATE" +%d)\n" |
| 67 | printf "#define COREBOOT_BUILD_WEEKDAY_BCD 0x$(our_date "$DATE" +%w)\n" |
| 68 | printf "#define COREBOOT_DMI_DATE \"$(our_date "$DATE" +%m/%d/%Y)\"\n" |
Martin Roth | e236204 | 2015-02-12 19:32:41 -0700 | [diff] [blame] | 69 | printf "\n" |
Idwer Vollering | b558902 | 2015-03-27 00:15:20 +0100 | [diff] [blame] | 70 | printf "#define COREBOOT_COMPILE_TIME \"$(our_date "$DATE" +%T)\"\n" |
Martin Roth | e236204 | 2015-02-12 19:32:41 -0700 | [diff] [blame] | 71 | printf "#endif\n" |