Liam Girdwood | b14e852 | 2018-01-10 17:36:41 +0000 | [diff] [blame] | 1 | |
| 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 |
| 7 | if [ $# -eq 0 ]; then |
| 8 | DIR=`pwd` |
| 9 | else |
| 10 | DIR=$1 |
| 11 | fi |
| 12 | |
Liam Girdwood | 856f768 | 2018-03-21 09:42:02 +0000 | [diff] [blame] | 13 | # get version from git tag |
| 14 | GIT_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. |
| 18 | if [ $(expr match $GIT_TAG 'SOF_FW_[A-Z][A-Z][A-Z]_' ) -eq 11 ]; then |
| 19 | VER=`echo $GIT_TAG | cut -d_ -f4` |
| 20 | else |
| 21 | VER=$GIT_TAG |
| 22 | fi |
| 23 | |
Liam Girdwood | 83fec15 | 2018-01-11 12:10:03 +0000 | [diff] [blame] | 24 | # create git version if we are a git repo or git worktree |
| 25 | if [ -e $DIR/.git -o -d $DIR/.git ]; then |
Liam Girdwood | b14e852 | 2018-01-10 17:36:41 +0000 | [diff] [blame] | 26 | # version for make dist |
Liam Girdwood | 856f768 | 2018-03-21 09:42:02 +0000 | [diff] [blame] | 27 | echo $VER > $DIR/.version |
| 28 | echo $VER > $DIR/.tarball-version |
Liam Girdwood | b14e852 | 2018-01-10 17:36:41 +0000 | [diff] [blame] | 29 | |
| 30 | # git commit for IPC |
Pierre-Louis Bossart | 81708a5 | 2018-04-04 18:46:50 -0500 | [diff] [blame^] | 31 | echo "#define SOF_TAG \"`git log --pretty=format:\"%h\" -1 | cut -c1-5`\"" > $DIR/src/include/version.h |
Liam Girdwood | b14e852 | 2018-01-10 17:36:41 +0000 | [diff] [blame] | 32 | else |
Pierre-Louis Bossart | 81708a5 | 2018-04-04 18:46:50 -0500 | [diff] [blame^] | 33 | echo "#define SOF_TAG \"0\"" > $DIR/src/include/version.h |
Liam Girdwood | b14e852 | 2018-01-10 17:36:41 +0000 | [diff] [blame] | 34 | fi |
| 35 | |
| 36 | # build counter |
| 37 | if [ -e $DIR/.build ]; then |
| 38 | num=$((`cat $DIR/.build` + 1)) |
| 39 | else |
| 40 | num=0 |
| 41 | fi |
| 42 | |
| 43 | # save and insert build counter |
| 44 | echo $num > $DIR/.build |
Pierre-Louis Bossart | 81708a5 | 2018-04-04 18:46:50 -0500 | [diff] [blame^] | 45 | echo "#define SOF_BUILD $num" >> $DIR/src/include/version.h |
Liam Girdwood | b14e852 | 2018-01-10 17:36:41 +0000 | [diff] [blame] | 46 | |
| 47 | #echo version for AC_INIT |
| 48 | if [ -e $DIR/.version ]; then |
Liam Girdwood | 93d62e5 | 2018-01-10 20:26:08 +0000 | [diff] [blame] | 49 | 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 Girdwood | b14e852 | 2018-01-10 17:36:41 +0000 | [diff] [blame] | 50 | fi |