From c0f9d4b0f1e4d1d49d238e4b2546de46f51166eb Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Thu, 10 Apr 2008 13:09:19 -0400 Subject: [PATCH] PR6393: git version tagging at build time 2008-04-10 Frank Ch. Eigler PR 6393. * git_version.sh: New file, copied from radeonhd. * configure.ac: No longer generate $builddir/SNAPSHOT. * Makefile.am: Generate $builddir/git_version.h. (EXTRA_DIST): Add git_version.h and git_version.sh. * main.cxx (version): Print generated GIT_MESSAGE therefrom. * Makefile.in, configure: Regenerated. --- ChangeLog | 10 ++ Makefile.am | 7 +- Makefile.in | 7 +- configure | 7 - configure.ac | 7 - git_version.sh | 348 +++++++++++++++++++++++++++++++++++++++++++++++++ main.cxx | 2 + 7 files changed, 372 insertions(+), 16 deletions(-) create mode 100755 git_version.sh diff --git a/ChangeLog b/ChangeLog index 7d2853d2f..fc720484f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-04-10 Frank Ch. Eigler + + PR 6393. + * git_version.sh: New file, copied from radeonhd. + * configure.ac: No longer generate $builddir/SNAPSHOT. + * Makefile.am: Generate $builddir/git_version.h. + (EXTRA_DIST): Add git_version.h and git_version.sh. + * main.cxx (version): Print generated GIT_MESSAGE therefrom. + * Makefile.in, configure: Regenerated. + 2008-04-09 David Smith * .gitignore: Added more files to ignore. diff --git a/Makefile.am b/Makefile.am index 1fc4dbec9..b09bbc053 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,6 +17,9 @@ stap_SOURCES = main.cxx \ tapsets.cxx buildrun.cxx loc2c.c hash.cxx mdfour.c \ cache.cxx util.cxx coveragedb.cxx stap_LDADD = @stap_LIBS@ @sqlite3_LIBS@ +main.o: git_version.h +git_version.h: + $(srcdir)/git_version.sh -k --srcdir $(srcdir) -o git_version.h stap_CXXFLAGS = $(AM_CXXFLAGS) stap_CPPFLAGS = $(AM_CPPFLAGS) @@ -102,7 +105,8 @@ LDADD = EXTRA_DIST = buildrun.h elaborate.h loc2c.h session.h \ parse.h staptree.h tapsets.h translate.h \ cache.h hash.h mdfour.h util.h staplog.c coveragedb.h \ - examples testsuite systemtap.spec runtime tapset + examples testsuite systemtap.spec runtime tapset \ + git_version.h git_version.sh SAMPLE_DEST_DIR = $(distdir)/examples/samples @@ -156,6 +160,7 @@ clean-local: rm -rf $(TEST_COV_DIR) rm -rf stap.info rm -rf staplog.so + rm -f git_version.h uninstall-local: rm -rf $(DESTDIR)$(pkgdatadir) diff --git a/Makefile.in b/Makefile.in index e82d66a3c..e1259bde7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -311,7 +311,8 @@ LDADD = EXTRA_DIST = buildrun.h elaborate.h loc2c.h session.h \ parse.h staptree.h tapsets.h translate.h \ cache.h hash.h mdfour.h util.h staplog.c coveragedb.h \ - examples testsuite systemtap.spec runtime tapset + examples testsuite systemtap.spec runtime tapset \ + git_version.h git_version.sh SAMPLE_DEST_DIR = $(distdir)/examples/samples SAMPLE_SRC = $(srcdir)/testsuite/systemtap.samples/iotask.stp \ @@ -1458,6 +1459,9 @@ uninstall-man: uninstall-man1 uninstall-man5 uninstall-man8 uninstall-man uninstall-man1 uninstall-man5 uninstall-man8 \ uninstall-pkglibexecPROGRAMS +main.o: git_version.h +git_version.h: + $(srcdir)/git_version.sh -k --srcdir $(srcdir) -o git_version.h @BUILD_ELFUTILS_TRUE@stamp-elfutils: config.status @BUILD_ELFUTILS_TRUE@ $(MAKE) $(AM_MAKEFLAGS) -C build-elfutils all @BUILD_ELFUTILS_TRUE@ for dir in libelf libebl libdw libdwfl backends; do \ @@ -1525,6 +1529,7 @@ clean-local: rm -rf $(TEST_COV_DIR) rm -rf stap.info rm -rf staplog.so + rm -f git_version.h uninstall-local: rm -rf $(DESTDIR)$(pkgdatadir) diff --git a/configure b/configure index c8be8582f..819c6f06c 100755 --- a/configure +++ b/configure @@ -6812,13 +6812,6 @@ cap_LIBS="$LIBS" LIBS="$SAVE_LIBS" CFLAGS="$SAVE_CFLAGS" -if test -d $srcdir/.git -a ! -f $srcdir/SNAPSHOT; then - snapshot=`cd $srcdir; git-rev-list --abbrev-commit --max-count=1 HEAD` - echo $snapshot > SNAPSHOT - { echo "$as_me:$LINENO: Created git SNAPSHOT $snapshot" >&5 -echo "$as_me: Created git SNAPSHOT $snapshot" >&6;} -fi - ac_config_headers="$ac_config_headers config.h:config.in" ac_config_files="$ac_config_files Makefile doc/Makefile systemtap.spec stap.1 stapprobes.5 stapfuncs.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5" diff --git a/configure.ac b/configure.ac index fa14516cd..51ed83a7a 100644 --- a/configure.ac +++ b/configure.ac @@ -204,13 +204,6 @@ AC_SUBST(cap_LIBS) LIBS="$SAVE_LIBS" CFLAGS="$SAVE_CFLAGS" -dnl Create SNAPSHOT file from git commit id if possible -if test -d $srcdir/.git -a ! -f $srcdir/SNAPSHOT; then - snapshot=`cd $srcdir; git-rev-list --abbrev-commit --max-count=1 HEAD` - echo $snapshot > SNAPSHOT - AC_MSG_NOTICE([Created git SNAPSHOT $snapshot]) -fi - AC_CONFIG_HEADERS([config.h:config.in]) AC_CONFIG_FILES(Makefile doc/Makefile systemtap.spec stap.1 stapprobes.5 stapfuncs.5 stapex.5 staprun.8 man/stapprobes.iosched.5 man/stapprobes.netdev.5 man/stapprobes.nfs.5 man/stapprobes.nfsd.5 man/stapprobes.pagefault.5 man/stapprobes.process.5 man/stapprobes.rpc.5 man/stapprobes.scsi.5 man/stapprobes.signal.5 man/stapprobes.socket.5 man/stapprobes.tcp.5 man/stapprobes.udp.5) AC_CONFIG_SUBDIRS(testsuite) diff --git a/git_version.sh b/git_version.sh new file mode 100755 index 000000000..69eb0f24e --- /dev/null +++ b/git_version.sh @@ -0,0 +1,348 @@ +#!/bin/sh +# +# Generate some basic versioning information which can be piped to a header. +# +# Copyright (c) 2006-2007 Luc Verhaegen +# Copyright (C) 2007 Hans Ulrich Niedermann +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# This script is based on the one written for xf86-video-unichrome by +# Luc Verhaegen, but was rewritten almost completely by Hans Ulrich +# Niedermann. The script contains a few bug fixes from Egbert Eich, +# Matthias Hopf, Joerg Sonnenberger, and possibly others. +# +# The author thanks the nice people on #git for the assistance. +# +# Simple testing of this script: +# /sbin/busybox sh git_version.sh --example > moo.c \ +# && gcc -Wall -Wextra -Wno-unused -o moo moo.c \ +# && ./moo +# (bash should also do) +# +# For how to hook this up to your automake- and/or imake-based build +# system, best take a look at how the RadeonHD.am and/or RadeonHD.tmpl +# work in the xf86-video-radeonhd build system. For non-recursive make, +# you can probably make things a little bit simpler. +# +# KNOWN BUGS: +# * Uses hyphenated ("git-foo-bar") program names, which git upstream +# have declared deprecated. +# + +# Help messages +USAGE="[