3 ## Copyright (c) 2010 The WebM project authors. All Rights Reserved.
5 ## Use of this source code is governed by a BSD-style license
6 ## that can be found in the LICENSE file in the root of the source
7 ## tree. An additional intellectual property rights grant can be found
8 ## in the file PATENTS. All contributing project authors may
9 ## be found in the AUTHORS file in the root of the source tree.
24 id=${3:-VERSION_STRING}
27 if [ -d "${source_path}/.git" ]; then
28 # Source Path is a git working copy. Check for local modifications.
29 export GIT_DIR="${source_path}/.git"
30 git_version_id=`git describe --match=v[0-9]* 2>/dev/null`
34 for p in "${source_path}" "${source_path}/.."; do
35 if [ -z "$git_version_id" -a -f "${p}/CHANGELOG" ]; then
36 changelog_version=`head -n1 "${p}/CHANGELOG" | awk '{print $2}'`
37 changelog_version="${changelog_version}"
41 version_str="${changelog_version}${git_version_id}"
42 bare_version=${version_str#v}
43 major_version=${bare_version%%.*}
44 bare_version=${bare_version#*.}
45 minor_version=${bare_version%%.*}
46 bare_version=${bare_version#*.}
47 patch_version=${bare_version%%-*}
48 bare_version=${bare_version#${patch_version}}
49 extra_version=${bare_version##-}
51 #since they'll be used as integers below make sure they are or force to 0
52 for v in major_version minor_version patch_version; do
53 if eval echo \$$v |grep -E -q '[^[:digit:]]'; then
59 echo "${changelog_version}${git_version_id}" > $$.tmp
62 #define VERSION_MAJOR $major_version
63 #define VERSION_MINOR $minor_version
64 #define VERSION_PATCH $patch_version
65 #define VERSION_EXTRA "$extra_version"
66 #define VERSION_PACKED ((VERSION_MAJOR<<16)|(VERSION_MINOR<<8)|(VERSION_PATCH))
67 #define ${id}_NOSP "${version_str}"
68 #define ${id} " ${version_str}"
71 if [ -n "$out_file" ]; then
72 diff $$.tmp ${out_file} >/dev/null 2>&1 || cat $$.tmp > ${out_file}