Ticket #1967: removed extra unneeded quotes in user menu.
[kaloumi3.git] / maint / version.sh
blob291e569f5db7df1f8592e6003e9be8b8473a86a6
1 #!/bin/sh
3 if [ -z "$1" ]
4 then
5 echo "usage: $0 <toplevel-source-dir>"
6 exit 1
7 fi
9 src_top_dir="$1"
11 VERSION_FILE="${src_top_dir}/version.h"
12 PREV_MC_VERSION="unknown"
13 CURR_MC_VERSION="${PREV_MC_VERSION}"
15 if [ -r "${VERSION_FILE}" ]
16 then
17 PREV_MC_VERSION=`sed -n 's/^#define MC_CURRENT_VERSION "\(.*\)"$/\1/p' "${VERSION_FILE}"`
18 CURR_MC_VERSION="${PREV_MC_VERSION}"
21 mc_print_version(){
23 if [ ! -f "${VERSION_FILE}" \
24 -o "${PREV_MC_VERSION}" != "${CURR_MC_VERSION}" ]
25 then
26 cat >"${VERSION_FILE}" <<EOF
27 #ifndef MC_CURRENT_VERSION
28 /* This is an autogenerated file. Don't edit! */
29 #define MC_CURRENT_VERSION "${CURR_MC_VERSION}"
30 #endif
31 EOF
33 exit
36 git_head=$(git --git-dir "${src_top_dir}/.git" rev-parse --verify HEAD 2>/dev/null)
37 [ -z "${git_head}" ] && mc_print_version
39 # try to store sha1
40 CURR_MC_VERSION="${git_head}"
42 new_version="$(git --git-dir "${src_top_dir}/.git" describe 2>/dev/null)"
43 [ -z "${new_version}" ] && mc_print_version
45 # store pretty tagged version
46 CURR_MC_VERSION="${new_version}"
47 mc_print_version