ck-version-info revision 1.1.1.1.8.2 1 1.1.1.1.8.2 tls #!/usr/bin/env perl
2 1.1.1.1.8.2 tls
3 1.1.1.1.8.2 tls # Note: this script must not be used to build MPFR due to the
4 1.1.1.1.8.2 tls # dependency on perl, but this is OK for "make dist".
5 1.1.1.1.8.2 tls
6 1.1.1.1.8.2 tls # Copyright 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
7 1.1.1.1.8.2 tls # This script is free software; the Free Software Foundation
8 1.1.1.1.8.2 tls # gives unlimited permission to copy and/or distribute it,
9 1.1.1.1.8.2 tls # with or without modifications, as long as this notice is preserved.
10 1.1.1.1.8.2 tls
11 1.1.1.1.8.2 tls # This program is distributed in the hope that it will be useful,
12 1.1.1.1.8.2 tls # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13 1.1.1.1.8.2 tls # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 1.1.1.1.8.2 tls # PARTICULAR PURPOSE.
15 1.1.1.1.8.2 tls
16 1.1.1.1.8.2 tls use strict;
17 1.1.1.1.8.2 tls use Cwd;
18 1.1.1.1.8.2 tls
19 1.1.1.1.8.2 tls if (! -d 'src')
20 1.1.1.1.8.2 tls {
21 1.1.1.1.8.2 tls getcwd() =~ m,/tools$,
22 1.1.1.1.8.2 tls or die "Execute $0 from the MPFR source directory\n";
23 1.1.1.1.8.2 tls chdir '..' or die "$!\n$0: can't change cwd\n";
24 1.1.1.1.8.2 tls }
25 1.1.1.1.8.2 tls
26 1.1.1.1.8.2 tls open VERSION, '<', 'VERSION'
27 1.1.1.1.8.2 tls or die "$!\n$0: can't open VERSION file\n";
28 1.1.1.1.8.2 tls my $version = do { local $/; <VERSION> };
29 1.1.1.1.8.2 tls close VERSION or die "$!\n$0: can't close VERSION file\n";
30 1.1.1.1.8.2 tls
31 1.1.1.1.8.2 tls my ($mv,$pl,$suf) = $version =~ /^(\d+\.\d+)\.(\d+)(-\S+)?/
32 1.1.1.1.8.2 tls or die "$0: bad VERSION format\n";
33 1.1.1.1.8.2 tls
34 1.1.1.1.8.2 tls open MF, '<', 'src/Makefile.am'
35 1.1.1.1.8.2 tls or die "$!\n$0: can't open Makefile.am file\n";
36 1.1.1.1.8.2 tls my $cur = 0;
37 1.1.1.1.8.2 tls my $age = -1;
38 1.1.1.1.8.2 tls my $vinfo; # expected -version-info value
39 1.1.1.1.8.2 tls while (<MF>)
40 1.1.1.1.8.2 tls {
41 1.1.1.1.8.2 tls last if $cur && ! /^\s*(#.*)$/;
42 1.1.1.1.8.2 tls /^#\s+(\d+\.\d+)\.x\s+(\d+):x:(\d+)/ or next;
43 1.1.1.1.8.2 tls $2 == ++$cur or die "$0: bad CURRENT ($2)";
44 1.1.1.1.8.2 tls $3 == 0 || $3 == $age + 1 or die "$0: bad AGE ($3)";
45 1.1.1.1.8.2 tls $age = $3;
46 1.1.1.1.8.2 tls $mv eq $1 and $vinfo = "$cur:$pl:$age";
47 1.1.1.1.8.2 tls }
48 1.1.1.1.8.2 tls /^libmpfr_la_LDFLAGS\s+=.*\s-version-info\s+(\d+:\d+:\d+)\s/
49 1.1.1.1.8.2 tls or die "$0: missing correct libmpfr_la_LDFLAGS line";
50 1.1.1.1.8.2 tls close MF or die "$!\n$0: can't close Makefile.am file\n";
51 1.1.1.1.8.2 tls $suf eq '-dev' || $vinfo eq $1
52 1.1.1.1.8.2 tls or die "$0: bad -version-info value ($1 instead of $vinfo)\n";
53 1.1.1.1.8.2 tls
54 1.1.1.1.8.2 tls open CONFIGURE, '<', 'configure.ac'
55 1.1.1.1.8.2 tls or die "$!\n$0: can't open configure.ac file\n";
56 1.1.1.1.8.2 tls my $dllversion = $cur - $age;
57 1.1.1.1.8.2 tls my $dllvinconf;
58 1.1.1.1.8.2 tls while (<CONFIGURE>)
59 1.1.1.1.8.2 tls {
60 1.1.1.1.8.2 tls /^\s*LIBMPFR_LDFLAGS\s*=.*-Wl,--output-def,\.libs\/libmpfr-(\d+)\.dll\.def/
61 1.1.1.1.8.2 tls and $dllvinconf = $1, last;
62 1.1.1.1.8.2 tls }
63 1.1.1.1.8.2 tls close CONFIGURE or die "$!\n$0: can't close configure.ac file\n";
64 1.1.1.1.8.2 tls defined $dllvinconf or die "$0: missing correct LIBMPFR_LDFLAGS line\n";
65 1.1.1.1.8.2 tls $suf eq '-dev' || $dllversion eq $dllvinconf
66 1.1.1.1.8.2 tls or die "$0: bad libmpfr.dll-version value (libmpfr-$dllvinconf.dll.def".
67 1.1.1.1.8.2 tls " instead of libmpfr-$dllversion.dll.def)\n";
68