#!/bin/sh # Generate some basic info on source code version to be included in program. # # 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. # # The author thanks the nice people on #git for the assistance! # # Simple testing of this script: # env SED="/sbin/busybox sed" \ # /sbin/busybox sh git-buildmsg --example > moo.c \ # && gcc -Wall -Wextra -Wno-unused -o moo moo.c \ # && ./moo # (bash and other seds should also do) # # Note: # A man page for this script does NOT make sense. It is supposed to be # copied into and shipped with other peoples' source trees. # # Ideas: # * Output for languages other than C (Erlang, Python, Perl, sh, ...) # * Recognize difference between being built from "non-git" sources and # a dist tarball generated from git rev XYZ. # The caller may have found these programs for us SED="${SED-sed}" # Initialize GIT_DIR=".git" working_dir="$(pwd)" # Who am I? self="$(basename "$0")" # Default settings ifndef_symbol="GIT_BUILDMSG_H" outfile="-" print_example=false srcdir="$(pwd)" error_if_no_git=false # Help messages USAGE="[