| 1 |
#! /bin/sh |
| 2 |
perl -x -S $0 "$@" |
| 3 |
exit |
| 4 |
|
| 5 |
#! perl |
| 6 |
require 5.003; |
| 7 |
use strict; |
| 8 |
|
| 9 |
# Copyright by The HDF Group. |
| 10 |
# Copyright by the Board of Trustees of the University of Illinois. |
| 11 |
# All rights reserved. |
| 12 |
# |
| 13 |
# This file is part of HDF. The full HDF copyright notice, including |
| 14 |
# terms governing use, modification, and redistribution, is contained in |
| 15 |
# the COPYING file, which can be found at the root of the source code |
| 16 |
# distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/. |
| 17 |
# If you do not have access to either file, you may request a copy from |
| 18 |
# [email protected]. |
| 19 |
# |
| 20 |
# |
| 21 |
# Robb Matzke <[email protected]> |
| 22 |
# 17 July 1998 |
| 23 |
# |
| 24 |
# HDF4 alterations |
| 25 |
# Larry Knox <[email protected]> |
| 26 |
# 25 September 2009 |
| 27 |
|
| 28 |
### Purpose |
| 29 |
# Increments the hdf4 version number by changing the value of |
| 30 |
# constants in the hdf/src/hfile.h file. The new version number is |
| 31 |
# printed on the standard output. An alternate source file name can be |
| 32 |
# specified as an argument. In any case, the original file is saved |
| 33 |
# by appending a tilde `~' to the name. |
| 34 |
|
| 35 |
### Usage: |
| 36 |
# h4vers [OPTIONS] [FILE] |
| 37 |
|
| 38 |
# Without options this program only displays the current version and |
| 39 |
# doesn't modify any files or create backups. The default is to print |
| 40 |
# The space and parentheses around A are only printed if A is not empty. |
| 41 |
# |
| 42 |
# The `-s VERSION' switch will set the version as specified. If the |
| 43 |
# string contains a dotted triple then it will be used as the version |
| 44 |
# number, otherwise up to three numbers will be read from the end of |
| 45 |
# the string and used as the major version, minor version, and release |
| 46 |
# number. If any numbers are missing then zero is assumed. This |
| 47 |
# allows versions to be specified like `-s "version 4.2 release 4"' or |
| 48 |
# `-s hdf4-4.2.4.tar.bz2'. If the new version is less than the old |
| 49 |
# version then a warning message is generated on standard error. The |
| 50 |
# annotation string, A, is set only if it appears immediately after the |
| 51 |
# third number, separated by a dash (e.g., `1.2.3-pre1') or in parentheses |
| 52 |
# (e.g., `version 1.2 release 3 (pre1)'). |
| 53 |
# |
| 54 |
# The `-i [major|minor|release|annot|last]' option increments the major |
| 55 |
# number, minor number, release number, or annotation string. The `last' |
| 56 |
# switch increments the annotation string if present, otherwise the |
| 57 |
# release number. If the release number is incremented then the annotation |
| 58 |
# string is cleared. If the minor number is incremented then the release |
| 59 |
# number is set to zero and the annotation string is cleared; if the major |
| 60 |
# number is incremented then the minor and release numbers are set to zero |
| 61 |
# and the annotation string is cleared. |
| 62 |
# |
| 63 |
# If a file is specified then that file is used instead of |
| 64 |
# ./hfile.h or ./hdf/src/hfile.h. |
| 65 |
# |
| 66 |
# If the version number is changed (either `-s' or `-i' was used on |
| 67 |
# the command line) then the first line of the README.md and |
| 68 |
# release_notes/RELEASE.txt two levels above the hfile.h file are also |
| 69 |
# modified so it looks something like: This is hdf4-1.2.3-pre1 currently |
| 70 |
# under development. The AC_INIT macro in configure.in will also change |
| 71 |
# in this case to be something like: AC_INIT([HDF4], [hdf4-1.2.3-pre1], |
| 72 |
# [[email protected]]). |
| 73 |
# |
| 74 |
#Following paragraph from h5vers does not apply for HDF4? |
| 75 |
# Whenever the version changes, this script will increment the revision |
| 76 |
# field in HDF4's libtool shared library version in config/lt_vers.am, |
| 77 |
# which is included in src/Makefile.am. Incrementing the revision field |
| 78 |
# indicates that the source code has changed since the last version |
| 79 |
# (which it probably has). |
| 80 |
############################################################################## |
| 81 |
|
| 82 |
sub getvers { |
| 83 |
local ($_) = @_; |
| 84 |
my (@vers); |
| 85 |
|
| 86 |
($vers[0]) = /^\#\s*define\s+LIBVER_MAJOR\s+(\d+)/m; |
| 87 |
($vers[1]) = /^\#\s*define\s+LIBVER_MINOR\s+(\d+)/m; |
| 88 |
($vers[2]) = /^\#\s*define\s+LIBVER_RELEASE\s+(\d+)/m; |
| 89 |
($vers[3]) = /^\#\s*define\s+LIBVER_SUBRELEASE\s+\"([^\"]*)\"/m; |
| 90 |
($vers[4]) = /^\#\s*define\s+LIBVER_STRING\s+\"([^\"]*\d+)\"/m; |
| 91 |
#The above gets the entire string, below would get just the date portion. |
| 92 |
#($vers[4]) = /^\#\s*define\s+LIBVER_STRING\s+\"[^\"]*,(.*,\s+\d+)\"/m; |
| 93 |
return @vers; |
| 94 |
} |
| 95 |
|
| 96 |
sub setvers { |
| 97 |
my ($contents, @vers) = @_; |
| 98 |
my @months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', |
| 99 |
'August', 'September', 'October', 'November', 'December'); |
| 100 |
my @date = (localtime(time)); |
| 101 |
$_[0] =~ s/^(\#\s*define\s+LIBVER_MAJOR\s+)\d+/$1$vers[0]/m; |
| 102 |
$_[0] =~ s/^(\#\s*define\s+LIBVER_MINOR\s+)\d+/$1$vers[1]/m; |
| 103 |
$_[0] =~ s/^(\#\s*define\s+LIBVER_RELEASE\s+)\d+/$1$vers[2]/m; |
| 104 |
$_[0] =~ s/^(\#\s*define\s+LIBVER_SUBRELEASE\s+\")[^\"]*/$1$vers[3]/m; |
| 105 |
$_[0] =~ s/^(\#\s*define\s+LIBVER_STRING\s+\")[^\"]*/ |
| 106 |
sprintf("%sHDF Version %d.%d Release %d%s%s, %s %d, %d", $1, @vers[0,1,2], |
| 107 |
$vers[3]?"-":"", $vers[3], $months[@date[4]], @date[3], 1900+@date[5])/me; |
| 108 |
my $stringlength = 25 + 32 + length $months[@date[4]] + 2 + 6; |
| 109 |
die "Version string too long: $stringlength characters." unless $stringlength < 81; |
| 110 |
#printf("HDF Version %d.%d Release %d%s%s, %s %d, %d\n", @vers[0,1,2], |
| 111 |
# $vers[3]?"-":"", $vers[3], $months[@date[4]], @date[3], 1900+@date[5]); |
| 112 |
return $_[0]; |
| 113 |
} |
| 114 |
|
| 115 |
sub usage { |
| 116 |
my ($prog) = $0 =~ /([^\/]+)$/; |
| 117 |
print STDERR <<EOF; |
| 118 |
Usage: $prog [OPTS] [FILE] |
| 119 |
-i major|minor|release|annot |
| 120 |
Increment specified version component and set following components |
| 121 |
to zero. |
| 122 |
-s VERSION |
| 123 |
Set the version as specified. The version number can be embedded in |
| 124 |
some other string such as \"hdf4-1.1.0-pre1.tar.bz2\" or even |
| 125 |
\"this is HDF4 library version 1.1 release 0 (pre1)\" for convenience. |
| 126 |
-v |
| 127 |
Instead of displaying only a dotted triple version number a line such |
| 128 |
as \"version 1.1 release 0 (pre1)\" will be printed. |
| 129 |
FILE |
| 130 |
The name of the file that contains version information. This is |
| 131 |
seldom necessary since files hfile.h, hdf/src/hfile.h, |
| 132 |
src/hfile.h, and ../hdf/src/hfile.h are automatically checked. |
| 133 |
EOF |
| 134 |
exit 1; |
| 135 |
} |
| 136 |
|
| 137 |
# Parse arguments |
| 138 |
my ($verbose, $set, $inc, $file, $rc); |
| 139 |
my (@files) = ("hdf/src/hfile.h", "../hdf/src/hfile.h", "src/hfile.h", "hfile.h"); |
| 140 |
while ($_ = shift) { |
| 141 |
$_ eq "-s" && do { |
| 142 |
die "-s switch needs a version number\n" unless @ARGV; |
| 143 |
$set = shift; |
| 144 |
next; |
| 145 |
}; |
| 146 |
|
| 147 |
$_ eq "-i" && do { |
| 148 |
if (@ARGV && $ARGV[0]=~/^(major|minor|release|annot)$/) { |
| 149 |
$inc = shift; |
| 150 |
} else { |
| 151 |
$inc = "last"; |
| 152 |
} |
| 153 |
next; |
| 154 |
}; |
| 155 |
|
| 156 |
$_ eq "-v" && do { |
| 157 |
$verbose = 1; |
| 158 |
next; |
| 159 |
}; |
| 160 |
|
| 161 |
/^-(h|\?|-?help)$/ && usage; |
| 162 |
/^-/ && die "unrecognized option: $_\n"; |
| 163 |
die "only one file name can be specified\n" if $file; |
| 164 |
$file = $_; |
| 165 |
} |
| 166 |
die "mutually exclusive options given\n" if $set && $inc; |
| 167 |
|
| 168 |
#print "file is $file.\n"; |
| 169 |
#print "File array is ", @files; |
| 170 |
|
| 171 |
# Determine file to use as hfile.h, README.md, |
| 172 |
# release_notes/RELEASE.txt, configure.in, |
| 173 |
# and config/cmake/scripts/HDF4config.cmake. |
| 174 |
# The paths to README.md, release_notes/RELEASE.txt, configure.ac, |
| 175 |
# and config/cmake/scripts/HDF4config.cmake |
| 176 |
# files are always from the directory two levels above hfile.h. |
| 177 |
unless ($file) { |
| 178 |
for (@files) { |
| 179 |
($file=$_,last) if -f $_; |
| 180 |
} |
| 181 |
} |
| 182 |
#print "file is $file.\n"; |
| 183 |
|
| 184 |
die "unable to find source file $file\n" unless defined $file; |
| 185 |
die "unable to read file: $file\n" unless -r $file; |
| 186 |
# config/lt_vers.am - HDF4 doesn't have this at present |
| 187 |
#my $LT_VERS = $file; |
| 188 |
#$LT_VERS =~ s/[^\/]*$/..\/config\/lt_vers.am/; |
| 189 |
#die "unable to read file: $LT_VERS\n" unless -r $file; |
| 190 |
# config/cmake/scripts/HDF4config.cmake |
| 191 |
my $HDF4CONFIGCMAKE = $file; |
| 192 |
$HDF4CONFIGCMAKE =~ s/[^\/]*$/..\/..\/config\/cmake\/scripts\/HDF4config.cmake/; |
| 193 |
die "unable to read file: $HDF4CONFIGCMAKE\n" unless -r $file; |
| 194 |
# java/src/hdf/hdflib/HDFLibrary.java |
| 195 |
my $H4_JAVA = $file; |
| 196 |
$H4_JAVA =~ s/[^\/]*$/..\/..\/java\/src\/hdf\/hdflib\/HDFLibrary.java/; |
| 197 |
die "unable to read file: $H4_JAVA\n" unless -r $file; |
| 198 |
# java/test/TestH4.java |
| 199 |
my $H4_TESTJAVA = $file; |
| 200 |
$H4_TESTJAVA =~ s/[^\/]*$/..\/..\/java\/test\/TestH4.java/; |
| 201 |
die "unable to read file: $H4_TESTJAVA\n" unless -r $file; |
| 202 |
# README.md |
| 203 |
my $README = $file; |
| 204 |
$README =~ s/[^\/]*$/..\/..\/README.md/; |
| 205 |
die "unable to read file: $README\n" unless -r $file; |
| 206 |
# release_notes/RELEASE.txt |
| 207 |
my $RELEASE = $file; |
| 208 |
$RELEASE =~ s/[^\/]*$/..\/..\/release_notes\/RELEASE.txt/; |
| 209 |
die "unable to read file: $RELEASE\n" unless -r $file; |
| 210 |
#print $RELEASE, "\n"; |
| 211 |
# configure.in |
| 212 |
my $CONFIGURE = $file; |
| 213 |
$CONFIGURE =~ s/[^\/]*$/..\/..\/configure.ac/; |
| 214 |
die "unable to read file: $CONFIGURE\n" unless -r $file; |
| 215 |
|
| 216 |
# Get the current version number. |
| 217 |
open FILE, $file or die "unable to open $file: $!\n"; |
| 218 |
my ($contents) = join "", <FILE>; |
| 219 |
close FILE; |
| 220 |
my (@curver) = getvers $contents; |
| 221 |
|
| 222 |
#print "Contents: $contents\n"; |
| 223 |
|
| 224 |
#print "curver", @curver, "\n"; |
| 225 |
|
| 226 |
# Determine the new version number. |
| 227 |
my @newver; #new version |
| 228 |
if ($set) { |
| 229 |
if ($set =~ /(\d+)\.(\d+)\.(\d+)(-([\da-zA-Z]\w*))?/) { |
| 230 |
@newver = ($1, $2, $3, $5); |
| 231 |
} elsif ($set =~ /(\d+)\D+(\d+)\D+(\d+)(\s*\(([a-zA-Z]\w*)\))?\D*$/) { |
| 232 |
@newver = ($1, $2, $3, $5); |
| 233 |
} elsif ($set =~ /(\d+)\D+(\d+)\D*$/) { |
| 234 |
@newver = ($1, $2, 0, ""); |
| 235 |
} elsif ($set =~ /(\d+)\D*$/) { |
| 236 |
@newver = ($1, 0, 0, ""); |
| 237 |
} else { |
| 238 |
die "illegal version number specified: $set\n"; |
| 239 |
} |
| 240 |
} elsif ($inc) { |
| 241 |
$inc = $curver[3] eq "" ? 'release' : 'annot' if $inc eq 'last'; |
| 242 |
if ($inc eq "major") { |
| 243 |
$newver[0] = $curver[0]+1; |
| 244 |
@newver[1,2,3] = (0,0,""); |
| 245 |
} elsif ($inc eq "minor") { |
| 246 |
$newver[0] = $curver[0]; |
| 247 |
$newver[1] = $curver[1]+1; |
| 248 |
@newver[2,3] = (0,""); |
| 249 |
} elsif ($inc eq "release") { |
| 250 |
@newver[0,1] = @curver[0,1]; |
| 251 |
$newver[2] = $curver[2]+1; |
| 252 |
$newver[3] = ""; |
| 253 |
} elsif ($inc eq "annot") { |
| 254 |
@newver[0,1,2] = @curver[0,1,2]; |
| 255 |
$newver[3] = $curver[3]; |
| 256 |
$newver[3] =~ s/(\d+)\D*$/$1+1/e or |
| 257 |
die "Annotation \"".$newver[3]."\" cannot be incremented.\n"; |
| 258 |
} else { |
| 259 |
die "unknown increment field: $inc\n"; |
| 260 |
} |
| 261 |
} else { |
| 262 |
# Nothing to do but print result |
| 263 |
$README = ""; |
| 264 |
$RELEASE = ""; |
| 265 |
$CONFIGURE = ""; |
| 266 |
$HDF4CONFIGCMAKE = ""; |
| 267 |
$H4_JAVA = ""; |
| 268 |
$H4_TESTJAVA = ""; |
| 269 |
@newver = @curver; |
| 270 |
} |
| 271 |
|
| 272 |
# Note if the version increased or decreased |
| 273 |
my $version_increased=""; |
| 274 |
# Print a warning if the version got smaller (don't check annot field) |
| 275 |
if ($newver[0]*1000000 + $newver[1]*1000 + $newver[2] < |
| 276 |
$curver[0]*1000000 + $curver[1]*1000 + $curver[2]) { |
| 277 |
printf STDERR "Warning: version decreased from %d.%d.%d to %d.%d.%d\n", |
| 278 |
@curver[0,1,2], @newver[0,1,2]; |
| 279 |
} |
| 280 |
if ($newver[0]*1000000 + $newver[1]*1000 + $newver[2] > |
| 281 |
$curver[0]*1000000 + $curver[1]*1000 + $curver[2]) { |
| 282 |
$version_increased="true"; |
| 283 |
} |
| 284 |
|
| 285 |
# Update the version number if it changed. |
| 286 |
if ($newver[0]!=$curver[0] || |
| 287 |
$newver[1]!=$curver[1] || |
| 288 |
$newver[2]!=$curver[2] || |
| 289 |
$newver[3]ne$curver[3]) { |
| 290 |
setvers $contents, @newver or die "unable to set version\n"; |
| 291 |
rename $file, "$file~" or die "unable to save backup file\n"; |
| 292 |
open FILE, ">$file" or die "unable to open $file but backup saved!\n"; |
| 293 |
print FILE $contents; |
| 294 |
close FILE; |
| 295 |
} |
| 296 |
|
| 297 |
# Update the libtool shared library version in src/Makefile.am if |
| 298 |
# the version number has increased. |
| 299 |
#if ($LT_VERS && $version_increased) { |
| 300 |
# open FILE, $LT_VERS or die "$LT_VERS: $!\n"; |
| 301 |
# my ($contentsy) = join "", <FILE>; |
| 302 |
# close FILE; |
| 303 |
|
| 304 |
# local($_) = $contentsy; |
| 305 |
|
| 306 |
# my ($lt_revision) = /^LT_VERS_REVISION\s*=\s*(\d+)/m; |
| 307 |
# my $new_lt_revision = $lt_revision+1; |
| 308 |
# ($contentsy) =~ s/^(LT_VERS_REVISION\s*=\s*)\d+/$1$new_lt_revision/m; |
| 309 |
|
| 310 |
# open FILE, ">$LT_VERS" or die "$LT_VERS: $!\n"; |
| 311 |
# print FILE $contentsy; |
| 312 |
# close FILE; |
| 313 |
#} |
| 314 |
|
| 315 |
# Update the README file |
| 316 |
if ($README) { |
| 317 |
open FILE, $README or die "$README: $!\n"; |
| 318 |
my @contents = <FILE>; |
| 319 |
close FILE; |
| 320 |
$contents[0] = sprintf("HDF version %d.%d.%d%s %s", |
| 321 |
@newver[0,1,2], |
| 322 |
$newver[3] eq "" ? "" : "-".$newver[3], |
| 323 |
"currently under development\n"); |
| 324 |
open FILE, ">$README" or die "$README: $!\n"; |
| 325 |
print FILE @contents; |
| 326 |
close FILE; |
| 327 |
} |
| 328 |
|
| 329 |
# Update the release_notes/RELEASE.txt file |
| 330 |
if ($RELEASE) { |
| 331 |
open FILE, $RELEASE or die "$RELEASE: $!\n"; |
| 332 |
my @contents = <FILE>; |
| 333 |
close FILE; |
| 334 |
$contents[0] = sprintf("HDF version %d.%d.%d%s %s", |
| 335 |
@newver[0,1,2], |
| 336 |
$newver[3] eq "" ? "" : "-".$newver[3], |
| 337 |
"currently under development\n"); |
| 338 |
open FILE, ">$RELEASE" or die "$RELEASE: $!\n"; |
| 339 |
print FILE @contents; |
| 340 |
close FILE; |
| 341 |
} |
| 342 |
|
| 343 |
# Update the config/cmake/scripts/HDF4config.cmake file |
| 344 |
if ($HDF4CONFIGCMAKE) { |
| 345 |
my $data = read_file($HDF4CONFIGCMAKE); |
| 346 |
# my $sub_rel_ver_str = ""; |
| 347 |
my $sub_rel_ver_str = ( |
| 348 |
$newver[3] eq "" |
| 349 |
? sprintf("\"%s\"", "") |
| 350 |
: sprintf("\"%s\"", "-".$newver[3]) |
| 351 |
); |
| 352 |
my $version_string = sprintf("\"%d.%d.%d\"", @newver[0,1,2]); |
| 353 |
|
| 354 |
$data =~ s/set \(CTEST_SOURCE_VERSION .*\)/set \(CTEST_SOURCE_VERSION $version_string\)/; |
| 355 |
$data =~ s/set \(CTEST_SOURCE_VERSEXT .*\)/set \(CTEST_SOURCE_VERSEXT $sub_rel_ver_str\)/; |
| 356 |
|
| 357 |
write_file($HDF4CONFIGCMAKE, $data); |
| 358 |
} |
| 359 |
|
| 360 |
# Update the java/src/hdf/hdflib/HDFLibrary.java file |
| 361 |
if ($H4_JAVA) { |
| 362 |
my $data = read_file($H4_JAVA); |
| 363 |
my $version_string = sprintf("%d.%d.%d", @newver[0,1,2]); |
| 364 |
|
| 365 |
$data =~ s/ private final static String JHI_VERSION = "\d*.\d*.\d*";/ private final static String JHI_VERSION = "$version_string";/; |
| 366 |
|
| 367 |
write_file($H4_JAVA, $data); |
| 368 |
} |
| 369 |
|
| 370 |
# Update the java/test/TestH4.java file |
| 371 |
if ($H4_TESTJAVA) { |
| 372 |
my $data = read_file($H4_TESTJAVA); |
| 373 |
my $version_string = sprintf("%d, %d, %d", @newver[0,1,2]); |
| 374 |
|
| 375 |
$data =~ s/ int LIB_VERSION\[\] = \{.*\};/ int LIB_VERSION\[\] = \{$version_string\};/; |
| 376 |
|
| 377 |
write_file($H4_TESTJAVA, $data); |
| 378 |
} |
| 379 |
|
| 380 |
# Update the man/hdf.1 file |
| 381 |
# There are currently 2 occurrences of the version string in the man/hdf.1 file. |
| 382 |
# Since they aren't the top line of the file we search rewrite the file line by |
| 383 |
# line, searching for the current major.minor.release version string, and replacing |
| 384 |
# it with the new one. In case someone changes the version string manually or it |
| 385 |
# otherwise gets out of sync, or another match is found that should not be updated, |
| 386 |
# we will track the changes in this file, issue an error message and exit at if |
| 387 |
# the number of changes is different than the 2 expected. |
| 388 |
|
| 389 |
# helper function to read the file for updating |
| 390 |
# config/cmake/scripts/HDF4Config.cmake and |
| 391 |
# java/src/hdf/hdflib/HDFLibrary.java files. |
| 392 |
# The version string in those files is not at the top, so the string replacement |
| 393 |
# is not for the first line, and reading/writing the entire file as one string |
| 394 |
# facilitates the substring replacement. |
| 395 |
sub read_file { |
| 396 |
my ($filename) = @_; |
| 397 |
|
| 398 |
open my $in, $filename or die "Could not open '$filename' for reading $!"; |
| 399 |
local $/ = undef; |
| 400 |
my $all = <$in>; |
| 401 |
close $in; |
| 402 |
|
| 403 |
return $all; |
| 404 |
} |
| 405 |
|
| 406 |
# helper function to write the file for updating |
| 407 |
# config/cmake/scripts/HDF4config.cmake and |
| 408 |
# java/src/hdf/hdflib/HDFLibrary.java files. |
| 409 |
sub write_file { |
| 410 |
my ($filename, $content) = @_; |
| 411 |
|
| 412 |
open my $out, ">$filename" or die "Could not open '$filename' for writing $!";; |
| 413 |
print $out $content; |
| 414 |
close $out; |
| 415 |
|
| 416 |
return; |
| 417 |
} |
| 418 |
|
| 419 |
|
| 420 |
sub gen_configure { |
| 421 |
my ($name, $conf) = @_; |
| 422 |
|
| 423 |
open FILE, $conf or die "$conf: $!\n"; |
| 424 |
my @contents = <FILE>; |
| 425 |
close FILE; |
| 426 |
|
| 427 |
for (my $i = 0; $i < $#contents; ++$i) { |
| 428 |
if ($contents[$i] =~ /^AC_INIT/) { |
| 429 |
$contents[$i] = sprintf("AC_INIT([$name], [%d.%d.%d%s], [help\@hdfgroup.org])\n", |
| 430 |
@newver[0,1,2], |
| 431 |
$newver[3] eq "" ? "" : "-".$newver[3]); |
| 432 |
last; |
| 433 |
} |
| 434 |
} |
| 435 |
|
| 436 |
open FILE, ">$conf" or die "$conf: $!\n"; |
| 437 |
print FILE @contents; |
| 438 |
close FILE; |
| 439 |
|
| 440 |
$conf =~ /^(.*?)\/?configure.ac$/; |
| 441 |
|
| 442 |
if ($1) { |
| 443 |
$rc = system("cd $1 && ./autogen.sh >/dev/null 2>/dev/null && rm -rf autom4te.cache"); |
| 444 |
} else { |
| 445 |
$rc = system("./autogen.sh >/dev/null 2>/dev/null && rm -rf autom4te.cache"); |
| 446 |
} |
| 447 |
if ($rc) { |
| 448 |
printf("./autogen.sh failed with exit code %d. Aborted.\n", $rc); |
| 449 |
exit 1; |
| 450 |
} |
| 451 |
} |
| 452 |
|
| 453 |
# Update the configure.ac files and regenerate them |
| 454 |
gen_configure("HDF", $CONFIGURE) if $CONFIGURE; |
| 455 |
|
| 456 |
sub gen_h4pubconf { |
| 457 |
my ($name, $pubconf, @vers) = @_; |
| 458 |
|
| 459 |
my $namelc = lc($name); |
| 460 |
my $nameuc = uc($name); |
| 461 |
|
| 462 |
open FILE, $pubconf or die "$pubconf: $!\n"; |
| 463 |
my @contents = <FILE>; |
| 464 |
close FILE; |
| 465 |
|
| 466 |
for (my $i = 0; $i < $#contents; ++$i) { |
| 467 |
if ($contents[$i] =~ /\#\s*define\s+H4_PACKAGE\s+/) { |
| 468 |
$contents[$i] = "\#define H4_PACKAGE \"$namelc\"\n"; |
| 469 |
} elsif ($contents[$i] =~ /\#\s*define\s+H4_PACKAGE_NAME\s+/) { |
| 470 |
$contents[$i] = "\#define H4_PACKAGE_NAME \"$nameuc\"\n"; |
| 471 |
} elsif ($contents[$i] =~ /\#\s*define\s+H4_PACKAGE_STRING\s+/) { |
| 472 |
$contents[$i] = sprintf("\#define H4_PACKAGE_STRING \"$nameuc %d.%d.%d%s\"\n", |
| 473 |
@vers[0,1,2], |
| 474 |
$newver[3] eq "" ? "" : "-".$newver[3]); |
| 475 |
} elsif ($contents[$i] =~ /\#\s*define\s+H4_PACKAGE_TARNAME\s+/) { |
| 476 |
$contents[$i] = "\#define H4_PACKAGE_TARNAME \"$namelc\"\n"; |
| 477 |
} elsif ($contents[$i] =~ /\#\s*define\s+H4_PACKAGE_VERSION\s+/) { |
| 478 |
$contents[$i] = sprintf("\#define H4_PACKAGE_VERSION \"%d.%d.%d%s\"\n", |
| 479 |
@vers[0,1,2], |
| 480 |
$newver[3] eq "" ? "" : "-".$newver[3]); |
| 481 |
} elsif ($contents[$i] =~ /\#\s*define\s+H4_VERSION\s+/) { |
| 482 |
$contents[$i] = sprintf("\#define H4_VERSION \"%d.%d.%d%s\"\n", |
| 483 |
@vers[0,1,2], |
| 484 |
$newver[3] eq "" ? "" : "-".$newver[3]); |
| 485 |
} |
| 486 |
} |
| 487 |
|
| 488 |
open FILE, ">$pubconf" or die "$pubconf: $!\n"; |
| 489 |
print FILE @contents; |
| 490 |
close FILE; |
| 491 |
} |
| 492 |
|
| 493 |
# Print the new version number |
| 494 |
if ($verbose) { |
| 495 |
#printf("Version %d.%d Release %d%s\n", @newver[0,1,2], |
| 496 |
# $newver[3] eq "" ? "" : " (".$newver[3].")"); |
| 497 |
printf("%s\n", $newver[4]); |
| 498 |
} else { |
| 499 |
printf("%d.%d.%d%s\n", @newver[0,1,2], |
| 500 |
$newver[3] eq "" ? "" : "-".$newver[3]); |
| 501 |
} |
| 502 |
|
| 503 |
exit 0; |
| 504 |
|
| 505 |
# Because the first line of this file looks like a Bourne shell script, we |
| 506 |
# must tell XEmacs explicitly that this is really a perl script. |
| 507 |
# |
| 508 |
# Local Variables: |
| 509 |
# mode:perl |
| 510 |
# End: |