]> git.ipfire.org Git - people/ms/dnsmasq.git/blame - bld/get-version
Fix new poll() code for helper pipe. Removed CPU-spin.
[people/ms/dnsmasq.git] / bld / get-version
CommitLineData
a4f04ed4
SK
1#!/bin/sh
2
3# Determine the version string to build into a binary.
4# When building in the git repository, we can use the output
5# of "git describe" which gives an unequivocal answer.
6#
7# Failing that, we use the contents of the VERSION file
8# which has a set of references substituted into it by git.
9# If we can find one which matches $v[0-9].* then we assume it's
10# a version-number tag, else we just use the whole string.
00acd063
SK
11# If there is more than one v[0-9].* tag, sort them and use the
12# first. This favours, eg v2.63 over 2.63rc6.
a4f04ed4 13
8efd731c
JL
14if which git >/dev/null 2>&1 && \
15 ([ -d $1/.git ] || grep '^gitdir:' $1/.git >/dev/null 2>&1); then
16 cd $1; git describe | sed 's/^v//'
fdacfb01 17elif grep '\$Format:%d\$' $1/VERSION >/dev/null 2>&1; then
98d76a03
SK
18# unsubstituted VERSION, but no git available.
19 echo UNKNOWN
a4f04ed4 20else
990123a9 21 vers=`cat $1/VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep ^v[0-9]`
a4f04ed4
SK
22
23 if [ $? -eq 0 ]; then
f4f40077 24 echo "${vers}" | sort -r | head -n 1 | sed 's/^v//'
a4f04ed4 25 else
fdacfb01 26 cat $1/VERSION
a4f04ed4
SK
27 fi
28fi
29
30exit 0
31