Fri Jul 21 08:29:56 2023 UTC ()
mk: Add put_time to USE_CXX_FEATURES. C++11 feature, but appeared in GCC 5.


(nia)
diff -r1.186 -r1.187 pkgsrc/doc/guide/files/fixes.xml
diff -r1.100 -r1.101 pkgsrc/mk/compiler.mk
diff -r1.255 -r1.256 pkgsrc/mk/compiler/gcc.mk

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

--- pkgsrc/doc/guide/files/fixes.xml 2023/07/18 12:49:46 1.186
+++ pkgsrc/doc/guide/files/fixes.xml 2023/07/21 08:29:56 1.187
@@ -1,2460 +1,2460 @@ @@ -1,2460 +1,2460 @@
1<!-- $NetBSD: fixes.xml,v 1.186 2023/07/18 12:49:46 nia Exp $ --> 1<!-- $NetBSD: fixes.xml,v 1.187 2023/07/21 08:29:56 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 1461charconv, parallelism_ts, unique_ptr, put_time
1462</programlisting> 1462</programlisting>
1463 .</para> 1463 .</para>
1464 </para> 1464 </para>
1465 </sect2> 1465 </sect2>
1466 1466
1467 <sect2 id="java-programming-language"> 1467 <sect2 id="java-programming-language">
1468 <title>Java</title> 1468 <title>Java</title>
1469 1469
1470 <para>If a program is written in Java, use the Java framework in 1470 <para>If a program is written in Java, use the Java framework in
1471 pkgsrc. The package must include 1471 pkgsrc. The package must include
1472 <filename>../../mk/java-vm.mk</filename>. This Makefile fragment 1472 <filename>../../mk/java-vm.mk</filename>. This Makefile fragment
1473 provides the following variables:</para> 1473 provides the following variables:</para>
1474 1474
1475 <itemizedlist> 1475 <itemizedlist>
1476 <listitem><para><varname>USE_JAVA</varname> defines if a build 1476 <listitem><para><varname>USE_JAVA</varname> defines if a build
1477 dependency on the JDK is added. If 1477 dependency on the JDK is added. If
1478 <varname>USE_JAVA</varname> is set to <quote>run</quote>, then 1478 <varname>USE_JAVA</varname> is set to <quote>run</quote>, then
1479 there is only a runtime dependency on the JDK. The default is 1479 there is only a runtime dependency on the JDK. The default is
1480 <quote>yes</quote>, which also adds a build dependency on the 1480 <quote>yes</quote>, which also adds a build dependency on the
1481 JDK.</para></listitem> 1481 JDK.</para></listitem>
1482 1482
1483 <listitem><para>Set <varname>USE_JAVA2</varname> to declare that 1483 <listitem><para>Set <varname>USE_JAVA2</varname> to declare that
1484 a package needs a Java2 implementation. The supported values 1484 a package needs a Java2 implementation. The supported values
1485 are <quote>yes</quote>, <quote>1.4</quote>, and 1485 are <quote>yes</quote>, <quote>1.4</quote>, and
1486 <quote>1.5</quote>. <quote>yes</quote> accepts any Java2 1486 <quote>1.5</quote>. <quote>yes</quote> accepts any Java2
1487 implementation, <quote>1.4</quote> insists on versions 1.4 or 1487 implementation, <quote>1.4</quote> insists on versions 1.4 or
1488 above, and <quote>1.5</quote> only accepts versions 1.5 or 1488 above, and <quote>1.5</quote> only accepts versions 1.5 or
1489 above. This variable is not set by default.</para></listitem> 1489 above. This variable is not set by default.</para></listitem>
1490 1490
1491 <listitem><para><varname>PKG_JAVA_HOME</varname> is 1491 <listitem><para><varname>PKG_JAVA_HOME</varname> is
1492 automatically set to the runtime location of the used Java 1492 automatically set to the runtime location of the used Java
1493 implementation dependency. It may be used to set 1493 implementation dependency. It may be used to set
1494 <varname>JAVA_HOME</varname> to a good value if the program 1494 <varname>JAVA_HOME</varname> to a good value if the program
1495 needs this variable to be defined. 1495 needs this variable to be defined.
1496 </para></listitem> 1496 </para></listitem>
1497 <!-- XXX: describe PKG_JVM_DEFAULT and PKG_JVMS_ACCEPTED, but 1497 <!-- XXX: describe PKG_JVM_DEFAULT and PKG_JVMS_ACCEPTED, but
1498 not here --> 1498 not here -->
1499 </itemizedlist> 1499 </itemizedlist>
1500 </sect2> 1500 </sect2>
1501 1501
1502 <sect2 id="go-programming-language"> 1502 <sect2 id="go-programming-language">
1503 <title>Go</title> 1503 <title>Go</title>
1504 1504
1505 <para>If a program is written in Go and has any dependencies on 1505 <para>If a program is written in Go and has any dependencies on
1506 other Go modules, have the package include 1506 other Go modules, have the package include
1507 <filename>../../lang/go/go-module.mk</filename>.</para> 1507 <filename>../../lang/go/go-module.mk</filename>.</para>
1508 1508
1509 1509
1510 <orderedlist> 1510 <orderedlist>
1511 <listitem><para>Generate a list of those dependencies with 1511 <listitem><para>Generate a list of those dependencies with
1512 <command>make clean && make patch && make show-go-modules > 1512 <command>make clean && make patch && make show-go-modules >
1513 go-modules.mk</command>.</para></listitem> 1513 go-modules.mk</command>.</para></listitem>
1514 1514
1515 <listitem><para>Prepend 1515 <listitem><para>Prepend
1516 <literal>.include "go-modules.mk"</literal> to any other 1516 <literal>.include "go-modules.mk"</literal> to any other
1517 <literal>.include</literal>s.</para></listitem> 1517 <literal>.include</literal>s.</para></listitem>
1518 1518
1519 <listitem><para>Incorporate these modules in 1519 <listitem><para>Incorporate these modules in
1520 <filename>distinfo</filename> with <command>make 1520 <filename>distinfo</filename> with <command>make
1521 makesum</command>.</para></listitem> 1521 makesum</command>.</para></listitem>
1522 </orderedlist> 1522 </orderedlist>
1523 </sect2> 1523 </sect2>
1524 1524
1525 <sect2 id="rust-programming-language"> 1525 <sect2 id="rust-programming-language">
1526 <title>Rust</title> 1526 <title>Rust</title>
1527 1527
1528 <para>If a program is written in Rust and uses Cargo to build, 1528 <para>If a program is written in Rust and uses Cargo to build,
1529 have the package include 1529 have the package include
1530 <filename>../../lang/rust/cargo.mk</filename>.</para> 1530 <filename>../../lang/rust/cargo.mk</filename>.</para>
1531 1531
1532 <orderedlist> 1532 <orderedlist>
1533 <listitem><para>Generate a list of those dependencies with 1533 <listitem><para>Generate a list of those dependencies with
1534 <command>make CARGO_ARGS="build --release" build && 1534 <command>make CARGO_ARGS="build --release" build &&
1535 make print-cargo-depends > cargo-depends.mk</command>.</para></listitem> 1535 make print-cargo-depends > cargo-depends.mk</command>.</para></listitem>
1536 1536
1537 <listitem><para>Prepend 1537 <listitem><para>Prepend
1538 <literal>.include "cargo-depends.mk"</literal> to any other 1538 <literal>.include "cargo-depends.mk"</literal> to any other
1539 <literal>.include</literal>s.</para></listitem> 1539 <literal>.include</literal>s.</para></listitem>
1540 1540
1541 <listitem><para>Incorporate these modules in 1541 <listitem><para>Incorporate these modules in
1542 <filename>distinfo</filename> with <command>make 1542 <filename>distinfo</filename> with <command>make
1543 makesum</command>.</para></listitem> 1543 makesum</command>.</para></listitem>
1544 </orderedlist> 1544 </orderedlist>
1545 </sect2> 1545 </sect2>
1546 1546
1547 <sect2 id="perl-scripts"> 1547 <sect2 id="perl-scripts">
1548 <title>Packages containing Perl scripts</title> 1548 <title>Packages containing Perl scripts</title>
1549 1549
1550 <para>If your package contains interpreted Perl scripts, add 1550 <para>If your package contains interpreted Perl scripts, add
1551 <quote>perl</quote> to the <varname>USE_TOOLS</varname> variable 1551 <quote>perl</quote> to the <varname>USE_TOOLS</varname> variable
1552 and set <varname>REPLACE_PERL</varname> to ensure that the proper 1552 and set <varname>REPLACE_PERL</varname> to ensure that the proper
1553 interpreter path is set. <varname>REPLACE_PERL</varname> should 1553 interpreter path is set. <varname>REPLACE_PERL</varname> should
1554 contain a list of scripts, relative to <varname>WRKSRC</varname>, 1554 contain a list of scripts, relative to <varname>WRKSRC</varname>,
1555 that you want adjusted. Every occurrence of 1555 that you want adjusted. Every occurrence of
1556 <filename>*/bin/perl</filename> in a she-bang line will be 1556 <filename>*/bin/perl</filename> in a she-bang line will be
1557 replaced with the full path to the Perl executable.</para> 1557 replaced with the full path to the Perl executable.</para>
1558 1558
1559 <para>If a particular version of Perl is needed, set the 1559 <para>If a particular version of Perl is needed, set the
1560 <varname>PERL5_REQD</varname> variable to the version number. The 1560 <varname>PERL5_REQD</varname> variable to the version number. The
1561 default is <quote>5.0</quote>.</para> 1561 default is <quote>5.0</quote>.</para>
1562 1562
1563 <para>See <xref linkend="perl-modules" /> for information 1563 <para>See <xref linkend="perl-modules" /> for information
1564 about handling Perl modules.</para> 1564 about handling Perl modules.</para>
1565 1565
1566 <para>There is also the <varname>REPLACE_PERL6</varname> variable 1566 <para>There is also the <varname>REPLACE_PERL6</varname> variable
1567 for the language now known as Raku.</para> 1567 for the language now known as Raku.</para>
1568 </sect2> 1568 </sect2>
1569 1569
1570 <sect2 id="shell-scripts"> 1570 <sect2 id="shell-scripts">
1571 <title>Packages containing shell scripts</title> 1571 <title>Packages containing shell scripts</title>
1572 1572
1573 <para><varname>REPLACE_SH</varname>, 1573 <para><varname>REPLACE_SH</varname>,
1574 <varname>REPLACE_BASH</varname>, <varname>REPLACE_CSH</varname>, 1574 <varname>REPLACE_BASH</varname>, <varname>REPLACE_CSH</varname>,
1575 and <varname>REPLACE_KSH</varname> can be used to replace shell 1575 and <varname>REPLACE_KSH</varname> can be used to replace shell
1576 she-bangs in files. Please use the appropriate one, preferring 1576 she-bangs in files. Please use the appropriate one, preferring
1577 <varname>REPLACE_SH</varname> when this shell is sufficient. 1577 <varname>REPLACE_SH</varname> when this shell is sufficient.
1578 Each should contain a list of scripts, relative to 1578 Each should contain a list of scripts, relative to
1579 <varname>WRKSRC</varname>, that you want adjusted. Every 1579 <varname>WRKSRC</varname>, that you want adjusted. Every
1580 occurrence of the matching shell in a she-bang line will be 1580 occurrence of the matching shell in a she-bang line will be
1581 replaced with the full path to the shell executable. 1581 replaced with the full path to the shell executable.
1582 When using <varname>REPLACE_BASH</varname>, don't forget to add 1582 When using <varname>REPLACE_BASH</varname>, don't forget to add
1583 <filename>bash</filename> to <varname>USE_TOOLS</varname>.</para> 1583 <filename>bash</filename> to <varname>USE_TOOLS</varname>.</para>
1584 </sect2> 1584 </sect2>
1585 1585
1586 <sect2 id="other-programming-languages"> 1586 <sect2 id="other-programming-languages">
1587 <title>Other programming languages</title> 1587 <title>Other programming languages</title>
1588 1588
1589 <para>There are further similar REPLACE variables available, e.g., 1589 <para>There are further similar REPLACE variables available, e.g.,
1590 <varname>REPLACE_AWK</varname> for packages containing awk scripts, 1590 <varname>REPLACE_AWK</varname> for packages containing awk scripts,
1591 and <varname>REPLACE_R</varname> for R. These two, like the others 1591 and <varname>REPLACE_R</varname> for R. These two, like the others
1592 noted above, have their actions defined centrally in 1592 noted above, have their actions defined centrally in
1593 <filename>mk/configure/replace-interpreter.mk</filename>. Other 1593 <filename>mk/configure/replace-interpreter.mk</filename>. Other
1594 languages define the actions of these variables within their own 1594 languages define the actions of these variables within their own
1595 dedicated part of the tree, e.g., <varname>REPLACE_PHP</varname> is 1595 dedicated part of the tree, e.g., <varname>REPLACE_PHP</varname> is
1596 actioned in <filename>lang/php/phpversion.mk</filename>, and 1596 actioned in <filename>lang/php/phpversion.mk</filename>, and
1597 <varname>REPLACE_PYTHON</varname> is actioned in 1597 <varname>REPLACE_PYTHON</varname> is actioned in
1598 <filename>lang/python/application.mk</filename>. For other languages, 1598 <filename>lang/python/application.mk</filename>. For other languages,
1599 consult the mk files found within their specific directories (the 1599 consult the mk files found within their specific directories (the
1600 naming convention varies), or check the list found in 1600 naming convention varies), or check the list found in
1601 <xref linkend="help-topics" />.</para> 1601 <xref linkend="help-topics" />.</para>
1602 1602
1603 <para>Currently, special handling for other languages varies 1603 <para>Currently, special handling for other languages varies
1604 in pkgsrc. If a compiler package provides a 1604 in pkgsrc. If a compiler package provides a
1605 <filename>buildlink3.mk</filename> file, include that, otherwise 1605 <filename>buildlink3.mk</filename> file, include that, otherwise
1606 just add a (build) dependency on the appropriate compiler 1606 just add a (build) dependency on the appropriate compiler
1607 package.</para> 1607 package.</para>
1608 </sect2> 1608 </sect2>
1609</sect1> 1609</sect1>
1610 1610
1611<sect1 id="fixes.build"> 1611<sect1 id="fixes.build">
1612 <title>The <emphasis>build</emphasis> phase</title> 1612 <title>The <emphasis>build</emphasis> phase</title>
1613 1613
1614 <para>The most common failures when building a package are that 1614 <para>The most common failures when building a package are that
1615 some platforms do not provide certain header files, functions or 1615 some platforms do not provide certain header files, functions or
1616 libraries, or they provide the functions in a library that the 1616 libraries, or they provide the functions in a library that the
1617 original package author didn't know. To work around this, you 1617 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 1618 can rewrite the source code in most cases so that it does not
1619 use the missing functions or provides a replacement function.</para> 1619 use the missing functions or provides a replacement function.</para>
1620 1620
1621<sect2 id="fixes.build.cpp"> 1621<sect2 id="fixes.build.cpp">
1622<title>Compiling C and C++ code conditionally</title> 1622<title>Compiling C and C++ code conditionally</title>
1623 1623
1624 <para>If a package already comes with a GNU configure script, the 1624 <para>If a package already comes with a GNU configure script, the
1625 preferred way to fix the build failure is to change the 1625 preferred way to fix the build failure is to change the
1626 configure script, not the code. In the other cases, you can 1626 configure script, not the code. In the other cases, you can
1627 utilize the C preprocessor, which defines certain macros 1627 utilize the C preprocessor, which defines certain macros
1628 depending on the operating system and hardware architecture it 1628 depending on the operating system and hardware architecture it
1629 compiles for. These macros can be queried using for example 1629 compiles for. These macros can be queried using for example
1630 <varname>#if defined(__i386)</varname>. Almost every operating 1630 <varname>#if defined(__i386)</varname>. Almost every operating
1631 system, hardware architecture and compiler has its own macro. 1631 system, hardware architecture and compiler has its own macro.
1632 For example, if the macros <varname>__GNUC__</varname>, 1632 For example, if the macros <varname>__GNUC__</varname>,
1633 <varname>__i386__</varname> and <varname>__NetBSD__</varname> 1633 <varname>__i386__</varname> and <varname>__NetBSD__</varname>
1634 are all defined, you know that you are using NetBSD on an i386 1634 are all defined, you know that you are using NetBSD on an i386
1635 compatible CPU, and your compiler is GCC.</para> 1635 compatible CPU, and your compiler is GCC.</para>
1636 1636
1637 <para>The list of the following macros for hardware and 1637 <para>The list of the following macros for hardware and
1638 operating system depends on the compiler that is used. For 1638 operating system depends on the compiler that is used. For
1639 example, if you want to conditionally compile code on Solaris, 1639 example, if you want to conditionally compile code on Solaris,
1640 don't use <varname>__sun__</varname>, as the SunPro compiler 1640 don't use <varname>__sun__</varname>, as the SunPro compiler
1641 does not define it. Use <varname>__sun</varname> instead.</para> 1641 does not define it. Use <varname>__sun</varname> instead.</para>
1642 1642
1643<sect3 id="fixes.build.cpp.os"> 1643<sect3 id="fixes.build.cpp.os">
1644<title>C preprocessor macros to identify the operating system</title> 1644<title>C preprocessor macros to identify the operating system</title>
1645 1645
1646 <para>To distinguish between specific NetBSD versions, 1646 <para>To distinguish between specific NetBSD versions,
1647 you should use the following code.</para> 1647 you should use the following code.</para>
1648 1648
1649<programlisting> 1649<programlisting>
1650#ifdef __NetBSD__ 1650#ifdef __NetBSD__
1651#include &lt;sys/param.h&gt; 1651#include &lt;sys/param.h&gt;
1652#if __NetBSD_Prereq__(9,99,17) 1652#if __NetBSD_Prereq__(9,99,17)
1653/* use a newer feature */ 1653/* use a newer feature */
1654#else 1654#else
1655/* older code */ 1655/* older code */
1656#endif 1656#endif
1657#endif 1657#endif
1658 1658
1659#ifndef _WIN32 1659#ifndef _WIN32
1660/* Unix-like specific code */ 1660/* Unix-like specific code */
1661#endif 1661#endif
1662</programlisting> 1662</programlisting>
1663 1663
1664 <para>To distinguish between 4.4 BSD-derived systems and the 1664 <para>To distinguish between 4.4 BSD-derived systems and the
1665 rest of the world, you should use the following code.</para> 1665 rest of the world, you should use the following code.</para>
1666 1666
1667<programlisting> 1667<programlisting>
1668#include &lt;sys/param.h&gt; 1668#include &lt;sys/param.h&gt;
1669#if (defined(BSD) &amp;&amp; BSD &gt;= 199306) 1669#if (defined(BSD) &amp;&amp; BSD &gt;= 199306)
1670/* BSD-specific code goes here */ 1670/* BSD-specific code goes here */
1671#else 1671#else
1672/* non-BSD-specific code goes here */ 1672/* non-BSD-specific code goes here */
1673#endif 1673#endif
1674</programlisting> 1674</programlisting>
1675 1675
1676 <para>You can also test for the following macros:</para> 1676 <para>You can also test for the following macros:</para>
1677 1677
1678<programlisting> 1678<programlisting>
1679Cygwin __CYGWIN__ 1679Cygwin __CYGWIN__
1680DragonFly __DragonFly__ 1680DragonFly __DragonFly__
1681FreeBSD __FreeBSD__ 1681FreeBSD __FreeBSD__
1682Haiku __HAIKU__ 1682Haiku __HAIKU__
1683Interix __INTERIX 1683Interix __INTERIX
1684IRIX __sgi (TODO: get a definite source for this) 1684IRIX __sgi (TODO: get a definite source for this)
1685Linux __linux 1685Linux __linux
1686Mac OS X __APPLE__ 1686Mac OS X __APPLE__
1687MirBSD __MirBSD__ (__OpenBSD__ is also defined) 1687MirBSD __MirBSD__ (__OpenBSD__ is also defined)
1688Minix3 __minix 1688Minix3 __minix
1689NetBSD __NetBSD__ 1689NetBSD __NetBSD__
1690OpenBSD __OpenBSD__ 1690OpenBSD __OpenBSD__
1691Solaris sun, __sun 1691Solaris sun, __sun
1692</programlisting> 1692</programlisting>
1693 1693
1694</sect3> 1694</sect3>
1695<sect3 id="fixes.build.cpp.arch"> 1695<sect3 id="fixes.build.cpp.arch">
1696<title>C preprocessor macros to identify the hardware architecture</title> 1696<title>C preprocessor macros to identify the hardware architecture</title>
1697 1697
1698<programlisting> 1698<programlisting>
1699i386 i386, __i386, __i386__ 1699i386 i386, __i386, __i386__
1700x86-64 __amd64__, __x86_64__ 1700x86-64 __amd64__, __x86_64__
1701ARM __arm__ 1701ARM __arm__
1702MIPS __mips 1702MIPS __mips
1703SPARC sparc, __sparc 1703SPARC sparc, __sparc
1704PowerPC __powerpc 1704PowerPC __powerpc
1705</programlisting> 1705</programlisting>
1706 1706
1707</sect3> 1707</sect3>
1708<sect3 id="fixes.build.cpp.compiler"> 1708<sect3 id="fixes.build.cpp.compiler">
1709<title>C preprocessor macros to identify the compiler</title> 1709<title>C preprocessor macros to identify the compiler</title>
1710 1710
1711<programlisting> 1711<programlisting>
1712GCC __GNUC__ (major version), __GNUC_MINOR__ 1712GCC __GNUC__ (major version), __GNUC_MINOR__
1713MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41) 1713MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
1714SunPro __SUNPRO_C (0x570 for Sun C 5.7) 1714SunPro __SUNPRO_C (0x570 for Sun C 5.7)
1715SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8) 1715SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
1716</programlisting> 1716</programlisting>
1717 1717
1718</sect3> 1718</sect3>
1719</sect2> 1719</sect2>
1720<sect2 id="compiler-bugs"> 1720<sect2 id="compiler-bugs">
1721<title>How to handle compiler bugs</title> 1721<title>How to handle compiler bugs</title>
1722 1722
1723 <para>Some source files trigger bugs in the compiler, based on 1723 <para>Some source files trigger bugs in the compiler, based on
1724 combinations of compiler version and architecture and almost 1724 combinations of compiler version and architecture and almost
1725 always relation to optimisation being enabled. Common symptoms 1725 always relation to optimisation being enabled. Common symptoms
1726 are gcc internal errors or never finishing compiling a 1726 are gcc internal errors or never finishing compiling a
1727 file.</para> 1727 file.</para>
1728 1728
1729 <para>Typically, a workaround involves testing the 1729 <para>Typically, a workaround involves testing the
1730 <varname>MACHINE_ARCH</varname> and compiler version, disabling 1730 <varname>MACHINE_ARCH</varname> and compiler version, disabling
1731 optimisation for that combination of file, 1731 optimisation for that combination of file,
1732 <varname>MACHINE_ARCH</varname> and compiler.</para> 1732 <varname>MACHINE_ARCH</varname> and compiler.</para>
1733 1733
1734 <para>This used to be a big problem in the past, but is rarely 1734 <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 1735 needed now as compiler technology has matured. If you still need
1736 to add a compiler specific workaround, please do so in the file 1736 to add a compiler specific workaround, please do so in the file
1737 <filename>hacks.mk</filename> and describe the symptom and 1737 <filename>hacks.mk</filename> and describe the symptom and
1738 compiler version as detailed as possible.</para> 1738 compiler version as detailed as possible.</para>
1739 1739
1740</sect2> 1740</sect2>
1741 1741
1742<sect2 id="fixes.build.header"> 1742<sect2 id="fixes.build.header">
1743<title>No such file or directory</title> 1743<title>No such file or directory</title>
1744 1744
1745<para>Compilation sometimes fails with an error message like this:</para> 1745<para>Compilation sometimes fails with an error message like this:</para>
1746 1746
1747<programlisting> 1747<programlisting>
1748.../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10: 1748.../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
1749 fatal error: pango/pango.h: No such file or directory 1749 fatal error: pango/pango.h: No such file or directory
1750</programlisting> 1750</programlisting>
1751 1751
1752<para>The proper way to fix this problem depends on the type of the 1752<para>The proper way to fix this problem depends on the type of the
1753header, which is described in the following sections.</para> 1753header, which is described in the following sections.</para>
1754 1754
1755<sect3 id="fixes.build.header.bl3"> 1755<sect3 id="fixes.build.header.bl3">
1756<title>Headers from other packages</title> 1756<title>Headers from other packages</title>
1757 1757
1758<para>If the header name looks like it comes from a different package, 1758<para>If the header name looks like it comes from a different package,
1759that other package should be included via the buildlink3 1759that other package should be included via the buildlink3
1760framework.</para> 1760framework.</para>
1761 1761
1762<para>First, look whether the header is somewhere in the buildlink3 1762<para>First, look whether the header is somewhere in the buildlink3
1763directory below <varname>WRKDIR</varname>. In the above case of 1763directory below <varname>WRKDIR</varname>. In the above case of
1764the missing Pango header:</para> 1764the missing Pango header:</para>
1765 1765
1766<programlisting> 1766<programlisting>
1767&uprompt; find work/.buildlink/ -print | grep -F pango/pango.h 1767&uprompt; find work/.buildlink/ -print | grep -F pango/pango.h
1768</programlisting> 1768</programlisting>
1769 1769
1770<para>In the case of Pango, the output is:</para> 1770<para>In the case of Pango, the output is:</para>
1771 1771
1772<programlisting> 1772<programlisting>
1773work/.buildlink/include/pango-1.0/pango/pango.h 1773work/.buildlink/include/pango-1.0/pango/pango.h
1774</programlisting> 1774</programlisting>
1775 1775
1776<para>If the <filename>pango/pango.h</filename> file were placed directly 1776<para>If the <filename>pango/pango.h</filename> file were placed directly
1777in the <filename>.buildlink</filename> directory, it would have been 1777in the <filename>.buildlink</filename> directory, it would have been
1778found automatically. There is an extra <filename>pango-1.0</filename> 1778found automatically. There is an extra <filename>pango-1.0</filename>
1779path component though, which means that the compiler command line must 1779path component though, which means that the compiler command line must
1780contain an option of the form 1780contain an option of the form
1781<literal>-I${BUILDLINK3_PREFIX.pango}/include/pango-1.0</literal>. In 1781<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> 1782most cases this option is generated by the configure script, which can be examined using:</para>
1783 1783
1784<programlisting> 1784<programlisting>
1785&uprompt; $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile 1785&uprompt; $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
1786-I/usr/pkg/include/pango-1.0 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</programlisting> 1791</programlisting>
1792 1792
1793<para>This looks good. These options are transformed by the buildlink 1793<para>This looks good. These options are transformed by the buildlink
1794wrapper to refer to the correct path inside 1794wrapper to refer to the correct path inside
1795<filename>work/.buildlink</filename>.</para> 1795<filename>work/.buildlink</filename>.</para>
1796 1796
1797<para>Since the compilation fails though, examine the compiler command 1797<para>Since the compilation fails though, examine the compiler command
1798lines in <filename>work/.work.log</filename> to see whether the 1798lines in <filename>work/.work.log</filename> to see whether the
1799<literal>-I</literal> option is included in the particular command 1799<literal>-I</literal> option is included in the particular command
1800line.</para> 1800line.</para>
1801 1801
1802<para>To further analyze the situation, run <command>bmake 1802<para>To further analyze the situation, run <command>bmake
1803build-env</command>, which sets up an interactive, realistic environment 1803build-env</command>, which sets up an interactive, realistic environment
1804including all the pkgsrc wrapper commands and environment variables. From 1804including all the pkgsrc wrapper commands and environment variables. From
1805there, try to compile some simple example programs that use the 1805there, try to compile some simple example programs that use the
1806header.</para> 1806header.</para>
1807 1807
1808</sect3> 1808</sect3>
1809 1809
1810<sect3 id="fixes.build.header.gen"> 1810<sect3 id="fixes.build.header.gen">
1811<title>Headers generated during the build</title> 1811<title>Headers generated during the build</title>
1812 1812
1813<para>If the name of the header seems to come from the package itself, 1813<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 1814and if the build is run with parallel jobs, the package may have some
1815undeclared dependencies between the <filename>.c</filename> and the 1815undeclared dependencies between the <filename>.c</filename> and the
1816<filename>.h</filename> files, and a C file is compiled before its 1816<filename>.h</filename> files, and a C file is compiled before its
1817required header is generated.</para> 1817required header is generated.</para>
1818 1818
1819<para>To see whether the build runs with parallel jobs, run 1819<para>To see whether the build runs with parallel jobs, run
1820<command>bmake show-all-build | grep JOBS</command>. Its output looks 1820<command>bmake show-all-build | grep JOBS</command>. Its output looks
1821like this:</para> 1821like this:</para>
1822 1822
1823<programlisting> 1823<programlisting>
1824 usr MAKE_JOBS= 7 1824 usr MAKE_JOBS= 7
1825 pkg MAKE_JOBS_SAFE # undefined 1825 pkg MAKE_JOBS_SAFE # undefined
1826 def _MAKE_JOBS_N= 7 1826 def _MAKE_JOBS_N= 7
1827</programlisting> 1827</programlisting>
1828 1828
1829<para>In this case the pkgsrc user has asked pkgsrc to build packages 1829<para>In this case the pkgsrc user has asked pkgsrc to build packages
1830with 7 jobs in parallel (<varname>MAKE_JOBS</varname>). The 1830with 7 jobs in parallel (<varname>MAKE_JOBS</varname>). The
1831package could have disabled parallel builds by setting 1831package could have disabled parallel builds by setting
1832<varname>MAKE_JOBS_SAFE</varname> to <literal>no</literal>, but 1832<varname>MAKE_JOBS_SAFE</varname> to <literal>no</literal>, but
1833in this case it hasn't.</para> 1833in this case it hasn't.</para>
1834 1834
1835<para>To see whether the build failure is caused by parallel builds, 1835<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 1836first save the exact error message and a bit of context, maybe you need
1837it later for reporting a bug. Next, run:</para> 1837it later for reporting a bug. Next, run:</para>
1838 1838
1839<programlisting> 1839<programlisting>
1840MAKE_JOBS_SAFE=no bmake clean build 1840MAKE_JOBS_SAFE=no bmake clean build
1841</programlisting> 1841</programlisting>
1842 1842
1843<para>If that succeeds, <ulink 1843<para>If that succeeds, <ulink
1844url="https://www.NetBSD.org/cgi-bin/sendpr.cgi?gndb=netbsd">file a bug 1844url="https://www.NetBSD.org/cgi-bin/sendpr.cgi?gndb=netbsd">file a bug
1845report</ulink> against the pkgsrc package, including the exact error 1845report</ulink> against the pkgsrc package, including the exact error
1846message and the contents of your &mk.conf; file.</para> 1846message and the contents of your &mk.conf; file.</para>
1847 1847
1848</sect3> 1848</sect3>
1849 1849
1850<sect3 id="fixes.build.header.symlink"> 1850<sect3 id="fixes.build.header.symlink">
1851<title>Symlinks</title> 1851<title>Symlinks</title>
1852 1852
1853<para>Pkgsrc does not work reliably if any of 1853<para>Pkgsrc does not work reliably if any of
1854<varname>LOCALBASE</varname>, <varname>VARBASE</varname> or 1854<varname>LOCALBASE</varname>, <varname>VARBASE</varname> or
1855<varname>WRKDIR</varname> contains a symlink. Since 2019Q2, the pkgsrc 1855<varname>WRKDIR</varname> contains a symlink. Since 2019Q2, the pkgsrc
1856bootstrap program prevents installing pkgsrc in symlink-based 1856bootstrap program prevents installing pkgsrc in symlink-based
1857directories. Existing pkgsrc installations are not checked for symlinks 1857directories. Existing pkgsrc installations are not checked for symlinks
1858though.</para> 1858though.</para>
1859 1859
1860<para>The "No such file or directory" error messages are a typical 1860<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 1861symptom of symlinks, and it's quite difficult to find out that this is
1862the actual cause.</para> 1862the actual cause.</para>
1863 1863
1864</sect3> 1864</sect3>
1865 1865
1866<sect3 id="fixes.build.header.stale"> 1866<sect3 id="fixes.build.header.stale">
1867<title>Stale working directories</title> 1867<title>Stale working directories</title>
1868 1868
1869<para>When building a hierarchy of packages, it may happen that one 1869<para>When building a hierarchy of packages, it may happen that one
1870package is built and then pkgsrc is updated. This situation can provoke 1870package is built and then pkgsrc is updated. This situation can provoke
1871various hard to diagnose build errors. To clean up the situation:</para> 1871various hard to diagnose build errors. To clean up the situation:</para>
1872 1872
1873<programlisting> 1873<programlisting>
1874&uprompt; (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work) 1874&uprompt; (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work)
1875</programlisting> 1875</programlisting>
1876 1876
1877<para>(The only purpose of the <filename>bsd.pkg.mk</filename> is to 1877<para>(The only purpose of the <filename>bsd.pkg.mk</filename> is to
1878prevent running this command in the wrong directory.)</para> 1878prevent running this command in the wrong directory.)</para>
1879 1879
1880<para>If you have set <varname>WRKOBJDIR</varname> in &mk.conf;, remove 1880<para>If you have set <varname>WRKOBJDIR</varname> in &mk.conf;, remove
1881that directory as well.</para> 1881that directory as well.</para>
1882 1882
1883</sect3> 1883</sect3>
1884 1884
1885<sect3 id="fixes.build.header.misc"> 1885<sect3 id="fixes.build.header.misc">
1886<title>Other possible reasons</title> 1886<title>Other possible reasons</title>
1887 1887
1888<para>On platforms other than BSD, third-party packages are installed in 1888<para>On platforms other than BSD, third-party packages are installed in
1889<filename>/usr/include</filename>, together with the base system. This 1889<filename>/usr/include</filename>, together with the base system. This
1890means that pkgsrc cannot distinguish between headers provided by the base 1890means that pkgsrc cannot distinguish between headers provided by the base
1891system (which it needs) and headers from third-party packages (which are 1891system (which it needs) and headers from third-party packages (which are
1892often included in pkgsrc as well). This can lead to subtle version 1892often included in pkgsrc as well). This can lead to subtle version
1893mismatches.</para> 1893mismatches.</para>
1894 1894
1895<para>In pkgsrc installations that have been active for several years, it 1895<para>In pkgsrc installations that have been active for several years, it
1896may happen that some files are manually deleted. To exclude this unlikely 1896may happen that some files are manually deleted. To exclude this unlikely
1897reason, run <command>pkg_admin check</command>.</para> 1897reason, run <command>pkg_admin check</command>.</para>
1898 1898
1899<para>It may help to run <command>pkg_admin rebuild-tree</command> to 1899<para>It may help to run <command>pkg_admin rebuild-tree</command> to
1900check/fix dependencies.</para> 1900check/fix dependencies.</para>
1901 1901
1902<para>If all of the above doesn't help, see <xref linkend="help-user"/> 1902<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 1903for contact information. Be prepared to describe what you have tried so
1904far and what any error messages were.</para> 1904far and what any error messages were.</para>
1905 1905
1906</sect3> 1906</sect3>
1907 1907
1908</sect2> 1908</sect2>
1909 1909
1910<sect2 id="undefined-reference"> 1910<sect2 id="undefined-reference">
1911<title>Undefined reference to <quote>...</quote></title> 1911<title>Undefined reference to <quote>...</quote></title>
1912 1912
1913 <para>This error message often means that a package did not 1913 <para>This error message often means that a package did not
1914 link to a shared library it needs. The following functions are 1914 link to a shared library it needs. The following functions are
1915 known to cause this error message over and over.</para> 1915 known to cause this error message over and over.</para>
1916 1916
1917 <informaltable id="undefined-reference-functions"> 1917 <informaltable id="undefined-reference-functions">
1918 <tgroup cols="3"> 1918 <tgroup cols="3">
1919 <thead><row><entry>Function</entry><entry>Library</entry><entry>Affected platforms</entry></row></thead> 1919 <thead><row><entry>Function</entry><entry>Library</entry><entry>Affected platforms</entry></row></thead>
1920 <tbody> 1920 <tbody>
1921 <row><entry>accept, bind, connect</entry><entry>-lsocket</entry><entry>Solaris</entry></row> 1921 <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> 1922 <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> 1923 <row><entry>dlopen, dlsym</entry><entry>-ldl</entry><entry>Linux</entry></row>
1924 <row><entry>gethost*</entry><entry>-lnsl</entry><entry>Solaris</entry></row> 1924 <row><entry>gethost*</entry><entry>-lnsl</entry><entry>Solaris</entry></row>
1925 <row><entry>inet_aton</entry><entry>-lresolv</entry><entry>Solaris</entry></row> 1925 <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> 1926 <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> 1927 <row><entry>openpty</entry><entry>-lutil</entry><entry>Linux</entry></row>
1928 </tbody> 1928 </tbody>
1929 </tgroup> 1929 </tgroup>
1930 </informaltable> 1930 </informaltable>
1931 1931
1932 <para>To fix these linker errors, it is often sufficient to add 1932 <para>To fix these linker errors, it is often sufficient to add
1933 <literal>LIBS.<replaceable>OperatingSystem</replaceable>+= 1933 <literal>LIBS.<replaceable>OperatingSystem</replaceable>+=
1934 -l<replaceable>foo</replaceable></literal> to the package 1934 -l<replaceable>foo</replaceable></literal> to the package
1935 <filename>Makefile</filename> and then run <command>bmake clean; 1935 <filename>Makefile</filename> and then run <command>bmake clean;
1936 bmake</command>.</para> 1936 bmake</command>.</para>
1937 1937
1938<sect3 id="undefined-reference-sunpro"> 1938<sect3 id="undefined-reference-sunpro">
1939<title>The SunPro compiler and inline functions</title> 1939<title>The SunPro compiler and inline functions</title>
1940 1940
1941<para>When you are using the SunPro compiler, there is another 1941<para>When you are using the SunPro compiler, there is another
1942possibility. That compiler cannot handle the following code:</para> 1942possibility. That compiler cannot handle the following code:</para>
1943 1943
1944<programlisting> 1944<programlisting>
1945extern int extern_func(int); 1945extern int extern_func(int);
1946 1946
1947static inline int 1947static inline int
1948inline_func(int x) 1948inline_func(int x)
1949{ 1949{
1950 return extern_func(x); 1950 return extern_func(x);
1951} 1951}
1952 1952
1953int main(void) 1953int main(void)
1954{ 1954{
1955 return 0; 1955 return 0;
1956} 1956}
1957</programlisting> 1957</programlisting>
1958 1958
1959<para>It generates the code for <function>inline_func</function> even if 1959<para>It generates the code for <function>inline_func</function> even if
1960that function is never used. This code then refers to 1960that function is never used. This code then refers to
1961<function>extern_func</function>, which can usually not be resolved. To 1961<function>extern_func</function>, which can usually not be resolved. To
1962solve this problem you can try to tell the package to disable inlining 1962solve this problem you can try to tell the package to disable inlining
1963of functions.</para> 1963of functions.</para>
1964 1964
1965</sect3> 1965</sect3>
1966 1966
1967<sect3 id="undefined-reference-atomic"> 1967<sect3 id="undefined-reference-atomic">
1968 <title>Missing atomic functions</title> 1968 <title>Missing atomic functions</title>
1969  1969
1970 <para>When building for older machine architectures (e.g., i386, PowerPC), 1970 <para>When building for older machine architectures (e.g., i386, PowerPC),
1971 builds may fail because the package expects modern 64-bit atomic functions 1971 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 1972 which the underlying hardware either doesn't support, or will only support
1973 with specific compiler flags. This is generally handled via inclusion of 1973 with specific compiler flags. This is generally handled via inclusion of
1974 mk/atomic64.mk.</para> 1974 mk/atomic64.mk.</para>
1975</sect3> 1975</sect3>
1976 1976
1977</sect2> 1977</sect2>
1978 1978
1979 <sect2 id="out-of-memory"> 1979 <sect2 id="out-of-memory">
1980 <title>Running out of memory</title> 1980 <title>Running out of memory</title>
1981 1981
1982 <para>Sometimes packages fail to build because the compiler runs 1982 <para>Sometimes packages fail to build because the compiler runs
1983 into an operating system specific soft limit. With the 1983 into an operating system specific soft limit. With the
1984 <varname>UNLIMIT_RESOURCES</varname> variable pkgsrc can be told 1984 <varname>UNLIMIT_RESOURCES</varname> variable pkgsrc can be told
1985 to unlimit the resources. The allowed values are any combination of 1985 to unlimit the resources. The allowed values are any combination of
1986 <quote>cputime</quote>, 1986 <quote>cputime</quote>,
1987 <quote>datasize</quote>, 1987 <quote>datasize</quote>,
1988 <quote>memorysize</quote>, 1988 <quote>memorysize</quote>,
1989 <quote>stacksize</quote> and 1989 <quote>stacksize</quote> and
1990 <quote>virtualsize</quote>. 1990 <quote>virtualsize</quote>.
1991 Setting this variable is similar to running the shell builtin 1991 Setting this variable is similar to running the shell builtin
1992 <command>ulimit</command> command to raise the maximum data 1992 <command>ulimit</command> command to raise the maximum data
1993 segment size or maximum stack size of a process, respectively, to 1993 segment size or maximum stack size of a process, respectively, to
1994 their hard limits.</para> 1994 their hard limits.</para>
1995 </sect2> 1995 </sect2>
1996</sect1> 1996</sect1>
1997 1997
1998<sect1 id="fixes.install"> 1998<sect1 id="fixes.install">
1999 <title>The <emphasis>install</emphasis> phase</title> 1999 <title>The <emphasis>install</emphasis> phase</title>
2000 2000
2001 <sect2 id="install-scripts"> 2001 <sect2 id="install-scripts">
2002 <title>Creating needed directories</title> 2002 <title>Creating needed directories</title>
2003 2003
2004 <para>The BSD-compatible <command>install</command> supplied 2004 <para>The BSD-compatible <command>install</command> supplied
2005 with some operating systems cannot create more than one 2005 with some operating systems cannot create more than one
2006 directory at a time. As such, you should call 2006 directory at a time. As such, you should call
2007 <literal>${INSTALL_*_DIR}</literal> like this:</para> 2007 <literal>${INSTALL_*_DIR}</literal> like this:</para>
2008 2008
2009<programlisting> 2009<programlisting>
2010${INSTALL_DATA_DIR} ${PREFIX}/dir1 2010${INSTALL_DATA_DIR} ${PREFIX}/dir1
2011${INSTALL_DATA_DIR} ${PREFIX}/dir2 2011${INSTALL_DATA_DIR} ${PREFIX}/dir2
2012</programlisting> 2012</programlisting>
2013 2013
2014 <para>Instead of running the <command>install</command> commands 2014 <para>Instead of running the <command>install</command> commands
2015 directly, you can also append <quote><literal>dir1 2015 directly, you can also append <quote><literal>dir1
2016 dir2</literal></quote> to the <varname>INSTALLATION_DIRS</varname> 2016 dir2</literal></quote> to the <varname>INSTALLATION_DIRS</varname>
2017 variable, which will automatically do the right thing.</para> 2017 variable, which will automatically do the right thing.</para>
2018 2018
2019 </sect2> 2019 </sect2>
2020 <sect2 id="where-to-install-documentation"> 2020 <sect2 id="where-to-install-documentation">
2021 <title>Where to install documentation</title> 2021 <title>Where to install documentation</title>
2022 2022
2023 <para>In general, documentation should be installed into 2023 <para>In general, documentation should be installed into
2024 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or 2024 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or
2025 <filename>${PREFIX}/share/doc/${PKGNAME_NOREV}</filename> (the latter 2025 <filename>${PREFIX}/share/doc/${PKGNAME_NOREV}</filename> (the latter
2026 includes the version number of the package).</para> 2026 includes the version number of the package).</para>
2027 2027
2028 <para>Many modern packages using GNU autoconf allow to set the 2028 <para>Many modern packages using GNU autoconf allow to set the
2029 directory where HTML documentation is installed with the 2029 directory where HTML documentation is installed with the
2030 <quote>--with-html-dir</quote> option. Sometimes using this flag is 2030 <quote>--with-html-dir</quote> option. Sometimes using this flag is
2031 needed because otherwise the documentation ends up in 2031 needed because otherwise the documentation ends up in
2032 <filename>${PREFIX}/share/doc/html</filename> or other places. In 2032 <filename>${PREFIX}/share/doc/html</filename> or other places. In
2033 pkgsrc, the HTML documentation should go into the package-specific 2033 pkgsrc, the HTML documentation should go into the package-specific
2034 directory, just like any other documentation.</para> 2034 directory, just like any other documentation.</para>
2035 2035
2036 <para>An exception to the above is that library API documentation 2036 <para>An exception to the above is that library API documentation
2037 generated with the <filename 2037 generated with the <filename
2038 role="pkg">textproc/gtk-doc</filename> tools, for use by special 2038 role="pkg">textproc/gtk-doc</filename> tools, for use by special
2039 browsers (devhelp) should be left at their default location, which 2039 browsers (devhelp) should be left at their default location, which
2040 is <filename>${PREFIX}/share/gtk-doc</filename>. Such 2040 is <filename>${PREFIX}/share/gtk-doc</filename>. Such
2041 documentation can be recognized from files ending in 2041 documentation can be recognized from files ending in
2042 <filename>.devhelp</filename> or <filename>.devhelp2</filename>. 2042 <filename>.devhelp</filename> or <filename>.devhelp2</filename>.
2043 (It is also acceptable to install such files in 2043 (It is also acceptable to install such files in
2044 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or 2044 <filename>${PREFIX}/share/doc/${PKGBASE}</filename> or
2045 <filename>${PREFIX}/share/doc/${PKGNAME}</filename>; the 2045 <filename>${PREFIX}/share/doc/${PKGNAME}</filename>; the
2046 <filename>.devhelp*</filename> file must be directly in that 2046 <filename>.devhelp*</filename> file must be directly in that
2047 directory then, no additional subdirectory level is allowed in 2047 directory then, no additional subdirectory level is allowed in
2048 this case. This is usually achieved by using 2048 this case. This is usually achieved by using
2049 <quote>--with-html-dir=${PREFIX}/share/doc</quote>. 2049 <quote>--with-html-dir=${PREFIX}/share/doc</quote>.
2050 <filename>${PREFIX}/share/gtk-doc</filename> is preferred 2050 <filename>${PREFIX}/share/gtk-doc</filename> is preferred
2051 though.)</para> 2051 though.)</para>
2052 2052
2053 </sect2> 2053 </sect2>
2054 2054
2055 <sect2 id="installing-score-files"> 2055 <sect2 id="installing-score-files">
2056 <title>Installing highscore files</title> 2056 <title>Installing highscore files</title>
2057 2057
2058 <para>Certain packages, most of them in the games category, install 2058 <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 2059 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 2060 highscores. In order for this to work, the binaries need to be
2061 installed setgid and the score files owned by the appropriate 2061 installed setgid and the score files owned by the appropriate
2062 group and/or owner (traditionally the "games" user/group). Set 2062 group and/or owner (traditionally the "games" user/group). Set
2063 <varname>USE_GAMESGROUP</varname> to yes to support this. The 2063 <varname>USE_GAMESGROUP</varname> to yes to support this. The
2064 following variables, documented in more detail in 2064 following variables, documented in more detail in
2065 <filename>mk/defaults/mk.conf</filename>, control this 2065 <filename>mk/defaults/mk.conf</filename>, control this
2066 behaviour: <varname>GAMEDATAMODE</varname>, 2066 behaviour: <varname>GAMEDATAMODE</varname>,
2067 <varname>GAMEDIRMODE</varname>, <varname>GAMES_GROUP</varname>, 2067 <varname>GAMEDIRMODE</varname>, <varname>GAMES_GROUP</varname>,
2068 <varname>GAMEMODE</varname>, <varname>GAME_USER</varname>. 2068 <varname>GAMEMODE</varname>, <varname>GAME_USER</varname>.
2069 Other useful variables are: <varname>GAMEDIR_PERMS</varname>, 2069 Other useful variables are: <varname>GAMEDIR_PERMS</varname>,
2070 <varname>GAMEDATA_PERMS</varname> and 2070 <varname>GAMEDATA_PERMS</varname> and
2071 <varname>SETGID_GAMES_PERMS</varname>.</para> 2071 <varname>SETGID_GAMES_PERMS</varname>.</para>
2072 2072
2073 <para>An example that illustrates some of the variables described above is 2073 <para>An example that illustrates some of the variables described above is
2074 <filename>games/moon-buggy</filename>. <varname>OWN_DIRS_PERMS</varname> is 2074 <filename>games/moon-buggy</filename>. <varname>OWN_DIRS_PERMS</varname> is
2075 used to properly set directory permissions of the directory where the 2075 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 2076 scorefile is saved, <varname>REQD_FILES_PERMS</varname> is used to create a
2077 dummy scorefile (<filename>mbscore</filename>) with the proper permissions 2077 dummy scorefile (<filename>mbscore</filename>) with the proper permissions
2078 and <varname>SPECIAL_PERMS</varname> is used to install setgid the game 2078 and <varname>SPECIAL_PERMS</varname> is used to install setgid the game
2079 binary:</para> 2079 binary:</para>
2080 2080
2081<programlisting> 2081<programlisting>
2082USE_GAMESGROUP= yes 2082USE_GAMESGROUP= yes
2083 2083
2084BUILD_DEFS+= VARBASE 2084BUILD_DEFS+= VARBASE
2085 2085
2086OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS} 2086OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
2087REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS} 2087REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
2088SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS} 2088SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
2089</programlisting> 2089</programlisting>
2090 2090
2091 <para>Various <varname>INSTALL_*</varname> variables are also available: 2091 <para>Various <varname>INSTALL_*</varname> variables are also available:
2092 <varname>INSTALL_GAME</varname> to install setgid game binaries, 2092 <varname>INSTALL_GAME</varname> to install setgid game binaries,
2093 <varname>INSTALL_GAME_DIR</varname> to install game directories that are 2093 <varname>INSTALL_GAME_DIR</varname> to install game directories that are
2094 needed to be accessed by setgid games and 2094 needed to be accessed by setgid games and
2095 <varname>INSTALL_GAME_DATA</varname> to install scorefiles.</para> 2095 <varname>INSTALL_GAME_DATA</varname> to install scorefiles.</para>
2096 2096
2097 <para>A package should therefore never hard code file ownership or 2097 <para>A package should therefore never hard code file ownership or
2098 access permissions but rely on <varname>*_PERMS</varname> as described above 2098 access permissions but rely on <varname>*_PERMS</varname> as described above
2099 or alternatively on <varname>INSTALL_GAME</varname>, 2099 or alternatively on <varname>INSTALL_GAME</varname>,
2100 <varname>INSTALL_GAME_DATA</varname> and 2100 <varname>INSTALL_GAME_DATA</varname> and
2101 <varname>INSTALL_GAME_DIR</varname> to set these correctly.</para> 2101 <varname>INSTALL_GAME_DIR</varname> to set these correctly.</para>
2102 </sect2> 2102 </sect2>
2103 2103
2104 <sect2 id="destdir-support"> 2104 <sect2 id="destdir-support">
2105 <title>Adding DESTDIR support to packages</title> 2105 <title>Adding DESTDIR support to packages</title>
2106 2106
2107 <para><varname>DESTDIR</varname> support means that a package 2107 <para><varname>DESTDIR</varname> support means that a package
2108 installs into a staging directory, not the final location of the 2108 installs into a staging directory, not the final location of the
2109 files. Then a binary package is created which can be used for 2109 files. Then a binary package is created which can be used for
2110 installation as usual. There are two ways: Either the package must 2110 installation as usual. There are two ways: Either the package must
2111 install as root (<quote>destdir</quote>) or the package can 2111 install as root (<quote>destdir</quote>) or the package can
2112 install as non-root user (<quote>user-destdir</quote>).</para> 2112 install as non-root user (<quote>user-destdir</quote>).</para>
2113 2113
2114 <itemizedlist> 2114 <itemizedlist>
2115 <listitem><para><varname>PKG_DESTDIR_SUPPORT</varname> has to be 2115 <listitem><para><varname>PKG_DESTDIR_SUPPORT</varname> has to be
2116 set to <quote>destdir</quote> or <quote>user-destdir</quote>. 2116 set to <quote>destdir</quote> or <quote>user-destdir</quote>.
2117 By default <varname>PKG_DESTDIR_SUPPORT</varname> 2117 By default <varname>PKG_DESTDIR_SUPPORT</varname>
2118 is set to <quote>user-destdir</quote> to help catching more 2118 is set to <quote>user-destdir</quote> to help catching more
2119 potential packaging problems. If bsd.prefs.mk is included in the Makefile, 2119 potential packaging problems. If bsd.prefs.mk is included in the Makefile,
2120 <varname>PKG_DESTDIR_SUPPORT</varname> needs to be set before 2120 <varname>PKG_DESTDIR_SUPPORT</varname> needs to be set before
2121 the inclusion.</para></listitem> 2121 the inclusion.</para></listitem>
2122 2122
2123 <listitem><para>All installation operations have to be prefixed with 2123 <listitem><para>All installation operations have to be prefixed with
2124 <filename>${DESTDIR}</filename>.</para></listitem> 2124 <filename>${DESTDIR}</filename>.</para></listitem>
2125 2125
2126 <listitem><para>automake gets this DESTDIR mostly right 2126 <listitem><para>automake gets this DESTDIR mostly right
2127 automatically. Many manual rules and pre/post-install often are 2127 automatically. Many manual rules and pre/post-install often are
2128 incorrect; fix them.</para></listitem> 2128 incorrect; fix them.</para></listitem>
2129 2129
2130 <listitem><para>If files are installed with special owner/group 2130 <listitem><para>If files are installed with special owner/group
2131 use <varname>SPECIAL_PERMS</varname>.</para></listitem> 2131 use <varname>SPECIAL_PERMS</varname>.</para></listitem>
2132 2132
2133 <listitem><para>In general, packages should support 2133 <listitem><para>In general, packages should support
2134 <varname>UNPRIVILEGED</varname> to be able to use 2134 <varname>UNPRIVILEGED</varname> to be able to use
2135 DESTDIR.</para></listitem> 2135 DESTDIR.</para></listitem>
2136 2136
2137 </itemizedlist> 2137 </itemizedlist>
2138 </sect2> 2138 </sect2>
2139 2139
2140 2140
2141 <sect2 id="hardcoded-paths"> 2141 <sect2 id="hardcoded-paths">
2142 <title>Packages with hardcoded paths to other interpreters</title> 2142 <title>Packages with hardcoded paths to other interpreters</title>
2143 2143
2144 <para>Your package may also contain scripts with hardcoded paths to 2144 <para>Your package may also contain scripts with hardcoded paths to
2145 other interpreters besides (or as well as) Perl. To correct the 2145 other interpreters besides (or as well as) Perl. To correct the
2146 full pathname to the script interpreter, you need to set the 2146 full pathname to the script interpreter, you need to set the
2147 following definitions in your <filename>Makefile</filename> (we 2147 following definitions in your <filename>Makefile</filename> (we
2148 shall use <command>tclsh</command> in this example):</para> 2148 shall use <command>tclsh</command> in this example):</para>
2149 2149
2150<programlisting> 2150<programlisting>
2151REPLACE_INTERPRETER+= tcl 2151REPLACE_INTERPRETER+= tcl
2152REPLACE.tcl.old= .*/bin/tclsh 2152REPLACE.tcl.old= .*/bin/tclsh
2153REPLACE.tcl.new= ${PREFIX}/bin/tclsh 2153REPLACE.tcl.new= ${PREFIX}/bin/tclsh
2154REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed, 2154REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
2155# relative to ${WRKSRC}, just as in REPLACE_PERL 2155# relative to ${WRKSRC}, just as in REPLACE_PERL
2156</programlisting> 2156</programlisting>
2157 2157
2158 </sect2> 2158 </sect2>
2159 2159
2160 2160
2161 <sect2 id="perl-modules"> 2161 <sect2 id="perl-modules">
2162 <title>Packages installing Perl modules</title> 2162 <title>Packages installing Perl modules</title>
2163 2163
2164 <para>Makefiles of packages providing perl5 modules should include 2164 <para>Makefiles of packages providing perl5 modules should include
2165 the Makefile fragment 2165 the Makefile fragment
2166 <filename>../../lang/perl5/module.mk</filename>. It provides a 2166 <filename>../../lang/perl5/module.mk</filename>. It provides a
2167 <command>do-configure</command> target for the standard perl 2167 <command>do-configure</command> target for the standard perl
2168 configuration for such modules as well as various hooks to tune 2168 configuration for such modules as well as various hooks to tune
2169 this configuration. See comments in this file for 2169 this configuration. See comments in this file for
2170 details.</para> 2170 details.</para>
2171 2171
2172 <para>Perl5 modules will install into different places depending 2172 <para>Perl5 modules will install into different places depending
2173 on the version of perl used during the build process. To 2173 on the version of perl used during the build process. To
2174 address this, pkgsrc will append lines to the 2174 address this, pkgsrc will append lines to the
2175 <filename>PLIST</filename> corresponding to the files listed in 2175 <filename>PLIST</filename> corresponding to the files listed in
2176 the installed <filename>.packlist</filename> file generated by 2176 the installed <filename>.packlist</filename> file generated by
2177 most perl5 modules. This is invoked by defining 2177 most perl5 modules. This is invoked by defining
2178 <varname>PERL5_PACKLIST</varname> to a space-separated list of 2178 <varname>PERL5_PACKLIST</varname> to a space-separated list of
2179 packlist files relative to <varname>PERL5_PACKLIST_DIR</varname> 2179 packlist files relative to <varname>PERL5_PACKLIST_DIR</varname>
2180 (<varname>PERL5_INSTALLVENDORARCH</varname> by default), 2180 (<varname>PERL5_INSTALLVENDORARCH</varname> by default),
2181 e.g.:</para> 2181 e.g.:</para>
2182 2182
2183<programlisting> 2183<programlisting>
2184PERL5_PACKLIST= auto/Pg/.packlist 2184PERL5_PACKLIST= auto/Pg/.packlist
2185</programlisting> 2185</programlisting>
2186 2186
2187 <para>The perl5 config variables 2187 <para>The perl5 config variables
2188 <varname>installarchlib</varname>, 2188 <varname>installarchlib</varname>,
2189 <varname>installscript</varname>, 2189 <varname>installscript</varname>,
2190 <varname>installvendorbin</varname>, 2190 <varname>installvendorbin</varname>,
2191 <varname>installvendorscript</varname>, 2191 <varname>installvendorscript</varname>,
2192 <varname>installvendorarch</varname>, 2192 <varname>installvendorarch</varname>,
2193 <varname>installvendorlib</varname>, 2193 <varname>installvendorlib</varname>,
2194 <varname>installvendorman1dir</varname>, and 2194 <varname>installvendorman1dir</varname>, and
2195 <varname>installvendorman3dir</varname> represent those 2195 <varname>installvendorman3dir</varname> represent those
2196 locations in which components of perl5 modules may be installed, 2196 locations in which components of perl5 modules may be installed,
2197 provided as variable with uppercase and prefixed with 2197 provided as variable with uppercase and prefixed with
2198 <varname>PERL5_</varname>, e.g. <varname>PERL5_INSTALLARCHLIB</varname> 2198 <varname>PERL5_</varname>, e.g. <varname>PERL5_INSTALLARCHLIB</varname>
2199 and may be used by perl5 packages that don't have a packlist. 2199 and may be used by perl5 packages that don't have a packlist.
2200 These variables are also substituted for in the 2200 These variables are also substituted for in the
2201 <filename>PLIST</filename> as uppercase prefixed with 2201 <filename>PLIST</filename> as uppercase prefixed with
2202 <varname>PERL5_SUB_</varname>.</para> 2202 <varname>PERL5_SUB_</varname>.</para>
2203 </sect2> 2203 </sect2>
2204 2204
2205 2205
2206 <sect2 id="faq.info-files"> 2206 <sect2 id="faq.info-files">
2207 <title>Packages installing info files</title> 2207 <title>Packages installing info files</title>
2208 2208
2209 <para>Some packages install info files or use the 2209 <para>Some packages install info files or use the
2210 <quote>makeinfo</quote> or <quote>install-info</quote> 2210 <quote>makeinfo</quote> or <quote>install-info</quote>
2211 commands. <varname>INFO_FILES</varname> should be defined in 2211 commands. <varname>INFO_FILES</varname> should be defined in
2212 the package Makefile so that <filename>INSTALL</filename> and 2212 the package Makefile so that <filename>INSTALL</filename> and
2213 <filename>DEINSTALL</filename> scripts will be generated to 2213 <filename>DEINSTALL</filename> scripts will be generated to
2214 handle registration of the info files in the Info directory 2214 handle registration of the info files in the Info directory
2215 file. The <quote>install-info</quote> command used for the info 2215 file. The <quote>install-info</quote> command used for the info
2216 files registration is either provided by the system, or by a 2216 files registration is either provided by the system, or by a
2217 special purpose package automatically added as dependency if 2217 special purpose package automatically added as dependency if
2218 needed.</para> 2218 needed.</para>
2219 2219
2220 <para><varname>PKGINFODIR</varname> is the directory under 2220 <para><varname>PKGINFODIR</varname> is the directory under
2221 <filename>${PREFIX}</filename> where info files are primarily 2221 <filename>${PREFIX}</filename> where info files are primarily
2222 located. <varname>PKGINFODIR</varname> defaults to 2222 located. <varname>PKGINFODIR</varname> defaults to
2223 <quote>info</quote> and can be overridden by the user.</para> 2223 <quote>info</quote> and can be overridden by the user.</para>
2224 2224
2225 <para>The info files for the package should be listed in the 2225 <para>The info files for the package should be listed in the
2226 package <filename>PLIST</filename>; however any split info files 2226 package <filename>PLIST</filename>; however any split info files
2227 need not be listed.</para> 2227 need not be listed.</para>
2228 2228
2229 <para>A package which needs the <quote>makeinfo</quote> command 2229 <para>A package which needs the <quote>makeinfo</quote> command
2230 at build time must add <quote>makeinfo</quote> to 2230 at build time must add <quote>makeinfo</quote> to
2231 <varname>USE_TOOLS</varname> in its Makefile. If a minimum 2231 <varname>USE_TOOLS</varname> in its Makefile. If a minimum
2232 version of the <quote>makeinfo</quote> command is needed it 2232 version of the <quote>makeinfo</quote> command is needed it
2233 should be noted with the <varname>TEXINFO_REQD</varname> 2233 should be noted with the <varname>TEXINFO_REQD</varname>
2234 variable in the package <filename>Makefile</filename>. By 2234 variable in the package <filename>Makefile</filename>. By
2235 default, a minimum version of 3.12 is required. If the system 2235 default, a minimum version of 3.12 is required. If the system
2236 does not provide a <command>makeinfo</command> command or if it 2236 does not provide a <command>makeinfo</command> command or if it
2237 does not match the required minimum, a build dependency on the 2237 does not match the required minimum, a build dependency on the
2238 <filename role="pkg">devel/gtexinfo</filename> package will 2238 <filename role="pkg">devel/gtexinfo</filename> package will
2239 be added automatically.</para> 2239 be added automatically.</para>
2240 2240
2241 <para>The build and installation process of the software provided 2241 <para>The build and installation process of the software provided
2242 by the package should not use the 2242 by the package should not use the
2243 <command>install-info</command> command as the registration of 2243 <command>install-info</command> command as the registration of
2244 info files is the task of the package 2244 info files is the task of the package
2245 <filename>INSTALL</filename> script, and it must use the 2245 <filename>INSTALL</filename> script, and it must use the
2246 appropriate <command>makeinfo</command> command.</para> 2246 appropriate <command>makeinfo</command> command.</para>
2247 2247
2248 <para>To achieve this goal, the pkgsrc infrastructure creates 2248 <para>To achieve this goal, the pkgsrc infrastructure creates
2249 overriding scripts for the <command>install-info</command> and 2249 overriding scripts for the <command>install-info</command> and
2250 <command>makeinfo</command> commands in a directory listed early 2250 <command>makeinfo</command> commands in a directory listed early
2251 in <varname>PATH</varname>.</para> 2251 in <varname>PATH</varname>.</para>
2252 2252
2253 <para>The script overriding <command>install-info</command> has 2253 <para>The script overriding <command>install-info</command> has
2254 no effect except the logging of a message. The script overriding 2254 no effect except the logging of a message. The script overriding
2255 <command>makeinfo</command> logs a message and according to the 2255 <command>makeinfo</command> logs a message and according to the
2256 value of <varname>TEXINFO_REQD</varname> either runs the appropriate 2256 value of <varname>TEXINFO_REQD</varname> either runs the appropriate
2257 <command>makeinfo</command> command or exit on error.</para> 2257 <command>makeinfo</command> command or exit on error.</para>
2258 </sect2> 2258 </sect2>
2259 2259
2260 <sect2 id="manpages"> 2260 <sect2 id="manpages">
2261 <title>Packages installing man pages</title> 2261 <title>Packages installing man pages</title>
2262 2262
2263 <para>All packages that install manual pages should install them 2263 <para>All packages that install manual pages should install them
2264 into the same directory, so that there is one common place to look 2264 into the same directory, so that there is one common place to look
2265 for them. In pkgsrc, this place is 2265 for them. In pkgsrc, this place is
2266 <literal>${PREFIX}/${PKGMANDIR}</literal>, and this expression 2266 <literal>${PREFIX}/${PKGMANDIR}</literal>, and this expression
2267 should be used in packages. The default for 2267 should be used in packages. The default for
2268 <varname>PKGMANDIR</varname> is 2268 <varname>PKGMANDIR</varname> is
2269 <quote><filename>man</filename></quote>. Another often-used value 2269 <quote><filename>man</filename></quote>. Another often-used value
2270 is <quote><filename>share/man</filename></quote>.</para> 2270 is <quote><filename>share/man</filename></quote>.</para>
2271 2271
2272 <note><para>The support for a custom <varname>PKGMANDIR</varname> 2272 <note><para>The support for a custom <varname>PKGMANDIR</varname>
2273 is far from complete.</para></note> 2273 is far from complete.</para></note>
2274 2274
2275 <para>The <filename>PLIST</filename> files can just use 2275 <para>The <filename>PLIST</filename> files can just use
2276 <filename>man/</filename> as the top level directory for the man 2276 <filename>man/</filename> as the top level directory for the man
2277 page file entries, and the pkgsrc framework will convert as 2277 page file entries, and the pkgsrc framework will convert as
2278 needed. In all other places, the correct 2278 needed. In all other places, the correct
2279 <varname>PKGMANDIR</varname> must be used.</para> 2279 <varname>PKGMANDIR</varname> must be used.</para>
2280 2280
2281 <para>Packages that are 2281 <para>Packages that are
2282 configured with <varname>GNU_CONFIGURE</varname> set as 2282 configured with <varname>GNU_CONFIGURE</varname> set as
2283 <quote>yes</quote>, by default will use the 2283 <quote>yes</quote>, by default will use the
2284 <filename>./configure</filename> 2284 <filename>./configure</filename>
2285 --mandir switch to set where the man pages should be installed. 2285 --mandir switch to set where the man pages should be installed.
2286 The path is <varname>GNU_CONFIGURE_MANDIR</varname> which defaults 2286 The path is <varname>GNU_CONFIGURE_MANDIR</varname> which defaults
2287 to <varname>${PREFIX}/${PKGMANDIR}</varname>.</para> 2287 to <varname>${PREFIX}/${PKGMANDIR}</varname>.</para>
2288 2288
2289 <para>Packages that use <varname>GNU_CONFIGURE</varname> but do not 2289 <para>Packages that use <varname>GNU_CONFIGURE</varname> but do not
2290 use --mandir, can set <varname>CONFIGURE_HAS_MANDIR</varname> 2290 use --mandir, can set <varname>CONFIGURE_HAS_MANDIR</varname>
2291 to <quote>no</quote>. 2291 to <quote>no</quote>.
2292 Or if the <filename>./configure</filename> script uses 2292 Or if the <filename>./configure</filename> script uses
2293 a non-standard use of --mandir, you can set 2293 a non-standard use of --mandir, you can set
2294 <varname>GNU_CONFIGURE_MANDIR</varname> as needed.</para> 2294 <varname>GNU_CONFIGURE_MANDIR</varname> as needed.</para>
2295 2295
2296 <para>See <xref linkend="manpage-compression"/> for 2296 <para>See <xref linkend="manpage-compression"/> for
2297 information on installation of compressed manual pages.</para> 2297 information on installation of compressed manual pages.</para>
2298 2298
2299 </sect2> 2299 </sect2>
2300 2300
2301 <sect2 id="x11-fonts"> 2301 <sect2 id="x11-fonts">
2302 <title>Packages installing X11 fonts</title> 2302 <title>Packages installing X11 fonts</title>
2303 2303
2304 <para>If a package installs font files, you will need to rebuild 2304 <para>If a package installs font files, you will need to rebuild
2305 the fonts database in the directory where they get installed at 2305 the fonts database in the directory where they get installed at
2306 installation and deinstallation time. This can be automatically 2306 installation and deinstallation time. This can be automatically
2307 done by using the pkginstall framework.</para> 2307 done by using the pkginstall framework.</para>
2308 2308
2309 <para>You can list the directories where fonts are installed in the 2309 <para>You can list the directories where fonts are installed in the
2310 <varname>FONTS_DIRS.<replaceable>type</replaceable></varname> 2310 <varname>FONTS_DIRS.<replaceable>type</replaceable></varname>
2311 variables, where <replaceable>type</replaceable> can be one of 2311 variables, where <replaceable>type</replaceable> can be one of
2312 <quote>ttf</quote>, <quote>type1</quote> or <quote>x11</quote>. 2312 <quote>ttf</quote>, <quote>type1</quote> or <quote>x11</quote>.
2313 Also make sure that the database file 2313 Also make sure that the database file
2314 <filename>fonts.dir</filename> is not listed in the PLIST.</para> 2314 <filename>fonts.dir</filename> is not listed in the PLIST.</para>
2315 2315
2316 <para>Note that you should not create new directories for fonts; 2316 <para>Note that you should not create new directories for fonts;
2317 instead use the standard ones to avoid that the user needs to 2317 instead use the standard ones to avoid that the user needs to
2318 manually configure his X server to find them.</para> 2318 manually configure his X server to find them.</para>
2319 </sect2> 2319 </sect2>
2320 2320
2321 <sect2 id="sgml-xml-data"> 2321 <sect2 id="sgml-xml-data">
2322 <title>Packages installing SGML or XML data</title> 2322 <title>Packages installing SGML or XML data</title>
2323 2323
2324 <para>If a package installs SGML or XML data files that need to be 2324 <para>If a package installs SGML or XML data files that need to be
2325 registered in system-wide catalogs (like DTDs, sub-catalogs, 2325 registered in system-wide catalogs (like DTDs, sub-catalogs,
2326 etc.), you need to take some extra steps:</para> 2326 etc.), you need to take some extra steps:</para>
2327 2327
2328 <orderedlist> 2328 <orderedlist>
2329 <listitem> 2329 <listitem>
2330 <para>Include 2330 <para>Include
2331 <filename>../../textproc/xmlcatmgr/catalogs.mk</filename> in 2331 <filename>../../textproc/xmlcatmgr/catalogs.mk</filename> in
2332 your <filename>Makefile</filename>, which takes care of 2332 your <filename>Makefile</filename>, which takes care of
2333 registering those files in system-wide catalogs at 2333 registering those files in system-wide catalogs at
2334 installation and deinstallation time.</para> 2334 installation and deinstallation time.</para>
2335 </listitem> 2335 </listitem>
2336 2336
2337 <listitem> 2337 <listitem>
2338 <para>Set <varname>SGML_CATALOGS</varname> to the full path of 2338 <para>Set <varname>SGML_CATALOGS</varname> to the full path of
2339 any SGML catalogs installed by the package.</para> 2339 any SGML catalogs installed by the package.</para>
2340 </listitem> 2340 </listitem>
2341 2341
2342 <listitem> 2342 <listitem>
2343 <para>Set <varname>XML_CATALOGS</varname> to the full path of 2343 <para>Set <varname>XML_CATALOGS</varname> to the full path of
2344 any XML catalogs installed by the package.</para> 2344 any XML catalogs installed by the package.</para>
2345 </listitem> 2345 </listitem>
2346 2346
2347 <listitem> 2347 <listitem>
2348 <para>Set <varname>SGML_ENTRIES</varname> to individual entries 2348 <para>Set <varname>SGML_ENTRIES</varname> to individual entries
2349 to be added to the SGML catalog. These come in groups of 2349 to be added to the SGML catalog. These come in groups of
2350 three strings; see xmlcatmgr(1) for more information 2350 three strings; see xmlcatmgr(1) for more information
2351 (specifically, arguments recognized by the 'add' action). 2351 (specifically, arguments recognized by the 'add' action).
2352 Note that you will normally not use this variable.</para> 2352 Note that you will normally not use this variable.</para>
2353 </listitem> 2353 </listitem>
2354 2354
2355 <listitem> 2355 <listitem>
2356 <para>Set <varname>XML_ENTRIES</varname> to individual entries 2356 <para>Set <varname>XML_ENTRIES</varname> to individual entries
2357 to be added to the XML catalog. These come in groups of three 2357 to be added to the XML catalog. These come in groups of three
2358 strings; see xmlcatmgr(1) for more information (specifically, 2358 strings; see xmlcatmgr(1) for more information (specifically,
2359 arguments recognized by the 'add' action). Note that you will 2359 arguments recognized by the 'add' action). Note that you will
2360 normally not use this variable.</para> 2360 normally not use this variable.</para>
2361 </listitem> 2361 </listitem>
2362 </orderedlist> 2362 </orderedlist>
2363 </sect2> 2363 </sect2>
2364 2364
2365 2365
2366 <sect2 id="mime-database"> 2366 <sect2 id="mime-database">
2367 <title>Packages installing extensions to the MIME database</title> 2367 <title>Packages installing extensions to the MIME database</title>
2368 2368
2369 <para>If a package provides extensions to the MIME database by 2369 <para>If a package provides extensions to the MIME database by
2370 installing <filename>.xml</filename> files inside 2370 installing <filename>.xml</filename> files inside
2371 <filename>${PREFIX}/share/mime/packages</filename>, you 2371 <filename>${PREFIX}/share/mime/packages</filename>, you
2372 need to take some extra steps to ensure that the database is kept 2372 need to take some extra steps to ensure that the database is kept
2373 consistent with respect to these new files:</para> 2373 consistent with respect to these new files:</para>
2374 2374
2375 <orderedlist> 2375 <orderedlist>
2376 <listitem> 2376 <listitem>
2377 <para>Include 2377 <para>Include
2378 <filename>../../databases/shared-mime-info/mimedb.mk</filename> 2378 <filename>../../databases/shared-mime-info/mimedb.mk</filename>
2379 (avoid using the <filename>buildlink3.mk</filename> file from 2379 (avoid using the <filename>buildlink3.mk</filename> file from
2380 this same directory, which is reserved for inclusion from 2380 this same directory, which is reserved for inclusion from
2381 other <filename>buildlink3.mk</filename> files). It takes 2381 other <filename>buildlink3.mk</filename> files). It takes
2382 care of rebuilding the MIME database at installation and 2382 care of rebuilding the MIME database at installation and
2383 deinstallation time, and disallows any access to it directly 2383 deinstallation time, and disallows any access to it directly
2384 from the package.</para> 2384 from the package.</para>
2385 </listitem> 2385 </listitem>
2386 2386
2387 <listitem> 2387 <listitem>
2388 <para>Check the PLIST and remove any entries under the 2388 <para>Check the PLIST and remove any entries under the
2389 <filename>share/mime</filename> directory, 2389 <filename>share/mime</filename> directory,
2390 <emphasis>except</emphasis> for files saved under 2390 <emphasis>except</emphasis> for files saved under
2391 <filename>share/mime/packages</filename>. The former are 2391 <filename>share/mime/packages</filename>. The former are
2392 handled automatically by 2392 handled automatically by
2393 the update-mime-database program, but the latter are 2393 the update-mime-database program, but the latter are
2394 package-dependent and must be removed by the package that 2394 package-dependent and must be removed by the package that
2395 installed them in the first place.</para> 2395 installed them in the first place.</para>
2396 </listitem> 2396 </listitem>
2397 2397
2398 <listitem> 2398 <listitem>
2399 <para>Remove any <filename>share/mime/*</filename> directories 2399 <para>Remove any <filename>share/mime/*</filename> directories
2400 from the PLIST. They will be handled by the shared-mime-info 2400 from the PLIST. They will be handled by the shared-mime-info
2401 package.</para> 2401 package.</para>
2402 </listitem> 2402 </listitem>
2403 </orderedlist> 2403 </orderedlist>
2404 </sect2> 2404 </sect2>
2405 2405
2406 2406
2407 <sect2 id="intltool"> 2407 <sect2 id="intltool">
2408 <title>Packages using intltool</title> 2408 <title>Packages using intltool</title>
2409 2409
2410 <para>If a package uses intltool during its build, add 2410 <para>If a package uses intltool during its build, add
2411 <literal>intltool</literal> to the <varname>USE_TOOLS</varname>, 2411 <literal>intltool</literal> to the <varname>USE_TOOLS</varname>,
2412 which forces it to use the intltool package provided by pkgsrc, 2412 which forces it to use the intltool package provided by pkgsrc,
2413 instead of the one bundled with the distribution file.</para> 2413 instead of the one bundled with the distribution file.</para>
2414 2414
2415 <para>This tracks intltool's build-time dependencies and uses the 2415 <para>This tracks intltool's build-time dependencies and uses the
2416 latest available version; this way, the package benefits of any 2416 latest available version; this way, the package benefits of any
2417 bug fixes that may have appeared since it was released.</para> 2417 bug fixes that may have appeared since it was released.</para>
2418 </sect2> 2418 </sect2>
2419 2419
2420 2420
2421 <sect2 id="startup-scripts"> 2421 <sect2 id="startup-scripts">
2422 <title>Packages installing startup scripts</title> 2422 <title>Packages installing startup scripts</title>
2423 <para>If a package contains a rc.d script, it won't be copied into 2423 <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 2424 the startup directory by default, but you can enable it, by adding
2425 the option <varname>PKG_RCD_SCRIPTS=YES</varname> in 2425 the option <varname>PKG_RCD_SCRIPTS=YES</varname> in
2426 &mk.conf;. This option will copy the scripts 2426 &mk.conf;. This option will copy the scripts
2427 into <filename>/etc/rc.d</filename> when a package is installed, and 2427 into <filename>/etc/rc.d</filename> when a package is installed, and
2428 it will automatically remove the scripts when the package is 2428 it will automatically remove the scripts when the package is
2429 deinstalled.</para> 2429 deinstalled.</para>
2430 </sect2> 2430 </sect2>
2431 2431
2432 <sect2 id="tex-packages"> 2432 <sect2 id="tex-packages">
2433 <title>Packages installing TeX modules</title> 2433 <title>Packages installing TeX modules</title>
2434 2434
2435 <para>If a package installs TeX packages into the texmf tree, 2435 <para>If a package installs TeX packages into the texmf tree,
2436 the <filename>ls-R</filename> database of the tree needs to be 2436 the <filename>ls-R</filename> database of the tree needs to be
2437 updated.</para> 2437 updated.</para>
2438 <note><para>Except the main TeX packages such as kpathsea, 2438 <note><para>Except the main TeX packages such as kpathsea,
2439 packages should install files 2439 packages should install files
2440 into <filename>${PREFIX}/share/texmf-dist</filename>, 2440 into <filename>${PREFIX}/share/texmf-dist</filename>,
2441 not <filename>${PREFIX}/share/texmf</filename>.</para></note> 2441 not <filename>${PREFIX}/share/texmf</filename>.</para></note>
2442 2442
2443 <orderedlist> 2443 <orderedlist>
2444 <listitem><para>Include 2444 <listitem><para>Include
2445 <filename>../../print/kpathsea/texmf.mk</filename>. This 2445 <filename>../../print/kpathsea/texmf.mk</filename>. This
2446 takes care of rebuilding the <filename>ls-R</filename> 2446 takes care of rebuilding the <filename>ls-R</filename>
2447 database at installation and deinstallation time.</para> 2447 database at installation and deinstallation time.</para>
2448 </listitem> 2448 </listitem>
2449 2449
2450 <listitem><para>If your package installs files into a texmf 2450 <listitem><para>If your package installs files into a texmf
2451 tree other than the one 2451 tree other than the one
2452 at <filename>${PREFIX}/share/texmf-dist</filename>, 2452 at <filename>${PREFIX}/share/texmf-dist</filename>,
2453 set <varname>TEX_TEXMF_DIRS</varname> to the list of all texmf 2453 set <varname>TEX_TEXMF_DIRS</varname> to the list of all texmf
2454 trees that need database update.</para> 2454 trees that need database update.</para>
2455 <para>If your package also installs font map files that need 2455 <para>If your package also installs font map files that need
2456 to be registered using <command>updmap</command>, 2456 to be registered using <command>updmap</command>,
2457 include <filename>../../print/tex-tetex/map.mk</filename> and 2457 include <filename>../../print/tex-tetex/map.mk</filename> and
2458 set <varname>TEX_MAP_FILES</varname> and/or 2458 set <varname>TEX_MAP_FILES</varname> and/or
2459 <varname>TEX_MIXEDMAP_FILES</varname> to the list of all 2459 <varname>TEX_MIXEDMAP_FILES</varname> to the list of all
2460 such font map files. Then <command>updmap</command> will 2460 such font map files. Then <command>updmap</command> will

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

--- pkgsrc/mk/compiler.mk 2023/07/18 12:49:46 1.100
+++ pkgsrc/mk/compiler.mk 2023/07/21 08:29:56 1.101
@@ -1,328 +1,329 @@ @@ -1,328 +1,329 @@
1# $NetBSD: compiler.mk,v 1.100 2023/07/18 12:49:46 nia Exp $ 1# $NetBSD: compiler.mk,v 1.101 2023/07/21 08:29:56 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# 86#
86# The following variables are defined, and available for testing in 87# The following variables are defined, and available for testing in
87# package Makefiles: 88# package Makefiles:
88# 89#
89# CC_VERSION 90# CC_VERSION
90# The compiler and version being used, e.g., 91# The compiler and version being used, e.g.,
91# 92#
92# .include "../../mk/compiler.mk" 93# .include "../../mk/compiler.mk"
93# 94#
94# .if !empty(CC_VERSION:Mgcc-3*) 95# .if !empty(CC_VERSION:Mgcc-3*)
95# ... 96# ...
96# .endif 97# .endif
97# 98#
98# Keywords: compiler 99# Keywords: compiler
99 100
100.if !defined(BSD_COMPILER_MK) 101.if !defined(BSD_COMPILER_MK)
101BSD_COMPILER_MK= defined 102BSD_COMPILER_MK= defined
102 103
103_VARGROUPS+= compiler 104_VARGROUPS+= compiler
104_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
105_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
106_SYS_VARS.compiler= CC_VERSION 107_SYS_VARS.compiler= CC_VERSION
107 108
108.include "bsd.fast.prefs.mk" 109.include "bsd.fast.prefs.mk"
109 110
110# 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.
111USE_LANGUAGES?= c 112USE_LANGUAGES?= c
112 113
113_C_STD_VERSIONS= c99 gnu99 c11 gnu11 c17 gnu17 114_C_STD_VERSIONS= c99 gnu99 c11 gnu11 c17 gnu17
114.for _version_ in ${_C_STD_VERSIONS} 115.for _version_ in ${_C_STD_VERSIONS}
115. if !empty(USE_LANGUAGES:M${_version_}) 116. if !empty(USE_LANGUAGES:M${_version_})
116USE_LANGUAGES+= c 117USE_LANGUAGES+= c
117. endif 118. endif
118.endfor 119.endfor
119 120
120_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
121.for _version_ in ${_CXX_STD_VERSIONS} 122.for _version_ in ${_CXX_STD_VERSIONS}
122. if !empty(USE_LANGUAGES:M${_version_}) 123. if !empty(USE_LANGUAGES:M${_version_})
123USE_LANGUAGES+= c++ 124USE_LANGUAGES+= c++
124. endif 125. endif
125.endfor 126.endfor
126 127
127#.READONLY: USE_LANGUAGES 128#.READONLY: USE_LANGUAGES
128_USE_LANGUAGES_EFFECTIVE:= ${USE_LANGUAGES} 129_USE_LANGUAGES_EFFECTIVE:= ${USE_LANGUAGES}
129 130
130COMPILER_USE_SYMLINKS?= yes 131COMPILER_USE_SYMLINKS?= yes
131 132
132_COMPILERS= ccc clang gcc hp icc ido \ 133_COMPILERS= ccc clang gcc hp icc ido \
133 mipspro mipspro-ucode pcc sunpro xlc 134 mipspro mipspro-ucode pcc sunpro xlc
134_PSEUDO_COMPILERS= ccache distcc f2c g95 135_PSEUDO_COMPILERS= ccache distcc f2c g95
135 136
136.if defined(NOT_FOR_COMPILER) && !empty(NOT_FOR_COMPILER) 137.if defined(NOT_FOR_COMPILER) && !empty(NOT_FOR_COMPILER)
137. for _compiler_ in ${_COMPILERS} 138. for _compiler_ in ${_COMPILERS}
138. if ${NOT_FOR_COMPILER:M${_compiler_}} == "" 139. if ${NOT_FOR_COMPILER:M${_compiler_}} == ""
139_ACCEPTABLE_COMPILERS+= ${_compiler_} 140_ACCEPTABLE_COMPILERS+= ${_compiler_}
140. endif 141. endif
141. endfor 142. endfor
142.elif defined(ONLY_FOR_COMPILER) && !empty(ONLY_FOR_COMPILER) 143.elif defined(ONLY_FOR_COMPILER) && !empty(ONLY_FOR_COMPILER)
143. for _compiler_ in ${_COMPILERS} 144. for _compiler_ in ${_COMPILERS}
144. if ${ONLY_FOR_COMPILER:M${_compiler_}} != "" 145. if ${ONLY_FOR_COMPILER:M${_compiler_}} != ""
145_ACCEPTABLE_COMPILERS+= ${_compiler_} 146_ACCEPTABLE_COMPILERS+= ${_compiler_}
146. endif 147. endif
147. endfor 148. endfor
148.else 149.else
149_ACCEPTABLE_COMPILERS+= ${_COMPILERS} 150_ACCEPTABLE_COMPILERS+= ${_COMPILERS}
150.endif 151.endif
151 152
152# Currently only gcc-based compilers support Ada 153# Currently only gcc-based compilers support Ada
153# Override PKGSRC_COMPILER if Ada language specified 154# Override PKGSRC_COMPILER if Ada language specified
154.if !empty(USE_LANGUAGES:Mada) 155.if !empty(USE_LANGUAGES:Mada)
155PKGSRC_COMPILER= gcc 156PKGSRC_COMPILER= gcc
156.endif 157.endif
157 158
158.if defined(_ACCEPTABLE_COMPILERS) 159.if defined(_ACCEPTABLE_COMPILERS)
159. for _acceptable_ in ${_ACCEPTABLE_COMPILERS} 160. for _acceptable_ in ${_ACCEPTABLE_COMPILERS}
160. for _compiler_ in ${PKGSRC_COMPILER} 161. for _compiler_ in ${PKGSRC_COMPILER}
161. if !empty(_ACCEPTABLE_COMPILERS:M${_compiler_}) && !defined(_COMPILER) 162. if !empty(_ACCEPTABLE_COMPILERS:M${_compiler_}) && !defined(_COMPILER)
162_COMPILER= ${_compiler_} 163_COMPILER= ${_compiler_}
163. endif 164. endif
164. endfor 165. endfor
165. endfor 166. endfor
166.endif 167.endif
167 168
168.if !defined(_COMPILER) 169.if !defined(_COMPILER)
169PKG_FAIL_REASON+= "No acceptable compiler found for ${PKGNAME}." 170PKG_FAIL_REASON+= "No acceptable compiler found for ${PKGNAME}."
170.endif 171.endif
171 172
172.for _compiler_ in ${PKGSRC_COMPILER} 173.for _compiler_ in ${PKGSRC_COMPILER}
173. if !empty(_PSEUDO_COMPILERS:M${_compiler_}) 174. if !empty(_PSEUDO_COMPILERS:M${_compiler_})
174_PKGSRC_COMPILER:= ${_compiler_} ${_PKGSRC_COMPILER} 175_PKGSRC_COMPILER:= ${_compiler_} ${_PKGSRC_COMPILER}
175. endif 176. endif
176.endfor 177.endfor
177_PKGSRC_COMPILER:= ${_COMPILER} ${_PKGSRC_COMPILER} 178_PKGSRC_COMPILER:= ${_COMPILER} ${_PKGSRC_COMPILER}
178 179
179_COMPILER_STRIP_VARS= # empty 180_COMPILER_STRIP_VARS= # empty
180 181
181.for _compiler_ in ${_PKGSRC_COMPILER} 182.for _compiler_ in ${_PKGSRC_COMPILER}
182. include "compiler/${_compiler_}.mk" 183. include "compiler/${_compiler_}.mk"
183.endfor 184.endfor
184.undef _compiler_ 185.undef _compiler_
185 186
186.if !defined(PKG_CPP) 187.if !defined(PKG_CPP)
187PKG_CPP:=${CPP} 188PKG_CPP:=${CPP}
188.endif 189.endif
189 190
190# Ensure the Solaris linker is used by default. 191# Ensure the Solaris linker is used by default.
191.if ${OPSYS} == "SunOS" 192.if ${OPSYS} == "SunOS"
192. if exists(/usr/ccs/bin/ld) 193. if exists(/usr/ccs/bin/ld)
193PKG_LD?= /usr/ccs/bin/ld 194PKG_LD?= /usr/ccs/bin/ld
194. elif exists(/usr/bin/ld) 195. elif exists(/usr/bin/ld)
195PKG_LD?= /usr/bin/ld 196PKG_LD?= /usr/bin/ld
196. endif 197. endif
197.endif 198.endif
198 199
199# Strip the leading paths from the toolchain variables since we manipulate 200# Strip the leading paths from the toolchain variables since we manipulate
200# the PATH to use the correct executable. 201# the PATH to use the correct executable.
201# 202#
202.for _var_ in ${_COMPILER_STRIP_VARS} 203.for _var_ in ${_COMPILER_STRIP_VARS}
203. if empty(${_var_}:C/^/_asdf_/1:N_asdf_*) 204. if empty(${_var_}:C/^/_asdf_/1:N_asdf_*)
204${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T} 205${_var_}:= ${${_var_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//:T}
205. else 206. else
206${_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_*}
207. endif 208. endif
208.endfor 209.endfor
209 210
210# 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++
211# 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
212# all that come after it. 213# all that come after it.
213# 214#
214_C_VERSION_REQD= 215_C_VERSION_REQD=
215.for _version_ in ${_C_STD_VERSIONS} 216.for _version_ in ${_C_STD_VERSIONS}
216. if empty(_C_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_}) 217. if empty(_C_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_})
217_C_VERSION_REQD= ${_version_} 218_C_VERSION_REQD= ${_version_}
218_WRAP_EXTRA_ARGS.CC+= ${_C_STD_FLAG.${_C_VERSION_REQD}} 219_WRAP_EXTRA_ARGS.CC+= ${_C_STD_FLAG.${_C_VERSION_REQD}}
219CWRAPPERS_PREPEND.cc+= ${_C_STD_FLAG.${_C_VERSION_REQD}} 220CWRAPPERS_PREPEND.cc+= ${_C_STD_FLAG.${_C_VERSION_REQD}}
220. endif 221. endif
221.endfor 222.endfor
222 223
223_CXX_VERSION_REQD= 224_CXX_VERSION_REQD=
224.for _version_ in ${_CXX_STD_VERSIONS} 225.for _version_ in ${_CXX_STD_VERSIONS}
225. if empty(_CXX_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_}) 226. if empty(_CXX_VERSION_REQD) && !empty(USE_LANGUAGES:M${_version_})
226_CXX_VERSION_REQD= ${_version_} 227_CXX_VERSION_REQD= ${_version_}
227_WRAP_EXTRA_ARGS.CXX+= ${_CXX_STD_FLAG.${_CXX_VERSION_REQD}} 228_WRAP_EXTRA_ARGS.CXX+= ${_CXX_STD_FLAG.${_CXX_VERSION_REQD}}
228CWRAPPERS_PREPEND.cxx+= ${_CXX_STD_FLAG.${_CXX_VERSION_REQD}} 229CWRAPPERS_PREPEND.cxx+= ${_CXX_STD_FLAG.${_CXX_VERSION_REQD}}
229. endif 230. endif
230.endfor 231.endfor
231 232
232.if defined(ABI) && !empty(ABI) 233.if defined(ABI) && !empty(ABI)
233_WRAP_EXTRA_ARGS.CC+= ${_COMPILER_ABI_FLAG.${ABI}} 234_WRAP_EXTRA_ARGS.CC+= ${_COMPILER_ABI_FLAG.${ABI}}
234_WRAP_EXTRA_ARGS.CXX+= ${_COMPILER_ABI_FLAG.${ABI}} 235_WRAP_EXTRA_ARGS.CXX+= ${_COMPILER_ABI_FLAG.${ABI}}
235_WRAP_EXTRA_ARGS.FC+= ${_COMPILER_ABI_FLAG.${ABI}} 236_WRAP_EXTRA_ARGS.FC+= ${_COMPILER_ABI_FLAG.${ABI}}
236CWRAPPERS_PREPEND.cc+= ${_COMPILER_ABI_FLAG.${ABI}} 237CWRAPPERS_PREPEND.cc+= ${_COMPILER_ABI_FLAG.${ABI}}
237CWRAPPERS_PREPEND.cxx+= ${_COMPILER_ABI_FLAG.${ABI}} 238CWRAPPERS_PREPEND.cxx+= ${_COMPILER_ABI_FLAG.${ABI}}
238CWRAPPERS_PREPEND.f77+= ${_COMPILER_ABI_FLAG.${ABI}} 239CWRAPPERS_PREPEND.f77+= ${_COMPILER_ABI_FLAG.${ABI}}
239.endif 240.endif
240 241
241# 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.
242# 243#
243.if ${_PKGSRC_USE_SSP} == "yes" && defined(_SSP_CFLAGS) 244.if ${_PKGSRC_USE_SSP} == "yes" && defined(_SSP_CFLAGS)
244_WRAP_EXTRA_ARGS.CC+= ${_SSP_CFLAGS} 245_WRAP_EXTRA_ARGS.CC+= ${_SSP_CFLAGS}
245_WRAP_EXTRA_ARGS.CXX+= ${_SSP_CFLAGS} 246_WRAP_EXTRA_ARGS.CXX+= ${_SSP_CFLAGS}
246CWRAPPERS_APPEND.cc+= ${_SSP_CFLAGS} 247CWRAPPERS_APPEND.cc+= ${_SSP_CFLAGS}
247CWRAPPERS_APPEND.cxx+= ${_SSP_CFLAGS} 248CWRAPPERS_APPEND.cxx+= ${_SSP_CFLAGS}
248CWRAPPERS_APPEND.f77+= ${_SSP_CFLAGS} 249CWRAPPERS_APPEND.f77+= ${_SSP_CFLAGS}
249.endif 250.endif
250 251
251# 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.
252# 253#
253.if ${_PKGSRC_USE_CTF} == "yes" && defined(_CTF_CFLAGS) 254.if ${_PKGSRC_USE_CTF} == "yes" && defined(_CTF_CFLAGS)
254_WRAP_EXTRA_ARGS.CC+= ${_CTF_CFLAGS} 255_WRAP_EXTRA_ARGS.CC+= ${_CTF_CFLAGS}
255CWRAPPERS_APPEND.cc+= ${_CTF_CFLAGS} 256CWRAPPERS_APPEND.cc+= ${_CTF_CFLAGS}
256.endif 257.endif
257 258
258# Add sysroot if using cross-compilation tools. 259# Add sysroot if using cross-compilation tools.
259# 260#
260.if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS]) 261.if !empty(TOOLS_USE_CROSS_COMPILE:M[yY][eE][sS])
261CWRAPPERS_PREPEND.cc+= --sysroot=${TOOLS_CROSS_DESTDIR:Q} 262CWRAPPERS_PREPEND.cc+= --sysroot=${TOOLS_CROSS_DESTDIR:Q}
262CWRAPPERS_PREPEND.cxx+= --sysroot=${TOOLS_CROSS_DESTDIR:Q} 263CWRAPPERS_PREPEND.cxx+= --sysroot=${TOOLS_CROSS_DESTDIR:Q}
263CWRAPPERS_PREPEND.ld+= --sysroot=${TOOLS_CROSS_DESTDIR:Q} 264CWRAPPERS_PREPEND.ld+= --sysroot=${TOOLS_CROSS_DESTDIR:Q}
264# XXX cross fortran 265# XXX cross fortran
265.endif 266.endif
266 267
267# 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
268# in the generated wrappers. 269# in the generated wrappers.
269# 270#
270_FAIL_WRAPPER.CC= ${WRKDIR}/.compiler/bin/c-fail-wrapper 271_FAIL_WRAPPER.CC= ${WRKDIR}/.compiler/bin/c-fail-wrapper
271_FAIL_WRAPPER.CXX= ${WRKDIR}/.compiler/bin/c++-fail-wrapper 272_FAIL_WRAPPER.CXX= ${WRKDIR}/.compiler/bin/c++-fail-wrapper
272_FAIL_WRAPPER.FC= ${WRKDIR}/.compiler/bin/fortran-fail-wrapper 273_FAIL_WRAPPER.FC= ${WRKDIR}/.compiler/bin/fortran-fail-wrapper
273_FAIL_WRAPPER.ADA= ${WRKDIR}/.compiler/bin/ada-fail-wrapper 274_FAIL_WRAPPER.ADA= ${WRKDIR}/.compiler/bin/ada-fail-wrapper
274 275
275${_FAIL_WRAPPER.CC}: fail-wrapper 276${_FAIL_WRAPPER.CC}: fail-wrapper
276${_FAIL_WRAPPER.CXX}: fail-wrapper 277${_FAIL_WRAPPER.CXX}: fail-wrapper
277${_FAIL_WRAPPER.FC}: fail-wrapper 278${_FAIL_WRAPPER.FC}: fail-wrapper
278${_FAIL_WRAPPER.ADA}: fail-wrapper 279${_FAIL_WRAPPER.ADA}: fail-wrapper
279 280
280.PHONY: fail-wrapper 281.PHONY: fail-wrapper
281fail-wrapper: .USE 282fail-wrapper: .USE
282 ${RUN} \ 283 ${RUN} \
283 ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \ 284 ${TEST} -d ${.TARGET:H} || ${MKDIR} ${.TARGET:H}; \
284 exec 1>${.TARGET}; \ 285 exec 1>${.TARGET}; \
285 ${ECHO} '#!'${TOOLS_SHELL:Q}; \ 286 ${ECHO} '#!'${TOOLS_SHELL:Q}; \
286 ${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-'${_TOOLS_WRAP_LOG:Q}'}"'; \ 287 ${ECHO} 'wrapperlog="$${TOOLS_WRAPPER_LOG-'${_TOOLS_WRAP_LOG:Q}'}"'; \
287 ${ECHO} 'lang="${.TARGET:T:S/-fail-wrapper//}"'; \ 288 ${ECHO} 'lang="${.TARGET:T:S/-fail-wrapper//}"'; \
288 ${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."'; \
289 ${ECHO} '${ECHO} "$$msg" >> $$wrapperlog'; \ 290 ${ECHO} '${ECHO} "$$msg" >> $$wrapperlog'; \
290 ${ECHO} '${ECHO} "$$msg" > ${WARNING_DIR}/${.TARGET:T}'; \ 291 ${ECHO} '${ECHO} "$$msg" > ${WARNING_DIR}/${.TARGET:T}'; \
291 ${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'; \
292 ${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'; \
293 ${ECHO} 'exit 1'; \ 294 ${ECHO} 'exit 1'; \
294 ${CHMOD} +x ${.TARGET} 295 ${CHMOD} +x ${.TARGET}
295 296
296.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++)
297PKG_CC:= ${_FAIL_WRAPPER.CC} 298PKG_CC:= ${_FAIL_WRAPPER.CC}
298ALL_ENV+= CPP=${CPP:Q} 299ALL_ENV+= CPP=${CPP:Q}
299override-tools: ${_FAIL_WRAPPER.CC} 300override-tools: ${_FAIL_WRAPPER.CC}
300.endif 301.endif
301.if empty(USE_LANGUAGES:Mc++) 302.if empty(USE_LANGUAGES:Mc++)
302PKG_CXX:= ${_FAIL_WRAPPER.CXX} 303PKG_CXX:= ${_FAIL_WRAPPER.CXX}
303ALL_ENV+= CXXCPP=${CPP:Q} # to make some Autoconf scripts happy 304ALL_ENV+= CXXCPP=${CPP:Q} # to make some Autoconf scripts happy
304override-tools: ${_FAIL_WRAPPER.CXX} 305override-tools: ${_FAIL_WRAPPER.CXX}
305.endif 306.endif
306.if empty(USE_LANGUAGES:Mfortran) && empty(USE_LANGUAGES:Mfortran77) 307.if empty(USE_LANGUAGES:Mfortran) && empty(USE_LANGUAGES:Mfortran77)
307PKG_FC:= ${_FAIL_WRAPPER.FC} 308PKG_FC:= ${_FAIL_WRAPPER.FC}
308override-tools: ${_FAIL_WRAPPER.FC} 309override-tools: ${_FAIL_WRAPPER.FC}
309.endif 310.endif
310.if empty(USE_LANGUAGES:Mada) 311.if empty(USE_LANGUAGES:Mada)
311PKG_ADA:= ${_FAIL_WRAPPER.ADA} 312PKG_ADA:= ${_FAIL_WRAPPER.ADA}
312override-tools: ${_FAIL_WRAPPER.ADA} 313override-tools: ${_FAIL_WRAPPER.ADA}
313.endif 314.endif
314 315
315.if !empty(DRAGONFLY_CCVER) && ${OPSYS} == "DragonFly" 316.if !empty(DRAGONFLY_CCVER) && ${OPSYS} == "DragonFly"
316ALL_ENV+= CCVER=${DRAGONFLY_CCVER} 317ALL_ENV+= CCVER=${DRAGONFLY_CCVER}
317.endif 318.endif
318 319
319.endif # BSD_COMPILER_MK 320.endif # BSD_COMPILER_MK
320 321
321.if ${CHECK_COMPILER:Uno:tl} == yes 322.if ${CHECK_COMPILER:Uno:tl} == yes
322. if ${USE_LANGUAGES:O:u} != ${_USE_LANGUAGES_EFFECTIVE:O:u} 323. if ${USE_LANGUAGES:O:u} != ${_USE_LANGUAGES_EFFECTIVE:O:u}
323.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.
324. endif 325. endif
325. 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}
326.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.
327. endif 328. endif
328.endif 329.endif

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

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