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