4 ### Make autoconf-like substitutions in files
6 ### (c) 2008 Mark Wooding
9 ###----- Licensing notice ---------------------------------------------------
11 ### This file is part of the Common Files Distribution (`common').
13 ### `Common' is free software; you can redistribute it and/or modify
14 ### it under the terms of the GNU General Public License as published by
15 ### the Free Software Foundation; either version 2 of the License, or
16 ### (at your option) any later version.
18 ### `Common' is distributed in the hope that it will be useful,
19 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ### GNU General Public License for more details.
23 ### You should have received a copy of the GNU General Public License
24 ### along with `common'; if not, write to the Free Software Foundation,
25 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 ###--------------------------------------------------------------------------
30 ### Parse command line arguments.
32 while [ $# -gt 0 ]; do
34 -h | --h | --he | --hel | --help)
38 Writes on standard output the program's version number.
50 echo "auto-version: unknown option \`$1'" >&2
61 echo >&2 "Usage: auto-version"
65 ###--------------------------------------------------------------------------
68 ## If this is a Git checkout then Git should be able to identify the version.
69 ## If there's also a Debian version, and that ends in a `~', then prefix the
70 ## Git version with this. Note that `pkg-config' is not very good, and, in
71 ## particular, doesn't support the convention that `~' sorts before anything
72 ## else, even the empty string, despite claiming to implement the RPM
73 ## version-comparison algorithm which specifies this behaviour, so one must
74 ## be careful when choosing `~' prefixes.
75 if [ -e .git ] && version=$(git describe --abbrev=4 --dirty=+ 2>/dev/null); then
76 debver=$(sed -n '/^.*(\(.*\)).*$/ { s::\1:p; q; }' debian/changelog)
77 case $debver in *~) version=$debver$version ;; esac
82 ## If this was unpacked from a source distribution, the RELEASE file should
83 ## say what the version was.
84 if [ -f RELEASE ]; then
89 ## If we're Debianized, then the Debian changelog ought to know.
90 if [ -f debian/changelog ]; then
91 sed -n '/^.*(\(.*\)).*$/ { s::\1:p; q; }' debian/changelog
95 ## Otherwise we're screwed.
99 ###----- That's all, folks --------------------------------------------------