#! /bin/sh

#   mkstamp - extract data from Revision and Date RCS tags in a file
#   Copyright (C) 1999, 2003 Free Software Foundation, Inc.
#   Written by Alexandre Oliva, 1999
#
#   This file is part of GNU Libtool.
#
# GNU Libtool is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# GNU Libtool is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Libtool; see the file COPYING.  If not, a copy
# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
# or obtained by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
####

# This script takes a directory as an argument and generates a
# revision and date based upon the ChangeLog files in that directory.

# Generate a revision that looks similar to CVS revision by using 1.
# then the number of lines in the ChangeLogs starting with dates (an
# approximation of the number of commits) + 1000. 
# For those pulling from the savannah git repository it should be
# possible to go from this revision number to the git revision fairly
# easily. The number will also always increase.

awk 'BEGIN {
	cocount=0;
}
/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]  / {
        if (cocount== 0) {
                datestr=$1
        }
	cocount++;
}
END {
	cocount = cocount + 1000;
        print "1." cocount " " datestr;
}' $1/ChangeLog $1/ChangeLog.[12][0-9][0-9][0-9]