diff --git a/Makefile.am b/Makefile.am index 15fa61a18..5ce7c0b90 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,3 +24,29 @@ EXTRA_DIST = $(icinga2doc_DATA) # Remove doc directory on uninstall uninstall-local: -rm -r $(icinga2docdir) + +BUILT_SOURCES = icinga-version.stamp +CLEANFILES = icinga-version.h +GIT_VERSION_CMD = $(SHELL) $(top_srcdir)/git_version.sh +icinga-version.stamp: + @if test -f "$(srcdir)/icinga-version.h"; then \ + if test -f "icinga-version.h"; then :; \ + else \ + cp "$(srcdir)/icinga-version.h" "icinga-version.h"; \ + fi; \ + fi + $(GIT_VERSION_CMD) -k -s $(top_srcdir) -o icinga-version.h + @if test -s "$(srcdir)/icinga-version.h"; then \ + if cmp "$(srcdir)/icinga-version.h" "icinga-version.h"; then :; \ + else \ + echo "Error: $(srcdir)/icinga-version.h and icinga-version.h differ."; \ + echo " You probably want to remove the former."; \ + exit 1; \ + fi; \ + fi + +dist-hook: icinga-version.stamp + if test -f "icinga-version.h"; then \ + $(SED) -e 's|^#undef GIT_IS_DIST.*|#define GIT_IS_DIST 1|' \ + "icinga-version.h" > "$(distdir)/icinga-version.h"; \ + fi \ No newline at end of file diff --git a/git_version.sh b/git_version.sh new file mode 100644 index 000000000..0852b857f --- /dev/null +++ b/git_version.sh @@ -0,0 +1,359 @@ +#!/bin/sh +# +# Generate some basic versioning information which can be piped to a header. +# +# Copyright (c) 2006-2007 Luc Verhaegen +# Copyright (C) 2007-2008 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. +# +# Requires git >= 1.3.0 for the 'git foo' (with space) syntax, +# and git >= 1.4 for some specific commands. + +# Help messages +USAGE="[