From lichray@gmail.com  Thu Mar 24 06:36:16 2011
Return-Path: <lichray@gmail.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EDACA106567B
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 24 Mar 2011 06:36:16 +0000 (UTC)
	(envelope-from lichray@gmail.com)
Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182])
	by mx1.freebsd.org (Postfix) with ESMTP id B3EFE8FC14
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 24 Mar 2011 06:36:16 +0000 (UTC)
Received: by iyj12 with SMTP id 12so11303297iyj.13
        for <FreeBSD-gnats-submit@freebsd.org>; Wed, 23 Mar 2011 23:36:15 -0700 (PDT)
Received: by 10.42.166.6 with SMTP id m6mr12485878icy.281.1300948575756;
        Wed, 23 Mar 2011 23:36:15 -0700 (PDT)
Received: from compaq.yuetime (c-98-228-191-105.hsd1.il.comcast.net [98.228.191.105])
        by mx.google.com with ESMTPS id wu1sm5779556icb.22.2011.03.23.23.36.13
        (version=TLSv1/SSLv3 cipher=OTHER);
        Wed, 23 Mar 2011 23:36:15 -0700 (PDT)
Received: by compaq.yuetime (sSMTP sendmail emulation); Thu, 24 Mar 2011 01:36:12 -0500
Message-Id: <4d8ae65f.013d2b0a.184d.ffff9cc1@mx.google.com>
Date: Thu, 24 Mar 2011 01:36:12 -0500
From: Zhihao Yuan <lichray@gmail.com>
Reply-To: Zhihao Yuan <lichray@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: lang/p5-F77 updated to 1.17; +Fix the broken port
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         155906
>Category:       ports
>Synopsis:       lang/p5-F77 updated to 1.17; +Fix the broken port
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    perl
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 24 06:40:01 UTC 2011
>Closed-Date:    Thu May 05 08:34:13 UTC 2011
>Last-Modified:  Thu May 05 08:34:13 UTC 2011
>Originator:     Zhihao Yuan
>Release:        FreeBSD 8.2-STABLE amd64
>Organization:
Northern Illinois University
>Environment:
System: FreeBSD compaq.yuetime 8.2-STABLE FreeBSD 8.2-STABLE #0: Mon Mar 14 02:51:28 CDT 2011 root@compaq.yuetime:/usr/obj/usr/src/sys/HOUKAGO amd64


	
>Description:
	ExtUtils::F77 has been updated to 1.17. Check http://search.cpan.org/~kgb/ExtUtils-F77/F77.pm for details.

	Note: the old version 1.16_1 in ports does not work! The problems are:
	1. It only searches for g77-34 on FreeBSD;
	2. It does not set the libg2c path (since this lib has been removed from FreeBSD base system).

>How-To-Repeat:
	
>Fix:
	So here is what my patch does:
	1. Detects both g77-34 and gfortran;
	2. Uses a post-patch to set the CFLAGS and gfortran version correctly.
	3. Marks gfortran as the default compiler (since g77 is deprecated in ports tree), and enables g77-34 as a fallback.
	Now this port works whenever you have a fortran compiler installed from ports/packages, and obey ${FC} and ${CFLAGS} :)

	

--- patch-p5-F77-1.17 begins here ---
diff -rupN p5-F77.orig/Makefile p5-F77/Makefile
--- p5-F77.orig/Makefile	2010-12-17 14:14:55.000000000 -0600
+++ p5-F77/Makefile	2011-03-24 00:33:49.074224622 -0500
@@ -6,8 +6,7 @@
 #
 
 PORTNAME=	ExtUtils-F77
-PORTVERSION=	1.16
-PORTREVISION=	1
+PORTVERSION=	1.17
 CATEGORIES=	lang perl5
 MASTER_SITES=	CPAN
 PKGNAMEPREFIX=	p5-
@@ -19,11 +18,11 @@ PERL_CONFIGURE=	yes
 
 MAN3=		ExtUtils::F77.3
 
-F2CLIB=		-lg2c
+GCCLIBDIR_CMDS=	${FC} -print-file-name=libgfortran.so | ${SED} -e s/libgfortran.so//
+F2CLIB=		-lgfortran
 
 post-patch:
-	@cd ${WRKSRC}; ${PERL5} -i.orig -pe \
-		's/(.*Freebsd.*lib )(-lf2c)(.*)/$$1 ${F2CLIB} $$3/' F77.pm
-	@${REINPLACE_CMD} -e "s/'f77',/'f77','g77-34',/" ${WRKSRC}/F77.pm
+	@${REINPLACE_CMD} -e "s/'gfortran44'/'${FC}'/" ${WRKSRC}/F77.pm
+	@${REINPLACE_CMD} -e "s/'-O2'/'${CFLAGS}'/" ${WRKSRC}/F77.pm
 
 .include <bsd.port.mk>
