|
@@ -0,0 +1,46 @@
|
|
|
+#!/bin/sh
|
|
|
+
|
|
|
+git --version &>/dev/null || exit
|
|
|
+
|
|
|
+curr_dir=$(pwd)
|
|
|
+
|
|
|
+src_top_dir=
|
|
|
+[ -d ${curr_dir}/.git ] && {
|
|
|
+ src_top_dir=${curr_dir}
|
|
|
+} || {
|
|
|
+ curr_dir=$(dirname ${curr_dir})
|
|
|
+ [ -d ${curr_dir}/.git ] && {
|
|
|
+ src_top_dir=${curr_dir}
|
|
|
+ } || {
|
|
|
+ [ -z "$1" ] && exit
|
|
|
+ src_top_dir=$1
|
|
|
+ }
|
|
|
+}
|
|
|
+[ -z "${src_top_dir}" ] && exit
|
|
|
+
|
|
|
+
|
|
|
+VERSION_FILE=${src_top_dir}/version.h
|
|
|
+
|
|
|
+pushd ${src_top_dir} &>/dev/null
|
|
|
+git_head=$(git rev-parse --verify HEAD 2>/dev/null)
|
|
|
+[ -z "${git_head}" ] && exit
|
|
|
+
|
|
|
+new_version="$(git describe 2>/dev/null)"
|
|
|
+[ -z "${new_version}" ] && exit
|
|
|
+popd &>/dev/null
|
|
|
+
|
|
|
+
|
|
|
+saved_version=
|
|
|
+[ -r ${VERSION_FILE} ] && {
|
|
|
+ saved_version=$(grep '^#define MC_CURRENT_VERSION' ${VERSION_FILE}| sed -r 's/.*"(.*)"$/\1/')
|
|
|
+}
|
|
|
+
|
|
|
+[ -z "${saved_version}" -o "${saved_version}" != "${new_version}" ] && {
|
|
|
+ cat >${VERSION_FILE} <<EOF
|
|
|
+#ifndef MC_CURRENT_VERSION
|
|
|
+/* This is autogenerated file. Don't edit! */
|
|
|
+#define MC_CURRENT_VERSION "${new_version}"
|
|
|
+#endif
|
|
|
+EOF
|
|
|
+}
|
|
|
+exit 0
|