#!/bin/sh

# FIG : Facility for Interactive Generation of figures
# Copyright (c) 1985-1988 by Supoj Sutanthavibul
# Parts Copyright (c) 1989-2015 by Brian V. Smith
# Parts Copyright (c) 1991 by Paul King
# Parts Copyright (c) 2016-2023 by Thomas Loimer
#
# Any party obtaining a copy of these files is granted, free of charge, a
# full and unrestricted irrevocable, world-wide, paid up, royalty-free,
# nonexclusive right and license to deal in this software and documentation
# files (the "Software"), including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense and/or sell copies
# of the Software, and to permit persons who receive copies from any such
# party to do so, with the only requirement being that the above copyright
# and this permission notice remain intact.
#
#

#
# update-version_m4: Set the version information in version.m4.
# Author: Thomas Loimer <thomas.loimer@tuwien.ac.at>, 2016-2023
#

# test, whether git is available, and we are in a git tree
if git config --local -l >/dev/null 2>&1 &&	\
    test "`git describe --abbrev=1`" !=		\
	"`sed -n '/^m4_def.*XFIG_VERS/ {s/.*, *\[\(.*\)\])/\1/;p}' version.m4`"
then
    sed  -i "\
	/^m4_define(\[\{0,1\}XFIG_VERSION/ s/\(.*, *\[\).*\]/\1`git describe --abbrev=1`]/
	/^m4_define(\[\{0,1\}RELEASEDATE/ s/\(.*, *\[\).*\]/\1`LC_TIME=C git show -s --pretty=%cd --date=format:'%b %Y'`]/" version.m4
fi
