From d8b08dbc85dfe28d926caf3c03e9d60c63d80794 Mon Sep 17 00:00:00 2001 From: James Laird Date: Mon, 18 Apr 2005 10:48:32 -0500 Subject: [svn-r10627] Purpose: Feature - libtool shared library versioning Description: Libtool provides a mechanism for different versions of the same shared library to be distinguished. Now this is applied to HDF5 when it is built as a shared library. Solution: The version number is stored in config/lt_vers.am, and included in src/Makefile.am. This number will be automatically updated by bin/h5vers; developers only need to update it when they change the API. *** IMPORTANT *** Any time the API changes, the version number in config/lt_vers.am must be updated! Platforms tested: mir, eirene, verbena, modi4 Misc. update: --- MANIFEST | 1 + bin/h5vers | 34 +++++++++++++++++++++++++++++++--- config/lt_vers.am | 26 ++++++++++++++++++++++++++ src/Makefile.am | 4 ++++ src/Makefile.in | 14 ++++++++++++-- 5 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 config/lt_vers.am diff --git a/MANIFEST b/MANIFEST index 9ee04e0..d4349e5 100644 --- a/MANIFEST +++ b/MANIFEST @@ -76,6 +76,7 @@ ./config/linux-gnuaout ./config/linux-gnulibc1 ./config/linux-gnulibc2 +./config/lt_vers.am ./config/Makefile.am.blank ./config/pgi-fflags ./config/pgi-flags diff --git a/bin/h5vers b/bin/h5vers index 508ec3d..9721f30 100755 --- a/bin/h5vers +++ b/bin/h5vers @@ -72,6 +72,12 @@ use strict; # something like: This is hdf5-1.2.3-pre1 currently under development. # The AC_INIT macro in configure.in will also change in this case to be # something like: AC_INIT([HDF5], [hdf5-1.2.3-pre1], [hdfhelp@ncsa.uiuc.edu]) +# +# Whenever the version changes, this script will increment the revision +# field in HDF5's libtool shared library version in config/lt_vers.am, +# which is included in src/Makefile.am. Incrementing the revision field +# indicates that the source code has changed since the last version +# (which it probably has). ############################################################################## sub getvers { @@ -150,9 +156,9 @@ while ($_ = shift) { die "mutually exclusive options given\n" if $set && $inc; # Determine file to use as H5public.h, README.txt, -# release_docs/RELEASE.txt, and configure.in. The README.txt, -# release_docs/RELEASE.txt, and configure.in files are always in the -# directory above H5public.h +# release_docs/RELEASE.txt, configure.in, and config/lt_vers.am. The +# README.txt, release_docs/RELEASE.txt, configure.in, and +# config/lt_vers.am files are always in the directory above H5public.h unless ($file) { for (@files) { ($file=$_,last) if -f $_; @@ -160,6 +166,10 @@ unless ($file) { } die "unable to find source files\n" unless defined $file; die "unable to read file: $file\n" unless -r $file; +# config/lt_vers.am +my $LT_VERS = $file; +$LT_VERS =~ s/[^\/]*$/..\/config\/lt_vers.am/; +die "unable to read file: $LT_VERS\n" unless -r $file; # README.txt my $README = $file; $README =~ s/[^\/]*$/..\/README.txt/; @@ -219,6 +229,7 @@ if ($set) { $README = ""; $RELEASE = ""; $CONFIGURE = ""; + $LT_VERS = ""; @newver = @curver; } @@ -241,6 +252,23 @@ if ($newver[0]!=$curver[0] || close FILE; } +# Update the libtool shared library version in src/Makefile.am +if ($LT_VERS) { + open FILE, $LT_VERS or die "$LT_VERS: $!\n"; + my ($contentsy) = join "", ; + close FILE; + + local($_) = $contentsy; + + my ($lt_revision) = /^LT_VERS_REVISION\s*=\s*(\d+)/m; + my $new_lt_revision = $lt_revision+1; + ($contentsy) =~ s/^(LT_VERS_REVISION\s*=\s*)\d+/$1$new_lt_revision/m; + + open FILE, ">$LT_VERS" or die "$LT_VERS: $!\n"; + print FILE $contentsy; + close FILE; +} + # Update the README.txt file if ($README) { open FILE, $README or die "$README: $!\n"; diff --git a/config/lt_vers.am b/config/lt_vers.am new file mode 100644 index 0000000..a6a6cd6 --- /dev/null +++ b/config/lt_vers.am @@ -0,0 +1,26 @@ +# Add libtool shared library version numbers to the HDF5 library +# See libtool versioning documentation online. +LT_VERS_INTERFACE = 0 +LT_VERS_REVISION = 0 +LT_VERS_AGE = 0 + +## If the API changes *at all*, increment LT_VERS_INTERFACE and +## reset LT_VERS_REVISION to 0. +## +## If the API changes but no functions are removed, also increment +## LT_VERS_AGE. +## If any functions are removed from the API, reset LT_VERS_AGE +## to 0. +## +## If the source changes but there are no API changes, increment +## LT_VERS_REVISION. This will happen automatically when +## bin/h5vers is run, but doing it manually shouldn't hurt +## anything. +## +## Note that this versioning system doesn't attempt to handle +## the effects of the H5_V1_x_COMPAT flag. +## +## Since the revision number is automatically incremented by +## bin/h5vers, don't move LT_VERS_REVISION from the fourth line +## without also editing the script! + diff --git a/src/Makefile.am b/src/Makefile.am index b861b36..50128e2 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,6 +18,7 @@ # include $(top_srcdir)/config/commence.am +include $(top_srcdir)/config/lt_vers.am # How to build H5detect for number format detection. # Use -g to force no optimization since many compilers (e.g., Intel) takes @@ -29,6 +30,9 @@ H5detect_CFLAGS = -g # Our main target, the HDF5 library lib_LTLIBRARIES=libhdf5.la +# Add libtool numbers to the HDF5 library (from config/lt_vers.am) +libhdf5_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) + # Temporary files MOSTLYCLEANFILES=H5detect.o H5detect.lo H5detect H5Tinit.o H5Tinit.lo H5Tinit.c diff --git a/src/Makefile.in b/src/Makefile.in index a48278c..5c5c05f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -60,7 +60,8 @@ host_triplet = @host@ DIST_COMMON = $(include_HEADERS) $(srcdir)/H5config.h.in \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/libhdf5.settings.in $(top_srcdir)/config/commence.am \ - $(top_srcdir)/config/conclude.am + $(top_srcdir)/config/conclude.am \ + $(top_srcdir)/config/lt_vers.am noinst_PROGRAMS = H5detect$(EXEEXT) subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -336,11 +337,20 @@ H5CC = $(bindir)/h5cc H5CC_PP = $(bindir)/h5pcc H5FC = $(bindir)/h5fc H5FC_PP = $(bindir)/h5pfc + +# Add libtool shared library version numbers to the HDF5 library +# See libtool versioning documentation online. +LT_VERS_INTERFACE = 0 +LT_VERS_REVISION = 0 +LT_VERS_AGE = 0 H5detect_CFLAGS = -g # Our main target, the HDF5 library lib_LTLIBRARIES = libhdf5.la +# Add libtool numbers to the HDF5 library (from config/lt_vers.am) +libhdf5_la_LDFLAGS = -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) + # Temporary files MOSTLYCLEANFILES = H5detect.o H5detect.lo H5detect H5Tinit.o H5Tinit.lo H5Tinit.c @@ -420,7 +430,7 @@ all: H5config.h .SUFFIXES: .SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/conclude.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/config/commence.am $(top_srcdir)/config/lt_vers.am $(top_srcdir)/config/conclude.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ -- cgit v0.12