Libtool versioning made easy (was Re: Converting libraries and plugins to use gtk3



On 06/11/2010 08:28 AM, Alexander Larsson wrote:
> * Reset the so version to 0:0:0

Those of you who've had to deal with libtool know that libtool versionin is a
PITA.  Here's a snippet to make libtool versioning (and as a result .so
versioning) automatic based on your regular major.minor.micro version number
(and assuming GNOME version conventions).

I'm copying from vte.

In your configure.ac:
===========
m4_define([version_major],0)
m4_define([version_minor],25)
m4_define([version_micro],1)
m4_define([version_triplet],version_major.version_minor.version_micro)

m4_define([so_major_adjust],9) dnl Don't change!

AC_PREREQ([2.59])
AC_INIT(vte, [version_triplet],
        [http://bugzilla.gnome.org/enter_bug.cgi?product=vte])

#################################################################################
Libtool versioning
################################################################################
m4_define([lt_revision], m4_if(m4_eval(version_minor%2),1,0,version_micro))
m4_define([lt_age], m4_eval(version_minor*100+version_micro-lt_revision))
m4_define([lt_current], m4_eval(so_major_adjust+version_major+lt_age))
m4_define([lt_triplet],lt_current:lt_revision:lt_age)

LT_VERSION_INFO="lt_triplet()"
AC_SUBST([LT_VERSION_INFO])
===========

In your src/Makefile.am add "-version-info $(LT_VERSION_INFO)" to your
library's LDFLAGS.

Update the so_major_adjust number such that your so_major matches whatever
your library currently uses.  For example, vte has a major version of 0, but
so-major of 9, so we use a 9 so_major_adjust.

The nice thing about this setup is that you get the library version number in
the .so number.  For stable releases, for example, vte-0.26.5, it will result
in libvte.so.9.2600.5, and for unstable releases, for example, vte-0.25.5, it
results in libvte.so.9.2505.0.

One note though.  When I implemented this scheme in cairo first, we got one
report from some odd unix flavor that libtool had problems handling such large
version numbers.  I've been using it in vte and pango for quite some while by
now though, and have not got any such reports.

Filed bug 623238 to add this to gnome-common.

behdad


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]