<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libusrp/+/15083">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">configure.ac: Use git-version-gen<br><br>Change-Id: Ib5458af1df08eec82339b4e7f7696b9c390a3078<br>---<br>M configure.ac<br>A git-version-gen<br>2 files changed, 155 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libusrp refs/changes/83/15083/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/configure.ac b/configure.ac</span><br><span>index ec86209..3f02c14 100644</span><br><span>--- a/configure.ac</span><br><span>+++ b/configure.ac</span><br><span>@@ -1,4 +1,7 @@</span><br><span style="color: hsl(0, 100%, 40%);">-AC_INIT([libusrp], [3.4.2])</span><br><span style="color: hsl(120, 100%, 40%);">+AC_INIT([libusrp],</span><br><span style="color: hsl(120, 100%, 40%);">+    m4_esyscmd([./git-version-gen .tarball-version]),</span><br><span style="color: hsl(120, 100%, 40%);">+     [openbsc@lists.osmocom.org])</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> AM_INIT_AUTOMAKE([foreign subdir-objects silent-rules])</span><br><span> AM_SILENT_RULES([yes])</span><br><span> </span><br><span>diff --git a/git-version-gen b/git-version-gen</span><br><span>new file mode 100755</span><br><span>index 0000000..42cf3d2</span><br><span>--- /dev/null</span><br><span>+++ b/git-version-gen</span><br><span>@@ -0,0 +1,151 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/bin/sh</span><br><span style="color: hsl(120, 100%, 40%);">+# Print a version string.</span><br><span style="color: hsl(120, 100%, 40%);">+scriptversion=2010-01-28.01</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Copyright (C) 2007-2010 Free Software Foundation, Inc.</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# This program is free software: you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+# it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+# the Free Software Foundation; either version 3 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+# (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+# but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+# GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# You should have received a copy of the GNU General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+# along with this program.  If not, see <http://www.gnu.org/licenses/>.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.</span><br><span style="color: hsl(120, 100%, 40%);">+# It may be run two ways:</span><br><span style="color: hsl(120, 100%, 40%);">+# - from a git repository in which the "git describe" command below</span><br><span style="color: hsl(120, 100%, 40%);">+#   produces useful output (thus requiring at least one signed tag)</span><br><span style="color: hsl(120, 100%, 40%);">+# - from a non-git-repo directory containing a .tarball-version file, which</span><br><span style="color: hsl(120, 100%, 40%);">+#   presumes this script is invoked like "./git-version-gen .tarball-version".</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# In order to use intra-version strings in your project, you will need two</span><br><span style="color: hsl(120, 100%, 40%);">+# separate generated version string files:</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# .tarball-version - present only in a distribution tarball, and not in</span><br><span style="color: hsl(120, 100%, 40%);">+#   a checked-out repository.  Created with contents that were learned at</span><br><span style="color: hsl(120, 100%, 40%);">+#   the last time autoconf was run, and used by git-version-gen.  Must not</span><br><span style="color: hsl(120, 100%, 40%);">+#   be present in either $(srcdir) or $(builddir) for git-version-gen to</span><br><span style="color: hsl(120, 100%, 40%);">+#   give accurate answers during normal development with a checked out tree,</span><br><span style="color: hsl(120, 100%, 40%);">+#   but must be present in a tarball when there is no version control system.</span><br><span style="color: hsl(120, 100%, 40%);">+#   Therefore, it cannot be used in any dependencies.  GNUmakefile has</span><br><span style="color: hsl(120, 100%, 40%);">+#   hooks to force a reconfigure at distribution time to get the value</span><br><span style="color: hsl(120, 100%, 40%);">+#   correct, without penalizing normal development with extra reconfigures.</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# .version - present in a checked-out repository and in a distribution</span><br><span style="color: hsl(120, 100%, 40%);">+#   tarball.  Usable in dependencies, particularly for files that don't</span><br><span style="color: hsl(120, 100%, 40%);">+#   want to depend on config.h but do want to track version changes.</span><br><span style="color: hsl(120, 100%, 40%);">+#   Delete this file prior to any autoconf run where you want to rebuild</span><br><span style="color: hsl(120, 100%, 40%);">+#   files to pick up a version string change; and leave it stale to</span><br><span style="color: hsl(120, 100%, 40%);">+#   minimize rebuild time after unrelated changes to configure sources.</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# It is probably wise to add these two files to .gitignore, so that you</span><br><span style="color: hsl(120, 100%, 40%);">+# don't accidentally commit either generated file.</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# Use the following line in your configure.ac, so that $(VERSION) will</span><br><span style="color: hsl(120, 100%, 40%);">+# automatically be up-to-date each time configure is run (and note that</span><br><span style="color: hsl(120, 100%, 40%);">+# since configure.ac no longer includes a version string, Makefile rules</span><br><span style="color: hsl(120, 100%, 40%);">+# should not depend on configure.ac for version updates).</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# AC_INIT([GNU project],</span><br><span style="color: hsl(120, 100%, 40%);">+#         m4_esyscmd([build-aux/git-version-gen .tarball-version]),</span><br><span style="color: hsl(120, 100%, 40%);">+#         [bug-project@example])</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# Then use the following lines in your Makefile.am, so that .version</span><br><span style="color: hsl(120, 100%, 40%);">+# will be present for dependencies, and so that .tarball-version will</span><br><span style="color: hsl(120, 100%, 40%);">+# exist in distribution tarballs.</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# BUILT_SOURCES = $(top_srcdir)/.version</span><br><span style="color: hsl(120, 100%, 40%);">+# $(top_srcdir)/.version:</span><br><span style="color: hsl(120, 100%, 40%);">+#    echo $(VERSION) > $@-t && mv $@-t $@</span><br><span style="color: hsl(120, 100%, 40%);">+# dist-hook:</span><br><span style="color: hsl(120, 100%, 40%);">+#        echo $(VERSION) > $(distdir)/.tarball-version</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+case $# in</span><br><span style="color: hsl(120, 100%, 40%);">+    1) ;;</span><br><span style="color: hsl(120, 100%, 40%);">+    *) echo 1>&2 "Usage: $0 \$srcdir/.tarball-version"; exit 1;;</span><br><span style="color: hsl(120, 100%, 40%);">+esac</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+tarball_version_file=$1</span><br><span style="color: hsl(120, 100%, 40%);">+nl='</span><br><span style="color: hsl(120, 100%, 40%);">+'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# First see if there is a tarball-only version file.</span><br><span style="color: hsl(120, 100%, 40%);">+# then try "git describe", then default.</span><br><span style="color: hsl(120, 100%, 40%);">+if test -f $tarball_version_file</span><br><span style="color: hsl(120, 100%, 40%);">+then</span><br><span style="color: hsl(120, 100%, 40%);">+    v=`cat $tarball_version_file` || exit 1</span><br><span style="color: hsl(120, 100%, 40%);">+    case $v in</span><br><span style="color: hsl(120, 100%, 40%);">+       *$nl*) v= ;; # reject multi-line output</span><br><span style="color: hsl(120, 100%, 40%);">+       [0-9]*) ;;</span><br><span style="color: hsl(120, 100%, 40%);">+    *) v= ;;</span><br><span style="color: hsl(120, 100%, 40%);">+    esac</span><br><span style="color: hsl(120, 100%, 40%);">+    test -z "$v" \</span><br><span style="color: hsl(120, 100%, 40%);">+      && echo "$0: WARNING: $tarball_version_file seems to be damaged" 1>&2</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+if test -n "$v"</span><br><span style="color: hsl(120, 100%, 40%);">+then</span><br><span style="color: hsl(120, 100%, 40%);">+    : # use $v</span><br><span style="color: hsl(120, 100%, 40%);">+elif</span><br><span style="color: hsl(120, 100%, 40%);">+       v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \</span><br><span style="color: hsl(120, 100%, 40%);">+       || git describe --abbrev=4 HEAD 2>/dev/null` \</span><br><span style="color: hsl(120, 100%, 40%);">+    && case $v in</span><br><span style="color: hsl(120, 100%, 40%);">+         [0-9]*) ;;</span><br><span style="color: hsl(120, 100%, 40%);">+    v[0-9]*) ;;</span><br><span style="color: hsl(120, 100%, 40%);">+   *) (exit 1) ;;</span><br><span style="color: hsl(120, 100%, 40%);">+       esac</span><br><span style="color: hsl(120, 100%, 40%);">+then</span><br><span style="color: hsl(120, 100%, 40%);">+    # Is this a new git that lists number of commits since the last</span><br><span style="color: hsl(120, 100%, 40%);">+    # tag or the previous older version that did not?</span><br><span style="color: hsl(120, 100%, 40%);">+    #   Newer: v6.10-77-g0f8faeb</span><br><span style="color: hsl(120, 100%, 40%);">+    #   Older: v6.10-g0f8faeb</span><br><span style="color: hsl(120, 100%, 40%);">+    case $v in</span><br><span style="color: hsl(120, 100%, 40%);">+       *-*-*) : git describe is okay three part flavor ;;</span><br><span style="color: hsl(120, 100%, 40%);">+    *-*)</span><br><span style="color: hsl(120, 100%, 40%);">+      : git describe is older two part flavor</span><br><span style="color: hsl(120, 100%, 40%);">+       # Recreate the number of commits and rewrite such that the</span><br><span style="color: hsl(120, 100%, 40%);">+            # result is the same as if we were using the newer version</span><br><span style="color: hsl(120, 100%, 40%);">+            # of git describe.</span><br><span style="color: hsl(120, 100%, 40%);">+            vtag=`echo "$v" | sed 's/-.*//'`</span><br><span style="color: hsl(120, 100%, 40%);">+            numcommits=`git rev-list "$vtag"..HEAD | wc -l`</span><br><span style="color: hsl(120, 100%, 40%);">+     v=`echo "$v" | sed "s/\(.*\)-\(.*\)/\1-$numcommits-\2/"`;</span><br><span style="color: hsl(120, 100%, 40%);">+         ;;</span><br><span style="color: hsl(120, 100%, 40%);">+    esac</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    # Change the first '-' to a '.', so version-comparing tools work properly.</span><br><span style="color: hsl(120, 100%, 40%);">+    # Remove the "g" in git describe's output string, to save a byte.</span><br><span style="color: hsl(120, 100%, 40%);">+    v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+    v=UNKNOWN</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+v=`echo "$v" |sed 's/^v//'`</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Don't declare a version "dirty" merely because a time stamp has changed.</span><br><span style="color: hsl(120, 100%, 40%);">+git status > /dev/null 2>&1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+dirty=`sh -c 'git diff-index --name-only HEAD' 2>/dev/null` || dirty=</span><br><span style="color: hsl(120, 100%, 40%);">+case "$dirty" in</span><br><span style="color: hsl(120, 100%, 40%);">+    '') ;;</span><br><span style="color: hsl(120, 100%, 40%);">+    *) # Append the suffix only if there isn't one already.</span><br><span style="color: hsl(120, 100%, 40%);">+        case $v in</span><br><span style="color: hsl(120, 100%, 40%);">+      *-dirty) ;;</span><br><span style="color: hsl(120, 100%, 40%);">+   *) v="$v-dirty" ;;</span><br><span style="color: hsl(120, 100%, 40%);">+        esac ;;</span><br><span style="color: hsl(120, 100%, 40%);">+esac</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Omit the trailing newline, so that m4_esyscmd can use the result directly.</span><br><span style="color: hsl(120, 100%, 40%);">+echo "$v" | tr -d '\012'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Local variables:</span><br><span style="color: hsl(120, 100%, 40%);">+# eval: (add-hook 'write-file-hooks 'time-stamp)</span><br><span style="color: hsl(120, 100%, 40%);">+# time-stamp-start: "scriptversion="</span><br><span style="color: hsl(120, 100%, 40%);">+# time-stamp-format: "%:y-%02m-%02d.%02H"</span><br><span style="color: hsl(120, 100%, 40%);">+# time-stamp-end: "$"</span><br><span style="color: hsl(120, 100%, 40%);">+# End:</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libusrp/+/15083">change 15083</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libusrp/+/15083"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libusrp </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ib5458af1df08eec82339b4e7f7696b9c390a3078 </div>
<div style="display:none"> Gerrit-Change-Number: 15083 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>