2018-08-22 22:48:36 +02:00
|
|
|
# $NetBSD: f2c.mk,v 1.19 2018/08/22 20:48:37 maya Exp $
|
2005-01-12 19:36:11 +01:00
|
|
|
#
|
|
|
|
# Copyright (c) 2005 The NetBSD Foundation, Inc.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This code is derived from software contributed to The NetBSD Foundation
|
2005-01-12 23:56:41 +01:00
|
|
|
# by Johnny C. Lam.
|
2005-01-12 19:36:11 +01:00
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#
|
2005-01-12 16:31:58 +01:00
|
|
|
|
|
|
|
.if !defined(COMPILER_F2C_MK)
|
|
|
|
COMPILER_F2C_MK= defined
|
|
|
|
|
|
|
|
.include "../../mk/bsd.prefs.mk"
|
|
|
|
|
|
|
|
# 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.
|
2006-12-15 13:46:23 +01:00
|
|
|
#
|
2010-07-30 09:58:58 +02:00
|
|
|
LANGUAGES.f2c= fortran fortran77
|
2005-01-12 16:31:58 +01:00
|
|
|
_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])
|
2008-05-24 09:27:11 +02:00
|
|
|
USE_LANGUAGES+= c
|
|
|
|
|
2005-01-12 16:31:58 +01:00
|
|
|
_F2C_DIR= ${WRKDIR}/.f2c
|
|
|
|
_F2C_VARS= # empty
|
2010-07-30 09:58:58 +02:00
|
|
|
. if !empty(_LANGUAGES.f2c:Mfortran) || !empty(_LANGUAGES.f2c:Mfortran77)
|
2005-01-12 16:31:58 +01:00
|
|
|
PKG_FC?= ${FC}
|
|
|
|
_F2C_VARS+= FC
|
|
|
|
_F2C_FC:= ${_F2C_DIR}/bin/${PKG_FC:T}
|
2007-01-16 18:16:20 +01:00
|
|
|
_ALIASES.FC+= f77 g77 f2c-f77
|
2015-11-25 14:05:47 +01:00
|
|
|
FCPATH= ${LOCALBASE}/bin/f2c-f77
|
2005-01-12 16:31:58 +01:00
|
|
|
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
|
|
|
|
|
2009-12-03 13:44:10 +01:00
|
|
|
# Dependencies:
|
2013-05-10 01:37:25 +02:00
|
|
|
TOOL_DEPENDS+= f2c>=20090411nb2:../../lang/f2c # translator
|
2009-12-15 18:35:36 +01:00
|
|
|
|
2017-03-05 11:40:18 +01:00
|
|
|
.if empty(PKGPATH:Mdevel/libtool-base) && empty(PKGPATH:Mcross/cross-libtool-base) # See below
|
2009-12-03 13:44:10 +01:00
|
|
|
. include "../../devel/libf2c/buildlink3.mk" # library
|
2009-12-15 18:35:36 +01:00
|
|
|
.endif
|
2005-01-12 16:31:58 +01:00
|
|
|
|
|
|
|
. if defined(F2C_DIR) && !empty(F2C_DIR)
|
2006-07-21 16:27:56 +02:00
|
|
|
PKGSRC_MAKE_ENV+= F2C_DIR=${F2C_DIR:Q}
|
2005-01-12 16:31:58 +01:00
|
|
|
. endif
|
|
|
|
|
2009-12-15 18:35:36 +01:00
|
|
|
# libtool-base is special as it only needs f77 to extract linker flags etc.
|
2017-03-05 11:40:18 +01:00
|
|
|
.if !empty(PKGPATH:Mdevel/libtool-base) || !empty(PKGPATH:Mcross/cross-libtool-base)
|
2009-12-15 18:35:36 +01:00
|
|
|
pre-configure: fake-f2c-libs
|
|
|
|
|
|
|
|
_WRAP_EXTRA_ARGS.FC+= -L${WRKDIR}/.f2c/lib -I${WRKDIR}/.f2c/include
|
|
|
|
|
|
|
|
fake-f2c-libs:
|
|
|
|
${MKDIR} ${WRKDIR}/.f2c/include
|
|
|
|
${MKDIR} ${WRKDIR}/.f2c/lib
|
|
|
|
${ECHO} 'int main(void) { return 0; }' > ${WRKDIR}/.f2c/lib/main.c
|
|
|
|
${CC} -c -o ${WRKDIR}/.f2c/lib/main.o ${WRKDIR}/.f2c/lib/main.c
|
|
|
|
${AR} cq ${WRKDIR}/.f2c/lib/libf2c.a ${WRKDIR}/.f2c/lib/main.o
|
|
|
|
${RANLIB} ${WRKDIR}/.f2c/lib/libf2c.a
|
|
|
|
${TOUCH} ${WRKDIR}/.f2c/include/f2c.h
|
|
|
|
.endif
|
|
|
|
|
2005-01-12 16:31:58 +01:00
|
|
|
# Create symlinks for the compiler into ${WRKDIR}.
|
|
|
|
. for _var_ in ${_F2C_VARS}
|
|
|
|
. if !target(${_F2C_${_var_}})
|
|
|
|
override-tools: ${_F2C_${_var_}}
|
|
|
|
${_F2C_${_var_}}:
|
2008-02-07 21:59:05 +01:00
|
|
|
${RUN}${MKDIR} ${.TARGET:H}
|
|
|
|
${RUN} \
|
2015-11-25 14:05:47 +01:00
|
|
|
${LN} -fs ${LOCALBASE}/bin/f2c-f77 ${.TARGET}
|
2005-01-12 16:31:58 +01:00
|
|
|
. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
|
2008-02-07 21:59:05 +01:00
|
|
|
${RUN} \
|
2005-01-12 16:31:58 +01:00
|
|
|
if [ ! -x "${_alias_}" ]; then \
|
2015-11-25 14:05:47 +01:00
|
|
|
${LN} -fs ${LOCALBASE}/bin/f2c-f77 ${_alias_}; \
|
2005-01-12 16:31:58 +01:00
|
|
|
fi
|
|
|
|
. endfor
|
|
|
|
. endif
|
|
|
|
. endfor
|
|
|
|
.endif # _USE_F2C == "yes"
|
|
|
|
|
|
|
|
.endif # COMPILER_F2C_MK
|