We've been using the build/get-version.sh script in
httpd-apreq-2. The following patch corrects the
libtool version string miscalculation (we let libtool
generate the shared library version for libapreq2, so
it's pretty well-tested).
The patch also includes a patch to correctly handle
multi-digit numbers (the original regexp will drop
all but the final digit due to the greediness of the
opening .* pattern.
% diff -u apr/build/get-version.sh httpd-apreq-2/build/get-version.sh
--- apr/build/get-version.sh 2002-09-10 09:11:20.000000000 +0000
+++ httpd-apreq-2/build/get-version.sh 2004-06-21 16:50:43.816189354 +0000
@@ -13,24 +13,24 @@
if test $# != 3; then
echo "USAGE: $0 CMD INCLUDEDIR PREFIX"
- echo " where CMD is one of: all, major"
+ echo " where CMD is one of: all, major, libtool"
exit 1
fi
-major_sed="/#define.*$3_MAJOR_VERSION/s/^.*\([0-9][0-9]*\).*$/\1/p"
-minor_sed="/#define.*$3_MINOR_VERSION/s/^.*\([0-9][0-9]*\).*$/\1/p"
-patch_sed="/#define.*$3_PATCH_VERSION/s/^.*\([0-9][0-9]*\).*$/\1/p"
+major_sed="/#define.*$3_MAJOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p"
+minor_sed="/#define.*$3_MINOR_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p"
+patch_sed="/#define.*$3_PATCH_VERSION/s/^[^0-9]*\([0-9]*\).*$/\1/p"
major="`sed -n $major_sed $2`"
minor="`sed -n $minor_sed $2`"
patch="`sed -n $patch_sed $2`"
+ltmaj="`expr $major + $minor`"
if test "$1" = "all"; then
echo ${major}.${minor}.${patch}
elif test "$1" = "major"; then
echo ${major}
elif test "$1" = "libtool"; then
- # Yes, ${minor}:${patch}:${minor} is correct due to libtool idiocy.
- echo ${minor}:${patch}:${minor}
+ echo ${ltmaj}:${patch}:${minor}
else
echo "ERROR: unknown version CMD ($1)"
exit 1
--
Joe Schaefer