Bug 93690

Summary: /usr/ports/Mk/bsd.gcc.mk doesn't know about gfortran
Product: Ports & Packages Reporter: giffunip <giffunip>
Component: Individual Port(s)Assignee: Port Management Team <portmgr>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description giffunip 2006-02-22 04:10:06 UTC
Currently setting USE_GCC for any version of gcc sets 

F77:=                   g77-${V}

On gcc version 4.0 and greater there is no g77. While the new gfortran can
build fortran77 programs, it is also a Fortran95 and most software packages,
including the autotools expect to find FC defined as the fortran95 compiler.

gfortran and f77 are incompatible unless gfortran is forced to use the older
format with the -ff2c option.

Fix: 

(silence...)
How-To-Repeat: On some ports that I am developing I need fortran90 and I have to use this:

BUILD_DEPENDS=  ${FC}:${PORTSDIR}/lang/gfortran

USE_GCC=        4.1+
WITH_FORTRAN=   yes
FC=     ${LOCALBASE}/bin/gfortran41
F77=    ${FC}

CONFIGURE_ENV+= FC=${FC} F77=${FC} FCFLAGS=${FCFLAGS}
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2006-02-22 06:34:56 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr

bsd.gcc.mk is assigned to portmgr.
Comment 2 Kris Kennaway freebsd_committer freebsd_triage 2006-05-23 23:11:08 UTC
State Changed
From-To: open->suspended

Suspended awaiting patch to implement the relevant change.
Comment 3 gerald 2006-09-03 00:38:46 UTC
The following patch tries to address this.  Only mildly tested on my
side, but I believe the approach is the right one.

Proposed ChangeLog:

Pass F77 via MAKE_ENV, in addition to CC and CXX.  Introduce FC in 
addition to F77 and pass this via MAKE_ENV as well.  For GCC 4.0 and 
later, we do not have g77, use gfortran instead.  If WITH_FORTRAN is
set, require lang/gfortran which is based on lang/gcc41 at this point.
Enhance the output of test-gcc: accordingly and fix a typo there.

Gerald

Index: bsd.gcc.mk
===================================================================
RCS file: /home/pcvs/ports/Mk/bsd.gcc.mk,v
retrieving revision 1.8
diff -u -3 -p -r1.8 bsd.gcc.mk
--- bsd.gcc.mk	5 Jul 2006 02:18:08 -0000	1.8
+++ bsd.gcc.mk	2 Sep 2006 23:24:24 -0000
@@ -127,16 +127,31 @@ _USE_GCC:=${_GCC_FOUND}
 
 #
 # Determine if the installed OS already has this GCCVERSION, and if not
-# then set BUILD_DEPENDS, CC, CXX and F77
+# then set BUILD_DEPENDS, CC, CXX, F77, and FC.
 #
 .for v in ${GCCVERSIONS}
 . if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
 .  if ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R}
-V:=				${_GCCVERSION_${v}_V:S/.//}
+# If Fortran support is requested, regardless of the value of USE_GCC
+# we need to use lang/gfortran, which is based on lang/gcc41 right now.
+.   if defined(WITH_FORTRAN)
+V:=			41
+_GCC_BUILD_DEPENDS:=	gfortran
+.else
+V:=			${_GCCVERSION_${v}_V:S/.//}
+_GCC_BUILD_DEPENDS:=	gcc${V}
+.   endif
 CC:=			gcc${V}
 CXX:=			g++${V}
+# Up to GCC 4.0, we had g77, g77-33, g77-34, and the like.  Starting
+# with GCC 4.0, we have gfortran, gfortran40, gfortran41, and the like.
+.   if ${_USE_GCC} < 4.0
 F77:=			g77-${V}
-_GCC_BUILD_DEPENDS:=	${CC}
+FC:=			${F77}
+.   else
+FC:=			gfortran${V}
+F77:=			${FC}
+.   endif
 .  endif
 . endif
 .endfor
@@ -146,7 +161,7 @@ _GCC_BUILD_DEPENDS:=	${CC}
 BUILD_DEPENDS+=	${_GCC_BUILD_DEPENDS}:${PORTSDIR}/lang/${_GCC_BUILD_DEPENDS}
 .endif
 
-MAKE_ENV+=	CC="${CC}" CXX="${CXX}"
+MAKE_ENV+=	CC="${CC}" CXX="${CXX}" F77="${F77}" FC="${FC}"
 
 test-gcc:
 	@echo USE_GCC=${USE_GCC}
@@ -155,6 +170,7 @@ test-gcc:
 .else
 	@echo Port cannot use later versions.
 .endif
+	@echo WITH_FORTRAN=${WITH_FORTRAN}
 .for v in ${GCCVERSIONS}
 	@echo -n "GCC version: ${_GCCVERSION_${v}_V} "
 .if defined(_GCC_FOUND${v})
@@ -163,5 +179,5 @@ test-gcc:
 	@echo "- OSVERSION from ${_GCCVERSION_${v}_L} to ${_GCCVERSION_${v}_R}"
 #	@echo ${v} - ${_GCC_FOUND${v}} - ${_GCCVERSION_${v}_L} to ${_GCCVERSION_${v}_R} - ${_GCCVERSION_${v}_V}
 .endfor
-	@echo Using GCC vesion ${_USE_GCC}
-	@echo CC:${CC} - CXX:${CXX} - F77:${F77} - BUILD_DEPENDS:${BUILD_DEPENDS}
+	@echo Using GCC version ${_USE_GCC}
+	@echo CC:${CC} - CXX:${CXX} - F77:${F77} - FC:${FC} - BUILD_DEPENDS:${BUILD_DEPENDS}
Comment 4 Thierry Thomas freebsd_committer freebsd_triage 2006-09-17 12:59:27 UTC
On Sun, 3 Sep 2006 at 01:38:46 +0200, Gerald Pfeifer
<gerald@pfeifer.com> wrote:

>  The following patch tries to address this.  Only mildly tested on my
>  side, but I believe the approach is the right one.
>  
>  Proposed ChangeLog:
>  
>  Pass F77 via MAKE_ENV, in addition to CC and CXX.  Introduce FC in 
>  addition to F77 and pass this via MAKE_ENV as well.  For GCC 4.0 and 
>  later, we do not have g77, use gfortran instead.  If WITH_FORTRAN is
>  set, require lang/gfortran which is based on lang/gcc41 at this point.
>  Enhance the output of test-gcc: accordingly and fix a typo there.

Actually the port lang/gfortran installs the binary gfortran41, and we
need the following patch:

--- bsd.gcc.mk.diff begins here ---
--- Mk/bsd.gcc.mk.orig	Sat Jul  8 16:36:40 2006
+++ Mk/bsd.gcc.mk	Sun Sep 17 12:17:13 2006
@@ -127,26 +127,43 @@
 
 #
 # Determine if the installed OS already has this GCCVERSION, and if not
-# then set BUILD_DEPENDS, CC, CXX and F77
+# then set BUILD_DEPENDS, CC, CXX, F77, and FC.
 #
 .for v in ${GCCVERSIONS}
 . if ${_USE_GCC} == ${_GCCVERSION_${v}_V}
 .  if ${OSVERSION} < ${_GCCVERSION_${v}_L} || ${OSVERSION} > ${_GCCVERSION_${v}_R}
-V:=				${_GCCVERSION_${v}_V:S/.//}
+# If Fortran support is requested, regardless of the value of USE_GCC
+# we need to use lang/gfortran, which is based on lang/gcc41 right now.
+.   if defined(WITH_FORTRAN)
+V:=			41
+_GCC_BUILD_DEPENDS:=	gfortran
+_GCC_PORT_DEPENDS:=	gfortran${V}
+.else
+V:=			${_GCCVERSION_${v}_V:S/.//}
+_GCC_BUILD_DEPENDS:=	gcc${V}
+_GCC_PORT_DEPENDS:=	gcc${V}
+.   endif
 CC:=			gcc${V}
 CXX:=			g++${V}
+# Up to GCC 4.0, we had g77, g77-33, g77-34, and the like.  Starting
+# with GCC 4.0, we have gfortran, gfortran40, gfortran41, and the like.
+.   if ${_USE_GCC} < 4.0
 F77:=			g77-${V}
-_GCC_BUILD_DEPENDS:=	${CC}
+FC:=			${F77}
+.   else
+FC:=			gfortran${V}
+F77:=			${FC}
+.   endif
 .  endif
 . endif
 .endfor
 .undef V
 
 .if defined(_GCC_BUILD_DEPENDS)
-BUILD_DEPENDS+=	${_GCC_BUILD_DEPENDS}:${PORTSDIR}/lang/${_GCC_BUILD_DEPENDS}
+BUILD_DEPENDS+=	${_GCC_PORT_DEPENDS}:${PORTSDIR}/lang/${_GCC_BUILD_DEPENDS}
 .endif
 
-MAKE_ENV+=	CC="${CC}" CXX="${CXX}"
+MAKE_ENV+=	CC="${CC}" CXX="${CXX}" F77="${F77}" FC="${FC}"
 
 test-gcc:
 	@echo USE_GCC=${USE_GCC}
@@ -155,6 +172,7 @@
 .else
 	@echo Port cannot use later versions.
 .endif
+	@echo WITH_FORTRAN=${WITH_FORTRAN}
 .for v in ${GCCVERSIONS}
 	@echo -n "GCC version: ${_GCCVERSION_${v}_V} "
 .if defined(_GCC_FOUND${v})
@@ -163,5 +181,5 @@
 	@echo "- OSVERSION from ${_GCCVERSION_${v}_L} to ${_GCCVERSION_${v}_R}"
 #	@echo ${v} - ${_GCC_FOUND${v}} - ${_GCCVERSION_${v}_L} to ${_GCCVERSION_${v}_R} - ${_GCCVERSION_${v}_V}
 .endfor
-	@echo Using GCC vesion ${_USE_GCC}
-	@echo CC:${CC} - CXX:${CXX} - F77:${F77} - BUILD_DEPENDS:${BUILD_DEPENDS}
+	@echo Using GCC version ${_USE_GCC}
+	@echo CC:${CC} - CXX:${CXX} - F77:${F77} - FC:${FC} - BUILD_DEPENDS:${BUILD_DEPENDS}
--- bsd.gcc.mk.diff ends here ---

With this patch, I have successfully built all the elmer ports.

Regards,
-- 
Th. Thomas.
Comment 5 Thierry Thomas freebsd_committer freebsd_triage 2006-09-17 13:29:05 UTC
On Sun 17 sep 06 at 13:59:27 +0200, Thierry Thomas <thierry@FreeBSD.org>
 wrote:

> With this patch, I have successfully built all the elmer ports.

Forgot to say: some minor patches must be applied to the elmer* ports,
to remove the gfortran direct dependency and the definition of ${FC}:

--- elmer-mathlibs.diff begins here ---
diff -urN ./math/elmer-mathlibs.orig/Makefile ./math/elmer-mathlibs/Makefile
--- ./math/elmer-mathlibs.orig/Makefile	Tue Jul 25 14:58:04 2006
+++ ./math/elmer-mathlibs/Makefile	Sat Sep 16 22:57:04 2006
@@ -15,7 +15,6 @@
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	Math libraries build with F90 for used in ELMER FEM
 
-BUILD_DEPENDS=	${FC}:${PORTSDIR}/lang/gfortran
 .ifdef WITH_MPI
 BUILD_DEPENDS+=	${LOCALBASE}/mpich/include/mpif.h:${PORTSDIR}/net/mpich
 .endif
@@ -27,7 +26,6 @@
 
 USE_GCC=	4.1+
 WITH_FORTRAN=	yes
-FC=	${LOCALBASE}/bin/gfortran41
 F77=	${FC}
 
 .ifdef WITH_OPTIMIZED_FLAGS
--- elmer-mathlibs.diff ends here ---

--- elmer-umfpack.diff begins here ---
diff -urN ./math/elmer-umfpack.orig/Makefile ./math/elmer-umfpack/Makefile
--- ./math/elmer-umfpack.orig/Makefile	Wed Jul 12 23:57:11 2006
+++ ./math/elmer-umfpack/Makefile	Sat Sep 16 22:59:08 2006
@@ -15,13 +15,10 @@
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	UMFPACK library used by ELMER FEM package
 
-BUILD_DEPENDS=	${FC}:${PORTSDIR}/lang/gfortran
-
 CONFLICTS=	umfpack-[0-9].[0-9]*
 
 USE_GCC=	4.1+
 WITH_FORTRAN=	yes
-FC=	${LOCALBASE}/bin/gfortran41
 F77=	${FC}
 CONFIGURE_ENV+=	FC=${FC} F77=${FC}
 GNU_CONFIGURE=	yes
--- elmer-umfpack.diff ends here ---

--- elmer-fem.diff begins here ---
diff -urN ./science/elmer-fem.orig/Makefile ./science/elmer-fem/Makefile
--- ./science/elmer-fem.orig/Makefile	Wed Aug 23 22:46:33 2006
+++ ./science/elmer-fem/Makefile	Sat Sep 16 23:03:06 2006
@@ -14,8 +14,7 @@
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	FEM solver for use in the ELMER FEM package
 
-BUILD_DEPENDS=	${FC}:${PORTSDIR}/lang/gfortran	\
-		${LOCALBASE}/lib/libmatc.a:${PORTSDIR}/science/elmer-matc	\
+BUILD_DEPENDS=	${LOCALBASE}/lib/libmatc.a:${PORTSDIR}/science/elmer-matc	\
 		${LOCALBASE}/lib/libblas.a:${PORTSDIR}/math/elmer-mathlibs	\
 		${LOCALBASE}/lib/liblapack.a:${PORTSDIR}/math/elmer-mathlibs	\
 		${LOCALBASE}/lib/libumfpack.a:${PORTSDIR}/math/elmer-umfpack	\
@@ -26,7 +25,6 @@
 
 USE_GCC=	4.1+
 WITH_FORTRAN=	yes
-FC=	${LOCALBASE}/bin/gfortran41
 F77=	${FC}
 
 .ifdef WITH_OPTIMIZED_FLAGS
--- elmer-fem.diff ends here ---

--- elmer-matc.diff begins here ---
diff -urN ./science/elmer-matc.orig/Makefile ./science/elmer-matc/Makefile
--- ./science/elmer-matc.orig/Makefile	Wed Jul 12 23:57:34 2006
+++ ./science/elmer-matc/Makefile	Sat Sep 16 23:00:56 2006
@@ -14,11 +14,8 @@
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	MatC language library used by ELMER FEM package
 
-BUILD_DEPENDS=	${FC}:${PORTSDIR}/lang/gfortran
-
 USE_GCC=	4.1+
 WITH_FORTRAN=	yes
-FC=	${LOCALBASE}/bin/gfortran41
 F77=	${FC}
 CONFIGURE_ENV+=	FC=${FC} F77=${FC}
 
--- elmer-matc.diff ends here ---

--- elmer-eio.diff begins here ---
diff -urN ./science/elmer-eio.orig/Makefile ./science/elmer-eio/Makefile
--- ./science/elmer-eio.orig/Makefile	Wed Jul 12 23:58:47 2006
+++ ./science/elmer-eio/Makefile	Sat Sep 16 23:02:03 2006
@@ -14,11 +14,8 @@
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	ELMER FEM Package Data base Interface
 
-BUILD_DEPENDS=	${FC}:${PORTSDIR}/lang/gfortran
-
 USE_GCC=	4.1+
 WITH_FORTRAN=	yes
-FC=	${LOCALBASE}/bin/gfortran41
 F77=	${FC}
 CONFIGURE_ENV+=	FC=${FC} F77=${FC} FCFLAGS=${FCFLAGS}
 
--- elmer-eio.diff ends here ---

--- elmer-hutiter.diff begins here ---
diff -urN ./science/elmer-hutiter.orig/Makefile ./science/elmer-hutiter/Makefile
--- ./science/elmer-hutiter.orig/Makefile	Wed Jul 12 23:59:10 2006
+++ ./science/elmer-hutiter/Makefile	Sat Sep 16 23:04:07 2006
@@ -14,14 +14,12 @@
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	HUTIter library for use in the ELMER FEM package
 
-BUILD_DEPENDS=	${FC}:${PORTSDIR}/lang/gfortran	\
-		${LOCALBASE}/lib/libblas.a:${PORTSDIR}/math/elmer-mathlibs	 \
+BUILD_DEPENDS=	${LOCALBASE}/lib/libblas.a:${PORTSDIR}/math/elmer-mathlibs	 \
 		${LOCALBASE}/lib/liblapack.a:${PORTSDIR}/math/elmer-mathlibs	 \
 		${LOCALBASE}/lib/libarpack.a:${PORTSDIR}/math/elmer-mathlibs
 
 USE_GCC=	4.1+
 
-FC=	${LOCALBASE}/bin/gfortran41
 F77=	${FC}
 WITH_FORTRAN=	yes
 CONFIGURE_ENV+=	FC=${FC} F77=${FC}
--- elmer-hutiter.diff ends here ---

--- elmerpost.diff begins here ---
diff -urN ./science/elmerpost.orig/Makefile ./science/elmerpost/Makefile
--- ./science/elmerpost.orig/Makefile	Thu Jul 13 00:01:07 2006
+++ ./science/elmerpost/Makefile	Sat Sep 16 23:07:12 2006
@@ -13,8 +13,7 @@
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	Visualization of Numerical Results in the ELMER FEM package
 
-BUILD_DEPENDS=	${FC}:${PORTSDIR}/lang/gfortran \
-		${LOCALBASE}/lib/libmatc.a:${PORTSDIR}/science/elmer-matc	\
+BUILD_DEPENDS=	${LOCALBASE}/lib/libmatc.a:${PORTSDIR}/science/elmer-matc	\
 		wish8.4:${PORTSDIR}/x11-toolkits/tk84
 RUN_DEPENDS=	wish8.4:${PORTSDIR}/x11-toolkits/tk84
 
@@ -29,7 +28,6 @@
 
 USE_GCC=	4.1+
 WITH_FORTRAN=	yes
-FC=	${LOCALBASE}/bin/gfortran41
 F77=	${FC}
 CONFIGURE_ENV+=	FC=${FC} F77=${FC} FCFLAGS=${FCFLAGS}
 
--- elmerpost.diff ends here ---

Regards,
-- 
Th. Thomas.
Comment 6 Kris Kennaway freebsd_committer freebsd_triage 2006-09-20 05:19:29 UTC
State Changed
From-To: suspended->analyzed

Currently being tested on package cluster
Comment 7 dfilter service freebsd_committer freebsd_triage 2006-09-30 20:25:53 UTC
linimon     2006-09-30 19:25:46 UTC

  FreeBSD ports repository

  Modified files:
    Mk                   bsd.database.mk bsd.gcc.mk bsd.port.mk 
    math/elmer-mathlibs  Makefile 
    math/elmer-umfpack   Makefile 
    science/elmer-eio    Makefile 
    science/elmer-fem    Makefile 
    science/elmer-hutiter Makefile 
    science/elmer-matc   Makefile 
    science/elmerpost    Makefile 
  Log:
  * Split bsd.port.mk pre and post includes into 3 pieces instead of 2, to
    allow OPTIONS to be able to influence dependencies.  This is still
    experimental [1]
  
  * Teach bsd.gcc.mk about gfortran [2]
  
  * Remove the outdated emulators/linux_base; the new default has been
    linux_base-fc4.  This will allow the outdated port to be removed [3]
  
  * Add USE_FIREBIRD macros to bsd.database.mk [4]
  
  PR:     93687 [1], 93690 [2], 103184 [3], 103357 [4]
  
  Submitted by:   shaun [1], Pedro F. Giffuni <giffunip at asme to org> [2],
                  gerald [2], thierry [2], vd [3], skv [4]
  
  Revision  Changes    Path
  1.15      +31 -1     ports/Mk/bsd.database.mk
  1.9       +26 -8     ports/Mk/bsd.gcc.mk
  1.544     +21 -19    ports/Mk/bsd.port.mk
  1.7       +0 -2      ports/math/elmer-mathlibs/Makefile
  1.4       +0 -3      ports/math/elmer-umfpack/Makefile
  1.4       +0 -3      ports/science/elmer-eio/Makefile
  1.9       +1 -3      ports/science/elmer-fem/Makefile
  1.5       +1 -3      ports/science/elmer-hutiter/Makefile
  1.4       +0 -3      ports/science/elmer-matc/Makefile
  1.4       +1 -3      ports/science/elmerpost/Makefile
_______________________________________________
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"
Comment 8 Mark Linimon freebsd_committer freebsd_triage 2006-09-30 20:33:59 UTC
State Changed
From-To: analyzed->closed

Committed, thanks to all who worked on this.