3 # gen-ver.sh for libquvi-scripts
4 # Copyright (C) 2011 Toni Gundogdu
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # This library 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 GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 VN
=`cat $1 2>/dev/null`
26 if test -n "$VN"; then
32 gen_version
() # $1=path to top source dir
34 path
=$1 ; [ -z $path ] && path
=.
36 # First check if the version file exists and use its value
37 versionfn
="$path/VERSION"
38 [ -f "$versionfn" ] && from_file
"$versionfn"
40 # If that file is not found, or fails (e.g. empty), parse from m4/version.m4
41 m4="$path/m4/version.m4"
42 VN
=`perl -ne'/(\d+)\.(\d+)\.(\d+)/ && print "$1.$2.$3"' < "$m4"`
45 # Use the "git describe" instead, if .git is present
46 if test -d "$path/.git" -o -f "$path/.git" ; then
47 _VN
=`git describe --match "v[0-9]*" --abbrev=4 HEAD 2>/dev/null`
48 [ -n "$_VN" ] && VN
=$_VN
56 echo "Usage: $0 [-h] [top_srcdir]
57 -h Show this help and exit
58 Run without options to print version. Define top_srcdir if run outside
59 the top source directory."