-
Notifications
You must be signed in to change notification settings - Fork 1
/
autogen.sh
executable file
·41 lines (35 loc) · 1.48 KB
/
autogen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
cd "$(dirname "$0")"
PACKAGE=$(grep AC_INIT configure.ac|head -1|sed -r 's,AC_INIT[(][[],,;s,[]].*,,')
GTVERSION=$(gettext --version|head -1|awk '{print$NF}'|sed -r 's,(^[^\.]*\.[^\.]*)\.[^\.]*$,\1,;s,(^[^\.]*\.[^\.]*\.[^\.]*)\.[^\.]*$,\1,')
if [ -x "`which git 2>/dev/null`" -a -d .git ]; then
VERSION=$(git describe --tags|sed -r 's,^rel-,,;s,^([0-9])([0-9])([0-9]),\1.\2.\3,;s,[-_],.,g;s,\.g.*$,,')
DATE=$(git show -s --format=%ci HEAD^{commit}|awk '{print$1}')
MDOCDATE=$(perl -MDate::Format -MDate::Parse -E 'print time2str("%B %e, %Y", str2time("'"$DATE"'"))'|sed 's, , ,')
BRANCH=$(git tag --sort=-creatordate|head -1)
GNITS="gnits "
if [ "$VERSION" != "$BRANCH" ]; then
BRANCH="master"
GNITS=""
fi
sed -i.bak -r \
-e "s:AC_INIT\([[]$PACKAGE[]],[[][^]]*[]]:AC_INIT([$PACKAGE],[$VERSION]:
s:AC_REVISION\([[][^]]*[]]\):AC_REVISION([$VERSION]):
s:^DATE=.*$:DATE='$DATE':
s:^MDOCDATE=.*$:MDOCDATE='$MDOCDATE':
s:^BRANCH=.*$:BRANCH='$BRANCH':
s:^AM_GNU_GETTEXT_VERSION.*:AM_GNU_GETTEXT_VERSION([$GTVERSION]):
s:^AM_INIT_AUTOMAKE\([[](gnits )?:AM_INIT_AUTOMAKE([$GNITS:" \
configure.ac
subst="s:%%PACKAGE%%:$PACKAGE:g
s:%%VERSION%%:$VERSION:g
s:%%DATE%%:$DATE:g
s:%%MDOCDATE%%:$MDOCDATE:g
s:%%BRANCH%%:$BRANCH:g"
sed -r -e "$subst" rpm/bbkeys.spec.in >rpm/bbkeys.spec
else
sed -i.bak configure.ac -r \
-e "s:^AM_GNU_GETTEXT_VERSION.*:AM_GNU_GETTEXT_VERSION([$GTVERSION]):"
fi
mkdir m4 2>/dev/null
autoreconf -iv