2 # gen-ver.sh for nomnom.
6 VN
=`cat $1 2>/dev/null`
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"`
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
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."