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