| @@ -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) |
32 | COMPILER_GFORTRAN_MK= defined | | 32 | COMPILER_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. |
42 | POSSIBLE_GFORTRAN_VERSION?= ${CC_VERSION:S/gcc-//:C/.[0-9].[0-9]$//} | | 41 | POSSIBLE_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. |
46 | GFORTRAN_VERSION?= 12 | | 45 | GFORTRAN_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*) |
53 | POSSIBLE_GFORTRAN_VERSION= 10 | | 52 | POSSIBLE_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*) |
59 | POSSIBLE_GFORTRAN_VERSION= 10 | | 58 | POSSIBLE_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) |
66 | GFORTRAN_VERSION?= ${POSSIBLE_GFORTRAN_VERSION} | | 65 | GFORTRAN_VERSION?= ${POSSIBLE_GFORTRAN_VERSION} |
67 | .else | | 66 | .else |
68 | GFORTRAN_VERSION?= 7 | | 67 | GFORTRAN_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) |
73 | IGNORE_GFORTRAN= yes | | 72 | IGNORE_GFORTRAN= yes |
74 | MAKEFLAGS+= IGNORE_GFORTRAN=yes | | 73 | MAKEFLAGS+= 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 | # |
85 | LANGUAGES.gfortran= fortran fortran77 | | 84 | LANGUAGES.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} |
100 | FC= gfortran | | 99 | FC= 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) |
106 | PKG_FC?= ${FC} | | 105 | PKG_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 |
110 | FCPATH= ${_GFORTRANBASE}/bin/gfortran | | 109 | FCPATH= ${_GFORTRANBASE}/bin/gfortran |
111 | PKG_FC:= ${_GFORTRAN_FC} | | 110 | PKG_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) |
116 | PREPEND_PATH+= ${_GFORTRAN_DIR}/bin | | 115 | PREPEND_PATH+= ${_GFORTRAN_DIR}/bin |
117 | . endif | | 116 | . endif |
118 | | | 117 | |
119 | # Add the dependency on gfortran. | | 118 | # Add the dependency on gfortran. |
120 | BUILDLINK_DEPMETHOD.gcc${GFORTRAN_VERSION}= full | | 119 | BUILDLINK_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) |
124 | PKGSRC_MAKE_ENV+= GFORTRAN_DIR=${GFORTRAN_DIR:Q} | | 123 | PKGSRC_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_}}) |
130 | override-tools: ${_GFORTRAN_${_var_}} | | 129 | override-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 |