Add --verbosity to manual
[quvi-tool.git] / gen-ver.sh
blob065d9a3fd9c208c321e7c25b41df1ef07d7773ea
1 #!/bin/sh
2 # gen-ver.sh for quvi.
4 from_file()
6 VN=`cat $1 2>/dev/null`
7 if test -n "$VN"; then
8 echo $VN
9 exit 0
13 gen_version() # $1=path to top source dir
15 path=$1 ; [ -z $path ] && path=.
17 # First check if the version file exists and use its value
18 versionfn="$path/VERSION"
19 [ -f "$versionfn" ] && from_file "$versionfn"
21 # If that file is not found, or fails (e.g. empty), parse from m4/version.m4
22 m4="$path/m4/version.m4"
23 VN=`perl -ne'/(\d+)\.(\d+)\.(\d+)/ && print "$1.$2.$3"' < "$m4"`
24 [ -z $VN ] && exit $?
26 # Use the "git describe" instead, if .git is present
27 if test -d "$path/.git" -o -f "$path/.git" ; then
28 _VN=`git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null`
29 [ -n "$_VN" ] && VN=$_VN
32 echo $VN
35 help()
37 echo "Usage: $0 [-h] [top_srcdir]
38 -h Show this help and exit
39 Run without options to print version. Define top_srcdir if run outside
40 the top source directory."
41 exit 0
44 while [ $# -gt 0 ]
46 case "$1" in
47 -h) help;;
48 *) break;;
49 esac
50 shift
51 done
53 gen_version $1