Tue Oct 31 13:47:57 2023 UTC ()
mk/compiler/fortran.mk: Adjust comments slightly


(gdt)
diff -r1.24 -r1.25 pkgsrc/mk/compiler/gfortran.mk

cvs diff -r1.24 -r1.25 pkgsrc/mk/compiler/gfortran.mk (switch to unified diff)

--- pkgsrc/mk/compiler/gfortran.mk 2023/10/31 13:45:30 1.24
+++ pkgsrc/mk/compiler/gfortran.mk 2023/10/31 13:47:56 1.25
@@ -1,145 +1,144 @@ @@ -1,145 +1,144 @@
1# $NetBSD: gfortran.mk,v 1.24 2023/10/31 13:45:30 gdt Exp $ 1# $NetBSD: gfortran.mk,v 1.25 2023/10/31 13:47:56 gdt Exp $
2# 2#
3# Copyright (c) 2005 The NetBSD Foundation, Inc. 3# Copyright (c) 2005 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# This code is derived from software contributed to The NetBSD Foundation 6# This code is derived from software contributed to The NetBSD Foundation
7# by Johnny C. Lam. 7# by Johnny C. Lam.
8# 8#
9# Redistribution and use in source and binary forms, with or without 9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions 10# modification, are permitted provided that the following conditions
11# are met: 11# are met:
12# 1. Redistributions of source code must retain the above copyright 12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer. 13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright 14# 2. Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the 15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution. 16# documentation and/or other materials provided with the distribution.
17# 17#
18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE. 28# POSSIBILITY OF SUCH DAMAGE.
29# 29#
30 30
31.if !defined(COMPILER_GFORTRAN_MK) 31.if !defined(COMPILER_GFORTRAN_MK)
32COMPILER_GFORTRAN_MK= defined 32COMPILER_GFORTRAN_MK= defined
33 33
34.include "../../mk/bsd.prefs.mk" 34.include "../../mk/bsd.prefs.mk"
35 35
36# If the pkgsrc base compiler is GCC, define POSSIBLE_GORTRAN_VERSION 36# If the pkgsrc base compiler is GCC, define POSSIBLE_GORTRAN_VERSION
37# (meaning a candidate we would like) to match, and try to use that if 37# (meaning a candidate we would like) to match. If that version is
38# possible, unless known to be problematic. Otherwise, pick a 38# known to be problematic on a platform, pick a better one.
39# mainstream version and hope for the best. 
40# \todo If the base compiler is clang, we probably should use flang 39# \todo If the base compiler is clang, we probably should use flang
41# rather than gfortran, but this is gfortran.mk. 40# rather than gfortran, but this is gfortran.mk.
42POSSIBLE_GFORTRAN_VERSION?= ${CC_VERSION:S/gcc-//:C/.[0-9].[0-9]$//} 41POSSIBLE_GFORTRAN_VERSION?= ${CC_VERSION:S/gcc-//:C/.[0-9].[0-9]$//}
43 42
44.if ${MACHINE_PLATFORM:MDarwin-*-*} 43.if ${MACHINE_PLATFORM:MDarwin-*-*}
45# \todo For parallel structure this should set POSSIBLE_GFORTRAN_VERSION instead. 44# \todo For parallel structure this should set POSSIBLE_GFORTRAN_VERSION instead.
46GFORTRAN_VERSION?= 12 45GFORTRAN_VERSION?= 12
47.endif 46.endif
48 47
49# pkgsrc gcc9 is missing NetBSD patches for aarch64, so if 9 is 48# pkgsrc gcc9 is missing NetBSD patches for aarch64, so if 9 is
50# selected (historical current only?), advance to 10. 49# selected (historical current only?), advance to 10.
51.if !empty(POSSIBLE_GFORTRAN_VERSION:M9) && \ 50.if !empty(POSSIBLE_GFORTRAN_VERSION:M9) && \
52 !empty(MACHINE_PLATFORM:MNetBSD-*-aarch64*) 51 !empty(MACHINE_PLATFORM:MNetBSD-*-aarch64*)
53POSSIBLE_GFORTRAN_VERSION= 10 52POSSIBLE_GFORTRAN_VERSION= 10
54.endif 53.endif
55 54
56# All pkgsrc gcc < 10 versions are not ok on 32-bit arm; advance to 10. 55# All pkgsrc gcc < 10 versions are not ok on 32-bit arm; advance to 10.
57.if !empty(POSSIBLE_GFORTRAN_VERSION:M[0-9]) && \ 56.if !empty(POSSIBLE_GFORTRAN_VERSION:M[0-9]) && \
58 !empty(MACHINE_PLATFORM:MNetBSD-*-earm*) 57 !empty(MACHINE_PLATFORM:MNetBSD-*-earm*)
59POSSIBLE_GFORTRAN_VERSION= 10 58POSSIBLE_GFORTRAN_VERSION= 10
60.endif 59.endif
61 60
62# If we are using gcc, and the POSSIBLE version exists in pkgsrc, use it. 61# If we are using gcc, and the POSSIBLE version exists in pkgsrc, use it.
63# Otherwise, pick gcc 7. \todo Revisit this choice. 62# Otherwise, pick gcc 7. \todo Revisit this choice.
64.if !empty(PKGSRC_COMPILER:Mgcc) && \ 63.if !empty(PKGSRC_COMPILER:Mgcc) && \
65 exists(${PKGSRCDIR}/lang/gcc${POSSIBLE_GFORTRAN_VERSION}/buildlink3.mk) 64 exists(${PKGSRCDIR}/lang/gcc${POSSIBLE_GFORTRAN_VERSION}/buildlink3.mk)
66GFORTRAN_VERSION?= ${POSSIBLE_GFORTRAN_VERSION} 65GFORTRAN_VERSION?= ${POSSIBLE_GFORTRAN_VERSION}
67.else 66.else
68GFORTRAN_VERSION?= 7 67GFORTRAN_VERSION?= 7
69.endif 68.endif
70 69
71.if !empty(PKGPATH:Mlang/gcc${GFORTRAN_VERSION}) || !empty(PKGPATH:Mdevel/patch) || \ 70.if !empty(PKGPATH:Mlang/gcc${GFORTRAN_VERSION}) || !empty(PKGPATH:Mdevel/patch) || \
72 !empty(PKGPATH:Mdevel/libtool-base) 71 !empty(PKGPATH:Mdevel/libtool-base)
73IGNORE_GFORTRAN= yes 72IGNORE_GFORTRAN= yes
74MAKEFLAGS+= IGNORE_GFORTRAN=yes 73MAKEFLAGS+= IGNORE_GFORTRAN=yes
75.endif 74.endif
76 75
77.if defined(IGNORE_GFORTRAN) 76.if defined(IGNORE_GFORTRAN)
78_USE_GFORTRAN= NO 77_USE_GFORTRAN= NO
79.endif 78.endif
80 79
81# LANGUAGES.<compiler> is the list of supported languages by the compiler. 80# LANGUAGES.<compiler> is the list of supported languages by the compiler.
82# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the ones 81# _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the ones
83# requested by the package in USE_LANGUAGES. 82# requested by the package in USE_LANGUAGES.
84# 83#
85LANGUAGES.gfortran= fortran fortran77 84LANGUAGES.gfortran= fortran fortran77
86_LANGUAGES.gfortran= # empty 85_LANGUAGES.gfortran= # empty
87.for _lang_ in ${USE_LANGUAGES} 86.for _lang_ in ${USE_LANGUAGES}
88_LANGUAGES.gfortran+= ${LANGUAGES.gfortran:M${_lang_}} 87_LANGUAGES.gfortran+= ${LANGUAGES.gfortran:M${_lang_}}
89.endfor 88.endfor
90.if empty(_LANGUAGES.gfortran) 89.if empty(_LANGUAGES.gfortran)
91_USE_GFORTRAN= NO 90_USE_GFORTRAN= NO
92.endif 91.endif
93 92
94.if !defined(_USE_GFORTRAN) 93.if !defined(_USE_GFORTRAN)
95_USE_GFORTRAN= YES 94_USE_GFORTRAN= YES
96.endif 95.endif
97 96
98.if !empty(_USE_GFORTRAN:M[yY][eE][sS]) 97.if !empty(_USE_GFORTRAN:M[yY][eE][sS])
99_GFORTRANBASE= ${TOOLBASE}/gcc${GFORTRAN_VERSION} 98_GFORTRANBASE= ${TOOLBASE}/gcc${GFORTRAN_VERSION}
100FC= gfortran 99FC= gfortran
101 100
102_GFORTRAN_DIR= ${WRKDIR}/.gfortran 101_GFORTRAN_DIR= ${WRKDIR}/.gfortran
103_GFORTRAN_VARS= # empty 102_GFORTRAN_VARS= # empty
104. if !empty(_LANGUAGES.gfortran:Mfortran) || \ 103. if !empty(_LANGUAGES.gfortran:Mfortran) || \
105 !empty(_LANGUAGES.gfortran:Mfortran77) 104 !empty(_LANGUAGES.gfortran:Mfortran77)
106PKG_FC?= ${FC} 105PKG_FC?= ${FC}
107_GFORTRAN_VARS+= FC 106_GFORTRAN_VARS+= FC
108_GFORTRAN_FC:= ${_GFORTRAN_DIR}/bin/${PKG_FC:T} 107_GFORTRAN_FC:= ${_GFORTRAN_DIR}/bin/${PKG_FC:T}
109_ALIASES.FC+= f77 g77 g95 gfortran 108_ALIASES.FC+= f77 g77 g95 gfortran
110FCPATH= ${_GFORTRANBASE}/bin/gfortran 109FCPATH= ${_GFORTRANBASE}/bin/gfortran
111PKG_FC:= ${_GFORTRAN_FC} 110PKG_FC:= ${_GFORTRAN_FC}
112. endif 111. endif
113 112
114# Prepend the path the to the compiler to the PATH 113# Prepend the path the to the compiler to the PATH
115. if !empty(_LANGUAGES.gfortran) 114. if !empty(_LANGUAGES.gfortran)
116PREPEND_PATH+= ${_GFORTRAN_DIR}/bin 115PREPEND_PATH+= ${_GFORTRAN_DIR}/bin
117. endif 116. endif
118 117
119# Add the dependency on gfortran. 118# Add the dependency on gfortran.
120BUILDLINK_DEPMETHOD.gcc${GFORTRAN_VERSION}= full 119BUILDLINK_DEPMETHOD.gcc${GFORTRAN_VERSION}= full
121. include "../../lang/gcc${GFORTRAN_VERSION}/buildlink3.mk" 120. include "../../lang/gcc${GFORTRAN_VERSION}/buildlink3.mk"
122 121
123. if defined(GFORTRAN_DIR) && !empty(GFORTRAN_DIR) 122. if defined(GFORTRAN_DIR) && !empty(GFORTRAN_DIR)
124PKGSRC_MAKE_ENV+= GFORTRAN_DIR=${GFORTRAN_DIR:Q} 123PKGSRC_MAKE_ENV+= GFORTRAN_DIR=${GFORTRAN_DIR:Q}
125. endif 124. endif
126 125
127# Create symlinks for the compiler into ${WRKDIR}. 126# Create symlinks for the compiler into ${WRKDIR}.
128. for _var_ in ${_GFORTRAN_VARS} 127. for _var_ in ${_GFORTRAN_VARS}
129. if !target(${_GFORTRAN_${_var_}}) 128. if !target(${_GFORTRAN_${_var_}})
130override-tools: ${_GFORTRAN_${_var_}} 129override-tools: ${_GFORTRAN_${_var_}}
131${_GFORTRAN_${_var_}}: 130${_GFORTRAN_${_var_}}:
132 ${RUN}${MKDIR} ${.TARGET:H} 131 ${RUN}${MKDIR} ${.TARGET:H}
133 ${RUN} \ 132 ${RUN} \
134 ${LN} -fs ${_GFORTRANBASE}/bin/gfortran ${.TARGET} 133 ${LN} -fs ${_GFORTRANBASE}/bin/gfortran ${.TARGET}
135. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//} 134. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
136 ${RUN} \ 135 ${RUN} \
137 if [ ! -x "${_alias_}" ]; then \ 136 if [ ! -x "${_alias_}" ]; then \
138 ${LN} -fs ${_GFORTRANBASE}/bin/gfortran ${_alias_}; \ 137 ${LN} -fs ${_GFORTRANBASE}/bin/gfortran ${_alias_}; \
139 fi 138 fi
140. endfor 139. endfor
141. endif 140. endif
142. endfor 141. endfor
143.endif # _USE_GFORTRAN == "yes" 142.endif # _USE_GFORTRAN == "yes"
144 143
145.endif # COMPILER_GFORTRAN_MK 144.endif # COMPILER_GFORTRAN_MK