1999-07-07 05:34:09 +08:00
|
|
|
#! /bin/sh
|
|
|
|
perl -x -S $0 "$@"
|
|
|
|
exit
|
|
|
|
|
|
|
|
#! perl
|
1998-07-18 03:03:43 +08:00
|
|
|
require 5.003;
|
1999-07-14 01:58:35 +08:00
|
|
|
use strict;
|
1998-07-18 03:03:43 +08:00
|
|
|
|
2003-04-01 01:39:53 +08:00
|
|
|
# Copyright by the Board of Trustees of the University of Illinois.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This file is part of HDF5. The full HDF5 copyright notice, including
|
|
|
|
# terms governing use, modification, and redistribution, is contained in
|
|
|
|
# the files COPYING and Copyright.html. COPYING can be found at the root
|
|
|
|
# of the source code distribution tree; Copyright.html can be found at the
|
|
|
|
# root level of an installed copy of the electronic HDF5 document set and
|
|
|
|
# is linked from the top-level documents page. It can also be found at
|
|
|
|
# http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have
|
|
|
|
# access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu.
|
|
|
|
#
|
1998-07-18 03:03:43 +08:00
|
|
|
# Robb Matzke <matzke@llnl.gov>
|
|
|
|
# 17 July 1998
|
|
|
|
|
|
|
|
### Purpose
|
|
|
|
# Increments the hdf5 version number by changing the value of
|
|
|
|
# constants in the src/H5public.h file. The new version number is
|
|
|
|
# printed on the standard output. An alternate source file name can be
|
|
|
|
# specified as an argument. In any case, the original file is saved
|
|
|
|
# by appending a tilde `~' to the name.
|
|
|
|
|
|
|
|
### Usage:
|
|
|
|
# h5vers [OPTIONS] [FILE]
|
|
|
|
|
|
|
|
# Without options this program only displays the current version and
|
|
|
|
# doesn't modify any files or create backups. The default is to print
|
2000-04-22 03:27:14 +08:00
|
|
|
# the version number like X.Y.Z-A where X is the major version number,
|
|
|
|
# Y is the minor version number, Z is the release number, and A is
|
|
|
|
# a short annotation string (the `-' is printed only if A is not empty).
|
|
|
|
# If the `-v' switch is given the version will be printed like:
|
|
|
|
#
|
|
|
|
# version X.Y release Z (A)
|
|
|
|
#
|
|
|
|
# The space and parentheses around A are only printed if A is not empty.
|
1998-07-18 03:03:43 +08:00
|
|
|
#
|
|
|
|
# The `-s VERSION' switch will set the version as specified. If the
|
|
|
|
# string contains a dotted triple then it will be used as the version
|
|
|
|
# number, otherwise up to three numbers will be read from the end of
|
|
|
|
# the string and used as the major version, minor version, and release
|
|
|
|
# number. If any numbers are missing then zero is assumed. This
|
|
|
|
# allows versions to be specified like `-s "version 2.1 release 8"' or
|
|
|
|
# `-s hdf5-2.1.8.tar.bz2'. If the new version is less than the old
|
2000-04-22 03:27:14 +08:00
|
|
|
# version then a warning message is generated on standard error. The
|
|
|
|
# annotation string, A, is set only if it appears immediately after the
|
|
|
|
# third number, separated by a dash (e.g., `1.2.3-pre1') or in parentheses
|
|
|
|
# (e.g., `version 1.2 release 3 (pre1)').
|
1998-07-18 03:03:43 +08:00
|
|
|
#
|
2000-04-22 03:27:14 +08:00
|
|
|
# The `-i [major|minor|release|annot|last]' option increments the major
|
|
|
|
# number, minor number, release number, or annotation string. The `last'
|
|
|
|
# switch increments the annotation string if present, otherwise the
|
|
|
|
# release number. If the release number is incremented then the annotation
|
|
|
|
# string is cleared. If the minor number is incremented then the release
|
|
|
|
# number is set to zero and the annotation string is cleared; if the major
|
|
|
|
# number is incremented then the minor and release numbers are set to zero
|
|
|
|
# and the annotation string is cleared.
|
1998-07-18 03:03:43 +08:00
|
|
|
#
|
|
|
|
# If a file is specified then that file is used instead of
|
|
|
|
# ./H5public.h or ./src/H5public.h.
|
1999-06-16 23:09:56 +08:00
|
|
|
#
|
|
|
|
# If the version number is changed (either `-s' or `-i' was used on
|
2001-07-06 13:43:38 +08:00
|
|
|
# the command line) then the first line of the README.txt and RELEASE.txt files
|
2001-05-11 06:15:50 +08:00
|
|
|
# one directory above the H5public.h file is also modified so it looks
|
2000-04-22 03:27:14 +08:00
|
|
|
# something like: This is hdf5-1.2.3-pre1 currently under development.
|
2002-04-26 06:37:24 +08:00
|
|
|
# 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])
|
1998-07-18 03:03:43 +08:00
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
sub getvers {
|
|
|
|
local ($_) = @_;
|
|
|
|
my (@vers);
|
|
|
|
|
|
|
|
($vers[0]) = /^\#\s*define\s+H5_VERS_MAJOR\s+(\d+)/m;
|
|
|
|
($vers[1]) = /^\#\s*define\s+H5_VERS_MINOR\s+(\d+)/m;
|
|
|
|
($vers[2]) = /^\#\s*define\s+H5_VERS_RELEASE\s+(\d+)/m;
|
2000-04-22 03:27:14 +08:00
|
|
|
($vers[3]) = /^\#\s*define\s+H5_VERS_SUBRELEASE\s+\"([^\"]*)\"/m;
|
1998-07-18 03:03:43 +08:00
|
|
|
return @vers;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub setvers {
|
|
|
|
my ($contents, @vers) = @_;
|
|
|
|
$_[0] =~ s/^(\#\s*define\s+H5_VERS_MAJOR\s+)\d+/$1$vers[0]/m;
|
|
|
|
$_[0] =~ s/^(\#\s*define\s+H5_VERS_MINOR\s+)\d+/$1$vers[1]/m;
|
|
|
|
$_[0] =~ s/^(\#\s*define\s+H5_VERS_RELEASE\s+)\d+/$1$vers[2]/m;
|
2000-04-22 03:27:14 +08:00
|
|
|
$_[0] =~ s/^(\#\s*define\s+H5_VERS_SUBRELEASE\s+\")[^\"]*/$1$vers[3]/m;
|
2001-05-10 04:34:34 +08:00
|
|
|
$_[0] =~ s/^(\#\s*define\s+H5_VERS_INFO\s+\")[^\"]*/
|
2001-05-11 22:08:27 +08:00
|
|
|
sprintf("%sHDF5 library version: %d.%d.%d%s%s", $1, @vers[0,1,2],
|
2001-05-10 04:34:34 +08:00
|
|
|
$vers[3]?"-":"", $vers[3])/me;
|
1998-07-18 03:03:43 +08:00
|
|
|
}
|
|
|
|
|
1998-09-10 02:19:59 +08:00
|
|
|
sub usage {
|
|
|
|
my ($prog) = $0 =~ /([^\/]+)$/;
|
|
|
|
print STDERR <<EOF;
|
|
|
|
Usage: $prog [OPTS] [FILE]
|
2000-04-22 03:27:14 +08:00
|
|
|
-i major|minor|release|annot
|
1998-09-10 02:19:59 +08:00
|
|
|
Increment specified version component and set following components
|
|
|
|
to zero.
|
|
|
|
-s VERSION
|
|
|
|
Set the version as specified. The version number can be embedded in
|
2000-04-22 03:27:14 +08:00
|
|
|
some other string such as \"hdf5-1.1.0-pre1.tar.bz2\" or even
|
2001-05-11 22:08:27 +08:00
|
|
|
\"this is HDF5 library version 1.1 release 0 (pre1)\" for convenience.
|
1998-09-10 02:19:59 +08:00
|
|
|
-v
|
|
|
|
Instead of displaying only a dotted triple version number a line such
|
2000-04-22 03:27:14 +08:00
|
|
|
as \"version 1.1 release 0 (pre1)\" will be printed.
|
1998-09-10 02:19:59 +08:00
|
|
|
FILE
|
|
|
|
The name of the file that contains version information. This is
|
|
|
|
seldom necessary since files H5public.h, src/H5public.h and
|
|
|
|
../src/H5public.h are automatically checked.
|
|
|
|
EOF
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
1998-07-18 03:03:43 +08:00
|
|
|
# Parse arguments
|
|
|
|
my ($verbose, $set, $inc, $file);
|
|
|
|
my (@files) = ("H5public.h", "src/H5public.h", "../src/H5public.h");
|
|
|
|
while ($_ = shift) {
|
|
|
|
$_ eq "-s" && do {
|
|
|
|
die "-s switch needs a version number\n" unless @ARGV;
|
|
|
|
$set = shift;
|
|
|
|
next;
|
|
|
|
};
|
|
|
|
|
|
|
|
$_ eq "-i" && do {
|
2000-04-22 03:27:14 +08:00
|
|
|
if (@ARGV && $ARGV[0]=~/^(major|minor|release|annot)$/) {
|
1998-07-31 03:48:20 +08:00
|
|
|
$inc = shift;
|
|
|
|
} else {
|
2000-04-22 03:27:14 +08:00
|
|
|
$inc = "last";
|
1998-07-31 03:48:20 +08:00
|
|
|
}
|
1998-07-18 03:03:43 +08:00
|
|
|
next;
|
|
|
|
};
|
|
|
|
|
|
|
|
$_ eq "-v" && do {
|
|
|
|
$verbose = 1;
|
|
|
|
next;
|
|
|
|
};
|
|
|
|
|
1998-09-10 02:19:59 +08:00
|
|
|
/^-(h|\?|-?help)$/ && usage;
|
|
|
|
/^-/ && die "unrecognized option: $_\n";
|
1998-07-18 03:03:43 +08:00
|
|
|
die "only one file name can be specified\n" if $file;
|
1998-09-10 02:19:59 +08:00
|
|
|
$file = $_;
|
1998-07-18 03:03:43 +08:00
|
|
|
}
|
|
|
|
die "mutually exclusive options given\n" if $set && $inc;
|
|
|
|
|
2002-04-26 06:37:24 +08:00
|
|
|
# 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
|
2001-07-06 13:43:38 +08:00
|
|
|
# directory above H5public.h
|
1998-07-18 03:03:43 +08:00
|
|
|
unless ($file) {
|
|
|
|
for (@files) {
|
|
|
|
($file=$_,last) if -f $_;
|
|
|
|
}
|
|
|
|
}
|
1999-07-14 01:58:35 +08:00
|
|
|
die "unable to find source files\n" unless defined $file;
|
1998-07-18 03:03:43 +08:00
|
|
|
die "unable to read file: $file\n" unless -r $file;
|
2001-07-06 13:43:38 +08:00
|
|
|
# README.txt
|
1999-07-14 01:58:35 +08:00
|
|
|
my $README = $file;
|
2001-07-06 13:43:38 +08:00
|
|
|
$README =~ s/[^\/]*$/..\/README.txt/;
|
1999-06-16 23:09:56 +08:00
|
|
|
die "unable to read file: $README\n" unless -r $file;
|
2001-07-06 13:43:38 +08:00
|
|
|
# release_docs/RELEASE.txt
|
2001-05-11 06:15:50 +08:00
|
|
|
my $RELEASE = $file;
|
2001-07-06 13:43:38 +08:00
|
|
|
$RELEASE =~ s/[^\/]*$/..\/release_docs\/RELEASE.txt/;
|
2001-05-11 06:15:50 +08:00
|
|
|
die "unable to read file: $RELEASE\n" unless -r $file;
|
2002-04-26 06:37:24 +08:00
|
|
|
# configure.in
|
|
|
|
my $CONFIGURE = $file;
|
|
|
|
$CONFIGURE =~ s/[^\/]*$/..\/configure.in/;
|
|
|
|
die "unable to read file: $CONFIGURE\n" unless -r $file;
|
1998-07-18 03:03:43 +08:00
|
|
|
|
|
|
|
# Get the current version number.
|
|
|
|
open FILE, $file or die "unable to open $file: $!\n";
|
|
|
|
my ($contents) = join "", <FILE>;
|
|
|
|
close FILE;
|
|
|
|
my (@curver) = getvers $contents;
|
|
|
|
|
|
|
|
# Determine the new version number.
|
1999-07-14 01:58:35 +08:00
|
|
|
my @newver; #new version
|
1998-07-18 03:03:43 +08:00
|
|
|
if ($set) {
|
2000-04-22 03:27:14 +08:00
|
|
|
if ($set =~ /(\d+)\.(\d+)\.(\d+)(-([a-zA-Z]\w*))?/) {
|
|
|
|
@newver = ($1, $2, $3, $5);
|
|
|
|
} elsif ($set =~ /(\d+)\D+(\d+)\D+(\d+)(\s*\(([a-zA-Z]\w*)\))?\D*$/) {
|
|
|
|
@newver = ($1, $2, $3, $5);
|
1998-07-18 03:03:43 +08:00
|
|
|
} elsif ($set =~ /(\d+)\D+(\d+)\D*$/) {
|
2000-04-22 03:27:14 +08:00
|
|
|
@newver = ($1, $2, 0, "");
|
1998-07-18 03:03:43 +08:00
|
|
|
} elsif ($set =~ /(\d+)\D*$/) {
|
2000-04-22 03:27:14 +08:00
|
|
|
@newver = ($1, 0, 0, "");
|
1998-07-18 03:03:43 +08:00
|
|
|
} else {
|
|
|
|
die "illegal version number specified: $set\n";
|
|
|
|
}
|
|
|
|
} elsif ($inc) {
|
2000-04-22 03:27:14 +08:00
|
|
|
$inc = $curver[3] eq "" ? 'release' : 'annot' if $inc eq 'last';
|
|
|
|
if ($inc eq "major") {
|
|
|
|
$newver[0] = $curver[0]+1;
|
|
|
|
@newver[1,2,3] = (0,0,"");
|
|
|
|
} elsif ($inc eq "minor") {
|
|
|
|
$newver[0] = $curver[0];
|
|
|
|
$newver[1] = $curver[1]+1;
|
|
|
|
@newver[2,3] = (0,"");
|
|
|
|
} elsif ($inc eq "release") {
|
|
|
|
@newver[0,1] = @curver[0,1];
|
|
|
|
$newver[2] = $curver[2]+1;
|
|
|
|
$newver[3] = "";
|
|
|
|
} elsif ($inc eq "annot") {
|
|
|
|
@newver[0,1,2] = @curver[0,1,2];
|
|
|
|
$newver[3] = $curver[3];
|
2000-12-21 01:11:19 +08:00
|
|
|
$newver[3] =~ s/(\d+)\D*$/$1+1/e or
|
2000-04-22 03:27:14 +08:00
|
|
|
die "Annotation \"".$newver[3]."\" cannot be incremented.\n";
|
|
|
|
} else {
|
|
|
|
die "unknown increment field: $inc\n";
|
|
|
|
}
|
1998-07-18 03:03:43 +08:00
|
|
|
} else {
|
1999-06-16 23:09:56 +08:00
|
|
|
# Nothing to do but print result
|
|
|
|
$README = "";
|
2001-05-11 06:15:50 +08:00
|
|
|
$RELEASE = "";
|
2002-04-26 06:37:24 +08:00
|
|
|
$CONFIGURE = "";
|
1998-07-18 03:03:43 +08:00
|
|
|
@newver = @curver;
|
|
|
|
}
|
|
|
|
|
2000-04-22 03:27:14 +08:00
|
|
|
# Print a warning if the version got smaller (don't check annot field)
|
1998-07-18 03:03:43 +08:00
|
|
|
if ($newver[0]*1000000 + $newver[1]*1000 + $newver[2] <
|
|
|
|
$curver[0]*1000000 + $curver[1]*1000 + $curver[2]) {
|
|
|
|
printf STDERR "Warning: version decreased from %d.%d.%d to %d.%d.%d\n",
|
2000-04-22 03:27:14 +08:00
|
|
|
@curver[0,1,2], @newver[0,1,2];
|
1998-07-18 03:03:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Update the version number if it changed.
|
|
|
|
if ($newver[0]!=$curver[0] ||
|
|
|
|
$newver[1]!=$curver[1] ||
|
2000-04-22 03:27:14 +08:00
|
|
|
$newver[2]!=$curver[2] ||
|
|
|
|
$newver[3]ne$curver[3]) {
|
1998-07-18 03:03:43 +08:00
|
|
|
setvers $contents, @newver or die "unable to set version\n";
|
|
|
|
rename $file, "$file~" or die "unable to save backup file\n";
|
|
|
|
open FILE, ">$file" or die "unable to open $file but backup saved!\n";
|
|
|
|
print FILE $contents;
|
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
|
2001-07-06 13:43:38 +08:00
|
|
|
# Update the README.txt file
|
1999-06-16 23:09:56 +08:00
|
|
|
if ($README) {
|
|
|
|
open FILE, $README or die "$README: $!\n";
|
1999-07-14 01:58:35 +08:00
|
|
|
my @contents = <FILE>;
|
1999-06-16 23:09:56 +08:00
|
|
|
close FILE;
|
2001-07-06 13:43:38 +08:00
|
|
|
$contents[0] = sprintf("HDF5 version %d.%d.%d%s %s",
|
2000-04-22 03:27:14 +08:00
|
|
|
@newver[0,1,2],
|
|
|
|
$newver[3] eq "" ? "" : "-".$newver[3],
|
|
|
|
"currently under development\n");
|
1999-06-16 23:09:56 +08:00
|
|
|
open FILE, ">$README" or die "$README: $!\n";
|
|
|
|
print FILE @contents;
|
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
|
2001-07-06 13:43:38 +08:00
|
|
|
# Update the release_docs/RELEASE.txt file
|
2001-05-11 06:15:50 +08:00
|
|
|
if ($RELEASE) {
|
|
|
|
open FILE, $RELEASE or die "$RELEASE: $!\n";
|
|
|
|
my @contents = <FILE>;
|
|
|
|
close FILE;
|
2001-07-06 13:43:38 +08:00
|
|
|
$contents[0] = sprintf("HDF5 version %d.%d.%d%s %s",
|
2001-05-11 06:15:50 +08:00
|
|
|
@newver[0,1,2],
|
|
|
|
$newver[3] eq "" ? "" : "-".$newver[3],
|
|
|
|
"currently under development\n");
|
|
|
|
open FILE, ">$RELEASE" or die "$RELEASE: $!\n";
|
|
|
|
print FILE @contents;
|
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
|
2002-04-26 06:37:24 +08:00
|
|
|
sub gen_configure {
|
2002-04-30 01:24:50 +08:00
|
|
|
my ($name, $conf) = @_;
|
2002-04-26 06:37:24 +08:00
|
|
|
|
|
|
|
open FILE, $conf or die "$conf: $!\n";
|
|
|
|
my @contents = <FILE>;
|
|
|
|
close FILE;
|
|
|
|
|
|
|
|
for (my $i = 0; $i < $#contents; ++$i) {
|
|
|
|
if ($contents[$i] =~ /^AC_INIT/) {
|
2002-04-30 01:24:50 +08:00
|
|
|
$contents[$i] = sprintf("AC_INIT([$name], [%d.%d.%d%s], [hdfhelp\@ncsa.uiuc.edu])\n",
|
2002-04-26 06:37:24 +08:00
|
|
|
@newver[0,1,2],
|
|
|
|
$newver[3] eq "" ? "" : "-".$newver[3]);
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
open FILE, ">$conf" or die "$conf: $!\n";
|
|
|
|
print FILE @contents;
|
|
|
|
close FILE;
|
|
|
|
|
|
|
|
$conf =~ /^(.*?)\/?configure.in$/;
|
|
|
|
|
|
|
|
if ($1) {
|
|
|
|
system("cd $1 && autoconf && rm -rf autom4te.cache");
|
|
|
|
} else {
|
|
|
|
system("autoconf && rm -rf autom4te.cache");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Update the configure.in files and regenerate them
|
2002-04-30 01:24:50 +08:00
|
|
|
gen_configure("HDF5", $CONFIGURE) if $CONFIGURE;
|
2002-04-26 06:37:24 +08:00
|
|
|
|
1998-07-18 03:03:43 +08:00
|
|
|
# Print the new version number
|
|
|
|
if ($verbose) {
|
2000-04-22 03:27:14 +08:00
|
|
|
printf("version %d.%d release %d%s\n", @newver[0,1,2],
|
|
|
|
$newver[3] eq "" ? "" : " (".$newver[3].")");
|
1998-07-18 03:03:43 +08:00
|
|
|
} else {
|
2000-04-22 03:27:14 +08:00
|
|
|
printf("%d.%d.%d%s\n", @newver[0,1,2],
|
|
|
|
$newver[3] eq "" ? "" : "-".$newver[3]);
|
1998-07-18 03:03:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
exit 0;
|
2000-04-22 03:27:14 +08:00
|
|
|
|
|
|
|
# Because the first line of this file looks like a Bourne shell script, we
|
|
|
|
# must tell XEmacs explicitly that this is really a perl script.
|
|
|
|
#
|
|
|
|
# Local Variables:
|
|
|
|
# mode:perl
|
|
|
|
# End:
|