Hello community, here is the log from the commit of package perl-ExtUtils-F77 for openSUSE:Factory checked in at 2019-01-08 12:28:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-ExtUtils-F77 (Old) and /work/SRC/openSUSE:Factory/.perl-ExtUtils-F77.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-ExtUtils-F77" Tue Jan 8 12:28:39 2019 rev:26 rq:663167 version:1.23 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-ExtUtils-F77/perl-ExtUtils-F77.changes 2018-12-12 17:26:57.290993348 +0100 +++ /work/SRC/openSUSE:Factory/.perl-ExtUtils-F77.new.28833/perl-ExtUtils-F77.changes 2019-01-08 12:31:06.192100536 +0100 @@ -1,0 +2,15 @@ +Sun Jan 6 06:06:44 UTC 2019 - Stephan Kulow <[email protected]> + +- updated to 1.23 + see /usr/share/doc/packages/perl-ExtUtils-F77/CHANGES + + v1.23 released Jan 5th 2019 + --------------------------- + + * Use File::Which and List::Util instead of bespoke code (mohawk2) + * Improvements to docs (karlglazebrook,mohawk2) + * improvements to tests and warnings (mohawk2) + * tidy up of code (mohawk2) + * simplify out of gfortran handling (mohawk2) + +------------------------------------------------------------------- Old: ---- ExtUtils-F77-1.22.tar.gz New: ---- ExtUtils-F77-1.23.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-ExtUtils-F77.spec ++++++ --- /var/tmp/diff_new_pack.4Brfkg/_old 2019-01-08 12:31:06.688099997 +0100 +++ /var/tmp/diff_new_pack.4Brfkg/_new 2019-01-08 12:31:06.692099992 +0100 @@ -1,7 +1,7 @@ # # spec file for package perl-ExtUtils-F77 # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: perl-ExtUtils-F77 -Version: 1.22 +Version: 1.23 Release: 0 %define cpan_name ExtUtils-F77 Summary: Simple interface to F77 libs @@ -30,6 +30,8 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros +BuildRequires: perl(File::Which) +Requires: perl(File::Which) %{perl_requires} # MANUAL BEGIN BuildRequires: gcc-fortran @@ -40,7 +42,9 @@ This module tries to figure out how to link C programs with Fortran subroutines on your system. Basically one must add a list of Fortran runtime libraries. The problem is their location and name varies with each -OS/compiler combination! +OS/compiler combination! It was originally developed to make building and +installation of the PGPLOT module easier, which links to the pgplot Fortran +graphics library. It is now used by a numnber of perl modules. This module tries to implement a simple 'rule-of-thumb' database for various flavours of UNIX systems. A simple self-documenting Perl database @@ -58,7 +62,7 @@ setting the environment variable F77LIBS, e.g. % setenv F77LIBS "-lfoo -lbar" - % perl Makefile.PL + % perl -MExtUtils::F77 -e 'print ExtUtils::F77->compiler, "\n"' ... %prep ++++++ ExtUtils-F77-1.22.tar.gz -> ExtUtils-F77-1.23.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ExtUtils-F77-1.22/CHANGES new/ExtUtils-F77-1.23/CHANGES --- old/ExtUtils-F77-1.22/CHANGES 2018-12-02 07:31:14.000000000 +0100 +++ new/ExtUtils-F77-1.23/CHANGES 2019-01-05 07:03:24.000000000 +0100 @@ -1,6 +1,16 @@ ExtUtils::F77 Changes list -------------------------- +v1.23 released Jan 5th 2019 +--------------------------- + +* Use File::Which and List::Util instead of bespoke code (mohawk2) +* Improvements to docs (karlglazebrook,mohawk2) +* improvements to tests and warnings (mohawk2) +* tidy up of code (mohawk2) +* simplify out of gfortran handling (mohawk2) + + v1.22 released Dec 2nd 2018 --------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ExtUtils-F77-1.22/F77.pm new/ExtUtils-F77-1.23/F77.pm --- old/ExtUtils-F77-1.22/F77.pm 2018-12-02 07:30:16.000000000 +0100 +++ new/ExtUtils-F77-1.23/F77.pm 2019-01-05 06:56:24.000000000 +0100 @@ -1,60 +1,37 @@ - package ExtUtils::F77; +use strict; +use warnings; use Config; use File::Spec; use Text::ParseWords; +use File::Which qw(which); +use List::Util qw(first); -=head1 NAME - -ExtUtils::F77 - Simple interface to F77 libs - -=head1 DESCRIPTION - -This module tries to figure out how to link C programs with -Fortran subroutines on your system. Basically one must add a list -of Fortran runtime libraries. The problem is their location -and name varies with each OS/compiler combination! - -This module tries to implement a simple -'rule-of-thumb' database for various flavours of UNIX systems. -A simple self-documenting Perl database of knowledge/code -for figuring out how to link for various combinations of OS and -compiler is embedded in the modules Perl code. Please help -save the world by submitted patches for new database entries for -your system at L<https://github.com/PDLPorters/extutils-f77> - -Note the default on most systems is now to search for a generic 'GNU' compiler -which can be gfortran, g77, g95 or fort77 (in that order based on usage) and then find -the appropriate link libraries automatically. (This is the 'Generic' 'GNU' database entry -in the code.) - -The library list which the module returns -can be explicitly overridden by setting the environment -variable F77LIBS, e.g. - - % setenv F77LIBS "-lfoo -lbar" - % perl Makefile.PL - ... - -=cut - -$VERSION = "1.22"; - -warn "\nExtUtils::F77: Version $VERSION\n"; - -# Database starts here. Basically we have a large hash specifying -# entries for each os/compiler combination. Entries can be code refs -# in which case they are executed and the returned value used. This -# allows us to be quite smart. +our $VERSION = "1.23"; +our $DEBUG; -# Hash key convention is uppercase first letter of -# hash keys. First key is usually the name of the architecture as -# returned by Config (modulo ucfirst()). +sub debug { return if !$DEBUG; warn @_ } print "Loaded ExtUtils::F77 version $VERSION\n"; -%F77config=(); +my %F77config=(); +my $Runtime = "-LSNAFU -lwontwork"; +my $RuntimeOK = 0; +my $Trail_ = 1; +my $Pkg = ""; +my $Compiler = ""; +my $Cflags = ""; +my ($gcc, $gfortran, $fallback_compiler); + +# all the compilers and their libraries +my %COMPLIBS = ( + g77 => [qw/ g2c f2c /], + f77 => [qw/ g2c f2c /], + fort77 => [qw/ g2c f2c /], + gfortran => [qw/ gfortran /], + g95 => [qw/ f95 /], +); ########## Win32 Specific ############## @@ -69,7 +46,7 @@ elsif ($Config{gccversion}) { # Different fortran compiler for gcc-4.x.x (and later) versus gcc-3.x.x $gcc = 'gcc'; - @version = split /\./, $Config{gccversion}; + @version = split /\./, $Config{gccversion}; $fallback_compiler = $version[0] >= 4 ? 'GFortran' : 'G77'; $gfortran = 'gfortran'; } @@ -88,82 +65,88 @@ ############## End of Win32 Specific ############## +# Database starts here. Basically we have a large hash specifying +# entries for each os/compiler combination. Entries can be code refs +# in which case they are executed and the returned value used. This +# allows us to be quite smart. + +# Hash key convention is uppercase first letter of +# hash keys. First key is usually the name of the architecture as +# returned by Config (modulo ucfirst()). + +# Format is: OS, then compiler-family, then specific keys: + +# DEFAULT: as a compiler-family, gives name of default compiler-family - corresponds to one of the keys + +# Link: Code to figure out and return link-string for this architecture +# Returns false if it can't find anything sensible. + +# Trail_: Whether symbols (subroutine names etc.) have trailing underscores +# (true/false) + +# Compiler: Program to run to actually compile stuff + +# Cflags: Associated compiler flags + +sub gfortran_make_linkline { + my ($dir, $lib, $defaultdir, $defaultlib, $append) = @_; + $dir ||= $defaultdir; + $lib ||= $defaultlib; + $append ||= ''; + return( qq{"-L$dir" $append -L/usr/lib -l$lib -lm} ); +} + +sub gfortran_find_libdir { + my ($compiler, $lib) = @_; + for my $suffix (qw(a so)) { + my $filename = "lib$lib.$suffix"; + my $dir = `$compiler -print-file-name=$filename`; + chomp $dir; + # Note that -print-file-name returns just the library name + # if it cant be found - make sure that we only accept the + # directory if it returns a proper path (or matches a /) + next if !defined $dir or $dir eq $lib; + $dir =~ s,/$filename$,,; + return $dir; + } +} + $F77config{MinGW}{G77}{Link} = sub { my @libs = ('g2c', 'f2c'); my ($dir, $lib, $test); foreach $test (@libs) { - $dir = `g77 -print-file-name=lib$test.a`; - chomp $dir; - # Note that -print-file-name returns just the library name - # if it cant be found - make sure that we only accept the - # directory if it returns a proper path (or matches a /) - if (defined $dir && $dir ne "lib$test.a") { - $lib = $test; # Found an existing library - last; - } + $dir = gfortran_find_libdir('g77', $test); + $lib = $test, last if defined $dir; } - - if ( defined $dir && defined $lib) { - $dir =~ s,/lib$lib.a$,,; - } else { - $dir = "/usr/local/lib"; - $lib = "f2c"; - } - return( qq{"-L$dir" -L/usr/lib -l$lib -lm} ); + gfortran_make_linkline($dir, $lib, "/usr/local/lib", "f2c"); }; +$F77config{MinGW}{G77}{Trail_} = 1; +$F77config{MinGW}{G77}{Compiler} = find_in_path('g77','f77','fort77'); +$F77config{MinGW}{G77}{Cflags} = '-O'; $F77config{MinGW}{GFortran}{Link} = sub { - $dir = `$gfortran -print-file-name=libgfortran.a`; - chomp $dir; - # Note that -print-file-name returns just the library name - # if it cant be found - make sure that we only accept the - # directory if it returns a proper path (or matches a /) - - if ( defined $dir ) { - $dir =~ s,/libgfortran.a$,,; - } else { - $dir = "/usr/local/lib"; - } - return( qq{"-L$dir" -L/usr/lib -lgfortran -lquadmath -lm} ); + my $dir = gfortran_find_libdir($gfortran, 'gfortran'); + gfortran_make_linkline($dir, "gfortran", "/usr/local/lib", "", '-lquadmath'); }; - -$F77config{MinGW}{G77}{Trail_} = 1; $F77config{MinGW}{GFortran}{Trail_} = 1; -$F77config{MinGW}{G77}{Compiler} = find_in_path('g77','f77','fort77'); $F77config{MinGW}{GFortran}{Compiler} = "$gfortran"; -$F77config{MinGW}{G77}{Cflags} = '-O'; $F77config{MinGW}{GFortran}{Cflags} = '-O'; ### SunOS (use this as a template for new entries) ### -# Code to figure out and return link-string for this architecture -# Returns false if it can't find anything sensible. - -$F77config{Sunos}{F77}{Link} = sub { - $dir = find_highest_SC("/usr/lang/SC*"); +$F77config{Sunos}{F77}{Link} = sub { + my $dir = find_highest_SC("/usr/lang/SC*"); return "" unless $dir; # Failure - print "$Pkg: Found Fortran latest version lib dir $dir\n"; + debug "$Pkg: Found Fortran latest version lib dir $dir\n"; return qq{"-L$dir" -lF77 -lm}; }; - -# Whether symbols (subroutine names etc.) have trailing underscores -# (true/false) - -$F77config{Sunos}{F77}{Trail_} = 1; - -# Name of default compiler - corresponds to one of the above keys - -$F77config{Sunos}{DEFAULT} = 'F77'; - -# Program to run to actually compile stuff - +$F77config{Sunos}{F77}{Trail_} = 1; $F77config{Sunos}{F77}{Compiler} = 'f77'; - -# Associated compiler flags - $F77config{Sunos}{F77}{Cflags} = '-O'; -############ Rest of database is here ############ +$F77config{Sunos}{DEFAULT} = 'F77'; + +############ Rest of database is here ############ ### Solaris ### @@ -188,10 +171,8 @@ } } - if (defined $NSPATH) { - - print "$Pkg: Found F77 path:--->$NSPATH\n"; + debug "$Pkg: Found F77 path:--->$NSPATH\n"; $dir = find_highest_SC("$NSPATH/WS*/lib") || find_highest_SC("$NSPATH/SC*/lib") || @@ -201,14 +182,12 @@ # match for libF77.*, as libF77.a isn't there anymore? unless ( $dir ) { - print "$Pkg: Trying $NSPATH/lib\n"; + debug "$Pkg: Trying $NSPATH/lib\n"; $dir = "$NSPATH/lib" if glob("$NSPATH/lib/libF77*"); } - - } else { } return "" unless $dir; # Failure - print "$Pkg: Found Fortran latest version lib dir $dir\n"; + debug "$Pkg: Found Fortran latest version lib dir $dir\n"; my @libs; @@ -230,7 +209,7 @@ -lfmaxlai -lfminvai -lfmaxvai - -lfsu + -lfsu -lsunmath -lm /; @@ -247,32 +226,34 @@ join( ' ', qq{"-L$dir"}, @libs ); }; - - $F77config{Solaris}{F77}{Trail_} = 1; $F77config{Solaris}{F77}{Compiler} = 'f77'; $F77config{Solaris}{F77}{Cflags} = '-O'; + $F77config{Solaris}{DEFAULT} = 'F77'; ### Generic GNU-77 or F2C system ### $F77config{Generic}{GNU}{Trail_} = 1; $F77config{Generic}{GNU}{Cflags} = ' '; # <---need this space! -$F77config{Generic}{GNU}{Link} = link_gnufortran_compiler('gfortran', 'g77', 'g95', 'fort77'); +$F77config{Generic}{GNU}{Link} = link_gnufortran_compiler('gfortran', 'g77', 'g95', 'fort77'); $F77config{Generic}{GNU}{Compiler} = find_in_path("$gfortran", 'g77', 'g95','fort77'); + $F77config{Generic}{DEFAULT} = 'GNU'; ### cygwin ### $F77config{Cygwin}{GNU}{Trail_} = 1; $F77config{Cygwin}{GNU}{Cflags} = '-O'; # <---need this space! -$F77config{Cygwin}{GNU}{Link} = link_gnufortran_compiler('g77', 'gfortran', 'g95', 'fort77'); +$F77config{Cygwin}{GNU}{Link} = link_gnufortran_compiler('g77', 'gfortran', 'g95', 'fort77'); $F77config{Cygwin}{GNU}{Compiler} = find_in_path('g77', "$gfortran", 'g95','fort77'); + $F77config{Cygwin}{DEFAULT} = 'GNU'; ### Linux ### $F77config{Linux}{GNU} = $F77config{Generic}{GNU}; + $F77config{Linux}{DEFAULT} = 'GNU'; ### DEC OSF/1 ### @@ -281,6 +262,7 @@ $F77config{Dec_osf}{F77}{Trail_} = 1; $F77config{Dec_osf}{F77}{Compiler} = 'f77'; $F77config{Dec_osf}{F77}{Cflags} = '-O'; + $F77config{Dec_osf}{DEFAULT} = 'F77'; ### HP/UX ### @@ -289,6 +271,7 @@ $F77config{Hpux}{F77}{Trail_} = 0; $F77config{Hpux}{F77}{Compiler} = 'f77'; $F77config{Hpux}{F77}{Cflags} = '-O'; + $F77config{Hpux}{DEFAULT} = 'F77'; ### IRIX ### @@ -299,7 +282,7 @@ # longer an experimental feature and I am using it exclusively without any # problem. The code below is what I use instead of original IRIX section # in the ExtUtils::F77 package. It adds the -64 flag and it is supposed to -# provide the same functionality as the old code for a non -64 abi. +# provide the same functionality as the old code for a non -64 abi. if (ucfirst($Config{'osname'}) eq "Irix") { @@ -334,6 +317,7 @@ $F77config{Irix}{F77}{Link} = "$libs"; $F77config{Irix}{F77}{Trail_} = 1; $F77config{Irix}{F77}{Compiler} = "f77 $abi"; + $F77config{Irix}{DEFAULT} = 'F77'; } @@ -341,6 +325,7 @@ $F77config{Aix}{F77}{Link} = "-L/usr/lib -lxlf90 -lxlf -lc -lm"; $F77config{Aix}{F77}{Trail_} = 0; + $F77config{Aix}{DEFAULT} = 'F77'; ### FreeBSD ### @@ -351,77 +336,37 @@ } $F77config{Freebsd}{G77}{Link} = sub { - $dir = `g77-34 -print-file-name=libg2c.a`; - chomp $dir; - # Note that -print-file-name returns just the library name - # if it cant be found - make sure that we only accept the - # directory if it returns a proper path (or matches a /) - - if( defined $dir ) { - $dir =~ s,/libg2c.a$,,; - } else { - $dir = "/usr/local/lib"; - } - return( qq{"-L$dir" -L/usr/lib -lg2c -lm} ); + my $dir = gfortran_find_libdir('g77-34', 'g2c'); + gfortran_make_linkline($dir, 'g2c', "/usr/local/lib", ''); }; +$F77config{Freebsd}{G77}{Trail_} = 1; +$F77config{Freebsd}{G77}{Compiler} = 'g77-34'; +$F77config{Freebsd}{G77}{Cflags} = '-O2'; $F77config{Freebsd}{GFortran}{Link} = sub { - $dir = `$gfortran -print-file-name=libgfortran.a`; - chomp $dir; - # Note that -print-file-name returns just the library name - # if it cant be found - make sure that we only accept the - # directory if it returns a proper path (or matches a /) - - if( defined $dir ) { - $dir =~ s,/libgfortran.a$,,; - } else { - $dir = "/usr/local/lib"; - } - return( qq{"-L$dir" -L/usr/lib -lgfortran -lm} ); + my $dir = gfortran_find_libdir($gfortran, 'gfortran'); + gfortran_make_linkline($dir, "gfortran", "/usr/local/lib", ""); }; - -$F77config{Freebsd}{G77}{Trail_} = 1; $F77config{Freebsd}{GFortran}{Trail_} = 1; -$F77config{Freebsd}{G77}{Compiler} = 'g77-34'; $F77config{Freebsd}{GFortran}{Compiler} = "$gfortran"; -$F77config{Freebsd}{G77}{Cflags} = '-O2'; $F77config{Freebsd}{GFortran}{Cflags} = '-O2'; -$F77config{Freebsd}{DEFAULT} = 'GFortran'; +$F77config{Freebsd}{DEFAULT} = 'GFortran'; ### VMS ### -$F77config{VMS}{Fortran}{Trail_} = 0; $F77config{VMS}{Fortran}{Link} = ' '; # <---need this space! -$F77config{VMS}{DEFAULT} = 'Fortran'; +$F77config{VMS}{Fortran}{Trail_} = 0; $F77config{VMS}{Fortran}{Compiler} = 'Fortran'; +$F77config{VMS}{DEFAULT} = 'Fortran'; + ### Darwin (Mac OS X) ### $F77config{Darwin}{GNU} = $F77config{Generic}{GNU}; $F77config{Darwin}{DEFAULT} = 'GNU'; - -############ End of database is here ############ - -=head1 SYNOPSIS - - use ExtUtils::F77; # Automatic guess - use ExtUtils::F77 qw(sunos); # Specify system - use ExtUtils::F77 qw(linux g77); # Specify system and compiler - $fortranlibs = ExtUtils::F77->runtime; - - -=cut - -# Package variables - -$Runtime = "-LSNAFU -lwontwork"; -$RuntimeOK = 0; -$Trail_ = 1; -$Pkg = ""; -$Compiler = ""; -$Cflags = ""; +############ End of database is here ############ sub get; # See below @@ -441,17 +386,18 @@ $system = 'Cygwin' if $system =~ /Cygwin/; $compiler = get $F77config{$system}{DEFAULT} unless $compiler; - print "$Pkg: Using system=$system compiler=" . + debug "$Pkg: Using system=$system compiler=" . (defined $compiler ? $compiler : "<undefined>") . "\n"; if (defined($ENV{F77LIBS})) { - print "Overriding Fortran libs from value of enviroment variable F77LIBS = $ENV{F77LIBS}\n"; + debug "Overriding Fortran libs from value of enviroment variable F77LIBS = $ENV{F77LIBS}\n"; $Runtime = $ENV{F77LIBS}; } else { # Try this combination + my $ok; if ( defined( $compiler ) and defined( $F77config{$system} )){ my $flibs = get ($F77config{$system}{$compiler}{Link}); if ($flibs ne "") { @@ -463,49 +409,48 @@ #(Note appending gcclibs seems to be no longer required) $Runtime =~ s|L([a-z,A-Z]):|L//$1|g if $^O =~ /cygwin/i; $Runtime = ' ' if $^O eq 'VMS'; # <-- need this space! - print "Runtime: $Runtime\n"; + debug "Runtime: $Runtime\n"; $ok = 1; if ($compiler eq 'GNU') { # Special gfortran case since it seems to have lots of random libs - print "Found compiler=$compiler - skipping validation of $Runtime \n"; + debug "Found compiler=$compiler - skipping validation of $Runtime \n"; - }else { + } else { $ok = validate_libs($Runtime) if $flibs ne "" ; } } - }else { + } else { $Runtime = $ok = ""; } # If it doesn't work try Generic + GNU77 unless (("$Runtime" ne "-LSNAFU -lwontwork") && $ok) { - print <<"EOD"; - $Pkg: Unable to guess and/or validate system/compiler configuration - $Pkg: Will try system=Generic Compiler=$fallback_compiler -EOD $system = $Config{cc} =~ /\bgcc/ && $^O =~ /MSWin32/i ? "MinGW" : $^O =~ /Freebsd/i ? "Freebsd" :"Generic"; $compiler = $fallback_compiler; + warn <<"EOD"; +$Pkg: Unable to guess and/or validate system/compiler configuration +$Pkg: Will try system=$system Compiler=$compiler +EOD my $flibs = get ($F77config{$system}{$compiler}{Link}); $Runtime = $flibs ; #. gcclibs($flibs); # Note gcclibs appears to be no longer required. $ok = validate_libs($Runtime) if $flibs ne ""; - print "$Pkg: Well that didn't appear to validate. Well I will try it anyway.\n" + warn "$Pkg: Well that didn't appear to validate. Well I will try it anyway.\n" unless $Runtime && $ok; } $RuntimeOK = $ok; - } # Not overriding + } # Not overriding # Now get the misc info for the methods. if (defined( $F77config{$system}{$compiler}{Trail_} )){ - $Trail_ = get $F77config{$system}{$compiler}{Trail_}; - } - else{ - print << "EOD"; + $Trail_ = get $F77config{$system}{$compiler}{Trail_}; + } else { + warn << "EOD"; $Pkg: There does not appear to be any configuration info about $Pkg: names with trailing underscores for system $system. Will assume $Pkg: F77 names have trailing underscores. @@ -516,18 +461,18 @@ if (defined( $F77config{$system}{$compiler}{Compiler} )) { $Compiler = get $F77config{$system}{$compiler}{Compiler}; } else { - print << "EOD"; + warn << "EOD"; $Pkg: There does not appear to be any configuration info about $Pkg: the F77 compiler name. Will assume 'f77'. EOD $Compiler = 'f77'; } - print "$Pkg: Compiler: $Compiler\n"; + debug "$Pkg: Compiler: $Compiler\n"; if (defined( $F77config{$system}{$compiler}{Cflags} )) { $Cflags = get $F77config{$system}{$compiler}{Cflags} ; } else { - print << "EOD"; + warn << "EOD"; $Pkg: There does not appear to be any configuration info about $Pkg: the options for the F77 compiler. Will assume none $Pkg: necessary. @@ -535,48 +480,10 @@ $Cflags = ''; } - print "$Pkg: Cflags: $Cflags\n"; + debug "$Pkg: Cflags: $Cflags\n"; } # End of import () -=head1 METHODS - -The following methods are provided: - -=over 4 - -=item * B<runtime> - -Returns a list of F77 runtime libraries. - - $fortranlibs = ExtUtils::F77->runtime; - -=item * B<runtimeok> - -Returns TRUE only if runtime libraries have been found successfully. - -=item * B<trail_> - -Returns true if F77 names have trailing underscores. - -=item * B<compiler> - -Returns command to execute the compiler (e.g. 'f77'). - -=item * B<cflags> - -Returns compiler flags. - -=item * B<testcompiler> - -Test to see if compiler actually works. - -=back - -More methods will probably be added in the future. - -=cut - sub runtime { return $Runtime; } sub runtimeok { return $RuntimeOK; } sub trail_ { return $Trail_; } @@ -599,11 +506,11 @@ # Find highest version number of SCN.N(.N) directories # (Nasty SunOS/Solaris naming scheme for F77 libs] sub find_highest_SC { - print "$Pkg: Scanning for $_[0]\n"; + debug "$Pkg: Scanning for $_[0]\n"; my @glob = glob(shift); my %n=(); for (@glob) { - #print "Found $_\n"; + #debug "Found $_\n"; if ( m|/SC(\d)\.(\d)/?.*$| ) { $n{$_} = $1 *100 + $2 * 10; } @@ -619,33 +526,33 @@ # Validate a string of form "-Ldir -lfoo -lbar" sub validate_libs { - print "$Pkg: Validating $_[0] "; + debug "$Pkg: Validating $_[0] "; my @args = shellwords(shift()); my $pat; my $ret = 1; # Create list of directories to search (with common defaults) - my @path = (); - for (@args, "/usr/lib", "/lib") { + my @path = (); + for (@args, "/usr/lib", "/lib") { push @path, $1 if /^-L(.+)$/ && -d $1; } # Search directories - for (@args) { + for (@args) { next if /^-L/; next if $_ eq "-lm"; # Ignore this common guy if (/^-l(.+)$/) { $pat = join(" ", map {$_."/lib".$1.".*"} @path); # Join dirs + file - #print "Checking for $pat\n"; + #debug "Checking for $pat\n"; unless (any_exists($pat)) { - print "\n$Pkg: Unable to find library $_" ; + debug "\n$Pkg: Unable to find library $_" ; $ret = 0; } } } - print $ret ? "[ok]\n" : "\n"; + debug $ret ? "[ok]\n" : "\n"; return $ret; } @@ -660,16 +567,16 @@ print OUT " write(*,*) 'Hello World'\n"; print OUT " end\n"; close(OUT); - print "Compiling the test Fortran program...\n"; + debug "Compiling the test Fortran program...\n"; system "$Compiler $Cflags $file.f -o ${file}_exe"; - print "Executing the test program...\n"; + debug "Executing the test program...\n"; if (`${file}_exe` ne " Hello World\n") { - print "Test of Fortran Compiler FAILED. \n"; - print "Do not know how to compile Fortran on your system\n"; + warn "Test of Fortran Compiler FAILED. \n"; + warn "Do not know how to compile Fortran on your system\n"; $ret=0; } else{ - print "Congratulations you seem to have a working f77!\n"; + debug "Congratulations you seem to have a working f77!\n"; $ret=1; } unlink("${file}_exe"); unlink("$file.f"); unlink("$file.o") if -e "$file.o"; @@ -678,7 +585,7 @@ # gcclibs() routine # Return gcc link libs (e.g. -L/usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3_U1/2.7.0 -lgcc) -# Note this routine appears to be no longer required - gcc3 or 4 change? - and is +# Note this routine appears to be no longer required - gcc3 or 4 change? - and is # NO LONGER CALLED from anywhere in the code. Use of this routine in the future # is DEPRECATED. Retain here just in case this logic is ever needed again, # - Karl Glazebrook Dec/2010 @@ -687,7 +594,7 @@ my $flibs = shift; # Fortran libs my $isgcc = $Config{'cc'} eq "$gcc"; if (!$isgcc && $^O ne 'VMS') { - print "Checking for gcc in disguise:\n"; + debug "Checking for gcc in disguise:\n"; $isgcc = 1 if $Config{gccversion}; my $string; if ($isgcc) { @@ -696,17 +603,17 @@ } else { $string = "Not gcc\n"; } - print $string; + debug $string; } if ($isgcc or ($flibs =~ /-lg2c/) or ($flibs =~ /-lf2c/) ) { # Don't link to libgcc on MS Windows iff we're using gfortran. - unless($fallback_compiler eq 'GFortran' && $^O =~ /MSWin/i) { - $gccdir = `$gcc -m32 -print-libgcc-file-name`; chomp $gccdir; + unless ($fallback_compiler eq 'GFortran' && $^O =~ /MSWin/i) { + my $gccdir = `$gcc -m32 -print-libgcc-file-name`; chomp $gccdir; $gccdir =~ s/\/libgcc.a//; return qq{ "-L$gccdir" -lgcc}; - }else{ + } else { return ""; - } + } }else{ return ""; @@ -714,29 +621,11 @@ } # Try and find a program in the users PATH - sub find_in_path { - my @names = @_; - my @path; - if ($^O =~ /mswin32/i) { - for(@names) { $_ .= '.exe'} - @path = split(";", $ENV{PATH}); - } - else {@path = split(":",$ENV{PATH})} - my ($name,$dir); - for $name (@names) { - return $name if exists $CACHE{$name}; - for $dir (@path) { - if (-x $dir."/$name") { - print "Found compiler $name\n"; - $CACHE{$name}++; - return $name; - } - } - } - return '' if $^O eq 'VMS'; - return undef; -# die "Unable to find a fortran compiler using names: ".join(" ",@names); + my $found = first { which $_ } @_; + return ($^O eq 'VMS' ? '' : undef) if !$found; + debug "Found compiler $found\n"; + return $found; } # Based on code from Tim Jeness, tries to figure out the correct GNU @@ -745,69 +634,116 @@ return () if $^O =~ /MSWin32/i; # Unneeded for MinGW, emits warnings if allowed to proceed. my @try = @_; my $compiler = find_in_path( @try ); - # all the compilers and their libraries - my %complibs = ( - g77 => [qw/ g2c f2c /], - f77 => [qw/ g2c f2c /], - fort77 => [qw/ g2c f2c /], - gfortran => [qw/ gfortran /], - g95 => [qw/ f95 /], - ); return () unless defined $compiler; - my @libs = @{$complibs{$compiler}}; - my ($dir, $lib, $test); - foreach $test (@libs) { - $dir = `$compiler -print-file-name=lib$test.a`; - chomp $dir; - # Note that -print-file-name returns just the library name - # if it cant be found - make sure that we only accept the - # directory if it returns a proper path (or matches a /) - if (defined $dir && $dir ne "lib$test.a") { - $lib = $test; # Found an existing library - $dir =~ s,/lib$lib.a$,,; - last; - } else { - # Try the same thing again but looking for the .so file - # rather than the .a file. - $dir = `$compiler -print-file-name=lib$test.so`; - chomp $dir; - if (defined $dir && $dir ne "lib$test.so") { - $lib = $test; # Found an existing library - $dir =~ s,/lib$lib.so$,,; - last; - } else { - $dir = "/usr/local/lib"; - $lib = "f2c"; - } - } - } # Get compiler version number - my @t =`$compiler --version`; $t[0] =~ /(\d+).(\d)+.(\d+)/; + my @t =`$compiler --version`; $t[0] =~ /(\d+).(\d)+.(\d+)/; my $version = "$1.$2"; # Major version number - print "ExtUtils::F77: $compiler version $version.$3\n"; + debug "ExtUtils::F77: $compiler version $version.$3\n"; # Sigh special case random extra gfortran libs to avoid PERL_DL_NONLAZY meltdowns. KG 25/10/2015 - $append = ""; + my $append = ""; if ( $Config{osname} =~ /darwin/ && $Config{osvers} >= 14 - && $compiler eq 'gfortran' && $version >= 4.9 ) { # Add extra libs for gfortran versions >= 4.9 and OS X + && $compiler eq 'gfortran' && $version >= 4.9 ) { + # Add extra libs for gfortran versions >= 4.9 and OS X $append = "-lgcc_ext.10.5 -lgcc_s.10.5 -lquadmath"; - return( qq{"-L$dir" $append -L/usr/lib -l$lib -lm} ); } - return( qq{"-L$dir" -L/usr/lib -l$lib -lm} ); + my @libs = @{$COMPLIBS{$compiler}}; + my ($dir, $lib, $test); + foreach $test (@libs) { + $dir = gfortran_find_libdir($compiler, $test); + $lib = $test, last if defined $dir; + } + gfortran_make_linkline($dir, $lib, "/usr/local/lib", "f2c", $append); } -=head1 SEE ALSO +1; # Return true -The L<PGPLOT> module uses this to link with the Fortran based graphics library, and was the cause of this module's development. +__END__ -=head1 AUTHOR +=head1 NAME -Karl Glazebrook +ExtUtils::F77 - Simple interface to F77 libs -=cut +=head1 DESCRIPTION +This module tries to figure out how to link C programs with +Fortran subroutines on your system. Basically one must add a list +of Fortran runtime libraries. The problem is their location +and name varies with each OS/compiler combination! It was originally +developed to make building and installation of the L<PGPLOT> module easier, +which links to the pgplot Fortran graphics library. It is now used by a numnber +of perl modules. -1; # Return true +This module tries to implement a simple +'rule-of-thumb' database for various flavours of UNIX systems. +A simple self-documenting Perl database of knowledge/code +for figuring out how to link for various combinations of OS and +compiler is embedded in the modules Perl code. Please help +save the world by submitted patches for new database entries for +your system at L<https://github.com/PDLPorters/extutils-f77> + +Note the default on most systems is now to search for a generic 'GNU' compiler +which can be gfortran, g77, g95 or fort77 (in that order based on usage) and then find +the appropriate link libraries automatically. (This is the 'Generic' 'GNU' database entry +in the code.) + +The library list which the module returns +can be explicitly overridden by setting the environment +variable F77LIBS, e.g. + + % setenv F77LIBS "-lfoo -lbar" + % perl -MExtUtils::F77 -e 'print ExtUtils::F77->compiler, "\n"' + ... + +=head1 SYNOPSIS + + use ExtUtils::F77; # Automatic guess + use ExtUtils::F77 qw(sunos); # Specify system + use ExtUtils::F77 qw(linux g77); # Specify system and compiler + $fortranlibs = ExtUtils::F77->runtime; + +=head1 METHODS + +The following are all class methods. + +=head2 runtime + +Returns a list of F77 runtime libraries. + + $fortranlibs = ExtUtils::F77->runtime; + +=head2 runtimeok + +Returns TRUE only if runtime libraries have been found successfully. + +=head2 trail_ + +Returns true if F77 names have trailing underscores. + +=head2 compiler + +Returns command to execute the compiler (e.g. 'f77'). +=head2 cflags +Returns compiler flags. + +=head2 testcompiler + +Test to see if compiler actually works. +=head1 DEBUGGING + +To debug this module, and/or get more information about its workings, +set C<$ExtUtils::F77::DEBUG> to a true value. If set, it will C<warn> +various information about its operations. + +As of version 1.22, this module will no longer print or warn if it is +working normally. + +=head1 SEE ALSO + +L<PDL> (PDL::Minuit and PDL::Slatec), L<PGPLOT> + +=head1 AUTHOR +Karl Glazebrook, with many other contributions (see git repository at https://github.com/PDLPorters/extutils-f77) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ExtUtils-F77-1.22/MANIFEST new/ExtUtils-F77-1.23/MANIFEST --- old/ExtUtils-F77-1.22/MANIFEST 2018-12-02 07:32:51.000000000 +0100 +++ new/ExtUtils-F77-1.23/MANIFEST 2019-01-05 07:04:19.000000000 +0100 @@ -3,7 +3,7 @@ F77.pm Makefile.PL MANIFEST This list of files -META.yml README t/require.t +META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ExtUtils-F77-1.22/META.json new/ExtUtils-F77-1.23/META.json --- old/ExtUtils-F77-1.22/META.json 2018-12-02 07:32:51.000000000 +0100 +++ new/ExtUtils-F77-1.23/META.json 2019-01-05 07:04:19.000000000 +0100 @@ -3,8 +3,8 @@ "author" : [ "Karl Glazebrook <[email protected]>" ], - "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001", + "dynamic_config" : 0, + "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.133380", "license" : [ "perl_5" ], @@ -19,23 +19,6 @@ "inc" ] }, - "prereqs" : { - "build" : { - "requires" : { - "ExtUtils::MakeMaker" : "0" - } - }, - "configure" : { - "requires" : { - "ExtUtils::MakeMaker" : "0" - } - }, - "runtime" : { - "requires" : { - "Text::ParseWords" : "0" - } - } - }, "release_status" : "stable", "resources" : { "repository" : { @@ -45,5 +28,5 @@ }, "x_IRC" : "irc://irc.perl.org/#pdl" }, - "version" : "1.22" + "version" : "1.23" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ExtUtils-F77-1.22/META.yml new/ExtUtils-F77-1.23/META.yml --- old/ExtUtils-F77-1.22/META.yml 2018-12-02 07:32:51.000000000 +0100 +++ new/ExtUtils-F77-1.23/META.yml 2019-01-05 07:04:19.000000000 +0100 @@ -2,24 +2,19 @@ abstract: 'a simple interface to F77 libs' author: - 'Karl Glazebrook <[email protected]>' -build_requires: - ExtUtils::MakeMaker: '0' -configure_requires: - ExtUtils::MakeMaker: '0' -dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001' +build_requires: {} +dynamic_config: 0 +generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.133380' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: '1.4' + version: 1.4 name: ExtUtils-F77 no_index: directory: - t - inc -requires: - Text::ParseWords: '0' resources: IRC: irc://irc.perl.org/#pdl repository: git://github.com/PDLPorters/extutils-f77.git -version: '1.22' +version: 1.23 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ExtUtils-F77-1.22/Makefile.PL new/ExtUtils-F77-1.23/Makefile.PL --- old/ExtUtils-F77-1.22/Makefile.PL 2018-12-01 07:24:40.000000000 +0100 +++ new/ExtUtils-F77-1.23/Makefile.PL 2019-01-05 06:56:24.000000000 +0100 @@ -7,9 +7,12 @@ VERSION_FROM => 'F77.pm', PREREQ_PM => { 'Text::ParseWords' => 0, + 'File::Which' => 0, + 'List::Util' => 0, }, META_MERGE => { "meta-spec" => { version => 2 }, + dynamic_config => 0, resources => { bugtracker => 'https://github.com/PDLPorters/extutils-f77/issues', repository => { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ExtUtils-F77-1.22/README new/ExtUtils-F77-1.23/README --- old/ExtUtils-F77-1.22/README 2018-12-01 07:26:26.000000000 +0100 +++ new/ExtUtils-F77-1.23/README 2019-01-05 06:56:24.000000000 +0100 @@ -10,6 +10,11 @@ 2. Install +Run "cpanm ExtUtils::F77". To install cpanm, see +https://metacpan.org/pod/App::cpanminus#INSTALLATION + +If you would like to install manually: + Extract archive file. Change current directory to extraction directory (usually ExtUtils-F77-x.xx/ where "x.xx" is version number). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ExtUtils-F77-1.22/t/require.t new/ExtUtils-F77-1.23/t/require.t --- old/ExtUtils-F77-1.22/t/require.t 2018-12-01 07:24:40.000000000 +0100 +++ new/ExtUtils-F77-1.23/t/require.t 2019-01-05 06:56:24.000000000 +0100 @@ -1,9 +1,17 @@ use strict; use warnings; +use File::Which qw(which); use Test::More tests => 3; -use_ok 'ExtUtils::F77'; +$ExtUtils::F77::DEBUG = $ExtUtils::F77::DEBUG = 1; -is ExtUtils::F77->testcompiler, 1, 'testcompiler method returns 1'; +my $mod = 'ExtUtils::F77'; +use_ok $mod; -is ExtUtils::F77->runtimeok, 1, 'runtime libs found'; +is $mod->testcompiler, 1, 'testcompiler method returns 1'; + +is $mod->runtimeok, 1, 'runtime libs found'; + +diag "Method: $_, ", explain $mod->$_ for qw(runtime trail_ compiler cflags); + +diag "Compiler: ", which $mod->compiler;
