Sat Jul 22 12:20:37 2023 UTC ()
mk: Add support for is_trivially_copy_constructible in USE_CXX_FEATURES.

While a mouthful, this is the name the GCC commit message used for the
features.


(nia)
diff -r1.187 -r1.188 pkgsrc/doc/guide/files/fixes.xml
diff -r1.101 -r1.102 pkgsrc/mk/compiler.mk
diff -r1.256 -r1.257 pkgsrc/mk/compiler/gcc.mk

cvs diff -r1.187 -r1.188 pkgsrc/doc/guide/files/fixes.xml (switch to unified diff)

--- pkgsrc/doc/guide/files/fixes.xml 2023/07/21 08:29:56 1.187
+++ pkgsrc/doc/guide/files/fixes.xml 2023/07/22 12:20:37 1.188
@@ -1,2460 +1,2461 @@ @@ -1,2460 +1,2461 @@
1<!-- $NetBSD: fixes.xml,v 1.187 2023/07/21 08:29:56 nia Exp $ --> 1<!-- $NetBSD: fixes.xml,v 1.188 2023/07/22 12:20:37 nia Exp $ -->
2 2
3<chapter id="fixes"> <?dbhtml filename="fixes.html"?> 3<chapter id="fixes"> <?dbhtml filename="fixes.html"?>
4<title>Making your package work</title> 4<title>Making your package work</title>
5 5
6<sect1 id="general-operation"> 6<sect1 id="general-operation">
7 <title>General operation</title> 7 <title>General operation</title>
8 8
9 <para>One appealing feature of pkgsrc is that it runs on many 9 <para>One appealing feature of pkgsrc is that it runs on many
10 different platforms. As a result, it is important to ensure, 10 different platforms. As a result, it is important to ensure,
11 where possible, that packages in pkgsrc are portable. This 11 where possible, that packages in pkgsrc are portable. This
12 chapter mentions some particular details you should pay 12 chapter mentions some particular details you should pay
13 attention to while working on pkgsrc.</para> 13 attention to while working on pkgsrc.</para>
14 14
15 <sect2 id="pulling-vars-from-etc-mk.conf"> 15 <sect2 id="pulling-vars-from-etc-mk.conf">
16 <title>How to pull in user-settable variables from &mk.conf;</title> 16 <title>How to pull in user-settable variables from &mk.conf;</title>
17 17
18 <para>The pkgsrc user can configure pkgsrc by overriding several 18 <para>The pkgsrc user can configure pkgsrc by overriding several
19 variables in the file pointed to by <varname>MAKECONF</varname>, 19 variables in the file pointed to by <varname>MAKECONF</varname>,
20 which is &mk.conf; by default. When you 20 which is &mk.conf; by default. When you
21 want to use those variables in the preprocessor directives of 21 want to use those variables in the preprocessor directives of
22 &man.make.1; (for example <literal>.if</literal> or 22 &man.make.1; (for example <literal>.if</literal> or
23 <literal>.for</literal>), you need to include the file 23 <literal>.for</literal>), you need to include the file
24 <filename>../../mk/bsd.prefs.mk</filename> before, which in turn 24 <filename>../../mk/bsd.prefs.mk</filename> before, which in turn
25 loads the user preferences.</para> 25 loads the user preferences.</para>
26 26
27 <para>But note that some variables may not be completely defined 27 <para>But note that some variables may not be completely defined
28 after <filename>../../mk/bsd.prefs.mk</filename> has been 28 after <filename>../../mk/bsd.prefs.mk</filename> has been
29 included, as they may contain references to variables that are 29 included, as they may contain references to variables that are
30 not yet defined. In shell commands (the lines in 30 not yet defined. In shell commands (the lines in
31 <filename>Makefile</filename> that are indented with a tab) this 31 <filename>Makefile</filename> that are indented with a tab) this
32 is no problem, since variables are only expanded when they are 32 is no problem, since variables are only expanded when they are
33 used. But in the preprocessor directives mentioned above and in 33 used. But in the preprocessor directives mentioned above and in
34 dependency lines (of the form <literal>target: 34 dependency lines (of the form <literal>target:
35 dependencies</literal>) the variables are expanded at load 35 dependencies</literal>) the variables are expanded at load
36 time.</para> 36 time.</para>
37 37
38 <note><para>To check whether a variable can be used at load time, 38 <note><para>To check whether a variable can be used at load time,
39 run <command>pkglint -Wall</command> on your package.</para></note> 39 run <command>pkglint -Wall</command> on your package.</para></note>
40 40
41 </sect2> 41 </sect2>
42 42
43 <sect2 id="user-interaction"> 43 <sect2 id="user-interaction">
44 <title>User interaction</title> 44 <title>User interaction</title>
45 45
46 <para>Occasionally, packages require interaction from the user, 46 <para>Occasionally, packages require interaction from the user,
47 and this can be in a number of ways:</para> 47 and this can be in a number of ways:</para>
48 48
49 <itemizedlist> 49 <itemizedlist>
50 50
51 <listitem> 51 <listitem>
52 <para>When fetching the distfiles, some packages require user 52 <para>When fetching the distfiles, some packages require user
53 interaction such as entering username/password or accepting a 53 interaction such as entering username/password or accepting a
54 license on a web page.</para> 54 license on a web page.</para>
55 </listitem> 55 </listitem>
56 56
57 <listitem> 57 <listitem>
58 <para>When extracting the distfiles, some packages may ask for 58 <para>When extracting the distfiles, some packages may ask for
59 passwords.</para> 59 passwords.</para>
60 </listitem> 60 </listitem>
61 61
62 <listitem> 62 <listitem>
63 <para>help to configure the package before it is built</para> 63 <para>help to configure the package before it is built</para>
64 </listitem> 64 </listitem>
65 65
66 <listitem> 66 <listitem>
67 <para>help during the build process</para> 67 <para>help during the build process</para>
68 </listitem> 68 </listitem>
69 69
70 <listitem> 70 <listitem>
71 <para>help during the installation of a package</para> 71 <para>help during the installation of a package</para>
72 </listitem> 72 </listitem>
73 </itemizedlist> 73 </itemizedlist>
74 74
75 <para>A package can set the <varname>INTERACTIVE_STAGE</varname> 75 <para>A package can set the <varname>INTERACTIVE_STAGE</varname>
76 variable to define which stages need interaction. This should be 76 variable to define which stages need interaction. This should be
77 done in the package's <filename>Makefile</filename>, e.g.:</para> 77 done in the package's <filename>Makefile</filename>, e.g.:</para>
78 78
79<programlisting> 79<programlisting>
80INTERACTIVE_STAGE= configure install 80INTERACTIVE_STAGE= configure install
81</programlisting> 81</programlisting>
82 82
83 <para>The user can then decide to skip this package by setting the 83 <para>The user can then decide to skip this package by setting the
84 <varname>BATCH</varname> variable. Packages that require interaction 84 <varname>BATCH</varname> variable. Packages that require interaction
85 are also excluded from bulk builds.</para> 85 are also excluded from bulk builds.</para>
86 </sect2> 86 </sect2>
87 87
88 <sect2 id="handling-licenses"> 88 <sect2 id="handling-licenses">
89 <title>Handling licenses</title> 89 <title>Handling licenses</title>
90 90
91 <para>Authors of software can choose the licence under which software 91 <para>Authors of software can choose the licence under which software
92 can be copied. The Free Software Foundation has declared some 92 can be copied. The Free Software Foundation has declared some
93 licenses "Free", and the Open Source Initiative has a definition of 93 licenses "Free", and the Open Source Initiative has a definition of
94 "Open Source".</para> 94 "Open Source".</para>
95 95
96 <para>By default, pkgsrc allows packages with Free or Open Source 96 <para>By default, pkgsrc allows packages with Free or Open Source
97 licenses to be built. To allow packages with other licenses to be 97 licenses to be built. To allow packages with other licenses to be
98 built as well, the pkgsrc user needs to add these licenses to the 98 built as well, the pkgsrc user needs to add these licenses to the
99 <varname>ACCEPTABLE_LICENSES</varname> variable in &mk.conf;. Note 99 <varname>ACCEPTABLE_LICENSES</varname> variable in &mk.conf;. Note
100 that this variable only affects which packages may be 100 that this variable only affects which packages may be
101 <emphasis>built</emphasis>, while the license terms often also 101 <emphasis>built</emphasis>, while the license terms often also
102 restrict the actual use of the package and its redistribution.</para> 102 restrict the actual use of the package and its redistribution.</para>
103 103
104 <para>One might want to only install packages with a BSD license, 104 <para>One might want to only install packages with a BSD license,
105 or the GPL, and not the other. The free licenses are added to the 105 or the GPL, and not the other. The free licenses are added to the
106 default <varname>ACCEPTABLE_LICENSES</varname> variable. The pkgsrc 106 default <varname>ACCEPTABLE_LICENSES</varname> variable. The pkgsrc
107 user can override the default by setting the 107 user can override the default by setting the
108 <varname>ACCEPTABLE_LICENSES</varname> variable with "=" instead 108 <varname>ACCEPTABLE_LICENSES</varname> variable with "=" instead
109 of "+=". The licenses accepted by default are defined in the 109 of "+=". The licenses accepted by default are defined in the
110 <varname>DEFAULT_ACCEPTABLE_LICENSES</varname> variable in the file 110 <varname>DEFAULT_ACCEPTABLE_LICENSES</varname> variable in the file
111 <filename>pkgsrc/mk/license.mk</filename>.</para> 111 <filename>pkgsrc/mk/license.mk</filename>.</para>
112 112
113 <para>The license tag mechanism is intended to address 113 <para>The license tag mechanism is intended to address
114 copyright-related issues surrounding building, installing and 114 copyright-related issues surrounding building, installing and
115 using a package, and not to address redistribution issues (see 115 using a package, and not to address redistribution issues (see
116 <varname>RESTRICTED</varname> and 116 <varname>RESTRICTED</varname> and
117 <varname>NO_SRC_ON_FTP</varname>, etc.). 117 <varname>NO_SRC_ON_FTP</varname>, etc.).
118 Packages with redistribution restrictions should set these 118 Packages with redistribution restrictions should set these
119 tags.</para> 119 tags.</para>
120 120
121 <para>Denoting that a package may be copied according to a 121 <para>Denoting that a package may be copied according to a
122 particular license is done by placing the license in 122 particular license is done by placing the license in
123 <filename>pkgsrc/licenses</filename> and setting the 123 <filename>pkgsrc/licenses</filename> and setting the
124 <varname>LICENSE</varname> variable to a string identifying the 124 <varname>LICENSE</varname> variable to a string identifying the
125 license, e.g. in <filename 125 license, e.g. in <filename
126 role="pkg">graphics/xv</filename>:</para> 126 role="pkg">graphics/xv</filename>:</para>
127 127
128<programlisting> 128<programlisting>
129LICENSE= xv-license 129LICENSE= xv-license
130</programlisting> 130</programlisting>
131 131
132 <para>When trying to build, the user will get a notice that the 132 <para>When trying to build, the user will get a notice that the
133 package is covered by a license which has not been placed in the 133 package is covered by a license which has not been placed in the
134 <varname>ACCEPTABLE_LICENSES</varname> variable:</para> 134 <varname>ACCEPTABLE_LICENSES</varname> variable:</para>
135 135
136<programlisting> 136<programlisting>
137&cprompt; <userinput>make</userinput> 137&cprompt; <userinput>make</userinput>
138===> xv-3.10anb9 has an unacceptable license: xv-license. 138===> xv-3.10anb9 has an unacceptable license: xv-license.
139===> To view the license, enter "/usr/bin/make show-license". 139===> To view the license, enter "/usr/bin/make show-license".
140===> To indicate acceptance, add this line to your /etc/mk.conf: 140===> To indicate acceptance, add this line to your /etc/mk.conf:
141===> ACCEPTABLE_LICENSES+=xv-license 141===> ACCEPTABLE_LICENSES+=xv-license
142*** Error code 1 142*** Error code 1
143</programlisting> 143</programlisting>
144 144
145 <para>The license can be viewed with <command>make 145 <para>The license can be viewed with <command>make
146 show-license</command>, and if the user so chooses, the line 146 show-license</command>, and if the user so chooses, the line
147 printed above can be added to &mk.conf; to 147 printed above can be added to &mk.conf; to
148 convey to pkgsrc that it should not in the future fail because of 148 convey to pkgsrc that it should not in the future fail because of
149 that license:</para> 149 that license:</para>
150 150
151<programlisting> 151<programlisting>
152ACCEPTABLE_LICENSES+=xv-license 152ACCEPTABLE_LICENSES+=xv-license
153</programlisting> 153</programlisting>
154 154
155 <para>The use of <varname>LICENSE=shareware</varname>, 155 <para>The use of <varname>LICENSE=shareware</varname>,
156 <varname>LICENSE=no-commercial-use</varname>, and similar language 156 <varname>LICENSE=no-commercial-use</varname>, and similar language
157 is deprecated because it does not crisply refer to a particular 157 is deprecated because it does not crisply refer to a particular
158 license text. Another problem with such usage is that it does not 158 license text. Another problem with such usage is that it does not
159 enable a user to tell pkgsrc to proceed for a single package 159 enable a user to tell pkgsrc to proceed for a single package
160 without also telling pkgsrc to proceed for all packages with that 160 without also telling pkgsrc to proceed for all packages with that
161 tag.</para> 161 tag.</para>
162 162
163 <sect3 id="new-license"> 163 <sect3 id="new-license">
164 <title>Adding a package with a new license</title> 164 <title>Adding a package with a new license</title>
165 165
166 <para>When adding a package with a new license, the following steps 166 <para>When adding a package with a new license, the following steps
167 are required:</para> 167 are required:</para>
168 <orderedlist> 168 <orderedlist>
169 169
170 <listitem> 170 <listitem>
171 171
172 <para>Check whether the license qualifies as Free or Open Source by 172 <para>Check whether the license qualifies as Free or Open Source by
173 referencing <ulink 173 referencing <ulink
174 url="https://www.gnu.org/licenses/license-list.en.html">Various 174 url="https://www.gnu.org/licenses/license-list.en.html">Various
175 Licenses and Comments about Them</ulink> and <ulink 175 Licenses and Comments about Them</ulink> and <ulink
176 url="https://opensource.org/licenses/alphabetical">Licenses by Name | 176 url="https://opensource.org/licenses/alphabetical">Licenses by Name |
177 Open Source Initiative</ulink>. If this is the case, the filename in 177 Open Source Initiative</ulink>. If this is the case, the filename in
178 <filename>pkgsrc/licenses/</filename> does not need the 178 <filename>pkgsrc/licenses/</filename> does not need the
179 <filename>-license</filename> suffix, and the license name should be 179 <filename>-license</filename> suffix, and the license name should be
180 added to:</para> 180 added to:</para>
181 181
182 <itemizedlist> 182 <itemizedlist>
183 183
184 <listitem><para>DEFAULT_ACCEPTABLE_LICENSES in 184 <listitem><para>DEFAULT_ACCEPTABLE_LICENSES in
185 <filename>pkgsrc/mk/license.mk</filename></para></listitem> 185 <filename>pkgsrc/mk/license.mk</filename></para></listitem>
186 186
187 <listitem><para>default_acceptable_licenses in 187 <listitem><para>default_acceptable_licenses in
188 <filename>pkgsrc/pkgtools/pkg_install/files/lib/license.c</filename></para></listitem> 188 <filename>pkgsrc/pkgtools/pkg_install/files/lib/license.c</filename></para></listitem>
189 189
190 </itemizedlist> 190 </itemizedlist>
191 </listitem> 191 </listitem>
192 192
193 <listitem><para>The license text should be added to 193 <listitem><para>The license text should be added to
194 <filename>pkgsrc/licenses</filename> for displaying. A list of known 194 <filename>pkgsrc/licenses</filename> for displaying. A list of known
195 licenses can be seen in this directory.</para></listitem> 195 licenses can be seen in this directory.</para></listitem>
196 196
197 </orderedlist> 197 </orderedlist>
198 </sect3> 198 </sect3>
199 199
200 <sect3 id="change-license"> 200 <sect3 id="change-license">
201 <title>Change to the license</title> 201 <title>Change to the license</title>
202 202
203 <para>When the license changes (in a way other than formatting), 203 <para>When the license changes (in a way other than formatting),
204 make sure that the new license has a different name (e.g., 204 make sure that the new license has a different name (e.g.,
205 append the version number if it exists, or the date). Just 205 append the version number if it exists, or the date). Just
206 because a user told pkgsrc to build programs under a previous 206 because a user told pkgsrc to build programs under a previous
207 version of a license does not mean that pkgsrc should build 207 version of a license does not mean that pkgsrc should build
208 programs under the new licenses. The higher-level point is that 208 programs under the new licenses. The higher-level point is that
209 pkgsrc does not evaluate licenses for reasonableness; the only 209 pkgsrc does not evaluate licenses for reasonableness; the only
210 test is a mechanistic test of whether a particular text has been 210 test is a mechanistic test of whether a particular text has been
211 approved by either of two bodies (FSF or OSI).</para> 211 approved by either of two bodies (FSF or OSI).</para>
212 </sect3> 212 </sect3>
213 </sect2> 213 </sect2>
214 214
215 <sect2 id="restricted-packages"> 215 <sect2 id="restricted-packages">
216 <title>Restricted packages</title> 216 <title>Restricted packages</title>
217 217
218 <para>Some licenses restrict how software may be re-distributed. 218 <para>Some licenses restrict how software may be re-distributed.
219 By declaring the restrictions, package tools can 219 By declaring the restrictions, package tools can
220 automatically refrain from e.g. placing binary packages on FTP 220 automatically refrain from e.g. placing binary packages on FTP
221 sites.</para> 221 sites.</para>
222 222
223 <para>There are four possible restrictions, which are 223 <para>There are four possible restrictions, which are
224 the cross product of sources (distfiles) and binaries not being 224 the cross product of sources (distfiles) and binaries not being
225 placed on FTP sites and CD-ROMs. Because this is rarely the exact 225 placed on FTP sites and CD-ROMs. Because this is rarely the exact
226 language in any license, and because non-Free licenses tend to be 226 language in any license, and because non-Free licenses tend to be
227 different from each other, pkgsrc adopts a definition of FTP and 227 different from each other, pkgsrc adopts a definition of FTP and
228 CD-ROM. 228 CD-ROM.
229 229
230 "FTP" means making the source or binary file available over the 230 "FTP" means making the source or binary file available over the
231 Internet at no charge. 231 Internet at no charge.
232 232
233 "CD-ROM" means making the source or binary available on some kind of 233 "CD-ROM" means making the source or binary available on some kind of
234 media, together with other source and binary packages, which is sold 234 media, together with other source and binary packages, which is sold
235 for a distribution charge. 235 for a distribution charge.
236 </para> 236 </para>
237 237
238 <para>In order to encode these restrictions, the package system 238 <para>In order to encode these restrictions, the package system
239 defines five make variables that can be set to note these 239 defines five make variables that can be set to note these
240 restrictions:</para> 240 restrictions:</para>
241 241
242 <itemizedlist> 242 <itemizedlist>
243 <listitem> 243 <listitem>
244 <para><varname>RESTRICTED</varname></para> 244 <para><varname>RESTRICTED</varname></para>
245 245
246 <para>This variable should be set whenever a restriction 246 <para>This variable should be set whenever a restriction
247 exists (regardless of its kind). Set this variable to a 247 exists (regardless of its kind). Set this variable to a
248 string containing the reason for the restriction. It should 248 string containing the reason for the restriction. It should
249 be understood that those wanting to understand the restriction 249 be understood that those wanting to understand the restriction
250 will have to read the license, and perhaps seek advice of 250 will have to read the license, and perhaps seek advice of
251 counsel.</para> 251 counsel.</para>
252 </listitem> 252 </listitem>
253 253
254 <listitem> 254 <listitem>
255 <para><varname>NO_BIN_ON_CDROM</varname></para> 255 <para><varname>NO_BIN_ON_CDROM</varname></para>
256 256
257 <para>Binaries may not be placed on CD-ROM containing other 257 <para>Binaries may not be placed on CD-ROM containing other
258 binary packages, for which a distribution charge may be made. 258 binary packages, for which a distribution charge may be made.
259 In this case, set this variable to 259 In this case, set this variable to
260 <varname>${RESTRICTED}</varname>.</para> 260 <varname>${RESTRICTED}</varname>.</para>
261 </listitem> 261 </listitem>
262 262
263 <listitem> 263 <listitem>
264 <para><varname>NO_BIN_ON_FTP</varname></para> 264 <para><varname>NO_BIN_ON_FTP</varname></para>
265 265
266 <para>Binaries may not made available on the Internet without 266 <para>Binaries may not made available on the Internet without
267 charge. In this case, set this variable to 267 charge. In this case, set this variable to
268 <varname>${RESTRICTED}</varname>. If this variable is set, 268 <varname>${RESTRICTED}</varname>. If this variable is set,
269 binary packages will not be included on ftp.NetBSD.org.</para> 269 binary packages will not be included on ftp.NetBSD.org.</para>
270 </listitem> 270 </listitem>
271 271
272 <listitem> 272 <listitem>
273 <para><varname>NO_SRC_ON_CDROM</varname></para> 273 <para><varname>NO_SRC_ON_CDROM</varname></para>
274 274
275 <para>Distfiles may not be placed on CD-ROM, together with 275 <para>Distfiles may not be placed on CD-ROM, together with
276 other distfiles, for which a fee may be charged. In this 276 other distfiles, for which a fee may be charged. In this
277 case, set this variable to <varname>${RESTRICTED}</varname>. 277 case, set this variable to <varname>${RESTRICTED}</varname>.
278 </para> 278 </para>
279 </listitem> 279 </listitem>
280 280
281 <listitem> 281 <listitem>
282 <para><varname>NO_SRC_ON_FTP</varname></para> 282 <para><varname>NO_SRC_ON_FTP</varname></para>
283 283
284 <para>Distfiles may not made available via FTP at no charge. 284 <para>Distfiles may not made available via FTP at no charge.
285 In this case, set this variable to 285 In this case, set this variable to
286 <varname>${RESTRICTED}</varname>. If this variable is set, 286 <varname>${RESTRICTED}</varname>. If this variable is set,
287 the distfile(s) will not be mirrored on ftp.NetBSD.org.</para> 287 the distfile(s) will not be mirrored on ftp.NetBSD.org.</para>
288 </listitem> 288 </listitem>
289 </itemizedlist> 289 </itemizedlist>
290 290
291 <para>Please note that packages will be removed from pkgsrc when the 291 <para>Please note that packages will be removed from pkgsrc when the
292 distfiles are not distributable and cannot be obtained for a period 292 distfiles are not distributable and cannot be obtained for a period
293 of one full quarter branch. Packages with manual/interactive fetch 293 of one full quarter branch. Packages with manual/interactive fetch
294 must have a maintainer and it is his/her responsibility to ensure 294 must have a maintainer and it is his/her responsibility to ensure
295 this.</para> 295 this.</para>
296 </sect2> 296 </sect2>
297 297
298 298
299 <sect2 id="dependencies"> 299 <sect2 id="dependencies">
300 <title>Handling dependencies</title> 300 <title>Handling dependencies</title>
301 301
302 <para>Your package may depend on some other package being present, 302 <para>Your package may depend on some other package being present,
303 and there are various ways of expressing this dependency. 303 and there are various ways of expressing this dependency.
304 pkgsrc supports the <varname>DEPENDS</varname>, 304 pkgsrc supports the <varname>DEPENDS</varname>,
305 <varname>BUILD_DEPENDS</varname>, 305 <varname>BUILD_DEPENDS</varname>,
306 <varname>TOOL_DEPENDS</varname>, and 306 <varname>TOOL_DEPENDS</varname>, and
307 <varname>TEST_DEPENDS</varname> definitions, the 307 <varname>TEST_DEPENDS</varname> definitions, the
308 <varname>USE_TOOLS</varname> definition, as well as dependencies 308 <varname>USE_TOOLS</varname> definition, as well as dependencies
309 via <filename>buildlink3.mk</filename>, which is the preferred way 309 via <filename>buildlink3.mk</filename>, which is the preferred way
310 to handle dependencies, and which uses the variables named above. 310 to handle dependencies, and which uses the variables named above.
311 See <xref linkend="buildlink"/> for more information.</para> 311 See <xref linkend="buildlink"/> for more information.</para>
312 312
313 <para>The basic difference is that the <varname>DEPENDS</varname> 313 <para>The basic difference is that the <varname>DEPENDS</varname>
314 definition registers that pre-requisite in the binary package so it 314 definition registers that pre-requisite in the binary package so it
315 will be pulled in when the binary package is later installed, whilst 315 will be pulled in when the binary package is later installed, whilst
316 the <varname>BUILD_DEPENDS</varname>, <varname>TOOL_DEPENDS</varname>, 316 the <varname>BUILD_DEPENDS</varname>, <varname>TOOL_DEPENDS</varname>,
317 and <varname>TEST_DEPENDS</varname> definitions do not, marking a 317 and <varname>TEST_DEPENDS</varname> definitions do not, marking a
318 dependency that is only needed for building or testing the resulting 318 dependency that is only needed for building or testing the resulting
319 package. See also <xref linkend="creating"/> for more information.</para> 319 package. See also <xref linkend="creating"/> for more information.</para>
320 320
321 <para>This means that if you only need a package present whilst 321 <para>This means that if you only need a package present whilst
322 you are building or testing, it should be noted as a 322 you are building or testing, it should be noted as a
323 <varname>TOOL_DEPENDS</varname>, 323 <varname>TOOL_DEPENDS</varname>,
324 <varname>BUILD_DEPENDS</varname>, or 324 <varname>BUILD_DEPENDS</varname>, or
325 <varname>TEST_DEPENDS</varname>. When cross-compiling, 325 <varname>TEST_DEPENDS</varname>. When cross-compiling,
326 <varname>TOOL_DEPENDS</varname> are <emphasis>native</emphasis> 326 <varname>TOOL_DEPENDS</varname> are <emphasis>native</emphasis>
327 packages, i.e. packages for the architecture where the package 327 packages, i.e. packages for the architecture where the package
328 is built; 328 is built;
329 <varname>BUILD_DEPENDS</varname> are <emphasis>target</emphasis> 329 <varname>BUILD_DEPENDS</varname> are <emphasis>target</emphasis>
330 packages, i.e., packages for the architecture for which the package 330 packages, i.e., packages for the architecture for which the package
331 is built.</para> 331 is built.</para>
332 332
333 <para>The format for a <varname>DEPENDS</varname>, 333 <para>The format for a <varname>DEPENDS</varname>,
334 <varname>BUILD_DEPENDS</varname>, <varname>TOOL_DEPENDS</varname>, 334 <varname>BUILD_DEPENDS</varname>, <varname>TOOL_DEPENDS</varname>,
335 and <varname>TEST_DEPENDS</varname> definition is:</para> 335 and <varname>TEST_DEPENDS</varname> definition is:</para>
336 336
337<programlisting> 337<programlisting>
338&lt;pre-req-package-name&gt;:../../&lt;category&gt;/&lt;pre-req-package&gt; 338&lt;pre-req-package-name&gt;:../../&lt;category&gt;/&lt;pre-req-package&gt;
339</programlisting> 339</programlisting>
340 340
341 <para>Please note that the <quote>pre-req-package-name</quote> 341 <para>Please note that the <quote>pre-req-package-name</quote>
342 may include any of the wildcard version numbers recognized by 342 may include any of the wildcard version numbers recognized by
343 &man.pkg.info.1;.</para> 343 &man.pkg.info.1;.</para>
344 344
345 <orderedlist> 345 <orderedlist>
346 <listitem> 346 <listitem>
347 <para>If your package needs another package's binaries or 347 <para>If your package needs another package's binaries or
348 libraries to build and run, and if that package has a 348 libraries to build and run, and if that package has a
349 <filename>buildlink3.mk</filename> file available, use it:</para> 349 <filename>buildlink3.mk</filename> file available, use it:</para>
350 350
351<programlisting> 351<programlisting>
352.include "../../graphics/jpeg/buildlink3.mk" 352.include "../../graphics/jpeg/buildlink3.mk"
353</programlisting> 353</programlisting>
354 </listitem> 354 </listitem>
355 355
356 <listitem> 356 <listitem>
357 <para>If your package needs another package's binaries or 357 <para>If your package needs another package's binaries or
358 libraries only for building, and if that package has a 358 libraries only for building, and if that package has a
359 <filename>buildlink3.mk</filename> file available, use it:</para> 359 <filename>buildlink3.mk</filename> file available, use it:</para>
360 360
361<programlisting> 361<programlisting>
362.include "../../graphics/jpeg/buildlink3.mk" 362.include "../../graphics/jpeg/buildlink3.mk"
363</programlisting> 363</programlisting>
364 <para>but set 364 <para>but set
365 <varname>BUILDLINK_DEPMETHOD.<replaceable>jpeg</replaceable>?=build</varname> 365 <varname>BUILDLINK_DEPMETHOD.<replaceable>jpeg</replaceable>?=build</varname>
366 to make it a build dependency only. This case is rather 366 to make it a build dependency only. This case is rather
367 rare.</para> 367 rare.</para>
368 </listitem> 368 </listitem>
369 369
370 <listitem> 370 <listitem>
371 <para>If your package needs binaries from another package to build, 371 <para>If your package needs binaries from another package to build,
372 use the <varname>TOOL_DEPENDS</varname> definition:</para> 372 use the <varname>TOOL_DEPENDS</varname> definition:</para>
373 373
374<programlisting> 374<programlisting>
375TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool 375TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
376</programlisting> 376</programlisting>
377 </listitem> 377 </listitem>
378 378
379 <listitem> 379 <listitem>
380 <para>If your package needs static libraries to link against, header 380 <para>If your package needs static libraries to link against, header
381 files to include, etc. from another package to build, 381 files to include, etc. from another package to build,
382 use the <varname>BUILD_DEPENDS</varname> definition.</para> 382 use the <varname>BUILD_DEPENDS</varname> definition.</para>
383 383
384<!-- 384<!--
385<programlisting> 385<programlisting>
386BUILD_DEPENDS+= TODO: find a good example 386BUILD_DEPENDS+= TODO: find a good example
387</programlisting> --> 387</programlisting> -->
388 </listitem> 388 </listitem>
389 389
390 <listitem> 390 <listitem>
391 <para>If your package needs a library with which to link and 391 <para>If your package needs a library with which to link and
392 there is no <filename>buildlink3.mk</filename> file 392 there is no <filename>buildlink3.mk</filename> file
393 available, create one. Using 393 available, create one. Using
394 <varname>DEPENDS</varname> won't be sufficient because the 394 <varname>DEPENDS</varname> won't be sufficient because the
395 include files and libraries will be hidden from the compiler.</para> 395 include files and libraries will be hidden from the compiler.</para>
396 </listitem> 396 </listitem>
397 397
398 <listitem> 398 <listitem>
399 <para>If your package needs some executable to be able to run 399 <para>If your package needs some executable to be able to run
400 correctly and if there's no 400 correctly and if there's no
401 <filename>buildlink3.mk</filename> file, this is specified 401 <filename>buildlink3.mk</filename> file, this is specified
402 using the <varname>DEPENDS</varname> variable. The 402 using the <varname>DEPENDS</varname> variable. The
403 <filename role="pkg">print/lyx</filename> package needs to 403 <filename role="pkg">print/lyx</filename> package needs to
404 be able to execute the latex binary from the tex-latex-bin package 404 be able to execute the latex binary from the tex-latex-bin package
405 when it runs, and that is specified:</para> 405 when it runs, and that is specified:</para>
406 406
407<programlisting> 407<programlisting>
408DEPENDS+= tex-latex-bin-[0-9]*:../../print/tex-latex-bin 408DEPENDS+= tex-latex-bin-[0-9]*:../../print/tex-latex-bin
409</programlisting> 409</programlisting>
410 </listitem> 410 </listitem>
411 <listitem> 411 <listitem>
412 <para>If your package includes a test suite that has extra 412 <para>If your package includes a test suite that has extra
413 dependencies only required for this purpose (frequently this 413 dependencies only required for this purpose (frequently this
414 can be run as a <quote>make test</quote> target), use the 414 can be run as a <quote>make test</quote> target), use the
415 <varname>TEST_DEPENDS</varname> variable.</para> 415 <varname>TEST_DEPENDS</varname> variable.</para>
416 </listitem> 416 </listitem>
417 <listitem> 417 <listitem>
418 <para>You can use wildcards in package dependencies. Note that 418 <para>You can use wildcards in package dependencies. Note that
419 such wildcard dependencies are retained when creating binary 419 such wildcard dependencies are retained when creating binary
420 packages. The dependency is checked when installing the binary 420 packages. The dependency is checked when installing the binary
421 package and any package which matches the pattern will be 421 package and any package which matches the pattern will be
422 used. Wildcard dependencies should be used with care.</para> 422 used. Wildcard dependencies should be used with care.</para>
423 423
424 <para>The <quote>-[0-9]*</quote> should be used instead of 424 <para>The <quote>-[0-9]*</quote> should be used instead of
425 <quote>-*</quote> to avoid potentially ambiguous matches 425 <quote>-*</quote> to avoid potentially ambiguous matches
426 such as <quote>tk-postgresql</quote> matching a 426 such as <quote>tk-postgresql</quote> matching a
427 <quote>tk-*</quote> <varname>DEPENDS</varname>.</para> 427 <quote>tk-*</quote> <varname>DEPENDS</varname>.</para>
428 428
429 <para>Wildcards can also be used to specify that a package 429 <para>Wildcards can also be used to specify that a package
430 will only build against a certain minimum version of a 430 will only build against a certain minimum version of a
431 pre-requisite:</para> 431 pre-requisite:</para>
432 432
433<programlisting> 433<programlisting>
434DEPENDS+= ImageMagick>=6.0:../../graphics/ImageMagick 434DEPENDS+= ImageMagick>=6.0:../../graphics/ImageMagick
435</programlisting> 435</programlisting>
436 436
437 <para>This means that the package will build using version 6.0 437 <para>This means that the package will build using version 6.0
438 of ImageMagick or newer. Such a dependency may be warranted 438 of ImageMagick or newer. Such a dependency may be warranted
439 if, for example, the command line options of an executable 439 if, for example, the command line options of an executable
440 have changed.</para> 440 have changed.</para>
441 441
442 <para>If you need to depend on minimum versions of libraries, 442 <para>If you need to depend on minimum versions of libraries,
443 set 443 set
444 <varname>BUILDLINK_API_DEPENDS.<replaceable>pkg</replaceable></varname> 444 <varname>BUILDLINK_API_DEPENDS.<replaceable>pkg</replaceable></varname>
445 to the appropriate pattern before including its 445 to the appropriate pattern before including its
446 <filename>buildlink3.mk</filename> file, e.g.</para> 446 <filename>buildlink3.mk</filename> file, e.g.</para>
447 447
448<programlisting> 448<programlisting>
449BUILDLINK_API_DEPENDS.jpeg+= jpeg>=9.0 449BUILDLINK_API_DEPENDS.jpeg+= jpeg>=9.0
450.include "../../graphics/jpeg/buildlink3.mk" 450.include "../../graphics/jpeg/buildlink3.mk"
451</programlisting> 451</programlisting>
452 452
453 <para>For security fixes, please update the package 453 <para>For security fixes, please update the package
454 vulnerabilities file. See <xref 454 vulnerabilities file. See <xref
455 linkend="security-handling"/> for more 455 linkend="security-handling"/> for more
456 information.</para> 456 information.</para>
457 </listitem> 457 </listitem>
458 </orderedlist> 458 </orderedlist>
459 459
460 <para>If your package needs files from another package to build, 460 <para>If your package needs files from another package to build,
461 add the relevant distribution files to 461 add the relevant distribution files to
462 <varname>DISTFILES</varname>, so they will be extracted 462 <varname>DISTFILES</varname>, so they will be extracted
463 automatically. See the <filename 463 automatically. See the <filename
464 role="pkg">print/ghostscript</filename> package for an example. 464 role="pkg">print/ghostscript</filename> package for an example.
465 (It relies on the jpeg sources being present in source form 465 (It relies on the jpeg sources being present in source form
466 during the build.)</para> 466 during the build.)</para>
467 </sect2> 467 </sect2>
468 468
469 469
470 <sect2 id="conflicts"> 470 <sect2 id="conflicts">
471 <title>Handling conflicts with other packages</title> 471 <title>Handling conflicts with other packages</title>
472 472
473 <para>Your package may conflict with other packages users might 473 <para>Your package may conflict with other packages users might
474 already have installed on their system, e.g., if your package 474 already have installed on their system, e.g., if your package
475 installs the same set of files as another package in the pkgsrc 475 installs the same set of files as another package in the pkgsrc
476 tree.</para> 476 tree.</para>
477 477
478 <para>For example, <filename role="pkg">x11/libXaw3d</filename> 478 <para>For example, <filename role="pkg">x11/libXaw3d</filename>
479 and <filename role="pkg">x11/Xaw-Xpm</filename> 479 and <filename role="pkg">x11/Xaw-Xpm</filename>
480 install the same shared library, thus you set in 480 install the same shared library, thus you set in
481 <filename>pkgsrc/x11/libXaw3d/Makefile</filename>:</para> 481 <filename>pkgsrc/x11/libXaw3d/Makefile</filename>:</para>
482 482
483<programlisting> 483<programlisting>
484CONFLICTS= Xaw-Xpm-[0-9]* 484CONFLICTS= Xaw-Xpm-[0-9]*
485</programlisting> 485</programlisting>
486 486
487 <para>and in <filename>pkgsrc/x11/Xaw-Xpm/Makefile</filename>:</para> 487 <para>and in <filename>pkgsrc/x11/Xaw-Xpm/Makefile</filename>:</para>
488 488
489<programlisting> 489<programlisting>
490CONFLICTS= libXaw3d-[0-9]* 490CONFLICTS= libXaw3d-[0-9]*
491</programlisting> 491</programlisting>
492 492
493 <para>&man.pkg.add.1 is able to detect attempts to install packages 493 <para>&man.pkg.add.1 is able to detect attempts to install packages
494 that conflict with existing packages and abort. However, in many 494 that conflict with existing packages and abort. However, in many
495 situations this is too late in the process. Binary package managers 495 situations this is too late in the process. Binary package managers
496 will not know about the conflict until they attempt to install the 496 will not know about the conflict until they attempt to install the
497 package after already downloading it and all its dependencies. 497 package after already downloading it and all its dependencies.
498 Users may also waste time building a package and its dependencies 498 Users may also waste time building a package and its dependencies
499 only to find out at the end that it conflicts with another package 499 only to find out at the end that it conflicts with another package
500 they have installed.</para> 500 they have installed.</para>
501 501
502 <para>To avoid these issues <varname>CONFLICTS</varname> entries 502 <para>To avoid these issues <varname>CONFLICTS</varname> entries
503 should be added in all cases where it is known that packages conflict 503 should be added in all cases where it is known that packages conflict
504 with each other. These <varname>CONFLICTS</varname> entries are 504 with each other. These <varname>CONFLICTS</varname> entries are
505 exported in &man.pkg.summary.5 files and consumed by binary package 505 exported in &man.pkg.summary.5 files and consumed by binary package
506 managers to inform users that packages cannot be installed onto 506 managers to inform users that packages cannot be installed onto
507 the target system.</para> 507 the target system.</para>
508 </sect2> 508 </sect2>
509 509
510 510
511 <sect2 id="not-building-packages"> 511 <sect2 id="not-building-packages">
512 <title>Packages that cannot or should not be built</title> 512 <title>Packages that cannot or should not be built</title>
513 513
514 <para>There are several reasons why a package might be 514 <para>There are several reasons why a package might be
515 instructed to not build under certain circumstances. If the 515 instructed to not build under certain circumstances. If the
516 package builds and runs on most platforms, the exceptions 516 package builds and runs on most platforms, the exceptions
517 should be noted with <varname>BROKEN_ON_PLATFORM</varname>. If 517 should be noted with <varname>BROKEN_ON_PLATFORM</varname>. If
518 the package builds and runs on a small handful of platforms, 518 the package builds and runs on a small handful of platforms,
519 set <varname>BROKEN_EXCEPT_ON_PLATFORM</varname> instead. 519 set <varname>BROKEN_EXCEPT_ON_PLATFORM</varname> instead.
520 Both <varname>BROKEN_ON_PLATFORM</varname> and 520 Both <varname>BROKEN_ON_PLATFORM</varname> and
521 <varname>BROKEN_EXCEPT_ON_PLATFORM</varname> are OS triples 521 <varname>BROKEN_EXCEPT_ON_PLATFORM</varname> are OS triples
522 (OS-version-platform) that can use glob-style 522 (OS-version-platform) that can use glob-style
523 wildcards.</para> 523 wildcards.</para>
524 <para>If a package is not appropriate for some platforms (as 524 <para>If a package is not appropriate for some platforms (as
525 opposed to merely broken), a different set of variables should be 525 opposed to merely broken), a different set of variables should be
526 used as this affects failure reporting and statistics. 526 used as this affects failure reporting and statistics.
527 If the package is appropriate for most platforms, the exceptions 527 If the package is appropriate for most platforms, the exceptions
528 should be noted with <varname>NOT_FOR_PLATFORM</varname>. If 528 should be noted with <varname>NOT_FOR_PLATFORM</varname>. If
529 the package is appropriate for only a small handful of platforms 529 the package is appropriate for only a small handful of platforms
530 (often exactly one), set <varname>ONLY_FOR_PLATFORM</varname> instead. 530 (often exactly one), set <varname>ONLY_FOR_PLATFORM</varname> instead.
531 Both <varname>ONLY_FOR_PLATFORM</varname> and 531 Both <varname>ONLY_FOR_PLATFORM</varname> and
532 <varname>NOT_FOR_PLATFORM</varname> are OS triples 532 <varname>NOT_FOR_PLATFORM</varname> are OS triples
533 (OS-version-platform) that can use glob-style 533 (OS-version-platform) that can use glob-style
534 wildcards.</para> 534 wildcards.</para>
535 <para>Some packages are tightly bound to a specific version of an 535 <para>Some packages are tightly bound to a specific version of an
536 operating system, e.g. LKMs or <filename 536 operating system, e.g. LKMs or <filename
537 role="pkg">sysutils/lsof</filename>. Such binary packages are not 537 role="pkg">sysutils/lsof</filename>. Such binary packages are not
538 backwards compatible with other versions of the OS, and should be 538 backwards compatible with other versions of the OS, and should be
539 uploaded to a version specific directory on the FTP server. Mark 539 uploaded to a version specific directory on the FTP server. Mark
540 these packages by setting <varname>OSVERSION_SPECIFIC</varname> to 540 these packages by setting <varname>OSVERSION_SPECIFIC</varname> to
541 <quote>yes</quote>. This variable is not currently used by any of 541 <quote>yes</quote>. This variable is not currently used by any of
542 the package system internals, but may be used in the 542 the package system internals, but may be used in the
543 future.</para> 543 future.</para>
544 <para>If the package should be skipped (for example, because it 544 <para>If the package should be skipped (for example, because it
545 provides functionality already provided by the system), set 545 provides functionality already provided by the system), set
546 <varname>PKG_SKIP_REASON</varname> to a descriptive message. If 546 <varname>PKG_SKIP_REASON</varname> to a descriptive message. If
547 the package should fail because some preconditions are not met, 547 the package should fail because some preconditions are not met,
548 set <varname>PKG_FAIL_REASON</varname> to a descriptive 548 set <varname>PKG_FAIL_REASON</varname> to a descriptive
549 message.</para> 549 message.</para>
550 </sect2> 550 </sect2>
551 551
552 552
553 <sect2 id="undeletable-packages"> 553 <sect2 id="undeletable-packages">
554 <title>Packages which should not be deleted, once installed</title> 554 <title>Packages which should not be deleted, once installed</title>
555 555
556 <para>To ensure that a package may not be deleted, once it has been 556 <para>To ensure that a package may not be deleted, once it has been
557 installed, the <varname>PKG_PRESERVE</varname> definition should 557 installed, the <varname>PKG_PRESERVE</varname> definition should
558 be set in the package Makefile. This will be carried into any 558 be set in the package Makefile. This will be carried into any
559 binary package that is made from this pkgsrc entry. A 559 binary package that is made from this pkgsrc entry. A
560 <quote>preserved</quote> package will 560 <quote>preserved</quote> package will
561 not be deleted using &man.pkg.delete.1; unless the 561 not be deleted using &man.pkg.delete.1; unless the
562 <quote>-f</quote> option is used.</para> 562 <quote>-f</quote> option is used.</para>
563 </sect2> 563 </sect2>
564 564
565 565
566 <sect2 id="security-handling"> 566 <sect2 id="security-handling">
567 <title>Handling packages with security problems</title> 567 <title>Handling packages with security problems</title>
568 568
569 <para>When a vulnerability is found, this should be noted in 569 <para>When a vulnerability is found, this should be noted in
570 <filename>localsrc/security/advisories/pkg-vulnerabilities</filename>. 570 <filename>localsrc/security/advisories/pkg-vulnerabilities</filename>.
571 Entries in that file consist of three parts:</para> 571 Entries in that file consist of three parts:</para>
572 <itemizedlist> 572 <itemizedlist>
573 <listitem><para>package version pattern</para></listitem> 573 <listitem><para>package version pattern</para></listitem>
574 <listitem><para>type of vulnerability (please cut'n'paste an existing one where possible)</para></listitem> 574 <listitem><para>type of vulnerability (please cut'n'paste an existing one where possible)</para></listitem>
575 <listitem><para>URL providing additional information about the issue</para></listitem> 575 <listitem><para>URL providing additional information about the issue</para></listitem>
576 </itemizedlist> 576 </itemizedlist>
577 577
578 <para>For the package version pattern please always use `&lt;' to 578 <para>For the package version pattern please always use `&lt;' to
579 mark an upper bound (not `&lt;='!). This will avoid possible 579 mark an upper bound (not `&lt;='!). This will avoid possible
580 problems due unrelated <varname>PKGREVISION</varname> bumps not 580 problems due unrelated <varname>PKGREVISION</varname> bumps not
581 related to security fixes. Lower bounds can be added too, using 581 related to security fixes. Lower bounds can be added too, using
582 '&gt;' or '&gt;='. For example, 582 '&gt;' or '&gt;='. For example,
583 <quote><literal>foo&gt;=1&lt;1.2</literal></quote> would mark 583 <quote><literal>foo&gt;=1&lt;1.2</literal></quote> would mark
584 versions 1.0 (included) to 1.2 (excluded) of 584 versions 1.0 (included) to 1.2 (excluded) of
585 <quote><literal>foo</literal></quote> as affected by the security 585 <quote><literal>foo</literal></quote> as affected by the security
586 issue.</para> 586 issue.</para>
587 587
588 <para>Entries should always be added at the bottom of the file.</para> 588 <para>Entries should always be added at the bottom of the file.</para>
589 589
590 <para>When fixing packages, please modify the upper bound of the 590 <para>When fixing packages, please modify the upper bound of the
591 corresponding entry. To continue the previous example, if a fix 591 corresponding entry. To continue the previous example, if a fix
592 was backported to version 1.1nb2, change the previous pattern to 592 was backported to version 1.1nb2, change the previous pattern to
593 <quote><literal>foo&gt;=1&lt;1.1nb2</literal></quote>.</para> 593 <quote><literal>foo&gt;=1&lt;1.1nb2</literal></quote>.</para>
594 594
595 <para>To locally test a package version pattern against a 595 <para>To locally test a package version pattern against a
596 <varname>PKGNAME</varname> you can use the <command>pkg_admin 596 <varname>PKGNAME</varname> you can use the <command>pkg_admin
597 pmatch</command> command.</para> 597 pmatch</command> command.</para>
598 598
599 <para>The URL should be as permanent as possible and provide as 599 <para>The URL should be as permanent as possible and provide as
600 much information about the issue as possible. CVE entries are 600 much information about the issue as possible. CVE entries are
601 preferred.</para> 601 preferred.</para>
602 602
603 <para>After committing that file, ask pkgsrc-security@NetBSD.org to 603 <para>After committing that file, ask pkgsrc-security@NetBSD.org to
604 update the file on ftp.NetBSD.org.</para> 604 update the file on ftp.NetBSD.org.</para>
605 605
606 <para>After fixing the vulnerability by a patch, its 606 <para>After fixing the vulnerability by a patch, its
607 <varname>PKGREVISION</varname> should be increased (this is of 607 <varname>PKGREVISION</varname> should be increased (this is of
608 course not necessary if the problem is fixed by using a newer 608 course not necessary if the problem is fixed by using a newer
609 release of the software), and the pattern in the 609 release of the software), and the pattern in the
610 pkg-vulnerabilities file must be updated.</para> 610 pkg-vulnerabilities file must be updated.</para>
611 611
612 <para>Also, if the fix should be applied to the stable pkgsrc 612 <para>Also, if the fix should be applied to the stable pkgsrc
613 branch, be sure to submit a pullup request!</para> 613 branch, be sure to submit a pullup request!</para>
614 614
615 <para>Binary packages already on ftp.NetBSD.org will be handled 615 <para>Binary packages already on ftp.NetBSD.org will be handled
616 semi-automatically by a weekly cron job.</para> 616 semi-automatically by a weekly cron job.</para>
617 617
618 <para>In case a security issue is disputed, please contact 618 <para>In case a security issue is disputed, please contact
619 pkgsrc-security@NetBSD.org.</para> 619 pkgsrc-security@NetBSD.org.</para>
620 </sect2> 620 </sect2>
621 621
622 622
623 <sect2 id="bumping-pkgrevision"> 623 <sect2 id="bumping-pkgrevision">
624 <title>How to handle incrementing versions when fixing an existing package</title> 624 <title>How to handle incrementing versions when fixing an existing package</title>
625 625
626 <para>When making fixes to an existing package it can be useful 626 <para>When making fixes to an existing package it can be useful
627 to change the version number in <varname>PKGNAME</varname>. To 627 to change the version number in <varname>PKGNAME</varname>. To
628 avoid conflicting with future versions by the original author, a 628 avoid conflicting with future versions by the original author, a
629 <quote>nb1</quote>, <quote>nb2</quote>, ... suffix can be used 629 <quote>nb1</quote>, <quote>nb2</quote>, ... suffix can be used
630 on package versions by setting <varname>PKGREVISION=1</varname> 630 on package versions by setting <varname>PKGREVISION=1</varname>
631 (2, ...). The <quote>nb</quote> is treated like a 631 (2, ...). The <quote>nb</quote> is treated like a
632 <quote>.</quote> by the package tools. e.g.</para> 632 <quote>.</quote> by the package tools. e.g.</para>
633 633
634<programlisting> 634<programlisting>
635DISTNAME= foo-17.42 635DISTNAME= foo-17.42
636PKGREVISION= 9 636PKGREVISION= 9
637</programlisting> 637</programlisting>
638 638
639 <para>will result in a <varname>PKGNAME</varname> of 639 <para>will result in a <varname>PKGNAME</varname> of
640 <quote>foo-17.42nb9</quote>. If you want to use the original 640 <quote>foo-17.42nb9</quote>. If you want to use the original
641 value of <varname>PKGNAME</varname> without the <quote>nbX</quote> 641 value of <varname>PKGNAME</varname> without the <quote>nbX</quote>
642 suffix, e.g. for setting <varname>DIST_SUBDIR</varname>, use 642 suffix, e.g. for setting <varname>DIST_SUBDIR</varname>, use
643 <varname>PKGNAME_NOREV</varname>.</para> 643 <varname>PKGNAME_NOREV</varname>.</para>
644 644
645 <para>When a new release of the package is released, the 645 <para>When a new release of the package is released, the
646 <varname>PKGREVISION</varname> should be removed, e.g. on a new 646 <varname>PKGREVISION</varname> should be removed, e.g. on a new
647 minor release of the above package, things should be like:</para> 647 minor release of the above package, things should be like:</para>
648 648
649<programlisting> 649<programlisting>
650DISTNAME= foo-17.43 650DISTNAME= foo-17.43
651</programlisting> 651</programlisting>
652 652
653 <para><varname>PKGREVISION</varname> should be incremented for any 653 <para><varname>PKGREVISION</varname> should be incremented for any
654 non-trivial change in the resulting binary package. Without a 654 non-trivial change in the resulting binary package. Without a
655 <varname>PKGREVISION</varname> bump, someone with the previous 655 <varname>PKGREVISION</varname> bump, someone with the previous
656 version installed has no way of knowing that their package is out 656 version installed has no way of knowing that their package is out
657 of date. Thus, changes without increasing 657 of date. Thus, changes without increasing
658 <varname>PKGREVISION</varname> are essentially labeled "this is so 658 <varname>PKGREVISION</varname> are essentially labeled "this is so
659 trivial that no reasonable person would want to upgrade", and this 659 trivial that no reasonable person would want to upgrade", and this
660 is the rough test for when increasing 660 is the rough test for when increasing
661 <varname>PKGREVISION</varname> is appropriate. Examples of 661 <varname>PKGREVISION</varname> is appropriate. Examples of
662 changes that do not merit increasing 662 changes that do not merit increasing
663 <varname>PKGREVISION</varname> are:</para> 663 <varname>PKGREVISION</varname> are:</para>
664 664
665 <itemizedlist> 665 <itemizedlist>
666 666
667 <listitem><para>Changing <varname>HOMEPAGE</varname>, 667 <listitem><para>Changing <varname>HOMEPAGE</varname>,
668 <varname>MAINTAINER</varname>, <varname>OWNER</varname>, or 668 <varname>MAINTAINER</varname>, <varname>OWNER</varname>, or
669 comments in Makefile.</para></listitem> 669 comments in Makefile.</para></listitem>
670 670
671 <listitem><para>Changing build variables if the resulting binary 671 <listitem><para>Changing build variables if the resulting binary
672 package is the same.</para></listitem> 672 package is the same.</para></listitem>
673 673
674 <listitem><para>Changing 674 <listitem><para>Changing
675 <filename>DESCR</filename>.</para></listitem> 675 <filename>DESCR</filename>.</para></listitem>
676 676
677 <listitem><para>Adding <varname>PKG_OPTIONS</varname> if the 677 <listitem><para>Adding <varname>PKG_OPTIONS</varname> if the
678 default options don't change.</para></listitem> 678 default options don't change.</para></listitem>
679 679
680 </itemizedlist> 680 </itemizedlist>
681 681
682 <para>Examples of changes that do merit an increase to 682 <para>Examples of changes that do merit an increase to
683 <varname>PKGREVISION</varname> include:</para> 683 <varname>PKGREVISION</varname> include:</para>
684 684
685 <itemizedlist> 685 <itemizedlist>
686 686
687 <listitem><para>Security fixes</para></listitem> 687 <listitem><para>Security fixes</para></listitem>
688 688
689 <listitem><para>Changes or additions to a patch 689 <listitem><para>Changes or additions to a patch
690 file</para></listitem> 690 file</para></listitem>
691 691
692 <listitem><para>Changes to the 692 <listitem><para>Changes to the
693 <filename>PLIST</filename></para></listitem> 693 <filename>PLIST</filename></para></listitem>
694 694
695 <listitem><para>A dependency is changed or 695 <listitem><para>A dependency is changed or
696 renamed.</para></listitem> 696 renamed.</para></listitem>
697 697
698 </itemizedlist> 698 </itemizedlist>
699 699
700 <para>PKGREVISION must also be incremented when dependencies have ABI 700 <para>PKGREVISION must also be incremented when dependencies have ABI
701 changes.</para> 701 changes.</para>
702 </sect2> 702 </sect2>
703 703
704<sect2 id="fixes.subst"> 704<sect2 id="fixes.subst">
705<title>Substituting variable text in the package files (the SUBST framework)</title> 705<title>Substituting variable text in the package files (the SUBST framework)</title>
706 706
707<para>When you want to replace the same text in multiple files, or 707<para>When you want to replace the same text in multiple files, or
708multiple times in the same file, it is cumbersome to maintain a patch 708multiple times in the same file, it is cumbersome to maintain a patch
709file for this. This is where the SUBST framework steps in. It provides an 709file for this. This is where the SUBST framework steps in. It provides an
710easy-to-use interface for replacing text in files. It just needs the 710easy-to-use interface for replacing text in files. It just needs the
711following information:</para> 711following information:</para>
712 712
713<itemizedlist> 713<itemizedlist>
714 714
715<listitem><para>In which phase of the package build cycle should the 715<listitem><para>In which phase of the package build cycle should the
716replacement happen?</para></listitem> 716replacement happen?</para></listitem>
717 717
718<listitem><para>In which files should the replacement 718<listitem><para>In which files should the replacement
719happen?</para></listitem> 719happen?</para></listitem>
720 720
721<listitem><para>Which text should be replaced with 721<listitem><para>Which text should be replaced with
722what?</para></listitem> 722what?</para></listitem>
723 723
724</itemizedlist> 724</itemizedlist>
725 725
726<para>This information is encoded in a block of <varname>SUBST</varname> 726<para>This information is encoded in a block of <varname>SUBST</varname>
727variables. A minimal example is:</para> 727variables. A minimal example is:</para>
728 728
729<programlisting> 729<programlisting>
730SUBST_CLASSES+= paths 730SUBST_CLASSES+= paths
731SUBST_STAGE.paths= pre-configure 731SUBST_STAGE.paths= pre-configure
732SUBST_FILES.paths= src/*.c 732SUBST_FILES.paths= src/*.c
733SUBST_SED.paths= -e 's,/usr/local,${PREFIX},g' 733SUBST_SED.paths= -e 's,/usr/local,${PREFIX},g'
734</programlisting> 734</programlisting>
735 735
736<para>Translated into English, it means: In the pre-configure stage (that 736<para>Translated into English, it means: In the pre-configure stage (that
737is, after applying the patches from the patches/ directory and before 737is, after applying the patches from the patches/ directory and before
738running the configure script and the portability check), replace the text 738running the configure script and the portability check), replace the text
739<literal>/usr/local</literal> with the content of the variable 739<literal>/usr/local</literal> with the content of the variable
740<varname>PREFIX</varname>.</para> 740<varname>PREFIX</varname>.</para>
741 741
742<para>Each SUBST block starts by appending an identifier to 742<para>Each SUBST block starts by appending an identifier to
743<varname>SUBST_CLASSES</varname> (note the <literal>+=</literal>). This 743<varname>SUBST_CLASSES</varname> (note the <literal>+=</literal>). This
744identifier can be chosen freely by the package. If there should ever be 744identifier can be chosen freely by the package. If there should ever be
745duplicate identifiers, the pkgsrc infrastructure will catch this and fail 745duplicate identifiers, the pkgsrc infrastructure will catch this and fail
746early, so don't worry about name collisions.</para> 746early, so don't worry about name collisions.</para>
747 747
748<para>Except for <varname>SUBST_CLASSES</varname>, all variables in a 748<para>Except for <varname>SUBST_CLASSES</varname>, all variables in a
749SUBST block are parameterized using this identifier. In the remainder of 749SUBST block are parameterized using this identifier. In the remainder of
750this section, these parameterized variables are written as 750this section, these parameterized variables are written as
751<varname>SUBST_STAGE.*</varname>.</para> 751<varname>SUBST_STAGE.*</varname>.</para>
752 752
753<programlisting> 753<programlisting>
754SUBST_CLASSES+= paths 754SUBST_CLASSES+= paths
755SUBST_STAGE.paths= pre-configure 755SUBST_STAGE.paths= pre-configure
756SUBST_MESSAGE.paths= Fixing absolute paths. 756SUBST_MESSAGE.paths= Fixing absolute paths.
757SUBST_FILES.paths= src/*.c 757SUBST_FILES.paths= src/*.c
758SUBST_FILES.paths+= scripts/*.sh 758SUBST_FILES.paths+= scripts/*.sh
759SUBST_SED.paths= -e 's,"/usr/local,"${PREFIX},g' 759SUBST_SED.paths= -e 's,"/usr/local,"${PREFIX},g'
760SUBST_SED.paths+= -e 's,"/var/log,"${VARBASE}/log,g' 760SUBST_SED.paths+= -e 's,"/var/log,"${VARBASE}/log,g'
761SUBST_VARS.paths= LOCALBASE PREFIX PKGVERSION 761SUBST_VARS.paths= LOCALBASE PREFIX PKGVERSION
762</programlisting> 762</programlisting>
763 763
764<para>To get a complete picture about the SUBST substitutions, run 764<para>To get a complete picture about the SUBST substitutions, run
765<command>bmake show-all-subst</command>. If something doesn't work as 765<command>bmake show-all-subst</command>. If something doesn't work as
766expected, run pkglint on the package, which detects several typical 766expected, run pkglint on the package, which detects several typical
767mistakes surrounding the SUBST blocks. For any questions that might 767mistakes surrounding the SUBST blocks. For any questions that might
768remain after this, have a look at 768remain after this, have a look at
769<filename>mk/subst.mk</filename>.</para> 769<filename>mk/subst.mk</filename>.</para>
770 770
771<sect3 id="fixes.subst.when"> 771<sect3 id="fixes.subst.when">
772<title>Choosing the time where the substitutions happen</title> 772<title>Choosing the time where the substitutions happen</title>
773 773
774<para>The <varname>SUBST_STAGE.*</varname> is one of 774<para>The <varname>SUBST_STAGE.*</varname> is one of
775{pre,do,post}-{extract,patch,configure,build,test,install}. Of these, 775{pre,do,post}-{extract,patch,configure,build,test,install}. Of these,
776<literal>pre-configure</literal> is used most often, by far. The most 776<literal>pre-configure</literal> is used most often, by far. The most
777popular stages are, in chronological order:</para> 777popular stages are, in chronological order:</para>
778 778
779<variablelist> 779<variablelist>
780 780
781<varlistentry><term><literal>post-extract</literal></term> 781<varlistentry><term><literal>post-extract</literal></term>
782<listitem><para>The substitutions are applied immediately after the 782<listitem><para>The substitutions are applied immediately after the
783distfiles are extracted. Running <command>bmake extract</command> on the 783distfiles are extracted. Running <command>bmake extract</command> on the
784package will leave no traces of the original files.</para> 784package will leave no traces of the original files.</para>
785 785
786<para>When the substitution applies to files for which there is also a 786<para>When the substitution applies to files for which there is also a
787patch in the <filename>patches/</filename> directory, this means that the 787patch in the <filename>patches/</filename> directory, this means that the
788patches will be computed based on the result of the substitution. When 788patches will be computed based on the result of the substitution. When
789these patches are sent to the upstream maintainer later, to be fixed in 789these patches are sent to the upstream maintainer later, to be fixed in
790the upstream package, these patches may no longer match what the upstream 790the upstream package, these patches may no longer match what the upstream
791author is used to. Because of this, <literal>pre-configure</literal> is 791author is used to. Because of this, <literal>pre-configure</literal> is
792often a better choice.</para></listitem></varlistentry> 792often a better choice.</para></listitem></varlistentry>
793 793
794<varlistentry><term><literal>pre-configure</literal></term> 794<varlistentry><term><literal>pre-configure</literal></term>
795<listitem><para>The substitutions are applied after the patches from the 795<listitem><para>The substitutions are applied after the patches from the
796<filename>patches/</filename> directory. This makes it possible to run 796<filename>patches/</filename> directory. This makes it possible to run
797<command>bmake patch</command> on the package, after which the patches 797<command>bmake patch</command> on the package, after which the patches
798can be edited using the tools pkgvi and mkpatches from the <filename 798can be edited using the tools pkgvi and mkpatches from the <filename
799role="pkg">pkgtools/pkgdiff</filename> package.</para> 799role="pkg">pkgtools/pkgdiff</filename> package.</para>
800 800
801<para>When updating the patches, it is helpful to explicitly separate the 801<para>When updating the patches, it is helpful to explicitly separate the
802<command>bmake patch</command> from the <command>bmake 802<command>bmake patch</command> from the <command>bmake
803configure</command>, and to only edit the patches between these commands. 803configure</command>, and to only edit the patches between these commands.
804Otherwise the substitutions from the SUBST block will end up in the patch 804Otherwise the substitutions from the SUBST block will end up in the patch
805file. When this happens in really obvious ways, pkglint will complain 805file. When this happens in really obvious ways, pkglint will complain
806about patches that contain a hard-coded <literal>/usr/pkg</literal> 806about patches that contain a hard-coded <literal>/usr/pkg</literal>
807instead of the correct and intended <literal>@PREFIX@</literal>, but it 807instead of the correct and intended <literal>@PREFIX@</literal>, but it
808can only detect these really obvious 808can only detect these really obvious
809cases.</para></listitem></varlistentry> 809cases.</para></listitem></varlistentry>
810 810
811<varlistentry><term><literal>do-configure</literal></term> 811<varlistentry><term><literal>do-configure</literal></term>
812<listitem><para>This stage should only be used if the package defines a 812<listitem><para>This stage should only be used if the package defines a
813<literal>pre-configure</literal> action itself, and the substitution must 813<literal>pre-configure</literal> action itself, and the substitution must
814happen after that. Typical examples are packages that use the 814happen after that. Typical examples are packages that use the
815<literal>pre-configure</literal> stage to regenerate the GNU configure 815<literal>pre-configure</literal> stage to regenerate the GNU configure
816script from 816script from
817<filename>configure.ac</filename>.</para></listitem></varlistentry> 817<filename>configure.ac</filename>.</para></listitem></varlistentry>
818 818
819<varlistentry><term><literal>post-configure</literal></term> 819<varlistentry><term><literal>post-configure</literal></term>
820<listitem><para>This stage is used to fix up any mistakes by the 820<listitem><para>This stage is used to fix up any mistakes by the
821configure stage.</para></listitem></varlistentry> 821configure stage.</para></listitem></varlistentry>
822 822
823<varlistentry><term><literal>pre-build</literal></term> 823<varlistentry><term><literal>pre-build</literal></term>
824<listitem><para>This stage should only be used for substitutions that are 824<listitem><para>This stage should only be used for substitutions that are
825clearly related to building the package, not for fixing the 825clearly related to building the package, not for fixing the
826configuration. Substitutions for pathnames (such as replacing 826configuration. Substitutions for pathnames (such as replacing
827<filename>/usr/local</filename> with <literal>${PREFIX}</literal>) or 827<filename>/usr/local</filename> with <literal>${PREFIX}</literal>) or
828user names (such as replacing <literal>@MY_USER@</literal> with the 828user names (such as replacing <literal>@MY_USER@</literal> with the
829actual username) belong in pre-configure or post-configure 829actual username) belong in pre-configure or post-configure
830instead.</para></listitem></varlistentry> 830instead.</para></listitem></varlistentry>
831 831
832<varlistentry><term><literal>post-build</literal></term> 832<varlistentry><term><literal>post-build</literal></term>
833<listitem><para>Just as with pre-build, this stage should only be used 833<listitem><para>Just as with pre-build, this stage should only be used
834for substitutions that are clearly related to building the package, not 834for substitutions that are clearly related to building the package, not
835for fixing the configuration. Substitutions for pathnames (such as 835for fixing the configuration. Substitutions for pathnames (such as
836replacing <filename>/usr/local</filename> with 836replacing <filename>/usr/local</filename> with
837<literal>${PREFIX}</literal>) or user names (such as replacing 837<literal>${PREFIX}</literal>) or user names (such as replacing
838<literal>@MY_USER@</literal> with the actual username) belong in 838<literal>@MY_USER@</literal> with the actual username) belong in
839pre-configure or post-configure instead.</para> 839pre-configure or post-configure instead.</para>
840 840
841<para>A typical use is to update pkg-config files to include the rpath 841<para>A typical use is to update pkg-config files to include the rpath
842compiler options.</para></listitem></varlistentry> 842compiler options.</para></listitem></varlistentry>
843 843
844<varlistentry><term><literal>pre-install</literal></term> 844<varlistentry><term><literal>pre-install</literal></term>
845<listitem><para>In general, the install phase should be as simple as 845<listitem><para>In general, the install phase should be as simple as
846possible. As with the pre-build and post-build stages, it should not be 846possible. As with the pre-build and post-build stages, it should not be
847used to fix pathnames or user names, these belong in pre-configure 847used to fix pathnames or user names, these belong in pre-configure
848instead. There are only few legitimate use cases for applying 848instead. There are only few legitimate use cases for applying
849substitutions in this stage.</para></listitem></varlistentry> 849substitutions in this stage.</para></listitem></varlistentry>
850 850
851</variablelist> 851</variablelist>
852 852
853</sect3> 853</sect3>
854 854
855<sect3 id="fixes.subst.where"> 855<sect3 id="fixes.subst.where">
856<title>Choosing the files where the substitutions happen</title> 856<title>Choosing the files where the substitutions happen</title>
857 857
858<para>The <varname>SUBST_FILES.*</varname> variable contains a list of 858<para>The <varname>SUBST_FILES.*</varname> variable contains a list of
859filename patterns. These patterns are relative to 859filename patterns. These patterns are relative to
860<varname>WRKSRC</varname> since that is where most substitutions happen. 860<varname>WRKSRC</varname> since that is where most substitutions happen.
861A typical example is:</para> 861A typical example is:</para>
862 862
863<programlisting> 863<programlisting>
864SUBST_FILES.path= Makefile */Makefile */*/Makefile *.[ch] 864SUBST_FILES.path= Makefile */Makefile */*/Makefile *.[ch]
865</programlisting> 865</programlisting>
866 866
867 867
868<para>The above patterns, especially the last, are quite broad. The SUBST 868<para>The above patterns, especially the last, are quite broad. The SUBST
869implementation checks that each filename pattern that is mentioned here 869implementation checks that each filename pattern that is mentioned here
870has an effect. For example, if none of the 870has an effect. For example, if none of the
871<filename>*/*/Makefile</filename> files contains the patterns to be found 871<filename>*/*/Makefile</filename> files contains the patterns to be found
872and substituted, that filename pattern is redundant and should be left 872and substituted, that filename pattern is redundant and should be left
873out. By default, the SUBST framework will complain with an error message. 873out. By default, the SUBST framework will complain with an error message.
874If the text to be substituted occurs in some of the files from a single 874If the text to be substituted occurs in some of the files from a single
875pattern, but not in all of them, that is totally ok, and the SUBST 875pattern, but not in all of them, that is totally ok, and the SUBST
876framework will only print an INFO message for those files.</para> 876framework will only print an INFO message for those files.</para>
877 877
878<para>If there is a good reason for having redundant filename patterns, 878<para>If there is a good reason for having redundant filename patterns,
879set <varname>SUBST_NOOP_OK.*</varname> to <literal>yes</literal>.</para> 879set <varname>SUBST_NOOP_OK.*</varname> to <literal>yes</literal>.</para>
880 880
881<para>Another popular way of choosing the files for the substitutions is 881<para>Another popular way of choosing the files for the substitutions is
882via a shell command, like this:</para> 882via a shell command, like this:</para>
883 883
884<programlisting> 884<programlisting>
885C_FILES_CMD= cd ${WRKSRC} &amp;&amp; ${FIND} . -name '*.c' 885C_FILES_CMD= cd ${WRKSRC} &amp;&amp; ${FIND} . -name '*.c'
886SUBST_FILES.path= ${C_FILES_CMD:sh} 886SUBST_FILES.path= ${C_FILES_CMD:sh}
887</programlisting> 887</programlisting>
888 888
889<para>The variable name <varname>C_FILES_CMD</varname> in this example is 889<para>The variable name <varname>C_FILES_CMD</varname> in this example is
890freely chosen and independent of the SUBST framework.</para> 890freely chosen and independent of the SUBST framework.</para>
891 891
892<para>In this variant, the <varname>SUBST_FILES.*</varname> variable 892<para>In this variant, the <varname>SUBST_FILES.*</varname> variable
893lists each file individually. Thereby chances are higher that there are 893lists each file individually. Thereby chances are higher that there are
894filename patterns in which no substitution happens. Since the SUBST 894filename patterns in which no substitution happens. Since the SUBST
895framework cannot know whether the filename patterns in 895framework cannot know whether the filename patterns in
896<varname>SUBST_FILES.*</varname> have been explicitly listed in the 896<varname>SUBST_FILES.*</varname> have been explicitly listed in the
897Makefile (where any redundant filename pattern would be suspicious) or 897Makefile (where any redundant filename pattern would be suspicious) or
898been generated by a shell command (in which redundant filename patterns 898been generated by a shell command (in which redundant filename patterns
899are more likely and to be expected), it will complain about these 899are more likely and to be expected), it will complain about these
900redundant filename patterns. Therefore, SUBST blocks that use a shell 900redundant filename patterns. Therefore, SUBST blocks that use a shell
901command to generate the list of filename patterns often need to set 901command to generate the list of filename patterns often need to set
902<varname>SUBST_NOOP_OK.*</varname> to <literal>yes</literal>.</para> 902<varname>SUBST_NOOP_OK.*</varname> to <literal>yes</literal>.</para>
903 903
904</sect3> 904</sect3>
905 905
906<sect3 id="fixes.subst.what"> 906<sect3 id="fixes.subst.what">
907<title>Choosing what to substitute</title> 907<title>Choosing what to substitute</title>
908 908
909<para>In most cases, the substitutions are given using one or more 909<para>In most cases, the substitutions are given using one or more
910&man.sed.1; commands, like this:</para> 910&man.sed.1; commands, like this:</para>
911 911
912<programlisting> 912<programlisting>
913SUBST_SED.path= -e 's|/usr/local|${PREFIX}|g' 913SUBST_SED.path= -e 's|/usr/local|${PREFIX}|g'
914</programlisting> 914</programlisting>
915 915
916<para>Each of the sed commands needs to be preceded by the 916<para>Each of the sed commands needs to be preceded by the
917<literal>-e</literal> option and should be specified on a line of its 917<literal>-e</literal> option and should be specified on a line of its
918own, to avoid hiding short sed commands at the end of a line.</para> 918own, to avoid hiding short sed commands at the end of a line.</para>
919 919
920<para>Since the sed commands often contain shell metacharacters as the 920<para>Since the sed commands often contain shell metacharacters as the
921separator (the <literal>|</literal> in the above example), it is common 921separator (the <literal>|</literal> in the above example), it is common
922to enclose them in single quotes.</para> 922to enclose them in single quotes.</para>
923 923
924<para>A common substitution is to replace placeholders of the form 924<para>A common substitution is to replace placeholders of the form
925<literal>@VARNAME@</literal> with their pkgsrc counterpart variable 925<literal>@VARNAME@</literal> with their pkgsrc counterpart variable
926<literal>${VARNAME}</literal>. A typical example is:</para> 926<literal>${VARNAME}</literal>. A typical example is:</para>
927 927
928<programlisting> 928<programlisting>
929SUBST_VARS.path= PREFIX 929SUBST_VARS.path= PREFIX
930</programlisting> 930</programlisting>
931 931
932<para>This type of substitutions is typically done by the GNU configure 932<para>This type of substitutions is typically done by the GNU configure
933scripts during the do-configure stage, but in some cases these need to be 933scripts during the do-configure stage, but in some cases these need to be
934overridden. The same pattern is also used when a package defines patches 934overridden. The same pattern is also used when a package defines patches
935that replace previously hard-coded paths like 935that replace previously hard-coded paths like
936<literal>/usr/local</literal> with a <literal>@PREFIX@</literal> 936<literal>/usr/local</literal> with a <literal>@PREFIX@</literal>
937placeholder first, which then gets substituted by the actual 937placeholder first, which then gets substituted by the actual
938<literal>${PREFIX}</literal> in the pre-configure stage. In many of these 938<literal>${PREFIX}</literal> in the pre-configure stage. In many of these
939cases, it works equally well to just use the SUBST framework to directly 939cases, it works equally well to just use the SUBST framework to directly
940replace <literal>/usr/local</literal> with <literal>${PREFIX}</literal>, 940replace <literal>/usr/local</literal> with <literal>${PREFIX}</literal>,
941thereby omitting the intermediate patch file.</para> 941thereby omitting the intermediate patch file.</para>
942 942
943<para>If the above is not flexible enough, it is possible to not use sed 943<para>If the above is not flexible enough, it is possible to not use sed
944at all for the substitution but to specify an entirely different command, 944at all for the substitution but to specify an entirely different command,
945like this:</para> 945like this:</para>
946 946
947<programlisting> 947<programlisting>
948SUBST_FILTER_CMD.path= LC_ALL=C ${TR} -d '\r' 948SUBST_FILTER_CMD.path= LC_ALL=C ${TR} -d '\r'
949</programlisting> 949</programlisting>
950 950
951<para>This is used for the few remaining packages in which the 951<para>This is used for the few remaining packages in which the
952distributed files use Windows-style line endings that need to be 952distributed files use Windows-style line endings that need to be
953converted to UNIX-style line endings.</para> 953converted to UNIX-style line endings.</para>
954 954
955</sect3> 955</sect3>
956 956
957<sect3 id="fixes.subst.other"> 957<sect3 id="fixes.subst.other">
958<title>Other SUBST variables</title> 958<title>Other SUBST variables</title>
959 959
960<para>When a SUBST block is applied during a package build, a message is 960<para>When a SUBST block is applied during a package build, a message is
961logged. The default message is fine for most purposes but can be 961logged. The default message is fine for most purposes but can be
962overridden by setting <literal>SUBST_MESSAGE.*</literal> to an individual 962overridden by setting <literal>SUBST_MESSAGE.*</literal> to an individual
963message.</para> 963message.</para>
964 964
965</sect3> 965</sect3>
966 966
967</sect2> 967</sect2>
968 968
969</sect1> 969</sect1>
970 970
971<sect1 id="fixes.fetch"> 971<sect1 id="fixes.fetch">
972 <title>The <emphasis>fetch</emphasis> phase</title> 972 <title>The <emphasis>fetch</emphasis> phase</title>
973 973
974 <sect2 id="no-plain-download"> 974 <sect2 id="no-plain-download">
975 <title>Packages whose distfiles aren't available for plain downloading</title> 975 <title>Packages whose distfiles aren't available for plain downloading</title>
976 976
977 <para>If you need to download from a dynamic URL you can set 977 <para>If you need to download from a dynamic URL you can set
978 <varname>DYNAMIC_MASTER_SITES</varname> and a <command>make 978 <varname>DYNAMIC_MASTER_SITES</varname> and a <command>make
979 fetch</command> will call <filename>files/getsite.sh</filename> 979 fetch</command> will call <filename>files/getsite.sh</filename>
980 with the name of each file to download as an argument, expecting 980 with the name of each file to download as an argument, expecting
981 it to output the URL of the directory from which to download 981 it to output the URL of the directory from which to download
982 it. <filename role="pkg">graphics/ns-cult3d</filename> is an 982 it. <filename role="pkg">graphics/ns-cult3d</filename> is an
983 example of this usage.</para> 983 example of this usage.</para>
984 984
985 <para>If the download can't be automated, because the user must 985 <para>If the download can't be automated, because the user must
986 submit personal information to apply for a password, or must pay 986 submit personal information to apply for a password, or must pay
987 for the source, or whatever, you can set 987 for the source, or whatever, you can set
988 <varname>FETCH_MESSAGE</varname> to a list of lines that are 988 <varname>FETCH_MESSAGE</varname> to a list of lines that are
989 displayed to the user before aborting the build. Example:</para> 989 displayed to the user before aborting the build. Example:</para>
990 990
991<programlisting> 991<programlisting>
992FETCH_MESSAGE= "Please download the files" 992FETCH_MESSAGE= "Please download the files"
993FETCH_MESSAGE+= " "${DISTFILES:Q} 993FETCH_MESSAGE+= " "${DISTFILES:Q}
994FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"." 994FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
995</programlisting> 995</programlisting>
996 996
997 </sect2> 997 </sect2>
998 998
999 999
1000 <sect2 id="modified-distfiles-same-name"> 1000 <sect2 id="modified-distfiles-same-name">
1001 <title>How to handle modified distfiles with the 'old' name</title> 1001 <title>How to handle modified distfiles with the 'old' name</title>
1002 1002
1003 <para>Sometimes authors of a software package make some 1003 <para>Sometimes authors of a software package make some
1004 modifications after the software was released, and they put up a 1004 modifications after the software was released, and they put up a
1005 new distfile without changing the package's version number. If a 1005 new distfile without changing the package's version number. If a
1006 package is already in pkgsrc at that time, the checksum will 1006 package is already in pkgsrc at that time, the checksum will
1007 no longer match. The contents of the new distfile should be 1007 no longer match. The contents of the new distfile should be
1008 compared against the old one before changing anything, to make 1008 compared against the old one before changing anything, to make
1009 sure the distfile was really updated on purpose, and that 1009 sure the distfile was really updated on purpose, and that
1010 no trojan horse or so crept in. 1010 no trojan horse or so crept in.
1011 Please mention that the distfiles were compared and what was found 1011 Please mention that the distfiles were compared and what was found
1012 in your commit message.</para> 1012 in your commit message.</para>
1013 <para>Then, the correct way to work around this is to set 1013 <para>Then, the correct way to work around this is to set
1014 <varname>DIST_SUBDIR</varname> to a unique directory name, usually 1014 <varname>DIST_SUBDIR</varname> to a unique directory name, usually
1015 based on <varname>PKGNAME_NOREV</varname> (but take care with 1015 based on <varname>PKGNAME_NOREV</varname> (but take care with
1016 python or ruby packages, where <varname>PKGNAME</varname> includes 1016 python or ruby packages, where <varname>PKGNAME</varname> includes
1017 a variable prefix). All <varname>DISTFILES</varname> and 1017 a variable prefix). All <varname>DISTFILES</varname> and
1018 <varname>PATCHFILES</varname> for this package will be put in that 1018 <varname>PATCHFILES</varname> for this package will be put in that
1019 subdirectory of the local distfiles directory. (See <xref 1019 subdirectory of the local distfiles directory. (See <xref
1020 linkend="bumping-pkgrevision"/> for more details.) In case this 1020 linkend="bumping-pkgrevision"/> for more details.) In case this
1021 happens more often, <varname>PKGNAME</varname> can be used (thus 1021 happens more often, <varname>PKGNAME</varname> can be used (thus
1022 including the <filename>nbX</filename> suffix) or a date stamp can 1022 including the <filename>nbX</filename> suffix) or a date stamp can
1023 be appended, like 1023 be appended, like
1024 <varname>${PKGNAME_NOREV}-YYYYMMDD</varname>.</para> 1024 <varname>${PKGNAME_NOREV}-YYYYMMDD</varname>.</para>
1025 1025
1026 <para><varname>DIST_SUBDIR</varname> is also used when a distfile's 1026 <para><varname>DIST_SUBDIR</varname> is also used when a distfile's
1027 name does not contain a version and the distfile is apt to change. In 1027 name does not contain a version and the distfile is apt to change. In
1028 cases where the likelihood of this is very small, 1028 cases where the likelihood of this is very small,
1029 <varname>DIST_SUBDIR</varname> might not be required. Additionally, 1029 <varname>DIST_SUBDIR</varname> might not be required. Additionally,
1030 <varname>DIST_SUBDIR</varname> must not be removed unless the 1030 <varname>DIST_SUBDIR</varname> must not be removed unless the
1031 distfile name changes, even if a package is being moved or 1031 distfile name changes, even if a package is being moved or
1032 renamed.</para> 1032 renamed.</para>
1033 1033
1034 <para>Do not forget regenerating the <filename>distinfo</filename> file 1034 <para>Do not forget regenerating the <filename>distinfo</filename> file
1035 after that, since it contains the <varname>DIST_SUBDIR</varname> 1035 after that, since it contains the <varname>DIST_SUBDIR</varname>
1036 path in the filenames. 1036 path in the filenames.
1037 Also, increase the PKGREVISION if the installed package is different. 1037 Also, increase the PKGREVISION if the installed package is different.
1038 Furthermore, a mail to the package's authors seems appropriate 1038 Furthermore, a mail to the package's authors seems appropriate
1039 telling them that changing distfiles after releases without 1039 telling them that changing distfiles after releases without
1040 changing the file names is not good practice.</para> 1040 changing the file names is not good practice.</para>
1041 </sect2> 1041 </sect2>
1042 1042
1043 <sect2 id="build.fetch.github"> 1043 <sect2 id="build.fetch.github">
1044 <title>Packages hosted on github.com</title> 1044 <title>Packages hosted on github.com</title>
1045 1045
1046 <para>Helper methods exist for packages hosted on github.com which 1046 <para>Helper methods exist for packages hosted on github.com which
1047 will often have distfile names that clash with other packages, for 1047 will often have distfile names that clash with other packages, for
1048 example <filename>1.0.tar.gz</filename>. Use one of the three recipes 1048 example <filename>1.0.tar.gz</filename>. Use one of the three recipes
1049 from below:</para> 1049 from below:</para>
1050 1050
1051 <sect3 id="build.fetch.github.tag"> 1051 <sect3 id="build.fetch.github.tag">
1052 <title>Fetch based on a tagged release</title> 1052 <title>Fetch based on a tagged release</title>
1053 1053
1054 <para>If your distfile URL looks similar to 1054 <para>If your distfile URL looks similar to
1055 <literal>https://github.com/username/example/archive/v1.0.zip</literal>, 1055 <literal>https://github.com/username/example/archive/v1.0.zip</literal>,
1056 then you are packaging a tagged release.</para> 1056 then you are packaging a tagged release.</para>
1057 1057
1058<programlisting> 1058<programlisting>
1059DISTNAME= example-1.0 1059DISTNAME= example-1.0
1060MASTER_SITES= ${MASTER_SITE_GITHUB:=username/} 1060MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1061#GITHUB_PROJECT= example # can be omitted if same as DISTNAME 1061#GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1062GITHUB_TAG= v${PKGVERSION_NOREV} 1062GITHUB_TAG= v${PKGVERSION_NOREV}
1063EXTRACT_SUFX= .zip 1063EXTRACT_SUFX= .zip
1064</programlisting> 1064</programlisting>
1065 1065
1066 <para>Here, DISTNAME combined with use of GITHUB_TAG leads the 1066 <para>Here, DISTNAME combined with use of GITHUB_TAG leads the
1067 file fetching infrastructure to save the resulting file locally as 1067 file fetching infrastructure to save the resulting file locally as
1068 <literal>example-1.0.zip</literal>.</para> 1068 <literal>example-1.0.zip</literal>.</para>
1069 1069
1070 </sect3> 1070 </sect3>
1071 1071
1072 <sect3 id="build.fetch.github.commit.prerelease"> 1072 <sect3 id="build.fetch.github.commit.prerelease">
1073 <title>Fetch based on a specific commit before the first release</title> 1073 <title>Fetch based on a specific commit before the first release</title>
1074 1074
1075 <para>If your distfile looks similar to 1075 <para>If your distfile looks similar to
1076 <literal>https://github.com/username/example/archive/988881adc9fc3655077dc2d4d757d480b5ea0e11</literal> and is from a commit before the first 1076 <literal>https://github.com/username/example/archive/988881adc9fc3655077dc2d4d757d480b5ea0e11</literal> and is from a commit before the first
1077 release, then set the package version to 0.0.0.N, where N is the number 1077 release, then set the package version to 0.0.0.N, where N is the number
1078 of commits to the repository, and set GITHUB_TAG to the commit hash. 1078 of commits to the repository, and set GITHUB_TAG to the commit hash.
1079 This will (almost) ensure that the first tagged release will have a 1079 This will (almost) ensure that the first tagged release will have a
1080 version greater than this one so that package upgrades will function 1080 version greater than this one so that package upgrades will function
1081 properly.</para> 1081 properly.</para>
1082 1082
1083<programlisting> 1083<programlisting>
1084DISTNAME= example-0.0.0.347 1084DISTNAME= example-0.0.0.347
1085MASTER_SITES= ${MASTER_SITE_GITHUB:=username/} 1085MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1086#GITHUB_PROJECT= example # can be omitted if same as DISTNAME 1086#GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1087GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11 1087GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
1088</programlisting> 1088</programlisting>
1089 </sect3> 1089 </sect3>
1090 1090
1091 <sect3 id="build.fetch.github.commit.postrelease"> 1091 <sect3 id="build.fetch.github.commit.postrelease">
1092 <title>Fetch based on a specific commit after a release</title> 1092 <title>Fetch based on a specific commit after a release</title>
1093 1093
1094 <para>If your distfile looks similar to 1094 <para>If your distfile looks similar to
1095 <literal>https://github.com/username/example/archive/988881adc9fc3655077dc2d4d757d480b5ea0e11</literal> and is from a commit after a release, 1095 <literal>https://github.com/username/example/archive/988881adc9fc3655077dc2d4d757d480b5ea0e11</literal> and is from a commit after a release,
1096 then include the last release version and the commit count since that 1096 then include the last release version and the commit count since that
1097 release in the package version and set GITHUB_TAG to the commit hash. 1097 release in the package version and set GITHUB_TAG to the commit hash.
1098 The latest release and commit count are shown in the output of 1098 The latest release and commit count are shown in the output of
1099 "git describe --tags": 1099 "git describe --tags":
1100 </para> 1100 </para>
1101 1101
1102<screen> 1102<screen>
1103# git clone https://github.com/username/example 1103# git clone https://github.com/username/example
1104# cd example 1104# cd example
1105# git describe --tags 1105# git describe --tags
11061.2.3-5-g988881a 11061.2.3-5-g988881a
1107</screen> 1107</screen>
1108 1108
1109<programlisting> 1109<programlisting>
1110DISTNAME= example-1.2.3.5 1110DISTNAME= example-1.2.3.5
1111MASTER_SITES= ${MASTER_SITE_GITHUB:=username/} 1111MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1112#GITHUB_PROJECT= example # can be omitted if same as DISTNAME 1112#GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1113GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11 1113GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
1114</programlisting> 1114</programlisting>
1115 </sect3> 1115 </sect3>
1116 1116
1117 <sect3 id="build.fetch.github.release"> 1117 <sect3 id="build.fetch.github.release">
1118 <title>Fetch based on release</title> 1118 <title>Fetch based on release</title>
1119 1119
1120 <para>If your distfile URL looks similar to 1120 <para>If your distfile URL looks similar to
1121 <literal>https://github.com/username/example/releases/download/rel-1.6/offensive-1.6.zip</literal>, 1121 <literal>https://github.com/username/example/releases/download/rel-1.6/offensive-1.6.zip</literal>,
1122 then you are packaging a release.</para> 1122 then you are packaging a release.</para>
1123 1123
1124<programlisting> 1124<programlisting>
1125DISTNAME= offensive-1.6 1125DISTNAME= offensive-1.6
1126PKGNAME= ${DISTNAME:S/offensive/proper/} 1126PKGNAME= ${DISTNAME:S/offensive/proper/}
1127MASTER_SITES= ${MASTER_SITE_GITHUB:=username/} 1127MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1128GITHUB_PROJECT= example 1128GITHUB_PROJECT= example
1129GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME} 1129GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
1130EXTRACT_SUFX= .zip 1130EXTRACT_SUFX= .zip
1131</programlisting> 1131</programlisting>
1132 </sect3> 1132 </sect3>
1133 </sect2> 1133 </sect2>
1134</sect1> 1134</sect1>
1135 1135
1136 1136
1137<sect1 id="fixes.configure"> 1137<sect1 id="fixes.configure">
1138 <title>The <emphasis>configure</emphasis> phase</title> 1138 <title>The <emphasis>configure</emphasis> phase</title>
1139 1139
1140 <sect2 id="fixes.libtool"> 1140 <sect2 id="fixes.libtool">
1141 <title>Shared libraries - libtool</title> 1141 <title>Shared libraries - libtool</title>
1142 1142
1143 <para>pkgsrc supports many different machines, with different 1143 <para>pkgsrc supports many different machines, with different
1144 object formats like a.out and ELF, and varying abilities to do 1144 object formats like a.out and ELF, and varying abilities to do
1145 shared library and dynamic loading at all. To accompany this, 1145 shared library and dynamic loading at all. To accompany this,
1146 varying commands and options have to be passed to the 1146 varying commands and options have to be passed to the
1147 compiler, linker, etc. to get the Right Thing, which can be 1147 compiler, linker, etc. to get the Right Thing, which can be
1148 pretty annoying especially if you don't have all the machines 1148 pretty annoying especially if you don't have all the machines
1149 at your hand to test things. The 1149 at your hand to test things. The
1150 <filename role="pkg">devel/libtool</filename> pkg 1150 <filename role="pkg">devel/libtool</filename> pkg
1151 can help here, as it just <quote>knows</quote> how to build 1151 can help here, as it just <quote>knows</quote> how to build
1152 both static and dynamic libraries from a set of source files, 1152 both static and dynamic libraries from a set of source files,
1153 thus being platform-independent.</para> 1153 thus being platform-independent.</para>
1154 1154
1155 <para>Here's how to use libtool in a package in seven simple 1155 <para>Here's how to use libtool in a package in seven simple
1156 steps:</para> 1156 steps:</para>
1157 1157
1158 <orderedlist> 1158 <orderedlist>
1159 <listitem> 1159 <listitem>
1160 <para>Add <varname>USE_LIBTOOL=yes</varname> to the package 1160 <para>Add <varname>USE_LIBTOOL=yes</varname> to the package
1161 Makefile.</para> 1161 Makefile.</para>
1162 </listitem> 1162 </listitem>
1163 1163
1164 <listitem> 1164 <listitem>
1165 <para>For library objects, use <quote>${LIBTOOL} --mode=compile 1165 <para>For library objects, use <quote>${LIBTOOL} --mode=compile
1166 ${CC}</quote> in place of <quote>${CC}</quote>. You could even 1166 ${CC}</quote> in place of <quote>${CC}</quote>. You could even
1167 add it to the definition of <varname>CC</varname>, if only 1167 add it to the definition of <varname>CC</varname>, if only
1168 libraries are being built in a given Makefile. This one command 1168 libraries are being built in a given Makefile. This one command
1169 will build both PIC and non-PIC library objects, so you need not 1169 will build both PIC and non-PIC library objects, so you need not
1170 have separate shared and non-shared library rules.</para> 1170 have separate shared and non-shared library rules.</para>
1171 </listitem> 1171 </listitem>
1172 1172
1173 <listitem> 1173 <listitem>
1174 <para>For the linking of the library, remove any 1174 <para>For the linking of the library, remove any
1175 <quote>ar</quote>, <quote>ranlib</quote>, and <quote>ld 1175 <quote>ar</quote>, <quote>ranlib</quote>, and <quote>ld
1176 -Bshareable</quote> commands, and instead use:</para> 1176 -Bshareable</quote> commands, and instead use:</para>
1177 1177
1178<programlisting> 1178<programlisting>
1179${LIBTOOL} --mode=link \ 1179${LIBTOOL} --mode=link \
1180 ${CC} -o ${.TARGET:.a=.la} \ 1180 ${CC} -o ${.TARGET:.a=.la} \
1181 ${OBJS:.o=.lo} \ 1181 ${OBJS:.o=.lo} \
1182 -rpath ${PREFIX}/lib \ 1182 -rpath ${PREFIX}/lib \
1183 -version-info major:minor 1183 -version-info major:minor
1184</programlisting> 1184</programlisting>
1185 1185
1186 <para>Note that the library is changed to have a 1186 <para>Note that the library is changed to have a
1187 <filename>.la</filename> extension, and the objects are 1187 <filename>.la</filename> extension, and the objects are
1188 changed to have a <filename>.lo</filename> 1188 changed to have a <filename>.lo</filename>
1189 extension. Change <varname>OBJS</varname> as 1189 extension. Change <varname>OBJS</varname> as
1190 necessary. This automatically creates all of the 1190 necessary. This automatically creates all of the
1191 <filename>.a</filename>, 1191 <filename>.a</filename>,
1192 <filename>.so.major.minor</filename>, and ELF symlinks (if 1192 <filename>.so.major.minor</filename>, and ELF symlinks (if
1193 necessary) in the build directory. Be sure to include 1193 necessary) in the build directory. Be sure to include
1194 <quote>-version-info</quote>, especially when major and 1194 <quote>-version-info</quote>, especially when major and
1195 minor are zero, as libtool will otherwise strip off the 1195 minor are zero, as libtool will otherwise strip off the
1196 shared library version.</para> 1196 shared library version.</para>
1197 1197
1198 <para>From the libtool manual:</para> 1198 <para>From the libtool manual:</para>
1199 1199
1200<programlisting> 1200<programlisting>
1201So, libtool library versions are described by three integers: 1201So, libtool library versions are described by three integers:
1202 1202
1203CURRENT 1203CURRENT
1204The most recent interface number that this library implements. 1204The most recent interface number that this library implements.
1205 1205
1206REVISION 1206REVISION
1207The implementation number of the CURRENT interface. 1207The implementation number of the CURRENT interface.
1208 1208
1209AGE 1209AGE
1210The difference between the newest and oldest interfaces that 1210The difference between the newest and oldest interfaces that
1211this library implements. In other words, the library implements 1211this library implements. In other words, the library implements
1212all the interface numbers in the range from number `CURRENT - 1212all the interface numbers in the range from number `CURRENT -
1213AGE' to `CURRENT'. 1213AGE' to `CURRENT'.
1214 1214
1215If two libraries have identical CURRENT and AGE numbers, then the 1215If two libraries have identical CURRENT and AGE numbers, then the
1216dynamic linker chooses the library with the greater REVISION number. 1216dynamic linker chooses the library with the greater REVISION number.
1217</programlisting> 1217</programlisting>
1218 1218
1219 <para>The <quote>-release</quote> option will produce 1219 <para>The <quote>-release</quote> option will produce
1220 different results for a.out and ELF (excluding symlinks) 1220 different results for a.out and ELF (excluding symlinks)
1221 in only one case. An ELF library of the form 1221 in only one case. An ELF library of the form
1222 <quote>libfoo-release.so.<emphasis>x</emphasis>.<emphasis>y</emphasis></quote> 1222 <quote>libfoo-release.so.<emphasis>x</emphasis>.<emphasis>y</emphasis></quote>
1223 will have a symlink of 1223 will have a symlink of
1224 <quote>libfoo.so.<emphasis>x</emphasis>.<emphasis>y</emphasis></quote> 1224 <quote>libfoo.so.<emphasis>x</emphasis>.<emphasis>y</emphasis></quote>
1225 on an a.out platform. This is handled 1225 on an a.out platform. This is handled
1226 automatically.</para> 1226 automatically.</para>
1227 1227
1228 <para>The <quote>-rpath argument</quote> is the install 1228 <para>The <quote>-rpath argument</quote> is the install
1229 directory of the library being built.</para> 1229 directory of the library being built.</para>
1230 1230
1231 <para>In the <filename>PLIST</filename>, include only the 1231 <para>In the <filename>PLIST</filename>, include only the
1232 <filename>.la</filename> file, the other files will be 1232 <filename>.la</filename> file, the other files will be
1233 added automatically.</para> 1233 added automatically.</para>
1234 </listitem> 1234 </listitem>
1235 1235
1236 <listitem> 1236 <listitem>
1237 <para>When linking shared object (<filename>.so</filename>) 1237 <para>When linking shared object (<filename>.so</filename>)
1238 files, i.e. files that are loaded via &man.dlopen.3;, NOT 1238 files, i.e. files that are loaded via &man.dlopen.3;, NOT
1239 shared libraries, use <quote>-module 1239 shared libraries, use <quote>-module
1240 -avoid-version</quote> to prevent them getting version 1240 -avoid-version</quote> to prevent them getting version
1241 tacked on.</para> 1241 tacked on.</para>
1242 1242
1243 <para>The <filename>PLIST</filename> file gets the 1243 <para>The <filename>PLIST</filename> file gets the
1244 <filename>foo.so</filename> entry.</para> 1244 <filename>foo.so</filename> entry.</para>
1245 </listitem> 1245 </listitem>
1246 1246
1247 <listitem> 1247 <listitem>
1248 <para>When linking programs that depend on these libraries 1248 <para>When linking programs that depend on these libraries
1249 <emphasis>before</emphasis> they are installed, preface 1249 <emphasis>before</emphasis> they are installed, preface
1250 the &man.cc.1; or &man.ld.1; line with <quote>${LIBTOOL} 1250 the &man.cc.1; or &man.ld.1; line with <quote>${LIBTOOL}
1251 --mode=link</quote>, and it will find the correct 1251 --mode=link</quote>, and it will find the correct
1252 libraries (static or shared), but please be aware that 1252 libraries (static or shared), but please be aware that
1253 libtool will not allow you to specify a relative path in 1253 libtool will not allow you to specify a relative path in
1254 -L (such as <quote>-L../somelib</quote>), because it 1254 -L (such as <quote>-L../somelib</quote>), because it
1255 expects you to change that argument to be the 1255 expects you to change that argument to be the
1256 <filename>.la</filename> file. e.g.</para> 1256 <filename>.la</filename> file. e.g.</para>
1257 1257
1258<programlisting> 1258<programlisting>
1259${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib 1259${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
1260</programlisting> 1260</programlisting>
1261 1261
1262 <para>should be changed to:</para> 1262 <para>should be changed to:</para>
1263 1263
1264<programlisting> 1264<programlisting>
1265${LIBTOOL} --mode=link ${CC} -o <replaceable>someprog</replaceable> <replaceable>../somelib/somelib.la</replaceable> 1265${LIBTOOL} --mode=link ${CC} -o <replaceable>someprog</replaceable> <replaceable>../somelib/somelib.la</replaceable>
1266</programlisting> 1266</programlisting>
1267 1267
1268 <para>and it will do the right thing with the libraries.</para> 1268 <para>and it will do the right thing with the libraries.</para>
1269 </listitem> 1269 </listitem>
1270 1270
1271 <listitem> 1271 <listitem>
1272 <para>When installing libraries, preface the &man.install.1; 1272 <para>When installing libraries, preface the &man.install.1;
1273 or &man.cp.1; command with <quote>${LIBTOOL} 1273 or &man.cp.1; command with <quote>${LIBTOOL}
1274 --mode=install</quote>, and change the library name to 1274 --mode=install</quote>, and change the library name to
1275 <filename>.la</filename>. e.g.</para> 1275 <filename>.la</filename>. e.g.</para>
1276 1276
1277<programlisting> 1277<programlisting>
1278${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib 1278${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1279</programlisting> 1279</programlisting>
1280 1280
1281 <para>This will install the static <filename>.a</filename>, 1281 <para>This will install the static <filename>.a</filename>,
1282 shared library, any needed symlinks, and run 1282 shared library, any needed symlinks, and run
1283 &man.ldconfig.8;.</para> 1283 &man.ldconfig.8;.</para>
1284 </listitem> 1284 </listitem>
1285 1285
1286 <listitem> 1286 <listitem>
1287 <para>In your <filename>PLIST</filename>, include only 1287 <para>In your <filename>PLIST</filename>, include only
1288 the <filename>.la</filename> 1288 the <filename>.la</filename>
1289 file (this is a change from previous behaviour).</para> 1289 file (this is a change from previous behaviour).</para>
1290 </listitem> 1290 </listitem>
1291 </orderedlist> 1291 </orderedlist>
1292 </sect2> 1292 </sect2>
1293 1293
1294 1294
1295 <sect2 id="using-libtool"> 1295 <sect2 id="using-libtool">
1296 <title>Using libtool on GNU packages that already support libtool</title> 1296 <title>Using libtool on GNU packages that already support libtool</title>
1297 1297
1298 <para>Add <varname>USE_LIBTOOL=yes</varname> to the 1298 <para>Add <varname>USE_LIBTOOL=yes</varname> to the
1299 package Makefile. This will override the package's own libtool 1299 package Makefile. This will override the package's own libtool
1300 in most cases. For older libtool using packages, libtool is 1300 in most cases. For older libtool using packages, libtool is
1301 made by ltconfig script during the do-configure step; you can 1301 made by ltconfig script during the do-configure step; you can
1302 check the libtool script location by doing <command>make 1302 check the libtool script location by doing <command>make
1303 configure; find work*/ -name libtool</command>.</para> 1303 configure; find work*/ -name libtool</command>.</para>
1304 1304
1305 <para><varname>LIBTOOL_OVERRIDE</varname> specifies which libtool 1305 <para><varname>LIBTOOL_OVERRIDE</varname> specifies which libtool
1306 scripts, relative to <varname>WRKSRC</varname>, to override. By 1306 scripts, relative to <varname>WRKSRC</varname>, to override. By
1307 default, it is set to <quote>libtool */libtool 1307 default, it is set to <quote>libtool */libtool
1308 */*/libtool</quote>. If this does not match the location of the 1308 */*/libtool</quote>. If this does not match the location of the
1309 package's libtool script(s), set it as appropriate.</para> 1309 package's libtool script(s), set it as appropriate.</para>
1310 1310
1311 <para>If you do not need <filename>*.a</filename> static 1311 <para>If you do not need <filename>*.a</filename> static
1312 libraries built and installed, then use 1312 libraries built and installed, then use
1313 <varname>SHLIBTOOL_OVERRIDE</varname> instead.</para> 1313 <varname>SHLIBTOOL_OVERRIDE</varname> instead.</para>
1314 1314
1315 <para>If your package makes use of the platform-independent library 1315 <para>If your package makes use of the platform-independent library
1316 for loading dynamic shared objects, that comes with libtool 1316 for loading dynamic shared objects, that comes with libtool
1317 (libltdl), you should include devel/libltdl/buildlink3.mk.</para> 1317 (libltdl), you should include devel/libltdl/buildlink3.mk.</para>
1318 1318
1319 <para>Some packages use libtool incorrectly so that the package 1319 <para>Some packages use libtool incorrectly so that the package
1320 may not work or build in some circumstances. Some of the more 1320 may not work or build in some circumstances. Some of the more
1321 common errors are:</para> 1321 common errors are:</para>
1322 1322
1323 <itemizedlist> 1323 <itemizedlist>
1324 <listitem> 1324 <listitem>
1325 <para>The inclusion of a shared object (-module) as a dependent library in an 1325 <para>The inclusion of a shared object (-module) as a dependent library in an
1326 executable or library. This in itself isn't a problem if one of two things 1326 executable or library. This in itself isn't a problem if one of two things
1327 has been done:</para> 1327 has been done:</para>
1328 1328
1329 <orderedlist> 1329 <orderedlist>
1330 <listitem> 1330 <listitem>
1331 <para>The shared object is named correctly, i.e. 1331 <para>The shared object is named correctly, i.e.
1332 <filename>libfoo.la</filename>, not 1332 <filename>libfoo.la</filename>, not
1333 <filename>foo.la</filename></para> 1333 <filename>foo.la</filename></para>
1334 </listitem> 1334 </listitem>
1335 1335
1336 <listitem> 1336 <listitem>
1337 <para>The -dlopen option is used when linking an executable.</para> 1337 <para>The -dlopen option is used when linking an executable.</para>
1338 </listitem> 1338 </listitem>
1339 </orderedlist> 1339 </orderedlist>
1340 </listitem> 1340 </listitem>
1341 1341
1342 <listitem> 1342 <listitem>
1343 <para>The use of libltdl without the correct calls to initialisation routines. 1343 <para>The use of libltdl without the correct calls to initialisation routines.
1344 The function lt_dlinit() should be called and the macro 1344 The function lt_dlinit() should be called and the macro
1345 <varname>LTDL_SET_PRELOADED_SYMBOLS</varname> included in 1345 <varname>LTDL_SET_PRELOADED_SYMBOLS</varname> included in
1346 executables.</para> 1346 executables.</para>
1347 </listitem> 1347 </listitem>
1348 </itemizedlist> 1348 </itemizedlist>
1349 </sect2> 1349 </sect2>
1350 1350
1351 1351
1352 <sect2 id="autoconf-automake"> 1352 <sect2 id="autoconf-automake">
1353 <title>GNU Autoconf/Automake</title> 1353 <title>GNU Autoconf/Automake</title>
1354 1354
1355 <para>If a package needs GNU autoconf or automake to be executed 1355 <para>If a package needs GNU autoconf or automake to be executed
1356 to regenerate the 1356 to regenerate the
1357 <filename>configure</filename> 1357 <filename>configure</filename>
1358 script and <filename>Makefile.in</filename> makefile 1358 script and <filename>Makefile.in</filename> makefile
1359 templates from <filename>configure.ac</filename> and 1359 templates from <filename>configure.ac</filename> and
1360 <filename>Makefile.am</filename>, 1360 <filename>Makefile.am</filename>,
1361 then they should be executed in a pre-configure target:</para> 1361 then they should be executed in a pre-configure target:</para>
1362 1362
1363<programlisting> 1363<programlisting>
1364USE_TOOLS+= autoconf automake autoreconf 1364USE_TOOLS+= autoconf automake autoreconf
1365GNU_CONFIGURE= yes 1365GNU_CONFIGURE= yes
1366... 1366...
1367 1367
1368pre-configure: 1368pre-configure:
1369 set -e; cd ${WRKSRC} && autoreconf -fi 1369 set -e; cd ${WRKSRC} && autoreconf -fi
1370... 1370...
1371</programlisting> 1371</programlisting>
1372 1372
1373 <para>Packages which use GNU Automake will sometimes 1373 <para>Packages which use GNU Automake will sometimes
1374 require GNU Make (<literal>gmake</literal> in 1374 require GNU Make (<literal>gmake</literal> in
1375 <varname>USE_TOOLS</varname>), 1375 <varname>USE_TOOLS</varname>),
1376 but not always. Note that autoreconf 1376 but not always. Note that autoreconf
1377 only needs to be executed if <filename>configure.ac</filename> 1377 only needs to be executed if <filename>configure.ac</filename>
1378 or Makefiles are modified, or <filename>configure</filename> 1378 or Makefiles are modified, or <filename>configure</filename>
1379 is not present.</para> 1379 is not present.</para>
1380 1380
1381 <para>There are times when the configure process makes 1381 <para>There are times when the configure process makes
1382 additional changes to the generated files, which then causes 1382 additional changes to the generated files, which then causes
1383 the build process to try to re-execute the automake sequence. 1383 the build process to try to re-execute the automake sequence.
1384 This is prevented by touching various files in the configure 1384 This is prevented by touching various files in the configure
1385 stage. If this causes problems with your package you can set 1385 stage. If this causes problems with your package you can set
1386 <varname>AUTOMAKE_OVERRIDE=NO</varname> in the package 1386 <varname>AUTOMAKE_OVERRIDE=NO</varname> in the package
1387 Makefile.</para> 1387 Makefile.</para>
1388 </sect2> 1388 </sect2>
1389 1389
1390 <sect2 id="meson"> 1390 <sect2 id="meson">
1391 <title>Meson / ninja</title> 1391 <title>Meson / ninja</title>
1392 1392
1393 <para>Packages using Meson to configure need to include: 1393 <para>Packages using Meson to configure need to include:
1394 1394
1395<programlisting> 1395<programlisting>
1396.include "../../devel/meson/build.mk" 1396.include "../../devel/meson/build.mk"
1397</programlisting></para> 1397</programlisting></para>
1398 1398
1399 <para>In nearly all cases (any program with dependencies), 1399 <para>In nearly all cases (any program with dependencies),
1400 pkg-config needs to be added to 1400 pkg-config needs to be added to
1401 <varname>USE_TOOLS</varname>. If the package installs 1401 <varname>USE_TOOLS</varname>. If the package installs
1402 translation files for non-English languages, also 1402 translation files for non-English languages, also
1403 add msgfmt and xgettext: 1403 add msgfmt and xgettext:
1404 1404
1405<programlisting> 1405<programlisting>
1406USE_TOOLS+= pkg-config msgfmt xgettext 1406USE_TOOLS+= pkg-config msgfmt xgettext
1407</programlisting></para> 1407</programlisting></para>
1408 1408
1409 <para>If any options need to be passed to Meson, use 1409 <para>If any options need to be passed to Meson, use
1410 <varname>MESON_ARGS</varname> instead of 1410 <varname>MESON_ARGS</varname> instead of
1411 <varname>CONFIGURE_ARGS</varname>: 1411 <varname>CONFIGURE_ARGS</varname>:
1412 1412
1413<programlisting> 1413<programlisting>
1414MESON_ARGS+= -Dx11=false 1414MESON_ARGS+= -Dx11=false
1415</programlisting></para> 1415</programlisting></para>
1416 </sect2> 1416 </sect2>
1417 1417
1418</sect1> 1418</sect1>
1419 1419
1420<sect1 id="programming-languages"> 1420<sect1 id="programming-languages">
1421 <title>Programming languages</title> 1421 <title>Programming languages</title>
1422 1422
1423 <sect2 id="basic-programming-languages"> 1423 <sect2 id="basic-programming-languages">
1424 <title>C, C++, and Fortran</title> 1424 <title>C, C++, and Fortran</title>
1425 1425
1426 <para>Compilers for the C and C++ languages comes with 1426 <para>Compilers for the C and C++ languages comes with
1427 the NetBSD base system. By default, pkgsrc assumes that a package 1427 the NetBSD base system. By default, pkgsrc assumes that a package
1428 is written in C and will hide all other compilers (via the wrapper 1428 is written in C and will hide all other compilers (via the wrapper
1429 framework, see <xref linkend="buildlink" />).</para> 1429 framework, see <xref linkend="buildlink" />).</para>
1430 1430
1431 <para>To declare which languages should be made available through 1431 <para>To declare which languages should be made available through
1432 pkgsrc's compiler wrappers, use  1432 pkgsrc's compiler wrappers, use
1433 the <varname>USE_LANGUAGES</varname> variable. Allowed values 1433 the <varname>USE_LANGUAGES</varname> variable. Allowed values
1434 currently are: 1434 currently are:
1435<programlisting> 1435<programlisting>
1436c99, c++, c++03, gnu++03, c++0x, gnu++0x, c++11, gnu++11, 1436c99, c++, c++03, gnu++03, c++0x, gnu++0x, c++11, gnu++11,
1437c++14, gnu++14, c++17, gnu++17, c++20, gnu++20, fortran, 1437c++14, gnu++14, c++17, gnu++17, c++20, gnu++20, fortran,
1438fortran77, java, objc, obj-c++, and ada. 1438fortran77, java, objc, obj-c++, and ada.
1439</programlisting> 1439</programlisting>
1440 (and any combination). The default is 1440 (and any combination). The default is
1441 <quote>c</quote>. Packages using GNU configure scripts, even if 1441 <quote>c</quote>. Packages using GNU configure scripts, even if
1442 written in C++, usually need a C compiler for the configure 1442 written in C++, usually need a C compiler for the configure
1443 phase. 1443 phase.
1444 Language variants like <literal>c++11</literal> 1444 Language variants like <literal>c++11</literal>
1445 can be specified if the package does not explicitly set 1445 can be specified if the package does not explicitly set
1446 <literal>-std=...</literal> when compiling (i.e. the package 1446 <literal>-std=...</literal> when compiling (i.e. the package
1447 assumes the compiler defaults to C++11 or some other standard). 1447 assumes the compiler defaults to C++11 or some other standard).
1448 This is a common bug in upstream build systems.</para> 1448 This is a common bug in upstream build systems.</para>
1449 1449
1450 <para>To declare which features a package requies from the 1450 <para>To declare which features a package requies from the
1451 compiler, set either <varname>USE_CC_FEATURES</varname> 1451 compiler, set either <varname>USE_CC_FEATURES</varname>
1452 or <varname>USE_CXX_FEATURES</varname>. Allowed values for 1452 or <varname>USE_CXX_FEATURES</varname>. Allowed values for
1453 <varname>USE_CC_FEATURES</varname> are currently: 1453 <varname>USE_CC_FEATURES</varname> are currently:
1454<programlisting> 1454<programlisting>
1455c11, c99, has_include 1455c11, c99, has_include
1456</programlisting> 1456</programlisting>
1457 Allowed values for <varname>USE_CXX_FEATURES</varname> are 1457 Allowed values for <varname>USE_CXX_FEATURES</varname> are
1458 currently: 1458 currently:
1459<programlisting> 1459<programlisting>
1460c++11, c++14, c++17, c++20, has_include, regex, filesystem, 1460c++11, c++14, c++17, c++20, has_include, regex, filesystem,
1461charconv, parallelism_ts, unique_ptr, put_time 1461charconv, parallelism_ts, unique_ptr, put_time,
 1462is_trivially_copy_constructible
1462</programlisting> 1463</programlisting>
1463 .</para> 1464 .</para>
1464 </para> 1465 </para>
1465 </sect2> 1466 </sect2>
1466 1467
1467 <sect2 id="java-programming-language"> 1468 <sect2 id="java-programming-language">
1468 <title>Java</title> 1469 <title>Java</title>
1469 1470
1470 <para>If a program is written in Java, use the Java framework in 1471 <para>If a program is written in Java, use the Java framework in
1471 pkgsrc. The package must include 1472 pkgsrc. The package must include
1472 <filename>../../mk/java-vm.mk</filename>. This Makefile fragment 1473 <filename>../../mk/java-vm.mk</filename>. This Makefile fragment
1473 provides the following variables:</para> 1474 provides the following variables:</para>
1474 1475
1475 <itemizedlist> 1476 <itemizedlist>
1476 <listitem><para><varname>USE_JAVA</varname> defines if a build 1477 <listitem><para><varname>USE_JAVA</varname> defines if a build
1477 dependency on the JDK is added. If 1478 dependency on the JDK is added. If
1478 <varname>USE_JAVA</varname> is set to <quote>run</quote>, then 1479 <varname>USE_JAVA</varname> is set to <quote>run</quote>, then
1479 there is only a runtime dependency on the JDK. The default is 1480 there is only a runtime dependency on the JDK. The default is
1480 <quote>yes</quote>, which also adds a build dependency on the 1481 <quote>yes</quote>, which also adds a build dependency on the
1481 JDK.</para></listitem> 1482 JDK.</para></listitem>
1482 1483
1483 <listitem><para>Set <varname>USE_JAVA2</varname> to declare that 1484 <listitem><para>Set <varname>USE_JAVA2</varname> to declare that
1484 a package needs a Java2 implementation. The supported values 1485 a package needs a Java2 implementation. The supported values
1485 are <quote>yes</quote>, <quote>1.4</quote>, and 1486 are <quote>yes</quote>, <quote>1.4</quote>, and
1486 <quote>1.5</quote>. <quote>yes</quote> accepts any Java2 1487 <quote>1.5</quote>. <quote>yes</quote> accepts any Java2
1487 implementation, <quote>1.4</quote> insists on versions 1.4 or 1488 implementation, <quote>1.4</quote> insists on versions 1.4 or
1488 above, and <quote>1.5</quote> only accepts versions 1.5 or 1489 above, and <quote>1.5</quote> only accepts versions 1.5 or
1489 above. This variable is not set by default.</para></listitem> 1490 above. This variable is not set by default.</para></listitem>
1490 1491
1491 <listitem><para><varname>PKG_JAVA_HOME</varname> is 1492 <listitem><para><varname>PKG_JAVA_HOME</varname> is
1492 automatically set to the runtime location of the used Java 1493 automatically set to the runtime location of the used Java
1493 implementation dependency. It may be used to set 1494 implementation dependency. It may be used to set
1494 <varname>JAVA_HOME</varname> to a good value if the program 1495 <varname>JAVA_HOME</varname> to a good value if the program
1495 needs this variable to be defined. 1496 needs this variable to be defined.
1496 </para></listitem> 1497 </para></listitem>
1497 <!-- XXX: describe PKG_JVM_DEFAULT and PKG_JVMS_ACCEPTED, but 1498 <!-- XXX: describe PKG_JVM_DEFAULT and PKG_JVMS_ACCEPTED, but
1498 not here --> 1499 not here -->
1499 </itemizedlist> 1500 </itemizedlist>
1500 </sect2> 1501 </sect2>
1501 1502
1502 <sect2 id="go-programming-language"> 1503 <sect2 id="go-programming-language">
1503 <title>Go</title> 1504 <title>Go</title>
1504 1505
1505 <para>If a program is written in Go and has any dependencies on 1506 <para>If a program is written in Go and has any dependencies on
1506 other Go modules, have the package include 1507 other Go modules, have the package include
1507 <filename>../../lang/go/go-module.mk</filename>.</para> 1508 <filename>../../lang/go/go-module.mk</filename>.</para>
1508 1509
1509 1510
1510 <orderedlist> 1511 <orderedlist>
1511 <listitem><para>Generate a list of those dependencies with 1512 <listitem><para>Generate a list of those dependencies with
1512 <command>make clean && make patch && make show-go-modules > 1513 <command>make clean && make patch && make show-go-modules >
1513 go-modules.mk</command>.</para></listitem> 1514 go-modules.mk</command>.</para></listitem>
1514 1515
1515 <listitem><para>Prepend 1516 <listitem><para>Prepend
1516 <literal>.include "go-modules.mk"</literal> to any other 1517 <literal>.include "go-modules.mk"</literal> to any other
1517 <literal>.include</literal>s.</para></listitem> 1518 <literal>.include</literal>s.</para></listitem>
1518 1519
1519 <listitem><para>Incorporate these modules in 1520 <listitem><para>Incorporate these modules in
1520 <filename>distinfo</filename> with <command>make 1521 <filename>distinfo</filename> with <command>make
1521 makesum</command>.</para></listitem> 1522 makesum</command>.</para></listitem>
1522 </orderedlist> 1523 </orderedlist>
1523 </sect2> 1524 </sect2>
1524 1525
1525 <sect2 id="rust-programming-language"> 1526 <sect2 id="rust-programming-language">
1526 <title>Rust</title> 1527 <title>Rust</title>
1527 1528
1528 <para>If a program is written in Rust and uses Cargo to build, 1529 <para>If a program is written in Rust and uses Cargo to build,
1529 have the package include 1530 have the package include
1530 <filename>../../lang/rust/cargo.mk</filename>.</para> 1531 <filename>../../lang/rust/cargo.mk</filename>.</para>
1531 1532
1532 <orderedlist> 1533 <orderedlist>
1533 <listitem><para>Generate a list of those dependencies with 1534 <listitem><para>Generate a list of those dependencies with
1534 <command>make CARGO_ARGS="build --release" build && 1535 <command>make CARGO_ARGS="build --release" build &&
1535 make print-cargo-depends > cargo-depends.mk</command>.</para></listitem> 1536 make print-cargo-depends > cargo-depends.mk</command>.</para></listitem>
1536 1537
1537 <listitem><para>Prepend 1538 <listitem><para>Prepend
1538 <literal>.include "cargo-depends.mk"</literal> to any other 1539 <literal>.include "cargo-depends.mk"</literal> to any other
1539 <literal>.include</literal>s.</para></listitem> 1540 <literal>.include</literal>s.</para></listitem>
1540 1541
1541 <listitem><para>Incorporate these modules in 1542 <listitem><para>Incorporate these modules in
1542 <filename>distinfo</filename> with <command>make 1543 <filename>distinfo</filename> with <command>make
1543 makesum</command>.</para></listitem> 1544 makesum</command>.</para></listitem>
1544 </orderedlist> 1545 </orderedlist>
1545 </sect2> 1546 </sect2>
1546 1547
1547 <sect2 id="perl-scripts"> 1548 <sect2 id="perl-scripts">
1548 <title>Packages containing Perl scripts</title> 1549 <title>Packages containing Perl scripts</title>
1549 1550
1550 <para>If your package contains interpreted Perl scripts, add 1551 <para>If your package contains interpreted Perl scripts, add
1551 <quote>perl</quote> to the <varname>USE_TOOLS</varname> variable 1552 <quote>perl</quote> to the <varname>USE_TOOLS</varname> variable
1552 and set <varname>REPLACE_PERL</varname> to ensure that the proper 1553 and set <varname>REPLACE_PERL</varname> to ensure that the proper
1553 interpreter path is set. <varname>REPLACE_PERL</varname> should 1554 interpreter path is set. <varname>REPLACE_PERL</varname> should
1554 contain a list of scripts, relative to <varname>WRKSRC</varname>, 1555 contain a list of scripts, relative to <varname>WRKSRC</varname>,
1555 that you want adjusted. Every occurrence of 1556 that you want adjusted. Every occurrence of
1556 <filename>*/bin/perl</filename> in a she-bang line will be 1557 <filename>*/bin/perl</filename> in a she-bang line will be
1557 replaced with the full path to the Perl executable.</para> 1558 replaced with the full path to the Perl executable.</para>
1558 1559
1559 <para>If a particular version of Perl is needed, set the 1560 <para>If a particular version of Perl is needed, set the
1560 <varname>PERL5_REQD</varname> variable to the version number. The 1561 <varname>PERL5_REQD</varname> variable to the version number. The
1561 default is <quote>5.0</quote>.</para> 1562 default is <quote>5.0</quote>.</para>
1562 1563
1563 <para>See <xref linkend="perl-modules" /> for information 1564 <para>See <xref linkend="perl-modules" /> for information
1564 about handling Perl modules.</para> 1565 about handling Perl modules.</para>
1565 1566
1566 <para>There is also the <varname>REPLACE_PERL6</varname> variable 1567 <para>There is also the <varname>REPLACE_PERL6</varname> variable
1567 for the language now known as Raku.</para> 1568 for the language now known as Raku.</para>
1568 </sect2> 1569 </sect2>
1569 1570
1570 <sect2 id="shell-scripts"> 1571 <sect2 id="shell-scripts">
1571 <title>Packages containing shell scripts</title> 1572 <title>Packages containing shell scripts</title>
1572 1573
1573 <para><varname>REPLACE_SH</varname>, 1574 <para><varname>REPLACE_SH</varname>,
1574 <varname>REPLACE_BASH</varname>, <varname>REPLACE_CSH</varname>, 1575 <varname>REPLACE_BASH</varname>, <varname>REPLACE_CSH</varname>,
1575 and <varname>REPLACE_KSH</varname> can be used to replace shell 1576 and <varname>REPLACE_KSH</varname> can be used to replace shell
1576 she-bangs in files. Please use the appropriate one, preferring 1577 she-bangs in files. Please use the appropriate one, preferring
1577 <varname>REPLACE_SH</varname> when this shell is sufficient. 1578 <varname>REPLACE_SH</varname> when this shell is sufficient.
1578 Each should contain a list of scripts, relative to 1579 Each should contain a list of scripts, relative to
1579 <varname>WRKSRC</varname>, that you want adjusted. Every 1580 <varname>WRKSRC</varname>, that you want adjusted. Every
1580 occurrence of the matching shell in a she-bang line will be 1581 occurrence of the matching shell in a she-bang line will be
1581 replaced with the full path to the shell executable. 1582 replaced with the full path to the shell executable.
1582 When using <varname>REPLACE_BASH</varname>, don't forget to add 1583 When using <varname>REPLACE_BASH</varname>, don't forget to add
1583 <filename>bash</filename> to <varname>USE_TOOLS</varname>.</para> 1584 <filename>bash</filename> to <varname>USE_TOOLS</varname>.</para>
1584 </sect2> 1585 </sect2>
1585 1586
1586 <sect2 id="other-programming-languages"> 1587 <sect2 id="other-programming-languages">
1587 <title>Other programming languages</title> 1588 <title>Other programming languages</title>
1588 1589
1589 <para>There are further similar REPLACE variables available, e.g., 1590 <para>There are further similar REPLACE variables available, e.g.,
1590 <varname>REPLACE_AWK</varname> for packages containing awk scripts, 1591 <varname>REPLACE_AWK</varname> for packages containing awk scripts,
1591 and <varname>REPLACE_R</varname> for R. These two, like the others 1592 and <varname>REPLACE_R</varname> for R. These two, like the others
1592 noted above, have their actions defined centrally in 1593 noted above, have their actions defined centrally in
1593 <filename>mk/configure/replace-interpreter.mk</filename>. Other 1594 <filename>mk/configure/replace-interpreter.mk</filename>. Other
1594 languages define the actions of these variables within their own 1595 languages define the actions of these variables within their own
1595 dedicated part of the tree, e.g., <varname>REPLACE_PHP</varname> is 1596 dedicated part of the tree, e.g., <varname>REPLACE_PHP</varname> is
1596 actioned in <filename>lang/php/phpversion.mk</filename>, and 1597 actioned in <filename>lang/php/phpversion.mk</filename>, and
1597 <varname>REPLACE_PYTHON</varname> is actioned in 1598 <varname>REPLACE_PYTHON</varname> is actioned in
1598 <filename>lang/python/application.mk</filename>. For other languages, 1599 <filename>lang/python/application.mk</filename>. For other languages,
1599 consult the mk files found within their specific directories (the 1600 consult the mk files found within their specific directories (the
1600 naming convention varies), or check the list found in 1601 naming convention varies), or check the list found in
1601 <xref linkend="help-topics" />.</para> 1602 <xref linkend="help-topics" />.</para>
1602 1603
1603 <para>Currently, special handling for other languages varies 1604 <para>Currently, special handling for other languages varies
1604 in pkgsrc. If a compiler package provides a 1605 in pkgsrc. If a compiler package provides a
1605 <filename>buildlink3.mk</filename> file, include that, otherwise 1606 <filename>buildlink3.mk</filename> file, include that, otherwise
1606 just add a (build) dependency on the appropriate compiler 1607 just add a (build) dependency on the appropriate compiler
1607 package.</para> 1608 package.</para>
1608 </sect2> 1609 </sect2>
1609</sect1> 1610</sect1>
1610 1611
1611<sect1 id="fixes.build"> 1612<sect1 id="fixes.build">
1612 <title>The <emphasis>build</emphasis> phase</title> 1613 <title>The <emphasis>build</emphasis> phase</title>
1613 1614
1614 <para>The most common failures when building a package are that 1615 <para>The most common failures when building a package are that
1615 some platforms do not provide certain header files, functions or 1616 some platforms do not provide certain header files, functions or
1616 libraries, or they provide the functions in a library that the 1617 libraries, or they provide the functions in a library that the
1617 original package author didn't know. To work around this, you 1618 original package author didn't know. To work around this, you
1618 can rewrite the source code in most cases so that it does not 1619 can rewrite the source code in most cases so that it does not
1619 use the missing functions or provides a replacement function.</para> 1620 use the missing functions or provides a replacement function.</para>
1620 1621
1621<sect2 id="fixes.build.cpp"> 1622<sect2 id="fixes.build.cpp">
1622<title>Compiling C and C++ code conditionally</title> 1623<title>Compiling C and C++ code conditionally</title>
1623 1624
1624 <para>If a package already comes with a GNU configure script, the 1625 <para>If a package already comes with a GNU configure script, the
1625 preferred way to fix the build failure is to change the 1626 preferred way to fix the build failure is to change the
1626 configure script, not the code. In the other cases, you can 1627 configure script, not the code. In the other cases, you can
1627 utilize the C preprocessor, which defines certain macros 1628 utilize the C preprocessor, which defines certain macros
1628 depending on the operating system and hardware architecture it 1629 depending on the operating system and hardware architecture it
1629 compiles for. These macros can be queried using for example 1630 compiles for. These macros can be queried using for example
1630 <varname>#if defined(__i386)</varname>. Almost every operating 1631 <varname>#if defined(__i386)</varname>. Almost every operating
1631 system, hardware architecture and compiler has its own macro. 1632 system, hardware architecture and compiler has its own macro.
1632 For example, if the macros <varname>__GNUC__</varname>, 1633 For example, if the macros <varname>__GNUC__</varname>,
1633 <varname>__i386__</varname> and <varname>__NetBSD__</varname> 1634 <varname>__i386__</varname> and <varname>__NetBSD__</varname>
1634 are all defined, you know that you are using NetBSD on an i386 1635 are all defined, you know that you are using NetBSD on an i386
1635 compatible CPU, and your compiler is GCC.</para> 1636 compatible CPU, and your compiler is GCC.</para>
1636 1637
1637 <para>The list of the following macros for hardware and 1638 <para>The list of the following macros for hardware and
1638 operating system depends on the compiler that is used. For 1639 operating system depends on the compiler that is used. For
1639 example, if you want to conditionally compile code on Solaris, 1640 example, if you want to conditionally compile code on Solaris,
1640 don't use <varname>__sun__</varname>, as the SunPro compiler 1641 don't use <varname>__sun__</varname>, as the SunPro compiler
1641 does not define it. Use <varname>__sun</varname> instead.</para> 1642 does not define it. Use <varname>__sun</varname> instead.</para>
1642 1643
1643<sect3 id="fixes.build.cpp.os"> 1644<sect3 id="fixes.build.cpp.os">
1644<title>C preprocessor macros to identify the operating system</title> 1645<title>C preprocessor macros to identify the operating system</title>
1645 1646
1646 <para>To distinguish between specific NetBSD versions, 1647 <para>To distinguish between specific NetBSD versions,
1647 you should use the following code.</para> 1648 you should use the following code.</para>
1648 1649
1649<programlisting> 1650<programlisting>
1650#ifdef __NetBSD__ 1651#ifdef __NetBSD__
1651#include &lt;sys/param.h&gt; 1652#include &lt;sys/param.h&gt;
1652#if __NetBSD_Prereq__(9,99,17) 1653#if __NetBSD_Prereq__(9,99,17)
1653/* use a newer feature */ 1654/* use a newer feature */
1654#else 1655#else
1655/* older code */ 1656/* older code */
1656#endif 1657#endif
1657#endif 1658#endif
1658 1659
1659#ifndef _WIN32 1660#ifndef _WIN32
1660/* Unix-like specific code */ 1661/* Unix-like specific code */
1661#endif 1662#endif
1662</programlisting> 1663</programlisting>
1663 1664
1664 <para>To distinguish between 4.4 BSD-derived systems and the 1665 <para>To distinguish between 4.4 BSD-derived systems and the
1665 rest of the world, you should use the following code.</para> 1666 rest of the world, you should use the following code.</para>
1666 1667
1667<programlisting> 1668<programlisting>
1668#include &lt;sys/param.h&gt; 1669#include &lt;sys/param.h&gt;
1669#if (defined(BSD) &amp;&amp; BSD &gt;= 199306) 1670#if (defined(BSD) &amp;&amp; BSD &gt;= 199306)
1670/* BSD-specific code goes here */ 1671/* BSD-specific code goes here */
1671#else 1672#else
1672/* non-BSD-specific code goes here */ 1673/* non-BSD-specific code goes here */
1673#endif 1674#endif
1674</programlisting> 1675</programlisting>
1675 1676
1676 <para>You can also test for the following macros:</para> 1677 <para>You can also test for the following macros:</para>
1677 1678
1678<programlisting> 1679<programlisting>
1679Cygwin __CYGWIN__ 1680Cygwin __CYGWIN__
1680DragonFly __DragonFly__ 1681DragonFly __DragonFly__
1681FreeBSD __FreeBSD__ 1682FreeBSD __FreeBSD__
1682Haiku __HAIKU__ 1683Haiku __HAIKU__
1683Interix __INTERIX 1684Interix __INTERIX
1684IRIX __sgi (TODO: get a definite source for this) 1685IRIX __sgi (TODO: get a definite source for this)
1685Linux __linux 1686Linux __linux
1686Mac OS X __APPLE__ 1687Mac OS X __APPLE__
1687MirBSD __MirBSD__ (__OpenBSD__ is also defined) 1688MirBSD __MirBSD__ (__OpenBSD__ is also defined)
1688Minix3 __minix 1689Minix3 __minix
1689NetBSD __NetBSD__ 1690NetBSD __NetBSD__
1690OpenBSD __OpenBSD__ 1691OpenBSD __OpenBSD__
1691Solaris sun, __sun 1692Solaris sun, __sun
1692</programlisting> 1693</programlisting>
1693 1694
1694</sect3> 1695</sect3>
1695<sect3 id="fixes.build.cpp.arch"> 1696<sect3 id="fixes.build.cpp.arch">
1696<title>C preprocessor macros to identify the hardware architecture</title> 1697<title>C preprocessor macros to identify the hardware architecture</title>
1697 1698
1698<programlisting> 1699<programlisting>
1699i386 i386, __i386, __i386__ 1700i386 i386, __i386, __i386__
1700x86-64 __amd64__, __x86_64__ 1701x86-64 __amd64__, __x86_64__
1701ARM __arm__ 1702ARM __arm__
1702MIPS __mips 1703MIPS __mips
1703SPARC sparc, __sparc 1704SPARC sparc, __sparc
1704PowerPC __powerpc 1705PowerPC __powerpc
1705</programlisting> 1706</programlisting>
1706 1707
1707</sect3> 1708</sect3>
1708<sect3 id="fixes.build.cpp.compiler"> 1709<sect3 id="fixes.build.cpp.compiler">
1709<title>C preprocessor macros to identify the compiler</title> 1710<title>C preprocessor macros to identify the compiler</title>
1710 1711
1711<programlisting> 1712<programlisting>
1712GCC __GNUC__ (major version), __GNUC_MINOR__ 1713GCC __GNUC__ (major version), __GNUC_MINOR__
1713MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41) 1714MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
1714SunPro __SUNPRO_C (0x570 for Sun C 5.7) 1715SunPro __SUNPRO_C (0x570 for Sun C 5.7)
1715SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8) 1716SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
1716</programlisting> 1717</programlisting>
1717 1718
1718</sect3> 1719</sect3>
1719</sect2> 1720</sect2>
1720<sect2 id="compiler-bugs"> 1721<sect2 id="compiler-bugs">
1721<title>How to handle compiler bugs</title> 1722<title>How to handle compiler bugs</title>
1722 1723
1723 <para>Some source files trigger bugs in the compiler, based on 1724 <para>Some source files trigger bugs in the compiler, based on
1724 combinations of compiler version and architecture and almost 1725 combinations of compiler version and architecture and almost
1725 always relation to optimisation being enabled. Common symptoms 1726 always relation to optimisation being enabled. Common symptoms
1726 are gcc internal errors or never finishing compiling a 1727 are gcc internal errors or never finishing compiling a
1727 file.</para> 1728 file.</para>
1728 1729
1729 <para>Typically, a workaround involves testing the 1730 <para>Typically, a workaround involves testing the
1730 <varname>MACHINE_ARCH</varname> and compiler version, disabling 1731 <varname>MACHINE_ARCH</varname> and compiler version, disabling
1731 optimisation for that combination of file, 1732 optimisation for that combination of file,
1732 <varname>MACHINE_ARCH</varname> and compiler.</para> 1733 <varname>MACHINE_ARCH</varname> and compiler.</para>
1733 1734
1734 <para>This used to be a big problem in the past, but is rarely 1735 <para>This used to be a big problem in the past, but is rarely
1735 needed now as compiler technology has matured. If you still need 1736 needed now as compiler technology has matured. If you still need
1736 to add a compiler specific workaround, please do so in the file 1737 to add a compiler specific workaround, please do so in the file
1737 <filename>hacks.mk</filename> and describe the symptom and 1738 <filename>hacks.mk</filename> and describe the symptom and
1738 compiler version as detailed as possible.</para> 1739 compiler version as detailed as possible.</para>
1739 1740
1740</sect2> 1741</sect2>
1741 1742
1742<sect2 id="fixes.build.header"> 1743<sect2 id="fixes.build.header">
1743<title>No such file or directory</title> 1744<title>No such file or directory</title>
1744 1745
1745<para>Compilation sometimes fails with an error message like this:</para> 1746<para>Compilation sometimes fails with an error message like this:</para>
1746 1747
1747<programlisting> 1748<programlisting>
1748.../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10: 1749.../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
1749 fatal error: pango/pango.h: No such file or directory 1750 fatal error: pango/pango.h: No such file or directory
1750</programlisting> 1751</programlisting>
1751 1752
1752<para>The proper way to fix this problem depends on the type of the 1753<para>The proper way to fix this problem depends on the type of the
1753header, which is described in the following sections.</para> 1754header, which is described in the following sections.</para>
1754 1755
1755<sect3 id="fixes.build.header.bl3"> 1756<sect3 id="fixes.build.header.bl3">
1756<title>Headers from other packages</title> 1757<title>Headers from other packages</title>
1757 1758
1758<para>If the header name looks like it comes from a different package, 1759<para>If the header name looks like it comes from a different package,
1759that other package should be included via the buildlink3 1760that other package should be included via the buildlink3
1760framework.</para> 1761framework.</para>
1761 1762
1762<para>First, look whether the header is somewhere in the buildlink3 1763<para>First, look whether the header is somewhere in the buildlink3
1763directory below <varname>WRKDIR</varname>. In the above case of 1764directory below <varname>WRKDIR</varname>. In the above case of
1764the missing Pango header:</para> 1765the missing Pango header:</para>
1765 1766
1766<programlisting> 1767<programlisting>
1767&uprompt; find work/.buildlink/ -print | grep -F pango/pango.h 1768&uprompt; find work/.buildlink/ -print | grep -F pango/pango.h
1768</programlisting> 1769</programlisting>
1769 1770
1770<para>In the case of Pango, the output is:</para> 1771<para>In the case of Pango, the output is:</para>
1771 1772
1772<programlisting> 1773<programlisting>
1773work/.buildlink/include/pango-1.0/pango/pango.h 1774work/.buildlink/include/pango-1.0/pango/pango.h
1774</programlisting> 1775</programlisting>
1775 1776
1776<para>If the <filename>pango/pango.h</filename> file were placed directly 1777<para>If the <filename>pango/pango.h</filename> file were placed directly
1777in the <filename>.buildlink</filename> directory, it would have been 1778in the <filename>.buildlink</filename> directory, it would have been
1778found automatically. There is an extra <filename>pango-1.0</filename> 1779found automatically. There is an extra <filename>pango-1.0</filename>
1779path component though, which means that the compiler command line must 1780path component though, which means that the compiler command line must
1780contain an option of the form 1781contain an option of the form
1781<literal>-I${BUILDLINK3_PREFIX.pango}/include/pango-1.0</literal>. In 1782<literal>-I${BUILDLINK3_PREFIX.pango}/include/pango-1.0</literal>. In
1782most cases this option is generated by the configure script, which can be examined using:</para> 1783most cases this option is generated by the configure script, which can be examined using:</para>
1783 1784
1784<programlisting> 1785<programlisting>
1785&uprompt; $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile 1786&uprompt; $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
1786-I/usr/pkg/include/pango-1.0 1787-I/usr/pkg/include/pango-1.0
1787-I/usr/pkg/include/pango-1.0 1788-I/usr/pkg/include/pango-1.0
1788-I/usr/pkg/include/pango-1.0 1789-I/usr/pkg/include/pango-1.0
1789-I/usr/pkg/include/pango-1.0 1790-I/usr/pkg/include/pango-1.0
1790-I/usr/pkg/include/pango-1.0 1791-I/usr/pkg/include/pango-1.0
1791</programlisting> 1792</programlisting>
1792 1793
1793<para>This looks good. These options are transformed by the buildlink 1794<para>This looks good. These options are transformed by the buildlink
1794wrapper to refer to the correct path inside 1795wrapper to refer to the correct path inside
1795<filename>work/.buildlink</filename>.</para> 1796<filename>work/.buildlink</filename>.</para>
1796 1797
1797<para>Since the compilation fails though, examine the compiler command 1798<para>Since the compilation fails though, examine the compiler command
1798lines in <filename>work/.work.log</filename> to see whether the 1799lines in <filename>work/.work.log</filename> to see whether the
1799<literal>-I</literal> option is included in the particular command 1800<literal>-I</literal> option is included in the particular command
1800line.</para> 1801line.</para>
1801 1802
1802<para>To further analyze the situation, run <command>bmake 1803<para>To further analyze the situation, run <command>bmake
1803build-env</command>, which sets up an interactive, realistic environment 1804build-env</command>, which sets up an interactive, realistic environment
1804including all the pkgsrc wrapper commands and environment variables. From 1805including all the pkgsrc wrapper commands and environment variables. From
1805there, try to compile some simple example programs that use the 1806there, try to compile some simple example programs that use the
1806header.</para> 1807header.</para>
1807 1808
1808</sect3> 1809</sect3>
1809 1810
1810<sect3 id="fixes.build.header.gen"> 1811<sect3 id="fixes.build.header.gen">
1811<title>Headers generated during the build</title> 1812<title>Headers generated during the build</title>
1812 1813
1813<para>If the name of the header seems to come from the package itself, 1814<para>If the name of the header seems to come from the package itself,
1814and if the build is run with parallel jobs, the package may have some 1815and if the build is run with parallel jobs, the package may have some
1815undeclared dependencies between the <filename>.c</filename> and the 1816undeclared dependencies between the <filename>.c</filename> and the
1816<filename>.h</filename> files, and a C file is compiled before its 1817<filename>.h</filename> files, and a C file is compiled before its
1817required header is generated.</para> 1818required header is generated.</para>
1818 1819
1819<para>To see whether the build runs with parallel jobs, run 1820<para>To see whether the build runs with parallel jobs, run
1820<command>bmake show-all-build | grep JOBS</command>. Its output looks 1821<command>bmake show-all-build | grep JOBS</command>. Its output looks
1821like this:</para> 1822like this:</para>
1822 1823
1823<programlisting> 1824<programlisting>
1824 usr MAKE_JOBS= 7 1825 usr MAKE_JOBS= 7
1825 pkg MAKE_JOBS_SAFE # undefined 1826 pkg MAKE_JOBS_SAFE # undefined
1826 def _MAKE_JOBS_N= 7 1827 def _MAKE_JOBS_N= 7
1827</programlisting> 1828</programlisting>
1828 1829
1829<para>In this case the pkgsrc user has asked pkgsrc to build packages 1830<para>In this case the pkgsrc user has asked pkgsrc to build packages
1830with 7 jobs in parallel (<varname>MAKE_JOBS</varname>). The 1831with 7 jobs in parallel (<varname>MAKE_JOBS</varname>). The
1831package could have disabled parallel builds by setting 1832package could have disabled parallel builds by setting
1832<varname>MAKE_JOBS_SAFE</varname> to <literal>no</literal>, but 1833<varname>MAKE_JOBS_SAFE</varname> to <literal>no</literal>, but
1833in this case it hasn't.</para> 1834in this case it hasn't.</para>
1834 1835
1835<para>To see whether the build failure is caused by parallel builds, 1836<para>To see whether the build failure is caused by parallel builds,
1836first save the exact error message and a bit of context, maybe you need 1837first save the exact error message and a bit of context, maybe you need
1837it later for reporting a bug. Next, run:</para> 1838it later for reporting a bug. Next, run:</para>
1838 1839
1839<programlisting> 1840<programlisting>
1840MAKE_JOBS_SAFE=no bmake clean build 1841MAKE_JOBS_SAFE=no bmake clean build
1841</programlisting> 1842</programlisting>
1842 1843
1843<para>If that succeeds, <ulink 1844<para>If that succeeds, <ulink
1844url="https://www.NetBSD.org/cgi-bin/sendpr.cgi?gndb=netbsd">file a bug 1845url="https://www.NetBSD.org/cgi-bin/sendpr.cgi?gndb=netbsd">file a bug
1845report</ulink> against the pkgsrc package, including the exact error 1846report</ulink> against the pkgsrc package, including the exact error
1846message and the contents of your &mk.conf; file.</para> 1847message and the contents of your &mk.conf; file.</para>
1847 1848
1848</sect3> 1849</sect3>
1849 1850
1850<sect3 id="fixes.build.header.symlink"> 1851<sect3 id="fixes.build.header.symlink">
1851<title>Symlinks</title> 1852<title>Symlinks</title>
1852 1853
1853<para>Pkgsrc does not work reliably if any of 1854<para>Pkgsrc does not work reliably if any of
1854<varname>LOCALBASE</varname>, <varname>VARBASE</varname> or 1855<varname>LOCALBASE</varname>, <varname>VARBASE</varname> or
1855<varname>WRKDIR</varname> contains a symlink. Since 2019Q2, the pkgsrc 1856<varname>WRKDIR</varname> contains a symlink. Since 2019Q2, the pkgsrc
1856bootstrap program prevents installing pkgsrc in symlink-based 1857bootstrap program prevents installing pkgsrc in symlink-based
1857directories. Existing pkgsrc installations are not checked for symlinks 1858directories. Existing pkgsrc installations are not checked for symlinks
1858though.</para> 1859though.</para>
1859 1860
1860<para>The "No such file or directory" error messages are a typical 1861<para>The "No such file or directory" error messages are a typical
1861symptom of symlinks, and it's quite difficult to find out that this is 1862symptom of symlinks, and it's quite difficult to find out that this is
1862the actual cause.</para> 1863the actual cause.</para>
1863 1864
1864</sect3> 1865</sect3>
1865 1866
1866<sect3 id="fixes.build.header.stale"> 1867<sect3 id="fixes.build.header.stale">
1867<title>Stale working directories</title> 1868<title>Stale working directories</title>
1868 1869
1869<para>When building a hierarchy of packages, it may happen that one 1870<para>When building a hierarchy of packages, it may happen that one
1870package is built and then pkgsrc is updated. This situation can provoke 1871package is built and then pkgsrc is updated. This situation can provoke
1871various hard to diagnose build errors. To clean up the situation:</para> 1872various hard to diagnose build errors. To clean up the situation:</para>
1872 1873
1873<programlisting> 1874<programlisting>
1874&uprompt; (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work) 1875&uprompt; (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work)
1875</programlisting> 1876</programlisting>
1876 1877
1877<para>(The only purpose of the <filename>bsd.pkg.mk</filename> is to 1878<para>(The only purpose of the <filename>bsd.pkg.mk</filename> is to
1878prevent running this command in the wrong directory.)</para> 1879prevent running this command in the wrong directory.)</para>
1879 1880
1880<para>If you have set <varname>WRKOBJDIR</varname> in &mk.conf;, remove 1881<para>If you have set <varname>WRKOBJDIR</varname> in &mk.conf;, remove
1881that directory as well.</para> 1882that directory as well.</para>
1882 1883
1883</sect3> 1884</sect3>
1884 1885
1885<sect3 id="fixes.build.header.misc"> 1886<sect3 id="fixes.build.header.misc">
1886<title>Other possible reasons</title> 1887<title>Other possible reasons</title>
1887 1888
1888<para>On platforms other than BSD, third-party packages are installed in 1889<para>On platforms other than BSD, third-party packages are installed in
1889<filename>/usr/include</filename>, together with the base system. This 1890<filename>/usr/include</filename>, together with the base system. This
1890means that pkgsrc cannot distinguish between headers provided by the base 1891means that pkgsrc cannot distinguish between headers provided by the base
1891system (which it needs) and headers from third-party packages (which are 1892system (which it needs) and headers from third-party packages (which are
1892often included in pkgsrc as well). This can lead to subtle version 1893often included in pkgsrc as well). This can lead to subtle version
1893mismatches.</para> 1894mismatches.</para>
1894 1895
1895<para>In pkgsrc installations that have been active for several years, it 1896<para>In pkgsrc installations that have been active for several years, it
1896may happen that some files are manually deleted. To exclude this unlikely 1897may happen that some files are manually deleted. To exclude this unlikely
1897reason, run <command>pkg_admin check</command>.</para> 1898reason, run <command>pkg_admin check</command>.</para>
1898 1899
1899<para>It may help to run <command>pkg_admin rebuild-tree</command> to 1900<para>It may help to run <command>pkg_admin rebuild-tree</command> to
1900check/fix dependencies.</para> 1901check/fix dependencies.</para>
1901 1902
1902<para>If all of the above doesn't help, see <xref linkend="help-user"/> 1903<para>If all of the above doesn't help, see <xref linkend="help-user"/>
1903for contact information. Be prepared to describe what you have tried so 1904for contact information. Be prepared to describe what you have tried so
1904far and what any error messages were.</para> 1905far and what any error messages were.</para>
1905 1906
1906</sect3> 1907</sect3>
1907 1908
1908</sect2> 1909</sect2>
1909 1910
1910<sect2 id="undefined-reference"> 1911<sect2 id="undefined-reference">
1911<title>Undefined reference to <quote>...</quote></title> 1912<title>Undefined reference to <quote>...</quote></title>
1912 1913
1913 <para>This error message often means that a package did not 1914 <para>This error message often means that a package did not
1914 link to a shared library it needs. The following functions are 1915 link to a shared library it needs. The following functions are
1915 known to cause this error message over and over.</para> 1916 known to cause this error message over and over.</para>
1916 1917
1917 <informaltable id="undefined-reference-functions"> 1918 <informaltable id="undefined-reference-functions">
1918 <tgroup cols="3"> 1919 <tgroup cols="3">
1919 <thead><row><entry>Function</entry><entry>Library</entry><entry>Affected platforms</entry></row></thead> 1920 <thead><row><entry>Function</entry><entry>Library</entry><entry>Affected platforms</entry></row></thead>
1920 <tbody> 1921 <tbody>
1921 <row><entry>accept, bind, connect</entry><entry>-lsocket</entry><entry>Solaris</entry></row> 1922 <row><entry>accept, bind, connect</entry><entry>-lsocket</entry><entry>Solaris</entry></row>
1922 <row><entry>crypt</entry><entry>-lcrypt</entry><entry>DragonFly, NetBSD</entry></row> 1923 <row><entry>crypt</entry><entry>-lcrypt</entry><entry>DragonFly, NetBSD</entry></row>
1923 <row><entry>dlopen, dlsym</entry><entry>-ldl</entry><entry>Linux</entry></row> 1924 <row><entry>dlopen, dlsym</entry><entry>-ldl</entry><entry>Linux</entry></row>
1924 <row><entry>gethost*</entry><entry>-lnsl</entry><entry>Solaris</entry></row> 1925 <row><entry>gethost*</entry><entry>-lnsl</entry><entry>Solaris</entry></row>
1925 <row><entry>inet_aton</entry><entry>-lresolv</entry><entry>Solaris</entry></row> 1926 <row><entry>inet_aton</entry><entry>-lresolv</entry><entry>Solaris</entry></row>
1926 <row><entry>nanosleep, sem_*, timer_*</entry><entry>-lrt</entry><entry>Solaris</entry></row> 1927 <row><entry>nanosleep, sem_*, timer_*</entry><entry>-lrt</entry><entry>Solaris</entry></row>
1927 <row><entry>openpty</entry><entry>-lutil</entry><entry>Linux</entry></row> 1928 <row><entry>openpty</entry><entry>-lutil</entry><entry>Linux</entry></row>
1928 </tbody> 1929 </tbody>
1929 </tgroup> 1930 </tgroup>
1930 </informaltable> 1931 </informaltable>
1931 1932
1932 <para>To fix these linker errors, it is often sufficient to add 1933 <para>To fix these linker errors, it is often sufficient to add
1933 <literal>LIBS.<replaceable>OperatingSystem</replaceable>+= 1934 <literal>LIBS.<replaceable>OperatingSystem</replaceable>+=
1934 -l<replaceable>foo</replaceable></literal> to the package 1935 -l<replaceable>foo</replaceable></literal> to the package
1935 <filename>Makefile</filename> and then run <command>bmake clean; 1936 <filename>Makefile</filename> and then run <command>bmake clean;
1936 bmake</command>.</para> 1937 bmake</command>.</para>
1937 1938
1938<sect3 id="undefined-reference-sunpro"> 1939<sect3 id="undefined-reference-sunpro">
1939<title>The SunPro compiler and inline functions</title> 1940<title>The SunPro compiler and inline functions</title>
1940 1941
1941<para>When you are using the SunPro compiler, there is another 1942<para>When you are using the SunPro compiler, there is another
1942possibility. That compiler cannot handle the following code:</para> 1943possibility. That compiler cannot handle the following code:</para>
1943 1944
1944<programlisting> 1945<programlisting>
1945extern int extern_func(int); 1946extern int extern_func(int);
1946 1947
1947static inline int 1948static inline int
1948inline_func(int x) 1949inline_func(int x)
1949{ 1950{
1950 return extern_func(x); 1951 return extern_func(x);
1951} 1952}
1952 1953
1953int main(void) 1954int main(void)
1954{ 1955{
1955 return 0; 1956 return 0;
1956} 1957}
1957</programlisting> 1958</programlisting>
1958 1959
1959<para>It generates the code for <function>inline_func</function> even if 1960<para>It generates the code for <function>inline_func</function> even if
1960that function is never used. This code then refers to 1961that function is never used. This code then refers to
1961<function>extern_func</function>, which can usually not be resolved. To 1962<function>extern_func</function>, which can usually not be resolved. To
1962solve this problem you can try to tell the package to disable inlining 1963solve this problem you can try to tell the package to disable inlining
1963of functions.</para> 1964of functions.</para>
1964 1965
1965</sect3> 1966</sect3>
1966 1967
1967<sect3 id="undefined-reference-atomic"> 1968<sect3 id="undefined-reference-atomic">
1968 <title>Missing atomic functions</title> 1969 <title>Missing atomic functions</title>
1969  1970
1970 <para>When building for older machine architectures (e.g., i386, PowerPC), 1971 <para>When building for older machine architectures (e.g., i386, PowerPC),
1971 builds may fail because the package expects modern 64-bit atomic functions 1972 builds may fail because the package expects modern 64-bit atomic functions
1972 which the underlying hardware either doesn't support, or will only support 1973 which the underlying hardware either doesn't support, or will only support
1973 with specific compiler flags. This is generally handled via inclusion of 1974 with specific compiler flags. This is generally handled via inclusion of
1974 mk/atomic64.mk.</para> 1975 mk/atomic64.mk.</para>
1975</sect3> 1976</sect3>
1976 1977
1977</sect2> 1978</sect2>
1978 1979
1979 <sect2 id="out-of-memory"> 1980 <sect2 id="out-of-memory">
1980 <title>Running out of memory</title> 1981 <title>Running out of memory</title>
1981 1982
1982 <para>Sometimes packages fail to build because the compiler runs 1983 <para>Sometimes packages fail to build because the compiler runs
1983 into an operating system specific soft limit. With the 1984 into an operating system specific soft limit. With the
1984 <varname>UNLIMIT_RESOURCES</varname> variable pkgsrc can be told 1985 <varname>UNLIMIT_RESOURCES</varname> variable pkgsrc can be told
1985 to unlimit the resources. The allowed values are any combination of 1986 to unlimit the resources. The allowed values are any combination of
1986 <quote>cputime</quote>, 1987 <quote>cputime</quote>,
1987 <quote>datasize</quote>, 1988 <quote>datasize</quote>,
1988 <quote>memorysize</quote>, 1989 <quote>memorysize</quote>,
1989 <quote>stacksize</quote> and 1990 <quote>stacksize</quote> and
1990 <quote>virtualsize</quote>. 1991 <quote>virtualsize</quote>.
1991 Setting this variable is similar to running the shell builtin 1992 Setting this variable is similar to running the shell builtin
1992 <command>ulimit</command> command to raise the maximum data 1993 <command>ulimit</command> command to raise the maximum data
1993 segment size or maximum stack size of a process, respectively, to 1994 segment size or maximum stack size of a process, respectively, to
1994 their hard limits.</para> 1995 their hard limits.</para>
1995 </sect2> 1996 </sect2>
1996</sect1> 1997</sect1>
1997 1998
1998<sect1 id="fixes.install"> 1999<sect1 id="fixes.install">
1999 <title>The <emphasis>install</emphasis> phase</title> 2000 <title>The <emphasis>install</emphasis> phase</title>
2000 2001
2001 <sect2 id="install-scripts"> 2002 <sect2 id="install-scripts">
2002 <title>Creating needed directories</title> 2003 <title>Creating needed directories</title>
2003 2004
2004 <para>The BSD-compatible <command>install</command> supplied 2005 <para>The BSD-compatible <command>install</command> supplied
2005 with some operating systems cannot create more than one 2006 with some operating systems cannot create more than one
2006 directory at a time. As such, you should call 2007 directory at a time. As such, you should call
2007 <literal>${INSTALL_*_DIR}</literal> like this:</para> 2008 <literal>${INSTALL_*_DIR}</literal> like this:</para>
2008 2009
2009<programlisting> 2010<programlisting>
2010${INSTALL_DATA_DIR} ${PREFIX}/dir1 2011${INSTALL_DATA_DIR} ${PREFIX}/dir1
2011${INSTALL_DATA_DIR} ${PREFIX}/dir2 2012${INSTALL_DATA_DIR} ${PREFIX}/dir2
2012</programlisting> 2013</programlisting>
2013 2014
2014 <para>Instead of running the <command>install</command> commands 2015 <para>Instead of running the <command>install</command> commands
2015 directly, you can also append <quote><literal>dir1 2016 directly, you can also append <quote><literal>dir1
2016 dir2</literal></quote> to the <varname>INSTALLATION_DIRS</varname> 2017 dir2</literal></quote> to the <varname>INSTALLATION_DIRS</varname>
2017 variable, which will automatically do the right thing.</para> 2018 variable, which will automatically do the right thing.</para>
2018 2019
2019 </sect2> 2020 </sect2>
2020 <sect2 id="where-to-install-documentation"> 2021 <sect2 id="where-to-install-documentation">
2021 <title>Where to install documentation</title> 2022 <title>Where to install documentation</title>
2022 2023
2023 <para>In general, documentation should be installed into 2024 <para>In general, documentation should be installed into
2024 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or 2025 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or
2025 <filename>${PREFIX}/share/doc/${PKGNAME_NOREV}</filename> (the latter 2026 <filename>${PREFIX}/share/doc/${PKGNAME_NOREV}</filename> (the latter
2026 includes the version number of the package).</para> 2027 includes the version number of the package).</para>
2027 2028
2028 <para>Many modern packages using GNU autoconf allow to set the 2029 <para>Many modern packages using GNU autoconf allow to set the
2029 directory where HTML documentation is installed with the 2030 directory where HTML documentation is installed with the
2030 <quote>--with-html-dir</quote> option. Sometimes using this flag is 2031 <quote>--with-html-dir</quote> option. Sometimes using this flag is
2031 needed because otherwise the documentation ends up in 2032 needed because otherwise the documentation ends up in
2032 <filename>${PREFIX}/share/doc/html</filename> or other places. In 2033 <filename>${PREFIX}/share/doc/html</filename> or other places. In
2033 pkgsrc, the HTML documentation should go into the package-specific 2034 pkgsrc, the HTML documentation should go into the package-specific
2034 directory, just like any other documentation.</para> 2035 directory, just like any other documentation.</para>
2035 2036
2036 <para>An exception to the above is that library API documentation 2037 <para>An exception to the above is that library API documentation
2037 generated with the <filename 2038 generated with the <filename
2038 role="pkg">textproc/gtk-doc</filename> tools, for use by special 2039 role="pkg">textproc/gtk-doc</filename> tools, for use by special
2039 browsers (devhelp) should be left at their default location, which 2040 browsers (devhelp) should be left at their default location, which
2040 is <filename>${PREFIX}/share/gtk-doc</filename>. Such 2041 is <filename>${PREFIX}/share/gtk-doc</filename>. Such
2041 documentation can be recognized from files ending in 2042 documentation can be recognized from files ending in
2042 <filename>.devhelp</filename> or <filename>.devhelp2</filename>. 2043 <filename>.devhelp</filename> or <filename>.devhelp2</filename>.
2043 (It is also acceptable to install such files in 2044 (It is also acceptable to install such files in
2044 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or 2045 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or
2045 <filename>${PREFIX}/share/doc/${PKGNAME}</filename>; the 2046 <filename>${PREFIX}/share/doc/${PKGNAME}</filename>; the
2046 <filename>.devhelp*</filename> file must be directly in that 2047 <filename>.devhelp*</filename> file must be directly in that
2047 directory then, no additional subdirectory level is allowed in 2048 directory then, no additional subdirectory level is allowed in
2048 this case. This is usually achieved by using 2049 this case. This is usually achieved by using
2049 <quote>--with-html-dir=${PREFIX}/share/doc</quote>. 2050 <quote>--with-html-dir=${PREFIX}/share/doc</quote>.
2050 <filename>${PREFIX}/share/gtk-doc</filename> is preferred 2051 <filename>${PREFIX}/share/gtk-doc</filename> is preferred
2051 though.)</para> 2052 though.)</para>
2052 2053
2053 </sect2> 2054 </sect2>
2054 2055
2055 <sect2 id="installing-score-files"> 2056 <sect2 id="installing-score-files">
2056 <title>Installing highscore files</title> 2057 <title>Installing highscore files</title>
2057 2058
2058 <para>Certain packages, most of them in the games category, install 2059 <para>Certain packages, most of them in the games category, install
2059 a score file that allows all users on the system to record their 2060 a score file that allows all users on the system to record their
2060 highscores. In order for this to work, the binaries need to be 2061 highscores. In order for this to work, the binaries need to be
2061 installed setgid and the score files owned by the appropriate 2062 installed setgid and the score files owned by the appropriate
2062 group and/or owner (traditionally the "games" user/group). Set 2063 group and/or owner (traditionally the "games" user/group). Set
2063 <varname>USE_GAMESGROUP</varname> to yes to support this. The 2064 <varname>USE_GAMESGROUP</varname> to yes to support this. The
2064 following variables, documented in more detail in 2065 following variables, documented in more detail in
2065 <filename>mk/defaults/mk.conf</filename>, control this 2066 <filename>mk/defaults/mk.conf</filename>, control this
2066 behaviour: <varname>GAMEDATAMODE</varname>, 2067 behaviour: <varname>GAMEDATAMODE</varname>,
2067 <varname>GAMEDIRMODE</varname>, <varname>GAMES_GROUP</varname>, 2068 <varname>GAMEDIRMODE</varname>, <varname>GAMES_GROUP</varname>,
2068 <varname>GAMEMODE</varname>, <varname>GAME_USER</varname>. 2069 <varname>GAMEMODE</varname>, <varname>GAME_USER</varname>.
2069 Other useful variables are: <varname>GAMEDIR_PERMS</varname>, 2070 Other useful variables are: <varname>GAMEDIR_PERMS</varname>,
2070 <varname>GAMEDATA_PERMS</varname> and 2071 <varname>GAMEDATA_PERMS</varname> and
2071 <varname>SETGID_GAMES_PERMS</varname>.</para> 2072 <varname>SETGID_GAMES_PERMS</varname>.</para>
2072 2073
2073 <para>An example that illustrates some of the variables described above is 2074 <para>An example that illustrates some of the variables described above is
2074 <filename>games/moon-buggy</filename>. <varname>OWN_DIRS_PERMS</varname> is 2075 <filename>games/moon-buggy</filename>. <varname>OWN_DIRS_PERMS</varname> is
2075 used to properly set directory permissions of the directory where the 2076 used to properly set directory permissions of the directory where the
2076 scorefile is saved, <varname>REQD_FILES_PERMS</varname> is used to create a 2077 scorefile is saved, <varname>REQD_FILES_PERMS</varname> is used to create a
2077 dummy scorefile (<filename>mbscore</filename>) with the proper permissions 2078 dummy scorefile (<filename>mbscore</filename>) with the proper permissions
2078 and <varname>SPECIAL_PERMS</varname> is used to install setgid the game 2079 and <varname>SPECIAL_PERMS</varname> is used to install setgid the game
2079 binary:</para> 2080 binary:</para>
2080 2081
2081<programlisting> 2082<programlisting>
2082USE_GAMESGROUP= yes 2083USE_GAMESGROUP= yes
2083 2084
2084BUILD_DEFS+= VARBASE 2085BUILD_DEFS+= VARBASE
2085 2086
2086OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS} 2087OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
2087REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS} 2088REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
2088SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS} 2089SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
2089</programlisting> 2090</programlisting>
2090 2091
2091 <para>Various <varname>INSTALL_*</varname> variables are also available: 2092 <para>Various <varname>INSTALL_*</varname> variables are also available:
2092 <varname>INSTALL_GAME</varname> to install setgid game binaries, 2093 <varname>INSTALL_GAME</varname> to install setgid game binaries,
2093 <varname>INSTALL_GAME_DIR</varname> to install game directories that are 2094 <varname>INSTALL_GAME_DIR</varname> to install game directories that are
2094 needed to be accessed by setgid games and 2095 needed to be accessed by setgid games and
2095 <varname>INSTALL_GAME_DATA</varname> to install scorefiles.</para> 2096 <varname>INSTALL_GAME_DATA</varname> to install scorefiles.</para>
2096 2097
2097 <para>A package should therefore never hard code file ownership or 2098 <para>A package should therefore never hard code file ownership or
2098 access permissions but rely on <varname>*_PERMS</varname> as described above 2099 access permissions but rely on <varname>*_PERMS</varname> as described above
2099 or alternatively on <varname>INSTALL_GAME</varname>, 2100 or alternatively on <varname>INSTALL_GAME</varname>,
2100 <varname>INSTALL_GAME_DATA</varname> and 2101 <varname>INSTALL_GAME_DATA</varname> and
2101 <varname>INSTALL_GAME_DIR</varname> to set these correctly.</para> 2102 <varname>INSTALL_GAME_DIR</varname> to set these correctly.</para>
2102 </sect2> 2103 </sect2>
2103 2104
2104 <sect2 id="destdir-support"> 2105 <sect2 id="destdir-support">
2105 <title>Adding DESTDIR support to packages</title> 2106 <title>Adding DESTDIR support to packages</title>
2106 2107
2107 <para><varname>DESTDIR</varname> support means that a package 2108 <para><varname>DESTDIR</varname> support means that a package
2108 installs into a staging directory, not the final location of the 2109 installs into a staging directory, not the final location of the
2109 files. Then a binary package is created which can be used for 2110 files. Then a binary package is created which can be used for
2110 installation as usual. There are two ways: Either the package must 2111 installation as usual. There are two ways: Either the package must
2111 install as root (<quote>destdir</quote>) or the package can 2112 install as root (<quote>destdir</quote>) or the package can
2112 install as non-root user (<quote>user-destdir</quote>).</para> 2113 install as non-root user (<quote>user-destdir</quote>).</para>
2113 2114
2114 <itemizedlist> 2115 <itemizedlist>
2115 <listitem><para><varname>PKG_DESTDIR_SUPPORT</varname> has to be 2116 <listitem><para><varname>PKG_DESTDIR_SUPPORT</varname> has to be
2116 set to <quote>destdir</quote> or <quote>user-destdir</quote>. 2117 set to <quote>destdir</quote> or <quote>user-destdir</quote>.
2117 By default <varname>PKG_DESTDIR_SUPPORT</varname> 2118 By default <varname>PKG_DESTDIR_SUPPORT</varname>
2118 is set to <quote>user-destdir</quote> to help catching more 2119 is set to <quote>user-destdir</quote> to help catching more
2119 potential packaging problems. If bsd.prefs.mk is included in the Makefile, 2120 potential packaging problems. If bsd.prefs.mk is included in the Makefile,
2120 <varname>PKG_DESTDIR_SUPPORT</varname> needs to be set before 2121 <varname>PKG_DESTDIR_SUPPORT</varname> needs to be set before
2121 the inclusion.</para></listitem> 2122 the inclusion.</para></listitem>
2122 2123
2123 <listitem><para>All installation operations have to be prefixed with 2124 <listitem><para>All installation operations have to be prefixed with
2124 <filename>${DESTDIR}</filename>.</para></listitem> 2125 <filename>${DESTDIR}</filename>.</para></listitem>
2125 2126
2126 <listitem><para>automake gets this DESTDIR mostly right 2127 <listitem><para>automake gets this DESTDIR mostly right
2127 automatically. Many manual rules and pre/post-install often are 2128 automatically. Many manual rules and pre/post-install often are
2128 incorrect; fix them.</para></listitem> 2129 incorrect; fix them.</para></listitem>
2129 2130
2130 <listitem><para>If files are installed with special owner/group 2131 <listitem><para>If files are installed with special owner/group
2131 use <varname>SPECIAL_PERMS</varname>.</para></listitem> 2132 use <varname>SPECIAL_PERMS</varname>.</para></listitem>
2132 2133
2133 <listitem><para>In general, packages should support 2134 <listitem><para>In general, packages should support
2134 <varname>UNPRIVILEGED</varname> to be able to use 2135 <varname>UNPRIVILEGED</varname> to be able to use
2135 DESTDIR.</para></listitem> 2136 DESTDIR.</para></listitem>
2136 2137
2137 </itemizedlist> 2138 </itemizedlist>
2138 </sect2> 2139 </sect2>
2139 2140
2140 2141
2141 <sect2 id="hardcoded-paths"> 2142 <sect2 id="hardcoded-paths">
2142 <title>Packages with hardcoded paths to other interpreters</title> 2143 <title>Packages with hardcoded paths to other interpreters</title>
2143 2144
2144 <para>Your package may also contain scripts with hardcoded paths to 2145 <para>Your package may also contain scripts with hardcoded paths to
2145 other interpreters besides (or as well as) Perl. To correct the 2146 other interpreters besides (or as well as) Perl. To correct the
2146 full pathname to the script interpreter, you need to set the 2147 full pathname to the script interpreter, you need to set the
2147 following definitions in your <filename>Makefile</filename> (we 2148 following definitions in your <filename>Makefile</filename> (we
2148 shall use <command>tclsh</command> in this example):</para> 2149 shall use <command>tclsh</command> in this example):</para>
2149 2150
2150<programlisting> 2151<programlisting>
2151REPLACE_INTERPRETER+= tcl 2152REPLACE_INTERPRETER+= tcl
2152REPLACE.tcl.old= .*/bin/tclsh 2153REPLACE.tcl.old= .*/bin/tclsh
2153REPLACE.tcl.new= ${PREFIX}/bin/tclsh 2154REPLACE.tcl.new= ${PREFIX}/bin/tclsh
2154REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed, 2155REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
2155# relative to ${WRKSRC}, just as in REPLACE_PERL 2156# relative to ${WRKSRC}, just as in REPLACE_PERL
2156</programlisting> 2157</programlisting>
2157 2158
2158 </sect2> 2159 </sect2>
2159 2160
2160 2161
2161 <sect2 id="perl-modules"> 2162 <sect2 id="perl-modules">
2162 <title>Packages installing Perl modules</title> 2163 <title>Packages installing Perl modules</title>
2163 2164
2164 <para>Makefiles of packages providing perl5 modules should include 2165 <para>Makefiles of packages providing perl5 modules should include
2165 the Makefile fragment 2166 the Makefile fragment
2166 <filename>../../lang/perl5/module.mk</filename>. It provides a 2167 <filename>../../lang/perl5/module.mk</filename>. It provides a
2167 <command>do-configure</command> target for the standard perl 2168 <command>do-configure</command> target for the standard perl
2168 configuration for such modules as well as various hooks to tune 2169 configuration for such modules as well as various hooks to tune
2169 this configuration. See comments in this file for 2170 this configuration. See comments in this file for
2170 details.</para> 2171 details.</para>
2171 2172
2172 <para>Perl5 modules will install into different places depending 2173 <para>Perl5 modules will install into different places depending
2173 on the version of perl used during the build process. To 2174 on the version of perl used during the build process. To
2174 address this, pkgsrc will append lines to the 2175 address this, pkgsrc will append lines to the
2175 <filename>PLIST</filename> corresponding to the files listed in 2176 <filename>PLIST</filename> corresponding to the files listed in
2176 the installed <filename>.packlist</filename> file generated by 2177 the installed <filename>.packlist</filename> file generated by
2177 most perl5 modules. This is invoked by defining 2178 most perl5 modules. This is invoked by defining
2178 <varname>PERL5_PACKLIST</varname> to a space-separated list of 2179 <varname>PERL5_PACKLIST</varname> to a space-separated list of
2179 packlist files relative to <varname>PERL5_PACKLIST_DIR</varname> 2180 packlist files relative to <varname>PERL5_PACKLIST_DIR</varname>
2180 (<varname>PERL5_INSTALLVENDORARCH</varname> by default), 2181 (<varname>PERL5_INSTALLVENDORARCH</varname> by default),
2181 e.g.:</para> 2182 e.g.:</para>
2182 2183
2183<programlisting> 2184<programlisting>
2184PERL5_PACKLIST= auto/Pg/.packlist 2185PERL5_PACKLIST= auto/Pg/.packlist
2185</programlisting> 2186</programlisting>
2186 2187
2187 <para>The perl5 config variables 2188 <para>The perl5 config variables
2188 <varname>installarchlib</varname>, 2189 <varname>installarchlib</varname>,
2189 <varname>installscript</varname>, 2190 <varname>installscript</varname>,
2190 <varname>installvendorbin</varname>, 2191 <varname>installvendorbin</varname>,
2191 <varname>installvendorscript</varname>, 2192 <varname>installvendorscript</varname>,
2192 <varname>installvendorarch</varname>, 2193 <varname>installvendorarch</varname>,
2193 <varname>installvendorlib</varname>, 2194 <varname>installvendorlib</varname>,
2194 <varname>installvendorman1dir</varname>, and 2195 <varname>installvendorman1dir</varname>, and
2195 <varname>installvendorman3dir</varname> represent those 2196 <varname>installvendorman3dir</varname> represent those
2196 locations in which components of perl5 modules may be installed, 2197 locations in which components of perl5 modules may be installed,
2197 provided as variable with uppercase and prefixed with 2198 provided as variable with uppercase and prefixed with
2198 <varname>PERL5_</varname>, e.g. <varname>PERL5_INSTALLARCHLIB</varname> 2199 <varname>PERL5_</varname>, e.g. <varname>PERL5_INSTALLARCHLIB</varname>
2199 and may be used by perl5 packages that don't have a packlist. 2200 and may be used by perl5 packages that don't have a packlist.
2200 These variables are also substituted for in the 2201 These variables are also substituted for in the
2201 <filename>PLIST</filename> as uppercase prefixed with 2202 <filename>PLIST</filename> as uppercase prefixed with
2202 <varname>PERL5_SUB_</varname>.</para> 2203 <varname>PERL5_SUB_</varname>.</para>
2203 </sect2> 2204 </sect2>
2204 2205
2205 2206
2206 <sect2 id="faq.info-files"> 2207 <sect2 id="faq.info-files">
2207 <title>Packages installing info files</title> 2208 <title>Packages installing info files</title>
2208 2209
2209 <para>Some packages install info files or use the 2210 <para>Some packages install info files or use the
2210 <quote>makeinfo</quote> or <quote>install-info</quote> 2211 <quote>makeinfo</quote> or <quote>install-info</quote>
2211 commands. <varname>INFO_FILES</varname> should be defined in 2212 commands. <varname>INFO_FILES</varname> should be defined in
2212 the package Makefile so that <filename>INSTALL</filename> and 2213 the package Makefile so that <filename>INSTALL</filename> and
2213 <filename>DEINSTALL</filename> scripts will be generated to 2214 <filename>DEINSTALL</filename> scripts will be generated to
2214 handle registration of the info files in the Info directory 2215 handle registration of the info files in the Info directory
2215 file. The <quote>install-info</quote> command used for the info 2216 file. The <quote>install-info</quote> command used for the info
2216 files registration is either provided by the system, or by a 2217 files registration is either provided by the system, or by a
2217 special purpose package automatically added as dependency if 2218 special purpose package automatically added as dependency if
2218 needed.</para> 2219 needed.</para>
2219 2220
2220 <para><varname>PKGINFODIR</varname> is the directory under 2221 <para><varname>PKGINFODIR</varname> is the directory under
2221 <filename>${PREFIX}</filename> where info files are primarily 2222 <filename>${PREFIX}</filename> where info files are primarily
2222 located. <varname>PKGINFODIR</varname> defaults to 2223 located. <varname>PKGINFODIR</varname> defaults to
2223 <quote>info</quote> and can be overridden by the user.</para> 2224 <quote>info</quote> and can be overridden by the user.</para>
2224 2225
2225 <para>The info files for the package should be listed in the 2226 <para>The info files for the package should be listed in the
2226 package <filename>PLIST</filename>; however any split info files 2227 package <filename>PLIST</filename>; however any split info files
2227 need not be listed.</para> 2228 need not be listed.</para>
2228 2229
2229 <para>A package which needs the <quote>makeinfo</quote> command 2230 <para>A package which needs the <quote>makeinfo</quote> command
2230 at build time must add <quote>makeinfo</quote> to 2231 at build time must add <quote>makeinfo</quote> to
2231 <varname>USE_TOOLS</varname> in its Makefile. If a minimum 2232 <varname>USE_TOOLS</varname> in its Makefile. If a minimum
2232 version of the <quote>makeinfo</quote> command is needed it 2233 version of the <quote>makeinfo</quote> command is needed it
2233 should be noted with the <varname>TEXINFO_REQD</varname> 2234 should be noted with the <varname>TEXINFO_REQD</varname>
2234 variable in the package <filename>Makefile</filename>. By 2235 variable in the package <filename>Makefile</filename>. By
2235 default, a minimum version of 3.12 is required. If the system 2236 default, a minimum version of 3.12 is required. If the system
2236 does not provide a <command>makeinfo</command> command or if it 2237 does not provide a <command>makeinfo</command> command or if it
2237 does not match the required minimum, a build dependency on the 2238 does not match the required minimum, a build dependency on the
2238 <filename role="pkg">devel/gtexinfo</filename> package will 2239 <filename role="pkg">devel/gtexinfo</filename> package will
2239 be added automatically.</para> 2240 be added automatically.</para>
2240 2241
2241 <para>The build and installation process of the software provided 2242 <para>The build and installation process of the software provided
2242 by the package should not use the 2243 by the package should not use the
2243 <command>install-info</command> command as the registration of 2244 <command>install-info</command> command as the registration of
2244 info files is the task of the package 2245 info files is the task of the package
2245 <filename>INSTALL</filename> script, and it must use the 2246 <filename>INSTALL</filename> script, and it must use the
2246 appropriate <command>makeinfo</command> command.</para> 2247 appropriate <command>makeinfo</command> command.</para>
2247 2248
2248 <para>To achieve this goal, the pkgsrc infrastructure creates 2249 <para>To achieve this goal, the pkgsrc infrastructure creates
2249 overriding scripts for the <command>install-info</command> and 2250 overriding scripts for the <command>install-info</command> and
2250 <command>makeinfo</command> commands in a directory listed early 2251 <command>makeinfo</command> commands in a directory listed early
2251 in <varname>PATH</varname>.</para> 2252 in <varname>PATH</varname>.</para>
2252 2253
2253 <para>The script overriding <command>install-info</command> has 2254 <para>The script overriding <command>install-info</command> has
2254 no effect except the logging of a message. The script overriding 2255 no effect except the logging of a message. The script overriding
2255 <command>makeinfo</command> logs a message and according to the 2256 <command>makeinfo</command> logs a message and according to the
2256 value of <varname>TEXINFO_REQD</varname> either runs the appropriate 2257 value of <varname>TEXINFO_REQD</varname> either runs the appropriate
2257 <command>makeinfo</command> command or exit on error.</para> 2258 <command>makeinfo</command> command or exit on error.</para>
2258 </sect2> 2259 </sect2>
2259 2260
2260 <sect2 id="manpages"> 2261 <sect2 id="manpages">
2261 <title>Packages installing man pages</title> 2262 <title>Packages installing man pages</title>
2262 2263
2263 <para>All packages that install manual pages should install them 2264 <para>All packages that install manual pages should install them
2264 into the same directory, so that there is one common place to look 2265 into the same directory, so that there is one common place to look
2265 for them. In pkgsrc, this place is 2266 for them. In pkgsrc, this place is
2266 <literal>${PREFIX}/${PKGMANDIR}</literal>, and this expression 2267 <literal>${PREFIX}/${PKGMANDIR}</literal>, and this expression
2267 should be used in packages. The default for 2268 should be used in packages. The default for
2268 <varname>PKGMANDIR</varname> is 2269 <varname>PKGMANDIR</varname> is
2269 <quote><filename>man</filename></quote>. Another often-used value 2270 <quote><filename>man</filename></quote>. Another often-used value
2270 is <quote><filename>share/man</filename></quote>.</para> 2271 is <quote><filename>share/man</filename></quote>.</para>
2271 2272
2272 <note><para>The support for a custom <varname>PKGMANDIR</varname> 2273 <note><para>The support for a custom <varname>PKGMANDIR</varname>
2273 is far from complete.</para></note> 2274 is far from complete.</para></note>
2274 2275
2275 <para>The <filename>PLIST</filename> files can just use 2276 <para>The <filename>PLIST</filename> files can just use
2276 <filename>man/</filename> as the top level directory for the man 2277 <filename>man/</filename> as the top level directory for the man
2277 page file entries, and the pkgsrc framework will convert as 2278 page file entries, and the pkgsrc framework will convert as
2278 needed. In all other places, the correct 2279 needed. In all other places, the correct
2279 <varname>PKGMANDIR</varname> must be used.</para> 2280 <varname>PKGMANDIR</varname> must be used.</para>
2280 2281
2281 <para>Packages that are 2282 <para>Packages that are
2282 configured with <varname>GNU_CONFIGURE</varname> set as 2283 configured with <varname>GNU_CONFIGURE</varname> set as
2283 <quote>yes</quote>, by default will use the 2284 <quote>yes</quote>, by default will use the
2284 <filename>./configure</filename> 2285 <filename>./configure</filename>
2285 --mandir switch to set where the man pages should be installed. 2286 --mandir switch to set where the man pages should be installed.
2286 The path is <varname>GNU_CONFIGURE_MANDIR</varname> which defaults 2287 The path is <varname>GNU_CONFIGURE_MANDIR</varname> which defaults
2287 to <varname>${PREFIX}/${PKGMANDIR}</varname>.</para> 2288 to <varname>${PREFIX}/${PKGMANDIR}</varname>.</para>
2288 2289
2289 <para>Packages that use <varname>GNU_CONFIGURE</varname> but do not 2290 <para>Packages that use <varname>GNU_CONFIGURE</varname> but do not
2290 use --mandir, can set <varname>CONFIGURE_HAS_MANDIR</varname> 2291 use --mandir, can set <varname>CONFIGURE_HAS_MANDIR</varname>
2291 to <quote>no</quote>. 2292 to <quote>no</quote>.
2292 Or if the <filename>./configure</filename> script uses 2293 Or if the <filename>./configure</filename> script uses
2293 a non-standard use of --mandir, you can set 2294 a non-standard use of --mandir, you can set
2294 <varname>GNU_CONFIGURE_MANDIR</varname> as needed.</para> 2295 <varname>GNU_CONFIGURE_MANDIR</varname> as needed.</para>
2295 2296
2296 <para>See <xref linkend="manpage-compression"/> for 2297 <para>See <xref linkend="manpage-compression"/> for
2297 information on installation of compressed manual pages.</para> 2298 information on installation of compressed manual pages.</para>
2298 2299
2299 </sect2> 2300 </sect2>
2300 2301
2301 <sect2 id="x11-fonts"> 2302 <sect2 id="x11-fonts">
2302 <title>Packages installing X11 fonts</title> 2303 <title>Packages installing X11 fonts</title>
2303 2304
2304 <para>If a package installs font files, you will need to rebuild 2305 <para>If a package installs font files, you will need to rebuild
2305 the fonts database in the directory where they get installed at 2306 the fonts database in the directory where they get installed at
2306 installation and deinstallation time. This can be automatically 2307 installation and deinstallation time. This can be automatically
2307 done by using the pkginstall framework.</para> 2308 done by using the pkginstall framework.</para>
2308 2309
2309 <para>You can list the directories where fonts are installed in the 2310 <para>You can list the directories where fonts are installed in the
2310 <varname>FONTS_DIRS.<replaceable>type</replaceable></varname> 2311 <varname>FONTS_DIRS.<replaceable>type</replaceable></varname>
2311 variables, where <replaceable>type</replaceable> can be one of 2312 variables, where <replaceable>type</replaceable> can be one of
2312 <quote>ttf</quote>, <quote>type1</quote> or <quote>x11</quote>. 2313 <quote>ttf</quote>, <quote>type1</quote> or <quote>x11</quote>.
2313 Also make sure that the database file 2314 Also make sure that the database file
2314 <filename>fonts.dir</filename> is not listed in the PLIST.</para> 2315 <filename>fonts.dir</filename> is not listed in the PLIST.</para>
2315 2316
2316 <para>Note that you should not create new directories for fonts; 2317 <para>Note that you should not create new directories for fonts;
2317 instead use the standard ones to avoid that the user needs to 2318 instead use the standard ones to avoid that the user needs to
2318 manually configure his X server to find them.</para> 2319 manually configure his X server to find them.</para>
2319 </sect2> 2320 </sect2>
2320 2321
2321 <sect2 id="sgml-xml-data"> 2322 <sect2 id="sgml-xml-data">
2322 <title>Packages installing SGML or XML data</title> 2323 <title>Packages installing SGML or XML data</title>
2323 2324
2324 <para>If a package installs SGML or XML data files that need to be 2325 <para>If a package installs SGML or XML data files that need to be
2325 registered in system-wide catalogs (like DTDs, sub-catalogs, 2326 registered in system-wide catalogs (like DTDs, sub-catalogs,
2326 etc.), you need to take some extra steps:</para> 2327 etc.), you need to take some extra steps:</para>
2327 2328
2328 <orderedlist> 2329 <orderedlist>
2329 <listitem> 2330 <listitem>
2330 <para>Include 2331 <para>Include
2331 <filename>../../textproc/xmlcatmgr/catalogs.mk</filename> in 2332 <filename>../../textproc/xmlcatmgr/catalogs.mk</filename> in
2332 your <filename>Makefile</filename>, which takes care of 2333 your <filename>Makefile</filename>, which takes care of
2333 registering those files in system-wide catalogs at 2334 registering those files in system-wide catalogs at
2334 installation and deinstallation time.</para> 2335 installation and deinstallation time.</para>
2335 </listitem> 2336 </listitem>
2336 2337
2337 <listitem> 2338 <listitem>
2338 <para>Set <varname>SGML_CATALOGS</varname> to the full path of 2339 <para>Set <varname>SGML_CATALOGS</varname> to the full path of
2339 any SGML catalogs installed by the package.</para> 2340 any SGML catalogs installed by the package.</para>
2340 </listitem> 2341 </listitem>
2341 2342
2342 <listitem> 2343 <listitem>
2343 <para>Set <varname>XML_CATALOGS</varname> to the full path of 2344 <para>Set <varname>XML_CATALOGS</varname> to the full path of
2344 any XML catalogs installed by the package.</para> 2345 any XML catalogs installed by the package.</para>
2345 </listitem> 2346 </listitem>
2346 2347
2347 <listitem> 2348 <listitem>
2348 <para>Set <varname>SGML_ENTRIES</varname> to individual entries 2349 <para>Set <varname>SGML_ENTRIES</varname> to individual entries
2349 to be added to the SGML catalog. These come in groups of 2350 to be added to the SGML catalog. These come in groups of
2350 three strings; see xmlcatmgr(1) for more information 2351 three strings; see xmlcatmgr(1) for more information
2351 (specifically, arguments recognized by the 'add' action). 2352 (specifically, arguments recognized by the 'add' action).
2352 Note that you will normally not use this variable.</para> 2353 Note that you will normally not use this variable.</para>
2353 </listitem> 2354 </listitem>
2354 2355
2355 <listitem> 2356 <listitem>
2356 <para>Set <varname>XML_ENTRIES</varname> to individual entries 2357 <para>Set <varname>XML_ENTRIES</varname> to individual entries
2357 to be added to the XML catalog. These come in groups of three 2358 to be added to the XML catalog. These come in groups of three
2358 strings; see xmlcatmgr(1) for more information (specifically, 2359 strings; see xmlcatmgr(1) for more information (specifically,
2359 arguments recognized by the 'add' action). Note that you will 2360 arguments recognized by the 'add' action). Note that you will
2360 normally not use this variable.</para> 2361 normally not use this variable.</para>
2361 </listitem> 2362 </listitem>
2362 </orderedlist> 2363 </orderedlist>
2363 </sect2> 2364 </sect2>
2364 2365
2365 2366
2366 <sect2 id="mime-database"> 2367 <sect2 id="mime-database">
2367 <title>Packages installing extensions to the MIME database</title> 2368 <title>Packages installing extensions to the MIME database</title>
2368 2369
2369 <para>If a package provides extensions to the MIME database by 2370 <para>If a package provides extensions to the MIME database by
2370 installing <filename>.xml</filename> files inside 2371 installing <filename>.xml</filename> files inside
2371 <filename>${PREFIX}/share/mime/packages</filename>, you 2372 <filename>${PREFIX}/share/mime/packages</filename>, you
2372 need to take some extra steps to ensure that the database is kept 2373 need to take some extra steps to ensure that the database is kept
2373 consistent with respect to these new files:</para> 2374 consistent with respect to these new files:</para>
2374 2375
2375 <orderedlist> 2376 <orderedlist>
2376 <listitem> 2377 <listitem>
2377 <para>Include 2378 <para>Include
2378 <filename>../../databases/shared-mime-info/mimedb.mk</filename> 2379 <filename>../../databases/shared-mime-info/mimedb.mk</filename>
2379 (avoid using the <filename>buildlink3.mk</filename> file from 2380 (avoid using the <filename>buildlink3.mk</filename> file from
2380 this same directory, which is reserved for inclusion from 2381 this same directory, which is reserved for inclusion from
2381 other <filename>buildlink3.mk</filename> files). It takes 2382 other <filename>buildlink3.mk</filename> files). It takes
2382 care of rebuilding the MIME database at installation and 2383 care of rebuilding the MIME database at installation and
2383 deinstallation time, and disallows any access to it directly 2384 deinstallation time, and disallows any access to it directly
2384 from the package.</para> 2385 from the package.</para>
2385 </listitem> 2386 </listitem>
2386 2387
2387 <listitem> 2388 <listitem>
2388 <para>Check the PLIST and remove any entries under the 2389 <para>Check the PLIST and remove any entries under the
2389 <filename>share/mime</filename> directory, 2390 <filename>share/mime</filename> directory,
2390 <emphasis>except</emphasis> for files saved under 2391 <emphasis>except</emphasis> for files saved under
2391 <filename>share/mime/packages</filename>. The former are 2392 <filename>share/mime/packages</filename>. The former are
2392 handled automatically by 2393 handled automatically by
2393 the update-mime-database program, but the latter are 2394 the update-mime-database program, but the latter are
2394 package-dependent and must be removed by the package that 2395 package-dependent and must be removed by the package that
2395 installed them in the first place.</para> 2396 installed them in the first place.</para>
2396 </listitem> 2397 </listitem>
2397 2398
2398 <listitem> 2399 <listitem>
2399 <para>Remove any <filename>share/mime/*</filename> directories 2400 <para>Remove any <filename>share/mime/*</filename> directories
2400 from the PLIST. They will be handled by the shared-mime-info 2401 from the PLIST. They will be handled by the shared-mime-info
2401 package.</para> 2402 package.</para>
2402 </listitem> 2403 </listitem>
2403 </orderedlist> 2404 </orderedlist>
2404 </sect2> 2405 </sect2>
2405 2406
2406 2407
2407 <sect2 id="intltool"> 2408 <sect2 id="intltool">
2408 <title>Packages using intltool</title> 2409 <title>Packages using intltool</title>
2409 2410
2410 <para>If a package uses intltool during its build, add 2411 <para>If a package uses intltool during its build, add
2411 <literal>intltool</literal> to the <varname>USE_TOOLS</varname>, 2412 <literal>intltool</literal> to the <varname>USE_TOOLS</varname>,
2412 which forces it to use the intltool package provided by pkgsrc, 2413 which forces it to use the intltool package provided by pkgsrc,
2413 instead of the one bundled with the distribution file.</para> 2414 instead of the one bundled with the distribution file.</para>
2414 2415
2415 <para>This tracks intltool's build-time dependencies and uses the 2416 <para>This tracks intltool's build-time dependencies and uses the
2416 latest available version; this way, the package benefits of any 2417 latest available version; this way, the package benefits of any
2417 bug fixes that may have appeared since it was released.</para> 2418 bug fixes that may have appeared since it was released.</para>
2418 </sect2> 2419 </sect2>
2419 2420
2420 2421
2421 <sect2 id="startup-scripts"> 2422 <sect2 id="startup-scripts">
2422 <title>Packages installing startup scripts</title> 2423 <title>Packages installing startup scripts</title>
2423 <para>If a package contains a rc.d script, it won't be copied into 2424 <para>If a package contains a rc.d script, it won't be copied into
2424 the startup directory by default, but you can enable it, by adding 2425 the startup directory by default, but you can enable it, by adding
2425 the option <varname>PKG_RCD_SCRIPTS=YES</varname> in 2426 the option <varname>PKG_RCD_SCRIPTS=YES</varname> in
2426 &mk.conf;. This option will copy the scripts 2427 &mk.conf;. This option will copy the scripts
2427 into <filename>/etc/rc.d</filename> when a package is installed, and 2428 into <filename>/etc/rc.d</filename> when a package is installed, and
2428 it will automatically remove the scripts when the package is 2429 it will automatically remove the scripts when the package is
2429 deinstalled.</para> 2430 deinstalled.</para>
2430 </sect2> 2431 </sect2>
2431 2432
2432 <sect2 id="tex-packages"> 2433 <sect2 id="tex-packages">
2433 <title>Packages installing TeX modules</title> 2434 <title>Packages installing TeX modules</title>
2434 2435
2435 <para>If a package installs TeX packages into the texmf tree, 2436 <para>If a package installs TeX packages into the texmf tree,
2436 the <filename>ls-R</filename> database of the tree needs to be 2437 the <filename>ls-R</filename> database of the tree needs to be
2437 updated.</para> 2438 updated.</para>
2438 <note><para>Except the main TeX packages such as kpathsea, 2439 <note><para>Except the main TeX packages such as kpathsea,
2439 packages should install files 2440 packages should install files
2440 into <filename>${PREFIX}/share/texmf-dist</filename>, 2441 into <filename>${PREFIX}/share/texmf-dist</filename>,
2441 not <filename>${PREFIX}/share/texmf</filename>.</para></note> 2442 not <filename>${PREFIX}/share/texmf</filename>.</para></note>
2442 2443
2443 <orderedlist> 2444 <orderedlist>
2444 <listitem><para>Include 2445 <listitem><para>Include
2445 <filename>../../print/kpathsea/texmf.mk</filename>. This 2446 <filename>../../print/kpathsea/texmf.mk</filename>. This
2446 takes care of rebuilding the <filename>ls-R</filename> 2447 takes care of rebuilding the <filename>ls-R</filename>
2447 database at installation and deinstallation time.</para> 2448 database at installation and deinstallation time.</para>
2448 </listitem> 2449 </listitem>
2449 2450
2450 <listitem><para>If your package installs files into a texmf 2451 <listitem><para>If your package installs files into a texmf
2451 tree other than the one 2452 tree other than the one
2452 at <filename>${PREFIX}/share/texmf-dist</filename>, 2453 at <filename>${PREFIX}/share/texmf-dist</filename>,
2453 set <varname>TEX_TEXMF_DIRS</varname> to the list of all texmf 2454 set <varname>TEX_TEXMF_DIRS</varname> to the list of all texmf
2454 trees that need database update.</para> 2455 trees that need database update.</para>
2455 <para>If your package also installs font map files that need 2456 <para>If your package also installs font map files that need
2456 to be registered using <command>updmap</command>, 2457 to be registered using <command>updmap</command>,
2457 include <filename>../../print/tex-tetex/map.mk</filename> and 2458 include <filename>../../print/tex-tetex/map.mk</filename> and
2458 set <varname>TEX_MAP_FILES</varname> and/or 2459 set <varname>TEX_MAP_FILES</varname> and/or
2459 <varname>TEX_MIXEDMAP_FILES</varname> to the list of all 2460 <varname>TEX_MIXEDMAP_FILES</varname> to the list of all
2460 such font map files. Then <command>updmap</command> will 2461 such font map files. Then <command>updmap</command> will

cvs diff -r1.101 -r1.102 pkgsrc/mk/compiler.mk (switch to unified diff)

--- pkgsrc/mk/compiler.mk 2023/07/21 08:29:56 1.101
+++ pkgsrc/mk/compiler.mk 2023/07/22 12:20:37 1.102
@@ -1,329 +1,329 @@ @@ -1,329 +1,329 @@
1# $NetBSD: compiler.mk,v 1.101 2023/07/21 08:29:56 nia Exp $ 1# $NetBSD: compiler.mk,v 1.102 2023/07/22 12:20:37 nia Exp $
2# 2#
3# This Makefile fragment implements handling for supported C/C++/Fortran 3# This Makefile fragment implements handling for supported C/C++/Fortran
4# compilers. 4# compilers.
5# 5#
6# The following variables may be set by the pkgsrc user in mk.conf: 6# The following variables may be set by the pkgsrc user in mk.conf:
7# 7#
8# PKGSRC_COMPILER 8# PKGSRC_COMPILER
9# A list of values specifying the chain of compilers to be used by 9# A list of values specifying the chain of compilers to be used by
10# pkgsrc to build packages. 10# pkgsrc to build packages.
11# 11#
12# Valid values are: 12# Valid values are:
13# ccc Compaq C Compilers (Tru64) 13# ccc Compaq C Compilers (Tru64)
14# ccache compiler cache (chainable) 14# ccache compiler cache (chainable)
15# clang Clang C and Objective-C compiler 15# clang Clang C and Objective-C compiler
16# distcc distributed C/C++ (chainable) 16# distcc distributed C/C++ (chainable)
17# f2c Fortran 77 to C compiler (chainable) 17# f2c Fortran 77 to C compiler (chainable)
18# icc Intel C++ Compiler (Linux) 18# icc Intel C++ Compiler (Linux)
19# ido SGI IRIS Development Option cc (IRIX 5) 19# ido SGI IRIS Development Option cc (IRIX 5)
20# gcc GNU 20# gcc GNU
21# hp HP-UX C/aC++ compilers 21# hp HP-UX C/aC++ compilers
22# mipspro Silicon Graphics, Inc. MIPSpro (n32/n64) 22# mipspro Silicon Graphics, Inc. MIPSpro (n32/n64)
23# mipspro-ucode Silicon Graphics, Inc. MIPSpro (o32) 23# mipspro-ucode Silicon Graphics, Inc. MIPSpro (o32)
24# pcc Portable C Compiler 24# pcc Portable C Compiler
25# sunpro Sun Microsystems, Inc. WorkShip/Forte/Sun 25# sunpro Sun Microsystems, Inc. WorkShip/Forte/Sun
26# ONE Studio 26# ONE Studio
27# xlc IBM's XL C/C++ compiler suite (Darwin/MacOSX) 27# xlc IBM's XL C/C++ compiler suite (Darwin/MacOSX)
28# 28#
29# The default is "gcc". You can use ccache and/or distcc with 29# The default is "gcc". You can use ccache and/or distcc with
30# an appropriate PKGSRC_COMPILER setting, e.g. "ccache distcc 30# an appropriate PKGSRC_COMPILER setting, e.g. "ccache distcc
31# gcc". You can also use "f2c" to overlay the lang/f2c package 31# gcc". You can also use "f2c" to overlay the lang/f2c package
32# over the C compiler instead of using the system Fortran 32# over the C compiler instead of using the system Fortran
33# compiler. The chain should always end in a real compiler. 33# compiler. The chain should always end in a real compiler.
34# This should only be set in /etc/mk.conf. 34# This should only be set in /etc/mk.conf.
35# 35#
36# COMPILER_USE_SYMLINKS 36# COMPILER_USE_SYMLINKS
37# If set to yes, use symlinks for the compiler drivers, otherwise 37# If set to yes, use symlinks for the compiler drivers, otherwise
38# shell scripts are created. The default is yes. 38# shell scripts are created. The default is yes.
39# 39#
40# CHECK_COMPILER 40# CHECK_COMPILER
41# If set to yes, fail early if the compiler.mk variables are not 41# If set to yes, fail early if the compiler.mk variables are not
42# set correctly. 42# set correctly.
43# 43#
44# ALLOW_NEWER_COMPILER 44# ALLOW_NEWER_COMPILER
45# If set to no, fail early if a package requires newer compiler 45# If set to no, fail early if a package requires newer compiler
46# features than supported by the system's compiler. If set to 46# features than supported by the system's compiler. If set to
47# yes (the default), pkgsrc may attempt to build a newer compiler 47# yes (the default), pkgsrc may attempt to build a newer compiler
48# to use instead. 48# to use instead.
49# 49#
50# The following variables may be set by a package: 50# The following variables may be set by a package:
51# 51#
52# USE_LANGUAGES 52# USE_LANGUAGES
53# Declares the languages that should be made available via 53# Declares the languages that should be made available via
54# pkgsrc's compiler wrappers. 54# pkgsrc's compiler wrappers.
55# 55#
56# If the package assumes the compiler defaults to a specific 56# If the package assumes the compiler defaults to a specific
57# language version, the USE_LANGUAGES variable can also be used 57# language version, the USE_LANGUAGES variable can also be used
58# to force the inclusion of flags such as -std=c++11. In this case, 58# to force the inclusion of flags such as -std=c++11. In this case,
59# USE_CC_FEATURES/USE_CXX_FEATURES should also be set. 59# USE_CC_FEATURES/USE_CXX_FEATURES should also be set.
60# 60#
61# Valid values are: c, c99, gnu99, c11, gnu11, c17, gnu17, c++, c++03, 61# Valid values are: c, c99, gnu99, c11, gnu11, c17, gnu17, c++, c++03,
62# gnu++03, c++0x, gnu++0x, c++11, gnu++11, c++14, gnu++14, c++17, 62# gnu++03, c++0x, gnu++0x, c++11, gnu++11, c++14, gnu++14, c++17,
63# gnu++17, c++20, gnu++20, fortran, fortran77, java, objc, obj-c++, ada. 63# gnu++17, c++20, gnu++20, fortran, fortran77, java, objc, obj-c++, ada.
64# 64#
65# The default is "c". 65# The default is "c".
66# 66#
67# USE_CC_FEATURES 67# USE_CC_FEATURES
68# 68#
69# Declares the C compiler features required by the package. 69# Declares the C compiler features required by the package.
70# 70#
71# This is used to (optionally) install a newer compiler 71# This is used to (optionally) install a newer compiler
72# than provided by the system, or to skip building the package. 72# than provided by the system, or to skip building the package.
73# 73#
74# Valid values are: c11, c99, has_include. 74# Valid values are: c11, c99, has_include.
75# 75#
76# USE_CXX_FEATURES 76# USE_CXX_FEATURES
77# 77#
78# Declares the C++ compiler features required by the package. 78# Declares the C++ compiler features required by the package.
79# 79#
80# This is used to (optionally) install a newer compiler 80# This is used to (optionally) install a newer compiler
81# than provided by the system, to or skip building the package. 81# than provided by the system, to or skip building the package.
82# 82#
83# Valid values are: c++11, c++14, c++17, c++20, has_include, 83# Valid values are: c++11, c++14, c++17, c++20, has_include,
84# regex, filesystem, unique_ptr, charconv, parallelism_ts, 84# regex, filesystem, unique_ptr, charconv, parallelism_ts,
85# put_time. 85# put_time, is_trivially_copy_constructible.
86# 86#
87# The following variables are defined, and available for testing in 87# The following variables are defined, and available for testing in
88# package Makefiles: 88# package Makefiles:
89# 89#
90# CC_VERSION 90# CC_VERSION
91# The compiler and version being used, e.g., 91# The compiler and version being used, e.g.,
92# 92#
93# .include "../../mk/compiler.mk" 93# .include "../../mk/compiler.mk"
94# 94#
95# .if !empty(CC_VERSION:Mgcc-3*) 95# .if !empty(CC_VERSION:Mgcc-3*)
96# ... 96# ...
97# .endif 97# .endif
98# 98#
99# Keywords: compiler 99# Keywords: compiler
100 100
101.if !defined(BSD_COMPILER_MK) 101.if !defined(BSD_COMPILER_MK)
102BSD_COMPILER_MK= defined 102BSD_COMPILER_MK= defined
103 103
104_VARGROUPS+= compiler 104_VARGROUPS+= compiler
105_USER_VARS.compiler= PKGSRC_COMPILER USE_PKGSRC_GCC ABI COMPILER_USE_SYMLINKS 105_USER_VARS.compiler= PKGSRC_COMPILER USE_PKGSRC_GCC ABI COMPILER_USE_SYMLINKS
106_PKG_VARS.compiler= USE_LANGUAGES GCC_REQD NOT_FOR_COMPILER ONLY_FOR_COMPILER 106_PKG_VARS.compiler= USE_LANGUAGES GCC_REQD NOT_FOR_COMPILER ONLY_FOR_COMPILER
107_SYS_VARS.compiler= CC_VERSION 107_SYS_VARS.compiler= CC_VERSION
108 108
109.include "bsd.fast.prefs.mk" 109.include "bsd.fast.prefs.mk"
110 110
111# Since most packages need a C compiler, this is the default value. 111# Since most packages need a C compiler, this is the default value.
112USE_LANGUAGES?= c 112USE_LANGUAGES?= c
113 113
114_C_STD_VERSIONS= c99 gnu99 c11 gnu11 c17 gnu17 114_C_STD_VERSIONS= c99 gnu99 c11 gnu11 c17 gnu17
115.for _version_ in ${_C_STD_VERSIONS} 115.for _version_ in ${_C_STD_VERSIONS}
116. if !empty(USE_LANGUAGES:M${_version_}) 116. if !empty(USE_LANGUAGES:M${_version_})
117USE_LANGUAGES+= c 117USE_LANGUAGES+= c
118. endif 118. endif
119.endfor 119.endfor
120 120
121_CXX_STD_VERSIONS= gnu++20 c++20 gnu++17 c++17 gnu++14 c++14 gnu++11 c++11 gnu++0x c++0x gnu++03 c++03 121_CXX_STD_VERSIONS= gnu++20 c++20 gnu++17 c++17 gnu++14 c++14 gnu++11 c++11 gnu++0x c++0x gnu++03 c++03
122.for _version_ in ${_CXX_STD_VERSIONS} 122.for _version_ in ${_CXX_STD_VERSIONS}
123. if !empty(USE_LANGUAGES:M${_version_}) 123. if !empty(USE_LANGUAGES:M${_version_})
124USE_LANGUAGES+= c++ 124USE_LANGUAGES+= c++
125. endif 125. endif
126.endfor 126.endfor
127 127
128#.READONLY: USE_LANGUAGES 128#.READONLY: USE_LANGUAGES
129_USE_LANGUAGES_EFFECTIVE:= ${USE_LANGUAGES} 129_USE_LANGUAGES_EFFECTIVE:= ${USE_LANGUAGES}
130 130
131COMPILER_USE_SYMLINKS?= yes 131COMPILER_USE_SYMLINKS?= yes
132 132
133_COMPILERS= ccc clang gcc hp icc ido \ 133_COMPILERS= ccc clang gcc hp icc ido \
134 mipspro mipspro-ucode pcc sunpro xlc 134 mipspro mipspro-ucode pcc sunpro xlc
135_PSEUDO_COMPILERS= ccache distcc f2c g95 135_PSEUDO_COMPILERS= ccache distcc f2c g95
136 136
137.if defined(NOT_FOR_COMPILER) && !empty(NOT_FOR_COMPILER) 137.if defined(NOT_FOR_COMPILER) && !empty(NOT_FOR_COMPILER)
138. for _compiler_ in ${_COMPILERS} 138. for _compiler_ in ${_COMPILERS}
139. if ${NOT_FOR_COMPILER:M${_compiler_}} == "" 139. if ${NOT_FOR_COMPILER:M${_compiler_}} == ""
140_ACCEPTABLE_COMPILERS+= ${_compiler_} 140_ACCEPTABLE_COMPILERS+= ${_compiler_}
141. endif 141. endif
142. endfor 142. endfor
143.elif defined(ONLY_FOR_COMPILER) && !empty(ONLY_FOR_COMPILER) 143.elif defined(ONLY_FOR_COMPILER) && !empty(ONLY_FOR_COMPILER)
144. for _compiler_ in ${_COMPILERS} 144. for _compiler_ in ${_COMPILERS}
145. if ${ONLY_FOR_COMPILER:M${_compiler_}} != "" 145. if ${ONLY_FOR_COMPILER:M${_compiler_}} != ""
146_ACCEPTABLE_COMPILERS+= ${_compiler_} 146_ACCEPTABLE_COMPILERS+= ${_compiler_}
147. endif 147. endif
148. endfor 148. endfor
149.else 149.else
150_ACCEPTABLE_COMPILERS+= ${_COMPILERS} 150_ACCEPTABLE_COMPILERS+= ${_COMPILERS}
151.endif 151.endif
152 152
153# Currently only gcc-based compilers support Ada 153# Currently only gcc-based compilers support Ada
154# Override PKGSRC_COMPILER if Ada language specified 154# Override PKGSRC_COMPILER if Ada language specified
155.if !empty(USE_LANGUAGES:Mada) 155.if !empty(USE_LANGUAGES:Mada)
156PKGSRC_COMPILER= gcc 156PKGSRC_COMPILER= gcc
157.endif 157.endif
158 158
159.if defined(_ACCEPTABLE_COMPILERS) 159.if defined(_ACCEPTABLE_COMPILERS)
160. for _acceptable_ in ${_ACCEPTABLE_COMPILERS} 160. for _acceptable_ in ${_ACCEPTABLE_COMPILERS}
161. for _compiler_ in ${PKGSRC_COMPILER} 161. for _compiler_ in ${PKGSRC_COMPILER}
162. if !empty(_ACCEPTABLE_COMPILERS:M${_compiler_}) && !defined(_COMPILER) 162. if !empty(_ACCEPTABLE_COMPILERS:M${_compiler_}) && !defined(_COMPILER)
163_COMPILER= ${_compiler_} 163_COMPILER= ${_compiler_}
164. endif 164. endif
165. endfor 165. endfor
166. endfor 166. endfor
167.endif 167.endif
168 168
169.if !defined(_COMPILER) 169.if !defined(_COMPILER)
170PKG_FAIL_REASON+= "No acceptable compiler found for ${PKGNAME}." 170PKG_FAIL_REASON+= "No acceptable compiler found for ${PKGNAME}."
171.endif 171.endif
172 172
173.for _compiler_ in ${PKGSRC_COMPILER} 173.for _compiler_ in ${PKGSRC_COMPILER}
174. if !empty(_PSEUDO_COMPILERS:M${_compiler_}) 174. if !empty(_PSEUDO_COMPILERS:M${_compiler_})
175_PKGSRC_COMPILER:= ${_compiler_} ${_PKGSRC_COMPILER} 175_PKGSRC_COMPILER:= ${_compiler_} ${_PKGSRC_COMPILER}
176. endif 176. endif
177.endfor 177.endfor
178_PKGSRC_COMPILER:= ${_COMPILER} ${_PKGSRC_COMPILER} 178_PKGSRC_COMPILER:= ${_COMPILER} ${_PKGSRC_COMPILER}
179 179
180_COMPILER_STRIP_VARS= # empty 180_COMPILER_STRIP_VARS= # empty
181 181
182.for _compiler_ in ${_PKGSRC_COMPILER} 182.for _compiler_ in ${_PKGSRC_COMPILER}
183. include "compiler/${_compiler_}.mk" 183. include "compiler/${_compiler_}.mk"
184.endfor 184.endfor
185.undef _compiler_ 185.undef _compiler_
186 186
187.if !defined(PKG_CPP) 187.if !defined(PKG_CPP)
188PKG_CPP:=${CPP} 188PKG_CPP:=${CPP}
189.endif 189.endif
190 190
191# Ensure the Solaris linker is used by default. 191# Ensure the Solaris linker is used by default.
192.if ${OPSYS} == "SunOS" 192.if ${OPSYS} == "SunOS"
193. if exists(/usr/ccs/bin/ld) 193. if exists(/usr/ccs/bin/ld)
194PKG_LD?= /usr/ccs/bin/ld 194PKG_LD?= /usr/ccs/bin/ld
195. elif exists(/usr/bin/ld) 195. elif exists(/usr/bin/ld)
196PKG_LD?= /usr/bin/ld 196PKG_LD?= /usr/bin/ld
197. endif 197. endif
198.endif 198.endif
199 199
200# Strip the leading paths from the toolchain variables since we manipulate 200# Strip the leading paths from the toolchain variables since we manipulate
201# the PATH to use the correct executable. 201# the PATH to use the correct executable.
202# 202#
203.for _var_ in ${_COMPILER_STRIP_VARS} 203.for _var_ in ${_COMPILER_STRIP_VARS}
204. if empty(${_var_}:C/^/_asdf_/1:N_asdf_*) 204. if empty(${_var_}:C/^/_asdf_/1:N_asdf_*)
205${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T} 205${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T}
206. else 206. else
207${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T} ${${_var_}:C/^/_asdf_/1:N_asdf_*} 207${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T} ${${_var_}:C/^/_asdf_/1:N_asdf_*}
208. endif 208. endif
209.endfor 209.endfor
210 210
211# Pass the compiler flag based on the most recent version of the C or C++ 211# Pass the compiler flag based on the most recent version of the C or C++
212# standard required. We currently assume that each standard is a superset of 212# standard required. We currently assume that each standard is a superset of
213# all that come after it. 213# all that come after it.
214# 214#
215_C_VERSION_REQD= 215_C_VERSION_REQD=
216.for _version_ in ${_C_STD_VERSIONS} 216.for _version_ in ${_C_STD_VERSIONS}
217. if empty(_C_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_}) 217. if empty(_C_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_})
218_C_VERSION_REQD= ${_version_} 218_C_VERSION_REQD= ${_version_}
219_WRAP_EXTRA_ARGS.CC+= ${_C_STD_FLAG.${_C_VERSION_REQD}} 219_WRAP_EXTRA_ARGS.CC+= ${_C_STD_FLAG.${_C_VERSION_REQD}}
220CWRAPPERS_PREPEND.cc+= ${_C_STD_FLAG.${_C_VERSION_REQD}} 220CWRAPPERS_PREPEND.cc+= ${_C_STD_FLAG.${_C_VERSION_REQD}}
221. endif 221. endif
222.endfor 222.endfor
223 223
224_CXX_VERSION_REQD= 224_CXX_VERSION_REQD=
225.for _version_ in ${_CXX_STD_VERSIONS} 225.for _version_ in ${_CXX_STD_VERSIONS}
226. if empty(_CXX_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_}) 226. if empty(_CXX_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_})
227_CXX_VERSION_REQD= ${_version_} 227_CXX_VERSION_REQD= ${_version_}
228_WRAP_EXTRA_ARGS.CXX+= ${_CXX_STD_FLAG.${_CXX_VERSION_REQD}} 228_WRAP_EXTRA_ARGS.CXX+= ${_CXX_STD_FLAG.${_CXX_VERSION_REQD}}
229CWRAPPERS_PREPEND.cxx+= ${_CXX_STD_FLAG.${_CXX_VERSION_REQD}} 229CWRAPPERS_PREPEND.cxx+= ${_CXX_STD_FLAG.${_CXX_VERSION_REQD}}
230. endif 230. endif
231.endfor 231.endfor
232 232
233.if defined(ABI) && !empty(ABI) 233.if defined(ABI) && !empty(ABI)
234_WRAP_EXTRA_ARGS.CC+= ${_COMPILER_ABI_FLAG.${ABI}} 234_WRAP_EXTRA_ARGS.CC+= ${_COMPILER_ABI_FLAG.${ABI}}
235_WRAP_EXTRA_ARGS.CXX+= ${_COMPILER_ABI_FLAG.${ABI}} 235_WRAP_EXTRA_ARGS.CXX+= ${_COMPILER_ABI_FLAG.${ABI}}
236_WRAP_EXTRA_ARGS.FC+= ${_COMPILER_ABI_FLAG.${ABI}} 236_WRAP_EXTRA_ARGS.FC+= ${_COMPILER_ABI_FLAG.${ABI}}
237CWRAPPERS_PREPEND.cc+= ${_COMPILER_ABI_FLAG.${ABI}} 237CWRAPPERS_PREPEND.cc+= ${_COMPILER_ABI_FLAG.${ABI}}
238CWRAPPERS_PREPEND.cxx+= ${_COMPILER_ABI_FLAG.${ABI}} 238CWRAPPERS_PREPEND.cxx+= ${_COMPILER_ABI_FLAG.${ABI}}
239CWRAPPERS_PREPEND.f77+= ${_COMPILER_ABI_FLAG.${ABI}} 239CWRAPPERS_PREPEND.f77+= ${_COMPILER_ABI_FLAG.${ABI}}
240.endif 240.endif
241 241
242# Enable SSP if the user has chosen to and the compiler supports it. 242# Enable SSP if the user has chosen to and the compiler supports it.
243# 243#
244.if ${_PKGSRC_USE_SSP} == "yes" && defined(_SSP_CFLAGS) 244.if ${_PKGSRC_USE_SSP} == "yes" && defined(_SSP_CFLAGS)
245_WRAP_EXTRA_ARGS.CC+= ${_SSP_CFLAGS} 245_WRAP_EXTRA_ARGS.CC+= ${_SSP_CFLAGS}
246_WRAP_EXTRA_ARGS.CXX+= ${_SSP_CFLAGS} 246_WRAP_EXTRA_ARGS.CXX+= ${_SSP_CFLAGS}
247CWRAPPERS_APPEND.cc+= ${_SSP_CFLAGS} 247CWRAPPERS_APPEND.cc+= ${_SSP_CFLAGS}
248CWRAPPERS_APPEND.cxx+= ${_SSP_CFLAGS} 248CWRAPPERS_APPEND.cxx+= ${_SSP_CFLAGS}
249CWRAPPERS_APPEND.f77+= ${_SSP_CFLAGS} 249CWRAPPERS_APPEND.f77+= ${_SSP_CFLAGS}
250.endif 250.endif
251 251
252# Add debug flags if the user has requested CTF and the compiler supports it. 252# Add debug flags if the user has requested CTF and the compiler supports it.
253# 253#
254.if ${_PKGSRC_USE_CTF} == "yes" && defined(_CTF_CFLAGS) 254.if ${_PKGSRC_USE_CTF} == "yes" && defined(_CTF_CFLAGS)
255_WRAP_EXTRA_ARGS.CC+= ${_CTF_CFLAGS} 255_WRAP_EXTRA_ARGS.CC+= ${_CTF_CFLAGS}
256CWRAPPERS_APPEND.cc+= ${_CTF_CFLAGS} 256CWRAPPERS_APPEND.cc+= ${_CTF_CFLAGS}
257.endif 257.endif
258 258
259# Add sysroot if using cross-compilation tools. 259# Add sysroot if using cross-compilation tools.
260# 260#
261.if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS]) 261.if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS])
262CWRAPPERS_PREPEND.cc+= --sysroot=${TOOLS_CROSS_DESTDIR:Q} 262CWRAPPERS_PREPEND.cc+= --sysroot=${TOOLS_CROSS_DESTDIR:Q}
263CWRAPPERS_PREPEND.cxx+= --sysroot=${TOOLS_CROSS_DESTDIR:Q} 263CWRAPPERS_PREPEND.cxx+= --sysroot=${TOOLS_CROSS_DESTDIR:Q}
264CWRAPPERS_PREPEND.ld+= --sysroot=${TOOLS_CROSS_DESTDIR:Q} 264CWRAPPERS_PREPEND.ld+= --sysroot=${TOOLS_CROSS_DESTDIR:Q}
265# XXX cross fortran 265# XXX cross fortran
266.endif 266.endif
267 267
268# If the languages are not requested, force them not to be available 268# If the languages are not requested, force them not to be available
269# in the generated wrappers. 269# in the generated wrappers.
270# 270#
271_FAIL_WRAPPER.CC= ${WRKDIR}/.compiler/bin/c-fail-wrapper 271_FAIL_WRAPPER.CC= ${WRKDIR}/.compiler/bin/c-fail-wrapper
272_FAIL_WRAPPER.CXX= ${WRKDIR}/.compiler/bin/c++-fail-wrapper 272_FAIL_WRAPPER.CXX= ${WRKDIR}/.compiler/bin/c++-fail-wrapper
273_FAIL_WRAPPER.FC= ${WRKDIR}/.compiler/bin/fortran-fail-wrapper 273_FAIL_WRAPPER.FC= ${WRKDIR}/.compiler/bin/fortran-fail-wrapper
274_FAIL_WRAPPER.ADA= ${WRKDIR}/.compiler/bin/ada-fail-wrapper 274_FAIL_WRAPPER.ADA= ${WRKDIR}/.compiler/bin/ada-fail-wrapper
275 275
276${_FAIL_WRAPPER.CC}: fail-wrapper 276${_FAIL_WRAPPER.CC}: fail-wrapper
277${_FAIL_WRAPPER.CXX}: fail-wrapper 277${_FAIL_WRAPPER.CXX}: fail-wrapper
278${_FAIL_WRAPPER.FC}: fail-wrapper 278${_FAIL_WRAPPER.FC}: fail-wrapper
279${_FAIL_WRAPPER.ADA}: fail-wrapper 279${_FAIL_WRAPPER.ADA}: fail-wrapper
280 280
281.PHONY: fail-wrapper 281.PHONY: fail-wrapper
282fail-wrapper: .USE 282fail-wrapper: .USE
283 ${RUN} \ 283 ${RUN} \
284 ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \ 284 ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
285 exec 1>${.TARGET}; \ 285 exec 1>${.TARGET}; \
286 ${ECHO} '#!'${TOOLS_SHELL:Q}; \ 286 ${ECHO} '#!'${TOOLS_SHELL:Q}; \
287 ${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-'${_TOOLS_WRAP_LOG:Q}'}"'; \ 287 ${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-'${_TOOLS_WRAP_LOG:Q}'}"'; \
288 ${ECHO} 'lang="${.TARGET:T:S/-fail-wrapper//}"'; \ 288 ${ECHO} 'lang="${.TARGET:T:S/-fail-wrapper//}"'; \
289 ${ECHO} 'msg="*** Please consider adding $$lang to USE_LANGUAGES in the package Makefile."'; \ 289 ${ECHO} 'msg="*** Please consider adding $$lang to USE_LANGUAGES in the package Makefile."'; \
290 ${ECHO} '${ECHO} "$$msg" >> $$wrapperlog'; \ 290 ${ECHO} '${ECHO} "$$msg" >> $$wrapperlog'; \
291 ${ECHO} '${ECHO} "$$msg" > ${WARNING_DIR}/${.TARGET:T}'; \ 291 ${ECHO} '${ECHO} "$$msg" > ${WARNING_DIR}/${.TARGET:T}'; \
292 ${ECHO} '${ECHO} "PKGSRC-WARNING: Something is trying to run the $$lang compiler," 1>&2'; \ 292 ${ECHO} '${ECHO} "PKGSRC-WARNING: Something is trying to run the $$lang compiler," 1>&2'; \
293 ${ECHO} '${ECHO} "PKGSRC-WARNING: but it is not added to USE_LANGUAGES in the package Makefile." 1>&2'; \ 293 ${ECHO} '${ECHO} "PKGSRC-WARNING: but it is not added to USE_LANGUAGES in the package Makefile." 1>&2'; \
294 ${ECHO} 'exit 1'; \ 294 ${ECHO} 'exit 1'; \
295 ${CHMOD} +x ${.TARGET} 295 ${CHMOD} +x ${.TARGET}
296 296
297.if empty(USE_LANGUAGES:Mc) && empty(USE_LANGUAGES:Mobjc) && empty(USE_LANGUAGES:Mobjc-c++) 297.if empty(USE_LANGUAGES:Mc) && empty(USE_LANGUAGES:Mobjc) && empty(USE_LANGUAGES:Mobjc-c++)
298PKG_CC:= ${_FAIL_WRAPPER.CC} 298PKG_CC:= ${_FAIL_WRAPPER.CC}
299ALL_ENV+= CPP=${CPP:Q} 299ALL_ENV+= CPP=${CPP:Q}
300override-tools: ${_FAIL_WRAPPER.CC} 300override-tools: ${_FAIL_WRAPPER.CC}
301.endif 301.endif
302.if empty(USE_LANGUAGES:Mc++) 302.if empty(USE_LANGUAGES:Mc++)
303PKG_CXX:= ${_FAIL_WRAPPER.CXX} 303PKG_CXX:= ${_FAIL_WRAPPER.CXX}
304ALL_ENV+= CXXCPP=${CPP:Q} # to make some Autoconf scripts happy 304ALL_ENV+= CXXCPP=${CPP:Q} # to make some Autoconf scripts happy
305override-tools: ${_FAIL_WRAPPER.CXX} 305override-tools: ${_FAIL_WRAPPER.CXX}
306.endif 306.endif
307.if empty(USE_LANGUAGES:Mfortran) && empty(USE_LANGUAGES:Mfortran77) 307.if empty(USE_LANGUAGES:Mfortran) && empty(USE_LANGUAGES:Mfortran77)
308PKG_FC:= ${_FAIL_WRAPPER.FC} 308PKG_FC:= ${_FAIL_WRAPPER.FC}
309override-tools: ${_FAIL_WRAPPER.FC} 309override-tools: ${_FAIL_WRAPPER.FC}
310.endif 310.endif
311.if empty(USE_LANGUAGES:Mada) 311.if empty(USE_LANGUAGES:Mada)
312PKG_ADA:= ${_FAIL_WRAPPER.ADA} 312PKG_ADA:= ${_FAIL_WRAPPER.ADA}
313override-tools: ${_FAIL_WRAPPER.ADA} 313override-tools: ${_FAIL_WRAPPER.ADA}
314.endif 314.endif
315 315
316.if !empty(DRAGONFLY_CCVER) && ${OPSYS} == "DragonFly" 316.if !empty(DRAGONFLY_CCVER) && ${OPSYS} == "DragonFly"
317ALL_ENV+= CCVER=${DRAGONFLY_CCVER} 317ALL_ENV+= CCVER=${DRAGONFLY_CCVER}
318.endif 318.endif
319 319
320.endif # BSD_COMPILER_MK 320.endif # BSD_COMPILER_MK
321 321
322.if ${CHECK_COMPILER:Uno:tl} == yes 322.if ${CHECK_COMPILER:Uno:tl} == yes
323. if ${USE_LANGUAGES:O:u} != ${_USE_LANGUAGES_EFFECTIVE:O:u} 323. if ${USE_LANGUAGES:O:u} != ${_USE_LANGUAGES_EFFECTIVE:O:u}
324.warning For ${PKGPATH}, only languages "${_USE_LANGUAGES_EFFECTIVE}" are used, the others in "${USE_LANGUAGES}" were defined too late. 324.warning For ${PKGPATH}, only languages "${_USE_LANGUAGES_EFFECTIVE}" are used, the others in "${USE_LANGUAGES}" were defined too late.
325. endif 325. endif
326. if ${GCC_REQD:U:O:u} != ${_GCC_REQD_EFFECTIVE:U:O:u} 326. if ${GCC_REQD:U:O:u} != ${_GCC_REQD_EFFECTIVE:U:O:u}
327.warning For ${PKGPATH}, only GCC_REQD "${_GCC_REQD_EFFECTIVE}" are used, the others in "${GCC_REQD}" were defined too late. 327.warning For ${PKGPATH}, only GCC_REQD "${_GCC_REQD_EFFECTIVE}" are used, the others in "${GCC_REQD}" were defined too late.
328. endif 328. endif
329.endif 329.endif

cvs diff -r1.256 -r1.257 pkgsrc/mk/compiler/gcc.mk (switch to unified diff)

--- pkgsrc/mk/compiler/gcc.mk 2023/07/21 08:29:56 1.256
+++ pkgsrc/mk/compiler/gcc.mk 2023/07/22 12:20:37 1.257
@@ -1,1124 +1,1128 @@ @@ -1,1124 +1,1128 @@
1# $NetBSD: gcc.mk,v 1.256 2023/07/21 08:29:56 nia Exp $ 1# $NetBSD: gcc.mk,v 1.257 2023/07/22 12:20:37 nia Exp $
2# 2#
3# This is the compiler definition for the GNU Compiler Collection. 3# This is the compiler definition for the GNU Compiler Collection.
4# 4#
5# User-settable variables: 5# User-settable variables:
6# 6#
7# GCCBASE 7# GCCBASE
8# If using a native GCC and the compiler is not in $PATH then 8# If using a native GCC and the compiler is not in $PATH then
9# this should be set to the base installation directory. 9# this should be set to the base installation directory.
10# 10#
11# USE_NATIVE_GCC 11# USE_NATIVE_GCC
12# When set to "yes", the native gcc is used, no matter which 12# When set to "yes", the native gcc is used, no matter which
13# compiler version a package requires. 13# compiler version a package requires.
14# 14#
15# USE_PKGSRC_GCC 15# USE_PKGSRC_GCC
16# When set to "yes", use an appropriate version of GCC from 16# When set to "yes", use an appropriate version of GCC from
17# pkgsrc based on GCC_REQD instead of the native compiler. 17# pkgsrc based on GCC_REQD instead of the native compiler.
18# 18#
19# USE_PKGSRC_GCC_RUNTIME 19# USE_PKGSRC_GCC_RUNTIME
20# When set to "yes", the runtime gcc libraries (libgcc, libstdc++ 20# When set to "yes", the runtime gcc libraries (libgcc, libstdc++
21# etc) will be used from pkgsrc rather than the native compiler. 21# etc) will be used from pkgsrc rather than the native compiler.
22# 22#
23# GCC_VERSION_SUFFIX 23# GCC_VERSION_SUFFIX
24# Optional suffix for GCC binaries, i.e. if the installed names are like 24# Optional suffix for GCC binaries, i.e. if the installed names are like
25# /usr/bin/g++-5, /usr/bin/gcc-5 etc. 25# /usr/bin/g++-5, /usr/bin/gcc-5 etc.
26 26
27# Package-settable variables: 27# Package-settable variables:
28# 28#
29# GCC_REQD 29# GCC_REQD
30# The minimum version of the GNU Compiler Collection that is 30# The minimum version of the GNU Compiler Collection that is
31# required to build this package. Setting this variable doesn't 31# required to build this package. Setting this variable doesn't
32# change the compiler that is used for building packages. See 32# change the compiler that is used for building packages. See
33# ONLY_FOR_COMPILER for that purpose. This is a list of version 33# ONLY_FOR_COMPILER for that purpose. This is a list of version
34# numbers, of which the maximum version is the definitive one. 34# numbers, of which the maximum version is the definitive one.
35# 35#
36# This variable can also be set by the user when USE_PKGSRC_GCC 36# This variable can also be set by the user when USE_PKGSRC_GCC
37# is in effect to ensure that a specific compiler is used for 37# is in effect to ensure that a specific compiler is used for
38# packages which do not specify a higher version. 38# packages which do not specify a higher version.
39# 39#
40# USE_GCC_RUNTIME 40# USE_GCC_RUNTIME
41# Packages which build shared libraries but do not use libtool to 41# Packages which build shared libraries but do not use libtool to
42# do so should define this variable. It is used to determine whether 42# do so should define this variable. It is used to determine whether
43# the gcc runtime should be depended upon when a user has enabled 43# the gcc runtime should be depended upon when a user has enabled
44# USE_PKGSRC_GCC_RUNTIME. 44# USE_PKGSRC_GCC_RUNTIME.
45# 45#
46# System-defined variables: 46# System-defined variables:
47# 47#
48# CC_VERSION 48# CC_VERSION
49# A string of the form "gcc-4.3.2" 49# A string of the form "gcc-4.3.2"
50# 50#
51# CC_VERSION_STRING 51# CC_VERSION_STRING
52# The same(?) as CC_VERSION. FIXME: What's the difference between 52# The same(?) as CC_VERSION. FIXME: What's the difference between
53# the two? 53# the two?
54# 54#
55# Keywords: gcc 55# Keywords: gcc
56# 56#
57 57
58.if !defined(COMPILER_GCC_MK) 58.if !defined(COMPILER_GCC_MK)
59COMPILER_GCC_MK= defined 59COMPILER_GCC_MK= defined
60 60
61_VARGROUPS+= gcc 61_VARGROUPS+= gcc
62_USER_VARS.gcc= \ 62_USER_VARS.gcc= \
63 USE_NATIVE_GCC USE_PKGSRC_GCC USE_PKGSRC_GCC_RUNTIME \ 63 USE_NATIVE_GCC USE_PKGSRC_GCC USE_PKGSRC_GCC_RUNTIME \
64 GCCBASE GCC_VERSION_SUFFIX \ 64 GCCBASE GCC_VERSION_SUFFIX \
65 TOOLS_USE_CROSS_COMPILE \ 65 TOOLS_USE_CROSS_COMPILE \
66 PKGSRC_USE_FORTIFY PKGSRC_USE_RELRO PKGSRC_USE_SSP \ 66 PKGSRC_USE_FORTIFY PKGSRC_USE_RELRO PKGSRC_USE_SSP \
67 COMPILER_USE_SYMLINKS CC 67 COMPILER_USE_SYMLINKS CC
68_PKG_VARS.gcc= \ 68_PKG_VARS.gcc= \
69 GCC_REQD USE_GCC_RUNTIME USE_LANGUAGES 69 GCC_REQD USE_GCC_RUNTIME USE_LANGUAGES
70_SYS_VARS.gcc= \ 70_SYS_VARS.gcc= \
71 CC_VERSION CC_VERSION_STRING LANGUAGES.gcc \ 71 CC_VERSION CC_VERSION_STRING LANGUAGES.gcc \
72 CCPATH CPPPATH CXXPATH F77PATH FCPATH \ 72 CCPATH CPPPATH CXXPATH F77PATH FCPATH \
73 PKG_CC PKG_CPP PKG_CXX PKG_FC FC PKGSRC_FORTRAN \ 73 PKG_CC PKG_CPP PKG_CXX PKG_FC FC PKGSRC_FORTRAN \
74 ADAPATH GMKPATH GLKPATH GBDPATH CHPPATH GLSPATH GNTPATH PRPPATH 74 ADAPATH GMKPATH GLKPATH GBDPATH CHPPATH GLSPATH GNTPATH PRPPATH
75_DEF_VARS.gcc= \ 75_DEF_VARS.gcc= \
76 MAKEFLAGS IMAKEOPTS \ 76 MAKEFLAGS IMAKEOPTS \
77 CFLAGS LDFLAGS \ 77 CFLAGS LDFLAGS \
78 PREPEND_PATH \ 78 PREPEND_PATH \
79 COMPILER_INCLUDE_DIRS COMPILER_LIB_DIRS \ 79 COMPILER_INCLUDE_DIRS COMPILER_LIB_DIRS \
80 CWRAPPERS_APPEND.cc CWRAPPERS_APPEND.cxx CWRAPPERS_APPEND.ld \ 80 CWRAPPERS_APPEND.cc CWRAPPERS_APPEND.cxx CWRAPPERS_APPEND.ld \
81 PKG_ADA PKG_GMK PKG_GLK PKG_GBD PKG_CHP PKG_GNT PKG_GLS PKG_PRP \ 81 PKG_ADA PKG_GMK PKG_GLK PKG_GBD PKG_CHP PKG_GNT PKG_GLS PKG_PRP \
82 PKGSRC_ADA PKGSRC_GMK PKGSRC_GLK PKGSRC_GBD PKGSRC_CHP PKGSRC_GNT PKGSRC_GLS PKGSRC_PRP \ 82 PKGSRC_ADA PKGSRC_GMK PKGSRC_GLK PKGSRC_GBD PKGSRC_CHP PKGSRC_GNT PKGSRC_GLS PKGSRC_PRP \
83 _CC _COMPILER_RPATH_FLAG _COMPILER_STRIP_VARS \ 83 _CC _COMPILER_RPATH_FLAG _COMPILER_STRIP_VARS \
84 _GCCBINDIR _GCC_ARCHDIR _GCC_BIN_PREFIX _GCC_CFLAGS \ 84 _GCCBINDIR _GCC_ARCHDIR _GCC_BIN_PREFIX _GCC_CFLAGS \
85 _GCC_CC _GCC_CPP _GCC_CXX _GCC_DEPENDENCY _GCC_DEPENDS \ 85 _GCC_CC _GCC_CPP _GCC_CXX _GCC_DEPENDENCY _GCC_DEPENDS \
86 _GCC_DIST_NAME _GCC_DIST_VERSION \ 86 _GCC_DIST_NAME _GCC_DIST_VERSION \
87 _GCC_FC _GCC_LDFLAGS _GCC_LIBDIRS _GCC_PKG \ 87 _GCC_FC _GCC_LDFLAGS _GCC_LIBDIRS _GCC_PKG \
88 _GCC_PKGBASE _GCC_PKGSRCDIR _GCC_PKG_SATISFIES_DEP \ 88 _GCC_PKGBASE _GCC_PKGSRCDIR _GCC_PKG_SATISFIES_DEP \
89 _GCC_PREFIX _GCC_REQD _GCC_STRICTEST_REQD _GCC_SUBPREFIX \ 89 _GCC_PREFIX _GCC_REQD _GCC_STRICTEST_REQD _GCC_SUBPREFIX \
90 _GCC_TEST_DEPENDS _GCC_NEEDS_A_FORTRAN _GCC_VARS _GCC_VERSION \ 90 _GCC_TEST_DEPENDS _GCC_NEEDS_A_FORTRAN _GCC_VARS _GCC_VERSION \
91 _GCC_VERSION_STRING \ 91 _GCC_VERSION_STRING \
92 _GCC_ADA _GCC_GMK _GCC_GLK _GCC_GBD _GCC_CHP _GCC_GLS _GCC_GNT _GCC_PRP \ 92 _GCC_ADA _GCC_GMK _GCC_GLK _GCC_GBD _GCC_CHP _GCC_GLS _GCC_GNT _GCC_PRP \
93 _IGNORE_GCC \ 93 _IGNORE_GCC \
94 _IS_BUILTIN_GCC \ 94 _IS_BUILTIN_GCC \
95 _LANGUAGES.gcc \ 95 _LANGUAGES.gcc \
96 _LINKER_RPATH_FLAG \ 96 _LINKER_RPATH_FLAG \
97 _NEED_GCC6 _NEED_GCC7 _NEED_GCC8 _NEED_GCC9 \ 97 _NEED_GCC6 _NEED_GCC7 _NEED_GCC8 _NEED_GCC9 \
98 _NEED_GCC10 _NEED_GCC12 _NEED_GCC13 \ 98 _NEED_GCC10 _NEED_GCC12 _NEED_GCC13 \
99 _NEED_GCC_AUX _NEED_NEWER_GCC \ 99 _NEED_GCC_AUX _NEED_NEWER_GCC \
100 _PKGSRC_GCC_VERSION \ 100 _PKGSRC_GCC_VERSION \
101 _USE_GCC_SHLIB _USE_PKGSRC_GCC \ 101 _USE_GCC_SHLIB _USE_PKGSRC_GCC \
102 _WRAP_EXTRA_ARGS.CC \ 102 _WRAP_EXTRA_ARGS.CC \
103 _EXTRA_CC_DIRS \ 103 _EXTRA_CC_DIRS \
104 _C_STD_VERSIONS \ 104 _C_STD_VERSIONS \
105 ${_C_STD_VERSIONS:@std@_C_STD_FLAG.${std}@} \ 105 ${_C_STD_VERSIONS:@std@_C_STD_FLAG.${std}@} \
106 _CXX_STD_VERSIONS \ 106 _CXX_STD_VERSIONS \
107 ${_CXX_STD_VERSIONS:@std@_CXX_STD_FLAG.${std}@} \ 107 ${_CXX_STD_VERSIONS:@std@_CXX_STD_FLAG.${std}@} \
108 _MKPIE_CFLAGS.gcc _MKPIE_LDFLAGS \ 108 _MKPIE_CFLAGS.gcc _MKPIE_LDFLAGS \
109 _FORTIFY_CFLAGS _RELRO_LDFLAGS _STACK_CHECK_CFLAGS \ 109 _FORTIFY_CFLAGS _RELRO_LDFLAGS _STACK_CHECK_CFLAGS \
110 _CTF_CFLAGS \ 110 _CTF_CFLAGS \
111 _GCC_DIR \ 111 _GCC_DIR \
112 _ALIASES.CC _ALIASES.CPP _ALIASES.CXX _ALIASES.FC \ 112 _ALIASES.CC _ALIASES.CPP _ALIASES.CXX _ALIASES.FC \
113 _ALIASES.ADA _ALIASES.GMK _ALIASES.GLK _ALIASES.GBD \ 113 _ALIASES.ADA _ALIASES.GMK _ALIASES.GLK _ALIASES.GBD \
114 _ALIASES.CHP _ALIASES.PRP _ALIASES.GLS _ALIASES.GNT \ 114 _ALIASES.CHP _ALIASES.PRP _ALIASES.GLS _ALIASES.GNT \
115 _COMPILER_ABI_FLAG.32 _COMPILER_ABI_FLAG.64 \ 115 _COMPILER_ABI_FLAG.32 _COMPILER_ABI_FLAG.64 \
116 _COMPILER_ABI_FLAG.n32 _COMPILER_ABI_FLAG.o32 \ 116 _COMPILER_ABI_FLAG.n32 _COMPILER_ABI_FLAG.o32 \
117 _SSP_CFLAGS \ 117 _SSP_CFLAGS \
118 _CXX_STD_FLAG.c++03 _CXX_STD_FLAG.gnu++03 118 _CXX_STD_FLAG.c++03 _CXX_STD_FLAG.gnu++03
119_USE_VARS.gcc= \ 119_USE_VARS.gcc= \
120 MACHINE_ARCH PATH DRAGONFLY_CCVER OPSYS TOOLBASE \ 120 MACHINE_ARCH PATH DRAGONFLY_CCVER OPSYS TOOLBASE \
121 USE_LIBTOOL \ 121 USE_LIBTOOL \
122 LIBABISUFFIX \ 122 LIBABISUFFIX \
123 COMPILER_RPATH_FLAG \ 123 COMPILER_RPATH_FLAG \
124 MACHINE_GNU_PLATFORM \ 124 MACHINE_GNU_PLATFORM \
125 WRKDIR MACHINE_PLATFORM PKGPATH \ 125 WRKDIR MACHINE_PLATFORM PKGPATH \
126 _PKGSRC_MKPIE _PKGSRC_MKREPRO _MKREPRO_CFLAGS.gcc \ 126 _PKGSRC_MKPIE _PKGSRC_MKREPRO _MKREPRO_CFLAGS.gcc \
127 _PKGSRC_USE_FORTIFY _PKGSRC_USE_RELRO _PKGSRC_USE_STACK_CHECK \ 127 _PKGSRC_USE_FORTIFY _PKGSRC_USE_RELRO _PKGSRC_USE_STACK_CHECK \
128 _OPSYS_INCLUDE_DIRS _OPSYS_LIB_DIRS 128 _OPSYS_INCLUDE_DIRS _OPSYS_LIB_DIRS
129_IGN_VARS.gcc= \ 129_IGN_VARS.gcc= \
130 _GCC6_PATTERNS _GCC7_PATTERNS _GCC8_PATTERNS _GCC9_PATTERNS \ 130 _GCC6_PATTERNS _GCC7_PATTERNS _GCC8_PATTERNS _GCC9_PATTERNS \
131 _GCC10_PATTERNS _GCC12_PATTERNS _GCC13_PATTERNS _GCC_AUX_PATTERNS 131 _GCC10_PATTERNS _GCC12_PATTERNS _GCC13_PATTERNS _GCC_AUX_PATTERNS
132_LISTED_VARS.gcc= \ 132_LISTED_VARS.gcc= \
133 MAKEFLAGS IMAKEOPTS LDFLAGS PREPEND_PATH 133 MAKEFLAGS IMAKEOPTS LDFLAGS PREPEND_PATH
134.include "../../mk/bsd.prefs.mk" 134.include "../../mk/bsd.prefs.mk"
135 135
136USE_NATIVE_GCC?= no 136USE_NATIVE_GCC?= no
137USE_PKGSRC_GCC?= no 137USE_PKGSRC_GCC?= no
138USE_PKGSRC_GCC_RUNTIME?=no 138USE_PKGSRC_GCC_RUNTIME?=no
139 139
140# 140#
141# Each successive GCC_REQD has an associated cost below when executing 141# Each successive GCC_REQD has an associated cost below when executing
142# pkg_admin to determine if it's suitable, so only add these incredibly 142# pkg_admin to determine if it's suitable, so only add these incredibly
143# old versions if we haven't already set one. 143# old versions if we haven't already set one.
144# 144#
145.if !defined(GCC_REQD) 145.if !defined(GCC_REQD)
146. if !empty(USE_LANGUAGES:Mc99) || ${MACHINE_ARCH} == "x86_64" 146. if !empty(USE_LANGUAGES:Mc99) || ${MACHINE_ARCH} == "x86_64"
147GCC_REQD+= 3.0 147GCC_REQD+= 3.0
148. else 148. else
149GCC_REQD+= 2.8.0 149GCC_REQD+= 2.8.0
150. endif 150. endif
151.endif 151.endif
152 152
153# 153#
154# Most of the time, GCC adds support for features of new C and C++ 154# Most of the time, GCC adds support for features of new C and C++
155# standards incrementally, so USE_CXX_FEATURES= c++XX is for 155# standards incrementally, so USE_CXX_FEATURES= c++XX is for
156# establishing an idealistic baseline, usually based on compiler 156# establishing an idealistic baseline, usually based on compiler
157# versions shipped with NetBSD. 157# versions shipped with NetBSD.
158# 158#
159# Resources: 159# Resources:
160# https://gcc.gnu.org/projects/cxx-status.html 160# https://gcc.gnu.org/projects/cxx-status.html
161# https://gcc.gnu.org/wiki/C11Status 161# https://gcc.gnu.org/wiki/C11Status
162# https://gcc.gnu.org/c99status.html 162# https://gcc.gnu.org/c99status.html
163# 163#
164 164
165.if !empty(USE_CXX_FEATURES:Mc++20) 165.if !empty(USE_CXX_FEATURES:Mc++20)
166# GCC 10 is chosen because it is planned to be shipped with NetBSD 10, 166# GCC 10 is chosen because it is planned to be shipped with NetBSD 10,
167# so is fairly battle-hardened with pkgsrc. 167# so is fairly battle-hardened with pkgsrc.
168# 168#
169# We hope that it remains OK for most C++20 in the future... 169# We hope that it remains OK for most C++20 in the future...
170GCC_REQD+= 10 170GCC_REQD+= 10
171.endif 171.endif
172 172
173.if !empty(USE_CXX_FEATURES:Mc++17) 173.if !empty(USE_CXX_FEATURES:Mc++17)
174# GCC 7 is chosen because it shipped with NetBSD 9, so is fairly 174# GCC 7 is chosen because it shipped with NetBSD 9, so is fairly
175# battle-hardened with pkgsrc. 175# battle-hardened with pkgsrc.
176GCC_REQD+= 7 176GCC_REQD+= 7
177.endif 177.endif
178 178
179.if !empty(USE_CXX_FEATURES:Mc++14) 179.if !empty(USE_CXX_FEATURES:Mc++14)
180# GCC 5 is chosen because it shipped with NetBSD 8, so is fairly 180# GCC 5 is chosen because it shipped with NetBSD 8, so is fairly
181# battle-hardened with pkgsrc. 181# battle-hardened with pkgsrc.
182GCC_REQD+= 5 182GCC_REQD+= 5
183.endif 183.endif
184 184
185.if !empty(USE_CXX_FEATURES:Mc++11) 185.if !empty(USE_CXX_FEATURES:Mc++11)
186# While gcc "technically" added experimental C++11 support earlier 186# While gcc "technically" added experimental C++11 support earlier
187# (and there was previously a lot of cargo-culted GCC_REQD in pkgsrc 187# (and there was previously a lot of cargo-culted GCC_REQD in pkgsrc
188# as a result), earlier compiler versions are not so well-tested any more. 188# as a result), earlier compiler versions are not so well-tested any more.
189# 189#
190# GCC 4.8 was the version shipped with NetBSD 7 and CentOS 7, so is fairly 190# GCC 4.8 was the version shipped with NetBSD 7 and CentOS 7, so is fairly
191# battle-hardened with pkgsrc. 191# battle-hardened with pkgsrc.
192# 192#
193# Versions before GCC 4.7 do not accept -std=c++11. 193# Versions before GCC 4.7 do not accept -std=c++11.
194GCC_REQD+= 4.8 194GCC_REQD+= 4.8
195.endif 195.endif
196 196
197.if !empty(USE_CXX_FEATURES:Mhas_include) || \ 197.if !empty(USE_CXX_FEATURES:Mhas_include) || \
198 !empty(USE_CC_FEATURES:Mhas_include) 198 !empty(USE_CC_FEATURES:Mhas_include)
199GCC_REQD+= 5 199GCC_REQD+= 5
200.endif 200.endif
201 201
202.if !empty(USE_CC_FEATURES:Mc99) 202.if !empty(USE_CC_FEATURES:Mc99)
203GCC_REQD+= 3 203GCC_REQD+= 3
204.endif 204.endif
205 205
206.if !empty(USE_CC_FEATURES:Mc11) 206.if !empty(USE_CC_FEATURES:Mc11)
207GCC_REQD+= 4.9 207GCC_REQD+= 4.9
208.endif 208.endif
209 209
210.if !empty(USE_CXX_FEATURES:Munique_ptr) 210.if !empty(USE_CXX_FEATURES:Munique_ptr)
211GCC_REQD+= 4.9 211GCC_REQD+= 4.9
212.endif 212.endif
213 213
214.if !empty(USE_CXX_FEATURES:Mregex) 214.if !empty(USE_CXX_FEATURES:Mregex)
215GCC_REQD+= 4.9 215GCC_REQD+= 4.9
216.endif 216.endif
217 217
218.if !empty(USE_CXX_FEATURES:Mput_time) 218.if !empty(USE_CXX_FEATURES:Mput_time)
219GCC_REQD+= 5 219GCC_REQD+= 5
220.endif 220.endif
221 221
 222.if !empty(USE_CXX_FEATURES:Mis_trivially_copy_constructible)
 223GCC_REQD+= 5
 224.endif
 225
222.if !empty(USE_CXX_FEATURES:Mfilesystem) 226.if !empty(USE_CXX_FEATURES:Mfilesystem)
223GCC_REQD+= 8 227GCC_REQD+= 8
224.endif 228.endif
225 229
226.if !empty(USE_CXX_FEATURES:Mparallelism_ts) 230.if !empty(USE_CXX_FEATURES:Mparallelism_ts)
227GCC_REQD+= 10 231GCC_REQD+= 10
228.endif 232.endif
229 233
230.if !empty(USE_CXX_FEATURES:Mcharconv) 234.if !empty(USE_CXX_FEATURES:Mcharconv)
231GCC_REQD+= 8 235GCC_REQD+= 8
232.endif 236.endif
233 237
234# Only one compiler defined here supports Ada: lang/gcc6-aux 238# Only one compiler defined here supports Ada: lang/gcc6-aux
235# If the Ada language is requested, force lang/gcc6-aux to be selected 239# If the Ada language is requested, force lang/gcc6-aux to be selected
236.if !empty(USE_LANGUAGES:Mada) 240.if !empty(USE_LANGUAGES:Mada)
237GCC_REQD+= 20160822 241GCC_REQD+= 20160822
238.endif 242.endif
239 243
240# _GCC_DIST_VERSION is the highest version of GCC installed by the pkgsrc 244# _GCC_DIST_VERSION is the highest version of GCC installed by the pkgsrc
241# without the PKGREVISIONs. 245# without the PKGREVISIONs.
242_GCC_DIST_NAME:= gcc13 246_GCC_DIST_NAME:= gcc13
243.include "../../lang/${_GCC_DIST_NAME}/version.mk" 247.include "../../lang/${_GCC_DIST_NAME}/version.mk"
244_GCC_DIST_VERSION:= ${${_GCC_DIST_NAME:tu}_DIST_VERSION} 248_GCC_DIST_VERSION:= ${${_GCC_DIST_NAME:tu}_DIST_VERSION}
245 249
246# _GCC6_PATTERNS matches N s.t. N < 7. 250# _GCC6_PATTERNS matches N s.t. N < 7.
247_GCC6_PATTERNS= 5 6 [0-6].* 251_GCC6_PATTERNS= 5 6 [0-6].*
248 252
249# _GCC7_PATTERNS matches N s.t. 7.0 <= N < 8. 253# _GCC7_PATTERNS matches N s.t. 7.0 <= N < 8.
250_GCC7_PATTERNS= 7 7.* 254_GCC7_PATTERNS= 7 7.*
251 255
252# _GCC8_PATTERNS matches N s.t. 8.0 <= N < 9. 256# _GCC8_PATTERNS matches N s.t. 8.0 <= N < 9.
253_GCC8_PATTERNS= 8 8.* 257_GCC8_PATTERNS= 8 8.*
254 258
255# _GCC9_PATTERNS matches N s.t. 9.0 <= N < 10. 259# _GCC9_PATTERNS matches N s.t. 9.0 <= N < 10.
256_GCC9_PATTERNS= 9 9.* 260_GCC9_PATTERNS= 9 9.*
257 261
258# _GCC10_PATTERNS matches N s.t. 10.0 <= N < 11. 262# _GCC10_PATTERNS matches N s.t. 10.0 <= N < 11.
259_GCC10_PATTERNS= 10 10.* 263_GCC10_PATTERNS= 10 10.*
260 264
261# _GCC12_PATTERNS matches N s.t. 12.0 <= N < 13. 265# _GCC12_PATTERNS matches N s.t. 12.0 <= N < 13.
262# gcc 11.x is not packaged, so depend on gcc12 in that case too 266# gcc 11.x is not packaged, so depend on gcc12 in that case too
263_GCC12_PATTERNS= 11 11.* 12 12.* 267_GCC12_PATTERNS= 11 11.* 12 12.*
264 268
265# _GCC13_PATTERNS matches N s.t. 13.0 <= N < 14. 269# _GCC13_PATTERNS matches N s.t. 13.0 <= N < 14.
266_GCC13_PATTERNS= 13 13.* 270_GCC13_PATTERNS= 13 13.*
267 271
268# _GCC_AUX_PATTERNS matches 8-digit date YYYYMMDD* 272# _GCC_AUX_PATTERNS matches 8-digit date YYYYMMDD*
269_GCC_AUX_PATTERNS= 20[1-2][0-9][0-1][0-9][0-3][0-9]* 273_GCC_AUX_PATTERNS= 20[1-2][0-9][0-1][0-9][0-3][0-9]*
270 274
271# Override the default from sys.mk if necessary. 275# Override the default from sys.mk if necessary.
272.if ${CC} == cc && ${GCCBASE:U} && !exists(${GCCBASE}/bin/${CC}) && exists(${GCCBASE}/bin/gcc) 276.if ${CC} == cc && ${GCCBASE:U} && !exists(${GCCBASE}/bin/${CC}) && exists(${GCCBASE}/bin/gcc)
273CC= gcc 277CC= gcc
274.endif 278.endif
275 279
276# _CC is the full path to the compiler named by ${CC} if it can be found. 280# _CC is the full path to the compiler named by ${CC} if it can be found.
277.if !defined(_CC) 281.if !defined(_CC)
278_CC:= ${CC:[1]} 282_CC:= ${CC:[1]}
279. if !empty(GCCBASE) && exists(${GCCBASE}/bin) 283. if !empty(GCCBASE) && exists(${GCCBASE}/bin)
280_EXTRA_CC_DIRS= ${GCCBASE}/bin 284_EXTRA_CC_DIRS= ${GCCBASE}/bin
281. endif 285. endif
282. for _dir_ in ${_EXTRA_CC_DIRS} ${PATH:C/\:/ /g} 286. for _dir_ in ${_EXTRA_CC_DIRS} ${PATH:C/\:/ /g}
283. if empty(_CC:M/*) 287. if empty(_CC:M/*)
284. if exists(${_dir_}/${CC:[1]}) 288. if exists(${_dir_}/${CC:[1]})
285_CC:= ${_dir_}/${CC:[1]} 289_CC:= ${_dir_}/${CC:[1]}
286. endif 290. endif
287. endif 291. endif
288. endfor 292. endfor
289. if ${TOOLS_USE_CROSS_COMPILE:tl} == "no" 293. if ${TOOLS_USE_CROSS_COMPILE:tl} == "no"
290# Pass along _CC only if we're working on native packages -- don't pass 294# Pass along _CC only if we're working on native packages -- don't pass
291# the cross-compiler on to submakes for building native packages. 295# the cross-compiler on to submakes for building native packages.
292MAKEFLAGS+= _CC=${_CC:Q} 296MAKEFLAGS+= _CC=${_CC:Q}
293. endif 297. endif
294.endif 298.endif
295 299
296.if !defined(_GCC_VERSION) 300.if !defined(_GCC_VERSION)
297# 301#
298# FIXME: Ideally we'd use PKGSRC_SETENV here, but not enough of the tools 302# FIXME: Ideally we'd use PKGSRC_SETENV here, but not enough of the tools
299# infrastructure is loaded for SETENV to be defined when mk/compiler.mk is 303# infrastructure is loaded for SETENV to be defined when mk/compiler.mk is
300# included first. LC_ALL is required here for similar reasons, as ALL_ENV 304# included first. LC_ALL is required here for similar reasons, as ALL_ENV
301# is not defined at this stage. 305# is not defined at this stage.
302# 306#
303_GCC_VERSION_STRING!= \ 307_GCC_VERSION_STRING!= \
304 ( env LC_ALL=C ${_CC} -v 2>&1 | ${GREP} 'gcc version') 2>/dev/null || ${ECHO} 0 308 ( env LC_ALL=C ${_CC} -v 2>&1 | ${GREP} 'gcc version') 2>/dev/null || ${ECHO} 0
305. if !empty(_GCC_VERSION_STRING:Megcs*) 309. if !empty(_GCC_VERSION_STRING:Megcs*)
306_GCC_VERSION= 2.8.1 # egcs is considered to be gcc-2.8.1. 310_GCC_VERSION= 2.8.1 # egcs is considered to be gcc-2.8.1.
307. elif !empty(DRAGONFLY_CCVER) && ${OPSYS} == "DragonFly" 311. elif !empty(DRAGONFLY_CCVER) && ${OPSYS} == "DragonFly"
308_GCC_VERSION!= env CCVER=${DRAGONFLY_CCVER} ${_CC} -dumpversion 312_GCC_VERSION!= env CCVER=${DRAGONFLY_CCVER} ${_CC} -dumpversion
309. elif !empty(_GCC_VERSION_STRING:Mgcc*) 313. elif !empty(_GCC_VERSION_STRING:Mgcc*)
310_GCC_VERSION!= ${_CC} -dumpversion 314_GCC_VERSION!= ${_CC} -dumpversion
311. else 315. else
312_GCC_VERSION= 0 316_GCC_VERSION= 0
313. endif 317. endif
314.endif 318.endif
315_GCC_PKG= gcc-${_GCC_VERSION:C/-.*$//} 319_GCC_PKG= gcc-${_GCC_VERSION:C/-.*$//}
316 320
317.for _version_ in ${_C_STD_VERSIONS} 321.for _version_ in ${_C_STD_VERSIONS}
318_C_STD_FLAG.${_version_}?= -std=${_version_} 322_C_STD_FLAG.${_version_}?= -std=${_version_}
319.endfor 323.endfor
320# XXX: pkgsrc historically hardcoded c99=gnu99 so we retain that for now, but 324# XXX: pkgsrc historically hardcoded c99=gnu99 so we retain that for now, but
321# we should look at removing this and be explicit in packages where required. 325# we should look at removing this and be explicit in packages where required.
322_C_STD_FLAG.c99= -std=gnu99 326_C_STD_FLAG.c99= -std=gnu99
323 327
324.for _version_ in ${_CXX_STD_VERSIONS} 328.for _version_ in ${_CXX_STD_VERSIONS}
325_CXX_STD_FLAG.${_version_}?= -std=${_version_} 329_CXX_STD_FLAG.${_version_}?= -std=${_version_}
326.endfor 330.endfor
327.if !empty(_GCC_VERSION:M[34].[1234].*) 331.if !empty(_GCC_VERSION:M[34].[1234].*)
328_CXX_STD_FLAG.c++03= -std=c++0x 332_CXX_STD_FLAG.c++03= -std=c++0x
329_CXX_STD_FLAG.gnu++03= -std=gnu++0x 333_CXX_STD_FLAG.gnu++03= -std=gnu++0x
330.endif 334.endif
331 335
332.if !empty(_CC:M${TOOLBASE}/*) 336.if !empty(_CC:M${TOOLBASE}/*)
333_IS_BUILTIN_GCC= NO 337_IS_BUILTIN_GCC= NO
334GCC_REQD+= ${_GCC_VERSION} 338GCC_REQD+= ${_GCC_VERSION}
335.else 339.else
336. if !empty(_CC:M/*) 340. if !empty(_CC:M/*)
337# 341#
338# GCC in older versions of Darwin report "Apple Computer ... based on gcc 342# GCC in older versions of Darwin report "Apple Computer ... based on gcc
339# version ...", so we can't just grep for "^gcc". 343# version ...", so we can't just grep for "^gcc".
340# 344#
341. if ${_GCC_VERSION} != "0" 345. if ${_GCC_VERSION} != "0"
342_IS_BUILTIN_GCC= YES 346_IS_BUILTIN_GCC= YES
343. else 347. else
344_IS_BUILTIN_GCC= NO 348_IS_BUILTIN_GCC= NO
345. endif 349. endif
346. else 350. else
347_IS_BUILTIN_GCC= NO 351_IS_BUILTIN_GCC= NO
348. endif 352. endif
349.endif 353.endif
350 354
351# Distill the GCC_REQD list into a single _GCC_REQD value that is the 355# Distill the GCC_REQD list into a single _GCC_REQD value that is the
352# highest version of GCC required. 356# highest version of GCC required.
353# 357#
354_GCC_STRICTEST_REQD?= none 358_GCC_STRICTEST_REQD?= none
355.for _version_ in ${GCC_REQD} 359.for _version_ in ${GCC_REQD}
356. for _pkg_ in gcc-${_version_} 360. for _pkg_ in gcc-${_version_}
357. if ${_GCC_STRICTEST_REQD} == "none" 361. if ${_GCC_STRICTEST_REQD} == "none"
358_GCC_PKG_SATISFIES_DEP= YES 362_GCC_PKG_SATISFIES_DEP= YES
359. for _vers_ in ${GCC_REQD} 363. for _vers_ in ${GCC_REQD}
360. if !empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS]) 364. if !empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS])
361_GCC_PKG_SATISFIES_DEP!= \ 365_GCC_PKG_SATISFIES_DEP!= \
362 if ${PKG_ADMIN} pmatch 'gcc>=${_vers_}' ${_pkg_} 2>/dev/null; then \ 366 if ${PKG_ADMIN} pmatch 'gcc>=${_vers_}' ${_pkg_} 2>/dev/null; then \
363 ${ECHO} "YES"; \ 367 ${ECHO} "YES"; \
364 else \ 368 else \
365 ${ECHO} "NO"; \ 369 ${ECHO} "NO"; \
366 fi 370 fi
367. endif 371. endif
368. endfor 372. endfor
369. if !empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS]) 373. if !empty(_GCC_PKG_SATISFIES_DEP:M[yY][eE][sS])
370_GCC_STRICTEST_REQD= ${_version_} 374_GCC_STRICTEST_REQD= ${_version_}
371. endif 375. endif
372. endif 376. endif
373. endfor 377. endfor
374.endfor 378.endfor
375_GCC_REQD= ${_GCC_STRICTEST_REQD} 379_GCC_REQD= ${_GCC_STRICTEST_REQD}
376 380
377# Determine which GCC version is required by examining _GCC_REQD. 381# Determine which GCC version is required by examining _GCC_REQD.
378_NEED_GCC6?= no 382_NEED_GCC6?= no
379.for _pattern_ in ${_GCC6_PATTERNS} 383.for _pattern_ in ${_GCC6_PATTERNS}
380. if !empty(_GCC_REQD:M${_pattern_}) 384. if !empty(_GCC_REQD:M${_pattern_})
381# XXX this won't work without adjustments elsewhere because of how 385# XXX this won't work without adjustments elsewhere because of how
382# _GCC_REQD is processed. 386# _GCC_REQD is processed.
383#. if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 089937 387#. if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 089937
384#USE_PKGSRC_GCC= yes 388#USE_PKGSRC_GCC= yes
385#USE_PKGSRC_GCC_RUNTIME= yes 389#USE_PKGSRC_GCC_RUNTIME= yes
386#. endif 390#. endif
387_NEED_GCC6= yes 391_NEED_GCC6= yes
388. if ${ALLOW_NEWER_COMPILER:tl} != "yes" 392. if ${ALLOW_NEWER_COMPILER:tl} != "yes"
389PKG_FAIL_REASON+= "Package requires at least gcc 6 to build" 393PKG_FAIL_REASON+= "Package requires at least gcc 6 to build"
390. endif 394. endif
391. endif 395. endif
392.endfor 396.endfor
393_NEED_GCC7?= no 397_NEED_GCC7?= no
394.for _pattern_ in ${_GCC7_PATTERNS} 398.for _pattern_ in ${_GCC7_PATTERNS}
395. if !empty(_GCC_REQD:M${_pattern_}) 399. if !empty(_GCC_REQD:M${_pattern_})
396. if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 089937 400. if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 089937
397USE_PKGSRC_GCC= yes 401USE_PKGSRC_GCC= yes
398USE_PKGSRC_GCC_RUNTIME= yes 402USE_PKGSRC_GCC_RUNTIME= yes
399. endif 403. endif
400. if ${ALLOW_NEWER_COMPILER:tl} != "yes" 404. if ${ALLOW_NEWER_COMPILER:tl} != "yes"
401PKG_FAIL_REASON+= "Package requires at least gcc 7 to build" 405PKG_FAIL_REASON+= "Package requires at least gcc 7 to build"
402. endif 406. endif
403_NEED_GCC7= yes 407_NEED_GCC7= yes
404. endif 408. endif
405.endfor 409.endfor
406_NEED_GCC8?= no 410_NEED_GCC8?= no
407.for _pattern_ in ${_GCC8_PATTERNS} 411.for _pattern_ in ${_GCC8_PATTERNS}
408. if !empty(_GCC_REQD:M${_pattern_}) 412. if !empty(_GCC_REQD:M${_pattern_})
409. if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 099917 413. if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 099917
410USE_PKGSRC_GCC= yes 414USE_PKGSRC_GCC= yes
411USE_PKGSRC_GCC_RUNTIME= yes 415USE_PKGSRC_GCC_RUNTIME= yes
412. endif 416. endif
413. if ${ALLOW_NEWER_COMPILER:tl} != "yes" 417. if ${ALLOW_NEWER_COMPILER:tl} != "yes"
414PKG_FAIL_REASON+= "Package requires at least gcc 8 to build" 418PKG_FAIL_REASON+= "Package requires at least gcc 8 to build"
415. endif 419. endif
416_NEED_GCC8= yes 420_NEED_GCC8= yes
417. endif 421. endif
418.endfor 422.endfor
419_NEED_GCC9?= no 423_NEED_GCC9?= no
420.for _pattern_ in ${_GCC9_PATTERNS} 424.for _pattern_ in ${_GCC9_PATTERNS}
421. if !empty(_GCC_REQD:M${_pattern_}) 425. if !empty(_GCC_REQD:M${_pattern_})
422. if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 099976 426. if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 099976
423USE_PKGSRC_GCC= yes 427USE_PKGSRC_GCC= yes
424USE_PKGSRC_GCC_RUNTIME= yes 428USE_PKGSRC_GCC_RUNTIME= yes
425. endif 429. endif
426. if ${ALLOW_NEWER_COMPILER:tl} != "yes" 430. if ${ALLOW_NEWER_COMPILER:tl} != "yes"
427PKG_FAIL_REASON+= "Package requires at least gcc 9 to build" 431PKG_FAIL_REASON+= "Package requires at least gcc 9 to build"
428. endif 432. endif
429_NEED_GCC9= yes 433_NEED_GCC9= yes
430. endif 434. endif
431.endfor 435.endfor
432_NEED_GCC10?= no 436_NEED_GCC10?= no
433.for _pattern_ in ${_GCC10_PATTERNS} 437.for _pattern_ in ${_GCC10_PATTERNS}
434. if !empty(_GCC_REQD:M${_pattern_}) 438. if !empty(_GCC_REQD:M${_pattern_})
435. if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 099982 439. if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 099982
436USE_PKGSRC_GCC= yes 440USE_PKGSRC_GCC= yes
437USE_PKGSRC_GCC_RUNTIME= yes 441USE_PKGSRC_GCC_RUNTIME= yes
438. endif 442. endif
439. if ${ALLOW_NEWER_COMPILER:tl} != "yes" 443. if ${ALLOW_NEWER_COMPILER:tl} != "yes"
440PKG_FAIL_REASON+= "Package requires at least gcc 10 to build" 444PKG_FAIL_REASON+= "Package requires at least gcc 10 to build"
441. endif 445. endif
442_NEED_GCC10= yes 446_NEED_GCC10= yes
443. endif 447. endif
444.endfor 448.endfor
445_NEED_GCC12?= no 449_NEED_GCC12?= no
446.for _pattern_ in ${_GCC12_PATTERNS} 450.for _pattern_ in ${_GCC12_PATTERNS}
447. if !empty(_GCC_REQD:M${_pattern_}) 451. if !empty(_GCC_REQD:M${_pattern_})
448. if ${ALLOW_NEWER_COMPILER:tl} != "yes" 452. if ${ALLOW_NEWER_COMPILER:tl} != "yes"
449PKG_FAIL_REASON+= "Package requires at least gcc 12 to build" 453PKG_FAIL_REASON+= "Package requires at least gcc 12 to build"
450. endif 454. endif
451_NEED_GCC12= yes 455_NEED_GCC12= yes
452. endif 456. endif
453.endfor 457.endfor
454_NEED_GCC13?= no 458_NEED_GCC13?= no
455.for _pattern_ in ${_GCC13_PATTERNS} 459.for _pattern_ in ${_GCC13_PATTERNS}
456. if !empty(_GCC_REQD:M${_pattern_}) 460. if !empty(_GCC_REQD:M${_pattern_})
457. if ${ALLOW_NEWER_COMPILER:tl} != "yes" 461. if ${ALLOW_NEWER_COMPILER:tl} != "yes"
458PKG_FAIL_REASON+= "Package requires at least gcc 13 to build" 462PKG_FAIL_REASON+= "Package requires at least gcc 13 to build"
459. endif 463. endif
460_NEED_GCC13= yes 464_NEED_GCC13= yes
461. endif 465. endif
462.endfor 466.endfor
463_NEED_GCC_AUX?= no 467_NEED_GCC_AUX?= no
464.for _pattern_ in ${_GCC_AUX_PATTERNS} 468.for _pattern_ in ${_GCC_AUX_PATTERNS}
465. if !empty(_GCC_REQD:M${_pattern_}) 469. if !empty(_GCC_REQD:M${_pattern_})
466_NEED_GCC_AUX= yes 470_NEED_GCC_AUX= yes
467_NEED_NEWER_GCC=NO 471_NEED_NEWER_GCC=NO
468. endif 472. endif
469.endfor 473.endfor
470.if !empty(_NEED_GCC6:M[nN][oO]) && !empty(_NEED_GCC7:M[nN][oO]) && \ 474.if !empty(_NEED_GCC6:M[nN][oO]) && !empty(_NEED_GCC7:M[nN][oO]) && \
471 !empty(_NEED_GCC8:M[nN][oO]) && !empty(_NEED_GCC9:M[nN][oO]) && \ 475 !empty(_NEED_GCC8:M[nN][oO]) && !empty(_NEED_GCC9:M[nN][oO]) && \
472 !empty(_NEED_GCC10:M[nN][oO]) && !empty(_NEED_GCC12:M[nN][oO]) && \ 476 !empty(_NEED_GCC10:M[nN][oO]) && !empty(_NEED_GCC12:M[nN][oO]) && \
473 !empty(_NEED_GCC13:M[nN][oO]) && !empty(_NEED_GCC_AUX:M[nN][oO]) 477 !empty(_NEED_GCC13:M[nN][oO]) && !empty(_NEED_GCC_AUX:M[nN][oO])
474_NEED_GCC8= yes 478_NEED_GCC8= yes
475.endif 479.endif
476 480
477# April 2022: GCC below 10 from pkgsrc is broken on 32-bit arm NetBSD. 481# April 2022: GCC below 10 from pkgsrc is broken on 32-bit arm NetBSD.
478.if !empty(MACHINE_PLATFORM:MNetBSD-*-earm*) && \ 482.if !empty(MACHINE_PLATFORM:MNetBSD-*-earm*) && \
479 ${OPSYS_VERSION} < 099900 && \ 483 ${OPSYS_VERSION} < 099900 && \
480 (${_NEED_GCC8:tl} == "yes" || ${_NEED_GCC9:tl} == "yes") 484 (${_NEED_GCC8:tl} == "yes" || ${_NEED_GCC9:tl} == "yes")
481_NEED_GCC6= no 485_NEED_GCC6= no
482_NEED_GCC7= no 486_NEED_GCC7= no
483_NEED_GCC8= no 487_NEED_GCC8= no
484_NEED_GCC9= no 488_NEED_GCC9= no
485_NEED_GCC10= yes 489_NEED_GCC10= yes
486_NEED_GCC12= yes 490_NEED_GCC12= yes
487_NEED_GCC13= yes 491_NEED_GCC13= yes
488.endif 492.endif
489 493
490# Assume by default that GCC will only provide a C compiler. 494# Assume by default that GCC will only provide a C compiler.
491LANGUAGES.gcc?= c 495LANGUAGES.gcc?= c
492.if !empty(_NEED_GCC6:M[yY][eE][sS]) 496.if !empty(_NEED_GCC6:M[yY][eE][sS])
493LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++ 497LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
494.elif !empty(_NEED_GCC7:M[yY][eE][sS]) 498.elif !empty(_NEED_GCC7:M[yY][eE][sS])
495LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++ 499LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
496.elif !empty(_NEED_GCC8:M[yY][eE][sS]) 500.elif !empty(_NEED_GCC8:M[yY][eE][sS])
497LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++ 501LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
498.elif !empty(_NEED_GCC9:M[yY][eE][sS]) 502.elif !empty(_NEED_GCC9:M[yY][eE][sS])
499LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++ 503LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
500.elif !empty(_NEED_GCC10:M[yY][eE][sS]) 504.elif !empty(_NEED_GCC10:M[yY][eE][sS])
501LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++ 505LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
502.elif !empty(_NEED_GCC12:M[yY][eE][sS]) 506.elif !empty(_NEED_GCC12:M[yY][eE][sS])
503LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++ 507LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
504.elif !empty(_NEED_GCC13:M[yY][eE][sS]) 508.elif !empty(_NEED_GCC13:M[yY][eE][sS])
505LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++ 509LANGUAGES.gcc= c c++ fortran fortran77 go java objc obj-c++
506.elif !empty(_NEED_GCC_AUX:M[yY][eE][sS]) 510.elif !empty(_NEED_GCC_AUX:M[yY][eE][sS])
507LANGUAGES.gcc= c c++ fortran fortran77 objc ada 511LANGUAGES.gcc= c c++ fortran fortran77 objc ada
508.endif 512.endif
509_LANGUAGES.gcc= # empty 513_LANGUAGES.gcc= # empty
510.for _lang_ in ${USE_LANGUAGES} 514.for _lang_ in ${USE_LANGUAGES}
511_LANGUAGES.gcc+= ${LANGUAGES.gcc:M${_lang_}} 515_LANGUAGES.gcc+= ${LANGUAGES.gcc:M${_lang_}}
512.endfor 516.endfor
513 517
514_WRAP_EXTRA_ARGS.cc+= -fcommon 518_WRAP_EXTRA_ARGS.cc+= -fcommon
515CWRAPPERS_PREPEND.cc+= -fcommon 519CWRAPPERS_PREPEND.cc+= -fcommon
516 520
517.if ${_PKGSRC_MKPIE} == "yes" 521.if ${_PKGSRC_MKPIE} == "yes"
518_MKPIE_CFLAGS.gcc= -fPIC 522_MKPIE_CFLAGS.gcc= -fPIC
519_MKPIE_FCFLAGS.gcc= -fPIC 523_MKPIE_FCFLAGS.gcc= -fPIC
520# for libraries a sink wrapper around gcc is required and used instead 524# for libraries a sink wrapper around gcc is required and used instead
521_MKPIE_LDFLAGS= -pie 525_MKPIE_LDFLAGS= -pie
522 526
523. if ${PKGSRC_OVERRIDE_MKPIE:tl} == "no" 527. if ${PKGSRC_OVERRIDE_MKPIE:tl} == "no"
524_GCC_CFLAGS+= ${_MKPIE_CFLAGS.gcc} 528_GCC_CFLAGS+= ${_MKPIE_CFLAGS.gcc}
525_GCC_FCFLAGS+= ${_MKPIE_FCFLAGS.gcc} 529_GCC_FCFLAGS+= ${_MKPIE_FCFLAGS.gcc}
526CWRAPPERS_APPEND.cc+= ${_MKPIE_CFLAGS.gcc} 530CWRAPPERS_APPEND.cc+= ${_MKPIE_CFLAGS.gcc}
527CWRAPPERS_APPEND.cxx+= ${_MKPIE_CFLAGS.gcc} 531CWRAPPERS_APPEND.cxx+= ${_MKPIE_CFLAGS.gcc}
528CWRAPPERS_APPEND.f77+= ${_MKPIE_FCFLAGS.gcc} 532CWRAPPERS_APPEND.f77+= ${_MKPIE_FCFLAGS.gcc}
529. endif 533. endif
530.endif 534.endif
531 535
532.if ${_PKGSRC_MKREPRO} == "yes" 536.if ${_PKGSRC_MKREPRO} == "yes"
533.export WRKDIR 537.export WRKDIR
534# XXX the dollar sign should not be expanded by the shell 538# XXX the dollar sign should not be expanded by the shell
535_GCC_CFLAGS+= -fdebug-prefix-map=$$$$WRKDIR/= 539_GCC_CFLAGS+= -fdebug-prefix-map=$$$$WRKDIR/=
536.endif 540.endif
537 541
538.if ${_PKGSRC_MKREPRO} == "yes" 542.if ${_PKGSRC_MKREPRO} == "yes"
539_GCC_CFLAGS+= ${_MKREPRO_CFLAGS.gcc} 543_GCC_CFLAGS+= ${_MKREPRO_CFLAGS.gcc}
540CWRAPPERS_APPEND.cc+= ${_MKREPRO_CFLAGS.gcc} 544CWRAPPERS_APPEND.cc+= ${_MKREPRO_CFLAGS.gcc}
541.endif 545.endif
542 546
543# The user can choose the level of FORTIFY. 547# The user can choose the level of FORTIFY.
544.if ${PKGSRC_USE_FORTIFY} == "weak" 548.if ${PKGSRC_USE_FORTIFY} == "weak"
545_FORTIFY_CFLAGS= -D_FORTIFY_SOURCE=1 549_FORTIFY_CFLAGS= -D_FORTIFY_SOURCE=1
546.else 550.else
547_FORTIFY_CFLAGS= -D_FORTIFY_SOURCE=2 551_FORTIFY_CFLAGS= -D_FORTIFY_SOURCE=2
548.endif 552.endif
549 553
550.if ${_PKGSRC_USE_FORTIFY} == "yes" 554.if ${_PKGSRC_USE_FORTIFY} == "yes"
551_GCC_CFLAGS+= ${_FORTIFY_CFLAGS} 555_GCC_CFLAGS+= ${_FORTIFY_CFLAGS}
552CWRAPPERS_APPEND.cc+= ${_FORTIFY_CFLAGS} 556CWRAPPERS_APPEND.cc+= ${_FORTIFY_CFLAGS}
553.endif 557.endif
554 558
555# The user or package can choose the level of RELRO. 559# The user or package can choose the level of RELRO.
556.if ${PKGSRC_USE_RELRO} != "partial" && \ 560.if ${PKGSRC_USE_RELRO} != "partial" && \
557 ${RELRO_SUPPORTED:Uyes:tl} != "partial" 561 ${RELRO_SUPPORTED:Uyes:tl} != "partial"
558_RELRO_LDFLAGS= -Wl,-zrelro -Wl,-znow 562_RELRO_LDFLAGS= -Wl,-zrelro -Wl,-znow
559.else 563.else
560_RELRO_LDFLAGS= -Wl,-zrelro 564_RELRO_LDFLAGS= -Wl,-zrelro
561.endif 565.endif
562 566
563.if !empty(_RELRO_LDFLAGS) && !empty(MACHINE_PLATFORM:MNetBSD-*-*mips*) 567.if !empty(_RELRO_LDFLAGS) && !empty(MACHINE_PLATFORM:MNetBSD-*-*mips*)
564_RELRO_LDFLAGS+= -Wl,-z,common-page-size=0x10000 568_RELRO_LDFLAGS+= -Wl,-z,common-page-size=0x10000
565.endif 569.endif
566 570
567.if ${_PKGSRC_USE_STACK_CHECK} == "yes" 571.if ${_PKGSRC_USE_STACK_CHECK} == "yes"
568_STACK_CHECK_CFLAGS= -fstack-check 572_STACK_CHECK_CFLAGS= -fstack-check
569_GCC_CFLAGS+= ${_STACK_CHECK_CFLAGS} 573_GCC_CFLAGS+= ${_STACK_CHECK_CFLAGS}
570.elif ${_PKGSRC_USE_STACK_CHECK} == "stack-clash" 574.elif ${_PKGSRC_USE_STACK_CHECK} == "stack-clash"
571_STACK_CHECK_CFLAGS= -fstack-clash-protection 575_STACK_CHECK_CFLAGS= -fstack-clash-protection
572_GCC_CFLAGS+= ${_STACK_CHECK_CFLAGS} 576_GCC_CFLAGS+= ${_STACK_CHECK_CFLAGS}
573.endif 577.endif
574 578
575_CTF_CFLAGS= -gdwarf-2 579_CTF_CFLAGS= -gdwarf-2
576 580
577# GCC has this annoying behaviour where it advocates in a multi-line 581# GCC has this annoying behaviour where it advocates in a multi-line
578# banner the use of "#include" over "#import" when including headers. 582# banner the use of "#include" over "#import" when including headers.
579# This generates a huge number of warnings when building practically all 583# This generates a huge number of warnings when building practically all
580# Objective-C code where it is convention to use "#import". Suppress 584# Objective-C code where it is convention to use "#import". Suppress
581# the warning if we're building Objective-C code using GCC. 585# the warning if we're building Objective-C code using GCC.
582# 586#
583.if !empty(_LANGUAGES.gcc:Mobjc) 587.if !empty(_LANGUAGES.gcc:Mobjc)
584CFLAGS+= -Wno-import 588CFLAGS+= -Wno-import
585.endif 589.endif
586 590
587CFLAGS+= ${_GCC_CFLAGS} 591CFLAGS+= ${_GCC_CFLAGS}
588FCFLAGS+= ${_GCC_FCFLAGS} 592FCFLAGS+= ${_GCC_FCFLAGS}
589 593
590.if !empty(_NEED_GCC6:M[yY][eE][sS]) 594.if !empty(_NEED_GCC6:M[yY][eE][sS])
591# 595#
592# We require gcc-6.x in the lang/gcc6-* directory. 596# We require gcc-6.x in the lang/gcc6-* directory.
593# 597#
594_GCC_PKGBASE= gcc6 598_GCC_PKGBASE= gcc6
595. if ${PKGPATH} == lang/gcc6 599. if ${PKGPATH} == lang/gcc6
596_IGNORE_GCC= yes 600_IGNORE_GCC= yes
597MAKEFLAGS+= _IGNORE_GCC=yes 601MAKEFLAGS+= _IGNORE_GCC=yes
598. endif 602. endif
599. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc) 603. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
600_GCC_PKGSRCDIR= ../../lang/gcc6 604_GCC_PKGSRCDIR= ../../lang/gcc6
601_GCC_DEPENDENCY= gcc6>=${_GCC_REQD}:../../lang/gcc6 605_GCC_DEPENDENCY= gcc6>=${_GCC_REQD}:../../lang/gcc6
602. if !empty(_LANGUAGES.gcc:Mc++) || \ 606. if !empty(_LANGUAGES.gcc:Mc++) || \
603 !empty(_LANGUAGES.gcc:Mfortran) || \ 607 !empty(_LANGUAGES.gcc:Mfortran) || \
604 !empty(_LANGUAGES.gcc:Mfortran77) || \ 608 !empty(_LANGUAGES.gcc:Mfortran77) || \
605 !empty(_LANGUAGES.gcc:Mgo) || \ 609 !empty(_LANGUAGES.gcc:Mgo) || \
606 !empty(_LANGUAGES.gcc:Mobjc) || \ 610 !empty(_LANGUAGES.gcc:Mobjc) || \
607 !empty(_LANGUAGES.gcc:Mobj-c++) 611 !empty(_LANGUAGES.gcc:Mobj-c++)
608_USE_GCC_SHLIB?= yes 612_USE_GCC_SHLIB?= yes
609. endif 613. endif
610. endif 614. endif
611.elif !empty(_NEED_GCC7:M[yY][eE][sS]) 615.elif !empty(_NEED_GCC7:M[yY][eE][sS])
612# 616#
613# We require gcc-7.x in the lang/gcc7-* directory. 617# We require gcc-7.x in the lang/gcc7-* directory.
614# 618#
615_GCC_PKGBASE= gcc7 619_GCC_PKGBASE= gcc7
616. if ${PKGPATH} == lang/gcc7 620. if ${PKGPATH} == lang/gcc7
617_IGNORE_GCC= yes 621_IGNORE_GCC= yes
618MAKEFLAGS+= _IGNORE_GCC=yes 622MAKEFLAGS+= _IGNORE_GCC=yes
619. endif 623. endif
620. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc) 624. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
621_GCC_PKGSRCDIR= ../../lang/gcc7 625_GCC_PKGSRCDIR= ../../lang/gcc7
622_GCC_DEPENDENCY= gcc7>=${_GCC_REQD}:../../lang/gcc7 626_GCC_DEPENDENCY= gcc7>=${_GCC_REQD}:../../lang/gcc7
623. if !empty(_LANGUAGES.gcc:Mc++) || \ 627. if !empty(_LANGUAGES.gcc:Mc++) || \
624 !empty(_LANGUAGES.gcc:Mfortran) || \ 628 !empty(_LANGUAGES.gcc:Mfortran) || \
625 !empty(_LANGUAGES.gcc:Mfortran77) || \ 629 !empty(_LANGUAGES.gcc:Mfortran77) || \
626 !empty(_LANGUAGES.gcc:Mgo) || \ 630 !empty(_LANGUAGES.gcc:Mgo) || \
627 !empty(_LANGUAGES.gcc:Mobjc) || \ 631 !empty(_LANGUAGES.gcc:Mobjc) || \
628 !empty(_LANGUAGES.gcc:Mobj-c++) 632 !empty(_LANGUAGES.gcc:Mobj-c++)
629_USE_GCC_SHLIB?= yes 633_USE_GCC_SHLIB?= yes
630. endif 634. endif
631. endif 635. endif
632.elif !empty(_NEED_GCC8:M[yY][eE][sS]) 636.elif !empty(_NEED_GCC8:M[yY][eE][sS])
633# 637#
634# We require gcc-8.x in the lang/gcc8-* directory. 638# We require gcc-8.x in the lang/gcc8-* directory.
635# 639#
636_GCC_PKGBASE= gcc8 640_GCC_PKGBASE= gcc8
637. if ${PKGPATH} == lang/gcc8 641. if ${PKGPATH} == lang/gcc8
638_IGNORE_GCC= yes 642_IGNORE_GCC= yes
639MAKEFLAGS+= _IGNORE_GCC=yes 643MAKEFLAGS+= _IGNORE_GCC=yes
640. endif 644. endif
641. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc) 645. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
642_GCC_PKGSRCDIR= ../../lang/gcc8 646_GCC_PKGSRCDIR= ../../lang/gcc8
643_GCC_DEPENDENCY= gcc8>=${_GCC_REQD}:../../lang/gcc8 647_GCC_DEPENDENCY= gcc8>=${_GCC_REQD}:../../lang/gcc8
644. if !empty(_LANGUAGES.gcc:Mc++) || \ 648. if !empty(_LANGUAGES.gcc:Mc++) || \
645 !empty(_LANGUAGES.gcc:Mfortran) || \ 649 !empty(_LANGUAGES.gcc:Mfortran) || \
646 !empty(_LANGUAGES.gcc:Mfortran77) || \ 650 !empty(_LANGUAGES.gcc:Mfortran77) || \
647 !empty(_LANGUAGES.gcc:Mgo) || \ 651 !empty(_LANGUAGES.gcc:Mgo) || \
648 !empty(_LANGUAGES.gcc:Mobjc) || \ 652 !empty(_LANGUAGES.gcc:Mobjc) || \
649 !empty(_LANGUAGES.gcc:Mobj-c++) 653 !empty(_LANGUAGES.gcc:Mobj-c++)
650_USE_GCC_SHLIB?= yes 654_USE_GCC_SHLIB?= yes
651. endif 655. endif
652. endif 656. endif
653.elif !empty(_NEED_GCC9:M[yY][eE][sS]) 657.elif !empty(_NEED_GCC9:M[yY][eE][sS])
654# 658#
655# We require gcc-9.x in the lang/gcc9-* directory. 659# We require gcc-9.x in the lang/gcc9-* directory.
656# 660#
657_GCC_PKGBASE= gcc9 661_GCC_PKGBASE= gcc9
658. if ${PKGPATH} == lang/gcc9 662. if ${PKGPATH} == lang/gcc9
659_IGNORE_GCC= yes 663_IGNORE_GCC= yes
660MAKEFLAGS+= _IGNORE_GCC=yes 664MAKEFLAGS+= _IGNORE_GCC=yes
661. endif 665. endif
662. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc) 666. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
663_GCC_PKGSRCDIR= ../../lang/gcc9 667_GCC_PKGSRCDIR= ../../lang/gcc9
664_GCC_DEPENDENCY= gcc9>=${_GCC_REQD}:../../lang/gcc9 668_GCC_DEPENDENCY= gcc9>=${_GCC_REQD}:../../lang/gcc9
665. if !empty(_LANGUAGES.gcc:Mc++) || \ 669. if !empty(_LANGUAGES.gcc:Mc++) || \
666 !empty(_LANGUAGES.gcc:Mfortran) || \ 670 !empty(_LANGUAGES.gcc:Mfortran) || \
667 !empty(_LANGUAGES.gcc:Mfortran77) || \ 671 !empty(_LANGUAGES.gcc:Mfortran77) || \
668 !empty(_LANGUAGES.gcc:Mgo) || \ 672 !empty(_LANGUAGES.gcc:Mgo) || \
669 !empty(_LANGUAGES.gcc:Mobjc) || \ 673 !empty(_LANGUAGES.gcc:Mobjc) || \
670 !empty(_LANGUAGES.gcc:Mobj-c++) 674 !empty(_LANGUAGES.gcc:Mobj-c++)
671_USE_GCC_SHLIB?= yes 675_USE_GCC_SHLIB?= yes
672. endif 676. endif
673. endif 677. endif
674.elif !empty(_NEED_GCC10:M[yY][eE][sS]) 678.elif !empty(_NEED_GCC10:M[yY][eE][sS])
675# 679#
676# We require gcc-10.x in the lang/gcc10-* directory. 680# We require gcc-10.x in the lang/gcc10-* directory.
677# 681#
678_GCC_PKGBASE= gcc10 682_GCC_PKGBASE= gcc10
679. if ${PKGPATH} == lang/gcc10 683. if ${PKGPATH} == lang/gcc10
680_IGNORE_GCC= yes 684_IGNORE_GCC= yes
681MAKEFLAGS+= _IGNORE_GCC=yes 685MAKEFLAGS+= _IGNORE_GCC=yes
682. endif 686. endif
683. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc) 687. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
684_GCC_PKGSRCDIR= ../../lang/gcc10 688_GCC_PKGSRCDIR= ../../lang/gcc10
685_GCC_DEPENDENCY= gcc10>=${_GCC_REQD}:../../lang/gcc10 689_GCC_DEPENDENCY= gcc10>=${_GCC_REQD}:../../lang/gcc10
686. if !empty(_LANGUAGES.gcc:Mc++) || \ 690. if !empty(_LANGUAGES.gcc:Mc++) || \
687 !empty(_LANGUAGES.gcc:Mfortran) || \ 691 !empty(_LANGUAGES.gcc:Mfortran) || \
688 !empty(_LANGUAGES.gcc:Mfortran77) || \ 692 !empty(_LANGUAGES.gcc:Mfortran77) || \
689 !empty(_LANGUAGES.gcc:Mgo) || \ 693 !empty(_LANGUAGES.gcc:Mgo) || \
690 !empty(_LANGUAGES.gcc:Mobjc) || \ 694 !empty(_LANGUAGES.gcc:Mobjc) || \
691 !empty(_LANGUAGES.gcc:Mobj-c++) 695 !empty(_LANGUAGES.gcc:Mobj-c++)
692_USE_GCC_SHLIB?= yes 696_USE_GCC_SHLIB?= yes
693. endif 697. endif
694. endif 698. endif
695.elif !empty(_NEED_GCC12:M[yY][eE][sS]) 699.elif !empty(_NEED_GCC12:M[yY][eE][sS])
696# 700#
697# We require gcc-12.x in the lang/gcc12-* directory. 701# We require gcc-12.x in the lang/gcc12-* directory.
698# 702#
699_GCC_PKGBASE= gcc12 703_GCC_PKGBASE= gcc12
700. if ${PKGPATH} == lang/gcc12 704. if ${PKGPATH} == lang/gcc12
701_IGNORE_GCC= yes 705_IGNORE_GCC= yes
702MAKEFLAGS+= _IGNORE_GCC=yes 706MAKEFLAGS+= _IGNORE_GCC=yes
703. endif 707. endif
704. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc) 708. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
705_GCC_PKGSRCDIR= ../../lang/gcc12 709_GCC_PKGSRCDIR= ../../lang/gcc12
706_GCC_DEPENDENCY= gcc12>=${_GCC_REQD}:../../lang/gcc12 710_GCC_DEPENDENCY= gcc12>=${_GCC_REQD}:../../lang/gcc12
707. if !empty(_LANGUAGES.gcc:Mc++) || \ 711. if !empty(_LANGUAGES.gcc:Mc++) || \
708 !empty(_LANGUAGES.gcc:Mfortran) || \ 712 !empty(_LANGUAGES.gcc:Mfortran) || \
709 !empty(_LANGUAGES.gcc:Mfortran77) || \ 713 !empty(_LANGUAGES.gcc:Mfortran77) || \
710 !empty(_LANGUAGES.gcc:Mgo) || \ 714 !empty(_LANGUAGES.gcc:Mgo) || \
711 !empty(_LANGUAGES.gcc:Mobjc) || \ 715 !empty(_LANGUAGES.gcc:Mobjc) || \
712 !empty(_LANGUAGES.gcc:Mobj-c++) 716 !empty(_LANGUAGES.gcc:Mobj-c++)
713_USE_GCC_SHLIB?= yes 717_USE_GCC_SHLIB?= yes
714. endif 718. endif
715. endif 719. endif
716.elif !empty(_NEED_GCC13:M[yY][eE][sS]) 720.elif !empty(_NEED_GCC13:M[yY][eE][sS])
717# 721#
718# We require gcc-13.x in the lang/gcc13-* directory. 722# We require gcc-13.x in the lang/gcc13-* directory.
719# 723#
720_GCC_PKGBASE= gcc13 724_GCC_PKGBASE= gcc13
721. if ${PKGPATH} == lang/gcc13 725. if ${PKGPATH} == lang/gcc13
722_IGNORE_GCC= yes 726_IGNORE_GCC= yes
723MAKEFLAGS+= _IGNORE_GCC=yes 727MAKEFLAGS+= _IGNORE_GCC=yes
724. endif 728. endif
725. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc) 729. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
726_GCC_PKGSRCDIR= ../../lang/gcc13 730_GCC_PKGSRCDIR= ../../lang/gcc13
727_GCC_DEPENDENCY= gcc13>=${_GCC_REQD}:../../lang/gcc13 731_GCC_DEPENDENCY= gcc13>=${_GCC_REQD}:../../lang/gcc13
728. if !empty(_LANGUAGES.gcc:Mc++) || \ 732. if !empty(_LANGUAGES.gcc:Mc++) || \
729 !empty(_LANGUAGES.gcc:Mfortran) || \ 733 !empty(_LANGUAGES.gcc:Mfortran) || \
730 !empty(_LANGUAGES.gcc:Mfortran77) || \ 734 !empty(_LANGUAGES.gcc:Mfortran77) || \
731 !empty(_LANGUAGES.gcc:Mgo) || \ 735 !empty(_LANGUAGES.gcc:Mgo) || \
732 !empty(_LANGUAGES.gcc:Mobjc) || \ 736 !empty(_LANGUAGES.gcc:Mobjc) || \
733 !empty(_LANGUAGES.gcc:Mobj-c++) 737 !empty(_LANGUAGES.gcc:Mobj-c++)
734_USE_GCC_SHLIB?= yes 738_USE_GCC_SHLIB?= yes
735. endif 739. endif
736. endif 740. endif
737.elif !empty(_NEED_GCC_AUX:M[yY][eE][sS]) 741.elif !empty(_NEED_GCC_AUX:M[yY][eE][sS])
738# 742#
739# We require Ada-capable compiler in the lang/gcc6-aux directory. 743# We require Ada-capable compiler in the lang/gcc6-aux directory.
740# 744#
741_GCC_PKGBASE= gcc6-aux 745_GCC_PKGBASE= gcc6-aux
742. if ${PKGPATH} == lang/gcc6-aux 746. if ${PKGPATH} == lang/gcc6-aux
743_IGNORE_GCC= yes 747_IGNORE_GCC= yes
744MAKEFLAGS+= _IGNORE_GCC=yes 748MAKEFLAGS+= _IGNORE_GCC=yes
745. endif 749. endif
746. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc) 750. if !defined(_IGNORE_GCC) && !empty(_LANGUAGES.gcc)
747_GCC_PKGSRCDIR= ../../lang/gcc6-aux 751_GCC_PKGSRCDIR= ../../lang/gcc6-aux
748_GCC_DEPENDENCY= gcc6-aux>=${_GCC_REQD}:../../lang/gcc6-aux 752_GCC_DEPENDENCY= gcc6-aux>=${_GCC_REQD}:../../lang/gcc6-aux
749. if !empty(_LANGUAGES.gcc:Mc++) || \ 753. if !empty(_LANGUAGES.gcc:Mc++) || \
750 !empty(_LANGUAGES.gcc:Mfortran) || \ 754 !empty(_LANGUAGES.gcc:Mfortran) || \
751 !empty(_LANGUAGES.gcc:Mfortran77) || \ 755 !empty(_LANGUAGES.gcc:Mfortran77) || \
752 !empty(_LANGUAGES.gcc:Mada) || \ 756 !empty(_LANGUAGES.gcc:Mada) || \
753 !empty(_LANGUAGES.gcc:Mobjc) 757 !empty(_LANGUAGES.gcc:Mobjc)
754_USE_GCC_SHLIB?= yes 758_USE_GCC_SHLIB?= yes
755. endif 759. endif
756. endif 760. endif
757.endif 761.endif
758_GCC_DEPENDS= ${_GCC_PKGBASE}>=${_GCC_REQD} 762_GCC_DEPENDS= ${_GCC_PKGBASE}>=${_GCC_REQD}
759 763
760# When not using the GNU linker, gcc will always link shared libraries against 764# When not using the GNU linker, gcc will always link shared libraries against
761# the shared version of libgcc, and so _USE_GCC_SHLIB needs to be enabled on 765# the shared version of libgcc, and so _USE_GCC_SHLIB needs to be enabled on
762# platforms with non-GNU linkers, such as SunOS. 766# platforms with non-GNU linkers, such as SunOS.
763# 767#
764# However, we cannot simply do this by default as it will create circular 768# However, we cannot simply do this by default as it will create circular
765# dependencies in packages which are required to build gcc itself, and so we 769# dependencies in packages which are required to build gcc itself, and so we
766# enable it based on USE_LIBTOOL for the majority of packages, and support 770# enable it based on USE_LIBTOOL for the majority of packages, and support
767# USE_GCC_RUNTIME for packages which create shared libraries but do not use 771# USE_GCC_RUNTIME for packages which create shared libraries but do not use
768# libtool to do so. 772# libtool to do so.
769# 773#
770.if (${OPSYS} == "Darwin" || ${OPSYS} == "SunOS") && \ 774.if (${OPSYS} == "Darwin" || ${OPSYS} == "SunOS") && \
771 (defined(USE_LIBTOOL) || defined(USE_GCC_RUNTIME)) 775 (defined(USE_LIBTOOL) || defined(USE_GCC_RUNTIME))
772_USE_GCC_SHLIB= yes 776_USE_GCC_SHLIB= yes
773.endif 777.endif
774 778
775.if !empty(USE_NATIVE_GCC:M[yY][eE][sS]) && !empty(_IS_BUILTIN_GCC:M[yY][eE][sS]) 779.if !empty(USE_NATIVE_GCC:M[yY][eE][sS]) && !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
776_USE_PKGSRC_GCC= no 780_USE_PKGSRC_GCC= no
777.elif !empty(USE_PKGSRC_GCC:M[yY][eE][sS]) 781.elif !empty(USE_PKGSRC_GCC:M[yY][eE][sS])
778# For environments where there is an external gcc too, but pkgsrc 782# For environments where there is an external gcc too, but pkgsrc
779# should use the pkgsrc one for consistency. 783# should use the pkgsrc one for consistency.
780_USE_PKGSRC_GCC= yes 784_USE_PKGSRC_GCC= yes
781.endif 785.endif
782 786
783.if defined(_IGNORE_GCC) 787.if defined(_IGNORE_GCC)
784_USE_PKGSRC_GCC= NO 788_USE_PKGSRC_GCC= NO
785.endif 789.endif
786 790
787.if !defined(_USE_PKGSRC_GCC) 791.if !defined(_USE_PKGSRC_GCC)
788_USE_PKGSRC_GCC= YES 792_USE_PKGSRC_GCC= YES
789. if !empty(_IS_BUILTIN_GCC:M[yY][eE][sS]) 793. if !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
790_GCC_TEST_DEPENDS= gcc>=${_GCC_REQD} 794_GCC_TEST_DEPENDS= gcc>=${_GCC_REQD}
791_USE_PKGSRC_GCC!= \ 795_USE_PKGSRC_GCC!= \
792 if ${PKG_ADMIN} pmatch '${_GCC_TEST_DEPENDS}' ${_GCC_PKG} 2>/dev/null; then \ 796 if ${PKG_ADMIN} pmatch '${_GCC_TEST_DEPENDS}' ${_GCC_PKG} 2>/dev/null; then \
793 ${ECHO} "NO"; \ 797 ${ECHO} "NO"; \
794 else \ 798 else \
795 ${ECHO} "YES"; \ 799 ${ECHO} "YES"; \
796 fi 800 fi
797. endif 801. endif
798.endif 802.endif
799 803
800# Check if any of the versions of GCC in pkgsrc can satisfy the _GCC_REQD 804# Check if any of the versions of GCC in pkgsrc can satisfy the _GCC_REQD
801# requirement. 805# requirement.
802# 806#
803.if !defined(_NEED_NEWER_GCC) 807.if !defined(_NEED_NEWER_GCC)
804_PKGSRC_GCC_VERSION= ${_GCC_PKGBASE}-${_GCC_DIST_VERSION} 808_PKGSRC_GCC_VERSION= ${_GCC_PKGBASE}-${_GCC_DIST_VERSION}
805_NEED_NEWER_GCC!= \ 809_NEED_NEWER_GCC!= \
806 if ${PKG_ADMIN} pmatch '${_GCC_DEPENDS}' ${_PKGSRC_GCC_VERSION} 2>/dev/null; then \ 810 if ${PKG_ADMIN} pmatch '${_GCC_DEPENDS}' ${_PKGSRC_GCC_VERSION} 2>/dev/null; then \
807 ${ECHO} "NO"; \ 811 ${ECHO} "NO"; \
808 else \ 812 else \
809 ${ECHO} "YES"; \ 813 ${ECHO} "YES"; \
810 fi 814 fi
811#MAKEFLAGS+= _NEED_NEWER_GCC=${_NEED_NEWER_GCC} 815#MAKEFLAGS+= _NEED_NEWER_GCC=${_NEED_NEWER_GCC}
812.endif 816.endif
813.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) && \ 817.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) && \
814 !empty(_NEED_NEWER_GCC:M[yY][eE][sS]) 818 !empty(_NEED_NEWER_GCC:M[yY][eE][sS])
815PKG_FAIL_REASON+= "Unable to satisfy dependency: ${_GCC_DEPENDS}" 819PKG_FAIL_REASON+= "Unable to satisfy dependency: ${_GCC_DEPENDS}"
816.endif 820.endif
817 821
818# GNU ld option used to set the rpath 822# GNU ld option used to set the rpath
819_LINKER_RPATH_FLAG= -R 823_LINKER_RPATH_FLAG= -R
820 824
821# GCC passes rpath directives to the linker using "-Wl,-R". 825# GCC passes rpath directives to the linker using "-Wl,-R".
822_COMPILER_RPATH_FLAG= -Wl,${_LINKER_RPATH_FLAG} 826_COMPILER_RPATH_FLAG= -Wl,${_LINKER_RPATH_FLAG}
823 827
824.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) 828.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
825# 829#
826# Ensure that the correct rpath is passed to the linker if we need to 830# Ensure that the correct rpath is passed to the linker if we need to
827# link against gcc shared libs. 831# link against gcc shared libs.
828# 832#
829# XXX cross-compilation -- is this TOOLBASE or LOCALBASE? 833# XXX cross-compilation -- is this TOOLBASE or LOCALBASE?
830# 834#
831_GCC_SUBPREFIX!= \ 835_GCC_SUBPREFIX!= \
832 if ${PKG_INFO} -qe ${_GCC_PKGBASE}; then \ 836 if ${PKG_INFO} -qe ${_GCC_PKGBASE}; then \
833 ${PKG_INFO} -f ${_GCC_PKGBASE} | \ 837 ${PKG_INFO} -f ${_GCC_PKGBASE} | \
834 ${GREP} "File:.*bin/gcc" | \ 838 ${GREP} "File:.*bin/gcc" | \
835 ${GREP} -v "/gcc[0-9][0-9]*-.*" | \ 839 ${GREP} -v "/gcc[0-9][0-9]*-.*" | \
836 ${SED} -e "s/.*File: *//;s/bin\/gcc.*//;q"; \ 840 ${SED} -e "s/.*File: *//;s/bin\/gcc.*//;q"; \
837 else \ 841 else \
838 case ${_CC} in \ 842 case ${_CC} in \
839 ${LOCALBASE}/*) \ 843 ${LOCALBASE}/*) \
840 subprefix="${_CC:H:S/\/bin$//:S/${LOCALBASE}\///:S/${LOCALBASE}//}"; \ 844 subprefix="${_CC:H:S/\/bin$//:S/${LOCALBASE}\///:S/${LOCALBASE}//}"; \
841 case "$${subprefix}" in \ 845 case "$${subprefix}" in \
842 "") ${ECHO} "$${subprefix}" ;; \ 846 "") ${ECHO} "$${subprefix}" ;; \
843 *) ${ECHO} "$${subprefix}/" ;; \ 847 *) ${ECHO} "$${subprefix}/" ;; \
844 esac; \ 848 esac; \
845 ;; \ 849 ;; \
846 *) \ 850 *) \
847 ${ECHO} "_GCC_SUBPREFIX_not_found/"; \ 851 ${ECHO} "_GCC_SUBPREFIX_not_found/"; \
848 ;; \ 852 ;; \
849 esac; \ 853 esac; \
850 fi 854 fi
851_GCC_PREFIX= ${LOCALBASE}/${_GCC_SUBPREFIX} 855_GCC_PREFIX= ${LOCALBASE}/${_GCC_SUBPREFIX}
852_GCC_ARCHDIR!= \ 856_GCC_ARCHDIR!= \
853 if [ -x ${_GCC_PREFIX}bin/gcc ]; then \ 857 if [ -x ${_GCC_PREFIX}bin/gcc ]; then \
854 ${DIRNAME} `${_GCC_PREFIX}bin/gcc -print-libgcc-file-name 2>/dev/null`; \ 858 ${DIRNAME} `${_GCC_PREFIX}bin/gcc -print-libgcc-file-name 2>/dev/null`; \
855 else \ 859 else \
856 ${ECHO} "_GCC_ARCHDIR_not_found"; \ 860 ${ECHO} "_GCC_ARCHDIR_not_found"; \
857 fi 861 fi
858_GCC_LIBDIRS= ${_GCC_ARCHDIR} 862_GCC_LIBDIRS= ${_GCC_ARCHDIR}
859. if empty(USE_PKGSRC_GCC_RUNTIME:M[Yy][Ee][Ss]) 863. if empty(USE_PKGSRC_GCC_RUNTIME:M[Yy][Ee][Ss])
860_GCC_LIBDIRS+= ${_GCC_PREFIX}lib${LIBABISUFFIX} 864_GCC_LIBDIRS+= ${_GCC_PREFIX}lib${LIBABISUFFIX}
861. endif 865. endif
862_GCC_LDFLAGS= # empty 866_GCC_LDFLAGS= # empty
863. for _dir_ in ${_GCC_LIBDIRS:N*not_found*} 867. for _dir_ in ${_GCC_LIBDIRS:N*not_found*}
864_GCC_LDFLAGS+= -L${_dir_} ${COMPILER_RPATH_FLAG}${_dir_} 868_GCC_LDFLAGS+= -L${_dir_} ${COMPILER_RPATH_FLAG}${_dir_}
865. endfor 869. endfor
866.endif 870.endif
867 871
868.if ${_PKGSRC_USE_RELRO} == "yes" 872.if ${_PKGSRC_USE_RELRO} == "yes"
869_GCC_LDFLAGS+= ${_RELRO_LDFLAGS} 873_GCC_LDFLAGS+= ${_RELRO_LDFLAGS}
870CWRAPPERS_PREPEND.cc+= ${_RELRO_LDFLAGS} 874CWRAPPERS_PREPEND.cc+= ${_RELRO_LDFLAGS}
871CWRAPPERS_PREPEND.cxx+= ${_RELRO_LDFLAGS} 875CWRAPPERS_PREPEND.cxx+= ${_RELRO_LDFLAGS}
872.endif 876.endif
873 877
874LDFLAGS+= ${_GCC_LDFLAGS} 878LDFLAGS+= ${_GCC_LDFLAGS}
875 879
876# Point the variables that specify the compiler to the installed 880# Point the variables that specify the compiler to the installed
877# GCC executables. 881# GCC executables.
878# 882#
879_GCC_DIR= ${WRKDIR}/.gcc 883_GCC_DIR= ${WRKDIR}/.gcc
880_GCC_VARS= # empty 884_GCC_VARS= # empty
881 885
882.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) 886.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
883_GCCBINDIR= ${_GCC_PREFIX}bin 887_GCCBINDIR= ${_GCC_PREFIX}bin
884.elif !empty(_IS_BUILTIN_GCC:M[yY][eE][sS]) 888.elif !empty(_IS_BUILTIN_GCC:M[yY][eE][sS])
885_GCCBINDIR= ${_CC:H} 889_GCCBINDIR= ${_CC:H}
886.endif 890.endif
887.if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS]) 891.if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS])
888_GCC_BIN_PREFIX= ${MACHINE_GNU_PLATFORM}- 892_GCC_BIN_PREFIX= ${MACHINE_GNU_PLATFORM}-
889.endif 893.endif
890_GCC_BIN_PREFIX?= # empty 894_GCC_BIN_PREFIX?= # empty
891GCC_VERSION_SUFFIX?= # empty 895GCC_VERSION_SUFFIX?= # empty
892.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}gcc${GCC_VERSION_SUFFIX}) 896.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}gcc${GCC_VERSION_SUFFIX})
893_GCC_VARS+= CC 897_GCC_VARS+= CC
894_GCC_CC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gcc${GCC_VERSION_SUFFIX} 898_GCC_CC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gcc${GCC_VERSION_SUFFIX}
895_ALIASES.CC= cc gcc 899_ALIASES.CC= cc gcc
896CCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gcc${GCC_VERSION_SUFFIX} 900CCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gcc${GCC_VERSION_SUFFIX}
897PKG_CC:= ${_GCC_CC} 901PKG_CC:= ${_GCC_CC}
898.endif 902.endif
899.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}cpp${GCC_VERSION_SUFFIX}) 903.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}cpp${GCC_VERSION_SUFFIX})
900_GCC_VARS+= CPP 904_GCC_VARS+= CPP
901_GCC_CPP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}cpp${GCC_VERSION_SUFFIX} 905_GCC_CPP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}cpp${GCC_VERSION_SUFFIX}
902_ALIASES.CPP= cpp 906_ALIASES.CPP= cpp
903CPPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}cpp${GCC_VERSION_SUFFIX} 907CPPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}cpp${GCC_VERSION_SUFFIX}
904PKG_CPP:= ${_GCC_CPP} 908PKG_CPP:= ${_GCC_CPP}
905.endif 909.endif
906.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}g++${GCC_VERSION_SUFFIX}) 910.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}g++${GCC_VERSION_SUFFIX})
907_GCC_VARS+= CXX 911_GCC_VARS+= CXX
908_GCC_CXX= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}g++${GCC_VERSION_SUFFIX} 912_GCC_CXX= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}g++${GCC_VERSION_SUFFIX}
909_ALIASES.CXX= c++ g++ 913_ALIASES.CXX= c++ g++
910CXXPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g++${GCC_VERSION_SUFFIX} 914CXXPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g++${GCC_VERSION_SUFFIX}
911PKG_CXX:= ${_GCC_CXX} 915PKG_CXX:= ${_GCC_CXX}
912.endif 916.endif
913.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77${GCC_VERSION_SUFFIX}) 917.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77${GCC_VERSION_SUFFIX})
914_GCC_VARS+= FC 918_GCC_VARS+= FC
915_GCC_FC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}g77${GCC_VERSION_SUFFIX} 919_GCC_FC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}g77${GCC_VERSION_SUFFIX}
916_ALIASES.FC= f77 g77 920_ALIASES.FC= f77 g77
917FC= g77 921FC= g77
918FCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77${GCC_VERSION_SUFFIX} 922FCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77${GCC_VERSION_SUFFIX}
919F77PATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77${GCC_VERSION_SUFFIX} 923F77PATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}g77${GCC_VERSION_SUFFIX}
920PKG_FC:= ${_GCC_FC} 924PKG_FC:= ${_GCC_FC}
921PKGSRC_FORTRAN?= g77 925PKGSRC_FORTRAN?= g77
922.endif 926.endif
923.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran${GCC_VERSION_SUFFIX}) 927.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran${GCC_VERSION_SUFFIX})
924_GCC_VARS+= FC 928_GCC_VARS+= FC
925_GCC_FC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gfortran${GCC_VERSION_SUFFIX} 929_GCC_FC= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gfortran${GCC_VERSION_SUFFIX}
926_ALIASES.FC= gfortran 930_ALIASES.FC= gfortran
927FC= gfortran 931FC= gfortran
928FCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran${GCC_VERSION_SUFFIX} 932FCPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran${GCC_VERSION_SUFFIX}
929F77PATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran${GCC_VERSION_SUFFIX} 933F77PATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gfortran${GCC_VERSION_SUFFIX}
930PKG_FC:= ${_GCC_FC} 934PKG_FC:= ${_GCC_FC}
931PKGSRC_FORTRAN?= gfortran 935PKGSRC_FORTRAN?= gfortran
932.endif 936.endif
933.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}ada) 937.if exists(${_GCCBINDIR}/${_GCC_BIN_PREFIX}ada)
934_GCC_VARS+= ADA GMK GLK GBD CHP PRP GLS GNT 938_GCC_VARS+= ADA GMK GLK GBD CHP PRP GLS GNT
935_GCC_ADA= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}ada 939_GCC_ADA= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}ada
936_GCC_GMK= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatmake 940_GCC_GMK= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatmake
937_GCC_GLK= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatlink 941_GCC_GLK= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatlink
938_GCC_GBD= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatbind 942_GCC_GBD= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatbind
939_GCC_CHP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatchop 943_GCC_CHP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatchop
940_GCC_PRP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatprep 944_GCC_PRP= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatprep
941_GCC_GLS= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatls 945_GCC_GLS= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnatls
942_GCC_GNT= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnat 946_GCC_GNT= ${_GCC_DIR}/bin/${_GCC_BIN_PREFIX}gnat
943_ALIASES.ADA= ada 947_ALIASES.ADA= ada
944_ALIASES.GMK= gnatmake 948_ALIASES.GMK= gnatmake
945_ALIASES.GLK= gnatlink 949_ALIASES.GLK= gnatlink
946_ALIASES.GBD= gnatbind 950_ALIASES.GBD= gnatbind
947_ALIASES.CHP= gnatchop 951_ALIASES.CHP= gnatchop
948_ALIASES.PRP= gnatprep 952_ALIASES.PRP= gnatprep
949_ALIASES.GLS= gnatls 953_ALIASES.GLS= gnatls
950_ALIASES.GNT= gnat 954_ALIASES.GNT= gnat
951ADAPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}ada 955ADAPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}ada
952GMKPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatmake 956GMKPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatmake
953GLKPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatlink 957GLKPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatlink
954GBDPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatbind 958GBDPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatbind
955CHPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatchop 959CHPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatchop
956PRPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatprep 960PRPPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatprep
957GLSPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatls 961GLSPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnatls
958GNTPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnat 962GNTPATH= ${_GCCBINDIR}/${_GCC_BIN_PREFIX}gnat
959PKG_ADA:= ${_GCC_ADA} 963PKG_ADA:= ${_GCC_ADA}
960PKG_GMK:= ${_GCC_GMK} 964PKG_GMK:= ${_GCC_GMK}
961PKG_GLK:= ${_GCC_GLK} 965PKG_GLK:= ${_GCC_GLK}
962PKG_GBD:= ${_GCC_GBD} 966PKG_GBD:= ${_GCC_GBD}
963PKG_CHP:= ${_GCC_CHP} 967PKG_CHP:= ${_GCC_CHP}
964PKG_PRP:= ${_GCC_PRP} 968PKG_PRP:= ${_GCC_PRP}
965PKG_GLS:= ${_GCC_GLS} 969PKG_GLS:= ${_GCC_GLS}
966PKG_GNT:= ${_GCC_GNT} 970PKG_GNT:= ${_GCC_GNT}
967PKGSRC_ADA?= ada 971PKGSRC_ADA?= ada
968PKGSRC_GMK?= gnatmake 972PKGSRC_GMK?= gnatmake
969PKGSRC_GLK?= gnatlink 973PKGSRC_GLK?= gnatlink
970PKGSRC_GBD?= gnatbind 974PKGSRC_GBD?= gnatbind
971PKGSRC_CHP?= gnatchop 975PKGSRC_CHP?= gnatchop
972PKGSRC_PRP?= gnatprep 976PKGSRC_PRP?= gnatprep
973PKGSRC_GLS?= gnatls 977PKGSRC_GLS?= gnatls
974PKGSRC_GNT?= gnat 978PKGSRC_GNT?= gnat
975.endif 979.endif
976_COMPILER_STRIP_VARS+= ${_GCC_VARS} 980_COMPILER_STRIP_VARS+= ${_GCC_VARS}
977 981
978# Pass the required flags to imake to tell it we're using gcc on Solaris. 982# Pass the required flags to imake to tell it we're using gcc on Solaris.
979.if ${OPSYS} == "SunOS" 983.if ${OPSYS} == "SunOS"
980IMAKEOPTS+= -DHasGcc2=YES -DHasGcc2ForCplusplus=YES 984IMAKEOPTS+= -DHasGcc2=YES -DHasGcc2ForCplusplus=YES
981.endif 985.endif
982 986
983.if ${OPSYS} == "AIX" 987.if ${OPSYS} == "AIX"
984# On AIX the GCC toolchain recognizes -maix32 and -maix64, 988# On AIX the GCC toolchain recognizes -maix32 and -maix64,
985# -m32 or -m64 are not recognized. 989# -m32 or -m64 are not recognized.
986_COMPILER_ABI_FLAG.32= -maix32 990_COMPILER_ABI_FLAG.32= -maix32
987_COMPILER_ABI_FLAG.64= -maix64 991_COMPILER_ABI_FLAG.64= -maix64
988# On HP-UX the GCC toolchain must be specifically targeted to an ABI, 992# On HP-UX the GCC toolchain must be specifically targeted to an ABI,
989# -m32 or -m64 are not recognized. 993# -m32 or -m64 are not recognized.
990.elif ${OPSYS} == "HPUX" 994.elif ${OPSYS} == "HPUX"
991_COMPILER_ABI_FLAG.32= # empty 995_COMPILER_ABI_FLAG.32= # empty
992_COMPILER_ABI_FLAG.64= # empty 996_COMPILER_ABI_FLAG.64= # empty
993.elif !empty(MACHINE_ARCH:Mmips*) 997.elif !empty(MACHINE_ARCH:Mmips*)
994_COMPILER_ABI_FLAG.32= -mabi=n32 # ABI == "32" == "n32" 998_COMPILER_ABI_FLAG.32= -mabi=n32 # ABI == "32" == "n32"
995_COMPILER_ABI_FLAG.n32= -mabi=n32 999_COMPILER_ABI_FLAG.n32= -mabi=n32
996_COMPILER_ABI_FLAG.o32= -mabi=32 1000_COMPILER_ABI_FLAG.o32= -mabi=32
997_COMPILER_ABI_FLAG.64= -mabi=64 1001_COMPILER_ABI_FLAG.64= -mabi=64
998.elif !empty(MACHINE_ARCH:Maarch64*) 1002.elif !empty(MACHINE_ARCH:Maarch64*)
999_COMPILER_ABI_FLAG.32= -m32 1003_COMPILER_ABI_FLAG.32= -m32
1000_COMPILER_ABI_FLAG.64= # empty 1004_COMPILER_ABI_FLAG.64= # empty
1001.else 1005.else
1002_COMPILER_ABI_FLAG.32= -m32 1006_COMPILER_ABI_FLAG.32= -m32
1003_COMPILER_ABI_FLAG.64= -m64 1007_COMPILER_ABI_FLAG.64= -m64
1004.endif 1008.endif
1005 1009
1006.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) 1010.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
1007. if exists(${CCPATH}) 1011. if exists(${CCPATH})
1008CC_VERSION_STRING!= ${CCPATH} -v 2>&1 1012CC_VERSION_STRING!= ${CCPATH} -v 2>&1
1009CC_VERSION!= \ 1013CC_VERSION!= \
1010 if ${CCPATH} -dumpversion > /dev/null 2>&1; then \ 1014 if ${CCPATH} -dumpversion > /dev/null 2>&1; then \
1011 ${ECHO} "gcc-`${CCPATH} -dumpversion`"; \ 1015 ${ECHO} "gcc-`${CCPATH} -dumpversion`"; \
1012 else \ 1016 else \
1013 ${ECHO} "gcc-${_GCC_REQD}"; \ 1017 ${ECHO} "gcc-${_GCC_REQD}"; \
1014 fi 1018 fi
1015 1019
1016. else 1020. else
1017CC_VERSION_STRING= ${CC_VERSION} 1021CC_VERSION_STRING= ${CC_VERSION}
1018CC_VERSION= gcc-${_GCC_REQD} 1022CC_VERSION= gcc-${_GCC_REQD}
1019. endif 1023. endif
1020.else 1024.else
1021CC_VERSION_STRING= ${CC_VERSION} 1025CC_VERSION_STRING= ${CC_VERSION}
1022CC_VERSION= ${_GCC_PKG} 1026CC_VERSION= ${_GCC_PKG}
1023.endif 1027.endif
1024 1028
1025# The user can choose the level of stack smashing protection. 1029# The user can choose the level of stack smashing protection.
1026.if empty(CC_VERSION:Mgcc-[1-3].*) 1030.if empty(CC_VERSION:Mgcc-[1-3].*)
1027. if ${PKGSRC_USE_SSP} == "all" 1031. if ${PKGSRC_USE_SSP} == "all"
1028_SSP_CFLAGS= -fstack-protector-all 1032_SSP_CFLAGS= -fstack-protector-all
1029. elif ${PKGSRC_USE_SSP} == "strong" 1033. elif ${PKGSRC_USE_SSP} == "strong"
1030_SSP_CFLAGS= -fstack-protector-strong 1034_SSP_CFLAGS= -fstack-protector-strong
1031. else 1035. else
1032_SSP_CFLAGS= -fstack-protector 1036_SSP_CFLAGS= -fstack-protector
1033. endif 1037. endif
1034.endif 1038.endif
1035 1039
1036# Prepend the path to the compiler to the PATH. 1040# Prepend the path to the compiler to the PATH.
1037.if !empty(_LANGUAGES.gcc) 1041.if !empty(_LANGUAGES.gcc)
1038PREPEND_PATH+= ${_GCC_DIR}/bin 1042PREPEND_PATH+= ${_GCC_DIR}/bin
1039.endif 1043.endif
1040 1044
1041# Add the dependency on GCC. 1045# Add the dependency on GCC.
1042.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) 1046.if !empty(_USE_PKGSRC_GCC:M[yY][eE][sS])
1043. for _dir_ in ${_GCC_PKGSRCDIR} 1047. for _dir_ in ${_GCC_PKGSRCDIR}
1044. include "${_dir_}/buildlink3.mk" 1048. include "${_dir_}/buildlink3.mk"
1045. endfor 1049. endfor
1046.endif 1050.endif
1047 1051
1048# Add dependency on GCC libraries if requested. 1052# Add dependency on GCC libraries if requested.
1049.if (defined(_USE_GCC_SHLIB) && !empty(_USE_GCC_SHLIB:M[Yy][Ee][Ss])) && !empty(USE_PKGSRC_GCC_RUNTIME:M[Yy][Ee][Ss]) 1053.if (defined(_USE_GCC_SHLIB) && !empty(_USE_GCC_SHLIB:M[Yy][Ee][Ss])) && !empty(USE_PKGSRC_GCC_RUNTIME:M[Yy][Ee][Ss])
1050# Special case packages which are themselves a dependency of gcc runtime. 1054# Special case packages which are themselves a dependency of gcc runtime.
1051. if ${PKGPATH} != devel/libtool-base && ${PKGPATH} != devel/binutils && \ 1055. if ${PKGPATH} != devel/libtool-base && ${PKGPATH} != devel/binutils && \
1052 empty(PKGPATH:Mlang/gcc4?) && empty(PKGPATH:Mlang/gcc[5-9]) && \ 1056 empty(PKGPATH:Mlang/gcc4?) && empty(PKGPATH:Mlang/gcc[5-9]) && \
1053 empty(PKGPATH:Mlang/gcc10) && empty(PKGPATH:Mlang/gcc12) && \ 1057 empty(PKGPATH:Mlang/gcc10) && empty(PKGPATH:Mlang/gcc12) && \
1054 empty(PKGPATH:Mlang/gcc13) 1058 empty(PKGPATH:Mlang/gcc13)
1055. if !empty(_GCC_PKGBASE:Mgcc6) 1059. if !empty(_GCC_PKGBASE:Mgcc6)
1056. include "../../lang/gcc6-libs/buildlink3.mk" 1060. include "../../lang/gcc6-libs/buildlink3.mk"
1057. elif !empty(_GCC_PKGBASE:Mgcc7) 1061. elif !empty(_GCC_PKGBASE:Mgcc7)
1058. include "../../lang/gcc7-libs/buildlink3.mk" 1062. include "../../lang/gcc7-libs/buildlink3.mk"
1059. elif !empty(_GCC_PKGBASE:Mgcc8) 1063. elif !empty(_GCC_PKGBASE:Mgcc8)
1060. include "../../lang/gcc8-libs/buildlink3.mk" 1064. include "../../lang/gcc8-libs/buildlink3.mk"
1061. elif !empty(_GCC_PKGBASE:Mgcc9) 1065. elif !empty(_GCC_PKGBASE:Mgcc9)
1062. include "../../lang/gcc9-libs/buildlink3.mk" 1066. include "../../lang/gcc9-libs/buildlink3.mk"
1063. elif !empty(_GCC_PKGBASE:Mgcc10) 1067. elif !empty(_GCC_PKGBASE:Mgcc10)
1064. include "../../lang/gcc10-libs/buildlink3.mk" 1068. include "../../lang/gcc10-libs/buildlink3.mk"
1065. elif !empty(_GCC_PKGBASE:Mgcc12) 1069. elif !empty(_GCC_PKGBASE:Mgcc12)
1066. include "../../lang/gcc12-libs/buildlink3.mk" 1070. include "../../lang/gcc12-libs/buildlink3.mk"
1067. elif !empty(_GCC_PKGBASE:Mgcc13) 1071. elif !empty(_GCC_PKGBASE:Mgcc13)
1068. include "../../lang/gcc13-libs/buildlink3.mk" 1072. include "../../lang/gcc13-libs/buildlink3.mk"
1069. else 1073. else
1070PKG_FAIL_REASON+= "No USE_PKGSRC_GCC_RUNTIME support for ${CC_VERSION}" 1074PKG_FAIL_REASON+= "No USE_PKGSRC_GCC_RUNTIME support for ${CC_VERSION}"
1071. endif 1075. endif
1072. endif 1076. endif
1073.endif 1077.endif
1074 1078
1075.for _var_ in ${_GCC_VARS} 1079.for _var_ in ${_GCC_VARS}
1076. if !target(${_GCC_${_var_}}) 1080. if !target(${_GCC_${_var_}})
1077override-tools: ${_GCC_${_var_}} 1081override-tools: ${_GCC_${_var_}}
1078${_GCC_${_var_}}: 1082${_GCC_${_var_}}:
1079 ${RUN}${MKDIR} ${.TARGET:H} 1083 ${RUN}${MKDIR} ${.TARGET:H}
1080. if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss]) 1084. if !empty(COMPILER_USE_SYMLINKS:M[Yy][Ee][Ss])
1081 ${RUN}${RM} -f ${.TARGET} 1085 ${RUN}${RM} -f ${.TARGET}
1082 ${RUN}${LN} -s ${_GCCBINDIR}/${.TARGET:T} ${.TARGET} 1086 ${RUN}${LN} -s ${_GCCBINDIR}/${.TARGET:T} ${.TARGET}
1083. else 1087. else
1084 ${RUN} \ 1088 ${RUN} \
1085 (${ECHO} '#!${TOOLS_SHELL}'; \ 1089 (${ECHO} '#!${TOOLS_SHELL}'; \
1086 ${ECHO} 'exec ${_GCCBINDIR}/${.TARGET:T} "$$@"'; \ 1090 ${ECHO} 'exec ${_GCCBINDIR}/${.TARGET:T} "$$@"'; \
1087 ) > ${.TARGET} 1091 ) > ${.TARGET}
1088 ${RUN}${CHMOD} +x ${.TARGET} 1092 ${RUN}${CHMOD} +x ${.TARGET}
1089. endif 1093. endif
1090. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//} 1094. for _alias_ in ${_ALIASES.${_var_}:S/^/${.TARGET:H}\//}
1091 ${RUN} \ 1095 ${RUN} \
1092 if [ ! -x "${_alias_}" ]; then \ 1096 if [ ! -x "${_alias_}" ]; then \
1093 ${LN} -f -s ${.TARGET:T} ${_alias_}; \ 1097 ${LN} -f -s ${.TARGET:T} ${_alias_}; \
1094 fi 1098 fi
1095. endfor 1099. endfor
1096. endif 1100. endif
1097.endfor 1101.endfor
1098 1102
1099# On systems without a Fortran compiler, pull one in if needed. 1103# On systems without a Fortran compiler, pull one in if needed.
1100PKGSRC_FORTRAN?=gfortran 1104PKGSRC_FORTRAN?=gfortran
1101 1105
1102_GCC_NEEDS_A_FORTRAN= no 1106_GCC_NEEDS_A_FORTRAN= no
1103.if empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) && !(defined(FCPATH) && exists(${FCPATH})) 1107.if empty(_USE_PKGSRC_GCC:M[yY][eE][sS]) && !(defined(FCPATH) && exists(${FCPATH}))
1104_GCC_NEEDS_A_FORTRAN= yes 1108_GCC_NEEDS_A_FORTRAN= yes
1105.else 1109.else
1106. for _pattern_ in 0.* 1.[0-4] 1.[0-4].* 1110. for _pattern_ in 0.* 1.[0-4] 1.[0-4].*
1107. if !empty(MACHINE_PLATFORM:MNetBSD-${_pattern_}-*) 1111. if !empty(MACHINE_PLATFORM:MNetBSD-${_pattern_}-*)
1108_GCC_NEEDS_A_FORTRAN= yes 1112_GCC_NEEDS_A_FORTRAN= yes
1109. endif 1113. endif
1110. endfor 1114. endfor
1111.endif 1115.endif
1112.if !empty(_GCC_NEEDS_A_FORTRAN:M[yY][eE][sS]) 1116.if !empty(_GCC_NEEDS_A_FORTRAN:M[yY][eE][sS])
1113. include "../../mk/compiler/${PKGSRC_FORTRAN}.mk" 1117. include "../../mk/compiler/${PKGSRC_FORTRAN}.mk"
1114.endif 1118.endif
1115 1119
1116.if ${OPSYS} == "Interix" && !empty(_GCCBINDIR:M/opt/gcc.*) 1120.if ${OPSYS} == "Interix" && !empty(_GCCBINDIR:M/opt/gcc.*)
1117COMPILER_INCLUDE_DIRS= ${_GCCBINDIR:H}/include ${_OPSYS_INCLUDE_DIRS} 1121COMPILER_INCLUDE_DIRS= ${_GCCBINDIR:H}/include ${_OPSYS_INCLUDE_DIRS}
1118COMPILER_LIB_DIRS= ${_GCCBINDIR:H}/lib ${_OPSYS_LIB_DIRS} 1122COMPILER_LIB_DIRS= ${_GCCBINDIR:H}/lib ${_OPSYS_LIB_DIRS}
1119.endif 1123.endif
1120 1124
1121#.READONLY: GCC_REQD 1125#.READONLY: GCC_REQD
1122_GCC_REQD_EFFECTIVE:= ${GCC_REQD} 1126_GCC_REQD_EFFECTIVE:= ${GCC_REQD}
1123 1127
1124.endif # COMPILER_GCC_MK 1128.endif # COMPILER_GCC_MK