blob: 815c0b80299c176525c2ff75ecbbaaabfa58a40f [file] [log] [blame]
Liam Girdwoodb14e8522018-01-10 17:36:41 +00001
2# version for configure, make dist and FW etc
3# usage "version.sh dir"
4# Where dir is the top level directory path.
5
6# use pwd is no path argument is given
7if [ $# -eq 0 ]; then
8 DIR=`pwd`
9else
10 DIR=$1
11fi
12
Liam Girdwood856f7682018-03-21 09:42:02 +000013# get version from git tag
14GIT_TAG=`git describe --abbrev=4`
15
16# Some releases have a SOF_FW_XXX_ prefix on the tag and this prefix
17# must be stripped for usage in version.h. i.e. we just need the number.
18if [ $(expr match $GIT_TAG 'SOF_FW_[A-Z][A-Z][A-Z]_' ) -eq 11 ]; then
19 VER=`echo $GIT_TAG | cut -d_ -f4`
20else
21 VER=$GIT_TAG
22fi
23
Liam Girdwood83fec152018-01-11 12:10:03 +000024# create git version if we are a git repo or git worktree
25if [ -e $DIR/.git -o -d $DIR/.git ]; then
Liam Girdwoodb14e8522018-01-10 17:36:41 +000026# version for make dist
Liam Girdwood856f7682018-03-21 09:42:02 +000027 echo $VER > $DIR/.version
28 echo $VER > $DIR/.tarball-version
Liam Girdwoodb14e8522018-01-10 17:36:41 +000029
30 # git commit for IPC
Pierre-Louis Bossart81708a52018-04-04 18:46:50 -050031 echo "#define SOF_TAG \"`git log --pretty=format:\"%h\" -1 | cut -c1-5`\"" > $DIR/src/include/version.h
Liam Girdwoodb14e8522018-01-10 17:36:41 +000032else
Pierre-Louis Bossart81708a52018-04-04 18:46:50 -050033 echo "#define SOF_TAG \"0\"" > $DIR/src/include/version.h
Liam Girdwoodb14e8522018-01-10 17:36:41 +000034fi
35
36# build counter
37if [ -e $DIR/.build ]; then
38 num=$((`cat $DIR/.build` + 1))
39else
40 num=0
41fi
42
43# save and insert build counter
44echo $num > $DIR/.build
Pierre-Louis Bossart81708a52018-04-04 18:46:50 -050045echo "#define SOF_BUILD $num" >> $DIR/src/include/version.h
Liam Girdwoodb14e8522018-01-10 17:36:41 +000046
47#echo version for AC_INIT
48if [ -e $DIR/.version ]; then
Liam Girdwood93d62e52018-01-10 20:26:08 +000049 echo -n `cat $DIR/.version | cut -dv -f2 | cut -d. -f1`.`cat $DIR/.version | cut -d. -f2 | cut -d- -f1`.`cat $DIR/.version | cut -d. -f3 | cut -d- -f1`
Liam Girdwoodb14e8522018-01-10 17:36:41 +000050fi