1#!/bin/sh
2
3GETVER="${0%/*}/getver.pl"
4GDLIB_MAJOR=$("${GETVER}" MAJOR)
5GDLIB_MINOR=$("${GETVER}" MINOR)
6GDLIB_REVISION=$("${GETVER}" RELEASE)
7
8# Dynamic library version information
9# See http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
10
11GDLIB_LT_CURRENT=3
12# This is the version where the soname (current above) changes.  We use it
13# to reset the revision base back to zero.  It's a bit of a pain, but some
14# systems restrict the revision range below to [0..255] (like OS X).
15GDLIB_PREV_MAJOR=2
16GDLIB_PREV_MINOR=2
17# This isn't 100% correct, but it tends to be a close enough approximation
18# for how we manage the codebase.  It's rare to do a release that doesn't
19# modify the library since this project is centered around the library.
20GDLIB_LT_REVISION=$(( ((GDLIB_MAJOR - GDLIB_PREV_MAJOR) << 6) | ((GDLIB_MINOR - GDLIB_PREV_MINOR) << 3) | GDLIB_REVISION ))
21GDLIB_LT_AGE=0
22
23# The first three fields we feed into libtool and the OS target determines how
24# they get used.  The last two fields we feed into cmake.  We use the same rules
25# as Linux SONAME versioning in libtool, but cmake should handle it for us.
26case $1 in
27CURRENT)
28	printf '%s' "${GDLIB_LT_CURRENT}"
29	;;
30REVISION)
31	printf '%s' "${GDLIB_LT_REVISION}"
32	;;
33AGE)
34	printf '%s' "${GDLIB_LT_AGE}"
35	;;
36VERSION)
37	printf '%s' "$(( GDLIB_LT_CURRENT - GDLIB_LT_AGE )).${GDLIB_LT_AGE}.${GDLIB_LT_REVISION}"
38	;;
39SONAME)
40	printf '%s' "$(( GDLIB_LT_CURRENT - GDLIB_LT_AGE ))"
41	;;
42esac
43