1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 16:24:02 +00:00
transmission/version.sh
2006-05-31 13:03:19 +00:00

42 lines
1.1 KiB
Bash
Executable file

#! /bin/sh
#
# $Id$
# Get current SVN revision from Ids in all source files
REVMAX=0
for pattern in '*.[chm]' '*.cpp' '*.po' '*.mk' 'Makefile' 'configure'; do
for f in `find . -name "$pattern"`; do
REV=`sed -e '/\$Id:/!d' -e \
's/.*\$Id: [^ ]* \([0-9]*\) .*/\1/' \
$f`
if [ -n "$REV" ]; then
if [ "$REV" -gt "$REVMAX" ]; then
REVMAX="$REV"
fi
fi
done
done
# Generate files to be included: only overwrite them if changed so make
# won't rebuild everything unless necessary
replace_if_differs ()
{
if cmp $1 $2 > /dev/null 2>&1; then
rm -f $1
else
mv -f $1 $2
fi
}
# Generate version.mk
cp -f mk/version.mk.in mk/version.mk.new
echo "VERSION_REVISION = $REVMAX" >> mk/version.mk.new
replace_if_differs mk/version.mk.new mk/version.mk
# Generate version.h from version.mk
grep "^VER" mk/version.mk | sed -e 's/^/#define /g' -e 's/= //g' \
-e 's/\(VERSION_STRING[ ]*\)\(.*\)/\1"\2"/' > \
libtransmission/version.h.new
replace_if_differs libtransmission/version.h.new libtransmission/version.h
exit 0