diff -rupN p5-F77.orig/distinfo p5-F77/distinfo
--- p5-F77.orig/distinfo	2008-12-30 07:00:59.000000000 -0600
+++ p5-F77/distinfo	2011-03-23 22:13:21.079273997 -0500
@@ -1,3 +1,2 @@
-MD5 (ExtUtils-F77-1.16.tar.gz) = af925e7e8a2876a5fd9b6c4660e37664
-SHA256 (ExtUtils-F77-1.16.tar.gz) = d3dfed878678495bbd1054d78ad100ddd3df59cbc8a2ce550dae9cd2e989b84c
-SIZE (ExtUtils-F77-1.16.tar.gz) = 10234
+SHA256 (ExtUtils-F77-1.17.tar.gz) = b3919200443174ff348ed5567d461335e289fba047cb17432f31dea5a26cad3f
+SIZE (ExtUtils-F77-1.17.tar.gz) = 11225
diff -rupN p5-F77.orig/files/patch-F77.pm p5-F77/files/patch-F77.pm
--- p5-F77.orig/files/patch-F77.pm	1969-12-31 18:00:00.000000000 -0600
+++ p5-F77/files/patch-F77.pm	2011-03-24 01:05:04.970778282 -0500
@@ -0,0 +1,65 @@
+--- F77.pm.orig	2010-12-31 19:53:06.000000000 -0600
++++ F77.pm	2011-03-24 01:05:00.742862139 -0500
+@@ -351,9 +351,49 @@ $F77config{Aix}{DEFAULT}     = 'F77';
+ 
+ ### FreeBSD ###
+ 
+-$F77config{Freebsd}{F77}{Trail_} = 1;
+-$F77config{Freebsd}{F77}{Link}   = '-L/usr/lib -lf2c -lm';
+-$F77config{Freebsd}{DEFAULT}     = 'F77';
++if($^O =~ /Freebsd/i) {
++  $gfortran = 'gfortran44'; # requires rewrite
++  $fallback_compiler = 'G77';
++}
++
++$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( "-L$dir -L/usr/lib -lg2c -lm" );
++};
++
++$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( "-L$dir -L/usr/lib -lgfortran -lm" );
++};
++
++$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 -pipe -march=nocona -fno-strict-aliasing';
++$F77config{Freebsd}{GFortran}{Cflags}   = '-O2 -pipe -march=nocona -fno-strict-aliasing';
++$F77config{Freebsd}{DEFAULT}     = 'GFortran';
++
+ 
+ ### VMS ###
+ 
+@@ -446,7 +486,8 @@ $Pkg: Will try system=Generic Compiler=$
+ EOD
+     	 $system   =
+             $Config{cc} =~ /\bgcc/ && $^O =~ /MSWin32/i ? "MinGW"
+-                                                        :"Generic";
++                                    : $^O =~ /Freebsd/i ? "Freebsd"
++                                                        : "Generic";
+     	 $compiler = $fallback_compiler;
+     	 my $flibs = get ($F77config{$system}{$compiler}{Link});
+     	 $Runtime =  $flibs ; #. gcclibs($flibs); #  Note gcclibs appears to be no longer required.
diff -rupN p5-F77.orig/pkg-plist p5-F77/pkg-plist
--- p5-F77.orig/pkg-plist	2008-12-30 07:18:42.000000000 -0600
+++ p5-F77/pkg-plist	2011-03-23 22:14:36.505175355 -0500
@@ -1,6 +1,5 @@
 %%SITE_PERL%%/ExtUtils/F77.pm
 %%SITE_PERL%%/%%PERL_ARCH%%/auto/ExtUtils/F77/.packlist
-%%SITE_PERL%%/ExtUtils/._F77.pm
 @dirrm %%SITE_PERL%%/%%PERL_ARCH%%/auto/ExtUtils/F77
 @dirrmtry %%SITE_PERL%%/%%PERL_ARCH%%/auto/ExtUtils
 @dirrmtry %%SITE_PERL%%/ExtUtils
--- patch-p5-F77-1.17 ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->perl 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Thu Mar 24 06:40:12 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155906 

From: Zhihao Yuan <lichray@gmail.com>
To: bug-followup@FreeBSD.org, lichray@gmail.com
Cc:  
Subject: Re: ports/155906: lang/p5-F77 updated to 1.17; Fix the broken port
Date: Thu, 24 Mar 2011 07:16:39 -0500

 Sorry... this patch massed something up. For these 2 lines:
 
 ++$F77config{Freebsd}{G77}{Cflags} = '-O2 -pipe -march=nocona
 -fno-strict-aliasing';
 ++$F77config{Freebsd}{GFortran}{Cflags}   = '-O2 -pipe -march=nocona
 -fno-strict-aliasing';
 
 Please change these two Perl strings into '-O2', then the post-patch
 will replace them with correct CFLAGS.
 
 -- 
 Zhihao Yuan
 The best way to predict the future is to invent it.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/155906: commit references a PR
Date: Thu,  5 May 2011 08:22:46 +0000 (UTC)

 tota        2011-05-05 08:22:29 UTC
 
   FreeBSD ports repository
 
   Modified files:
     lang/p5-F77          Makefile distinfo pkg-plist 
   Added files:
     lang/p5-F77/files    patch-F77.pm 
   Log:
   - Update to 1.17
     * Detect both g77-34 and gfortran
     * Use a post-patch to set the CFLAGS and gfortran version correctly
     * Mark gfortran as the default compiler (since g77 is deprecated in ports
       tree), and enable g77-34 as a fallback
   
   PR:             ports/155906
   Submitted by:   Zhihao Yuan <lichray_AT_gmail_DOT_com>
   
   Revision  Changes    Path
   1.18      +6 -6      ports/lang/p5-F77/Makefile
   1.8       +2 -3      ports/lang/p5-F77/distinfo
   1.1       +65 -0     ports/lang/p5-F77/files/patch-F77.pm (new)
   1.6       +0 -1      ports/lang/p5-F77/pkg-plist
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: tota 
State-Changed-When: Thu May 5 08:33:33 UTC 2011 
State-Changed-Why:  
Committed, with minor changes. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155906 
>Unformatted:
