summaryrefslogtreecommitdiff
path: root/mk/compiler
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2005-01-12 15:31:58 +0000
committerjlam <jlam@pkgsrc.org>2005-01-12 15:31:58 +0000
commitb6b853727dc16c84fba65c5d610f333d83e309ff (patch)
treec0c77d22dc6d7622e4196a9cf79e6fc77ed93ceb /mk/compiler
parent98d6a371a10bb43601330b19f60f71ceb54ac6d2 (diff)
downloadpkgsrc-b6b853727dc16c84fba65c5d610f333d83e309ff.tar.gz
Nuke USE_FORTRAN and bring the f2c handling within the mk/compiler
framework. The list of changes include: * Modify compiler.mk so that "c" is always prepended to USE_LANGUAGES, so we no longer need to say it in package Makefiles. Packages should now append to USE_LANGUAGES instead of setting it. * Create mk/compiler/f2c.mk which implements another pseudo-compiler "f2c" that may be used with any C compiler backend, e.g. PKGSRC_COMPILER= f2c ccache gcc * Teach the various "real" compiler files, e.g., sunpro.mk, mipspro.mk, etc., to use f2c if the native Fortran compiler isn't present. Packages that use Fortran should now simply include the line: USE_LANGUAGES+= fortran in the package Makefile.
Diffstat (limited to 'mk/compiler')
-rw-r--r--mk/compiler/ccc.mk12
-rw-r--r--mk/compiler/f2c.mk93
-rw-r--r--mk/compiler/gcc.mk19
-rw-r--r--mk/compiler/mipspro.mk12
-rw-r--r--mk/compiler/sunpro.mk12
-rw-r--r--mk/compiler/xlc.mk12
6 files changed, 155 insertions, 5 deletions
diff --git a/mk/compiler/ccc.mk b/mk/compiler/ccc.mk
index 395e74f9cec..7ae44d3d3a2 100644
--- a/mk/compiler/ccc.mk
+++ b/mk/compiler/ccc.mk
@@ -1,4 +1,4 @@
-# $NetBSD: ccc.mk,v 1.6 2004/11/30 14:50:37 jlam Exp $
+# $NetBSD: ccc.mk,v 1.7 2005/01/12 15:32:01 jlam Exp $
.if !defined(COMPILER_CCC_MK)
COMPILER_CCC_MK= defined
@@ -84,4 +84,14 @@ ${_CCC_${_var_}}:
. endif
.endfor
+# Force the use of f2c-f77 for compiling Fortran.
+_CCC_USE_F2C= no
+FCPATH= /nonexistent
+.if !exists(${FCPATH})
+_CCC_USE_F2C= yes
+.endif
+.if !empty(_CCC_USE_F2C:M[yY][eE][sS])
+. include "../../mk/compiler/f2c.mk"
+.endif
+
.endif # COMPILER_CCC_MK
diff --git a/mk/compiler/f2c.mk b/mk/compiler/f2c.mk
new file mode 100644
index 00000000000..72228eb3bbf
--- /dev/null
+++ b/mk/compiler/f2c.mk
@@ -0,0 +1,93 @@
+# $NetBSD: f2c.mk,v 1.1 2005/01/12 15:32:01 jlam Exp $
+
+.if !defined(COMPILER_F2C_MK)
+COMPILER_F2C_MK= defined
+
+.include "../../mk/bsd.prefs.mk"
+
+.if !empty(PKGPATH:Mlang/f2c) || !empty(PKGPATH:Mdevel/patch) || \
+ !empty(PKGPATH:Mdevel/libtool-base)
+IGNORE_F2C= yes
+MAKEFLAGS+= IGNORE_F2C=yes
+.endif
+
+.if defined(IGNORE_F2C)
+_USE_F2C= NO
+.endif
+
+# LANGUAGES.<compiler> is the list of supported languages by the compiler.
+# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the ones
+# requested by the package in USE_LANGUAGES.
+#
+LANGUAGES.f2c= fortran
+_LANGUAGES.f2c= # empty
+.for _lang_ in ${USE_LANGUAGES}
+_LANGUAGES.f2c+= ${LANGUAGES.f2c:M${_lang_}}
+.endfor
+.if empty(_LANGUAGES.f2c)
+_USE_F2C= NO
+.endif
+
+.if !defined(_USE_F2C)
+_USE_F2C= YES
+.endif
+
+.if !empty(_USE_F2C:M[yY][eE][sS])
+EVAL_PREFIX+= _F2CBASE=f2c
+_F2CBASE_DEFAULT= ${LOCALBASE}
+_F2CBASE?= ${LOCALBASE}
+
+_F2C_DIR= ${WRKDIR}/.f2c
+_F2C_VARS= # empty
+. if !empty(_LANGUAGES.f2c:Mfortran)
+PKG_FC?= ${FC}
+_F2C_VARS+= FC
+_F2C_FC:= ${_F2C_DIR}/bin/${PKG_FC:T}
+_ALIASES.FC+= f77 f2c-f77
+FCPATH= ${_F2CBASE}/bin/f2c-f77
+PKG_FC:= ${_F2C_FC}
+#
+# The f2c-f77 shell script invokes the C compiler, so ensure that it finds
+# the cc wrapper for proper transformations.
+#
+# XXX This shouldn't really be leaking into here, as it breaks encapsulation.
+# XXX It should really be handled within the wrapper framework.
+#
+_WRAP_ENV.FC= PATH="${WRAPPER_BINDIR}:${_WRAP_PATH}"; export PATH
+. endif
+
+# Prepend the path the to the compiler to the PATH
+. if !empty(_LANGUAGES.f2c)
+PREPEND_PATH+= ${_F2C_DIR}/bin
+. endif
+
+# Add the dependency on f2c.
+. if !empty(USE_BUILDLINK3:M[yY][eE][sS])
+. include "../../lang/f2c/buildlink3.mk"
+. else
+DEPENDS+= f2c>=20001205nb3:../../lang/f2c
+. endif
+
+. if defined(F2C_DIR) && !empty(F2C_DIR)
+BUILD_ENV+= F2C_DIR=${F2C_DIR:Q}
+. endif
+
+# Create symlinks for the compiler into ${WRKDIR}.
+. for _var_ in ${_F2C_VARS}
+. if !target(${_F2C_${_var_}})
+override-tools: ${_F2C_${_var_}}
+${_F2C_${_var_}}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${LN} -fs ${_F2CBASE}/bin/f2c-f77 ${.TARGET}
+. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if [ ! -x "${_alias_}" ]; then \
+ ${LN} -fs ${_F2CBASE}/bin/f2c-f77 ${_alias_}; \
+ fi
+. endfor
+. endif
+. endfor
+.endif # _USE_F2C == "yes"
+
+.endif # COMPILER_F2C_MK
diff --git a/mk/compiler/gcc.mk b/mk/compiler/gcc.mk
index 4099063f6bf..8939db1e9f5 100644
--- a/mk/compiler/gcc.mk
+++ b/mk/compiler/gcc.mk
@@ -1,4 +1,4 @@
-# $NetBSD: gcc.mk,v 1.77 2004/11/30 14:50:37 jlam Exp $
+# $NetBSD: gcc.mk,v 1.78 2005/01/12 15:32:01 jlam Exp $
.if !defined(COMPILER_GCC_MK)
COMPILER_GCC_MK= defined
@@ -436,4 +436,21 @@ ${_GCC_${_var_}}:
. endif
.endfor
+# On older NetBSD systems and where the Fortran compiler doesn't exist,
+# force the use of f2c-f77.
+#
+_GCC_USE_F2C= no
+.if !exists(${FCPATH})
+_GCC_USE_F2C= yes
+.else
+. for _pattern_ in 0.* 1.[0-4] 1.[0-4].*
+. if !empty(MACHINE_PLATFORM:MNetBSD-${_pattern_}-*)
+_GCC_USE_F2C= yes
+. endif
+. endfor
+.endif
+.if !empty(_GCC_USE_F2C:M[yY][eE][sS])
+. include "../../mk/compiler/f2c.mk"
+.endif
+
.endif # COMPILER_GCC_MK
diff --git a/mk/compiler/mipspro.mk b/mk/compiler/mipspro.mk
index 694a66c7544..1a483cc80a5 100644
--- a/mk/compiler/mipspro.mk
+++ b/mk/compiler/mipspro.mk
@@ -1,4 +1,4 @@
-# $NetBSD: mipspro.mk,v 1.29 2004/11/30 14:50:37 jlam Exp $
+# $NetBSD: mipspro.mk,v 1.30 2005/01/12 15:32:01 jlam Exp $
.if !defined(COMPILER_MIPSPRO_MK)
COMPILER_MIPSPRO_MK= defined
@@ -95,4 +95,14 @@ CFLAGS+= ${MABIFLAG}
LDFLAGS+= ${MABIFLAG}
.endif
+# Force the use of f2c-f77 for compiling Fortran.
+_MIPSPRO_USE_F2C= no
+FCPATH= /nonexistent
+.if !exists(${FCPATH})
+_MIPSPRO_USE_F2C= yes
+.endif
+.if !empty(_MIPSPRO_USE_F2C:M[yY][eE][sS])
+. include "../../mk/compiler/f2c.mk"
+.endif
+
.endif # COMPILER_MIPSPRO_MK
diff --git a/mk/compiler/sunpro.mk b/mk/compiler/sunpro.mk
index 85b0a0306d7..f979b6cb6c9 100644
--- a/mk/compiler/sunpro.mk
+++ b/mk/compiler/sunpro.mk
@@ -1,4 +1,4 @@
-# $NetBSD: sunpro.mk,v 1.25 2004/11/30 14:50:37 jlam Exp $
+# $NetBSD: sunpro.mk,v 1.26 2005/01/12 15:32:01 jlam Exp $
.if !defined(COMPILER_SUNPRO_MK)
COMPILER_SUNPRO_MK= defined
@@ -83,4 +83,14 @@ ${_SUNPRO_${_var_}}:
. endif
.endfor
+# Force the use of f2c-f77 for compiling Fortran.
+_SUNPRO_USE_F2C= no
+FCPATH= /nonexistent
+.if !exists(${FCPATH})
+_SUNPRO_USE_F2C= yes
+.endif
+.if !empty(_SUNPRO_USE_F2C:M[yY][eE][sS])
+. include "../../mk/compiler/f2c.mk"
+.endif
+
.endif # COMPILER_SUNPRO_MK
diff --git a/mk/compiler/xlc.mk b/mk/compiler/xlc.mk
index f23546f8606..9b0aa91f277 100644
--- a/mk/compiler/xlc.mk
+++ b/mk/compiler/xlc.mk
@@ -1,4 +1,4 @@
-# $NetBSD: xlc.mk,v 1.7 2004/11/30 14:50:37 jlam Exp $
+# $NetBSD: xlc.mk,v 1.8 2005/01/12 15:32:01 jlam Exp $
.if !defined(COMPILER_XLC_MK)
COMPILER_XLC_MK= defined
@@ -78,4 +78,14 @@ ${_XLC_${_var_}}:
. endif
.endfor
+# Force the use of f2c-f77 for compiling Fortran.
+_XLC_USE_F2C= no
+FCPATH= /nonexistent
+.if !exists(${FCPATH})
+_XLC_USE_F2C= yes
+.endif
+.if !empty(_XLC_USE_F2C:M[yY][eE][sS])
+. include "../../mk/compiler/f2c.mk"
+.endif
+
.endif # COMPILER_XLC_MK